@charterlabs/rhinestone-sdk 0.3.9 → 0.4.2
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/README.md +89 -1
- package/dist/src/accounts/index.d.ts +6 -3
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +8 -2
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +3 -3
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +4 -1
- package/dist/src/accounts/signing/common.d.ts +10 -5
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +21 -7
- package/dist/src/accounts/signing/message.d.ts +3 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/mfa-webauthn.d.ts +30 -0
- package/dist/src/accounts/signing/mfa-webauthn.d.ts.map +1 -0
- package/dist/src/accounts/signing/mfa-webauthn.js +119 -0
- package/dist/src/accounts/startale.js +1 -1
- package/dist/src/accounts/utils.d.ts +1 -1
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/actions/mfa.d.ts +6 -2
- package/dist/src/actions/mfa.d.ts.map +1 -1
- package/dist/src/actions/mfa.js +14 -4
- package/dist/src/auth/provider.d.ts +7 -0
- package/dist/src/auth/provider.d.ts.map +1 -0
- package/dist/src/auth/provider.js +41 -0
- package/dist/src/errors/index.d.ts +2 -2
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +2 -1
- package/dist/src/execution/error.d.ts +9 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +12 -1
- package/dist/src/execution/index.d.ts +6 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +17 -13
- package/dist/src/execution/utils.d.ts +17 -6
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +193 -43
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +13 -11
- package/dist/src/jwt-server/digest.d.ts +11 -0
- package/dist/src/jwt-server/digest.d.ts.map +1 -0
- package/dist/src/jwt-server/digest.js +22 -0
- package/dist/src/jwt-server/express.d.ts +16 -0
- package/dist/src/jwt-server/express.d.ts.map +1 -0
- package/dist/src/jwt-server/express.js +24 -0
- package/dist/src/jwt-server/handlers.d.ts +10 -0
- package/dist/src/jwt-server/handlers.d.ts.map +1 -0
- package/dist/src/jwt-server/handlers.js +41 -0
- package/dist/src/jwt-server/index.d.ts +8 -0
- package/dist/src/jwt-server/index.d.ts.map +1 -0
- package/dist/src/jwt-server/index.js +18 -0
- package/dist/src/jwt-server/jcs.d.ts +12 -0
- package/dist/src/jwt-server/jcs.d.ts.map +1 -0
- package/dist/src/jwt-server/jcs.js +60 -0
- package/dist/src/jwt-server/signer.d.ts +18 -0
- package/dist/src/jwt-server/signer.d.ts.map +1 -0
- package/dist/src/jwt-server/signer.js +71 -0
- package/dist/src/jwt-server/sponsorship.d.ts +19 -0
- package/dist/src/jwt-server/sponsorship.d.ts.map +1 -0
- package/dist/src/jwt-server/sponsorship.js +56 -0
- package/dist/src/jwt-server/web.d.ts +4 -0
- package/dist/src/jwt-server/web.d.ts.map +1 -0
- package/dist/src/jwt-server/web.js +27 -0
- package/dist/src/modules/validators/core.d.ts +6 -2
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +46 -21
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.d.ts.map +1 -1
- package/dist/src/modules/validators/index.js +5 -1
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +55 -0
- package/dist/src/modules/validators/policies/claim/permit2.d.ts.map +1 -0
- package/dist/src/modules/validators/policies/claim/permit2.js +239 -0
- package/dist/src/modules/validators/policies/claim/types.d.ts +12 -0
- package/dist/src/modules/validators/policies/claim/types.d.ts.map +1 -0
- package/dist/src/modules/validators/policies/claim/types.js +18 -0
- package/dist/src/modules/validators/smart-sessions.d.ts +22 -7
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +82 -22
- package/dist/src/orchestrator/client.d.ts +9 -4
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +29 -17
- package/dist/src/orchestrator/consts.d.ts +3 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -2
- package/dist/src/orchestrator/index.d.ts +4 -3
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +2 -2
- package/dist/src/orchestrator/registry.d.ts +2 -1
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +17 -1
- package/dist/src/orchestrator/types.d.ts +6 -1
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +88 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +3 -9
- package/dist/src/utils/index.d.ts.map +1 -1
- package/package.json +18 -4
- package/dist/src/accounts/index.test.d.ts +0 -2
- package/dist/src/accounts/index.test.d.ts.map +0 -1
- package/dist/src/accounts/index.test.js +0 -33
- package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/index.test.js +0 -35
- package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/providers.test.js +0 -43
- package/dist/src/accounts/kernel.test.d.ts +0 -2
- package/dist/src/accounts/kernel.test.d.ts.map +0 -1
- package/dist/src/accounts/kernel.test.js +0 -132
- package/dist/src/accounts/nexus.test.d.ts +0 -2
- package/dist/src/accounts/nexus.test.d.ts.map +0 -1
- package/dist/src/accounts/nexus.test.js +0 -118
- package/dist/src/accounts/safe.test.d.ts +0 -2
- package/dist/src/accounts/safe.test.d.ts.map +0 -1
- package/dist/src/accounts/safe.test.js +0 -118
- package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
- package/dist/src/accounts/signing/passkeys.test.js +0 -88
- package/dist/src/accounts/startale.test.d.ts +0 -2
- package/dist/src/accounts/startale.test.d.ts.map +0 -1
- package/dist/src/accounts/startale.test.js +0 -189
- package/dist/src/accounts/utils.test.d.ts +0 -2
- package/dist/src/accounts/utils.test.d.ts.map +0 -1
- package/dist/src/accounts/utils.test.js +0 -49
- package/dist/src/actions/ecdsa.test.d.ts +0 -2
- package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
- package/dist/src/actions/ecdsa.test.js +0 -99
- package/dist/src/actions/passkeys.test.d.ts +0 -2
- package/dist/src/actions/passkeys.test.d.ts.map +0 -1
- package/dist/src/actions/passkeys.test.js +0 -54
- package/dist/src/actions/recovery.test.d.ts +0 -2
- package/dist/src/actions/recovery.test.d.ts.map +0 -1
- package/dist/src/actions/recovery.test.js +0 -168
- package/dist/src/execution/utils.test.d.ts +0 -2
- package/dist/src/execution/utils.test.d.ts.map +0 -1
- package/dist/src/execution/utils.test.js +0 -150
- package/dist/src/modules/index.test.d.ts +0 -2
- package/dist/src/modules/index.test.d.ts.map +0 -1
- package/dist/src/modules/index.test.js +0 -81
- package/dist/src/modules/validators/core.test.d.ts +0 -2
- package/dist/src/modules/validators/core.test.d.ts.map +0 -1
- package/dist/src/modules/validators/core.test.js +0 -101
- package/dist/src/modules/validators/smart-sessions.test.d.ts +0 -2
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +0 -1
- package/dist/src/modules/validators/smart-sessions.test.js +0 -61
- package/dist/src/orchestrator/registry.test.d.ts +0 -2
- package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.test.js +0 -154
- package/dist/test/consts.d.ts +0 -10
- package/dist/test/consts.d.ts.map +0 -1
- package/dist/test/consts.js +0 -22
- package/dist/test/utils/utils.d.ts +0 -5
- package/dist/test/utils/utils.d.ts.map +0 -1
- package/dist/test/utils/utils.js +0 -20
|
@@ -21,32 +21,67 @@ exports.resolveCallInputs = resolveCallInputs;
|
|
|
21
21
|
exports.getIntentAccount = getIntentAccount;
|
|
22
22
|
exports.getTargetExecutionSignature = getTargetExecutionSignature;
|
|
23
23
|
exports.hashErc7739TypedDataForSolady = hashErc7739TypedDataForSolady;
|
|
24
|
+
exports.resolveSessionForChain = resolveSessionForChain;
|
|
24
25
|
const viem_1 = require("viem");
|
|
25
26
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
26
27
|
const erc7739_1 = require("viem/experimental/erc7739");
|
|
27
28
|
const accounts_1 = require("../accounts");
|
|
29
|
+
const common_1 = require("../accounts/signing/common");
|
|
28
30
|
const startale_1 = require("../accounts/startale");
|
|
29
31
|
const utils_1 = require("../accounts/utils");
|
|
32
|
+
const provider_1 = require("../auth/provider");
|
|
30
33
|
const modules_1 = require("../modules");
|
|
31
34
|
const validators_1 = require("../modules/validators");
|
|
32
35
|
const core_1 = require("../modules/validators/core");
|
|
36
|
+
const permit2_1 = require("../modules/validators/policies/claim/permit2");
|
|
33
37
|
const orchestrator_1 = require("../orchestrator");
|
|
34
38
|
const registry_1 = require("../orchestrator/registry");
|
|
35
39
|
const types_1 = require("../orchestrator/types");
|
|
40
|
+
const utils_2 = require("../orchestrator/utils");
|
|
36
41
|
const compact_1 = require("./compact");
|
|
37
42
|
const error_1 = require("./error");
|
|
38
|
-
const
|
|
43
|
+
const permit2_2 = require("./permit2");
|
|
39
44
|
const singleChainOps_1 = require("./singleChainOps");
|
|
45
|
+
function isResolvedSessionSignerSet(signers) {
|
|
46
|
+
return (signers?.type === 'experimental_session' && 'verifyExecutions' in signers);
|
|
47
|
+
}
|
|
48
|
+
async function resolveSignersForChain(config, signers, chainId) {
|
|
49
|
+
if (signers?.type !== 'experimental_session') {
|
|
50
|
+
return signers;
|
|
51
|
+
}
|
|
52
|
+
const resolved = resolveSessionForChain(signers, chainId);
|
|
53
|
+
const enabled = await (0, validators_1.isSessionEnabled)((0, accounts_1.getAddress)(config), config.provider, resolved.session, config.useDevContracts);
|
|
54
|
+
const enableData = enabled ? undefined : resolved.enableData;
|
|
55
|
+
const hasExplicitActions = !!resolved.session.actions?.length;
|
|
56
|
+
const verifyExecutions = resolved.verifyExecutions ?? signers.verifyExecutions ?? hasExplicitActions;
|
|
57
|
+
return {
|
|
58
|
+
type: 'experimental_session',
|
|
59
|
+
session: resolved.session,
|
|
60
|
+
enableData,
|
|
61
|
+
verifyExecutions,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function resolveSessionForChain(signers, chainId) {
|
|
65
|
+
if ('sessions' in signers) {
|
|
66
|
+
const config = signers.sessions[chainId];
|
|
67
|
+
if (!config) {
|
|
68
|
+
throw new Error(`No session configured for chain ${chainId}`);
|
|
69
|
+
}
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
return { session: signers.session, enableData: signers.enableData };
|
|
73
|
+
}
|
|
40
74
|
async function prepareTransaction(config, transaction) {
|
|
41
|
-
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, auxiliaryFunds, account, recipient, } = getTransactionParams(transaction);
|
|
75
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, auxiliaryFunds, account, recipient, sourceCalls, } = getTransactionParams(transaction);
|
|
42
76
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
43
77
|
const isUserOpSigner = signers?.type === 'guardians';
|
|
44
78
|
if (isUserOpSigner) {
|
|
45
79
|
throw new error_1.SignerNotSupportedError();
|
|
46
80
|
}
|
|
47
|
-
const
|
|
81
|
+
const prepared = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, auxiliaryFunds, account, signers, sourceCalls);
|
|
48
82
|
return {
|
|
49
|
-
intentRoute,
|
|
83
|
+
intentRoute: prepared.intentRoute,
|
|
84
|
+
intentInput: prepared.intentInput,
|
|
50
85
|
transaction,
|
|
51
86
|
};
|
|
52
87
|
}
|
|
@@ -95,6 +130,7 @@ async function signTransaction(config, preparedTransaction) {
|
|
|
95
130
|
const targetExecutionSignature = await getTargetExecutionSignature(config, intentRoute.intentOp, targetChain, signers);
|
|
96
131
|
return {
|
|
97
132
|
intentRoute,
|
|
133
|
+
intentInput: preparedTransaction.intentInput,
|
|
98
134
|
transaction: preparedTransaction.transaction,
|
|
99
135
|
originSignatures,
|
|
100
136
|
destinationSignature,
|
|
@@ -105,6 +141,16 @@ async function getTargetExecutionSignature(config, intentOp, targetChain, signer
|
|
|
105
141
|
if (signers?.type !== 'experimental_session') {
|
|
106
142
|
return undefined;
|
|
107
143
|
}
|
|
144
|
+
const settlementLayers = intentOp.elements.map((e) => e.mandate.qualifier.settlementContext.settlementLayer);
|
|
145
|
+
const hasIntentExecutorOps = settlementLayers.some((l) => l === 'INTENT_EXECUTOR' || l === 'SAME_CHAIN');
|
|
146
|
+
if (!hasIntentExecutorOps) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const resolvedSigners = await resolveSignersForChain(config, signers, targetChain.id);
|
|
150
|
+
if (!isResolvedSessionSignerSet(resolvedSigners) ||
|
|
151
|
+
!resolvedSigners.verifyExecutions) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
108
154
|
const destination = getTargetExecutionMessage(config, intentOp);
|
|
109
155
|
const validator = getValidator(config, signers);
|
|
110
156
|
if (!validator) {
|
|
@@ -112,7 +158,7 @@ async function getTargetExecutionSignature(config, intentOp, targetChain, signer
|
|
|
112
158
|
}
|
|
113
159
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
114
160
|
const isRoot = validator.address === ownerValidator.address;
|
|
115
|
-
const signature = await getDestinationSignature(config,
|
|
161
|
+
const signature = await getDestinationSignature(config, resolvedSigners, validator, isRoot, targetChain, destination, [], true);
|
|
116
162
|
return signature;
|
|
117
163
|
}
|
|
118
164
|
async function signUserOperation(config, preparedUserOperation) {
|
|
@@ -153,10 +199,23 @@ async function signTypedData(config, parameters, chain, signers, options) {
|
|
|
153
199
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
154
200
|
const isRoot = validator.address === ownerValidator.address;
|
|
155
201
|
if (signers?.type === 'experimental_session') {
|
|
202
|
+
const resolved = resolveSessionForChain(signers, chain.id);
|
|
156
203
|
return await signTypedDataWithSession(config, chain, {
|
|
157
204
|
address: validator.address,
|
|
158
205
|
isRoot,
|
|
159
|
-
},
|
|
206
|
+
}, resolved.session, parameters);
|
|
207
|
+
}
|
|
208
|
+
const account = (0, accounts_1.getAccountProvider)(config);
|
|
209
|
+
if (account.type === 'startale' && (0, core_1.supportsEip712)(validator)) {
|
|
210
|
+
const isK1 = validator.address.toLowerCase() ===
|
|
211
|
+
startale_1.K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
212
|
+
if (isK1) {
|
|
213
|
+
const sig = await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
|
|
214
|
+
if (!options?.skipErc6492) {
|
|
215
|
+
return await (0, accounts_1.toErc6492Signature)(config, sig, chain);
|
|
216
|
+
}
|
|
217
|
+
return sig;
|
|
218
|
+
}
|
|
160
219
|
}
|
|
161
220
|
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
|
|
162
221
|
address: validator.address,
|
|
@@ -167,8 +226,9 @@ async function signTypedData(config, parameters, chain, signers, options) {
|
|
|
167
226
|
}
|
|
168
227
|
return signature;
|
|
169
228
|
}
|
|
170
|
-
async function signTypedDataWithSession(config, chain, validator,
|
|
229
|
+
async function signTypedDataWithSession(config, chain, validator, session, parameters) {
|
|
171
230
|
const { name, version, chainId, verifyingContract, salt } = (0, accounts_1.getEip712Domain)(config, chain);
|
|
231
|
+
const signers = (0, common_1.convertOwnerSetToSignerSet)(session.owners);
|
|
172
232
|
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, validator, {
|
|
173
233
|
domain: parameters.domain,
|
|
174
234
|
primaryType: 'TypedDataSign',
|
|
@@ -199,7 +259,7 @@ async function signTypedDataWithSession(config, chain, validator, signers, param
|
|
|
199
259
|
message: parameters.message,
|
|
200
260
|
signature,
|
|
201
261
|
});
|
|
202
|
-
return (0, viem_1.encodePacked)(['bytes32', 'bytes'], [(0, validators_1.getPermissionId)(
|
|
262
|
+
return (0, viem_1.encodePacked)(['bytes32', 'bytes'], [(0, validators_1.getPermissionId)(session), erc7739Signature]);
|
|
203
263
|
});
|
|
204
264
|
return await (0, accounts_1.toErc6492Signature)(config, signature, chain);
|
|
205
265
|
}
|
|
@@ -240,10 +300,10 @@ async function signAuthorizationsInternal(config, data) {
|
|
|
240
300
|
return authorizations;
|
|
241
301
|
}
|
|
242
302
|
async function submitTransaction(config, signedTransaction, authorizations, dryRun = false) {
|
|
243
|
-
const { intentRoute, transaction, originSignatures, destinationSignature, targetExecutionSignature, } = signedTransaction;
|
|
303
|
+
const { intentRoute, intentInput, transaction, originSignatures, destinationSignature, targetExecutionSignature, } = signedTransaction;
|
|
244
304
|
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
245
305
|
const intentOp = intentRoute.intentOp;
|
|
246
|
-
return await submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun);
|
|
306
|
+
return await submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput);
|
|
247
307
|
}
|
|
248
308
|
async function submitUserOperation(config, signedUserOperation) {
|
|
249
309
|
const chain = signedUserOperation.transaction.chain;
|
|
@@ -267,6 +327,7 @@ function getTransactionParams(transaction) {
|
|
|
267
327
|
const auxiliaryFunds = transaction.auxiliaryFunds;
|
|
268
328
|
const account = transaction.experimental_accountOverride;
|
|
269
329
|
const recipient = transaction.recipient;
|
|
330
|
+
const sourceCalls = transaction.sourceCalls;
|
|
270
331
|
const tokenRequests = getTokenRequests(targetChain, initialTokenRequests);
|
|
271
332
|
return {
|
|
272
333
|
sourceChains,
|
|
@@ -283,6 +344,7 @@ function getTransactionParams(transaction) {
|
|
|
283
344
|
auxiliaryFunds,
|
|
284
345
|
account,
|
|
285
346
|
recipient,
|
|
347
|
+
sourceCalls,
|
|
286
348
|
};
|
|
287
349
|
}
|
|
288
350
|
function getTokenRequests(targetChain, initialTokenRequests) {
|
|
@@ -336,7 +398,7 @@ function getIntentAccount(config, eip7702InitSignature, account) {
|
|
|
336
398
|
delegations,
|
|
337
399
|
};
|
|
338
400
|
}
|
|
339
|
-
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, auxiliaryFunds, account, signers) {
|
|
401
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, auxiliaryFunds, account, signers, sourceCalls) {
|
|
340
402
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
341
403
|
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
342
404
|
function getRecipient(recipient) {
|
|
@@ -357,13 +419,76 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
357
419
|
const intentAccount = {
|
|
358
420
|
...getIntentAccount(config, eip7702InitSignature, account),
|
|
359
421
|
...(signers?.type === 'experimental_session' && {
|
|
360
|
-
|
|
422
|
+
// Global fallback: target-chain sig for backward-compat with older orchestrators
|
|
423
|
+
mockSignature: (0, validators_1.buildMockSignature)(resolveSessionForChain(signers, targetChain.id).session, config.useDevContracts, sourceChains?.length ?? 1),
|
|
424
|
+
// Per-chain map: enables accurate per-chain session validation gas simulation
|
|
425
|
+
mockSignatures: Object.fromEntries([
|
|
426
|
+
...new Set([
|
|
427
|
+
...(sourceChains ?? []).map((c) => c.id),
|
|
428
|
+
targetChain.id,
|
|
429
|
+
]),
|
|
430
|
+
].map((chainId) => [
|
|
431
|
+
String(chainId),
|
|
432
|
+
(0, validators_1.buildMockSignature)(resolveSessionForChain(signers, chainId).session, config.useDevContracts, sourceChains?.length ?? 1, chainId),
|
|
433
|
+
])),
|
|
361
434
|
}),
|
|
362
435
|
};
|
|
363
436
|
const recipient = getRecipient(recipientInput);
|
|
364
437
|
const signatureMode = signers?.type === 'experimental_session'
|
|
365
438
|
? types_1.SIG_MODE_EMISSARY_EXECUTION_ERC1271
|
|
366
439
|
: types_1.SIG_MODE_ERC1271_EMISSARY;
|
|
440
|
+
// For session signers that need enabling, pass a dummy preclaimop per source chain
|
|
441
|
+
// so the orchestrator bakes it into the bundle before computing its HMAC. The filler
|
|
442
|
+
// executes the op via verifyExecution in ENABLE mode, enabling the session on-chain
|
|
443
|
+
// without a separate UserOp. Must be sent in the routing request — not injected
|
|
444
|
+
// post-facto — because the orchestrator HMAC covers preClaimOps.
|
|
445
|
+
const preClaimExecutions = {};
|
|
446
|
+
if (signers?.type === 'experimental_session' && sourceChains) {
|
|
447
|
+
const resolvedPerChain = await Promise.all(sourceChains.map(async (chain) => ({
|
|
448
|
+
chainId: chain.id,
|
|
449
|
+
resolved: await resolveSignersForChain(config, signers, chain.id),
|
|
450
|
+
})));
|
|
451
|
+
for (const { chainId, resolved } of resolvedPerChain) {
|
|
452
|
+
if (!isResolvedSessionSignerSet(resolved))
|
|
453
|
+
continue;
|
|
454
|
+
const { enableData, verifyExecutions } = resolved;
|
|
455
|
+
if (!verifyExecutions || !enableData)
|
|
456
|
+
continue;
|
|
457
|
+
preClaimExecutions[chainId] = [
|
|
458
|
+
{
|
|
459
|
+
to: validators_1.DUMMY_PRECLAIMOP_TARGET,
|
|
460
|
+
value: 0n,
|
|
461
|
+
data: validators_1.DUMMY_PRECLAIMOP_SELECTOR,
|
|
462
|
+
},
|
|
463
|
+
];
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (sourceCalls) {
|
|
467
|
+
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
468
|
+
const allowedChainIds = new Set([
|
|
469
|
+
...(sourceChains ?? []).map((c) => c.id),
|
|
470
|
+
targetChain.id,
|
|
471
|
+
]);
|
|
472
|
+
for (const [chainIdStr, calls] of Object.entries(sourceCalls)) {
|
|
473
|
+
const chainId = Number(chainIdStr);
|
|
474
|
+
if (!allowedChainIds.has(chainId)) {
|
|
475
|
+
throw new error_1.InvalidSourceCallsError({ chainId });
|
|
476
|
+
}
|
|
477
|
+
const chain = sourceChains?.find((c) => c.id === chainId) ??
|
|
478
|
+
(targetChain.id === chainId ? targetChain : undefined);
|
|
479
|
+
if (!chain) {
|
|
480
|
+
throw new error_1.InvalidSourceCallsError({ chainId });
|
|
481
|
+
}
|
|
482
|
+
const resolved = await resolveCallInputs(calls, config, chain, accountAddress);
|
|
483
|
+
const userExecutions = parseCalls(resolved, chainId);
|
|
484
|
+
if (userExecutions.length === 0)
|
|
485
|
+
continue;
|
|
486
|
+
preClaimExecutions[chainId] = [
|
|
487
|
+
...(preClaimExecutions[chainId] ?? []),
|
|
488
|
+
...userExecutions,
|
|
489
|
+
];
|
|
490
|
+
}
|
|
491
|
+
}
|
|
367
492
|
const metaIntent = {
|
|
368
493
|
destinationChainId: targetChain.id,
|
|
369
494
|
tokenRequests: tokenRequests.map((tokenRequest) => ({
|
|
@@ -395,10 +520,12 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
395
520
|
signatureMode,
|
|
396
521
|
auxiliaryFunds,
|
|
397
522
|
},
|
|
523
|
+
...(Object.keys(preClaimExecutions).length > 0 && { preClaimExecutions }),
|
|
398
524
|
};
|
|
399
|
-
const
|
|
525
|
+
const serializedIntent = (0, utils_2.convertBigIntFields)(metaIntent);
|
|
526
|
+
const orchestrator = (0, orchestrator_1.getOrchestrator)(config._authProvider ?? (0, provider_1.createAuthProvider)(config), config.endpointUrl, config.headers);
|
|
400
527
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
401
|
-
return intentRoute;
|
|
528
|
+
return { intentRoute, intentInput: serializedIntent };
|
|
402
529
|
}
|
|
403
530
|
async function signIntent(config, intentOp, targetChain, signers, targetExecution) {
|
|
404
531
|
const { origin, destination } = getIntentMessages(config, intentOp);
|
|
@@ -432,23 +559,12 @@ async function signIntent(config, intentOp, targetChain, signers, targetExecutio
|
|
|
432
559
|
const originSignatures = [];
|
|
433
560
|
for (const typedData of origin) {
|
|
434
561
|
const chain = (0, registry_1.getChainById)(typedData.domain?.chainId);
|
|
435
|
-
|
|
436
|
-
// Specifically, we need to remove the enable data in this case
|
|
437
|
-
const matchesTargetChain = chain.id === targetChain.id;
|
|
438
|
-
const originSigners = signers?.type === 'experimental_session'
|
|
439
|
-
? {
|
|
440
|
-
type: 'experimental_session',
|
|
441
|
-
session: signers.session,
|
|
442
|
-
verifyExecutions: matchesTargetChain
|
|
443
|
-
? signers.verifyExecutions
|
|
444
|
-
: undefined,
|
|
445
|
-
enableData: matchesTargetChain ? signers.enableData : undefined,
|
|
446
|
-
}
|
|
447
|
-
: signers;
|
|
562
|
+
const originSigners = await resolveSignersForChain(config, signers, chain.id);
|
|
448
563
|
const signature = await signIntentTypedData(config, originSigners, validator, isRoot, typedData, chain, targetExecution ?? false);
|
|
449
564
|
originSignatures.push(signature);
|
|
450
565
|
}
|
|
451
|
-
const
|
|
566
|
+
const destinationSigners = await resolveSignersForChain(config, signers, targetChain.id);
|
|
567
|
+
const destinationSignature = await getDestinationSignature(config, destinationSigners, validator, isRoot, targetChain, destination, originSignatures, targetExecution ?? false);
|
|
452
568
|
return {
|
|
453
569
|
originSignatures,
|
|
454
570
|
destinationSignature,
|
|
@@ -493,7 +609,7 @@ function getIntentMessages(config, intentOp) {
|
|
|
493
609
|
origin.push(typedData);
|
|
494
610
|
}
|
|
495
611
|
else if (withPermit2) {
|
|
496
|
-
const typedData = (0,
|
|
612
|
+
const typedData = (0, permit2_2.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
497
613
|
origin.push(typedData);
|
|
498
614
|
}
|
|
499
615
|
else {
|
|
@@ -519,12 +635,28 @@ function getTargetExecutionMessage(config, intentOp) {
|
|
|
519
635
|
};
|
|
520
636
|
return typedData;
|
|
521
637
|
}
|
|
638
|
+
/** Computes claim policy calldata when parameters are Permit2 typed data with claim policies. */
|
|
639
|
+
function resolveClaimPolicyData(signers, parameters) {
|
|
640
|
+
if (parameters.primaryType !== 'PermitBatchWitnessTransferFrom' ||
|
|
641
|
+
!signers.session.claimPolicies?.length) {
|
|
642
|
+
return undefined;
|
|
643
|
+
}
|
|
644
|
+
const msg = parameters.message;
|
|
645
|
+
if (!msg.permitted ||
|
|
646
|
+
!msg.mandate ||
|
|
647
|
+
typeof msg.spender !== 'string' ||
|
|
648
|
+
typeof msg.nonce !== 'bigint' ||
|
|
649
|
+
typeof msg.deadline !== 'bigint') {
|
|
650
|
+
return undefined;
|
|
651
|
+
}
|
|
652
|
+
return (0, permit2_1.buildPermit2ClaimPolicyCalldata)(signers.session.claimPolicies[0], parameters.message);
|
|
653
|
+
}
|
|
522
654
|
async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain, targetExecution) {
|
|
523
655
|
if ((0, core_1.supportsEip712)(validator)) {
|
|
524
656
|
const isK1Validator = validator.address.toLowerCase() ===
|
|
525
657
|
startale_1.K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
526
658
|
if (isK1Validator) {
|
|
527
|
-
return await
|
|
659
|
+
return await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
|
|
528
660
|
}
|
|
529
661
|
return await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
|
|
530
662
|
address: validator.address,
|
|
@@ -532,20 +664,27 @@ async function signIntentTypedData(config, signers, validator, isRoot, parameter
|
|
|
532
664
|
}, parameters);
|
|
533
665
|
}
|
|
534
666
|
const hash = (0, viem_1.hashTypedData)(parameters);
|
|
535
|
-
if (signers
|
|
667
|
+
if (isResolvedSessionSignerSet(signers) && signers.verifyExecutions) {
|
|
536
668
|
if (targetExecution) {
|
|
537
|
-
|
|
669
|
+
const targetSigners = {
|
|
538
670
|
type: 'experimental_session',
|
|
539
671
|
session: signers.session,
|
|
540
672
|
verifyExecutions: true,
|
|
541
|
-
|
|
673
|
+
enableData: signers.enableData,
|
|
674
|
+
};
|
|
675
|
+
// signWithSession (called inside getEmissarySignature) already calls packSignature
|
|
676
|
+
// internally, so no transform is needed here
|
|
677
|
+
return await (0, accounts_1.getEmissarySignature)(config, targetSigners, chain, hash);
|
|
542
678
|
}
|
|
543
|
-
const
|
|
679
|
+
const claimPolicyData = resolveClaimPolicyData(signers, parameters);
|
|
680
|
+
const sessionSignersForEip1271 = {
|
|
544
681
|
type: 'experimental_session',
|
|
545
682
|
session: signers.session,
|
|
546
683
|
verifyExecutions: false,
|
|
547
684
|
enableData: signers.enableData,
|
|
548
|
-
|
|
685
|
+
claimPolicyData,
|
|
686
|
+
};
|
|
687
|
+
const eip1271Signature = await (0, accounts_1.getEip1271Signature)(config, sessionSignersForEip1271, chain, {
|
|
549
688
|
address: validator.address,
|
|
550
689
|
isRoot,
|
|
551
690
|
}, hash);
|
|
@@ -560,6 +699,13 @@ async function signIntentTypedData(config, signers, validator, isRoot, parameter
|
|
|
560
699
|
notarizedClaimSig: eip1271Signature,
|
|
561
700
|
};
|
|
562
701
|
}
|
|
702
|
+
if (isResolvedSessionSignerSet(signers)) {
|
|
703
|
+
const claimPolicyData = resolveClaimPolicyData(signers, parameters);
|
|
704
|
+
return await (0, accounts_1.getEip1271Signature)(config, claimPolicyData !== undefined ? { ...signers, claimPolicyData } : signers, chain, {
|
|
705
|
+
address: validator.address,
|
|
706
|
+
isRoot,
|
|
707
|
+
}, hash);
|
|
708
|
+
}
|
|
563
709
|
return await (0, accounts_1.getEip1271Signature)(config, signers, chain, {
|
|
564
710
|
address: validator.address,
|
|
565
711
|
isRoot,
|
|
@@ -619,8 +765,8 @@ async function submitUserOp(config, chain, userOp, signature) {
|
|
|
619
765
|
chain: chain.id,
|
|
620
766
|
};
|
|
621
767
|
}
|
|
622
|
-
async function submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun) {
|
|
623
|
-
return submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun);
|
|
768
|
+
async function submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput) {
|
|
769
|
+
return submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput);
|
|
624
770
|
}
|
|
625
771
|
function createSignedIntentOp(intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations) {
|
|
626
772
|
return {
|
|
@@ -640,13 +786,17 @@ function createSignedIntentOp(intentOp, originSignatures, destinationSignature,
|
|
|
640
786
|
: undefined,
|
|
641
787
|
};
|
|
642
788
|
}
|
|
643
|
-
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun) {
|
|
789
|
+
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput) {
|
|
644
790
|
const signedIntentOp = createSignedIntentOp(intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations);
|
|
645
|
-
const
|
|
646
|
-
const
|
|
791
|
+
const isSponsored = !!intentInput?.options?.sponsorSettings;
|
|
792
|
+
const orchestrator = (0, orchestrator_1.getOrchestrator)(config._authProvider ?? (0, provider_1.createAuthProvider)(config), config.endpointUrl, config.headers);
|
|
793
|
+
const intentResults = await orchestrator.submitIntent(signedIntentOp, dryRun, intentInput ? { intentInput, isSponsored } : undefined);
|
|
794
|
+
// Some settlement paths (e.g. SAME_CHAIN) may not return a result.id — fall
|
|
795
|
+
// back to the nonce which the orchestrator also accepts as an intent identifier.
|
|
796
|
+
const intentId = intentResults.result.id ?? intentOp.nonce;
|
|
647
797
|
return {
|
|
648
798
|
type: 'intent',
|
|
649
|
-
id: BigInt(
|
|
799
|
+
id: BigInt(intentId),
|
|
650
800
|
sourceChains: sourceChains?.map((chain) => chain.id),
|
|
651
801
|
targetChain: targetChain.id,
|
|
652
802
|
};
|
|
@@ -807,10 +957,10 @@ function validateTokenSymbols(chain, tokenAddressOrSymbols) {
|
|
|
807
957
|
}
|
|
808
958
|
}
|
|
809
959
|
}
|
|
810
|
-
// Signs
|
|
960
|
+
// Signs typed data using ERC-7739 nested EIP-712 for Startale accounts.
|
|
811
961
|
// Uses a Solady-compatible TypedDataSign hash and wraps the signature with
|
|
812
962
|
// the app domain separator and contents hash for on-chain verification.
|
|
813
|
-
async function
|
|
963
|
+
async function signErc7739TypedData(config, signers, validator, isRoot, parameters, chain) {
|
|
814
964
|
const verifierDomain = (0, accounts_1.getEip712Domain)(config, chain);
|
|
815
965
|
const hash = hashErc7739TypedDataForSolady({
|
|
816
966
|
domain: parameters.domain,
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, Chain, HashTypedDataParameters, Hex, SignableMessage, SignedAuthorizationList, TypedData, TypedDataDefinition
|
|
1
|
+
import type { Account, Address, Chain, HashTypedDataParameters, Hex, SignableMessage, SignedAuthorizationList, TypedData, TypedDataDefinition } from 'viem';
|
|
2
2
|
import type { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
3
|
import { deployStandaloneWithEoa as deployStandaloneWithEoaInternal } from './accounts';
|
|
4
4
|
import { walletClientToAccount, wrapParaAccount } from './accounts/walletClient';
|
|
@@ -9,7 +9,7 @@ import { type IntentRoute, type PreparedTransactionData, type PreparedUserOperat
|
|
|
9
9
|
import { MULTI_FACTOR_VALIDATOR_ADDRESS, OWNABLE_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS } from './modules';
|
|
10
10
|
import { type SessionDetails } from './modules/validators/smart-sessions';
|
|
11
11
|
import { type ApprovalRequired, type AuxiliaryFunds, getAllSupportedChainsAndTokens, getSupportedTokens, getTokenAddress, getTokenDecimals, type IntentInput, type IntentOp, type IntentOpStatus, type Portfolio, type SettlementLayer, type SignedIntentOp, type SplitIntentsInput, type SplitIntentsResult, type TokenRequirements, type WrapRequired } from './orchestrator';
|
|
12
|
-
import type { AccountProviderConfig, AccountType, BundlerConfig, Call, CallInput, MultiFactorValidatorConfig, OwnableValidatorConfig, OwnerSet, PaymasterConfig, Policy, ProviderConfig, Recovery, RhinestoneAccountConfig, RhinestoneConfig, RhinestoneSDKConfig, Session, SignerSet, TokenRequest, TokenSymbol, Transaction, UniversalActionPolicyParamCondition, UserOperationTransaction, WebauthnValidatorConfig } from './types';
|
|
12
|
+
import type { AccountProviderConfig, AccountType, BundlerConfig, Call, CallInput, ChainSessionConfig, MultiFactorValidatorConfig, OwnableValidatorConfig, OwnerSet, PaymasterConfig, Permit2ClaimPolicy, Policy, ProviderConfig, Recovery, RhinestoneAccountConfig, RhinestoneConfig, RhinestoneSDKConfig, Session, SignerSet, TokenRequest, TokenSymbol, Transaction, UniversalActionPolicyParamCondition, UserOperationTransaction, WebauthnValidatorConfig } from './types';
|
|
13
13
|
interface RhinestoneAccount {
|
|
14
14
|
config: RhinestoneAccountConfig;
|
|
15
15
|
deploy: (chain: Chain, params?: {
|
|
@@ -62,7 +62,7 @@ interface RhinestoneAccount {
|
|
|
62
62
|
*/
|
|
63
63
|
declare function createRhinestoneAccount(config: RhinestoneConfig): Promise<RhinestoneAccount>;
|
|
64
64
|
declare class RhinestoneSDK {
|
|
65
|
-
private
|
|
65
|
+
private authProvider;
|
|
66
66
|
private endpointUrl?;
|
|
67
67
|
private provider?;
|
|
68
68
|
private bundler?;
|
|
@@ -77,7 +77,7 @@ declare class RhinestoneSDK {
|
|
|
77
77
|
splitIntents(input: SplitIntentsInput): Promise<SplitIntentsResult>;
|
|
78
78
|
}
|
|
79
79
|
export { RhinestoneSDK, createRhinestoneAccount, deployAccountsForOwners, walletClientToAccount, wrapParaAccount, OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, getSupportedTokens, getTokenAddress, getTokenDecimals, getAllSupportedChainsAndTokens, deployStandaloneWithEoaInternal as deployStandaloneWithEoa, checkERC20AllowanceDirect, getPermit2Address, signPermit2Batch, signPermit2Sequential, };
|
|
80
|
-
export type { RhinestoneAccount, AccountType, RhinestoneAccountConfig, AccountProviderConfig, ProviderConfig, BundlerConfig, PaymasterConfig, Transaction, TokenSymbol, CallInput, Call, TokenRequest, OwnerSet, OwnableValidatorConfig, WebauthnValidatorConfig, MultiFactorValidatorConfig, SignerSet, Session, Recovery, Policy, UniversalActionPolicyParamCondition, PreparedTransactionData, SignedTransactionData, TransactionResult, PreparedUserOperationData, SignedUserOperationData, UserOperationResult, AuxiliaryFunds, IntentInput, IntentOp, IntentOpStatus, IntentRoute, SettlementLayer, SignedIntentOp, SplitIntentsInput, SplitIntentsResult, Portfolio, TokenRequirements, WrapRequired, ApprovalRequired, MultiChainPermit2Config, MultiChainPermit2Result, BatchPermit2Result, };
|
|
81
|
-
export { generateCredentialId, getCredentialIds,
|
|
80
|
+
export type { RhinestoneAccount, AccountType, RhinestoneAccountConfig, AccountProviderConfig, ProviderConfig, BundlerConfig, PaymasterConfig, Transaction, TokenSymbol, CallInput, Call, TokenRequest, OwnerSet, OwnableValidatorConfig, WebauthnValidatorConfig, MultiFactorValidatorConfig, SignerSet, ChainSessionConfig, Session, Recovery, Policy, Permit2ClaimPolicy, UniversalActionPolicyParamCondition, PreparedTransactionData, SignedTransactionData, TransactionResult, PreparedUserOperationData, SignedUserOperationData, UserOperationResult, AuxiliaryFunds, IntentInput, IntentOp, IntentOpStatus, IntentRoute, SettlementLayer, SignedIntentOp, SplitIntentsInput, SplitIntentsResult, Portfolio, TokenRequirements, WrapRequired, ApprovalRequired, MultiChainPermit2Config, MultiChainPermit2Result, BatchPermit2Result, };
|
|
81
|
+
export { addCredential, generateCredentialId, getCredentialIds, getCredentialInfo, getCredentials, getThreshold, hasCredential, hasCredentialById, removeCredential, setThreshold, WEBAUTHN_VALIDATOR_ABI, } from './modules/validators/webauthn-contract';
|
|
82
82
|
export { getOrchestrator } from './orchestrator';
|
|
83
83
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,mBAAmB,EACpB,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAGL,uBAAuB,IAAI,+BAA+B,EAS3D,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,EAML,KAAK,iBAAiB,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eAAe,EAEf,yBAAyB,EACzB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAE9B,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,8BAA8B,EAE9B,+BAA+B,IAAI,uBAAuB,EAE1D,yBAAyB,EACzB,iBAAiB,EAEjB,gBAAgB,EAChB,qBAAqB,GACtB,CAAA;AACD,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,SAAS,EACT,kBAAkB,EAClB,OAAO,EACP,QAAQ,EACR,MAAM,EACN,kBAAkB,EAClB,mCAAmC,EACnC,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAEhB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,CAAA;AAID,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,GACvB,MAAM,wCAAwC,CAAA;AAG/C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOrchestrator = exports.WEBAUTHN_VALIDATOR_ABI = exports.
|
|
3
|
+
exports.getOrchestrator = exports.WEBAUTHN_VALIDATOR_ABI = exports.setThreshold = exports.removeCredential = exports.hasCredentialById = exports.hasCredential = exports.getThreshold = exports.getCredentials = exports.getCredentialInfo = exports.getCredentialIds = exports.generateCredentialId = exports.addCredential = exports.signPermit2Sequential = exports.signPermit2Batch = exports.getPermit2Address = exports.checkERC20AllowanceDirect = exports.deployStandaloneWithEoa = exports.getAllSupportedChainsAndTokens = exports.getTokenDecimals = exports.getTokenAddress = exports.getSupportedTokens = exports.SMART_SESSION_EMISSARY_ADDRESS = exports.MULTI_FACTOR_VALIDATOR_ADDRESS = exports.WEBAUTHN_VALIDATOR_ADDRESS = exports.OWNABLE_VALIDATOR_ADDRESS = exports.wrapParaAccount = exports.walletClientToAccount = exports.deployAccountsForOwners = exports.RhinestoneSDK = void 0;
|
|
4
4
|
exports.createRhinestoneAccount = createRhinestoneAccount;
|
|
5
5
|
const accounts_1 = require("./accounts");
|
|
6
6
|
Object.defineProperty(exports, "deployStandaloneWithEoa", { enumerable: true, get: function () { return accounts_1.deployStandaloneWithEoa; } });
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "walletClientToAccount", { enumerable: true, get:
|
|
|
9
9
|
Object.defineProperty(exports, "wrapParaAccount", { enumerable: true, get: function () { return walletClient_1.wrapParaAccount; } });
|
|
10
10
|
const deployment_1 = require("./actions/deployment");
|
|
11
11
|
Object.defineProperty(exports, "deployAccountsForOwners", { enumerable: true, get: function () { return deployment_1.deployAccountsForOwners; } });
|
|
12
|
+
const provider_1 = require("./auth/provider");
|
|
12
13
|
const execution_1 = require("./execution");
|
|
13
14
|
const permit2_1 = require("./execution/permit2");
|
|
14
15
|
Object.defineProperty(exports, "checkERC20AllowanceDirect", { enumerable: true, get: function () { return permit2_1.checkERC20AllowanceDirect; } });
|
|
@@ -298,7 +299,7 @@ async function createRhinestoneAccount(config) {
|
|
|
298
299
|
};
|
|
299
300
|
}
|
|
300
301
|
class RhinestoneSDK {
|
|
301
|
-
|
|
302
|
+
authProvider;
|
|
302
303
|
endpointUrl;
|
|
303
304
|
provider;
|
|
304
305
|
bundler;
|
|
@@ -306,7 +307,7 @@ class RhinestoneSDK {
|
|
|
306
307
|
useDevContracts;
|
|
307
308
|
headers;
|
|
308
309
|
constructor(options) {
|
|
309
|
-
this.
|
|
310
|
+
this.authProvider = (0, provider_1.createAuthProvider)(options);
|
|
310
311
|
this.endpointUrl = options.endpointUrl;
|
|
311
312
|
this.provider = options.provider;
|
|
312
313
|
this.bundler = options.bundler;
|
|
@@ -317,7 +318,7 @@ class RhinestoneSDK {
|
|
|
317
318
|
createAccount(config) {
|
|
318
319
|
const rhinestoneConfig = {
|
|
319
320
|
...config,
|
|
320
|
-
|
|
321
|
+
_authProvider: this.authProvider,
|
|
321
322
|
endpointUrl: this.endpointUrl,
|
|
322
323
|
provider: this.provider,
|
|
323
324
|
bundler: this.bundler,
|
|
@@ -328,25 +329,26 @@ class RhinestoneSDK {
|
|
|
328
329
|
return createRhinestoneAccount(rhinestoneConfig);
|
|
329
330
|
}
|
|
330
331
|
getIntentStatus(intentId) {
|
|
331
|
-
return (0, execution_1.getIntentStatus)(this.
|
|
332
|
+
return (0, execution_1.getIntentStatus)(this.authProvider, this.endpointUrl, intentId, this.headers);
|
|
332
333
|
}
|
|
333
334
|
splitIntents(input) {
|
|
334
|
-
return (0, execution_1.splitIntents)(this.
|
|
335
|
+
return (0, execution_1.splitIntents)(this.authProvider, this.endpointUrl, input, this.headers);
|
|
335
336
|
}
|
|
336
337
|
}
|
|
337
338
|
exports.RhinestoneSDK = RhinestoneSDK;
|
|
338
339
|
// WebAuthn Validator contract helpers (keep Charter API stable)
|
|
340
|
+
// biome-ignore lint/performance/noBarrelFile: required to preserve Charter's public API surface
|
|
339
341
|
var webauthn_contract_1 = require("./modules/validators/webauthn-contract");
|
|
342
|
+
Object.defineProperty(exports, "addCredential", { enumerable: true, get: function () { return webauthn_contract_1.addCredential; } });
|
|
340
343
|
Object.defineProperty(exports, "generateCredentialId", { enumerable: true, get: function () { return webauthn_contract_1.generateCredentialId; } });
|
|
341
344
|
Object.defineProperty(exports, "getCredentialIds", { enumerable: true, get: function () { return webauthn_contract_1.getCredentialIds; } });
|
|
342
|
-
Object.defineProperty(exports, "
|
|
345
|
+
Object.defineProperty(exports, "getCredentialInfo", { enumerable: true, get: function () { return webauthn_contract_1.getCredentialInfo; } });
|
|
346
|
+
Object.defineProperty(exports, "getCredentials", { enumerable: true, get: function () { return webauthn_contract_1.getCredentials; } });
|
|
347
|
+
Object.defineProperty(exports, "getThreshold", { enumerable: true, get: function () { return webauthn_contract_1.getThreshold; } });
|
|
343
348
|
Object.defineProperty(exports, "hasCredential", { enumerable: true, get: function () { return webauthn_contract_1.hasCredential; } });
|
|
344
|
-
Object.defineProperty(exports, "
|
|
349
|
+
Object.defineProperty(exports, "hasCredentialById", { enumerable: true, get: function () { return webauthn_contract_1.hasCredentialById; } });
|
|
345
350
|
Object.defineProperty(exports, "removeCredential", { enumerable: true, get: function () { return webauthn_contract_1.removeCredential; } });
|
|
346
351
|
Object.defineProperty(exports, "setThreshold", { enumerable: true, get: function () { return webauthn_contract_1.setThreshold; } });
|
|
347
|
-
Object.defineProperty(exports, "getCredentialInfo", { enumerable: true, get: function () { return webauthn_contract_1.getCredentialInfo; } });
|
|
348
|
-
Object.defineProperty(exports, "getThreshold", { enumerable: true, get: function () { return webauthn_contract_1.getThreshold; } });
|
|
349
|
-
Object.defineProperty(exports, "getCredentials", { enumerable: true, get: function () { return webauthn_contract_1.getCredentials; } });
|
|
350
352
|
Object.defineProperty(exports, "WEBAUTHN_VALIDATOR_ABI", { enumerable: true, get: function () { return webauthn_contract_1.WEBAUTHN_VALIDATOR_ABI; } });
|
|
351
353
|
// Orchestrator helpers
|
|
352
354
|
var orchestrator_2 = require("./orchestrator");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute a deterministic hex-encoded SHA-256 digest of an intent input object.
|
|
3
|
+
*
|
|
4
|
+
* 1. JCS-canonicalise the intent input (RFC 8785)
|
|
5
|
+
* 2. SHA-256 hash the UTF-8 bytes
|
|
6
|
+
* 3. Return lowercase hex string
|
|
7
|
+
*
|
|
8
|
+
* Uses the Web Crypto API (available in Node.js ≥ 15 and all modern browsers).
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeIntentInputDigest(intentInput: unknown): Promise<string>;
|
|
11
|
+
//# sourceMappingURL=digest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../jwt-server/digest.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeIntentInputDigest = computeIntentInputDigest;
|
|
4
|
+
const jcs_1 = require("./jcs");
|
|
5
|
+
/**
|
|
6
|
+
* Compute a deterministic hex-encoded SHA-256 digest of an intent input object.
|
|
7
|
+
*
|
|
8
|
+
* 1. JCS-canonicalise the intent input (RFC 8785)
|
|
9
|
+
* 2. SHA-256 hash the UTF-8 bytes
|
|
10
|
+
* 3. Return lowercase hex string
|
|
11
|
+
*
|
|
12
|
+
* Uses the Web Crypto API (available in Node.js ≥ 15 and all modern browsers).
|
|
13
|
+
*/
|
|
14
|
+
async function computeIntentInputDigest(intentInput) {
|
|
15
|
+
const canonical = (0, jcs_1.jcsCanonicalise)(intentInput);
|
|
16
|
+
const encoded = new TextEncoder().encode(canonical);
|
|
17
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', encoded);
|
|
18
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
19
|
+
return Array.from(hashArray)
|
|
20
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
21
|
+
.join('');
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type JwtHandlerConfig } from './handlers';
|
|
2
|
+
interface ExpressRequest {
|
|
3
|
+
body?: unknown;
|
|
4
|
+
}
|
|
5
|
+
interface ExpressResponse {
|
|
6
|
+
status(code: number): ExpressResponse;
|
|
7
|
+
json(body: unknown): void;
|
|
8
|
+
}
|
|
9
|
+
type ExpressHandler = (req: ExpressRequest, res: ExpressResponse) => void;
|
|
10
|
+
interface ExpressRouter {
|
|
11
|
+
get(path: string, handler: ExpressHandler): ExpressRouter;
|
|
12
|
+
post(path: string, handler: ExpressHandler): ExpressRouter;
|
|
13
|
+
}
|
|
14
|
+
export declare function createExpressRouter(config: JwtHandlerConfig): ExpressRouter;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=express.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../jwt-server/express.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAA;AAEnB,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,UAAU,eAAe;IACvB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;IACrC,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;CAC1B;AAED,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,KAAK,IAAI,CAAA;AAEzE,UAAU,aAAa;IACrB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAAA;IACzD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,aAAa,CAAA;CAC3D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAyB3E"}
|