@@ -2,7 +2,8 @@ import { BaseModule } from '../base-module';
2
2
import { createApiKeyMissingError } from '../../core/sdk-exceptions' ;
3
3
import { post , get } from '../../utils/rest' ;
4
4
import { generateIssuerFromPublicAddress } from '../../utils/issuer' ;
5
- import { MagicUserMetadata } from '../../types' ;
5
+ import { MagicUserMetadata , MagicWallet } from '../../types' ;
6
+ import { WalletType } from '../../types/wallet-types' ;
6
7
7
8
export class UsersModule extends BaseModule {
8
9
// --- User logout endpoints
@@ -26,6 +27,33 @@ export class UsersModule extends BaseModule {
26
27
// --- User metadata endpoints
27
28
28
29
public async getMetadataByIssuer ( issuer : string ) : Promise < MagicUserMetadata > {
30
+ return this . getMetadataByIssuerAndWallet ( issuer , WalletType . NONE ) ;
31
+ }
32
+
33
+ public async getMetadataByToken ( DIDToken : string ) : Promise < MagicUserMetadata > {
34
+ const issuer = this . sdk . token . getIssuer ( DIDToken ) ;
35
+ return this . getMetadataByIssuer ( issuer ) ;
36
+ }
37
+
38
+ public async getMetadataByPublicAddress ( publicAddress : string ) : Promise < MagicUserMetadata > {
39
+ const issuer = generateIssuerFromPublicAddress ( publicAddress ) ;
40
+ return this . getMetadataByIssuer ( issuer ) ;
41
+ }
42
+
43
+ public async getMetadataByTokenAndWallet ( DIDToken : string , walletType : WalletType ) : Promise < MagicUserMetadata > {
44
+ const issuer = this . sdk . token . getIssuer ( DIDToken ) ;
45
+ return this . getMetadataByIssuerAndWallet ( issuer , walletType ) ;
46
+ }
47
+
48
+ public async getMetadataByPublicAddressAndWallet (
49
+ publicAddress : string ,
50
+ walletType : WalletType ,
51
+ ) : Promise < MagicUserMetadata > {
52
+ const issuer = generateIssuerFromPublicAddress ( publicAddress ) ;
53
+ return this . getMetadataByIssuerAndWallet ( issuer , walletType ) ;
54
+ }
55
+
56
+ public async getMetadataByIssuerAndWallet ( issuer : string , walletType : WalletType ) : Promise < MagicUserMetadata > {
29
57
if ( ! this . sdk . secretApiKey ) throw createApiKeyMissingError ( ) ;
30
58
31
59
const data = await get < {
@@ -34,24 +62,16 @@ export class UsersModule extends BaseModule {
34
62
email : string | null ;
35
63
oauth_provider : string | null ;
36
64
phone_number : string | null ;
37
- } > ( `${ this . sdk . apiBaseUrl } /v1/admin/auth/user/get` , this . sdk . secretApiKey , { issuer } ) ;
65
+ wallets : MagicWallet [ ] | null ;
66
+ } > ( `${ this . sdk . apiBaseUrl } /v1/admin/auth/user/get?wallet_type=${ walletType } ` , this . sdk . secretApiKey , { issuer } ) ;
38
67
39
68
return {
40
69
issuer : data . issuer ?? null ,
41
70
publicAddress : data . public_address ?? null ,
42
71
email : data . email ?? null ,
43
72
oauthProvider : data . oauth_provider ?? null ,
44
73
phoneNumber : data . phone_number ?? null ,
74
+ wallets : data . wallets ?? null ,
45
75
} ;
46
76
}
47
-
48
- public async getMetadataByToken ( DIDToken : string ) : Promise < MagicUserMetadata > {
49
- const issuer = this . sdk . token . getIssuer ( DIDToken ) ;
50
- return this . getMetadataByIssuer ( issuer ) ;
51
- }
52
-
53
- public async getMetadataByPublicAddress ( publicAddress : string ) : Promise < MagicUserMetadata > {
54
- const issuer = generateIssuerFromPublicAddress ( publicAddress ) ;
55
- return this . getMetadataByIssuer ( issuer ) ;
56
- }
57
77
}
0 commit comments