@crossmint/client-sdk-smart-wallet 0.1.17 → 0.1.19
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/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/blockchain/wallets/account/passkey.ts +27 -3
- package/src/types/params.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossmint/client-sdk-smart-wallet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"repository": "https://github.com/Crossmint/crossmint-sdk",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Paella Labs Inc",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"permissionless": "0.1.36",
|
|
27
27
|
"viem": "2.17.5",
|
|
28
28
|
"zod": "3.22.4",
|
|
29
|
-
"@crossmint/client-sdk-base": "1.2.
|
|
30
|
-
"@crossmint/common-sdk-base": "0.
|
|
29
|
+
"@crossmint/client-sdk-base": "1.2.8",
|
|
30
|
+
"@crossmint/common-sdk-base": "0.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"typedoc": "0.26.5",
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
PasskeyRegistrationError,
|
|
12
12
|
} from "../../../error";
|
|
13
13
|
import type { AccountAndSigner, PasskeyCreationContext } from "../../../types/internal";
|
|
14
|
-
import type { UserParams } from "../../../types/params";
|
|
14
|
+
import type { PasskeySigner, UserParams, WalletParams } from "../../../types/params";
|
|
15
15
|
import type { PasskeySignerData, PasskeyValidatorSerializedData } from "../../../types/service";
|
|
16
16
|
import { PasskeySignerConfig } from "./signer";
|
|
17
17
|
import type { AccountCreationStrategy } from "./strategy";
|
|
@@ -42,6 +42,10 @@ export class PasskeyCreationStrategy implements AccountCreationStrategy {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
try {
|
|
45
|
+
if (existing == null && walletParams.signer.onPrePasskeyRegistration != null) {
|
|
46
|
+
await walletParams.signer.onPrePasskeyRegistration();
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
const passkey = await this.getPasskey(user, inputPasskeyName, existing?.signerConfig.data);
|
|
46
50
|
|
|
47
51
|
const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;
|
|
@@ -64,9 +68,12 @@ export class PasskeyCreationStrategy implements AccountCreationStrategy {
|
|
|
64
68
|
|
|
65
69
|
return {
|
|
66
70
|
signerConfig: this.getSignerConfig(validator, validatorContractVersion, inputPasskeyName),
|
|
67
|
-
account: this.decorate(kernelAccount, inputPasskeyName),
|
|
71
|
+
account: this.decorate(kernelAccount, inputPasskeyName, walletParams),
|
|
68
72
|
};
|
|
69
73
|
} catch (error) {
|
|
74
|
+
if (walletParams.signer.onPasskeyRegistrationError != null) {
|
|
75
|
+
walletParams.signer.onPasskeyRegistrationError(error);
|
|
76
|
+
}
|
|
70
77
|
throw this.mapError(error, inputPasskeyName);
|
|
71
78
|
}
|
|
72
79
|
}
|
|
@@ -130,7 +137,11 @@ export class PasskeyCreationStrategy implements AccountCreationStrategy {
|
|
|
130
137
|
return error;
|
|
131
138
|
}
|
|
132
139
|
|
|
133
|
-
private decorate<Account extends KernelSmartAccount<EntryPoint>>(
|
|
140
|
+
private decorate<Account extends KernelSmartAccount<EntryPoint>>(
|
|
141
|
+
account: Account,
|
|
142
|
+
passkeyName: string,
|
|
143
|
+
walletParams: WalletParams
|
|
144
|
+
): Account {
|
|
134
145
|
return new Proxy(account, {
|
|
135
146
|
get: (target, prop, receiver) => {
|
|
136
147
|
const original = Reflect.get(target, prop, receiver);
|
|
@@ -138,10 +149,23 @@ export class PasskeyCreationStrategy implements AccountCreationStrategy {
|
|
|
138
149
|
return original;
|
|
139
150
|
}
|
|
140
151
|
|
|
152
|
+
const signer = walletParams.signer as PasskeySigner;
|
|
141
153
|
return async (...args: any[]) => {
|
|
154
|
+
const isFirstTransaction = args?.[0]?.factoryData != null;
|
|
155
|
+
if (
|
|
156
|
+
isFirstTransaction &&
|
|
157
|
+
prop === "signUserOperation" &&
|
|
158
|
+
signer.type === "PASSKEY" &&
|
|
159
|
+
signer.onFirstTimePasskeySigning != null
|
|
160
|
+
) {
|
|
161
|
+
await signer.onFirstTimePasskeySigning();
|
|
162
|
+
}
|
|
142
163
|
try {
|
|
143
164
|
return await original.call(target, ...args);
|
|
144
165
|
} catch (error) {
|
|
166
|
+
if (signer.onFirstTimePasskeySigningError != null) {
|
|
167
|
+
await signer.onFirstTimePasskeySigningError(error);
|
|
168
|
+
}
|
|
145
169
|
throw this.mapError(error, passkeyName);
|
|
146
170
|
}
|
|
147
171
|
};
|
package/src/types/params.ts
CHANGED
|
@@ -22,6 +22,10 @@ export type PasskeySigner = {
|
|
|
22
22
|
* that is specified in the project settings (typically `sub`) will be used.
|
|
23
23
|
*/
|
|
24
24
|
passkeyName?: string;
|
|
25
|
+
onPrePasskeyRegistration?: () => Promise<void> | void;
|
|
26
|
+
onPasskeyRegistrationError?: (error: unknown) => Promise<void>;
|
|
27
|
+
onFirstTimePasskeySigning?: () => Promise<void> | void;
|
|
28
|
+
onFirstTimePasskeySigningError?: (error: unknown) => Promise<void>;
|
|
25
29
|
};
|
|
26
30
|
|
|
27
31
|
export type ExternalSigner = EIP1193Provider | ViemAccount;
|