@account-kit/signer 4.0.0-beta.3 → 4.0.0-beta.5
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 +33 -1
- package/dist/esm/base.js +81 -7
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +28 -5
- package/dist/esm/client/base.js +25 -1
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +78 -5
- package/dist/esm/client/index.js +211 -6
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +25 -0
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/oauth.d.ts +18 -0
- package/dist/esm/oauth.js +29 -0
- package/dist/esm/oauth.js.map +1 -0
- package/dist/esm/session/manager.d.ts +3 -2
- package/dist/esm/session/manager.js +28 -15
- package/dist/esm/session/manager.js.map +1 -1
- package/dist/esm/session/types.d.ts +1 -1
- package/dist/esm/session/types.js.map +1 -1
- package/dist/esm/signer.d.ts +39 -7
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/utils/typeAssertions.d.ts +1 -0
- package/dist/esm/utils/typeAssertions.js +4 -0
- package/dist/esm/utils/typeAssertions.js.map +1 -0
- 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 +33 -1
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +28 -5
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +78 -5
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +25 -0
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/oauth.d.ts +19 -0
- package/dist/types/oauth.d.ts.map +1 -0
- package/dist/types/session/manager.d.ts +3 -2
- package/dist/types/session/manager.d.ts.map +1 -1
- package/dist/types/session/types.d.ts +1 -1
- package/dist/types/session/types.d.ts.map +1 -1
- package/dist/types/signer.d.ts +39 -7
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/utils/typeAssertions.d.ts +2 -0
- package/dist/types/utils/typeAssertions.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/base.ts +80 -10
- package/src/client/base.ts +31 -3
- package/src/client/index.ts +244 -12
- package/src/client/types.ts +26 -0
- package/src/oauth.ts +38 -0
- package/src/session/manager.ts +45 -19
- package/src/session/types.ts +1 -1
- package/src/signer.ts +15 -1
- package/src/utils/typeAssertions.ts +3 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turnkey requires the nonce in the id token to be in this format.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} turnkeyPublicKey key from a Turnkey iframe
|
|
5
|
+
* @returns {string} nonce to be used in OIDC
|
|
6
|
+
*/
|
|
7
|
+
export declare function getOauthNonce(turnkeyPublicKey: string): string;
|
|
8
|
+
export type ScopeAndClaims = {
|
|
9
|
+
scope: string;
|
|
10
|
+
claims?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Returns the default scope and claims when using a known auth provider
|
|
14
|
+
*
|
|
15
|
+
* @param {string} knownAuthProviderId id of a known auth provider, e.g. "google"
|
|
16
|
+
* @returns {ScopeAndClaims | undefined} default scope and claims
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDefaultScopeAndClaims(knownAuthProviderId: string): ScopeAndClaims | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { sha256 } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Turnkey requires the nonce in the id token to be in this format.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} turnkeyPublicKey key from a Turnkey iframe
|
|
6
|
+
* @returns {string} nonce to be used in OIDC
|
|
7
|
+
*/
|
|
8
|
+
export function getOauthNonce(turnkeyPublicKey) {
|
|
9
|
+
return sha256(new TextEncoder().encode(turnkeyPublicKey)).slice(2);
|
|
10
|
+
}
|
|
11
|
+
const DEFAULT_SCOPE_AND_CLAIMS = {
|
|
12
|
+
google: { scope: "openid email" },
|
|
13
|
+
apple: { scope: "openid email" },
|
|
14
|
+
facebook: { scope: "openid email" },
|
|
15
|
+
twitch: {
|
|
16
|
+
scope: "openid user:read:email",
|
|
17
|
+
claims: JSON.stringify({ id_token: { email: null } }),
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Returns the default scope and claims when using a known auth provider
|
|
22
|
+
*
|
|
23
|
+
* @param {string} knownAuthProviderId id of a known auth provider, e.g. "google"
|
|
24
|
+
* @returns {ScopeAndClaims | undefined} default scope and claims
|
|
25
|
+
*/
|
|
26
|
+
export function getDefaultScopeAndClaims(knownAuthProviderId) {
|
|
27
|
+
return DEFAULT_SCOPE_AND_CLAIMS[knownAuthProviderId];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,gBAAwB;IACpD,OAAO,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AAOD,MAAM,wBAAwB,GAAmC;IAC/D,MAAM,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;IACjC,KAAK,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;IAChC,QAAQ,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE;IACnC,MAAM,EAAE;QACN,KAAK,EAAE,wBAAwB;QAC/B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;KACtD;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,mBAA2B;IAE3B,OAAO,wBAAwB,CAAC,mBAAmB,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { sha256 } from \"viem\";\n\n/**\n * Turnkey requires the nonce in the id token to be in this format.\n *\n * @param {string} turnkeyPublicKey key from a Turnkey iframe\n * @returns {string} nonce to be used in OIDC\n */\nexport function getOauthNonce(turnkeyPublicKey: string): string {\n return sha256(new TextEncoder().encode(turnkeyPublicKey)).slice(2);\n}\n\nexport type ScopeAndClaims = {\n scope: string;\n claims?: string;\n};\n\nconst DEFAULT_SCOPE_AND_CLAIMS: Record<string, ScopeAndClaims> = {\n google: { scope: \"openid email\" },\n apple: { scope: \"openid email\" },\n facebook: { scope: \"openid email\" },\n twitch: {\n scope: \"openid user:read:email\",\n claims: JSON.stringify({ id_token: { email: null } }),\n },\n};\n\n/**\n * Returns the default scope and claims when using a known auth provider\n *\n * @param {string} knownAuthProviderId id of a known auth provider, e.g. \"google\"\n * @returns {ScopeAndClaims | undefined} default scope and claims\n */\nexport function getDefaultScopeAndClaims(\n knownAuthProviderId: string\n): ScopeAndClaims | undefined {\n return DEFAULT_SCOPE_AND_CLAIMS[knownAuthProviderId];\n}\n"]}
|
|
@@ -10,14 +10,14 @@ export declare const SessionManagerParamsSchema: z.ZodObject<{
|
|
|
10
10
|
expirationTimeMs: z.ZodDefault<z.ZodNumber>;
|
|
11
11
|
client: z.ZodType<BaseSignerClient<unknown>, z.ZodTypeDef, BaseSignerClient<unknown>>;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
storage: (Storage | "localStorage" | "sessionStorage") & (Storage | "localStorage" | "sessionStorage" | undefined);
|
|
13
14
|
sessionKey: string;
|
|
14
|
-
storage: ("localStorage" | "sessionStorage" | Storage) & ("localStorage" | "sessionStorage" | Storage | undefined);
|
|
15
15
|
expirationTimeMs: number;
|
|
16
16
|
client: BaseSignerClient<unknown>;
|
|
17
17
|
}, {
|
|
18
18
|
client: BaseSignerClient<unknown>;
|
|
19
19
|
sessionKey?: string | undefined;
|
|
20
|
-
storage?: "localStorage" | "sessionStorage" |
|
|
20
|
+
storage?: Storage | "localStorage" | "sessionStorage" | undefined;
|
|
21
21
|
expirationTimeMs?: number | undefined;
|
|
22
22
|
}>;
|
|
23
23
|
export type SessionManagerParams = z.input<typeof SessionManagerParamsSchema>;
|
|
@@ -42,4 +42,5 @@ export declare class SessionManager {
|
|
|
42
42
|
initialize(): void;
|
|
43
43
|
private getInitialState;
|
|
44
44
|
private registerEventListeners;
|
|
45
|
+
private setSessionWithUserAndBundle;
|
|
45
46
|
}
|
|
@@ -2,6 +2,7 @@ import EventEmitter from "eventemitter3";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createJSONStorage, persist, subscribeWithSelector, } from "zustand/middleware";
|
|
4
4
|
import { createStore } from "zustand/vanilla";
|
|
5
|
+
import { assertNever } from "../utils/typeAssertions.js";
|
|
5
6
|
export const DEFAULT_SESSION_MS = 15 * 60 * 1000; // 15 minutes
|
|
6
7
|
export const SessionManagerParamsSchema = z.object({
|
|
7
8
|
sessionKey: z.string().default("alchemy-signer-session"),
|
|
@@ -57,11 +58,16 @@ export class SessionManager {
|
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
60
|
switch (existingSession.type) {
|
|
60
|
-
case "email":
|
|
61
|
+
case "email":
|
|
62
|
+
case "oauth": {
|
|
63
|
+
const connectedEventName = existingSession.type === "email"
|
|
64
|
+
? "connectedEmail"
|
|
65
|
+
: "connectedOauth";
|
|
61
66
|
const result = await this.client
|
|
62
|
-
.
|
|
67
|
+
.completeAuthWithBundle({
|
|
63
68
|
bundle: existingSession.bundle,
|
|
64
69
|
orgId: existingSession.user.orgId,
|
|
70
|
+
connectedEventName,
|
|
65
71
|
})
|
|
66
72
|
.catch((e) => {
|
|
67
73
|
console.warn("Failed to load user from session", e);
|
|
@@ -81,7 +87,7 @@ export class SessionManager {
|
|
|
81
87
|
return this.client.lookupUserWithPasskey(existingSession.user);
|
|
82
88
|
}
|
|
83
89
|
default:
|
|
84
|
-
|
|
90
|
+
assertNever(existingSession, `Unknown session type: ${existingSession.type}`);
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
});
|
|
@@ -174,18 +180,7 @@ export class SessionManager {
|
|
|
174
180
|
}
|
|
175
181
|
});
|
|
176
182
|
this.client.on("disconnected", () => this.clearSession());
|
|
177
|
-
this.client.on("connectedEmail", (user, bundle) => {
|
|
178
|
-
const existingSession = this.getSession();
|
|
179
|
-
if (existingSession != null &&
|
|
180
|
-
existingSession.type === "email" &&
|
|
181
|
-
existingSession.user.userId === user.userId &&
|
|
182
|
-
// if the bundle is different, then we've refreshed the session
|
|
183
|
-
// so we need to reset the session
|
|
184
|
-
existingSession.bundle === bundle) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
this.setSession({ type: "email", user, bundle });
|
|
188
|
-
});
|
|
183
|
+
this.client.on("connectedEmail", (user, bundle) => this.setSessionWithUserAndBundle({ type: "email", user, bundle }));
|
|
189
184
|
this.client.on("connectedPasskey", (user) => {
|
|
190
185
|
const existingSession = this.getSession();
|
|
191
186
|
if (existingSession != null &&
|
|
@@ -195,6 +190,7 @@ export class SessionManager {
|
|
|
195
190
|
}
|
|
196
191
|
this.setSession({ type: "passkey", user });
|
|
197
192
|
});
|
|
193
|
+
this.client.on("connectedOauth", (user, bundle) => this.setSessionWithUserAndBundle({ type: "oauth", user, bundle }));
|
|
198
194
|
// sync local state if persisted state has changed from another tab
|
|
199
195
|
window.addEventListener("focus", () => {
|
|
200
196
|
this.store.persist.rehydrate();
|
|
@@ -202,6 +198,23 @@ export class SessionManager {
|
|
|
202
198
|
});
|
|
203
199
|
}
|
|
204
200
|
});
|
|
201
|
+
Object.defineProperty(this, "setSessionWithUserAndBundle", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
configurable: true,
|
|
204
|
+
writable: true,
|
|
205
|
+
value: ({ type, user, bundle, }) => {
|
|
206
|
+
const existingSession = this.getSession();
|
|
207
|
+
if (existingSession != null &&
|
|
208
|
+
existingSession.type === type &&
|
|
209
|
+
existingSession.user.userId === user.userId &&
|
|
210
|
+
// if the bundle is different, then we've refreshed the session
|
|
211
|
+
// so we need to reset the session
|
|
212
|
+
existingSession.bundle === bundle) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
this.setSession({ type, user, bundle });
|
|
216
|
+
}
|
|
217
|
+
});
|
|
205
218
|
const { sessionKey, storage: storageType, expirationTimeMs, client, } = SessionManagerParamsSchema.parse(params);
|
|
206
219
|
this.sessionKey = sessionKey;
|
|
207
220
|
const storage = typeof storageType === "string"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/session/manager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAA8B,MAAM,iBAAiB,CAAC;AAK1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC;IACxD,OAAO,EAAE,CAAC;SACP,IAAI,CAAC,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;SACxC,OAAO,CAAC,cAAc,CAAC;SACvB,EAAE,CAAC,CAAC,CAAC,MAAM,EAAW,CAAC;IAC1B,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,OAAO,CAAC,kBAAkB,CAAC;SAC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M,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAwB,CAAC;QAE7D,IAAI,CAAC,KAAK,GAAG,WAAW,CACtB,qBAAqB,CACnB,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE;YAC5B,IAAI,EAAE,IAAI,CAAC,UAAU;YACrB,OAAO,EAAE,iBAAiB,CAAe,GAAG,EAAE,CAAC,OAAO,CAAC;SACxD,CAAC,CACH,CACF,CAAC;QAEF,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAChC,CAAC;IA0GM,UAAU;QACf,IAAI,CAAC,cAAc,EAAE;aAClB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACb,4FAA4F;YAC5F,IAAI,IAAI;gBAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,EAAG,CAAC,CAAC;;gBAC7D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC9C,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,eAAe;QACrB,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;CAmDF","sourcesContent":["import EventEmitter from \"eventemitter3\";\nimport { z } from \"zod\";\nimport {\n createJSONStorage,\n persist,\n subscribeWithSelector,\n} from \"zustand/middleware\";\nimport { createStore, type Mutate, type StoreApi } from \"zustand/vanilla\";\nimport type { BaseSignerClient } from \"../client/base\";\nimport type { User } from \"../client/types\";\nimport type { Session, SessionManagerEvents } from \"./types\";\n\nexport const DEFAULT_SESSION_MS = 15 * 60 * 1000; // 15 minutes\n\nexport const SessionManagerParamsSchema = z.object({\n sessionKey: z.string().default(\"alchemy-signer-session\"),\n storage: z\n .enum([\"localStorage\", \"sessionStorage\"])\n .default(\"localStorage\")\n .or(z.custom<Storage>()),\n expirationTimeMs: z\n .number()\n .default(DEFAULT_SESSION_MS)\n .describe(\n \"The time in milliseconds that a session should last before expiring [default: 15 minutes]\"\n ),\n client: z.custom<BaseSignerClient>(),\n});\n\nexport type SessionManagerParams = z.input<typeof SessionManagerParamsSchema>;\n\ntype SessionState = {\n session: Session | null;\n};\n\ntype Store = Mutate<\n StoreApi<SessionState>,\n [[\"zustand/subscribeWithSelector\", never], [\"zustand/persist\", SessionState]]\n>;\n\nexport class SessionManager {\n private sessionKey: string;\n private client: BaseSignerClient;\n private eventEmitter: EventEmitter<SessionManagerEvents>;\n readonly expirationTimeMs: number;\n private store: Store;\n\n constructor(params: SessionManagerParams) {\n const {\n sessionKey,\n storage: storageType,\n expirationTimeMs,\n client,\n } = SessionManagerParamsSchema.parse(params);\n this.sessionKey = sessionKey;\n const storage =\n typeof storageType === \"string\"\n ? storageType === \"localStorage\"\n ? localStorage\n : sessionStorage\n : storageType;\n this.expirationTimeMs = expirationTimeMs;\n this.client = client;\n this.eventEmitter = new EventEmitter<SessionManagerEvents>();\n\n this.store = createStore(\n subscribeWithSelector(\n persist(this.getInitialState, {\n name: this.sessionKey,\n storage: createJSONStorage<SessionState>(() => storage),\n })\n )\n );\n\n this.registerEventListeners();\n }\n\n public getSessionUser = async (): Promise<User | null> => {\n const existingSession = this.getSession();\n if (existingSession == null) {\n return null;\n }\n\n switch (existingSession.type) {\n case \"email\": {\n const result = await this.client\n .completeEmailAuth({\n bundle: existingSession.bundle,\n orgId: existingSession.user.orgId,\n })\n .catch((e) => {\n console.warn(\"Failed to load user from session\", e);\n return null;\n });\n\n if (!result) {\n this.clearSession();\n return null;\n }\n\n return result;\n }\n case \"passkey\": {\n // we don't need to do much here if we already have a user\n // this will setup the client with the user context, but\n // requests still have to be signed by the user on first request\n // so this is fine\n return this.client.lookupUserWithPasskey(existingSession.user);\n }\n default:\n throw new Error(\"Unknown session type\");\n }\n };\n\n public clearSession = () => {\n this.store.setState({ session: null });\n };\n\n public setTemporarySession = (session: { orgId: string }) => {\n // temporary session must be placed in localStorage so that it can be accessed across tabs\n localStorage.setItem(\n `${this.sessionKey}:temporary`,\n JSON.stringify(session)\n );\n };\n\n public getTemporarySession = (): { orgId: string } | null => {\n // temporary session must be placed in localStorage so that it can be accessed across tabs\n const sessionStr = localStorage.getItem(`${this.sessionKey}:temporary`);\n\n if (!sessionStr) {\n return null;\n }\n\n return JSON.parse(sessionStr);\n };\n\n on = <E extends keyof SessionManagerEvents>(\n event: E,\n listener: SessionManagerEvents[E]\n ) => {\n this.eventEmitter.on(event, listener as any);\n\n return () => this.eventEmitter.removeListener(event, listener as any);\n };\n\n private getSession = (): Session | null => {\n const session = this.store.getState().session;\n\n if (!session) {\n return null;\n }\n\n /**\n * TODO: this isn't really good enough\n * A user's session could be about to expire and we would still return it\n *\n * Instead we should check if a session is about to expire and refresh it\n * We should revisit this later\n */\n if (session.expirationDateMs < Date.now()) {\n this.store.setState({ session: null });\n return null;\n }\n\n return session;\n };\n\n private setSession = (\n session:\n | Omit<Extract<Session, { type: \"email\" }>, \"expirationDateMs\">\n | Omit<Extract<Session, { type: \"passkey\" }>, \"expirationDateMs\">\n ) => {\n this.store.setState({\n session: {\n ...session,\n expirationDateMs: Date.now() + this.expirationTimeMs,\n },\n });\n };\n\n public initialize() {\n this.getSessionUser()\n .then((user) => {\n // once we complete auth we can update the state of the session to connected or disconnected\n if (user) this.eventEmitter.emit(\"connected\", this.getSession()!);\n else this.eventEmitter.emit(\"disconnected\");\n })\n .finally(() => {\n this.eventEmitter.emit(\"initialized\");\n });\n }\n\n private getInitialState(): SessionState {\n return {\n session: null,\n };\n }\n\n private registerEventListeners = () => {\n this.store.subscribe(\n ({ session }) => session,\n (session, prevSession) => {\n if (session != null && prevSession == null) {\n this.eventEmitter.emit(\"connected\", session);\n } else if (session == null && prevSession != null) {\n this.eventEmitter.emit(\"disconnected\");\n }\n }\n );\n\n this.client.on(\"disconnected\", () => this.clearSession());\n\n this.client.on(\"connectedEmail\", (user, bundle) => {\n const existingSession = this.getSession();\n if (\n existingSession != null &&\n existingSession.type === \"email\" &&\n existingSession.user.userId === user.userId &&\n // if the bundle is different, then we've refreshed the session\n // so we need to reset the session\n existingSession.bundle === bundle\n ) {\n return;\n }\n\n this.setSession({ type: \"email\", user, bundle });\n });\n\n this.client.on(\"connectedPasskey\", (user) => {\n const existingSession = this.getSession();\n if (\n existingSession != null &&\n existingSession.type === \"passkey\" &&\n existingSession.user.userId === user.userId\n ) {\n return;\n }\n\n this.setSession({ type: \"passkey\", user });\n });\n\n // sync local state if persisted state has changed from another tab\n window.addEventListener(\"focus\", () => {\n this.store.persist.rehydrate();\n this.initialize();\n });\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/session/manager.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAA8B,MAAM,iBAAiB,CAAC;AAI1E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,wBAAwB,CAAC;IACxD,OAAO,EAAE,CAAC;SACP,IAAI,CAAC,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;SACxC,OAAO,CAAC,cAAc,CAAC;SACvB,EAAE,CAAC,CAAC,CAAC,MAAM,EAAW,CAAC;IAC1B,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,OAAO,CAAC,k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,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,eAAe;QACrB,OAAO;YACL,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;CAmEF","sourcesContent":["import EventEmitter from \"eventemitter3\";\nimport { z } from \"zod\";\nimport {\n createJSONStorage,\n persist,\n subscribeWithSelector,\n} from \"zustand/middleware\";\nimport { createStore, type Mutate, type StoreApi } from \"zustand/vanilla\";\nimport type { BaseSignerClient } from \"../client/base\";\nimport type { User } from \"../client/types\";\nimport type { Session, SessionManagerEvents } from \"./types\";\nimport { assertNever } from \"../utils/typeAssertions.js\";\n\nexport const DEFAULT_SESSION_MS = 15 * 60 * 1000; // 15 minutes\n\nexport const SessionManagerParamsSchema = z.object({\n sessionKey: z.string().default(\"alchemy-signer-session\"),\n storage: z\n .enum([\"localStorage\", \"sessionStorage\"])\n .default(\"localStorage\")\n .or(z.custom<Storage>()),\n expirationTimeMs: z\n .number()\n .default(DEFAULT_SESSION_MS)\n .describe(\n \"The time in milliseconds that a session should last before expiring [default: 15 minutes]\"\n ),\n client: z.custom<BaseSignerClient>(),\n});\n\nexport type SessionManagerParams = z.input<typeof SessionManagerParamsSchema>;\n\ntype SessionState = {\n session: Session | null;\n};\n\ntype Store = Mutate<\n StoreApi<SessionState>,\n [[\"zustand/subscribeWithSelector\", never], [\"zustand/persist\", SessionState]]\n>;\n\nexport class SessionManager {\n private sessionKey: string;\n private client: BaseSignerClient;\n private eventEmitter: EventEmitter<SessionManagerEvents>;\n readonly expirationTimeMs: number;\n private store: Store;\n\n constructor(params: SessionManagerParams) {\n const {\n sessionKey,\n storage: storageType,\n expirationTimeMs,\n client,\n } = SessionManagerParamsSchema.parse(params);\n this.sessionKey = sessionKey;\n const storage =\n typeof storageType === \"string\"\n ? storageType === \"localStorage\"\n ? localStorage\n : sessionStorage\n : storageType;\n this.expirationTimeMs = expirationTimeMs;\n this.client = client;\n this.eventEmitter = new EventEmitter<SessionManagerEvents>();\n\n this.store = createStore(\n subscribeWithSelector(\n persist(this.getInitialState, {\n name: this.sessionKey,\n storage: createJSONStorage<SessionState>(() => storage),\n })\n )\n );\n\n this.registerEventListeners();\n }\n\n public getSessionUser = async (): Promise<User | null> => {\n const existingSession = this.getSession();\n if (existingSession == null) {\n return null;\n }\n\n switch (existingSession.type) {\n case \"email\":\n case \"oauth\": {\n const connectedEventName =\n existingSession.type === \"email\"\n ? \"connectedEmail\"\n : \"connectedOauth\";\n const result = await this.client\n .completeAuthWithBundle({\n bundle: existingSession.bundle,\n orgId: existingSession.user.orgId,\n connectedEventName,\n })\n .catch((e) => {\n console.warn(\"Failed to load user from session\", e);\n return null;\n });\n\n if (!result) {\n this.clearSession();\n return null;\n }\n\n return result;\n }\n case \"passkey\": {\n // we don't need to do much here if we already have a user\n // this will setup the client with the user context, but\n // requests still have to be signed by the user on first request\n // so this is fine\n return this.client.lookupUserWithPasskey(existingSession.user);\n }\n default:\n assertNever(\n existingSession,\n `Unknown session type: ${(existingSession as any).type}`\n );\n }\n };\n\n public clearSession = () => {\n this.store.setState({ session: null });\n };\n\n public setTemporarySession = (session: { orgId: string }) => {\n // temporary session must be placed in localStorage so that it can be accessed across tabs\n localStorage.setItem(\n `${this.sessionKey}:temporary`,\n JSON.stringify(session)\n );\n };\n\n public getTemporarySession = (): { orgId: string } | null => {\n // temporary session must be placed in localStorage so that it can be accessed across tabs\n const sessionStr = localStorage.getItem(`${this.sessionKey}:temporary`);\n\n if (!sessionStr) {\n return null;\n }\n\n return JSON.parse(sessionStr);\n };\n\n on = <E extends keyof SessionManagerEvents>(\n event: E,\n listener: SessionManagerEvents[E]\n ) => {\n this.eventEmitter.on(event, listener as any);\n\n return () => this.eventEmitter.removeListener(event, listener as any);\n };\n\n private getSession = (): Session | null => {\n const session = this.store.getState().session;\n\n if (!session) {\n return null;\n }\n\n /**\n * TODO: this isn't really good enough\n * A user's session could be about to expire and we would still return it\n *\n * Instead we should check if a session is about to expire and refresh it\n * We should revisit this later\n */\n if (session.expirationDateMs < Date.now()) {\n this.store.setState({ session: null });\n return null;\n }\n\n return session;\n };\n\n private setSession = (\n session:\n | Omit<Extract<Session, { type: \"email\" | \"oauth\" }>, \"expirationDateMs\">\n | Omit<Extract<Session, { type: \"passkey\" }>, \"expirationDateMs\">\n ) => {\n this.store.setState({\n session: {\n ...session,\n expirationDateMs: Date.now() + this.expirationTimeMs,\n },\n });\n };\n\n public initialize() {\n this.getSessionUser()\n .then((user) => {\n // once we complete auth we can update the state of the session to connected or disconnected\n if (user) this.eventEmitter.emit(\"connected\", this.getSession()!);\n else this.eventEmitter.emit(\"disconnected\");\n })\n .finally(() => {\n this.eventEmitter.emit(\"initialized\");\n });\n }\n\n private getInitialState(): SessionState {\n return {\n session: null,\n };\n }\n\n private registerEventListeners = () => {\n this.store.subscribe(\n ({ session }) => session,\n (session, prevSession) => {\n if (session != null && prevSession == null) {\n this.eventEmitter.emit(\"connected\", session);\n } else if (session == null && prevSession != null) {\n this.eventEmitter.emit(\"disconnected\");\n }\n }\n );\n\n this.client.on(\"disconnected\", () => this.clearSession());\n\n this.client.on(\"connectedEmail\", (user, bundle) =>\n this.setSessionWithUserAndBundle({ type: \"email\", user, bundle })\n );\n\n this.client.on(\"connectedPasskey\", (user) => {\n const existingSession = this.getSession();\n if (\n existingSession != null &&\n existingSession.type === \"passkey\" &&\n existingSession.user.userId === user.userId\n ) {\n return;\n }\n\n this.setSession({ type: \"passkey\", user });\n });\n\n this.client.on(\"connectedOauth\", (user, bundle) =>\n this.setSessionWithUserAndBundle({ type: \"oauth\", user, bundle })\n );\n\n // sync local state if persisted state has changed from another tab\n window.addEventListener(\"focus\", () => {\n this.store.persist.rehydrate();\n this.initialize();\n });\n };\n\n private setSessionWithUserAndBundle = ({\n type,\n user,\n bundle,\n }: {\n type: \"email\" | \"oauth\";\n user: User;\n bundle: string;\n }) => {\n const existingSession = this.getSession();\n if (\n existingSession != null &&\n existingSession.type === type &&\n existingSession.user.userId === user.userId &&\n // if the bundle is different, then we've refreshed the session\n // so we need to reset the session\n existingSession.bundle === bundle\n ) {\n return;\n }\n\n this.setSession({ type, user, bundle });\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/session/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { User } from \"../client/types\";\n\nexport type Session =\n | {\n type: \"email\";\n bundle: string;\n expirationDateMs: number;\n user: User;\n }\n | { type: \"passkey\"; user: User; expirationDateMs: number };\n\nexport type SessionManagerEvents = {\n connected(session: Session): void;\n disconnected(): void;\n initialized(): void;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/session/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { User } from \"../client/types\";\n\nexport type Session =\n | {\n type: \"email\" | \"oauth\";\n bundle: string;\n expirationDateMs: number;\n user: User;\n }\n | { type: \"passkey\"; user: User; expirationDateMs: number };\n\nexport type SessionManagerEvents = {\n connected(session: Session): void;\n disconnected(): void;\n initialized(): void;\n};\n"]}
|
package/dist/esm/signer.d.ts
CHANGED
|
@@ -22,6 +22,24 @@ export type AuthParams = {
|
|
|
22
22
|
createNew: true;
|
|
23
23
|
username: string;
|
|
24
24
|
creationOpts?: CredentialCreationOptionOverrides;
|
|
25
|
+
} | ({
|
|
26
|
+
type: "oauth";
|
|
27
|
+
authProviderId: string;
|
|
28
|
+
isCustomProvider?: boolean;
|
|
29
|
+
scope?: string;
|
|
30
|
+
claims?: string;
|
|
31
|
+
} & RedirectConfig) | {
|
|
32
|
+
type: "oauthReturn";
|
|
33
|
+
bundle: string;
|
|
34
|
+
orgId: string;
|
|
35
|
+
};
|
|
36
|
+
export type OauthMode = "redirect" | "popup";
|
|
37
|
+
export type RedirectConfig = {
|
|
38
|
+
mode: "redirect";
|
|
39
|
+
redirectUrl: string;
|
|
40
|
+
} | {
|
|
41
|
+
mode: "popup";
|
|
42
|
+
redirectUrl?: never;
|
|
25
43
|
};
|
|
26
44
|
export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
27
45
|
client: z.ZodUnion<[z.ZodType<AlchemySignerWebClient, z.ZodTypeDef, AlchemySignerWebClient>, z.ZodObject<{
|
|
@@ -86,6 +104,8 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
86
104
|
}>;
|
|
87
105
|
rpId: z.ZodOptional<z.ZodString>;
|
|
88
106
|
rootOrgId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
107
|
+
oauthCallbackUrl: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
108
|
+
enablePopupOauth: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
89
109
|
}, "strip", z.ZodTypeAny, {
|
|
90
110
|
connection: {
|
|
91
111
|
apiKey: string;
|
|
@@ -104,11 +124,13 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
104
124
|
jwt: string;
|
|
105
125
|
apiKey?: undefined;
|
|
106
126
|
};
|
|
107
|
-
rootOrgId: string;
|
|
108
127
|
iframeConfig: {
|
|
109
128
|
iframeElementId: string;
|
|
110
129
|
iframeContainerId: string;
|
|
111
130
|
};
|
|
131
|
+
rootOrgId: string;
|
|
132
|
+
oauthCallbackUrl: string;
|
|
133
|
+
enablePopupOauth: boolean;
|
|
112
134
|
rpId?: string | undefined;
|
|
113
135
|
}, {
|
|
114
136
|
connection: {
|
|
@@ -134,6 +156,8 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
134
156
|
};
|
|
135
157
|
rpId?: string | undefined;
|
|
136
158
|
rootOrgId?: string | undefined;
|
|
159
|
+
oauthCallbackUrl?: string | undefined;
|
|
160
|
+
enablePopupOauth?: boolean | undefined;
|
|
137
161
|
}>]>;
|
|
138
162
|
sessionConfig: z.ZodOptional<z.ZodObject<Omit<{
|
|
139
163
|
sessionKey: z.ZodDefault<z.ZodString>;
|
|
@@ -141,12 +165,12 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
141
165
|
expirationTimeMs: z.ZodDefault<z.ZodNumber>;
|
|
142
166
|
client: z.ZodType<import("./index.js").BaseSignerClient<unknown>, z.ZodTypeDef, import("./index.js").BaseSignerClient<unknown>>;
|
|
143
167
|
}, "client">, "strip", z.ZodTypeAny, {
|
|
168
|
+
storage: (Storage | "localStorage" | "sessionStorage") & (Storage | "localStorage" | "sessionStorage" | undefined);
|
|
144
169
|
sessionKey: string;
|
|
145
|
-
storage: ("localStorage" | "sessionStorage" | Storage) & ("localStorage" | "sessionStorage" | Storage | undefined);
|
|
146
170
|
expirationTimeMs: number;
|
|
147
171
|
}, {
|
|
172
|
+
storage?: Storage | "localStorage" | "sessionStorage" | undefined;
|
|
148
173
|
sessionKey?: string | undefined;
|
|
149
|
-
storage?: "localStorage" | "sessionStorage" | Storage | undefined;
|
|
150
174
|
expirationTimeMs?: number | undefined;
|
|
151
175
|
}>>;
|
|
152
176
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -168,11 +192,13 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
168
192
|
jwt: string;
|
|
169
193
|
apiKey?: undefined;
|
|
170
194
|
};
|
|
171
|
-
rootOrgId: string;
|
|
172
195
|
iframeConfig: {
|
|
173
196
|
iframeElementId: string;
|
|
174
197
|
iframeContainerId: string;
|
|
175
198
|
};
|
|
199
|
+
rootOrgId: string;
|
|
200
|
+
oauthCallbackUrl: string;
|
|
201
|
+
enablePopupOauth: boolean;
|
|
176
202
|
rpId?: string | undefined;
|
|
177
203
|
} | AlchemySignerWebClient) & ({
|
|
178
204
|
connection: {
|
|
@@ -192,16 +218,18 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
192
218
|
jwt: string;
|
|
193
219
|
apiKey?: undefined;
|
|
194
220
|
};
|
|
195
|
-
rootOrgId: string;
|
|
196
221
|
iframeConfig: {
|
|
197
222
|
iframeElementId: string;
|
|
198
223
|
iframeContainerId: string;
|
|
199
224
|
};
|
|
225
|
+
rootOrgId: string;
|
|
226
|
+
oauthCallbackUrl: string;
|
|
227
|
+
enablePopupOauth: boolean;
|
|
200
228
|
rpId?: string | undefined;
|
|
201
229
|
} | AlchemySignerWebClient | undefined);
|
|
202
230
|
sessionConfig?: {
|
|
231
|
+
storage: (Storage | "localStorage" | "sessionStorage") & (Storage | "localStorage" | "sessionStorage" | undefined);
|
|
203
232
|
sessionKey: string;
|
|
204
|
-
storage: ("localStorage" | "sessionStorage" | Storage) & ("localStorage" | "sessionStorage" | Storage | undefined);
|
|
205
233
|
expirationTimeMs: number;
|
|
206
234
|
} | undefined;
|
|
207
235
|
}, {
|
|
@@ -229,6 +257,8 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
229
257
|
};
|
|
230
258
|
rpId?: string | undefined;
|
|
231
259
|
rootOrgId?: string | undefined;
|
|
260
|
+
oauthCallbackUrl?: string | undefined;
|
|
261
|
+
enablePopupOauth?: boolean | undefined;
|
|
232
262
|
} | AlchemySignerWebClient) & ({
|
|
233
263
|
connection: {
|
|
234
264
|
apiKey: string;
|
|
@@ -253,10 +283,12 @@ export declare const AlchemySignerParamsSchema: z.ZodObject<{
|
|
|
253
283
|
};
|
|
254
284
|
rpId?: string | undefined;
|
|
255
285
|
rootOrgId?: string | undefined;
|
|
286
|
+
oauthCallbackUrl?: string | undefined;
|
|
287
|
+
enablePopupOauth?: boolean | undefined;
|
|
256
288
|
} | AlchemySignerWebClient | undefined);
|
|
257
289
|
sessionConfig?: {
|
|
290
|
+
storage?: Storage | "localStorage" | "sessionStorage" | undefined;
|
|
258
291
|
sessionKey?: string | undefined;
|
|
259
|
-
storage?: "localStorage" | "sessionStorage" | Storage | undefined;
|
|
260
292
|
expirationTimeMs?: number | undefined;
|
|
261
293
|
} | undefined;
|
|
262
294
|
}>;
|
package/dist/esm/signer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAmClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC;KACvC,MAAM,CAAC;IACN,MAAM,EAAE,CAAC;SACN,MAAM,EAA0B;SAChC,EAAE,CAAC,+BAA+B,CAAC;CACvC,CAAC;KACD,MAAM,CAAC;IACN,aAAa,EAAE,0BAA0B,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE;CAC5E,CAAC,CAAC;AAIL;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAyC;IAC7E;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,MAA2B;QACrC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,GACjC,yBAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,MAA8B,CAAC;QACnC,IAAI,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC1B,CAAC;QACD,KAAK,CAAC;YACJ,MAAM;YACN,aAAa;SACd,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { z } from \"zod\";\nimport { BaseAlchemySigner } from \"./base.js\";\nimport {\n AlchemySignerClientParamsSchema,\n AlchemySignerWebClient,\n} from \"./client/index.js\";\nimport type { CredentialCreationOptionOverrides } from \"./client/types.js\";\nimport { SessionManagerParamsSchema } from \"./session/manager.js\";\n\nexport type AuthParams =\n | { type: \"email\"; email: string; redirectParams?: URLSearchParams }\n | { type: \"email\"; bundle: string; orgId?: string }\n | {\n type: \"passkey\";\n email: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | {\n type: \"passkey\";\n createNew: false;\n }\n | {\n type: \"passkey\";\n createNew: true;\n username: string;\n creationOpts?: CredentialCreationOptionOverrides;\n }\n | ({\n type: \"oauth\";\n authProviderId: string;\n isCustomProvider?: boolean;\n scope?: string;\n claims?: string;\n } & RedirectConfig)\n | { type: \"oauthReturn\"; bundle: string; orgId: string };\n\nexport type OauthMode = \"redirect\" | \"popup\";\n\nexport type RedirectConfig =\n | { mode: \"redirect\"; redirectUrl: string }\n | { mode: \"popup\"; redirectUrl?: never };\n\nexport const AlchemySignerParamsSchema = z\n .object({\n client: z\n .custom<AlchemySignerWebClient>()\n .or(AlchemySignerClientParamsSchema),\n })\n .extend({\n sessionConfig: SessionManagerParamsSchema.omit({ client: true }).optional(),\n });\n\nexport type AlchemySignerParams = z.input<typeof AlchemySignerParamsSchema>;\n\n/**\n * A SmartAccountSigner that can be used with any SmartContractAccount\n */\nexport class AlchemyWebSigner extends BaseAlchemySigner<AlchemySignerWebClient> {\n /**\n * Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.\n *\n * @example\n * ```ts\n * import { AlchemyWebSigner } from \"@account-kit/signer\";\n *\n * const signer = new AlchemyWebSigner({\n * client: {\n * connection: {\n * rpcUrl: \"/api/rpc\",\n * },\n * iframeConfig: {\n * iframeContainerId: \"alchemy-signer-iframe-container\",\n * },\n * },\n * });\n * ```\n *\n * @param {AlchemySignerParams} params The parameters for the Alchemy signer, including the client and session configuration\n */\n constructor(params: AlchemySignerParams) {\n const { sessionConfig, ...params_ } =\n AlchemySignerParamsSchema.parse(params);\n\n let client: AlchemySignerWebClient;\n if (\"connection\" in params_.client) {\n client = new AlchemySignerWebClient(params_.client);\n } else {\n client = params_.client;\n }\n super({\n client,\n sessionConfig,\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assertNever(_: never, message: string): never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeAssertions.js","sourceRoot":"","sources":["../../../src/utils/typeAssertions.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CAAC,CAAQ,EAAE,OAAe;IACnD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["export function assertNever(_: never, message: string): never {\n throw new Error(message);\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.0.0-beta.
|
|
1
|
+
export declare const VERSION = "4.0.0-beta.5";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.0.0-beta.5\";\n"]}
|
package/dist/types/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SmartAccountAuthenticator } from "@aa-sdk/core";
|
|
2
2
|
import { type CustomSource, type Hex, type LocalAccount, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
|
|
3
3
|
import type { BaseSignerClient } from "./client/base";
|
|
4
|
-
import type { User } from "./client/types";
|
|
4
|
+
import type { OauthConfig, User } from "./client/types";
|
|
5
5
|
import { type SessionManagerParams } from "./session/manager.js";
|
|
6
6
|
import type { AuthParams } from "./signer";
|
|
7
7
|
import { type AlchemySignerEvents } from "./types.js";
|
|
@@ -36,6 +36,36 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
36
36
|
* @returns {() => void} a function to remove the listener
|
|
37
37
|
*/
|
|
38
38
|
on: <E extends keyof AlchemySignerEvents>(event: E, listener: AlchemySignerEvents[E]) => () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Prepares the config needed to use popup-based OAuth login. This must be
|
|
41
|
+
* called before calling `.authenticate` with params `{ type: "oauth", mode:
|
|
42
|
+
* "popup" }`, and is recommended to be called on page load.
|
|
43
|
+
*
|
|
44
|
+
* This method exists because browsers may prevent popups from opening unless
|
|
45
|
+
* triggered by user interaction, and so the OAuth config must already have
|
|
46
|
+
* been fetched at the time a user clicks a social login button.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { AlchemyWebSigner } from "@account-kit/signer";
|
|
51
|
+
*
|
|
52
|
+
* const signer = new AlchemyWebSigner({
|
|
53
|
+
* client: {
|
|
54
|
+
* connection: {
|
|
55
|
+
* rpcUrl: "/api/rpc",
|
|
56
|
+
* },
|
|
57
|
+
* iframeConfig: {
|
|
58
|
+
* iframeContainerId: "alchemy-signer-iframe-container",
|
|
59
|
+
* },
|
|
60
|
+
* },
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* await signer.preparePopupOauth();
|
|
64
|
+
* ```
|
|
65
|
+
* @returns {Promise<OauthConfig>} the config which must be loaded before
|
|
66
|
+
* using popup-based OAuth
|
|
67
|
+
*/
|
|
68
|
+
preparePopupOauth: () => Promise<OauthConfig>;
|
|
39
69
|
/**
|
|
40
70
|
* Authenticate a user with either an email or a passkey and create a session for that user
|
|
41
71
|
*
|
|
@@ -316,6 +346,8 @@ export declare abstract class BaseAlchemySigner<TClient extends BaseSignerClient
|
|
|
316
346
|
toViemAccount: () => LocalAccount;
|
|
317
347
|
private authenticateWithEmail;
|
|
318
348
|
private authenticateWithPasskey;
|
|
349
|
+
private authenticateWithOauth;
|
|
350
|
+
private handleOauthReturn;
|
|
319
351
|
private registerListeners;
|
|
320
352
|
}
|
|
321
353
|
//# sourceMappingURL=base.d.ts.map
|
package/dist/types/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACz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F,OAAO,CAAC,uBAAuB,CAoC7B;IAEF,OAAO,CAAC,qBAAqB,CAc3B;IAEF,OAAO,CAAC,iBAAiB,CAQpB;IAEL,OAAO,CAAC,iBAAiB,CA0BvB;CACH"}
|
|
@@ -2,7 +2,7 @@ import { type ConnectionConfig } from "@aa-sdk/core";
|
|
|
2
2
|
import { TurnkeyClient, type TSignedRequest } from "@turnkey/http";
|
|
3
3
|
import EventEmitter from "eventemitter3";
|
|
4
4
|
import type { Hex } from "viem";
|
|
5
|
-
import type { AlchemySignerClientEvents, CreateAccountParams, EmailAuthParams, GetWebAuthnAttestationResult, SignerBody, SignerResponse, SignupResponse, User } from "./types.js";
|
|
5
|
+
import type { AlchemySignerClientEvents, CreateAccountParams, EmailAuthParams, GetWebAuthnAttestationResult, OauthConfig, OauthParams, SignerBody, SignerResponse, SignupResponse, User } from "./types.js";
|
|
6
6
|
export interface BaseSignerClientParams {
|
|
7
7
|
stamper: TurnkeyClient["stamper"];
|
|
8
8
|
connection: ConnectionConfig;
|
|
@@ -23,12 +23,19 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
23
23
|
protected turnkeyClient: TurnkeyClient;
|
|
24
24
|
protected rootOrg: string;
|
|
25
25
|
protected eventEmitter: EventEmitter<AlchemySignerClientEvents>;
|
|
26
|
+
protected oauthConfig: OauthConfig | undefined;
|
|
26
27
|
/**
|
|
27
28
|
* Create a new instance of the Alchemy Signer client
|
|
28
29
|
*
|
|
29
30
|
* @param {BaseSignerClientParams} params the parameters required to create the client
|
|
30
31
|
*/
|
|
31
32
|
constructor(params: BaseSignerClientParams);
|
|
33
|
+
/**
|
|
34
|
+
* Asynchronously fetches and sets the OAuth configuration.
|
|
35
|
+
*
|
|
36
|
+
* @returns {Promise<OauthConfig>} A promise that resolves to the OAuth configuration
|
|
37
|
+
*/
|
|
38
|
+
initOauth: () => Promise<OauthConfig>;
|
|
32
39
|
protected get user(): User | undefined;
|
|
33
40
|
protected set user(user: User | undefined);
|
|
34
41
|
/**
|
|
@@ -53,13 +60,21 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
53
60
|
abstract initEmailAuth(params: Omit<EmailAuthParams, "targetPublicKey">): Promise<{
|
|
54
61
|
orgId: string;
|
|
55
62
|
}>;
|
|
56
|
-
abstract
|
|
63
|
+
abstract completeAuthWithBundle(params: {
|
|
57
64
|
bundle: string;
|
|
58
65
|
orgId: string;
|
|
66
|
+
connectedEventName: keyof AlchemySignerClientEvents;
|
|
59
67
|
}): Promise<User>;
|
|
68
|
+
abstract oauthWithRedirect(args: Extract<OauthParams, {
|
|
69
|
+
mode: "redirect";
|
|
70
|
+
}>): Promise<never>;
|
|
71
|
+
abstract oauthWithPopup(args: Extract<OauthParams, {
|
|
72
|
+
mode: "popup";
|
|
73
|
+
}>): Promise<User>;
|
|
60
74
|
abstract disconnect(): Promise<void>;
|
|
61
75
|
abstract exportWallet(params: TExportWalletParams): Promise<boolean>;
|
|
62
76
|
abstract lookupUserWithPasskey(user?: User): Promise<User>;
|
|
77
|
+
protected abstract getOauthConfig(): Promise<OauthConfig>;
|
|
63
78
|
protected abstract getWebAuthnAttestation(options: CredentialCreationOptions, userDetails?: {
|
|
64
79
|
username: string;
|
|
65
80
|
}): Promise<GetWebAuthnAttestationResult>;
|
|
@@ -129,7 +144,7 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
129
144
|
* @param {SignerBody<R>} body The request body containing the data to be sent
|
|
130
145
|
* @returns {Promise<SignerResponse<R>>} A promise that resolves to the response from the signer
|
|
131
146
|
*/
|
|
132
|
-
request: <R extends "/v1/signup" | "/v1/whoami" | "/v1/auth" | "/v1/lookup" | "/v1/sign-payload">(route: R, body: SignerBody<R>) => Promise<SignerResponse<R>>;
|
|
147
|
+
request: <R extends "/v1/signup" | "/v1/whoami" | "/v1/auth" | "/v1/lookup" | "/v1/sign-payload" | "/v1/prepare-oauth">(route: R, body: SignerBody<R>) => Promise<SignerResponse<R>>;
|
|
133
148
|
private exportAsSeedPhrase;
|
|
134
149
|
private exportAsPrivateKey;
|
|
135
150
|
protected pollActivityCompletion: <T extends "createOrganizationResult" | "createAuthenticatorsResult" | "createUsersResult" | "createPrivateKeysResult" | "createInvitationsResult" | "acceptInvitationResult" | "signRawPayloadResult" | "createPolicyResult" | "disablePrivateKeyResult" | "deleteUsersResult" | "deleteAuthenticatorsResult" | "deleteInvitationResult" | "deleteOrganizationResult" | "deletePolicyResult" | "createUserTagResult" | "deleteUserTagsResult" | "signTransactionResult" | "deleteApiKeysResult" | "createApiKeysResult" | "createPrivateKeyTagResult" | "deletePrivateKeyTagsResult" | "setPaymentMethodResult" | "activateBillingTierResult" | "deletePaymentMethodResult" | "createApiOnlyUsersResult" | "updateRootQuorumResult" | "updateUserTagResult" | "updatePrivateKeyTagResult" | "createSubOrganizationResult" | "updateAllowedOriginsResult" | "createPrivateKeysResultV2" | "updateUserResult" | "updatePolicyResult" | "createSubOrganizationResultV3" | "createWalletResult" | "createWalletAccountsResult" | "initUserEmailRecoveryResult" | "recoverUserResult" | "setOrganizationFeatureResult" | "removeOrganizationFeatureResult" | "exportPrivateKeyResult" | "exportWalletResult" | "createSubOrganizationResultV4" | "emailAuthResult" | "exportWalletAccountResult">(activity: Awaited<ReturnType<(typeof this.turnkeyClient)["getActivity"]>>["activity"], organizationId: string, resultKey: T) => Promise<NonNullable<{
|
|
@@ -236,7 +251,11 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
236
251
|
privateKeys: {
|
|
237
252
|
privateKeyId?: string | undefined;
|
|
238
253
|
addresses?: {
|
|
239
|
-
format?: "ADDRESS_FORMAT_UNCOMPRESSED" | "ADDRESS_FORMAT_COMPRESSED" | "ADDRESS_FORMAT_ETHEREUM" | "ADDRESS_FORMAT_SOLANA" | "ADDRESS_FORMAT_COSMOS" | undefined;
|
|
254
|
+
format?: "ADDRESS_FORMAT_UNCOMPRESSED" | "ADDRESS_FORMAT_COMPRESSED" | "ADDRESS_FORMAT_ETHEREUM" | "ADDRESS_FORMAT_SOLANA" | "ADDRESS_FORMAT_COSMOS" | undefined; /**
|
|
255
|
+
* Returns the current user or null if no user is set.
|
|
256
|
+
*
|
|
257
|
+
* @returns {User | null} the current user object or null if no user is available
|
|
258
|
+
*/
|
|
240
259
|
address?: string | undefined;
|
|
241
260
|
}[] | undefined;
|
|
242
261
|
}[];
|
|
@@ -252,7 +271,11 @@ export declare abstract class BaseSignerClient<TExportWalletParams = unknown> {
|
|
|
252
271
|
privateKeys: {
|
|
253
272
|
privateKeyId?: string | undefined;
|
|
254
273
|
addresses?: {
|
|
255
|
-
format?: "ADDRESS_FORMAT_UNCOMPRESSED" | "ADDRESS_FORMAT_COMPRESSED" | "ADDRESS_FORMAT_ETHEREUM" | "ADDRESS_FORMAT_SOLANA" | "ADDRESS_FORMAT_COSMOS" | undefined;
|
|
274
|
+
format?: "ADDRESS_FORMAT_UNCOMPRESSED" | "ADDRESS_FORMAT_COMPRESSED" | "ADDRESS_FORMAT_ETHEREUM" | "ADDRESS_FORMAT_SOLANA" | "ADDRESS_FORMAT_COSMOS" | undefined; /**
|
|
275
|
+
* Returns the current user or null if no user is set.
|
|
276
|
+
*
|
|
277
|
+
* @returns {User | null} the current user object or null if no user is available
|
|
278
|
+
*/
|
|
256
279
|
address?: string | undefined;
|
|
257
280
|
}[] | undefined;
|
|
258
281
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/client/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAGhC,OAAO,KAAK,EAEV,yBAAyB,EACzB,mBAAmB,EACnB,e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