@account-kit/signer 4.0.0-beta.8 → 4.0.0-beta.9
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/dist/esm/base.d.ts +4 -2
- package/dist/esm/base.js +40 -20
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +5 -11
- package/dist/esm/client/base.js +11 -1
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +13 -5
- package/dist/esm/client/index.js +17 -8
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +2 -0
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/signer.d.ts +1 -0
- package/dist/esm/signer.js +46 -3
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/types.d.ts +5 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/base.d.ts +4 -2
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +5 -11
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +13 -5
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +2 -0
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/signer.d.ts +1 -0
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -3
- package/src/base.ts +54 -24
- package/src/client/base.ts +16 -1
- package/src/client/index.ts +20 -7
- package/src/client/types.ts +2 -0
- package/src/signer.ts +60 -5
- package/src/types.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,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M,mBAAmB,GAC3B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE3C,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1E,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAE7C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQlC,CAAC;AAEL,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,sBAAsB,CAAC;IAC7E;;;;;;;;;;;;;;;;;;;;OAoBG;gBACS,MAAM,EAAE,mBAAmB;CAuCxC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type AlchemySignerEvents = {
|
|
|
3
3
|
connected(user: User): void;
|
|
4
4
|
disconnected(): void;
|
|
5
5
|
statusChanged(status: AlchemySignerStatus): void;
|
|
6
|
+
errorChanged(error: ErrorInfo | undefined): void;
|
|
6
7
|
};
|
|
7
8
|
export type AlchemySignerEvent = keyof AlchemySignerEvents;
|
|
8
9
|
export declare enum AlchemySignerStatus {
|
|
@@ -12,4 +13,8 @@ export declare enum AlchemySignerStatus {
|
|
|
12
13
|
AUTHENTICATING = "AUTHENTICATING",
|
|
13
14
|
AWAITING_EMAIL_AUTH = "AWAITING_EMAIL_AUTH"
|
|
14
15
|
}
|
|
16
|
+
export interface ErrorInfo {
|
|
17
|
+
name: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
15
20
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,YAAY,IAAI,IAAI,CAAC;IACrB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,mBAAmB,CAAC;AAE3D,oBAAY,mBAAmB;IAC7B,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;CAC5C"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,YAAY,IAAI,IAAI,CAAC;IACrB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,mBAAmB,CAAC;AAE3D,oBAAY,mBAAmB;IAC7B,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;CAC5C;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.0.0-beta.
|
|
1
|
+
export declare const VERSION = "4.0.0-beta.9";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/signer",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.9",
|
|
4
4
|
"description": "Core interfaces and clients for interfacing with the Alchemy Signer API",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,11 +49,12 @@
|
|
|
49
49
|
"vitest": "^2.0.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aa-sdk/core": "^4.0.0-beta.
|
|
52
|
+
"@aa-sdk/core": "^4.0.0-beta.9",
|
|
53
53
|
"@turnkey/http": "^2.6.2",
|
|
54
54
|
"@turnkey/iframe-stamper": "^1.0.0",
|
|
55
55
|
"@turnkey/viem": "^0.4.8",
|
|
56
56
|
"@turnkey/webauthn-stamper": "^0.4.3",
|
|
57
|
+
"jwt-decode": "^4.0.0",
|
|
57
58
|
"zod": "^3.22.4"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
72
73
|
},
|
|
73
74
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "6c5f0ff3863587178909a4df689df3d8379b1851"
|
|
75
76
|
}
|
package/src/base.ts
CHANGED
|
@@ -27,17 +27,20 @@ import {
|
|
|
27
27
|
AlchemySignerStatus,
|
|
28
28
|
type AlchemySignerEvent,
|
|
29
29
|
type AlchemySignerEvents,
|
|
30
|
+
type ErrorInfo,
|
|
30
31
|
} from "./types.js";
|
|
31
32
|
import { assertNever } from "./utils/typeAssertions.js";
|
|
32
33
|
|
|
33
34
|
export interface BaseAlchemySignerParams<TClient extends BaseSignerClient> {
|
|
34
35
|
client: TClient;
|
|
35
36
|
sessionConfig?: Omit<SessionManagerParams, "client">;
|
|
37
|
+
initialError?: ErrorInfo;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
type AlchemySignerStore = {
|
|
39
41
|
user: User | null;
|
|
40
42
|
status: AlchemySignerStatus;
|
|
43
|
+
error: ErrorInfo | null;
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
type InternalStore = Mutate<
|
|
@@ -65,8 +68,13 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
65
68
|
* @param {BaseAlchemySignerParams<TClient>} param0 Object containing the client and session configuration
|
|
66
69
|
* @param {TClient} param0.client The client instance to be used internally
|
|
67
70
|
* @param {SessionConfig} param0.sessionConfig Configuration for managing sessions
|
|
71
|
+
* @param {ErrorInfo | undefined} param0.initialError Error already present on the signer when initialized, if any
|
|
68
72
|
*/
|
|
69
|
-
constructor({
|
|
73
|
+
constructor({
|
|
74
|
+
client,
|
|
75
|
+
sessionConfig,
|
|
76
|
+
initialError,
|
|
77
|
+
}: BaseAlchemySignerParams<TClient>) {
|
|
70
78
|
this.inner = client;
|
|
71
79
|
this.store = createStore(
|
|
72
80
|
subscribeWithSelector(
|
|
@@ -74,6 +82,7 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
74
82
|
({
|
|
75
83
|
user: null,
|
|
76
84
|
status: AlchemySignerStatus.INITIALIZING,
|
|
85
|
+
error: initialError ?? null,
|
|
77
86
|
} satisfies AlchemySignerStore)
|
|
78
87
|
)
|
|
79
88
|
);
|
|
@@ -84,15 +93,6 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
84
93
|
...sessionConfig,
|
|
85
94
|
client: this.inner,
|
|
86
95
|
});
|
|
87
|
-
this.store = createStore(
|
|
88
|
-
subscribeWithSelector(
|
|
89
|
-
() =>
|
|
90
|
-
({
|
|
91
|
-
user: null,
|
|
92
|
-
status: AlchemySignerStatus.INITIALIZING,
|
|
93
|
-
} satisfies AlchemySignerStore)
|
|
94
|
-
)
|
|
95
|
-
);
|
|
96
96
|
// register listeners first
|
|
97
97
|
this.registerListeners();
|
|
98
98
|
// then initialize so that we can catch those events
|
|
@@ -138,8 +138,17 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
138
138
|
listener as AlchemySignerEvents["statusChanged"],
|
|
139
139
|
{ fireImmediately: true }
|
|
140
140
|
);
|
|
141
|
+
case "errorChanged":
|
|
142
|
+
return this.store.subscribe(
|
|
143
|
+
({ error }) => error,
|
|
144
|
+
(error) =>
|
|
145
|
+
(listener as AlchemySignerEvents["errorChanged"])(
|
|
146
|
+
error ?? undefined
|
|
147
|
+
),
|
|
148
|
+
{ fireImmediately: true }
|
|
149
|
+
);
|
|
141
150
|
default:
|
|
142
|
-
|
|
151
|
+
assertNever(event, `Unknown event type ${event}`);
|
|
143
152
|
}
|
|
144
153
|
};
|
|
145
154
|
|
|
@@ -203,17 +212,22 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
203
212
|
*/
|
|
204
213
|
authenticate: (params: AuthParams) => Promise<User> = async (params) => {
|
|
205
214
|
const { type } = params;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
try {
|
|
216
|
+
switch (type) {
|
|
217
|
+
case "email":
|
|
218
|
+
return this.authenticateWithEmail(params);
|
|
219
|
+
case "passkey":
|
|
220
|
+
return this.authenticateWithPasskey(params);
|
|
221
|
+
case "oauth":
|
|
222
|
+
return this.authenticateWithOauth(params);
|
|
223
|
+
case "oauthReturn":
|
|
224
|
+
return this.handleOauthReturn(params);
|
|
225
|
+
default:
|
|
226
|
+
assertNever(type, `Unknown auth type: ${type}`);
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
this.store.setState({ error: toErrorInfo(error) });
|
|
230
|
+
throw error;
|
|
217
231
|
}
|
|
218
232
|
};
|
|
219
233
|
|
|
@@ -577,7 +591,10 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
577
591
|
});
|
|
578
592
|
|
|
579
593
|
this.sessionManager.setTemporarySession({ orgId });
|
|
580
|
-
this.store.setState({
|
|
594
|
+
this.store.setState({
|
|
595
|
+
status: AlchemySignerStatus.AWAITING_EMAIL_AUTH,
|
|
596
|
+
error: null,
|
|
597
|
+
});
|
|
581
598
|
|
|
582
599
|
// We wait for the session manager to emit a connected event if
|
|
583
600
|
// cross tab sessions are permitted
|
|
@@ -667,11 +684,13 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
667
684
|
private handleOauthReturn = ({
|
|
668
685
|
bundle,
|
|
669
686
|
orgId,
|
|
687
|
+
idToken,
|
|
670
688
|
}: Extract<AuthParams, { type: "oauthReturn" }>): Promise<User> =>
|
|
671
689
|
this.inner.completeAuthWithBundle({
|
|
672
690
|
bundle,
|
|
673
691
|
orgId,
|
|
674
692
|
connectedEventName: "connectedOauth",
|
|
693
|
+
idToken,
|
|
675
694
|
});
|
|
676
695
|
|
|
677
696
|
private registerListeners = () => {
|
|
@@ -679,6 +698,7 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
679
698
|
this.store.setState({
|
|
680
699
|
user: session.user,
|
|
681
700
|
status: AlchemySignerStatus.CONNECTED,
|
|
701
|
+
error: null,
|
|
682
702
|
});
|
|
683
703
|
});
|
|
684
704
|
|
|
@@ -694,11 +714,21 @@ export abstract class BaseAlchemySigner<TClient extends BaseSignerClient>
|
|
|
694
714
|
status: state.user
|
|
695
715
|
? AlchemySignerStatus.CONNECTED
|
|
696
716
|
: AlchemySignerStatus.DISCONNECTED,
|
|
717
|
+
...(state.user ? { error: null } : undefined),
|
|
697
718
|
}));
|
|
698
719
|
});
|
|
699
720
|
|
|
700
721
|
this.inner.on("authenticating", () => {
|
|
701
|
-
this.store.setState({
|
|
722
|
+
this.store.setState({
|
|
723
|
+
status: AlchemySignerStatus.AUTHENTICATING,
|
|
724
|
+
error: null,
|
|
725
|
+
});
|
|
702
726
|
});
|
|
703
727
|
};
|
|
704
728
|
}
|
|
729
|
+
|
|
730
|
+
function toErrorInfo(error: unknown): ErrorInfo {
|
|
731
|
+
return error instanceof Error
|
|
732
|
+
? { name: error.name, message: error.message }
|
|
733
|
+
: { name: "Error", message: "Unknown error" };
|
|
734
|
+
}
|
package/src/client/base.ts
CHANGED
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
User,
|
|
20
20
|
} from "./types.js";
|
|
21
21
|
import { assertNever } from "../utils/typeAssertions.js";
|
|
22
|
+
import { jwtDecode } from "jwt-decode";
|
|
22
23
|
|
|
23
24
|
export interface BaseSignerClientParams {
|
|
24
25
|
stamper: TurnkeyClient["stamper"];
|
|
@@ -130,6 +131,7 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
130
131
|
bundle: string;
|
|
131
132
|
orgId: string;
|
|
132
133
|
connectedEventName: keyof AlchemySignerClientEvents;
|
|
134
|
+
idToken?: string;
|
|
133
135
|
}): Promise<User>;
|
|
134
136
|
|
|
135
137
|
public abstract oauthWithRedirect(
|
|
@@ -217,10 +219,14 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
217
219
|
* Retrieves the current user or fetches the user information if not already available.
|
|
218
220
|
*
|
|
219
221
|
* @param {string} [orgId] optional organization ID, defaults to the user's organization ID
|
|
222
|
+
* @param {string} idToken an OIDC ID token containing additional user information
|
|
220
223
|
* @returns {Promise<User>} A promise that resolves to the user object
|
|
221
224
|
* @throws {Error} if no organization ID is provided when there is no current user
|
|
222
225
|
*/
|
|
223
|
-
public whoami = async (
|
|
226
|
+
public whoami = async (
|
|
227
|
+
orgId = this.user?.orgId,
|
|
228
|
+
idToken?: string
|
|
229
|
+
): Promise<User> => {
|
|
224
230
|
if (this.user) {
|
|
225
231
|
return this.user;
|
|
226
232
|
}
|
|
@@ -237,6 +243,15 @@ export abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
237
243
|
stampedRequest,
|
|
238
244
|
});
|
|
239
245
|
|
|
246
|
+
if (idToken) {
|
|
247
|
+
const claims: Record<string, unknown> = jwtDecode(idToken);
|
|
248
|
+
user.idToken = idToken;
|
|
249
|
+
user.claims = claims;
|
|
250
|
+
if (typeof claims.email === "string") {
|
|
251
|
+
user.email = claims.email;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
240
255
|
const credentialId = (() => {
|
|
241
256
|
try {
|
|
242
257
|
return JSON.parse(stampedRequest?.stamp.stampHeaderValue)
|
package/src/client/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { getWebAuthnAttestation } from "@turnkey/http";
|
|
|
3
3
|
import { IframeStamper } from "@turnkey/iframe-stamper";
|
|
4
4
|
import { WebauthnStamper } from "@turnkey/webauthn-stamper";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { getDefaultScopeAndClaims, getOauthNonce } from "../oauth.js";
|
|
7
|
+
import type { AuthParams, OauthMode } from "../signer.js";
|
|
6
8
|
import { base64UrlEncode } from "../utils/base64UrlEncode.js";
|
|
7
9
|
import { generateRandomBuffer } from "../utils/generateRandomBuffer.js";
|
|
8
10
|
import { BaseSignerClient } from "./base.js";
|
|
@@ -16,8 +18,6 @@ import type {
|
|
|
16
18
|
OauthParams,
|
|
17
19
|
User,
|
|
18
20
|
} from "./types.js";
|
|
19
|
-
import { getDefaultScopeAndClaims, getOauthNonce } from "../oauth.js";
|
|
20
|
-
import type { AuthParams, OauthMode } from "../signer.js";
|
|
21
21
|
|
|
22
22
|
const CHECK_CLOSE_INTERVAL = 500;
|
|
23
23
|
|
|
@@ -215,7 +215,9 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
* Completes auth for the user by injecting a credential bundle and retrieving
|
|
218
|
+
* Completes auth for the user by injecting a credential bundle and retrieving
|
|
219
|
+
* the user information based on the provided organization ID. Emits events
|
|
220
|
+
* during the process.
|
|
219
221
|
*
|
|
220
222
|
* @example
|
|
221
223
|
* ```ts
|
|
@@ -233,17 +235,24 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
233
235
|
* const account = await client.completeAuthWithBundle({ orgId: "user-org-id", bundle: "bundle-from-email", connectedEventName: "connectedEmail" });
|
|
234
236
|
* ```
|
|
235
237
|
*
|
|
236
|
-
* @param {{ bundle: string; orgId: string
|
|
237
|
-
*
|
|
238
|
+
* @param {{ bundle: string; orgId: string, connectedEventName: keyof AlchemySignerClientEvents, idToken?: string }} config
|
|
239
|
+
* The configuration object for the authentication function containing the
|
|
240
|
+
* credential bundle to inject and the organization id associated with the
|
|
241
|
+
* user, as well as the event to be emitted on success and optionally an OIDC
|
|
242
|
+
* ID token with extra user information
|
|
243
|
+
* @returns {Promise<User>} A promise that resolves to the authenticated user
|
|
244
|
+
* information
|
|
238
245
|
*/
|
|
239
246
|
public override completeAuthWithBundle = async ({
|
|
240
247
|
bundle,
|
|
241
248
|
orgId,
|
|
242
249
|
connectedEventName,
|
|
250
|
+
idToken,
|
|
243
251
|
}: {
|
|
244
252
|
bundle: string;
|
|
245
253
|
orgId: string;
|
|
246
254
|
connectedEventName: keyof AlchemySignerClientEvents;
|
|
255
|
+
idToken?: string;
|
|
247
256
|
}): Promise<User> => {
|
|
248
257
|
this.eventEmitter.emit("authenticating");
|
|
249
258
|
await this.initIframeStamper();
|
|
@@ -254,7 +263,8 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
254
263
|
throw new Error("Failed to inject credential bundle");
|
|
255
264
|
}
|
|
256
265
|
|
|
257
|
-
const user = await this.whoami(orgId);
|
|
266
|
+
const user = await this.whoami(orgId, idToken);
|
|
267
|
+
|
|
258
268
|
this.eventEmitter.emit(connectedEventName, user, bundle);
|
|
259
269
|
|
|
260
270
|
return user;
|
|
@@ -372,6 +382,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
372
382
|
public override disconnect = async () => {
|
|
373
383
|
this.user = undefined;
|
|
374
384
|
this.iframeStamper.clear();
|
|
385
|
+
await this.iframeStamper.init();
|
|
375
386
|
};
|
|
376
387
|
|
|
377
388
|
/**
|
|
@@ -454,15 +465,17 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
454
465
|
const {
|
|
455
466
|
alchemyBundle: bundle,
|
|
456
467
|
alchemyOrgId: orgId,
|
|
468
|
+
alchemyIdToken: idToken,
|
|
457
469
|
alchemyError,
|
|
458
470
|
} = event.data;
|
|
459
|
-
if (bundle && orgId) {
|
|
471
|
+
if (bundle && orgId && idToken) {
|
|
460
472
|
cleanup();
|
|
461
473
|
popup?.close();
|
|
462
474
|
this.completeAuthWithBundle({
|
|
463
475
|
bundle,
|
|
464
476
|
orgId,
|
|
465
477
|
connectedEventName: "connectedOauth",
|
|
478
|
+
idToken,
|
|
466
479
|
}).then(resolve, reject);
|
|
467
480
|
} else if (alchemyError) {
|
|
468
481
|
cleanup();
|
package/src/client/types.ts
CHANGED
package/src/signer.ts
CHANGED
|
@@ -31,7 +31,12 @@ export type AuthParams =
|
|
|
31
31
|
claims?: string;
|
|
32
32
|
} & OauthProviderConfig &
|
|
33
33
|
OauthRedirectConfig)
|
|
34
|
-
| {
|
|
34
|
+
| {
|
|
35
|
+
type: "oauthReturn";
|
|
36
|
+
bundle: string;
|
|
37
|
+
orgId: string;
|
|
38
|
+
idToken: string;
|
|
39
|
+
};
|
|
35
40
|
|
|
36
41
|
export type OauthProviderConfig =
|
|
37
42
|
| {
|
|
@@ -105,9 +110,59 @@ export class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient>
|
|
|
105
110
|
} else {
|
|
106
111
|
client = params_.client;
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
const { emailBundle, oauthBundle, oauthOrgId, oauthError, idToken } =
|
|
114
|
+
getAndRemoveQueryParams({
|
|
115
|
+
emailBundle: "bundle",
|
|
116
|
+
// We don't need this, but we still want to remove it from the URL.
|
|
117
|
+
emailOrgId: "orgId",
|
|
118
|
+
oauthBundle: "alchemy-bundle",
|
|
119
|
+
oauthOrgId: "alchemy-org-id",
|
|
120
|
+
oauthError: "alchemy-error",
|
|
121
|
+
idToken: "alchemy-id-token",
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const initialError =
|
|
125
|
+
oauthError != null
|
|
126
|
+
? { name: "OauthError", message: oauthError }
|
|
127
|
+
: undefined;
|
|
128
|
+
|
|
129
|
+
super({ client, sessionConfig, initialError });
|
|
130
|
+
|
|
131
|
+
if (emailBundle) {
|
|
132
|
+
this.authenticate({ type: "email", bundle: emailBundle });
|
|
133
|
+
} else if (oauthBundle && oauthOrgId && idToken) {
|
|
134
|
+
this.authenticate({
|
|
135
|
+
type: "oauthReturn",
|
|
136
|
+
bundle: oauthBundle,
|
|
137
|
+
orgId: oauthOrgId,
|
|
138
|
+
idToken,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Reads and removes the specified query params from the URL.
|
|
146
|
+
*
|
|
147
|
+
* @param {T} keys object whose values are the query parameter keys to read and
|
|
148
|
+
* remove
|
|
149
|
+
* @returns {{ [K in keyof T]: string | undefined }} object with the same keys
|
|
150
|
+
* as the input whose values are the values of the query params.
|
|
151
|
+
*/
|
|
152
|
+
function getAndRemoveQueryParams<T extends Record<string, string>>(
|
|
153
|
+
keys: T
|
|
154
|
+
): { [K in keyof T]: string | undefined } {
|
|
155
|
+
const url = new URL(window.location.href);
|
|
156
|
+
const result: Record<string, string | undefined> = {};
|
|
157
|
+
let foundQueryParam = false;
|
|
158
|
+
for (const [key, param] of Object.entries(keys)) {
|
|
159
|
+
const value = url.searchParams.get(param) ?? undefined;
|
|
160
|
+
foundQueryParam ||= value != null;
|
|
161
|
+
result[key] = value;
|
|
162
|
+
url.searchParams.delete(param);
|
|
163
|
+
}
|
|
164
|
+
if (foundQueryParam) {
|
|
165
|
+
window.history.replaceState(window.history.state, "", url.toString());
|
|
112
166
|
}
|
|
167
|
+
return result as { [K in keyof T]: string | undefined };
|
|
113
168
|
}
|
package/src/types.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type AlchemySignerEvents = {
|
|
|
4
4
|
connected(user: User): void;
|
|
5
5
|
disconnected(): void;
|
|
6
6
|
statusChanged(status: AlchemySignerStatus): void;
|
|
7
|
+
errorChanged(error: ErrorInfo | undefined): void;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
export type AlchemySignerEvent = keyof AlchemySignerEvents;
|
|
@@ -15,3 +16,8 @@ export enum AlchemySignerStatus {
|
|
|
15
16
|
AUTHENTICATING = "AUTHENTICATING",
|
|
16
17
|
AWAITING_EMAIL_AUTH = "AWAITING_EMAIL_AUTH",
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
export interface ErrorInfo {
|
|
21
|
+
name: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}
|