@@ -108,7 +108,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
108
108
organizationId ?: string ;
109
109
} ) : Promise < SdkApiTypes . TCreateReadOnlySessionResponse > => {
110
110
const readOnlySessionResult = await this . createReadOnlySession (
111
- config || { } ,
111
+ config || { }
112
112
) ;
113
113
await saveSession ( readOnlySessionResult , this . authClient ) ;
114
114
@@ -128,12 +128,12 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
128
128
refereshSession = async (
129
129
sessionType : SessionType = SessionType . READ_WRITE ,
130
130
targetPublicKey ?: string , // TODO: eventually we want to automatically pull this from localStorage/iframe
131
- expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS ,
131
+ expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS
132
132
) : Promise < void > => {
133
133
if ( sessionType === SessionType . READ_ONLY ) {
134
134
if ( this ! instanceof TurnkeyPasskeyClient ) {
135
135
throw new Error (
136
- "You must use a passkey client to refresh a read session" ,
136
+ "You must use a passkey client to refresh a read session"
137
137
) ; // TODO: support wallet clients perhaps?
138
138
}
139
139
const readOnlySessionResult = await this . createReadOnlySession ( { } ) ;
@@ -150,7 +150,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
150
150
if ( sessionType === SessionType . READ_WRITE ) {
151
151
if ( ! targetPublicKey ) {
152
152
throw new Error (
153
- "You must provide a targetPublicKey to refresh a read-write session." ,
153
+ "You must provide a targetPublicKey to refresh a read-write session."
154
154
) ;
155
155
}
156
156
const readWriteSessionResult = await this . createReadWriteSession ( {
@@ -170,7 +170,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
170
170
} else {
171
171
// Throw an error if the client is not an iframe client
172
172
throw new Error (
173
- "You must use an iframe client to refresh a read-write session" ,
173
+ "You must use an iframe client to refresh a read-write session"
174
174
) ; //should we default to a "localStorage" client?
175
175
}
176
176
await storeSession ( session , AuthClient . Iframe ) ;
@@ -187,14 +187,14 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
187
187
*/
188
188
loginWithBundle = async (
189
189
bundle : string , // we need a way to get the expiry of this token. Either it lives in the token itself or is returned from the server action and passed again here
190
- expirationSeconds : string , // we need a way to get the expiry of this token. Either it lives in the token itself or is returned from the server action and passed again here
190
+ expirationSeconds : string // we need a way to get the expiry of this token. Either it lives in the token itself or is returned from the server action and passed again here
191
191
) : Promise < void > => {
192
192
if ( this ! instanceof TurnkeyIframeClient ) {
193
193
await this . injectCredentialBundle ( bundle ) ;
194
194
} else {
195
195
// Throw an error if the client is not an iframe client
196
196
throw new Error (
197
- "You must use an iframe client to log in with a session." ,
197
+ "You must use an iframe client to log in with a session."
198
198
) ; //should we default to a "localStorage" client?
199
199
}
200
200
const whoAmI = await this . getWhoami ( ) ;
@@ -215,15 +215,15 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
215
215
* To be used in conjunction with an `iframeStamper`.
216
216
*
217
217
* @param session
218
- * @returns {Promise<SdkApiTypes. void> }
218
+ * @returns {Promise<void> }
219
219
*/
220
220
loginWithSession = async ( session : Session ) : Promise < void > => {
221
221
if ( this instanceof TurnkeyIframeClient ) {
222
222
await this . injectCredentialBundle ( session . token ! ) ;
223
223
} else {
224
224
// Throw an error if the client is not an iframe client
225
225
throw new Error (
226
- "You must use an iframe client to log in with a session." ,
226
+ "You must use an iframe client to log in with a session."
227
227
) ; //should we default to a "localStorage" client?
228
228
}
229
229
await storeSession ( session , AuthClient . Iframe ) ;
@@ -240,8 +240,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
240
240
sessionType : SessionType = SessionType . READ_WRITE ,
241
241
iframeClient : TurnkeyIframeClient ,
242
242
targetPublicKey ?: string , // TODO: eventually we want to automatically pull this from localStorage/iframe
243
-
244
- expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS ,
243
+ expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS
245
244
) : Promise < void > => {
246
245
// Create a read-only session
247
246
if ( sessionType === SessionType . READ_ONLY ) {
@@ -261,7 +260,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
261
260
if ( sessionType === SessionType . READ_WRITE ) {
262
261
if ( ! targetPublicKey ) {
263
262
throw new Error (
264
- "You must provide a targetPublicKey to create a read-write session." ,
263
+ "You must provide a targetPublicKey to create a read-write session."
265
264
) ;
266
265
}
267
266
@@ -280,7 +279,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
280
279
281
280
if ( ! iframeClient ) {
282
281
throw new Error (
283
- "You must provide an iframe client to log in with a passkey." ,
282
+ "You must provide an iframe client to log in with a passkey."
284
283
) ;
285
284
}
286
285
await iframeClient . injectCredentialBundle ( session . token ! ) ;
@@ -304,7 +303,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
304
303
loginWithReadWriteSession = async (
305
304
targetEmbeddedKey : string ,
306
305
expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS ,
307
- userId ?: string ,
306
+ userId ?: string
308
307
) : Promise < SdkApiTypes . TCreateReadWriteSessionResponse > => {
309
308
const readWriteSessionResult = await this . createReadWriteSession ( {
310
309
targetPublicKey : targetEmbeddedKey ,
@@ -334,7 +333,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
334
333
*/
335
334
loginWithAuthBundle = async (
336
335
credentialBundle : string ,
337
- expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS ,
336
+ expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS
338
337
) : Promise < any > => {
339
338
try {
340
339
const whoAmIResult = await this . getWhoami ( ) ;
@@ -348,7 +347,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
348
347
await saveSession ( readWriteSessionResultWithSession , this . authClient ) ;
349
348
return true ;
350
349
} catch {
351
- return false ;
350
+ throw new Error ( "Unable to log in with the provided auth bundle." ) ;
352
351
}
353
352
} ;
354
353
@@ -388,20 +387,20 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
388
387
389
388
if ( phoneNumber ) {
390
389
promises . push (
391
- this . updateUser ( { userId, userPhoneNumber : "" , userTagIds : [ ] } ) ,
390
+ this . updateUser ( { userId, userPhoneNumber : "" , userTagIds : [ ] } )
392
391
) ;
393
392
}
394
393
if ( email ) {
395
394
promises . push (
396
- this . updateUser ( { userId, userEmail : "" , userTagIds : [ ] } ) ,
395
+ this . updateUser ( { userId, userEmail : "" , userTagIds : [ ] } )
397
396
) ;
398
397
}
399
398
if ( authenticatorIds && authenticatorIds . length > 0 ) {
400
399
promises . push ( this . deleteAuthenticators ( { userId, authenticatorIds } ) ) ;
401
400
}
402
401
if ( oauthProviderIds && oauthProviderIds . length > 0 ) {
403
402
promises . push (
404
- this . deleteOauthProviders ( { userId, providerIds : oauthProviderIds } ) ,
403
+ this . deleteOauthProviders ( { userId, providerIds : oauthProviderIds } )
405
404
) ;
406
405
}
407
406
if ( apiKeyIds && apiKeyIds . length > 0 ) {
@@ -456,12 +455,12 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
456
455
userId,
457
456
userPhoneNumber : phoneNumber ,
458
457
userTagIds : [ ] ,
459
- } ) ,
458
+ } )
460
459
) ;
461
460
}
462
461
if ( email ) {
463
462
promises . push (
464
- this . updateUser ( { userId, userEmail : email , userTagIds : [ ] } ) ,
463
+ this . updateUser ( { userId, userEmail : email , userTagIds : [ ] } )
465
464
) ;
466
465
}
467
466
if ( authenticators && authenticators . length > 0 ) {
@@ -526,7 +525,7 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
526
525
}
527
526
if ( Object . keys ( userUpdates ) . length > 0 ) {
528
527
promises . push (
529
- this . updateUser ( { userId, ...userUpdates , userTagIds : [ ] } ) ,
528
+ this . updateUser ( { userId, ...userUpdates , userTagIds : [ ] } )
530
529
) ;
531
530
}
532
531
@@ -537,15 +536,15 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
537
536
this . createAuthenticators ( {
538
537
userId,
539
538
authenticators : authenticators . add ,
540
- } ) ,
539
+ } )
541
540
) ;
542
541
}
543
542
if ( authenticators . deleteIds ?. length ) {
544
543
promises . push (
545
544
this . deleteAuthenticators ( {
546
545
userId,
547
546
authenticatorIds : authenticators . deleteIds ,
548
- } ) ,
547
+ } )
549
548
) ;
550
549
}
551
550
}
@@ -557,15 +556,15 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
557
556
this . createOauthProviders ( {
558
557
userId,
559
558
oauthProviders : oauthProviders . add ,
560
- } ) ,
559
+ } )
561
560
) ;
562
561
}
563
562
if ( oauthProviders . deleteIds ?. length ) {
564
563
promises . push (
565
564
this . deleteOauthProviders ( {
566
565
userId,
567
566
providerIds : oauthProviders . deleteIds ,
568
- } ) ,
567
+ } )
569
568
) ;
570
569
}
571
570
}
@@ -577,15 +576,15 @@ export class TurnkeyBrowserClient extends TurnkeyBaseClient {
577
576
this . createApiKeys ( {
578
577
userId,
579
578
apiKeys : apiKeys . add ,
580
- } ) ,
579
+ } )
581
580
) ;
582
581
}
583
582
if ( apiKeys . deleteIds ?. length ) {
584
583
promises . push (
585
584
this . deleteApiKeys ( {
586
585
userId,
587
586
apiKeyIds : apiKeys . deleteIds ,
588
- } ) ,
587
+ } )
589
588
) ;
590
589
}
591
590
}
@@ -614,7 +613,7 @@ export class TurnkeyPasskeyClient extends TurnkeyBrowserClient {
614
613
* @returns {Promise<Passkey> }
615
614
*/
616
615
createUserPasskey = async (
617
- config : Record < any , any > = { } ,
616
+ config : Record < any , any > = { }
618
617
) : Promise < Passkey > => {
619
618
const challenge = generateRandomBuffer ( ) ;
620
619
const encodedChallenge = base64UrlEncode ( challenge ) ;
@@ -694,15 +693,15 @@ export class TurnkeyPasskeyClient extends TurnkeyBrowserClient {
694
693
userId : string ,
695
694
targetEmbeddedKey : string ,
696
695
expirationSeconds : string = DEFAULT_SESSION_EXPIRATION_IN_SECONDS ,
697
- organizationId ?: string ,
696
+ organizationId ?: string
698
697
) : Promise < ReadWriteSession > => {
699
698
const user = await getStorageValue ( StorageKeys . UserSession ) ;
700
699
organizationId = organizationId ?? user ?. organization . organizationId ;
701
700
userId = userId ?? user ?. userId ;
702
701
703
702
if ( ! organizationId ) {
704
703
throw new Error (
705
- "Error creating passkey session: Organization ID is required" ,
704
+ "Error creating passkey session: Organization ID is required"
706
705
) ;
707
706
}
708
707
@@ -738,7 +737,7 @@ export class TurnkeyPasskeyClient extends TurnkeyBrowserClient {
738
737
credentialBundle,
739
738
sessionExpiry : expiry ,
740
739
} ,
741
- this . authClient ,
740
+ this . authClient
742
741
) ;
743
742
744
743
return {
@@ -763,44 +762,44 @@ export class TurnkeyIframeClient extends TurnkeyBrowserClient {
763
762
}
764
763
765
764
injectCredentialBundle = async (
766
- credentialBundle : string ,
765
+ credentialBundle : string
767
766
) : Promise < boolean > => {
768
767
return await ( this . stamper as IframeStamper ) . injectCredentialBundle (
769
- credentialBundle ,
768
+ credentialBundle
770
769
) ;
771
770
} ;
772
771
773
772
injectWalletExportBundle = async (
774
773
credentialBundle : string ,
775
- organizationId : string ,
774
+ organizationId : string
776
775
) : Promise < boolean > => {
777
776
return await ( this . stamper as IframeStamper ) . injectWalletExportBundle (
778
777
credentialBundle ,
779
- organizationId ,
778
+ organizationId
780
779
) ;
781
780
} ;
782
781
783
782
injectKeyExportBundle = async (
784
783
credentialBundle : string ,
785
784
organizationId : string ,
786
- keyFormat ?: KeyFormat | undefined ,
785
+ keyFormat ?: KeyFormat | undefined
787
786
) : Promise < boolean > => {
788
787
return await ( this . stamper as IframeStamper ) . injectKeyExportBundle (
789
788
credentialBundle ,
790
789
organizationId ,
791
- keyFormat ,
790
+ keyFormat
792
791
) ;
793
792
} ;
794
793
795
794
injectImportBundle = async (
796
795
bundle : string ,
797
796
organizationId : string ,
798
- userId : string ,
797
+ userId : string
799
798
) : Promise < boolean > => {
800
799
return await ( this . stamper as IframeStamper ) . injectImportBundle (
801
800
bundle ,
802
801
organizationId ,
803
- userId ,
802
+ userId
804
803
) ;
805
804
} ;
806
805
0 commit comments