@account-kit/react-native-signer 4.8.0 → 4.10.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/android/src/main/java/com/accountkit/reactnativesigner/core/TEKStamper.kt +84 -25
- package/lib/commonjs/client.js +67 -11
- package/lib/commonjs/client.js.map +1 -1
- package/lib/commonjs/errors.js +15 -0
- package/lib/commonjs/errors.js.map +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/signer.js +2 -0
- package/lib/commonjs/signer.js.map +1 -1
- package/lib/commonjs/utils/base64UrlEncode.js +12 -0
- package/lib/commonjs/utils/base64UrlEncode.js.map +1 -0
- package/lib/commonjs/utils/buffer-polyfill.js +7 -0
- package/lib/commonjs/utils/buffer-polyfill.js.map +1 -0
- package/lib/commonjs/utils/parseUrlParams.js +19 -0
- package/lib/commonjs/utils/parseUrlParams.js.map +1 -0
- package/lib/module/client.js +68 -12
- package/lib/module/client.js.map +1 -1
- package/lib/module/errors.js +10 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/signer.js +1 -1
- package/lib/module/signer.js.map +1 -1
- package/lib/module/utils/base64UrlEncode.js +7 -0
- package/lib/module/utils/base64UrlEncode.js.map +1 -0
- package/lib/module/utils/buffer-polyfill.js +7 -0
- package/lib/module/utils/buffer-polyfill.js.map +1 -0
- package/lib/module/utils/parseUrlParams.js +14 -0
- package/lib/module/utils/parseUrlParams.js.map +1 -0
- package/lib/typescript/commonjs/src/client.d.ts +9 -3
- package/lib/typescript/commonjs/src/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/errors.d.ts +6 -0
- package/lib/typescript/commonjs/src/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/signer.d.ts +14 -1
- package/lib/typescript/commonjs/src/signer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/utils/base64UrlEncode.d.ts +2 -0
- package/lib/typescript/commonjs/src/utils/base64UrlEncode.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/buffer-polyfill.d.ts +2 -0
- package/lib/typescript/commonjs/src/utils/buffer-polyfill.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/parseUrlParams.d.ts +2 -0
- package/lib/typescript/commonjs/src/utils/parseUrlParams.d.ts.map +1 -0
- package/lib/typescript/module/src/client.d.ts +9 -3
- package/lib/typescript/module/src/client.d.ts.map +1 -1
- package/lib/typescript/module/src/errors.d.ts +6 -0
- package/lib/typescript/module/src/errors.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/signer.d.ts +14 -1
- package/lib/typescript/module/src/signer.d.ts.map +1 -1
- package/lib/typescript/module/src/utils/base64UrlEncode.d.ts +2 -0
- package/lib/typescript/module/src/utils/base64UrlEncode.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/buffer-polyfill.d.ts +2 -0
- package/lib/typescript/module/src/utils/buffer-polyfill.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/parseUrlParams.d.ts +2 -0
- package/lib/typescript/module/src/utils/parseUrlParams.d.ts.map +1 -0
- package/package.json +6 -4
- package/src/client.ts +91 -15
- package/src/errors.ts +10 -0
- package/src/index.tsx +1 -2
- package/src/signer.ts +5 -2
- package/src/utils/base64UrlEncode.ts +11 -0
- package/src/utils/buffer-polyfill.ts +5 -0
- package/src/utils/parseUrlParams.ts +14 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Buffer","base64UrlEncode","challenge","from","toString","replace"],"sourceRoot":"../../../src","sources":["utils/base64UrlEncode.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,QAAQ;AAE/B,OAAO,MAAMC,eAAe,GAC1BC,SAAwC,IAC7B;EACX,OAAOF,MAAM,CAACG,IAAI,CAACD,SAAS,CAAC,CAC1BE,QAAQ,CAAC,QAAQ,CAAC,CAClBC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CACnBA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CACnBA,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;AACtB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Buffer","global"],"sourceRoot":"../../../src","sources":["utils/buffer-polyfill.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,QAAQ;AAE/B,IAAI,CAACC,MAAM,CAACD,MAAM,EAAE;EAClBC,MAAM,CAACD,MAAM,GAAGA,MAAM;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const parseSearchParams = url => {
|
|
4
|
+
const regex = /[?&]([^=#]+)=([^&#]*)/g;
|
|
5
|
+
let params = {};
|
|
6
|
+
let match;
|
|
7
|
+
while (match = regex.exec(url)) {
|
|
8
|
+
if (match[1] !== undefined && match[2] !== undefined) {
|
|
9
|
+
params[match[1]] = match[2];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return params;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=parseUrlParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseSearchParams","url","regex","params","match","exec","undefined"],"sourceRoot":"../../../src","sources":["utils/parseUrlParams.ts"],"mappings":";;AAAA,OAAO,MAAMA,iBAAiB,GAAIC,GAAW,IAAK;EAChD,MAAMC,KAAK,GAAG,wBAAwB;EAEtC,IAAIC,MAA8B,GAAG,CAAC,CAAC;EACvC,IAAIC,KAA6B;EAEjC,OAAQA,KAAK,GAAGF,KAAK,CAACG,IAAI,CAACJ,GAAG,CAAC,EAAG;IAChC,IAAIG,KAAK,CAAC,CAAC,CAAC,KAAKE,SAAS,IAAIF,KAAK,CAAC,CAAC,CAAC,KAAKE,SAAS,EAAE;MACpDH,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC;IAC7B;EACF;EAEA,OAAOD,MAAM;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./utils/mmkv-localstorage-polyfill";
|
|
2
|
+
import "./utils/buffer-polyfill";
|
|
2
3
|
import { BaseSignerClient, type AlchemySignerClientEvents, type AuthenticatingEventMetadata, type CreateAccountParams, type EmailAuthParams, type GetWebAuthnAttestationResult, type OauthConfig, type OauthParams, type OtpParams, type SignupResponse, type User } from "@account-kit/signer";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
@@ -36,6 +37,7 @@ export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
|
36
37
|
apiKey?: undefined;
|
|
37
38
|
}>;
|
|
38
39
|
rootOrgId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
oauthCallbackUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
39
41
|
}, "strip", z.ZodTypeAny, {
|
|
40
42
|
connection: {
|
|
41
43
|
apiKey: string;
|
|
@@ -54,6 +56,7 @@ export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
|
54
56
|
jwt: string;
|
|
55
57
|
apiKey?: undefined;
|
|
56
58
|
};
|
|
59
|
+
oauthCallbackUrl: string;
|
|
57
60
|
rootOrgId?: string | undefined;
|
|
58
61
|
}, {
|
|
59
62
|
connection: {
|
|
@@ -74,10 +77,13 @@ export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
|
74
77
|
apiKey?: undefined;
|
|
75
78
|
};
|
|
76
79
|
rootOrgId?: string | undefined;
|
|
80
|
+
oauthCallbackUrl?: string | undefined;
|
|
77
81
|
}>;
|
|
78
82
|
export type RNSignerClientParams = z.input<typeof RNSignerClientParamsSchema>;
|
|
79
83
|
export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
80
84
|
private stamper;
|
|
85
|
+
oauthCallbackUrl: string;
|
|
86
|
+
private validAuthenticatingTypes;
|
|
81
87
|
constructor(params: RNSignerClientParams);
|
|
82
88
|
submitOtpCode(args: Omit<OtpParams, "targetPublicKey">): Promise<{
|
|
83
89
|
bundle: string;
|
|
@@ -93,18 +99,18 @@ export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
93
99
|
authenticatingType: AuthenticatingEventMetadata["type"];
|
|
94
100
|
idToken?: string;
|
|
95
101
|
}): Promise<User>;
|
|
96
|
-
oauthWithRedirect(
|
|
102
|
+
oauthWithRedirect: (args: Extract<OauthParams, {
|
|
97
103
|
mode: "redirect";
|
|
98
|
-
}>)
|
|
104
|
+
}>) => Promise<User>;
|
|
99
105
|
oauthWithPopup(_args: Extract<OauthParams, {
|
|
100
106
|
mode: "popup";
|
|
101
107
|
}>): Promise<User>;
|
|
102
108
|
disconnect(): Promise<void>;
|
|
103
109
|
exportWallet(_params: unknown): Promise<boolean>;
|
|
104
110
|
lookupUserWithPasskey(_user?: User): Promise<User>;
|
|
105
|
-
protected getOauthConfig(): Promise<OauthConfig>;
|
|
106
111
|
protected getWebAuthnAttestation(_options: CredentialCreationOptions, _userDetails?: {
|
|
107
112
|
username: string;
|
|
108
113
|
}): Promise<GetWebAuthnAttestationResult>;
|
|
114
|
+
protected getOauthConfig: () => Promise<OauthConfig>;
|
|
109
115
|
}
|
|
110
116
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,gBAAgB,EAEhB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,qBAAa,cAAe,SAAQ,gBAAgB,CAAC,SAAS,CAAC;IAC7D,OAAO,CAAC,OAAO,CAAoB;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,wBAAwB,CAI9B;gBAEU,MAAM,EAAE,oBAAoB;IAazB,aAAa,CAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,GACvC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAYf,aAAa,CAC1B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,cAAc,CAAC;IAoBX,aAAa,CAC1B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,GAC/C,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAad,sBAAsB,CAAC,MAAM,EAAE;QAC5C,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;QACpD,kBAAkB,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACxD,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBR,iBAAiB,SAClB,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,KAC/C,OAAO,CAAC,IAAI,CAAC,CAqDd;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;cAIxC,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":"errors.d.ts","sourceRoot":"","sources":["../../../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBAAa,4BAA6B,SAAQ,SAAS;IAChD,IAAI,SAAkC;;CAMhD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { RNAlchemySigner } from "./signer";
|
|
1
|
+
export { RNAlchemySigner, type RNAlchemySignerType } from "./signer.ts";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -37,6 +37,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
37
37
|
apiKey?: undefined;
|
|
38
38
|
}>;
|
|
39
39
|
rootOrgId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
oauthCallbackUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
40
41
|
}, "strip", z.ZodTypeAny, {
|
|
41
42
|
connection: {
|
|
42
43
|
apiKey: string;
|
|
@@ -55,6 +56,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
55
56
|
jwt: string;
|
|
56
57
|
apiKey?: undefined;
|
|
57
58
|
};
|
|
59
|
+
oauthCallbackUrl: string;
|
|
58
60
|
rootOrgId?: string | undefined;
|
|
59
61
|
}, {
|
|
60
62
|
connection: {
|
|
@@ -75,6 +77,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
75
77
|
apiKey?: undefined;
|
|
76
78
|
};
|
|
77
79
|
rootOrgId?: string | undefined;
|
|
80
|
+
oauthCallbackUrl?: string | undefined;
|
|
78
81
|
}>]>;
|
|
79
82
|
sessionConfig: z.ZodOptional<z.ZodObject<Omit<{
|
|
80
83
|
sessionKey: z.ZodDefault<z.ZodString>;
|
|
@@ -107,6 +110,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
107
110
|
jwt: string;
|
|
108
111
|
apiKey?: undefined;
|
|
109
112
|
};
|
|
113
|
+
oauthCallbackUrl: string;
|
|
110
114
|
rootOrgId?: string | undefined;
|
|
111
115
|
} | RNSignerClient) & ({
|
|
112
116
|
connection: {
|
|
@@ -126,6 +130,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
126
130
|
jwt: string;
|
|
127
131
|
apiKey?: undefined;
|
|
128
132
|
};
|
|
133
|
+
oauthCallbackUrl: string;
|
|
129
134
|
rootOrgId?: string | undefined;
|
|
130
135
|
} | RNSignerClient | undefined);
|
|
131
136
|
sessionConfig?: {
|
|
@@ -152,6 +157,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
152
157
|
apiKey?: undefined;
|
|
153
158
|
};
|
|
154
159
|
rootOrgId?: string | undefined;
|
|
160
|
+
oauthCallbackUrl?: string | undefined;
|
|
155
161
|
} | RNSignerClient) & ({
|
|
156
162
|
connection: {
|
|
157
163
|
apiKey: string;
|
|
@@ -171,6 +177,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
171
177
|
apiKey?: undefined;
|
|
172
178
|
};
|
|
173
179
|
rootOrgId?: string | undefined;
|
|
180
|
+
oauthCallbackUrl?: string | undefined;
|
|
174
181
|
} | RNSignerClient | undefined);
|
|
175
182
|
sessionConfig?: {
|
|
176
183
|
sessionKey?: string | undefined;
|
|
@@ -178,6 +185,12 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
178
185
|
} | undefined;
|
|
179
186
|
}>;
|
|
180
187
|
export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;
|
|
181
|
-
export declare
|
|
188
|
+
export declare class RNAlchemySignerSingleton extends BaseAlchemySigner<RNSignerClient> {
|
|
189
|
+
private static instance;
|
|
190
|
+
private constructor();
|
|
191
|
+
static getInstance(params: RNAlchemySignerParams): RNAlchemySignerSingleton;
|
|
192
|
+
}
|
|
193
|
+
export declare function RNAlchemySigner(params: RNAlchemySignerParams): RNAlchemySignerSingleton;
|
|
194
|
+
export type RNAlchemySignerType = RNAlchemySignerSingleton;
|
|
182
195
|
export {};
|
|
183
196
|
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AAEtE,QAAA,MAAM,2BAA2B
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AAEtE,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEgC,EAAG,UAElE,CAAC,EAAE,SACH;iBAAe,EAAG,QAAQ,EAAE,EAAE,UAAU,CAAC,EAAE,OAAO,uCAEnC,EACb,OAAE,UAAS,EACb,UAEA;0BAAmC,EAAG,UAAU,CAAC,EAAE,SAAS;gBAAc,EAAG,OAE3E,0DAA2B,EAAG,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAJxC,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,qBAAa,wBAAyB,SAAQ,iBAAiB,CAAC,cAAc,CAAC;IAC7E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAElD,OAAO;WAsBO,WAAW,CAAC,MAAM,EAAE,qBAAqB;CAMxD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,4BAI5D;AAED,MAAM,MAAM,mBAAmB,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64UrlEncode.d.ts","sourceRoot":"","sources":["../../../../../src/utils/base64UrlEncode.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,cACf,WAAW,GAAG,eAAe,KACvC,MAMF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-polyfill.d.ts","sourceRoot":"","sources":["../../../../../src/utils/buffer-polyfill.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseUrlParams.d.ts","sourceRoot":"","sources":["../../../../../src/utils/parseUrlParams.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAS,MAAM,2BAa5C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./utils/mmkv-localstorage-polyfill";
|
|
2
|
+
import "./utils/buffer-polyfill";
|
|
2
3
|
import { BaseSignerClient, type AlchemySignerClientEvents, type AuthenticatingEventMetadata, type CreateAccountParams, type EmailAuthParams, type GetWebAuthnAttestationResult, type OauthConfig, type OauthParams, type OtpParams, type SignupResponse, type User } from "@account-kit/signer";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
@@ -36,6 +37,7 @@ export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
|
36
37
|
apiKey?: undefined;
|
|
37
38
|
}>;
|
|
38
39
|
rootOrgId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
oauthCallbackUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
39
41
|
}, "strip", z.ZodTypeAny, {
|
|
40
42
|
connection: {
|
|
41
43
|
apiKey: string;
|
|
@@ -54,6 +56,7 @@ export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
|
54
56
|
jwt: string;
|
|
55
57
|
apiKey?: undefined;
|
|
56
58
|
};
|
|
59
|
+
oauthCallbackUrl: string;
|
|
57
60
|
rootOrgId?: string | undefined;
|
|
58
61
|
}, {
|
|
59
62
|
connection: {
|
|
@@ -74,10 +77,13 @@ export declare const RNSignerClientParamsSchema: z.ZodObject<{
|
|
|
74
77
|
apiKey?: undefined;
|
|
75
78
|
};
|
|
76
79
|
rootOrgId?: string | undefined;
|
|
80
|
+
oauthCallbackUrl?: string | undefined;
|
|
77
81
|
}>;
|
|
78
82
|
export type RNSignerClientParams = z.input<typeof RNSignerClientParamsSchema>;
|
|
79
83
|
export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
80
84
|
private stamper;
|
|
85
|
+
oauthCallbackUrl: string;
|
|
86
|
+
private validAuthenticatingTypes;
|
|
81
87
|
constructor(params: RNSignerClientParams);
|
|
82
88
|
submitOtpCode(args: Omit<OtpParams, "targetPublicKey">): Promise<{
|
|
83
89
|
bundle: string;
|
|
@@ -93,18 +99,18 @@ export declare class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
93
99
|
authenticatingType: AuthenticatingEventMetadata["type"];
|
|
94
100
|
idToken?: string;
|
|
95
101
|
}): Promise<User>;
|
|
96
|
-
oauthWithRedirect(
|
|
102
|
+
oauthWithRedirect: (args: Extract<OauthParams, {
|
|
97
103
|
mode: "redirect";
|
|
98
|
-
}>)
|
|
104
|
+
}>) => Promise<User>;
|
|
99
105
|
oauthWithPopup(_args: Extract<OauthParams, {
|
|
100
106
|
mode: "popup";
|
|
101
107
|
}>): Promise<User>;
|
|
102
108
|
disconnect(): Promise<void>;
|
|
103
109
|
exportWallet(_params: unknown): Promise<boolean>;
|
|
104
110
|
lookupUserWithPasskey(_user?: User): Promise<User>;
|
|
105
|
-
protected getOauthConfig(): Promise<OauthConfig>;
|
|
106
111
|
protected getWebAuthnAttestation(_options: CredentialCreationOptions, _userDetails?: {
|
|
107
112
|
username: string;
|
|
108
113
|
}): Promise<GetWebAuthnAttestationResult>;
|
|
114
|
+
protected getOauthConfig: () => Promise<OauthConfig>;
|
|
109
115
|
}
|
|
110
116
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EACL,gBAAgB,EAEhB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,qBAAa,cAAe,SAAQ,gBAAgB,CAAC,SAAS,CAAC;IAC7D,OAAO,CAAC,OAAO,CAAoB;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,wBAAwB,CAI9B;gBAEU,MAAM,EAAE,oBAAoB;IAazB,aAAa,CAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,GACvC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAYf,aAAa,CAC1B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,cAAc,CAAC;IAoBX,aAAa,CAC1B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,GAC/C,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAad,sBAAsB,CAAC,MAAM,EAAE;QAC5C,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;QACpD,kBAAkB,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACxD,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBR,iBAAiB,SAClB,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,KAC/C,OAAO,CAAC,IAAI,CAAC,CAqDd;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;cAIxC,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":"errors.d.ts","sourceRoot":"","sources":["../../../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBAAa,4BAA6B,SAAQ,SAAS;IAChD,IAAI,SAAkC;;CAMhD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { RNAlchemySigner } from "./signer";
|
|
1
|
+
export { RNAlchemySigner, type RNAlchemySignerType } from "./signer.ts";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -37,6 +37,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
37
37
|
apiKey?: undefined;
|
|
38
38
|
}>;
|
|
39
39
|
rootOrgId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
oauthCallbackUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
40
41
|
}, "strip", z.ZodTypeAny, {
|
|
41
42
|
connection: {
|
|
42
43
|
apiKey: string;
|
|
@@ -55,6 +56,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
55
56
|
jwt: string;
|
|
56
57
|
apiKey?: undefined;
|
|
57
58
|
};
|
|
59
|
+
oauthCallbackUrl: string;
|
|
58
60
|
rootOrgId?: string | undefined;
|
|
59
61
|
}, {
|
|
60
62
|
connection: {
|
|
@@ -75,6 +77,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
75
77
|
apiKey?: undefined;
|
|
76
78
|
};
|
|
77
79
|
rootOrgId?: string | undefined;
|
|
80
|
+
oauthCallbackUrl?: string | undefined;
|
|
78
81
|
}>]>;
|
|
79
82
|
sessionConfig: z.ZodOptional<z.ZodObject<Omit<{
|
|
80
83
|
sessionKey: z.ZodDefault<z.ZodString>;
|
|
@@ -107,6 +110,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
107
110
|
jwt: string;
|
|
108
111
|
apiKey?: undefined;
|
|
109
112
|
};
|
|
113
|
+
oauthCallbackUrl: string;
|
|
110
114
|
rootOrgId?: string | undefined;
|
|
111
115
|
} | RNSignerClient) & ({
|
|
112
116
|
connection: {
|
|
@@ -126,6 +130,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
126
130
|
jwt: string;
|
|
127
131
|
apiKey?: undefined;
|
|
128
132
|
};
|
|
133
|
+
oauthCallbackUrl: string;
|
|
129
134
|
rootOrgId?: string | undefined;
|
|
130
135
|
} | RNSignerClient | undefined);
|
|
131
136
|
sessionConfig?: {
|
|
@@ -152,6 +157,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
152
157
|
apiKey?: undefined;
|
|
153
158
|
};
|
|
154
159
|
rootOrgId?: string | undefined;
|
|
160
|
+
oauthCallbackUrl?: string | undefined;
|
|
155
161
|
} | RNSignerClient) & ({
|
|
156
162
|
connection: {
|
|
157
163
|
apiKey: string;
|
|
@@ -171,6 +177,7 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
171
177
|
apiKey?: undefined;
|
|
172
178
|
};
|
|
173
179
|
rootOrgId?: string | undefined;
|
|
180
|
+
oauthCallbackUrl?: string | undefined;
|
|
174
181
|
} | RNSignerClient | undefined);
|
|
175
182
|
sessionConfig?: {
|
|
176
183
|
sessionKey?: string | undefined;
|
|
@@ -178,6 +185,12 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
178
185
|
} | undefined;
|
|
179
186
|
}>;
|
|
180
187
|
export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;
|
|
181
|
-
export declare
|
|
188
|
+
export declare class RNAlchemySignerSingleton extends BaseAlchemySigner<RNSignerClient> {
|
|
189
|
+
private static instance;
|
|
190
|
+
private constructor();
|
|
191
|
+
static getInstance(params: RNAlchemySignerParams): RNAlchemySignerSingleton;
|
|
192
|
+
}
|
|
193
|
+
export declare function RNAlchemySigner(params: RNAlchemySignerParams): RNAlchemySignerSingleton;
|
|
194
|
+
export type RNAlchemySignerType = RNAlchemySignerSingleton;
|
|
182
195
|
export {};
|
|
183
196
|
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AAEtE,QAAA,MAAM,2BAA2B
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AAEtE,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAEgC,EAAG,UAElE,CAAC,EAAE,SACH;iBAAe,EAAG,QAAQ,EAAE,EAAE,UAAU,CAAC,EAAE,OAAO,uCAEnC,EACb,OAAE,UAAS,EACb,UAEA;0BAAmC,EAAG,UAAU,CAAC,EAAE,SAAS;gBAAc,EAAG,OAE3E,0DAA2B,EAAG,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAJxC,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,qBAAa,wBAAyB,SAAQ,iBAAiB,CAAC,cAAc,CAAC;IAC7E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAElD,OAAO;WAsBO,WAAW,CAAC,MAAM,EAAE,qBAAqB;CAMxD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,4BAI5D;AAED,MAAM,MAAM,mBAAmB,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64UrlEncode.d.ts","sourceRoot":"","sources":["../../../../../src/utils/base64UrlEncode.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,cACf,WAAW,GAAG,eAAe,KACvC,MAMF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-polyfill.d.ts","sourceRoot":"","sources":["../../../../../src/utils/buffer-polyfill.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseUrlParams.d.ts","sourceRoot":"","sources":["../../../../../src/utils/parseUrlParams.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,QAAS,MAAM,2BAa5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/react-native-signer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"author": "Alchemy",
|
|
5
5
|
"description": "React Native compatible Account Kit signer",
|
|
6
6
|
"source": "./src/index.tsx",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"react": "18.3.1",
|
|
80
80
|
"react-native": "0.76.5",
|
|
81
81
|
"react-native-builder-bob": "^0.30.3",
|
|
82
|
+
"react-native-inappbrowser-reborn": "^3.7.0",
|
|
82
83
|
"react-native-mmkv": "^3.1.0",
|
|
83
84
|
"release-it": "^15.0.0",
|
|
84
85
|
"turbo": "^1.10.7",
|
|
@@ -93,6 +94,7 @@
|
|
|
93
94
|
"react-native": "*",
|
|
94
95
|
"react-native-config": "1.5.3",
|
|
95
96
|
"react-native-gesture-handler": "2.21.2",
|
|
97
|
+
"react-native-inappbrowser-reborn": "^3.7.0",
|
|
96
98
|
"react-native-mmkv": "^3.1.0"
|
|
97
99
|
},
|
|
98
100
|
"jest": {
|
|
@@ -147,9 +149,9 @@
|
|
|
147
149
|
"version": "0.42.2"
|
|
148
150
|
},
|
|
149
151
|
"dependencies": {
|
|
150
|
-
"@aa-sdk/core": "^4.
|
|
151
|
-
"@account-kit/signer": "^4.
|
|
152
|
+
"@aa-sdk/core": "^4.10.0",
|
|
153
|
+
"@account-kit/signer": "^4.10.0",
|
|
152
154
|
"viem": "^2.21.40"
|
|
153
155
|
},
|
|
154
|
-
"gitHead": "
|
|
156
|
+
"gitHead": "8acd2d8e45410bfb2d7e4447d3a130e23e605cd4"
|
|
155
157
|
}
|
package/src/client.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/* eslint-disable import/extensions */
|
|
2
2
|
import "./utils/mmkv-localstorage-polyfill";
|
|
3
|
+
import "./utils/buffer-polyfill";
|
|
3
4
|
import { type ConnectionConfig } from "@aa-sdk/core";
|
|
4
5
|
import {
|
|
5
6
|
BaseSignerClient,
|
|
7
|
+
OauthFailedError,
|
|
6
8
|
type AlchemySignerClientEvents,
|
|
7
9
|
type AuthenticatingEventMetadata,
|
|
8
10
|
type CreateAccountParams,
|
|
@@ -16,10 +18,17 @@ import {
|
|
|
16
18
|
} from "@account-kit/signer";
|
|
17
19
|
import NativeTEKStamper from "./NativeTEKStamper";
|
|
18
20
|
import { z } from "zod";
|
|
21
|
+
import { InAppBrowser } from "react-native-inappbrowser-reborn";
|
|
22
|
+
import { parseSearchParams } from "./utils/parseUrlParams";
|
|
23
|
+
import { InAppBrowserUnavailableError } from "./errors";
|
|
19
24
|
|
|
20
25
|
export const RNSignerClientParamsSchema = z.object({
|
|
21
26
|
connection: z.custom<ConnectionConfig>(),
|
|
22
27
|
rootOrgId: z.string().optional(),
|
|
28
|
+
oauthCallbackUrl: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.default("https://signer.alchemy.com/callback"),
|
|
23
32
|
});
|
|
24
33
|
|
|
25
34
|
export type RNSignerClientParams = z.input<typeof RNSignerClientParamsSchema>;
|
|
@@ -27,14 +36,24 @@ export type RNSignerClientParams = z.input<typeof RNSignerClientParamsSchema>;
|
|
|
27
36
|
// TODO: need to emit events
|
|
28
37
|
export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
29
38
|
private stamper = NativeTEKStamper;
|
|
39
|
+
oauthCallbackUrl: string;
|
|
40
|
+
private validAuthenticatingTypes: AuthenticatingEventMetadata["type"][] = [
|
|
41
|
+
"email",
|
|
42
|
+
"otp",
|
|
43
|
+
"oauth",
|
|
44
|
+
];
|
|
45
|
+
|
|
30
46
|
constructor(params: RNSignerClientParams) {
|
|
31
|
-
const { connection, rootOrgId } =
|
|
47
|
+
const { connection, rootOrgId, oauthCallbackUrl } =
|
|
48
|
+
RNSignerClientParamsSchema.parse(params);
|
|
32
49
|
|
|
33
50
|
super({
|
|
34
51
|
stamper: NativeTEKStamper,
|
|
35
52
|
rootOrgId: rootOrgId ?? "24c1acf5-810f-41e0-a503-d5d13fa8e830",
|
|
36
53
|
connection,
|
|
37
54
|
});
|
|
55
|
+
|
|
56
|
+
this.oauthCallbackUrl = oauthCallbackUrl;
|
|
38
57
|
}
|
|
39
58
|
|
|
40
59
|
override async submitOtpCode(
|
|
@@ -95,14 +114,14 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
95
114
|
authenticatingType: AuthenticatingEventMetadata["type"];
|
|
96
115
|
idToken?: string;
|
|
97
116
|
}): Promise<User> {
|
|
98
|
-
if (
|
|
99
|
-
params.authenticatingType !== "email" &&
|
|
100
|
-
params.authenticatingType !== "otp"
|
|
101
|
-
) {
|
|
117
|
+
if (!this.validAuthenticatingTypes.includes(params.authenticatingType)) {
|
|
102
118
|
throw new Error("Unsupported authenticating type");
|
|
103
119
|
}
|
|
104
120
|
|
|
105
|
-
this.eventEmitter.emit("authenticating", {
|
|
121
|
+
this.eventEmitter.emit("authenticating", {
|
|
122
|
+
type: params.authenticatingType,
|
|
123
|
+
});
|
|
124
|
+
|
|
106
125
|
await this.stamper.init();
|
|
107
126
|
|
|
108
127
|
const result = await this.stamper.injectCredentialBundle(params.bundle);
|
|
@@ -116,15 +135,67 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
116
135
|
this.eventEmitter.emit(params.connectedEventName, user, params.bundle);
|
|
117
136
|
return user;
|
|
118
137
|
}
|
|
119
|
-
override oauthWithRedirect(
|
|
120
|
-
|
|
121
|
-
): Promise<
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
override oauthWithRedirect = async (
|
|
139
|
+
args: Extract<OauthParams, { mode: "redirect" }>
|
|
140
|
+
): Promise<User> => {
|
|
141
|
+
// Ensure the In-App Browser required for authentication is available
|
|
142
|
+
if (!(await InAppBrowser.isAvailable())) {
|
|
143
|
+
throw new InAppBrowserUnavailableError();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.eventEmitter.emit("authenticating", { type: "oauth" });
|
|
147
|
+
|
|
148
|
+
const oauthParams = args;
|
|
149
|
+
const turnkeyPublicKey = await this.stamper.init();
|
|
150
|
+
const oauthCallbackUrl = this.oauthCallbackUrl;
|
|
151
|
+
const oauthConfig = await this.getOauthConfig();
|
|
152
|
+
const providerUrl = await this.getOauthProviderUrl({
|
|
153
|
+
oauthParams,
|
|
154
|
+
turnkeyPublicKey,
|
|
155
|
+
oauthCallbackUrl,
|
|
156
|
+
oauthConfig,
|
|
157
|
+
usesRelativeUrl: false,
|
|
158
|
+
});
|
|
159
|
+
const redirectUrl = args.redirectUrl;
|
|
160
|
+
const res = await InAppBrowser.openAuth(providerUrl, redirectUrl);
|
|
161
|
+
|
|
162
|
+
if (res.type !== "success" || !res.url) {
|
|
163
|
+
throw new OauthFailedError("An error occured completing your request");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const authResult = parseSearchParams(res.url);
|
|
167
|
+
const bundle = authResult["alchemy-bundle"] ?? "";
|
|
168
|
+
const orgId = authResult["alchemy-org-id"] ?? "";
|
|
169
|
+
const idToken = authResult["alchemy-id-token"] ?? "";
|
|
170
|
+
const isSignup = authResult["alchemy-is-signup"];
|
|
171
|
+
const error = authResult["alchemy-error"];
|
|
172
|
+
|
|
173
|
+
if (bundle && orgId && idToken) {
|
|
174
|
+
const user = await this.completeAuthWithBundle({
|
|
175
|
+
bundle,
|
|
176
|
+
orgId,
|
|
177
|
+
connectedEventName: "connectedOauth",
|
|
178
|
+
idToken,
|
|
179
|
+
authenticatingType: "oauth",
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
if (isSignup) {
|
|
183
|
+
this.eventEmitter.emit("newUserSignup");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return user;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Throw the Alchemy error if available, otherwise throw a generic error.
|
|
190
|
+
throw new OauthFailedError(
|
|
191
|
+
error ?? "An error occured completing your request"
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
|
|
124
195
|
override oauthWithPopup(
|
|
125
196
|
_args: Extract<OauthParams, { mode: "popup" }>
|
|
126
197
|
): Promise<User> {
|
|
127
|
-
throw new Error("Method not implemented
|
|
198
|
+
throw new Error("Method not implemented");
|
|
128
199
|
}
|
|
129
200
|
|
|
130
201
|
override async disconnect(): Promise<void> {
|
|
@@ -138,13 +209,18 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
138
209
|
override lookupUserWithPasskey(_user?: User): Promise<User> {
|
|
139
210
|
throw new Error("Method not implemented.");
|
|
140
211
|
}
|
|
141
|
-
|
|
142
|
-
throw new Error("Method not implemented.");
|
|
143
|
-
}
|
|
212
|
+
|
|
144
213
|
protected override getWebAuthnAttestation(
|
|
145
214
|
_options: CredentialCreationOptions,
|
|
146
215
|
_userDetails?: { username: string }
|
|
147
216
|
): Promise<GetWebAuthnAttestationResult> {
|
|
148
217
|
throw new Error("Method not implemented.");
|
|
149
218
|
}
|
|
219
|
+
|
|
220
|
+
protected override getOauthConfig = async (): Promise<OauthConfig> => {
|
|
221
|
+
const publicKey = await this.stamper.init();
|
|
222
|
+
|
|
223
|
+
const nonce = this.getOauthNonce(publicKey);
|
|
224
|
+
return this.request("/v1/prepare-oauth", { nonce });
|
|
225
|
+
};
|
|
150
226
|
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseError } from "@aa-sdk/core";
|
|
2
|
+
|
|
3
|
+
export class InAppBrowserUnavailableError extends BaseError {
|
|
4
|
+
override name = "InAppBrowserUnavailableError";
|
|
5
|
+
constructor() {
|
|
6
|
+
super(
|
|
7
|
+
"In-App Browser is not available. Please authenticate with a different method."
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
}
|