@rhinestone/sdk 1.0.0-alpha.9 → 1.0.0-beta.38
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/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +30 -15
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +284 -140
- package/dist/src/accounts/index.test.js +3 -5
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +4 -3
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +32 -6
- package/dist/src/accounts/kernel.test.js +41 -19
- package/dist/src/accounts/nexus.d.ts +11 -4
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +182 -25
- package/dist/src/accounts/nexus.test.js +44 -18
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +88 -58
- package/dist/src/accounts/safe.test.js +40 -14
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +145 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +36 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +125 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +88 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +35 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +9 -14
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -38
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +29 -294
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +150 -7
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +112 -95
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +62 -42
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -27
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +357 -103
- package/dist/src/index.d.ts +41 -22
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +199 -65
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +4 -18
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +15 -63
- package/dist/src/modules/index.test.js +9 -26
- package/dist/src/modules/omni-account.d.ts +2 -1
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +3 -1
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +4 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +64 -41
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -7
- package/dist/src/orchestrator/client.d.ts +4 -4
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +30 -15
- package/dist/src/orchestrator/index.d.ts +2 -3
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +1 -23
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +37 -33
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +97 -29
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +74 -10
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +72 -1
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/orchestrator/registry.json +0 -365
- /package/dist/src/{actions → accounts/json-rpc}/index.test.d.ts +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertOwnerSetToSignerSet = convertOwnerSetToSignerSet;
|
|
4
|
+
exports.signWithMultiFactorAuth = signWithMultiFactorAuth;
|
|
5
|
+
exports.signWithSession = signWithSession;
|
|
6
|
+
exports.signWithGuardians = signWithGuardians;
|
|
7
|
+
exports.signWithOwners = signWithOwners;
|
|
8
|
+
const viem_1 = require("viem");
|
|
9
|
+
const modules_1 = require("../../modules");
|
|
10
|
+
const core_1 = require("../../modules/validators/core");
|
|
11
|
+
const passkeys_1 = require("./passkeys");
|
|
12
|
+
function convertOwnerSetToSignerSet(owners) {
|
|
13
|
+
switch (owners.type) {
|
|
14
|
+
case 'ecdsa': {
|
|
15
|
+
return {
|
|
16
|
+
type: 'owner',
|
|
17
|
+
kind: 'ecdsa',
|
|
18
|
+
accounts: owners.accounts,
|
|
19
|
+
module: owners.module,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
case 'passkey': {
|
|
23
|
+
return {
|
|
24
|
+
type: 'owner',
|
|
25
|
+
kind: 'passkey',
|
|
26
|
+
accounts: owners.accounts,
|
|
27
|
+
module: owners.module,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
case 'multi-factor': {
|
|
31
|
+
return {
|
|
32
|
+
type: 'owner',
|
|
33
|
+
kind: 'multi-factor',
|
|
34
|
+
validators: owners.validators.map((validator, index) => {
|
|
35
|
+
switch (validator.type) {
|
|
36
|
+
case 'ecdsa': {
|
|
37
|
+
return {
|
|
38
|
+
type: validator.type,
|
|
39
|
+
id: index,
|
|
40
|
+
accounts: validator.accounts,
|
|
41
|
+
module: validator.module,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case 'passkey': {
|
|
45
|
+
return {
|
|
46
|
+
type: 'passkey',
|
|
47
|
+
id: index,
|
|
48
|
+
accounts: validator.accounts,
|
|
49
|
+
module: validator.module,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function signWithMultiFactorAuth(signers, chain, address, params, isUserOpHash, signMain) {
|
|
59
|
+
const signatures = await Promise.all(signers.validators.map(async (validator) => {
|
|
60
|
+
if (validator === null) {
|
|
61
|
+
return '0x';
|
|
62
|
+
}
|
|
63
|
+
const validatorSigners = convertOwnerSetToSignerSet(validator);
|
|
64
|
+
return signMain(validatorSigners, chain, address, params, isUserOpHash);
|
|
65
|
+
}));
|
|
66
|
+
const data = (0, viem_1.encodeAbiParameters)([
|
|
67
|
+
{
|
|
68
|
+
components: [
|
|
69
|
+
{
|
|
70
|
+
internalType: 'bytes32',
|
|
71
|
+
name: 'packedValidatorAndId',
|
|
72
|
+
type: 'bytes32',
|
|
73
|
+
},
|
|
74
|
+
{ internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
75
|
+
],
|
|
76
|
+
name: 'validators',
|
|
77
|
+
type: 'tuple[]',
|
|
78
|
+
},
|
|
79
|
+
], [
|
|
80
|
+
signers.validators.map((validator, index) => {
|
|
81
|
+
const validatorModule = (0, core_1.getValidator)(validator);
|
|
82
|
+
return {
|
|
83
|
+
packedValidatorAndId: (0, viem_1.concat)([
|
|
84
|
+
(0, viem_1.pad)((0, viem_1.toHex)(validator.id), {
|
|
85
|
+
size: 12,
|
|
86
|
+
}),
|
|
87
|
+
validatorModule.address,
|
|
88
|
+
]),
|
|
89
|
+
data: signatures[index],
|
|
90
|
+
};
|
|
91
|
+
}),
|
|
92
|
+
]);
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
async function signWithSession(signers, chain, address, params, isUserOpHash, signMain) {
|
|
96
|
+
const sessionSigners = convertOwnerSetToSignerSet(signers.session.owners);
|
|
97
|
+
return signMain(sessionSigners, chain, address, params, isUserOpHash);
|
|
98
|
+
}
|
|
99
|
+
async function signWithGuardians(signers, params, signingFunctions) {
|
|
100
|
+
const signatures = await Promise.all(signers.guardians.map((account) => signingFunctions.signEcdsa(account, params, false)));
|
|
101
|
+
return (0, viem_1.concat)(signatures);
|
|
102
|
+
}
|
|
103
|
+
async function signWithOwners(signers, chain, address, params, signingFunctions, isUserOpHash, signMain) {
|
|
104
|
+
switch (signers.kind) {
|
|
105
|
+
case 'ecdsa': {
|
|
106
|
+
// Ownable validator uses `v` value to determine which validation mode to use
|
|
107
|
+
// This is not needed for UserOps
|
|
108
|
+
const updateV = (!signers.module ||
|
|
109
|
+
signers.module?.toLowerCase() === core_1.OWNABLE_VALIDATOR_ADDRESS) &&
|
|
110
|
+
!isUserOpHash;
|
|
111
|
+
const signatures = await Promise.all(signers.accounts.map((account) => signingFunctions.signEcdsa(account, params, updateV)));
|
|
112
|
+
return (0, viem_1.concat)(signatures);
|
|
113
|
+
}
|
|
114
|
+
case 'passkey': {
|
|
115
|
+
const signatures = await Promise.all(signers.accounts.map((account) => signingFunctions.signPasskey(account, params)));
|
|
116
|
+
const usePrecompile = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
117
|
+
const credIds = signers.accounts.map((account) => {
|
|
118
|
+
const publicKey = account.publicKey;
|
|
119
|
+
const { x, y } = (0, passkeys_1.parsePublicKey)(publicKey);
|
|
120
|
+
return (0, passkeys_1.generateCredentialId)(x, y, address);
|
|
121
|
+
});
|
|
122
|
+
const webAuthns = signatures.map((signature) => {
|
|
123
|
+
const { r, s } = (0, passkeys_1.parseSignature)(signature.signature);
|
|
124
|
+
return {
|
|
125
|
+
authenticatorData: signature.webauthn.authenticatorData,
|
|
126
|
+
clientDataJSON: signature.webauthn.clientDataJSON,
|
|
127
|
+
challengeIndex: BigInt(signature.webauthn.challengeIndex),
|
|
128
|
+
typeIndex: BigInt(signature.webauthn.typeIndex),
|
|
129
|
+
r,
|
|
130
|
+
s,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
if (signers.module?.toLowerCase() === core_1.WEBAUTHN_V0_VALIDATOR_ADDRESS) {
|
|
134
|
+
return (0, passkeys_1.packSignatureV0)(webAuthns[0], usePrecompile);
|
|
135
|
+
}
|
|
136
|
+
return (0, passkeys_1.packSignature)(credIds, usePrecompile, webAuthns);
|
|
137
|
+
}
|
|
138
|
+
case 'multi-factor': {
|
|
139
|
+
return signWithMultiFactorAuth(signers, chain, address, params, isUserOpHash, signMain);
|
|
140
|
+
}
|
|
141
|
+
default: {
|
|
142
|
+
throw new Error('Unsupported owner kind');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Address, type Chain, type Hex } from 'viem';
|
|
2
|
+
import type { SignerSet } from '../../types';
|
|
3
|
+
declare function sign(signers: SignerSet, chain: Chain, address: Address, hash: Hex, isUserOpHash: boolean): Promise<Hex>;
|
|
4
|
+
export { sign };
|
|
5
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C,iBAAe,IAAI,CACjB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,GAAG,CAAC,CAyBd;AA4BD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sign = sign;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
async function sign(signers, chain, address, hash, isUserOpHash) {
|
|
8
|
+
const signingFunctions = {
|
|
9
|
+
signEcdsa: (account, hash, updateV) => signEcdsa(account, hash, updateV),
|
|
10
|
+
signPasskey: (account, hash) => signPasskey(account, hash),
|
|
11
|
+
};
|
|
12
|
+
switch (signers.type) {
|
|
13
|
+
case 'owner': {
|
|
14
|
+
return (0, common_1.signWithOwners)(signers, chain, address, hash, signingFunctions, isUserOpHash, sign);
|
|
15
|
+
}
|
|
16
|
+
case 'session': {
|
|
17
|
+
return (0, common_1.signWithSession)(signers, chain, address, hash, isUserOpHash, sign);
|
|
18
|
+
}
|
|
19
|
+
case 'guardians': {
|
|
20
|
+
return (0, common_1.signWithGuardians)(signers, hash, signingFunctions);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function signEcdsa(account, hash, updateV) {
|
|
25
|
+
if (!account.signMessage) {
|
|
26
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
27
|
+
}
|
|
28
|
+
const originalSignature = await account.signMessage({
|
|
29
|
+
message: { raw: hash },
|
|
30
|
+
});
|
|
31
|
+
// Manually tweak the `v` value to trigger the message prefixing onchain
|
|
32
|
+
// https://github.com/rhinestonewtf/checknsignatures/blob/main/src/CheckNSignatures.sol#L53-L61
|
|
33
|
+
const { r, s, v } = (0, viem_1.parseSignature)(originalSignature);
|
|
34
|
+
if (!v) {
|
|
35
|
+
throw new Error('Invalid signature');
|
|
36
|
+
}
|
|
37
|
+
const newV = updateV ? v + 4n : v;
|
|
38
|
+
const newSignature = (0, viem_1.concat)([r, s, (0, viem_1.toHex)(newV)]);
|
|
39
|
+
return newSignature;
|
|
40
|
+
}
|
|
41
|
+
async function signPasskey(account, hash) {
|
|
42
|
+
const { webauthn, signature } = await account.sign({ hash });
|
|
43
|
+
return {
|
|
44
|
+
webauthn,
|
|
45
|
+
signature,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Address, type Hex } from 'viem';
|
|
2
|
+
interface WebAuthnSignature {
|
|
3
|
+
authenticatorData: Hex;
|
|
4
|
+
clientDataJSON: string;
|
|
5
|
+
challengeIndex: bigint;
|
|
6
|
+
typeIndex: bigint;
|
|
7
|
+
r: bigint;
|
|
8
|
+
s: bigint;
|
|
9
|
+
}
|
|
10
|
+
declare function parsePublicKey(publicKey: Hex | Uint8Array): {
|
|
11
|
+
x: bigint;
|
|
12
|
+
y: bigint;
|
|
13
|
+
};
|
|
14
|
+
declare function parseSignature(signature: Hex | Uint8Array): {
|
|
15
|
+
r: bigint;
|
|
16
|
+
s: bigint;
|
|
17
|
+
};
|
|
18
|
+
declare function generateCredentialId(pubKeyX: bigint, pubKeyY: bigint, account: Address): `0x${string}`;
|
|
19
|
+
declare function packSignature(credIds: Hex[], usePrecompile: boolean, webAuthns: {
|
|
20
|
+
authenticatorData: Hex;
|
|
21
|
+
clientDataJSON: string;
|
|
22
|
+
challengeIndex: bigint;
|
|
23
|
+
typeIndex: bigint;
|
|
24
|
+
r: bigint;
|
|
25
|
+
s: bigint;
|
|
26
|
+
}[]): Hex;
|
|
27
|
+
declare function packSignatureV0(webauthn: {
|
|
28
|
+
authenticatorData: Hex;
|
|
29
|
+
clientDataJSON: string;
|
|
30
|
+
typeIndex: number | bigint;
|
|
31
|
+
r: bigint;
|
|
32
|
+
s: bigint;
|
|
33
|
+
}, usePrecompiled: boolean): `0x${string}`;
|
|
34
|
+
export { parsePublicKey, parseSignature, generateCredentialId, packSignature, packSignatureV0, };
|
|
35
|
+
export type { WebAuthnSignature };
|
|
36
|
+
//# sourceMappingURL=passkeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkeys.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/passkeys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAGZ,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,UAAU,iBAAiB;IACzB,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,iBAAS,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG;IACpD,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAUA;AAED,iBAAS,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG;IACpD,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CASA;AAED,iBAAS,oBAAoB,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,iBAkBjB;AAED,iBAAS,aAAa,CACpB,OAAO,EAAE,GAAG,EAAE,EACd,aAAa,EAAE,OAAO,EACtB,SAAS,EAAE;IACT,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,EAAE,GACF,GAAG,CAqDL;AAED,iBAAS,eAAe,CACtB,QAAQ,EAAE;IACR,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,EACD,cAAc,EAAE,OAAO,iBAqCxB;AAED,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,eAAe,GAChB,CAAA;AACD,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePublicKey = parsePublicKey;
|
|
4
|
+
exports.parseSignature = parseSignature;
|
|
5
|
+
exports.generateCredentialId = generateCredentialId;
|
|
6
|
+
exports.packSignature = packSignature;
|
|
7
|
+
exports.packSignatureV0 = packSignatureV0;
|
|
8
|
+
const viem_1 = require("viem");
|
|
9
|
+
function parsePublicKey(publicKey) {
|
|
10
|
+
const bytes = typeof publicKey === 'string' ? (0, viem_1.hexToBytes)(publicKey) : publicKey;
|
|
11
|
+
const offset = bytes.length === 65 ? 1 : 0;
|
|
12
|
+
const x = bytes.slice(offset, 32 + offset);
|
|
13
|
+
const y = bytes.slice(32 + offset, 64 + offset);
|
|
14
|
+
return {
|
|
15
|
+
x: BigInt((0, viem_1.bytesToHex)(x)),
|
|
16
|
+
y: BigInt((0, viem_1.bytesToHex)(y)),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function parseSignature(signature) {
|
|
20
|
+
const bytes = typeof signature === 'string' ? (0, viem_1.hexToBytes)(signature) : signature;
|
|
21
|
+
const r = bytes.slice(0, 32);
|
|
22
|
+
const s = bytes.slice(32, 64);
|
|
23
|
+
return {
|
|
24
|
+
r: BigInt((0, viem_1.bytesToHex)(r)),
|
|
25
|
+
s: BigInt((0, viem_1.bytesToHex)(s)),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function generateCredentialId(pubKeyX, pubKeyY, account) {
|
|
29
|
+
return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
|
|
30
|
+
{
|
|
31
|
+
type: 'uint256',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'uint256',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'address',
|
|
38
|
+
},
|
|
39
|
+
], [pubKeyX, pubKeyY, account]));
|
|
40
|
+
}
|
|
41
|
+
function packSignature(credIds, usePrecompile, webAuthns) {
|
|
42
|
+
// Sort both `credIds` and `webAuthns` by credIds
|
|
43
|
+
const credIdsAndWebAuthns = credIds.map((credId, index) => ({
|
|
44
|
+
credId,
|
|
45
|
+
webAuthn: webAuthns[index],
|
|
46
|
+
}));
|
|
47
|
+
credIdsAndWebAuthns.sort((a, b) => a.credId.localeCompare(b.credId));
|
|
48
|
+
credIds = credIdsAndWebAuthns.map(({ credId }) => credId);
|
|
49
|
+
webAuthns = credIdsAndWebAuthns.map(({ webAuthn }) => webAuthn);
|
|
50
|
+
// Encode
|
|
51
|
+
return (0, viem_1.encodeAbiParameters)([
|
|
52
|
+
{
|
|
53
|
+
type: 'bytes32[]',
|
|
54
|
+
name: 'credIds',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'bool',
|
|
58
|
+
name: 'usePrecompile',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: 'tuple[]',
|
|
62
|
+
name: 'webAuthns',
|
|
63
|
+
components: [
|
|
64
|
+
{
|
|
65
|
+
type: 'bytes',
|
|
66
|
+
name: 'authenticatorData',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'string',
|
|
70
|
+
name: 'clientDataJSON',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: 'uint256',
|
|
74
|
+
name: 'challengeIndex',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'uint256',
|
|
78
|
+
name: 'typeIndex',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'uint256',
|
|
82
|
+
name: 'r',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'uint256',
|
|
86
|
+
name: 's',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
], [credIds, usePrecompile, webAuthns]);
|
|
91
|
+
}
|
|
92
|
+
function packSignatureV0(webauthn, usePrecompiled) {
|
|
93
|
+
return (0, viem_1.encodeAbiParameters)([
|
|
94
|
+
{ type: 'bytes', name: 'authenticatorData' },
|
|
95
|
+
{
|
|
96
|
+
type: 'string',
|
|
97
|
+
name: 'clientDataJSON',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: 'uint256',
|
|
101
|
+
name: 'responseTypeLocation',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: 'uint256',
|
|
105
|
+
name: 'r',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'uint256',
|
|
109
|
+
name: 's',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
type: 'bool',
|
|
113
|
+
name: 'usePrecompiled',
|
|
114
|
+
},
|
|
115
|
+
], [
|
|
116
|
+
webauthn.authenticatorData,
|
|
117
|
+
webauthn.clientDataJSON,
|
|
118
|
+
typeof webauthn.typeIndex === 'bigint'
|
|
119
|
+
? webauthn.typeIndex
|
|
120
|
+
: BigInt(webauthn.typeIndex),
|
|
121
|
+
webauthn.r,
|
|
122
|
+
webauthn.s,
|
|
123
|
+
usePrecompiled,
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkeys.test.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/passkeys.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const passkeys_1 = require("./passkeys");
|
|
5
|
+
(0, vitest_1.describe)('Passkeys', () => {
|
|
6
|
+
(0, vitest_1.describe)('Parse Public Key', () => {
|
|
7
|
+
(0, vitest_1.test)('default', () => {
|
|
8
|
+
const parsed = (0, passkeys_1.parsePublicKey)('0x7a2b9234dbc079da984e021acb76cf230dff5c03f2c5668024ddaeeb388520294bd61dcef34cade4d3bca405e63179ef022948ac45d0b0530cb125977c118ad7');
|
|
9
|
+
(0, vitest_1.expect)(parsed.x).toEqual(55259151030970399927675340420359705684663366332711724388150056154288143802409n);
|
|
10
|
+
(0, vitest_1.expect)(parsed.y).toEqual(34301774645623054632612895881498878184566570389017277955884655401641769536215n);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.describe)('Parse Signature', () => {
|
|
14
|
+
(0, vitest_1.test)('default', () => {
|
|
15
|
+
const parsed = (0, passkeys_1.parseSignature)('0xf60f80fe3fd029d1b380d631f0b659bfbc8f8f60921a88e1e123c159aa540f920ed337464d1bb813dc5f9c3e81998185370da49cc525e9f42cdf805f1030aff8');
|
|
16
|
+
(0, vitest_1.expect)(parsed.r).toEqual(111296353735534357766084082487308191701889898756402773464442570100570127077266n);
|
|
17
|
+
(0, vitest_1.expect)(parsed.s).toEqual(6705566102199758127831148650668918567109283965479844611524279039128750829560n);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
(0, vitest_1.describe)('Generate Credential ID', () => {
|
|
21
|
+
(0, vitest_1.test)('default', () => {
|
|
22
|
+
const id = (0, passkeys_1.generateCredentialId)(55259151030970399927675340420359705684663366332711724388150056154288143802409n, 34301774645623054632612895881498878184566570389017277955884655401641769536215n, '0xb975975c9f381b5df3b4af93bdd1ba739698bc37');
|
|
23
|
+
(0, vitest_1.expect)(id).toEqual('0x9437809df26444a849d303b1174543f0851df5fae657da19f3bb0d92356426ea');
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.describe)('Pack Signature', () => {
|
|
27
|
+
(0, vitest_1.test)('single', () => {
|
|
28
|
+
const credIds = [
|
|
29
|
+
'0x9437809df26444a849d303b1174543f0851df5fae657da19f3bb0d92356426ea',
|
|
30
|
+
];
|
|
31
|
+
const usePrecompile = false;
|
|
32
|
+
const webAuthns = [
|
|
33
|
+
{
|
|
34
|
+
authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000',
|
|
35
|
+
clientDataJSON: '{"type":"webauthn.get","challenge":"4p2TiZpTooLCFFYTC2HmMPVMiVjZGghCJ0dz7zUDEeA","origin":"http://localhost:5173","crossOrigin":false}',
|
|
36
|
+
challengeIndex: 23n,
|
|
37
|
+
typeIndex: 1n,
|
|
38
|
+
r: 111296353735534357766084082487308191701889898756402773464442570100570127077266n,
|
|
39
|
+
s: 6705566102199758127831148650668918567109283965479844611524279039128750829560n,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
const packed = (0, passkeys_1.packSignature)(credIds, usePrecompile, webAuthns);
|
|
43
|
+
(0, vitest_1.expect)(packed).toEqual('0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000019437809df26444a849d303b1174543f0851df5fae657da19f3bb0d92356426ea0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001f60f80fe3fd029d1b380d631f0b659bfbc8f8f60921a88e1e123c159aa540f920ed337464d1bb813dc5f9c3e81998185370da49cc525e9f42cdf805f1030aff8000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2234703254695a70546f6f4c43464659544332486d4d50564d69566a5a476768434a30647a377a5544456541222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000');
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.test)('multisig', () => {
|
|
46
|
+
const credIds = [
|
|
47
|
+
'0x9437809df26444a849d303b1174543f0851df5fae657da19f3bb0d92356426ea',
|
|
48
|
+
'0x6be9646e4d64132d1a1789a467d0501e948d23afce6792d963f401434d7bef33',
|
|
49
|
+
];
|
|
50
|
+
const usePrecompile = true;
|
|
51
|
+
const webAuthns = [
|
|
52
|
+
{
|
|
53
|
+
authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000',
|
|
54
|
+
clientDataJSON: '{"type":"webauthn.get","challenge":"4p2TiZpTooLCFFYTC2HmMPVMiVjZGghCJ0dz7zUDEeA","origin":"http://localhost:5173","crossOrigin":false}',
|
|
55
|
+
challengeIndex: 23n,
|
|
56
|
+
typeIndex: 1n,
|
|
57
|
+
r: 111296353735534357766084082487308191701889898756402773464442570100570127077266n,
|
|
58
|
+
s: 6705566102199758127831148650668918567109283965479844611524279039128750829560n,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000',
|
|
62
|
+
clientDataJSON: '{"type":"webauthn.get","challenge":"19qAcQAVCeucFt8tQSizBBdbxW6Jkex_3nAejdRuVek","origin":"http://localhost:5173","crossOrigin":false}',
|
|
63
|
+
challengeIndex: 23n,
|
|
64
|
+
typeIndex: 1n,
|
|
65
|
+
r: 52674584175531096231012948456392242307658490190760877544141461393264453154030n,
|
|
66
|
+
s: 1045924358482323524717958171193057427003444327614976707002321626568131749413n,
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
const packed = (0, passkeys_1.packSignature)(credIds, usePrecompile, webAuthns);
|
|
70
|
+
(0, vitest_1.expect)(packed).toEqual('0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000026be9646e4d64132d1a1789a467d0501e948d23afce6792d963f401434d7bef339437809df26444a849d303b1174543f0851df5fae657da19f3bb0d92356426ea00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001700000000000000000000000000000000000000000000000000000000000000017474c214167b8a4704cf06f75287a738e7ddbcca9cc0383db6dac6a7d090f4ee024ff8e2a2e8c54aa8cf5f36e3b6125016c3d58d896e3a85c5cd2cd0027a2625000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22313971416351415643657563467438745153697a424264627857364a6b65785f336e41656a64527556656b222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73657d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001f60f80fe3fd029d1b380d631f0b659bfbc8f8f60921a88e1e123c159aa540f920ed337464d1bb813dc5f9c3e81998185370da49cc525e9f42cdf805f1030aff8000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2234703254695a70546f6f4c43464659544332486d4d50564d69566a5a476768434a30647a377a5544456541222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
(0, vitest_1.describe)('Pack Signature V0', () => {
|
|
74
|
+
(0, vitest_1.test)('single', () => {
|
|
75
|
+
const usePrecompile = false;
|
|
76
|
+
const webAuthns = {
|
|
77
|
+
authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000',
|
|
78
|
+
clientDataJSON: '{"type":"webauthn.get","challenge":"4p2TiZpTooLCFFYTC2HmMPVMiVjZGghCJ0dz7zUDEeA","origin":"http://localhost:5173","crossOrigin":false}',
|
|
79
|
+
challengeIndex: 23n,
|
|
80
|
+
typeIndex: 1n,
|
|
81
|
+
r: 111296353735534357766084082487308191701889898756402773464442570100570127077266n,
|
|
82
|
+
s: 6705566102199758127831148650668918567109283965479844611524279039128750829560n,
|
|
83
|
+
};
|
|
84
|
+
const packed = (0, passkeys_1.packSignatureV0)(webAuthns, usePrecompile);
|
|
85
|
+
(0, vitest_1.expect)(packed).toEqual('0x00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001f60f80fe3fd029d1b380d631f0b659bfbc8f8f60921a88e1e123c159aa540f920ed337464d1bb813dc5f9c3e81998185370da49cc525e9f42cdf805f1030aff80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000867b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2234703254695a70546f6f4c43464659544332486d4d50564d69566a5a476768434a30647a377a5544456541222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73657d0000000000000000000000000000000000000000000000000000');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Address, Chain, HashTypedDataParameters, Hex, TypedData } from 'viem';
|
|
2
|
+
import type { SignerSet } from '../../types';
|
|
3
|
+
declare function sign<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(signers: SignerSet, chain: Chain, address: Address, parameters: HashTypedDataParameters<typedData, primaryType>): Promise<Hex>;
|
|
4
|
+
export { sign };
|
|
5
|
+
//# sourceMappingURL=typedData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedData.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/typedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,SAAS,EACV,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C,iBAAe,IAAI,CACjB,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACjE,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,SAAS,EAEtE,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,GAC1D,OAAO,CAAC,GAAG,CAAC,CA2Bd;AA6BD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sign = sign;
|
|
4
|
+
const error_1 = require("../error");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
async function sign(signers, chain, address, parameters) {
|
|
7
|
+
const signingFunctions = {
|
|
8
|
+
signEcdsa: (account, params) => signEcdsa(account, params),
|
|
9
|
+
signPasskey: (account, params) => signPasskey(account, params),
|
|
10
|
+
};
|
|
11
|
+
switch (signers.type) {
|
|
12
|
+
case 'owner': {
|
|
13
|
+
return (0, common_1.signWithOwners)(signers, chain, address, parameters, signingFunctions, false, sign);
|
|
14
|
+
}
|
|
15
|
+
case 'session': {
|
|
16
|
+
return (0, common_1.signWithSession)(signers, chain, address, parameters, false, sign);
|
|
17
|
+
}
|
|
18
|
+
case 'guardians': {
|
|
19
|
+
return (0, common_1.signWithGuardians)(signers, parameters, signingFunctions);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function signEcdsa(account, parameters) {
|
|
24
|
+
if (!account.signTypedData) {
|
|
25
|
+
throw new error_1.SigningNotSupportedForAccountError();
|
|
26
|
+
}
|
|
27
|
+
return await account.signTypedData(parameters);
|
|
28
|
+
}
|
|
29
|
+
async function signPasskey(account, parameters) {
|
|
30
|
+
const { webauthn, signature } = await account.signTypedData(parameters);
|
|
31
|
+
return {
|
|
32
|
+
webauthn,
|
|
33
|
+
signature,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -12,9 +12,9 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
12
12
|
};
|
|
13
13
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
14
14
|
declare function getInstallData(module: Module): `0x${string}`;
|
|
15
|
-
declare function
|
|
15
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
16
16
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
17
17
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
18
18
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
19
|
-
export { getInstallData, getAddress,
|
|
19
|
+
export { getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, };
|
|
20
20
|
//# sourceMappingURL=startale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startale.d.ts","sourceRoot":"","sources":["../../../accounts/startale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAatD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAQ1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAa9C,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAuDrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBAErC;AAED,iBAAe,
|
|
1
|
+
{"version":3,"file":"startale.d.ts","sourceRoot":"","sources":["../../../accounts/startale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAatD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAQ1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAa9C,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAuDrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBA4BlD;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,MAAM,iBAErC;AAED,iBAAe,aAAa,CAC1B,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,eAAe,EAC1B,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAQvE;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAUlC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACpC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAWlC;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,oKAUlC;AAED,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,CAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstallData = getInstallData;
|
|
4
4
|
exports.getAddress = getAddress;
|
|
5
|
-
exports.
|
|
5
|
+
exports.packSignature = packSignature;
|
|
6
6
|
exports.getDeployArgs = getDeployArgs;
|
|
7
7
|
exports.getSmartAccount = getSmartAccount;
|
|
8
8
|
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
@@ -86,8 +86,8 @@ function getAddress(config) {
|
|
|
86
86
|
function getInstallData(module) {
|
|
87
87
|
return (0, nexus_1.getInstallData)(module);
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
90
|
-
return (0, nexus_1.
|
|
89
|
+
async function packSignature(signature, validator, transformSignature = (signature) => signature) {
|
|
90
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature, K1_DEFAULT_VALIDATOR_ADDRESS);
|
|
91
91
|
}
|
|
92
92
|
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
93
93
|
return (0, nexus_1.getSmartAccount)(client, address, owners, validatorAddress, sign, K1_DEFAULT_VALIDATOR_ADDRESS);
|