@rhinestone/sdk 0.0.0-dev-20260728163313 → 0.0.0-dev-20260728220029
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/actions/passkeys.d.ts.map +1 -1
- package/dist/src/actions/passkeys.js +4 -64
- package/dist/src/actions/recovery.d.ts +4 -1
- package/dist/src/actions/recovery.d.ts.map +1 -1
- package/dist/src/actions/recovery.js +15 -5
- package/dist/src/actions/webauthn.d.ts +6 -0
- package/dist/src/actions/webauthn.d.ts.map +1 -0
- package/dist/src/actions/webauthn.js +67 -0
- package/dist/src/clients/orchestrator/client.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passkeys.d.ts","sourceRoot":"","sources":["../../../actions/passkeys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"passkeys.d.ts","sourceRoot":"","sources":["../../../actions/passkeys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,gCAAgC,CAAA;AAWvC;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,UAAU,EAAE,kBAAkB,GAAG,aAAa,CAU7D;AAED;;;GAGG;AACH,iBAAS,OAAO,IAAI,aAAa,CAgBhC;AAED;;;;;;GAMG;AACH,iBAAS,QAAQ,CACf,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,uBAAuB,EAAE,OAAO,GAC/B,aAAa,CAOf;AAED;;;;;GAKG;AACH,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAEpE;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAE5D;AAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { encodeFunctionData } from 'viem';
|
|
2
1
|
import { resolveWebauthnCredentials, WEBAUTHN_VALIDATOR_ADDRESS, } from '../modules/validators/webauthn.js';
|
|
3
2
|
import { resolveModuleInstallation, resolveModuleUninstallation, } from './runtime.js';
|
|
3
|
+
import { addWebauthnCredential, changeWebauthnThreshold, removeWebauthnCredential, } from './webauthn.js';
|
|
4
4
|
/**
|
|
5
5
|
* Enable passkeys authentication
|
|
6
6
|
* @param pubKey Public key for the passkey
|
|
@@ -46,30 +46,7 @@ function disable() {
|
|
|
46
46
|
* @returns Call to add the passkey owner
|
|
47
47
|
*/
|
|
48
48
|
function addOwner(pubKeyX, pubKeyY, requireUserVerification) {
|
|
49
|
-
return
|
|
50
|
-
to: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
51
|
-
value: 0n,
|
|
52
|
-
data: encodeFunctionData({
|
|
53
|
-
abi: [
|
|
54
|
-
{
|
|
55
|
-
inputs: [
|
|
56
|
-
{ name: 'pubKeyX', type: 'uint256' },
|
|
57
|
-
{ name: 'pubKeyY', type: 'uint256' },
|
|
58
|
-
{
|
|
59
|
-
name: 'requireUserVerification',
|
|
60
|
-
type: 'bool',
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
name: 'addCredential',
|
|
64
|
-
outputs: [],
|
|
65
|
-
stateMutability: 'nonpayable',
|
|
66
|
-
type: 'function',
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
functionName: 'addCredential',
|
|
70
|
-
args: [pubKeyX, pubKeyY, requireUserVerification],
|
|
71
|
-
}),
|
|
72
|
-
};
|
|
49
|
+
return addWebauthnCredential(WEBAUTHN_VALIDATOR_ADDRESS, pubKeyX, pubKeyY, requireUserVerification);
|
|
73
50
|
}
|
|
74
51
|
/**
|
|
75
52
|
* Remove a passkey owner
|
|
@@ -78,26 +55,7 @@ function addOwner(pubKeyX, pubKeyY, requireUserVerification) {
|
|
|
78
55
|
* @returns Call to remove the passkey owner
|
|
79
56
|
*/
|
|
80
57
|
function removeOwner(pubKeyX, pubKeyY) {
|
|
81
|
-
return
|
|
82
|
-
to: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
83
|
-
value: 0n,
|
|
84
|
-
data: encodeFunctionData({
|
|
85
|
-
abi: [
|
|
86
|
-
{
|
|
87
|
-
inputs: [
|
|
88
|
-
{ name: 'pubKeyX', type: 'uint256' },
|
|
89
|
-
{ name: 'pubKeyY', type: 'uint256' },
|
|
90
|
-
],
|
|
91
|
-
name: 'removeCredential',
|
|
92
|
-
outputs: [],
|
|
93
|
-
stateMutability: 'nonpayable',
|
|
94
|
-
type: 'function',
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
functionName: 'removeCredential',
|
|
98
|
-
args: [pubKeyX, pubKeyY],
|
|
99
|
-
}),
|
|
100
|
-
};
|
|
58
|
+
return removeWebauthnCredential(WEBAUTHN_VALIDATOR_ADDRESS, pubKeyX, pubKeyY);
|
|
101
59
|
}
|
|
102
60
|
/**
|
|
103
61
|
* Change an account's signer threshold (passkey)
|
|
@@ -105,24 +63,6 @@ function removeOwner(pubKeyX, pubKeyY) {
|
|
|
105
63
|
* @returns Call to change the threshold
|
|
106
64
|
*/
|
|
107
65
|
function changeThreshold(newThreshold) {
|
|
108
|
-
return
|
|
109
|
-
to: WEBAUTHN_VALIDATOR_ADDRESS,
|
|
110
|
-
value: 0n,
|
|
111
|
-
data: encodeFunctionData({
|
|
112
|
-
abi: [
|
|
113
|
-
{
|
|
114
|
-
inputs: [
|
|
115
|
-
{ internalType: 'uint256', name: '_threshold', type: 'uint256' },
|
|
116
|
-
],
|
|
117
|
-
name: 'setThreshold',
|
|
118
|
-
outputs: [],
|
|
119
|
-
stateMutability: 'nonpayable',
|
|
120
|
-
type: 'function',
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
functionName: 'setThreshold',
|
|
124
|
-
args: [BigInt(newThreshold)],
|
|
125
|
-
}),
|
|
126
|
-
};
|
|
66
|
+
return changeWebauthnThreshold(WEBAUTHN_VALIDATOR_ADDRESS, newThreshold);
|
|
127
67
|
}
|
|
128
68
|
export { addOwner, removeOwner, changeThreshold, disable, enable };
|
|
@@ -23,7 +23,10 @@ export interface RecoverPasskeyOwnershipOptions extends CallResolveContext {
|
|
|
23
23
|
* id, so their coordinates cannot be read back onchain.
|
|
24
24
|
*/
|
|
25
25
|
currentCredentials: readonly PasskeyCredential[];
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Target passkey owner set. If supplied, `module` must match the account's
|
|
28
|
+
* configured owner validator.
|
|
29
|
+
*/
|
|
27
30
|
newOwners: WebauthnValidatorConfig;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../../actions/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAgC,MAAM,MAAM,CAAA;AACjE,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,mBAAmB,CAAA;AA0B1B,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE;;;OAGG;IACH,SAAS,EAAE,sBAAsB,CAAA;CAClC;AAED,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;;;;;;;;OASG;IACH,kBAAkB,EAAE,SAAS,iBAAiB,EAAE,CAAA;IAChD
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../../actions/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAgC,MAAM,MAAM,CAAA;AACjE,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,mBAAmB,CAAA;AA0B1B,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE;;;OAGG;IACH,SAAS,EAAE,sBAAsB,CAAA;CAClC;AAED,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;;;;;;;;OASG;IACH,kBAAkB,EAAE,SAAS,iBAAiB,EAAE,CAAA;IAChD;;;OAGG;IACH,SAAS,EAAE,uBAAuB,CAAA;CACnC;AAED;;;;;;GAMG;AACH,iBAAS,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,SAAS,SAAI,GAAG,aAAa,CAUlE;AAED;;;;;;;;;;;GAWG;AACH,iBAAe,qBAAqB,CAClC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,aAAa,EAAE,CAAC,CA4D1B;AAED;;;;;;;;;;;GAWG;AACH,iBAAe,uBAAuB,CACpC,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,aAAa,EAAE,CAAC,CAwE1B;AAMD,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,CAAA"}
|
|
@@ -3,8 +3,8 @@ import { OWNABLE_VALIDATOR_ADDRESS } from '../modules/validators/ownable.js';
|
|
|
3
3
|
import { resolveSocialRecoveryValidator } from '../modules/validators/social-recovery.js';
|
|
4
4
|
import { parseWebauthnPublicKey, WEBAUTHN_VALIDATOR_ADDRESS, } from '../modules/validators/webauthn.js';
|
|
5
5
|
import { addOwnableOwner, changeOwnableThreshold, removeOwnableOwner, } from './ownable.js';
|
|
6
|
-
import { addOwner as addPasskeyOwner, changeThreshold as changePasskeyThreshold, removeOwner as removePasskeyOwner, } from './passkeys.js';
|
|
7
6
|
import { readOwnershipFor, readThresholdFor, resolveValidatorInstallation, } from './runtime.js';
|
|
7
|
+
import { addWebauthnCredential, changeWebauthnThreshold, removeWebauthnCredential, } from './webauthn.js';
|
|
8
8
|
/** Sentinel head of the validator's owner linked list. */
|
|
9
9
|
const SENTINEL_OWNER = '0x0000000000000000000000000000000000000001';
|
|
10
10
|
/**
|
|
@@ -90,7 +90,17 @@ async function recoverEcdsaOwnership(options) {
|
|
|
90
90
|
* @returns Calls to recover ownership, in the order they must be sent
|
|
91
91
|
*/
|
|
92
92
|
async function recoverPasskeyOwnership(options) {
|
|
93
|
-
const
|
|
93
|
+
const configuredValidator = options.config.owners?.type === 'passkey'
|
|
94
|
+
? (options.config.owners.module ?? WEBAUTHN_VALIDATOR_ADDRESS)
|
|
95
|
+
: undefined;
|
|
96
|
+
const requestedValidator = options.newOwners.module;
|
|
97
|
+
if (configuredValidator &&
|
|
98
|
+
requestedValidator &&
|
|
99
|
+
!isAddressEqual(configuredValidator, requestedValidator)) {
|
|
100
|
+
throw new Error('Recovery owner validator must match the configured owner validator');
|
|
101
|
+
}
|
|
102
|
+
const validator = configuredValidator ?? requestedValidator ?? WEBAUTHN_VALIDATOR_ADDRESS;
|
|
103
|
+
const existingThreshold = await readThresholdFor(options, options.accountAddress, validator);
|
|
94
104
|
const newCredentials = options.newOwners.accounts.map((account) => {
|
|
95
105
|
// Must go through the shared parser: uncompressed SEC1 keys are 65 bytes
|
|
96
106
|
// with an 0x04 prefix, and slicing from byte 0 shifts both coordinates.
|
|
@@ -108,13 +118,13 @@ async function recoverPasskeyOwnership(options) {
|
|
|
108
118
|
// `removeCredential` reverts once the count would reach the threshold.
|
|
109
119
|
// Rotating the sole credential of a 1-of-1 account is impossible otherwise.
|
|
110
120
|
for (const credential of credentialsToAdd) {
|
|
111
|
-
calls.push(
|
|
121
|
+
calls.push(addWebauthnCredential(validator, credential.pubKeyX, credential.pubKeyY, credential.requireUV));
|
|
112
122
|
}
|
|
113
123
|
if (existingThreshold !== newThreshold) {
|
|
114
|
-
calls.push(
|
|
124
|
+
calls.push(changeWebauthnThreshold(validator, newThreshold));
|
|
115
125
|
}
|
|
116
126
|
for (const credential of credentialsToRemove) {
|
|
117
|
-
calls.push(
|
|
127
|
+
calls.push(removeWebauthnCredential(validator, credential.pubKeyX, credential.pubKeyY));
|
|
118
128
|
}
|
|
119
129
|
return calls;
|
|
120
130
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import type { CalldataInput } from '../config/account.js';
|
|
3
|
+
export declare function addWebauthnCredential(validator: Address, pubKeyX: bigint, pubKeyY: bigint, requireUserVerification: boolean): CalldataInput;
|
|
4
|
+
export declare function removeWebauthnCredential(validator: Address, pubKeyX: bigint, pubKeyY: bigint): CalldataInput;
|
|
5
|
+
export declare function changeWebauthnThreshold(validator: Address, newThreshold: number): CalldataInput;
|
|
6
|
+
//# sourceMappingURL=webauthn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../../../actions/webauthn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAsB,MAAM,MAAM,CAAA;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,uBAAuB,EAAE,OAAO,GAC/B,aAAa,CAsBf;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,aAAa,CAqBf;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,MAAM,GACnB,aAAa,CAoBf"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { encodeFunctionData } from 'viem';
|
|
2
|
+
export function addWebauthnCredential(validator, pubKeyX, pubKeyY, requireUserVerification) {
|
|
3
|
+
return {
|
|
4
|
+
to: validator,
|
|
5
|
+
value: 0n,
|
|
6
|
+
data: encodeFunctionData({
|
|
7
|
+
abi: [
|
|
8
|
+
{
|
|
9
|
+
inputs: [
|
|
10
|
+
{ name: 'pubKeyX', type: 'uint256' },
|
|
11
|
+
{ name: 'pubKeyY', type: 'uint256' },
|
|
12
|
+
{ name: 'requireUserVerification', type: 'bool' },
|
|
13
|
+
],
|
|
14
|
+
name: 'addCredential',
|
|
15
|
+
outputs: [],
|
|
16
|
+
stateMutability: 'nonpayable',
|
|
17
|
+
type: 'function',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
functionName: 'addCredential',
|
|
21
|
+
args: [pubKeyX, pubKeyY, requireUserVerification],
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function removeWebauthnCredential(validator, pubKeyX, pubKeyY) {
|
|
26
|
+
return {
|
|
27
|
+
to: validator,
|
|
28
|
+
value: 0n,
|
|
29
|
+
data: encodeFunctionData({
|
|
30
|
+
abi: [
|
|
31
|
+
{
|
|
32
|
+
inputs: [
|
|
33
|
+
{ name: 'pubKeyX', type: 'uint256' },
|
|
34
|
+
{ name: 'pubKeyY', type: 'uint256' },
|
|
35
|
+
],
|
|
36
|
+
name: 'removeCredential',
|
|
37
|
+
outputs: [],
|
|
38
|
+
stateMutability: 'nonpayable',
|
|
39
|
+
type: 'function',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
functionName: 'removeCredential',
|
|
43
|
+
args: [pubKeyX, pubKeyY],
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function changeWebauthnThreshold(validator, newThreshold) {
|
|
48
|
+
return {
|
|
49
|
+
to: validator,
|
|
50
|
+
value: 0n,
|
|
51
|
+
data: encodeFunctionData({
|
|
52
|
+
abi: [
|
|
53
|
+
{
|
|
54
|
+
inputs: [
|
|
55
|
+
{ internalType: 'uint256', name: '_threshold', type: 'uint256' },
|
|
56
|
+
],
|
|
57
|
+
name: 'setThreshold',
|
|
58
|
+
outputs: [],
|
|
59
|
+
stateMutability: 'nonpayable',
|
|
60
|
+
type: 'function',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
functionName: 'setThreshold',
|
|
64
|
+
args: [BigInt(newThreshold)],
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -3,7 +3,7 @@ import { createOrchestratorAuth } from './auth.js';
|
|
|
3
3
|
import { ChainCatalog, parseChains } from './chain-catalog.js';
|
|
4
4
|
import { fetchOrchestratorJson } from './fetch.js';
|
|
5
5
|
import { mapIntentRequestToWire, mapIntentStatusFromWire, mapPortfolioFromWire, mapQuoteResponseFromWire, mapSignedIntentToWire, mapSplitRequestToWire, mapSplitResultFromWire, } from './mappers.js';
|
|
6
|
-
const SDK_VERSION = '0.0.0-dev-
|
|
6
|
+
const SDK_VERSION = '0.0.0-dev-20260728220029';
|
|
7
7
|
const API_VERSION = '2026-04.blanc';
|
|
8
8
|
export function createOrchestratorClient(options) {
|
|
9
9
|
const fetchPort = options.fetch ?? globalThis.fetch;
|