@@ -56,52 +56,11 @@ export default class WebAuthnProvider extends BaseProvider {
5656 options : PublicKeyCredentialCreationOptionsJSON ,
5757 customArgs ?: MintRequestBody
5858 ) : Promise < string > {
59- // Submit registration options to the authenticator
60- const { startRegistration } = await import ( '@simplewebauthn/browser' ) ;
61- const attResp : RegistrationResponseJSON = await startRegistration ( options ) ;
62-
63- // Get auth method id
64- const authMethodId = await this . getAuthMethodId ( {
65- authMethodType : AUTH_METHOD_TYPE . WebAuthn ,
66- accessToken : JSON . stringify ( attResp ) ,
67- } ) ;
68-
69- // Get auth method pub key
70- const authMethodPubkey =
71- WebAuthnProvider . getPublicKeyFromRegistration ( attResp ) ;
72-
73- // Format args for relay server
74- const defaultArgs = {
75- keyType : 2 ,
76- permittedAuthMethodTypes : [ AUTH_METHOD_TYPE . WebAuthn ] ,
77- permittedAuthMethodIds : [ authMethodId ] ,
78- permittedAuthMethodPubkeys : [ authMethodPubkey ] ,
79- permittedAuthMethodScopes : [ [ ethers . BigNumber . from ( '1' ) ] ] ,
80- addPkpEthAddressAsPermittedAddress : true ,
81- sendPkpToItself : true ,
82- } ;
83-
84- const args = {
85- ...defaultArgs ,
86- ...customArgs ,
87- } ;
88-
89- const body = JSON . stringify ( args ) ;
90-
91- // Mint PKP
92- const mintRes = await this . relay . mintPKP ( body ) ;
93- if ( ! mintRes || ! mintRes . requestId ) {
94- throw new UnknownError (
95- {
96- info : {
97- mintRes,
98- } ,
99- } ,
100- 'Missing mint response or request ID from relay server'
101- ) ;
102- }
103-
104- return mintRes . requestId ;
59+ const result = await this . verifyAndMintPKPThroughRelayerAndReturnAuthMethod (
60+ options ,
61+ customArgs
62+ ) ;
63+ return result . requestId ;
10564 }
10665
10766 /**
0 commit comments