@account-kit/react-native-signer 4.26.0 → 4.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/client.js +36 -55
- package/lib/commonjs/client.js.map +1 -1
- package/lib/commonjs/utils/parseMfaError.js +20 -0
- package/lib/commonjs/utils/parseMfaError.js.map +1 -0
- package/lib/module/client.js +37 -56
- package/lib/module/client.js.map +1 -1
- package/lib/module/utils/parseMfaError.js +16 -0
- package/lib/module/utils/parseMfaError.js.map +1 -0
- package/lib/typescript/commonjs/src/client.d.ts +3 -43
- package/lib/typescript/commonjs/src/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/parseMfaError.d.ts +3 -0
- package/lib/typescript/commonjs/src/utils/parseMfaError.d.ts.map +1 -0
- package/lib/typescript/module/src/client.d.ts +3 -43
- package/lib/typescript/module/src/client.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/parseMfaError.d.ts +3 -0
- package/lib/typescript/module/src/utils/parseMfaError.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/client.ts +43 -68
- package/src/utils/parseMfaError.ts +15 -0
package/lib/commonjs/client.js
CHANGED
|
@@ -12,6 +12,7 @@ var _zod = require("zod");
|
|
|
12
12
|
var _errors = require("./errors.js");
|
|
13
13
|
var _NativeTEKStamper = _interopRequireDefault(require("./NativeTEKStamper.js"));
|
|
14
14
|
var _parseUrlParams = require("./utils/parseUrlParams.js");
|
|
15
|
+
var _parseMfaError = require("./utils/parseMfaError.js");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
/* eslint-disable import/extensions */
|
|
17
18
|
|
|
@@ -46,13 +47,24 @@ class RNSignerClient extends _signer.BaseSignerClient {
|
|
|
46
47
|
...args,
|
|
47
48
|
targetPublicKey: publicKey
|
|
48
49
|
});
|
|
49
|
-
if (response
|
|
50
|
-
|
|
50
|
+
if ("credentialBundle" in response && response.credentialBundle) {
|
|
51
|
+
return {
|
|
52
|
+
mfaRequired: false,
|
|
53
|
+
bundle: response.credentialBundle
|
|
54
|
+
};
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
|
|
57
|
+
// If the server says "MFA_REQUIRED", pass that data back to the caller:
|
|
58
|
+
if (response.status === "MFA_REQUIRED" && response.encryptedPayload && response.multiFactors) {
|
|
59
|
+
return {
|
|
60
|
+
mfaRequired: true,
|
|
61
|
+
encryptedPayload: response.encryptedPayload,
|
|
62
|
+
multiFactors: response.multiFactors
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Otherwise, it's truly an error:
|
|
67
|
+
throw new Error("Failed to submit OTP code. Server did not return required fields.");
|
|
56
68
|
}
|
|
57
69
|
async createAccount(params) {
|
|
58
70
|
if (params.type !== "email") {
|
|
@@ -79,13 +91,24 @@ class RNSignerClient extends _signer.BaseSignerClient {
|
|
|
79
91
|
this.eventEmitter.emit("authenticating", {
|
|
80
92
|
type: "email"
|
|
81
93
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
const targetPublicKey = await this.stamper.init();
|
|
95
|
+
try {
|
|
96
|
+
return await this.request("/v1/auth", {
|
|
97
|
+
email: params.email,
|
|
98
|
+
emailMode: params.emailMode,
|
|
99
|
+
targetPublicKey,
|
|
100
|
+
multiFactors: params.multiFactors
|
|
101
|
+
});
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const multiFactors = (0, _parseMfaError.parseMfaError)(error);
|
|
104
|
+
|
|
105
|
+
// If MFA is required, and emailMode is Magic Link, the user must submit mfa with the request or
|
|
106
|
+
// the server will return an error with the required mfa factors.
|
|
107
|
+
if (multiFactors) {
|
|
108
|
+
throw new _signer.MfaRequiredError(multiFactors);
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
89
112
|
}
|
|
90
113
|
async completeAuthWithBundle(params) {
|
|
91
114
|
if (!this.validAuthenticatingTypes.includes(params.authenticatingType)) {
|
|
@@ -180,48 +203,6 @@ class RNSignerClient extends _signer.BaseSignerClient {
|
|
|
180
203
|
nonce
|
|
181
204
|
});
|
|
182
205
|
};
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Retrieves the list of MFA factors configured for the current user.
|
|
186
|
-
*
|
|
187
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
188
|
-
*/
|
|
189
|
-
getMfaFactors() {
|
|
190
|
-
throw new Error("getMfaFactors is not implemented in RNSignerClient");
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Initiates the setup of a new MFA factor for the current user.
|
|
195
|
-
*
|
|
196
|
-
* @param {EnableMfaParams} _params The parameters required to enable a new MFA factor
|
|
197
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
198
|
-
*/
|
|
199
|
-
addMfa(_params) {
|
|
200
|
-
throw new Error("enableMfa is not implemented in RNSignerClient");
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Verifies a newly created MFA factor to complete the setup process.
|
|
205
|
-
*
|
|
206
|
-
* @param {VerifyMfaParams} _params The parameters required to verify the MFA factor
|
|
207
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
208
|
-
*/
|
|
209
|
-
verifyMfa(_params) {
|
|
210
|
-
throw new Error("verifyMfa is not implemented in RNSignerClient");
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Removes existing MFA factors by ID.
|
|
215
|
-
*
|
|
216
|
-
* @param {RemoveMfaParams} _params The parameters specifying which factors to disable
|
|
217
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
218
|
-
*/
|
|
219
|
-
removeMfa(_params) {
|
|
220
|
-
throw new Error("disableMfa is not implemented in RNSignerClient");
|
|
221
|
-
}
|
|
222
|
-
validateMultiFactors(_params) {
|
|
223
|
-
throw new Error("validateMultiFactors is not implemented in RNSignerClient");
|
|
224
|
-
}
|
|
225
206
|
}
|
|
226
207
|
exports.RNSignerClient = RNSignerClient;
|
|
227
208
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_signer","_reactNativeInappbrowserReborn","_zod","_errors","_NativeTEKStamper","_interopRequireDefault","_parseUrlParams","e","__esModule","default","RNSignerClientParamsSchema","exports","z","object","connection","custom","rootOrgId","string","optional","oauthCallbackUrl","RNSignerClient","BaseSignerClient","stamper","NativeTEKStamper","validAuthenticatingTypes","constructor","params","parse","submitOtpCode","args","eventEmitter","emit","type","publicKey","init","response","request","targetPublicKey","
|
|
1
|
+
{"version":3,"names":["require","_signer","_reactNativeInappbrowserReborn","_zod","_errors","_NativeTEKStamper","_interopRequireDefault","_parseUrlParams","_parseMfaError","e","__esModule","default","RNSignerClientParamsSchema","exports","z","object","connection","custom","rootOrgId","string","optional","oauthCallbackUrl","RNSignerClient","BaseSignerClient","stamper","NativeTEKStamper","validAuthenticatingTypes","constructor","params","parse","submitOtpCode","args","eventEmitter","emit","type","publicKey","init","response","request","targetPublicKey","credentialBundle","mfaRequired","bundle","status","encryptedPayload","multiFactors","Error","createAccount","email","expirationSeconds","emailMode","redirectParams","toString","initEmailAuth","error","parseMfaError","MfaRequiredError","completeAuthWithBundle","includes","authenticatingType","result","injectCredentialBundle","user","whoami","orgId","idToken","connectedEventName","oauthWithRedirect","InAppBrowser","isAvailable","InAppBrowserUnavailableError","oauthParams","turnkeyPublicKey","oauthConfig","getOauthConfig","providerUrl","getOauthProviderUrl","usesRelativeUrl","redirectUrl","res","openAuth","url","OauthFailedError","authResult","parseSearchParams","isSignup","oauthWithPopup","_args","disconnect","undefined","clear","exportWallet","_params","lookupUserWithPasskey","_user","getWebAuthnAttestation","_options","_userDetails","nonce","getOauthNonce"],"sourceRoot":"../../src","sources":["client.ts"],"mappings":";;;;;;AAAAA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CAAC;EAC5C;EACS+C,qBAAqBA,CAACC,KAAY,EAAiB;IAC1D,MAAM,IAAIhD,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EAESP,eAAeA,CAAA,EAAoB;IAC1C,OAAO,IAAI,CAACf,OAAO,CAACY,IAAI,CAAC,CAAC;EAC5B;EAEmB2D,sBAAsBA,CACvCC,QAAmC,EACnCC,YAAmC,EACI;IACvC,MAAM,IAAInD,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EAEmB4B,cAAc,GAAG,MAAAA,CAAA,KAAkC;IACpE,MAAMvC,SAAS,GAAG,MAAM,IAAI,CAACX,OAAO,CAACY,IAAI,CAAC,CAAC;IAE3C,MAAM8D,KAAK,GAAG,IAAI,CAACC,aAAa,CAAChE,SAAS,CAAC;IAC3C,OAAO,IAAI,CAACG,OAAO,CAAC,mBAAmB,EAAE;MAAE4D;IAAM,CAAC,CAAC;EACrD,CAAC;AACH;AAACrF,OAAA,CAAAS,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseMfaError = parseMfaError;
|
|
7
|
+
function parseMfaError(error) {
|
|
8
|
+
if (error instanceof Error) {
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(error.message);
|
|
11
|
+
if (parsed?.data?.multiFactors) {
|
|
12
|
+
return parsed.data.multiFactors;
|
|
13
|
+
}
|
|
14
|
+
} catch {
|
|
15
|
+
// ignore JSON parse failures
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=parseMfaError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseMfaError","error","Error","parsed","JSON","parse","message","data","multiFactors"],"sourceRoot":"../../../src","sources":["utils/parseMfaError.ts"],"mappings":";;;;;;AAEO,SAASA,aAAaA,CAACC,KAAc,EAAsB;EAChE,IAAIA,KAAK,YAAYC,KAAK,EAAE;IAC1B,IAAI;MACF,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACJ,KAAK,CAACK,OAAO,CAAC;MACxC,IAAIH,MAAM,EAAEI,IAAI,EAAEC,YAAY,EAAE;QAC9B,OAAOL,MAAM,CAACI,IAAI,CAACC,YAAY;MACjC;IACF,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,OAAO,IAAI;AACb","ignoreList":[]}
|
package/lib/module/client.js
CHANGED
|
@@ -5,12 +5,13 @@ import "./utils/mmkv-localstorage-polyfill.js";
|
|
|
5
5
|
|
|
6
6
|
/* eslint-disable import/extensions */
|
|
7
7
|
|
|
8
|
-
import { BaseSignerClient, OauthFailedError } from "@account-kit/signer";
|
|
8
|
+
import { BaseSignerClient, OauthFailedError, MfaRequiredError } from "@account-kit/signer";
|
|
9
9
|
import { InAppBrowser } from "react-native-inappbrowser-reborn";
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
import { InAppBrowserUnavailableError } from "./errors.js";
|
|
12
12
|
import NativeTEKStamper from "./NativeTEKStamper.js";
|
|
13
13
|
import { parseSearchParams } from "./utils/parseUrlParams.js";
|
|
14
|
+
import { parseMfaError } from "./utils/parseMfaError.js";
|
|
14
15
|
export const RNSignerClientParamsSchema = z.object({
|
|
15
16
|
connection: z.custom(),
|
|
16
17
|
rootOrgId: z.string().optional(),
|
|
@@ -42,13 +43,24 @@ export class RNSignerClient extends BaseSignerClient {
|
|
|
42
43
|
...args,
|
|
43
44
|
targetPublicKey: publicKey
|
|
44
45
|
});
|
|
45
|
-
if (response
|
|
46
|
-
|
|
46
|
+
if ("credentialBundle" in response && response.credentialBundle) {
|
|
47
|
+
return {
|
|
48
|
+
mfaRequired: false,
|
|
49
|
+
bundle: response.credentialBundle
|
|
50
|
+
};
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
|
|
53
|
+
// If the server says "MFA_REQUIRED", pass that data back to the caller:
|
|
54
|
+
if (response.status === "MFA_REQUIRED" && response.encryptedPayload && response.multiFactors) {
|
|
55
|
+
return {
|
|
56
|
+
mfaRequired: true,
|
|
57
|
+
encryptedPayload: response.encryptedPayload,
|
|
58
|
+
multiFactors: response.multiFactors
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Otherwise, it's truly an error:
|
|
63
|
+
throw new Error("Failed to submit OTP code. Server did not return required fields.");
|
|
52
64
|
}
|
|
53
65
|
async createAccount(params) {
|
|
54
66
|
if (params.type !== "email") {
|
|
@@ -75,13 +87,24 @@ export class RNSignerClient extends BaseSignerClient {
|
|
|
75
87
|
this.eventEmitter.emit("authenticating", {
|
|
76
88
|
type: "email"
|
|
77
89
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
const targetPublicKey = await this.stamper.init();
|
|
91
|
+
try {
|
|
92
|
+
return await this.request("/v1/auth", {
|
|
93
|
+
email: params.email,
|
|
94
|
+
emailMode: params.emailMode,
|
|
95
|
+
targetPublicKey,
|
|
96
|
+
multiFactors: params.multiFactors
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
const multiFactors = parseMfaError(error);
|
|
100
|
+
|
|
101
|
+
// If MFA is required, and emailMode is Magic Link, the user must submit mfa with the request or
|
|
102
|
+
// the server will return an error with the required mfa factors.
|
|
103
|
+
if (multiFactors) {
|
|
104
|
+
throw new MfaRequiredError(multiFactors);
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
85
108
|
}
|
|
86
109
|
async completeAuthWithBundle(params) {
|
|
87
110
|
if (!this.validAuthenticatingTypes.includes(params.authenticatingType)) {
|
|
@@ -176,47 +199,5 @@ export class RNSignerClient extends BaseSignerClient {
|
|
|
176
199
|
nonce
|
|
177
200
|
});
|
|
178
201
|
};
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Retrieves the list of MFA factors configured for the current user.
|
|
182
|
-
*
|
|
183
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
184
|
-
*/
|
|
185
|
-
getMfaFactors() {
|
|
186
|
-
throw new Error("getMfaFactors is not implemented in RNSignerClient");
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Initiates the setup of a new MFA factor for the current user.
|
|
191
|
-
*
|
|
192
|
-
* @param {EnableMfaParams} _params The parameters required to enable a new MFA factor
|
|
193
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
194
|
-
*/
|
|
195
|
-
addMfa(_params) {
|
|
196
|
-
throw new Error("enableMfa is not implemented in RNSignerClient");
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Verifies a newly created MFA factor to complete the setup process.
|
|
201
|
-
*
|
|
202
|
-
* @param {VerifyMfaParams} _params The parameters required to verify the MFA factor
|
|
203
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
204
|
-
*/
|
|
205
|
-
verifyMfa(_params) {
|
|
206
|
-
throw new Error("verifyMfa is not implemented in RNSignerClient");
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Removes existing MFA factors by ID.
|
|
211
|
-
*
|
|
212
|
-
* @param {RemoveMfaParams} _params The parameters specifying which factors to disable
|
|
213
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
214
|
-
*/
|
|
215
|
-
removeMfa(_params) {
|
|
216
|
-
throw new Error("disableMfa is not implemented in RNSignerClient");
|
|
217
|
-
}
|
|
218
|
-
validateMultiFactors(_params) {
|
|
219
|
-
throw new Error("validateMultiFactors is not implemented in RNSignerClient");
|
|
220
|
-
}
|
|
221
202
|
}
|
|
222
203
|
//# sourceMappingURL=client.js.map
|
package/lib/module/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BaseSignerClient","OauthFailedError","InAppBrowser","z","InAppBrowserUnavailableError","NativeTEKStamper","parseSearchParams","RNSignerClientParamsSchema","object","connection","custom","rootOrgId","string","optional","oauthCallbackUrl","default","RNSignerClient","stamper","validAuthenticatingTypes","constructor","params","parse","submitOtpCode","args","eventEmitter","emit","type","publicKey","init","response","request","targetPublicKey","
|
|
1
|
+
{"version":3,"names":["BaseSignerClient","OauthFailedError","MfaRequiredError","InAppBrowser","z","InAppBrowserUnavailableError","NativeTEKStamper","parseSearchParams","parseMfaError","RNSignerClientParamsSchema","object","connection","custom","rootOrgId","string","optional","oauthCallbackUrl","default","RNSignerClient","stamper","validAuthenticatingTypes","constructor","params","parse","submitOtpCode","args","eventEmitter","emit","type","publicKey","init","response","request","targetPublicKey","credentialBundle","mfaRequired","bundle","status","encryptedPayload","multiFactors","Error","createAccount","email","expirationSeconds","emailMode","redirectParams","toString","initEmailAuth","error","completeAuthWithBundle","includes","authenticatingType","result","injectCredentialBundle","user","whoami","orgId","idToken","connectedEventName","oauthWithRedirect","isAvailable","oauthParams","turnkeyPublicKey","oauthConfig","getOauthConfig","providerUrl","getOauthProviderUrl","usesRelativeUrl","redirectUrl","res","openAuth","url","authResult","isSignup","oauthWithPopup","_args","disconnect","undefined","clear","exportWallet","_params","lookupUserWithPasskey","_user","getWebAuthnAttestation","_options","_userDetails","nonce","getOauthNonce"],"sourceRoot":"../../src","sources":["client.ts"],"mappings":";;AAAA,OAAO,4BAA4B;AACnC,OAAO,uCAAuC;;AAE9C;;AAEA,SACEA,gBAAgB,EAChBC,gBAAgB,EAChBC,gBAAgB,QAaX,qBAAqB;AAC5B,SAASC,YAAY,QAAQ,kCAAkC;AAC/D,SAASC,CAAC,QAAQ,KAAK;AACvB,SAASC,4BAA4B,QAAQ,aAAU;AACvD,OAAOC,gBAAgB,MAAM,uBAAuB;AACpD,SAASC,iBAAiB,QAAQ,2BAAwB;AAC1D,SAAS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AG,MAAM,IAAI,CAACV,OAAO,CAACW,IAAI,CAAC,CAAC;IAE3C,MAAMwD,KAAK,GAAG,IAAI,CAACC,aAAa,CAAC1D,SAAS,CAAC;IAC3C,OAAO,IAAI,CAACG,OAAO,CAAC,mBAAmB,EAAE;MAAEsD;IAAM,CAAC,CAAC;EACrD,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function parseMfaError(error) {
|
|
4
|
+
if (error instanceof Error) {
|
|
5
|
+
try {
|
|
6
|
+
const parsed = JSON.parse(error.message);
|
|
7
|
+
if (parsed?.data?.multiFactors) {
|
|
8
|
+
return parsed.data.multiFactors;
|
|
9
|
+
}
|
|
10
|
+
} catch {
|
|
11
|
+
// ignore JSON parse failures
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=parseMfaError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseMfaError","error","Error","parsed","JSON","parse","message","data","multiFactors"],"sourceRoot":"../../../src","sources":["utils/parseMfaError.ts"],"mappings":";;AAEA,OAAO,SAASA,aAAaA,CAACC,KAAc,EAAsB;EAChE,IAAIA,KAAK,YAAYC,KAAK,EAAE;IAC1B,IAAI;MACF,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACJ,KAAK,CAACK,OAAO,CAAC;MACxC,IAAIH,MAAM,EAAEI,IAAI,EAAEC,YAAY,EAAE;QAC9B,OAAOL,MAAM,CAACI,IAAI,CAACC,YAAY;MACjC;IACF,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./utils/buffer-polyfill.js";
|
|
2
2
|
import "./utils/mmkv-localstorage-polyfill.js";
|
|
3
|
-
import { BaseSignerClient, type AlchemySignerClientEvents, type AuthenticatingEventMetadata, type CreateAccountParams, type
|
|
3
|
+
import { BaseSignerClient, type AlchemySignerClientEvents, type AuthenticatingEventMetadata, type CreateAccountParams, type EmailAuthParams, type GetWebAuthnAttestationResult, type MfaFactor, type OauthConfig, type OauthParams, type OtpParams, type SignupResponse, type User, type SubmitOtpCodeResponse } from "@account-kit/signer";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
6
6
|
connection: z.ZodType<{
|
|
@@ -89,6 +89,8 @@ export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
89
89
|
createAccount(params: CreateAccountParams): Promise<SignupResponse>;
|
|
90
90
|
initEmailAuth(params: Omit<EmailAuthParams, "targetPublicKey">): Promise<{
|
|
91
91
|
orgId: string;
|
|
92
|
+
otpId?: string;
|
|
93
|
+
multiFactors?: MfaFactor[];
|
|
92
94
|
}>;
|
|
93
95
|
completeAuthWithBundle(params: {
|
|
94
96
|
bundle: string;
|
|
@@ -111,47 +113,5 @@ export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
111
113
|
username: string;
|
|
112
114
|
}): Promise<GetWebAuthnAttestationResult>;
|
|
113
115
|
protected getOauthConfig: () => Promise<OauthConfig>;
|
|
114
|
-
/**
|
|
115
|
-
* Retrieves the list of MFA factors configured for the current user.
|
|
116
|
-
*
|
|
117
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
118
|
-
*/
|
|
119
|
-
getMfaFactors(): Promise<{
|
|
120
|
-
multiFactors: MfaFactor[];
|
|
121
|
-
}>;
|
|
122
|
-
/**
|
|
123
|
-
* Initiates the setup of a new MFA factor for the current user.
|
|
124
|
-
*
|
|
125
|
-
* @param {EnableMfaParams} _params The parameters required to enable a new MFA factor
|
|
126
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
127
|
-
*/
|
|
128
|
-
addMfa(_params: EnableMfaParams): Promise<EnableMfaResult>;
|
|
129
|
-
/**
|
|
130
|
-
* Verifies a newly created MFA factor to complete the setup process.
|
|
131
|
-
*
|
|
132
|
-
* @param {VerifyMfaParams} _params The parameters required to verify the MFA factor
|
|
133
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
134
|
-
*/
|
|
135
|
-
verifyMfa(_params: VerifyMfaParams): Promise<{
|
|
136
|
-
multiFactors: MfaFactor[];
|
|
137
|
-
}>;
|
|
138
|
-
/**
|
|
139
|
-
* Removes existing MFA factors by ID.
|
|
140
|
-
*
|
|
141
|
-
* @param {RemoveMfaParams} _params The parameters specifying which factors to disable
|
|
142
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
143
|
-
*/
|
|
144
|
-
removeMfa(_params: RemoveMfaParams): Promise<{
|
|
145
|
-
multiFactors: MfaFactor[];
|
|
146
|
-
}>;
|
|
147
|
-
validateMultiFactors(_params: {
|
|
148
|
-
encryptedPayload: string;
|
|
149
|
-
multiFactors: {
|
|
150
|
-
multiFactorId: string;
|
|
151
|
-
multiFactorCode: string;
|
|
152
|
-
}[];
|
|
153
|
-
}): Promise<{
|
|
154
|
-
bundle: string;
|
|
155
|
-
}>;
|
|
156
116
|
}
|
|
157
117
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AACpC,OAAO,uCAAuC,CAAC;AAI/C,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AACpC,OAAO,uCAAuC,CAAC;AAI/C,OAAO,EACL,gBAAgB,EAGhB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,W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,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,KAC/C,OAAO,CAAC,IAAI,CAAC,CAuDd;IAEO,cAAc,CACrB,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,GAC7C,OAAO,CAAC,IAAI,CAAC;IAID,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAGhD,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;cAIxB,sBAAsB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClC,OAAO,CAAC,4BAA4B,CAAC;IAIxC,UAAmB,cAAc,QAAa,OAAO,CAAC,WAAW,CAAC,CAKhE;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseMfaError.d.ts","sourceRoot":"","sources":["../../../../../src/utils/parseMfaError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,CAYhE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./utils/buffer-polyfill.js";
|
|
2
2
|
import "./utils/mmkv-localstorage-polyfill.js";
|
|
3
|
-
import { BaseSignerClient, type AlchemySignerClientEvents, type AuthenticatingEventMetadata, type CreateAccountParams, type
|
|
3
|
+
import { BaseSignerClient, type AlchemySignerClientEvents, type AuthenticatingEventMetadata, type CreateAccountParams, type EmailAuthParams, type GetWebAuthnAttestationResult, type MfaFactor, type OauthConfig, type OauthParams, type OtpParams, type SignupResponse, type User, type SubmitOtpCodeResponse } from "@account-kit/signer";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
6
6
|
connection: z.ZodType<{
|
|
@@ -89,6 +89,8 @@ export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
89
89
|
createAccount(params: CreateAccountParams): Promise<SignupResponse>;
|
|
90
90
|
initEmailAuth(params: Omit<EmailAuthParams, "targetPublicKey">): Promise<{
|
|
91
91
|
orgId: string;
|
|
92
|
+
otpId?: string;
|
|
93
|
+
multiFactors?: MfaFactor[];
|
|
92
94
|
}>;
|
|
93
95
|
completeAuthWithBundle(params: {
|
|
94
96
|
bundle: string;
|
|
@@ -111,47 +113,5 @@ export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
111
113
|
username: string;
|
|
112
114
|
}): Promise<GetWebAuthnAttestationResult>;
|
|
113
115
|
protected getOauthConfig: () => Promise<OauthConfig>;
|
|
114
|
-
/**
|
|
115
|
-
* Retrieves the list of MFA factors configured for the current user.
|
|
116
|
-
*
|
|
117
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
118
|
-
*/
|
|
119
|
-
getMfaFactors(): Promise<{
|
|
120
|
-
multiFactors: MfaFactor[];
|
|
121
|
-
}>;
|
|
122
|
-
/**
|
|
123
|
-
* Initiates the setup of a new MFA factor for the current user.
|
|
124
|
-
*
|
|
125
|
-
* @param {EnableMfaParams} _params The parameters required to enable a new MFA factor
|
|
126
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
127
|
-
*/
|
|
128
|
-
addMfa(_params: EnableMfaParams): Promise<EnableMfaResult>;
|
|
129
|
-
/**
|
|
130
|
-
* Verifies a newly created MFA factor to complete the setup process.
|
|
131
|
-
*
|
|
132
|
-
* @param {VerifyMfaParams} _params The parameters required to verify the MFA factor
|
|
133
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
134
|
-
*/
|
|
135
|
-
verifyMfa(_params: VerifyMfaParams): Promise<{
|
|
136
|
-
multiFactors: MfaFactor[];
|
|
137
|
-
}>;
|
|
138
|
-
/**
|
|
139
|
-
* Removes existing MFA factors by ID.
|
|
140
|
-
*
|
|
141
|
-
* @param {RemoveMfaParams} _params The parameters specifying which factors to disable
|
|
142
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
143
|
-
*/
|
|
144
|
-
removeMfa(_params: RemoveMfaParams): Promise<{
|
|
145
|
-
multiFactors: MfaFactor[];
|
|
146
|
-
}>;
|
|
147
|
-
validateMultiFactors(_params: {
|
|
148
|
-
encryptedPayload: string;
|
|
149
|
-
multiFactors: {
|
|
150
|
-
multiFactorId: string;
|
|
151
|
-
multiFactorCode: string;
|
|
152
|
-
}[];
|
|
153
|
-
}): Promise<{
|
|
154
|
-
bundle: string;
|
|
155
|
-
}>;
|
|
156
116
|
}
|
|
157
117
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AACpC,OAAO,uCAAuC,CAAC;AAI/C,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAC;AACpC,OAAO,uCAAuC,CAAC;AAI/C,OAAO,EACL,gBAAgB,EAGhB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,0BAA0B;;;;;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C7C,OAAO,CAAC,IAAI,CAAC;IAID,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAGhD,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;cAIxB,sBAAsB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClC,OAAO,CAAC,4BAA4B,CAAC;IAIxC,UAAmB,cAAc,QAAa,OAAO,CAAC,WAAW,CAAC,CAKhE;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseMfaError.d.ts","sourceRoot":"","sources":["../../../../../src/utils/parseMfaError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,CAYhE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/react-native-signer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.28.0",
|
|
4
4
|
"author": "Alchemy",
|
|
5
5
|
"description": "React Native compatible Account Kit signer",
|
|
6
6
|
"source": "./src/index.tsx",
|
|
@@ -150,9 +150,9 @@
|
|
|
150
150
|
"version": "0.42.2"
|
|
151
151
|
},
|
|
152
152
|
"dependencies": {
|
|
153
|
-
"@aa-sdk/core": "^4.
|
|
154
|
-
"@account-kit/signer": "^4.
|
|
153
|
+
"@aa-sdk/core": "^4.28.0",
|
|
154
|
+
"@account-kit/signer": "^4.28.0",
|
|
155
155
|
"viem": "^2.21.40"
|
|
156
156
|
},
|
|
157
|
-
"gitHead": "
|
|
157
|
+
"gitHead": "fd15569ef554b4ff19c72d864e1031aad8bdf8b3"
|
|
158
158
|
}
|
package/src/client.ts
CHANGED
|
@@ -6,13 +6,11 @@ import { type ConnectionConfig } from "@aa-sdk/core";
|
|
|
6
6
|
import {
|
|
7
7
|
BaseSignerClient,
|
|
8
8
|
OauthFailedError,
|
|
9
|
+
MfaRequiredError,
|
|
9
10
|
type AlchemySignerClientEvents,
|
|
10
11
|
type AuthenticatingEventMetadata,
|
|
11
12
|
type CreateAccountParams,
|
|
12
|
-
type RemoveMfaParams,
|
|
13
13
|
type EmailAuthParams,
|
|
14
|
-
type EnableMfaParams,
|
|
15
|
-
type EnableMfaResult,
|
|
16
14
|
type GetWebAuthnAttestationResult,
|
|
17
15
|
type MfaFactor,
|
|
18
16
|
type OauthConfig,
|
|
@@ -20,7 +18,6 @@ import {
|
|
|
20
18
|
type OtpParams,
|
|
21
19
|
type SignupResponse,
|
|
22
20
|
type User,
|
|
23
|
-
type VerifyMfaParams,
|
|
24
21
|
type SubmitOtpCodeResponse,
|
|
25
22
|
} from "@account-kit/signer";
|
|
26
23
|
import { InAppBrowser } from "react-native-inappbrowser-reborn";
|
|
@@ -28,6 +25,7 @@ import { z } from "zod";
|
|
|
28
25
|
import { InAppBrowserUnavailableError } from "./errors";
|
|
29
26
|
import NativeTEKStamper from "./NativeTEKStamper.js";
|
|
30
27
|
import { parseSearchParams } from "./utils/parseUrlParams";
|
|
28
|
+
import { parseMfaError } from "./utils/parseMfaError";
|
|
31
29
|
|
|
32
30
|
export const RNSignerClientParamsSchema = z.object({
|
|
33
31
|
connection: z.custom<ConnectionConfig>(),
|
|
@@ -74,11 +72,30 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
74
72
|
targetPublicKey: publicKey,
|
|
75
73
|
});
|
|
76
74
|
|
|
77
|
-
if (response
|
|
78
|
-
|
|
75
|
+
if ("credentialBundle" in response && response.credentialBundle) {
|
|
76
|
+
return {
|
|
77
|
+
mfaRequired: false,
|
|
78
|
+
bundle: response.credentialBundle,
|
|
79
|
+
};
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
// If the server says "MFA_REQUIRED", pass that data back to the caller:
|
|
83
|
+
if (
|
|
84
|
+
response.status === "MFA_REQUIRED" &&
|
|
85
|
+
response.encryptedPayload &&
|
|
86
|
+
response.multiFactors
|
|
87
|
+
) {
|
|
88
|
+
return {
|
|
89
|
+
mfaRequired: true,
|
|
90
|
+
encryptedPayload: response.encryptedPayload,
|
|
91
|
+
multiFactors: response.multiFactors,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Otherwise, it's truly an error:
|
|
96
|
+
throw new Error(
|
|
97
|
+
"Failed to submit OTP code. Server did not return required fields."
|
|
98
|
+
);
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
override async createAccount(
|
|
@@ -105,17 +122,27 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
105
122
|
|
|
106
123
|
override async initEmailAuth(
|
|
107
124
|
params: Omit<EmailAuthParams, "targetPublicKey">
|
|
108
|
-
): Promise<{ orgId: string }> {
|
|
125
|
+
): Promise<{ orgId: string; otpId?: string; multiFactors?: MfaFactor[] }> {
|
|
109
126
|
this.eventEmitter.emit("authenticating", { type: "email" });
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
const targetPublicKey = await this.stamper.init();
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
return await this.request("/v1/auth", {
|
|
131
|
+
email: params.email,
|
|
132
|
+
emailMode: params.emailMode,
|
|
133
|
+
targetPublicKey,
|
|
134
|
+
multiFactors: params.multiFactors,
|
|
135
|
+
});
|
|
136
|
+
} catch (error) {
|
|
137
|
+
const multiFactors = parseMfaError(error);
|
|
117
138
|
|
|
118
|
-
|
|
139
|
+
// If MFA is required, and emailMode is Magic Link, the user must submit mfa with the request or
|
|
140
|
+
// the server will return an error with the required mfa factors.
|
|
141
|
+
if (multiFactors) {
|
|
142
|
+
throw new MfaRequiredError(multiFactors);
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
119
146
|
}
|
|
120
147
|
|
|
121
148
|
override async completeAuthWithBundle(params: {
|
|
@@ -240,56 +267,4 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
240
267
|
const nonce = this.getOauthNonce(publicKey);
|
|
241
268
|
return this.request("/v1/prepare-oauth", { nonce });
|
|
242
269
|
};
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Retrieves the list of MFA factors configured for the current user.
|
|
246
|
-
*
|
|
247
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
248
|
-
*/
|
|
249
|
-
public override getMfaFactors(): Promise<{ multiFactors: MfaFactor[] }> {
|
|
250
|
-
throw new Error("getMfaFactors is not implemented in RNSignerClient");
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Initiates the setup of a new MFA factor for the current user.
|
|
255
|
-
*
|
|
256
|
-
* @param {EnableMfaParams} _params The parameters required to enable a new MFA factor
|
|
257
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
258
|
-
*/
|
|
259
|
-
public override addMfa(_params: EnableMfaParams): Promise<EnableMfaResult> {
|
|
260
|
-
throw new Error("enableMfa is not implemented in RNSignerClient");
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Verifies a newly created MFA factor to complete the setup process.
|
|
265
|
-
*
|
|
266
|
-
* @param {VerifyMfaParams} _params The parameters required to verify the MFA factor
|
|
267
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
268
|
-
*/
|
|
269
|
-
public override verifyMfa(_params: VerifyMfaParams): Promise<{
|
|
270
|
-
multiFactors: MfaFactor[];
|
|
271
|
-
}> {
|
|
272
|
-
throw new Error("verifyMfa is not implemented in RNSignerClient");
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Removes existing MFA factors by ID.
|
|
277
|
-
*
|
|
278
|
-
* @param {RemoveMfaParams} _params The parameters specifying which factors to disable
|
|
279
|
-
* @throws {Error} This method is not implemented in RNSignerClient
|
|
280
|
-
*/
|
|
281
|
-
public override removeMfa(_params: RemoveMfaParams): Promise<{
|
|
282
|
-
multiFactors: MfaFactor[];
|
|
283
|
-
}> {
|
|
284
|
-
throw new Error("disableMfa is not implemented in RNSignerClient");
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
public override validateMultiFactors(_params: {
|
|
288
|
-
encryptedPayload: string;
|
|
289
|
-
multiFactors: { multiFactorId: string; multiFactorCode: string }[];
|
|
290
|
-
}): Promise<{ bundle: string }> {
|
|
291
|
-
throw new Error(
|
|
292
|
-
"validateMultiFactors is not implemented in RNSignerClient"
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
270
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MfaFactor } from "@account-kit/signer";
|
|
2
|
+
|
|
3
|
+
export function parseMfaError(error: unknown): MfaFactor[] | null {
|
|
4
|
+
if (error instanceof Error) {
|
|
5
|
+
try {
|
|
6
|
+
const parsed = JSON.parse(error.message);
|
|
7
|
+
if (parsed?.data?.multiFactors) {
|
|
8
|
+
return parsed.data.multiFactors;
|
|
9
|
+
}
|
|
10
|
+
} catch {
|
|
11
|
+
// ignore JSON parse failures
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|