@account-kit/signer 4.35.0 → 4.36.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/dist/esm/base.d.ts +2 -2
- package/dist/esm/base.js +22 -5
- package/dist/esm/base.js.map +1 -1
- package/dist/esm/client/base.d.ts +4 -292
- package/dist/esm/client/base.js.map +1 -1
- package/dist/esm/client/index.d.ts +14 -26
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/metrics.js.map +1 -1
- package/dist/esm/oauth.js.map +1 -1
- package/dist/esm/session/manager.d.ts +2 -2
- package/dist/esm/session/manager.js.map +1 -1
- package/dist/esm/signer.d.ts +25 -117
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/solanaSigner.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 +2 -2
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/client/base.d.ts +4 -292
- package/dist/types/client/base.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +14 -26
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/session/manager.d.ts +2 -2
- package/dist/types/session/manager.d.ts.map +1 -1
- package/dist/types/signer.d.ts +25 -117
- package/dist/types/signer.d.ts.map +1 -1
- package/dist/types/utils/base64UrlEncode.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -8
- package/src/base.ts +75 -54
- package/src/client/base.ts +37 -38
- package/src/client/index.ts +10 -10
- package/src/client/types.ts +1 -1
- package/src/errors.ts +1 -1
- package/src/metrics.ts +1 -1
- package/src/oauth.ts +1 -1
- package/src/session/manager.ts +15 -12
- package/src/signer.ts +1 -1
- package/src/solanaSigner.ts +15 -15
- package/src/version.ts +1 -1
package/src/client/index.ts
CHANGED
|
@@ -149,7 +149,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
149
149
|
// Passkey account creation flow
|
|
150
150
|
const { attestation, challenge } = await this.getWebAuthnAttestation(
|
|
151
151
|
params.creationOpts,
|
|
152
|
-
{ username: "email" in params ? params.email : params.username }
|
|
152
|
+
{ username: "email" in params ? params.email : params.username },
|
|
153
153
|
);
|
|
154
154
|
|
|
155
155
|
const result = await this.request("/v1/signup", {
|
|
@@ -196,7 +196,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
196
196
|
* @returns {Promise<any>} The response from the authentication request
|
|
197
197
|
*/
|
|
198
198
|
public override initEmailAuth = async (
|
|
199
|
-
params: Omit<EmailAuthParams, "targetPublicKey"
|
|
199
|
+
params: Omit<EmailAuthParams, "targetPublicKey">,
|
|
200
200
|
) => {
|
|
201
201
|
this.eventEmitter.emit("authenticating", { type: "otp" });
|
|
202
202
|
const { email, emailMode, expirationSeconds } = params;
|
|
@@ -250,7 +250,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
250
250
|
* @returns {Promise<{ bundle: string }>} A promise that resolves to an object containing the credential bundle.
|
|
251
251
|
*/
|
|
252
252
|
public override async submitOtpCode(
|
|
253
|
-
args: Omit<OtpParams, "targetPublicKey"
|
|
253
|
+
args: Omit<OtpParams, "targetPublicKey">,
|
|
254
254
|
): Promise<SubmitOtpCodeResponse> {
|
|
255
255
|
this.eventEmitter.emit("authenticating", { type: "otpVerify" });
|
|
256
256
|
const targetPublicKey = await this.initIframeStamper();
|
|
@@ -281,7 +281,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
281
281
|
|
|
282
282
|
// Otherwise, it's truly an error:
|
|
283
283
|
throw new Error(
|
|
284
|
-
"Failed to submit OTP code. Server did not return required fields."
|
|
284
|
+
"Failed to submit OTP code. Server did not return required fields.",
|
|
285
285
|
);
|
|
286
286
|
}
|
|
287
287
|
|
|
@@ -366,7 +366,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
366
366
|
* @returns {Promise<User>} A promise that resolves to the authenticated user object
|
|
367
367
|
*/
|
|
368
368
|
public override lookupUserWithPasskey = async (
|
|
369
|
-
user: User | undefined = undefined
|
|
369
|
+
user: User | undefined = undefined,
|
|
370
370
|
) => {
|
|
371
371
|
this.eventEmitter.emit("authenticating", { type: "passkey" });
|
|
372
372
|
await this.initWebauthnStamper(user);
|
|
@@ -487,7 +487,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
487
487
|
* @returns {Promise<never>} A promise that will never resolve, only reject if the redirection fails
|
|
488
488
|
*/
|
|
489
489
|
public override oauthWithRedirect = async (
|
|
490
|
-
args: Extract<AuthParams, { type: "oauth"; mode: "redirect" }
|
|
490
|
+
args: Extract<AuthParams, { type: "oauth"; mode: "redirect" }>,
|
|
491
491
|
): Promise<never> => {
|
|
492
492
|
const turnkeyPublicKey = await this.initIframeStamper();
|
|
493
493
|
|
|
@@ -500,7 +500,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
500
500
|
|
|
501
501
|
window.location.href = providerUrl;
|
|
502
502
|
return new Promise((_, reject) =>
|
|
503
|
-
setTimeout(() => reject("Failed to redirect to OAuth provider"), 1000)
|
|
503
|
+
setTimeout(() => reject("Failed to redirect to OAuth provider"), 1000),
|
|
504
504
|
);
|
|
505
505
|
};
|
|
506
506
|
|
|
@@ -531,7 +531,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
531
531
|
* @returns {Promise<User>} A promise that resolves to a `User` object containing the authenticated user information
|
|
532
532
|
*/
|
|
533
533
|
public override oauthWithPopup = async (
|
|
534
|
-
args: Extract<AuthParams, { type: "oauth"; mode: "popup" }
|
|
534
|
+
args: Extract<AuthParams, { type: "oauth"; mode: "popup" }>,
|
|
535
535
|
): Promise<User | AuthLinkingPrompt> => {
|
|
536
536
|
const turnkeyPublicKey = await this.initIframeStamper();
|
|
537
537
|
const oauthParams = args;
|
|
@@ -543,7 +543,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
543
543
|
const popup = window.open(
|
|
544
544
|
providerUrl,
|
|
545
545
|
"_blank",
|
|
546
|
-
"popup,width=500,height=600"
|
|
546
|
+
"popup,width=500,height=600",
|
|
547
547
|
);
|
|
548
548
|
const eventEmitter = this.eventEmitter;
|
|
549
549
|
return new Promise((resolve, reject) => {
|
|
@@ -672,7 +672,7 @@ export class AlchemySignerWebClient extends BaseSignerClient<ExportWalletParams>
|
|
|
672
672
|
options?: CredentialCreationOptionOverrides,
|
|
673
673
|
userDetails: { username: string } = {
|
|
674
674
|
username: this.user?.email ?? "anonymous",
|
|
675
|
-
}
|
|
675
|
+
},
|
|
676
676
|
) => {
|
|
677
677
|
const challenge = generateRandomBuffer();
|
|
678
678
|
const authenticatorUserId = generateRandomBuffer();
|
package/src/client/types.ts
CHANGED
package/src/errors.ts
CHANGED
package/src/metrics.ts
CHANGED
package/src/oauth.ts
CHANGED
|
@@ -33,7 +33,7 @@ const DEFAULT_PROVIDER_CUSTOMIZATION: Record<
|
|
|
33
33
|
* @returns {AuthProviderCustomization | undefined} default customization parameters
|
|
34
34
|
*/
|
|
35
35
|
export function getDefaultProviderCustomization(
|
|
36
|
-
knownAuthProviderId: KnownAuthProvider
|
|
36
|
+
knownAuthProviderId: KnownAuthProvider,
|
|
37
37
|
): AuthProviderCustomization | undefined {
|
|
38
38
|
return DEFAULT_PROVIDER_CUSTOMIZATION[knownAuthProviderId];
|
|
39
39
|
}
|
package/src/session/manager.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const SessionManagerParamsSchema = z.object({
|
|
|
27
27
|
.number()
|
|
28
28
|
.default(DEFAULT_SESSION_MS)
|
|
29
29
|
.describe(
|
|
30
|
-
"The time in milliseconds that a session should last before expiring [default: 15 minutes]"
|
|
30
|
+
"The time in milliseconds that a session should last before expiring [default: 15 minutes]",
|
|
31
31
|
),
|
|
32
32
|
client: z.custom<BaseSignerClient>(),
|
|
33
33
|
});
|
|
@@ -81,8 +81,8 @@ export class SessionManager {
|
|
|
81
81
|
persist(this.getInitialState, {
|
|
82
82
|
name: this.sessionKey,
|
|
83
83
|
storage: createJSONStorage<SessionState>(() => storage),
|
|
84
|
-
})
|
|
85
|
-
)
|
|
84
|
+
}),
|
|
85
|
+
),
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
this.registerEventListeners();
|
|
@@ -138,7 +138,7 @@ export class SessionManager {
|
|
|
138
138
|
default:
|
|
139
139
|
assertNever(
|
|
140
140
|
existingSession,
|
|
141
|
-
`Unknown session type: ${(existingSession as any).type}
|
|
141
|
+
`Unknown session type: ${(existingSession as any).type}`,
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
};
|
|
@@ -156,7 +156,7 @@ export class SessionManager {
|
|
|
156
156
|
// temporary session must be placed in localStorage so that it can be accessed across tabs
|
|
157
157
|
localStorage.setItem(
|
|
158
158
|
`${this.sessionKey}:temporary`,
|
|
159
|
-
JSON.stringify(session)
|
|
159
|
+
JSON.stringify(session),
|
|
160
160
|
);
|
|
161
161
|
};
|
|
162
162
|
|
|
@@ -173,7 +173,7 @@ export class SessionManager {
|
|
|
173
173
|
|
|
174
174
|
on = <E extends keyof SessionManagerEvents>(
|
|
175
175
|
event: E,
|
|
176
|
-
listener: SessionManagerEvents[E]
|
|
176
|
+
listener: SessionManagerEvents[E],
|
|
177
177
|
) => {
|
|
178
178
|
this.eventEmitter.on(event, listener as any);
|
|
179
179
|
|
|
@@ -211,7 +211,7 @@ export class SessionManager {
|
|
|
211
211
|
Extract<Session, { type: "email" | "oauth" | "otp" }>,
|
|
212
212
|
"expirationDateMs"
|
|
213
213
|
>
|
|
214
|
-
| Omit<Extract<Session, { type: "passkey" }>, "expirationDateMs"
|
|
214
|
+
| Omit<Extract<Session, { type: "passkey" }>, "expirationDateMs">,
|
|
215
215
|
) => {
|
|
216
216
|
const session = {
|
|
217
217
|
...session_,
|
|
@@ -250,7 +250,7 @@ export class SessionManager {
|
|
|
250
250
|
} else if (session == null && prevSession != null) {
|
|
251
251
|
this.eventEmitter.emit("disconnected");
|
|
252
252
|
}
|
|
253
|
-
}
|
|
253
|
+
},
|
|
254
254
|
);
|
|
255
255
|
|
|
256
256
|
// Helper type to ensure that a listener is either defined or explicitly
|
|
@@ -325,10 +325,13 @@ export class SessionManager {
|
|
|
325
325
|
clearTimeout(this.clearSessionHandle);
|
|
326
326
|
}
|
|
327
327
|
|
|
328
|
-
this.clearSessionHandle = setTimeout(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
328
|
+
this.clearSessionHandle = setTimeout(
|
|
329
|
+
() => {
|
|
330
|
+
this.client.disconnect();
|
|
331
|
+
this.clearSession();
|
|
332
|
+
},
|
|
333
|
+
Math.min(session.expirationDateMs - Date.now(), Math.pow(2, 31) - 1),
|
|
334
|
+
);
|
|
332
335
|
};
|
|
333
336
|
|
|
334
337
|
private setSessionWithUserAndBundle = ({
|
package/src/signer.ts
CHANGED
|
@@ -276,7 +276,7 @@ function installReplaceStateFilter(qpToRemove: string[]) {
|
|
|
276
276
|
* as the input whose values are the values of the query params.
|
|
277
277
|
*/
|
|
278
278
|
function getAndRemoveQueryParams<T extends Record<string, string>>(
|
|
279
|
-
keys: T
|
|
279
|
+
keys: T,
|
|
280
280
|
): { [K in keyof T]: string | undefined } {
|
|
281
281
|
const url = new URL(window.location.href);
|
|
282
282
|
const result: Record<string, string | undefined> = {};
|
package/src/solanaSigner.ts
CHANGED
|
@@ -38,7 +38,7 @@ export class SolanaSigner {
|
|
|
38
38
|
* @returns {Promise<Transaction | VersionedTransaction >} The transaction with the signature added
|
|
39
39
|
*/
|
|
40
40
|
async addSignature(
|
|
41
|
-
transaction: Transaction | VersionedTransaction
|
|
41
|
+
transaction: Transaction | VersionedTransaction,
|
|
42
42
|
): Promise<Transaction | VersionedTransaction> {
|
|
43
43
|
const user = this.alchemyClient.getUser();
|
|
44
44
|
if (!user) {
|
|
@@ -53,12 +53,12 @@ export class SolanaSigner {
|
|
|
53
53
|
const messageToSign = this.getMessageToSign(transaction);
|
|
54
54
|
const signature = await this.alchemyClient.signRawMessage(
|
|
55
55
|
messageToSign,
|
|
56
|
-
"SOLANA"
|
|
56
|
+
"SOLANA",
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
transaction.addSignature(
|
|
60
60
|
fromKey,
|
|
61
|
-
Buffer.from(toBytes(this.formatSignatureForSolana(signature)))
|
|
61
|
+
Buffer.from(toBytes(this.formatSignatureForSolana(signature))),
|
|
62
62
|
);
|
|
63
63
|
return transaction;
|
|
64
64
|
}
|
|
@@ -82,7 +82,7 @@ export class SolanaSigner {
|
|
|
82
82
|
const messageToSign = toHex(message);
|
|
83
83
|
const signature = await this.alchemyClient.signRawMessage(
|
|
84
84
|
messageToSign,
|
|
85
|
-
"SOLANA"
|
|
85
|
+
"SOLANA",
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
return toBytes(this.formatSignatureForSolana(signature));
|
|
@@ -91,16 +91,16 @@ export class SolanaSigner {
|
|
|
91
91
|
async createTransaction(
|
|
92
92
|
instructions: TransactionInstruction[],
|
|
93
93
|
connection: Connection,
|
|
94
|
-
version?: "versioned"
|
|
94
|
+
version?: "versioned",
|
|
95
95
|
): Promise<VersionedTransaction>;
|
|
96
96
|
async createTransaction(
|
|
97
97
|
instructions: TransactionInstruction[],
|
|
98
98
|
connection: Connection,
|
|
99
|
-
version?: "legacy"
|
|
99
|
+
version?: "legacy",
|
|
100
100
|
): Promise<Transaction>;
|
|
101
101
|
async createTransaction(
|
|
102
102
|
instructions: TransactionInstruction[],
|
|
103
|
-
connection: Connection
|
|
103
|
+
connection: Connection,
|
|
104
104
|
): Promise<VersionedTransaction>;
|
|
105
105
|
|
|
106
106
|
/**
|
|
@@ -114,7 +114,7 @@ export class SolanaSigner {
|
|
|
114
114
|
async createTransaction(
|
|
115
115
|
instructions: TransactionInstruction[],
|
|
116
116
|
connection: Connection,
|
|
117
|
-
version?: string
|
|
117
|
+
version?: string,
|
|
118
118
|
): Promise<Transaction | VersionedTransaction> {
|
|
119
119
|
const blockhash = (await connection.getLatestBlockhash()).blockhash;
|
|
120
120
|
|
|
@@ -124,7 +124,7 @@ export class SolanaSigner {
|
|
|
124
124
|
// Legacy transaction
|
|
125
125
|
transferTransaction = instructions.reduce(
|
|
126
126
|
(tx, instruction) => tx.add(instruction),
|
|
127
|
-
new Transaction()
|
|
127
|
+
new Transaction(),
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
// Get a recent block hash
|
|
@@ -157,7 +157,7 @@ export class SolanaSigner {
|
|
|
157
157
|
async addSponsorship(
|
|
158
158
|
instructions: TransactionInstruction[],
|
|
159
159
|
connection: Connection,
|
|
160
|
-
policyId: string
|
|
160
|
+
policyId: string,
|
|
161
161
|
): Promise<VersionedTransaction> {
|
|
162
162
|
const { blockhash } = await connection.getLatestBlockhash({
|
|
163
163
|
commitment: "finalized",
|
|
@@ -170,7 +170,7 @@ export class SolanaSigner {
|
|
|
170
170
|
}).compileToV0Message();
|
|
171
171
|
const versionedTransaction = new VersionedTransaction(message);
|
|
172
172
|
const serializedTransaction = Buffer.from(
|
|
173
|
-
versionedTransaction.serialize()
|
|
173
|
+
versionedTransaction.serialize(),
|
|
174
174
|
).toString("base64");
|
|
175
175
|
const body = JSON.stringify({
|
|
176
176
|
id: crypto?.randomUUID() ?? Math.floor(Math.random() * 1000000),
|
|
@@ -195,17 +195,17 @@ export class SolanaSigner {
|
|
|
195
195
|
const response = await fetch(
|
|
196
196
|
// TODO: Use the connection??
|
|
197
197
|
connection.rpcEndpoint,
|
|
198
|
-
options
|
|
198
|
+
options,
|
|
199
199
|
);
|
|
200
200
|
const jsonResponse = await response.json();
|
|
201
201
|
if (!jsonResponse?.result?.serializedTransaction)
|
|
202
202
|
throw new Error(
|
|
203
203
|
`Response doesn't include the serializedTransaction ${JSON.stringify(
|
|
204
|
-
jsonResponse
|
|
205
|
-
)}
|
|
204
|
+
jsonResponse,
|
|
205
|
+
)}`,
|
|
206
206
|
);
|
|
207
207
|
return VersionedTransaction.deserialize(
|
|
208
|
-
decodeBase64(jsonResponse.result.serializedTransaction)
|
|
208
|
+
decodeBase64(jsonResponse.result.serializedTransaction),
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
|
package/src/version.ts
CHANGED