Skip to content

Commit 1e70e7e

Browse files
authored
Merge pull request #127 from magiclabs/PDEEXP-856-Add-WebAuthn-Metadata
feat: add username data field to metadata call response
2 parents cd6661f + 777ac94 commit 1e70e7e

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/modules/users/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class UsersModule extends BaseModule {
6161
email: string | null;
6262
oauth_provider: string | null;
6363
phone_number: string | null;
64+
username: string | null;
6465
wallets: MagicWallet[] | null;
6566
}>(`${this.sdk.apiBaseUrl}/v1/admin/auth/user/get`, this.sdk.secretApiKey, { issuer, wallet_type: walletType });
6667

@@ -70,6 +71,7 @@ export class UsersModule extends BaseModule {
7071
email: data.email ?? null,
7172
oauthProvider: data.oauth_provider ?? null,
7273
phoneNumber: data.phone_number ?? null,
74+
username: data.username ?? null,
7375
wallets: data.wallets ?? null,
7476
};
7577
}

src/types/sdk-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ export interface MagicUserMetadata {
1515
email: string | null;
1616
oauthProvider: string | null;
1717
phoneNumber: string | null;
18+
username: string | null;
1819
wallets: MagicWallet[] | null;
1920
}

test/spec/modules/users/getMetadataByIssuer.spec.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
import { createMagicAdminSDK } from '../../../lib/factories';
2-
import { API_KEY } from '../../../lib/constants';
31
import { createApiKeyMissingError } from '../../../../src/core/sdk-exceptions';
4-
import { get } from '../../../../src/utils/rest';
52
import { WalletType } from '../../../../src/types/wallet-types';
3+
import { get } from '../../../../src/utils/rest';
4+
import { API_KEY } from '../../../lib/constants';
5+
import { createMagicAdminSDK } from '../../../lib/factories';
66

77
const successRes = Promise.resolve({
88
issuer: 'foo',
99
public_address: 'bar',
1010
email: 'baz',
1111
oauth_provider: 'foo1',
1212
phone_number: '+1234',
13+
username: 'buzz',
1314
});
1415
const successResWithWallets = Promise.resolve({
1516
issuer: 'foo',
1617
public_address: 'bar',
1718
email: 'baz',
1819
oauth_provider: 'foo1',
1920
phone_number: '+1234',
21+
username: 'buzz',
2022
wallets: [
2123
{
2224
wallet_type: 'SOLANA',
2325
network: 'MAINNET',
24-
public_address: 'barxyz'
25-
}
26-
]
26+
public_address: 'barxyz',
27+
},
28+
],
2729
});
2830
const nullRes = Promise.resolve({});
2931

@@ -35,18 +37,22 @@ test('Successfully GETs to metadata endpoint via issuer', async () => {
3537

3638
const result = await sdk.users.getMetadataByIssuer('did:ethr:0x1234');
3739

40+
console.log(result);
41+
3842
const getArguments = getStub.mock.calls[0];
3943
expect(getArguments).toEqual([
4044
'https://example.com/v1/admin/auth/user/get',
4145
API_KEY,
42-
{ issuer: 'did:ethr:0x1234', wallet_type: 'NONE'},
46+
{ issuer: 'did:ethr:0x1234', wallet_type: 'NONE' },
4347
]);
48+
4449
expect(result).toEqual({
4550
issuer: 'foo',
4651
publicAddress: 'bar',
4752
email: 'baz',
4853
oauthProvider: 'foo1',
4954
phoneNumber: '+1234',
55+
username: 'buzz',
5056
wallets: null,
5157
});
5258
});
@@ -71,6 +77,7 @@ test('Successfully GETs `null` metadata endpoint via issuer', async () => {
7177
email: null,
7278
oauthProvider: null,
7379
phoneNumber: null,
80+
username: null,
7481
wallets: null,
7582
});
7683
});
@@ -108,10 +115,13 @@ test('Successfully GETs to metadata endpoint via issuer and wallet type', async
108115
email: 'baz',
109116
oauthProvider: 'foo1',
110117
phoneNumber: '+1234',
111-
wallets: [{
112-
wallet_type: 'SOLANA',
113-
network: 'MAINNET',
114-
public_address: 'barxyz'
115-
}],
118+
username: 'buzz',
119+
wallets: [
120+
{
121+
wallet_type: 'SOLANA',
122+
network: 'MAINNET',
123+
public_address: 'barxyz',
124+
},
125+
],
116126
});
117-
});
127+
});

0 commit comments

Comments
 (0)