@@ -14,7 +14,7 @@ import { PasskeysHandler } from './handlers/passkeys.js'
1414import { GuardRole } from './guards.js'
1515
1616export type StartSignUpWithRedirectArgs = {
17- kind : 'google-pkce' | 'apple'
17+ kind : 'google-pkce' | 'apple' | `custom-${ string } `
1818 target : string
1919 metadata : { [ key : string ] : string }
2020}
@@ -55,7 +55,7 @@ export type CompleteRedirectArgs = CommonSignupArgs & {
5555}
5656
5757export type AuthCodeSignupArgs = CommonSignupArgs & {
58- kind : 'google-pkce' | 'apple'
58+ kind : 'google-pkce' | 'apple' | `custom-${ string } `
5959 commitment : AuthCommitment
6060 code : string
6161 target : string
@@ -693,10 +693,30 @@ export class Wallets implements WalletsInterface {
693693 }
694694 }
695695 }
696+
697+ if ( args . kind . startsWith ( 'custom-' ) ) {
698+ // TODO: support other custom auth methods (e.g. id-token)
699+ const handler = this . shared . handlers . get ( args . kind ) as AuthCodeHandler
700+ if ( ! handler ) {
701+ throw new Error ( 'handler-not-registered' )
702+ }
703+
704+ const [ signer , metadata ] = await handler . completeAuth ( args . commitment , args . code )
705+ return {
706+ signer,
707+ extra : {
708+ signerKind : args . kind ,
709+ } ,
710+ loginEmail : metadata . email ,
711+ }
712+ }
713+
714+ throw new Error ( 'invalid-signup-kind' )
696715 }
697716
698717 async startSignUpWithRedirect ( args : StartSignUpWithRedirectArgs ) {
699- const handler = this . shared . handlers . get ( 'login-' + args . kind ) as AuthCodeHandler
718+ const kind = args . kind . startsWith ( 'custom-' ) ? args . kind : 'login-' + args . kind
719+ const handler = this . shared . handlers . get ( kind ) as AuthCodeHandler
700720 if ( ! handler ) {
701721 throw new Error ( 'handler-not-registered' )
702722 }
@@ -721,7 +741,8 @@ export class Wallets implements WalletsInterface {
721741 use4337 : args . use4337 ,
722742 } )
723743 } else {
724- const handler = this . shared . handlers . get ( 'login-' + commitment . kind ) as AuthCodeHandler
744+ const kind = commitment . kind . startsWith ( 'custom-' ) ? commitment . kind : 'login-' + commitment . kind
745+ const handler = this . shared . handlers . get ( kind ) as AuthCodeHandler
725746 if ( ! handler ) {
726747 throw new Error ( 'handler-not-registered' )
727748 }
0 commit comments