@rhinestone/sdk 1.4.2 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -1
- package/dist/src/accounts/error.d.ts +1 -1
- package/dist/src/accounts/error.js +1 -19
- package/dist/src/accounts/index.d.ts +5 -5
- package/dist/src/accounts/index.js +121 -157
- package/dist/src/accounts/json-rpc/index.d.ts +1 -1
- package/dist/src/accounts/json-rpc/index.js +8 -10
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
- package/dist/src/accounts/json-rpc/providers.js +4 -7
- package/dist/src/accounts/kernel.d.ts +3 -3
- package/dist/src/accounts/kernel.js +66 -75
- package/dist/src/accounts/nexus.d.ts +3 -3
- package/dist/src/accounts/nexus.js +62 -73
- package/dist/src/accounts/passport.d.ts +3 -3
- package/dist/src/accounts/passport.js +9 -13
- package/dist/src/accounts/safe.d.ts +3 -3
- package/dist/src/accounts/safe.js +54 -63
- package/dist/src/accounts/signing/common.d.ts +10 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +30 -36
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.js +10 -12
- package/dist/src/accounts/signing/passkeys.js +11 -17
- package/dist/src/accounts/signing/typedData.d.ts +1 -1
- package/dist/src/accounts/signing/typedData.js +6 -8
- package/dist/src/accounts/startale.d.ts +3 -3
- package/dist/src/accounts/startale.js +37 -47
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.js +22 -28
- package/dist/src/accounts/walletClient.js +4 -8
- package/dist/src/actions/compact.d.ts +1 -1
- package/dist/src/actions/compact.js +22 -35
- package/dist/src/actions/deployment.d.ts +1 -1
- package/dist/src/actions/deployment.js +11 -13
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.js +14 -20
- package/dist/src/actions/index.d.ts +2 -2
- package/dist/src/actions/index.js +6 -10
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.js +18 -24
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.js +14 -20
- package/dist/src/actions/recovery.d.ts +1 -1
- package/dist/src/actions/recovery.js +25 -29
- package/dist/src/actions/smart-sessions.d.ts +1 -1
- package/dist/src/actions/smart-sessions.js +8 -12
- 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 +38 -0
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.js +10 -54
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.js +10 -18
- package/dist/src/execution/error.js +1 -11
- package/dist/src/execution/index.d.ts +9 -8
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +54 -67
- package/dist/src/execution/permit2.d.ts +5 -5
- package/dist/src/execution/permit2.js +8 -13
- package/dist/src/execution/singleChainOps.d.ts +2 -2
- package/dist/src/execution/singleChainOps.js +1 -3
- package/dist/src/execution/types.d.ts +1 -1
- package/dist/src/execution/types.js +1 -2
- package/dist/src/execution/utils.d.ts +10 -6
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +159 -162
- package/dist/src/index.d.ts +10 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +57 -67
- 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 +19 -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 +23 -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 +37 -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 +7 -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 +57 -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 +68 -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 +51 -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 +23 -0
- package/dist/src/modules/abi/smart-session-emissary.js +1 -3
- package/dist/src/modules/abi/smart-sessions.js +1 -4
- package/dist/src/modules/chain-abstraction.js +1 -5
- package/dist/src/modules/common.d.ts +1 -1
- package/dist/src/modules/common.js +1 -13
- package/dist/src/modules/index.d.ts +5 -5
- package/dist/src/modules/index.js +35 -50
- package/dist/src/modules/legacy.d.ts +2 -2
- package/dist/src/modules/legacy.js +11 -14
- package/dist/src/modules/read.d.ts +1 -1
- package/dist/src/modules/read.js +11 -15
- package/dist/src/modules/validators/core.d.ts +2 -2
- package/dist/src/modules/validators/core.js +26 -44
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.js +3 -19
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
- package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
- package/dist/src/modules/validators/policies/claim/types.js +11 -14
- package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +77 -97
- package/dist/src/orchestrator/client.d.ts +10 -5
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +73 -66
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +2 -8
- package/dist/src/orchestrator/error.js +1 -33
- package/dist/src/orchestrator/index.d.ts +8 -7
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +8 -57
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.d.ts +5 -1
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +29 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.js +9 -15
- package/package.json +29 -98
- 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 -168
- 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/signing.test.d.ts +0 -2
- package/dist/src/execution/signing.test.d.ts.map +0 -1
- package/dist/src/execution/signing.test.js +0 -465
- 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 -388
- 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/policies/claim/permit2.test.d.ts +0 -2
- package/dist/src/modules/validators/policies/claim/permit2.test.d.ts.map +0 -1
- package/dist/src/modules/validators/policies/claim/permit2.test.js +0 -519
- 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 -311
- 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/src/utils/index.test.d.ts +0 -2
- package/dist/src/utils/index.test.d.ts.map +0 -1
- package/dist/src/utils/index.test.js +0 -42
- 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
package/dist/src/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Address, Chain, HashTypedDataParameters, Hex, SignableMessage, SignedAuthorizationList, TypedData, TypedDataDefinition } from 'viem';
|
|
2
2
|
import type { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
|
-
import { walletClientToAccount, wrapParaAccount } from './accounts/walletClient';
|
|
4
|
-
import { deployAccountsForOwners } from './actions/deployment';
|
|
5
|
-
import { type TransactionResult, type TransactionStatus, type UserOperationResult } from './execution';
|
|
6
|
-
import { type BatchPermit2Result, checkERC20AllowanceDirect, getPermit2Address, type MultiChainPermit2Config, type MultiChainPermit2Result, signPermit2Batch, signPermit2Sequential } from './execution/permit2';
|
|
7
|
-
import { type IntentRoute, type PreparedTransactionData, type PreparedUserOperationData, type SignedTransactionData, type SignedUserOperationData } from './execution/utils';
|
|
8
|
-
import { MULTI_FACTOR_VALIDATOR_ADDRESS, OWNABLE_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS } from './modules';
|
|
9
|
-
import { type SessionDetails } from './modules/validators/smart-sessions';
|
|
10
|
-
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';
|
|
11
|
-
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';
|
|
3
|
+
import { walletClientToAccount, wrapParaAccount } from './accounts/walletClient.js';
|
|
4
|
+
import { deployAccountsForOwners } from './actions/deployment.js';
|
|
5
|
+
import { type TransactionResult, type TransactionStatus, type UserOperationResult } from './execution/index.js';
|
|
6
|
+
import { type BatchPermit2Result, checkERC20AllowanceDirect, getPermit2Address, type MultiChainPermit2Config, type MultiChainPermit2Result, signPermit2Batch, signPermit2Sequential } from './execution/permit2.js';
|
|
7
|
+
import { type IntentRoute, type PreparedTransactionData, type PreparedUserOperationData, type SignedTransactionData, type SignedUserOperationData } from './execution/utils.js';
|
|
8
|
+
import { MULTI_FACTOR_VALIDATOR_ADDRESS, OWNABLE_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS } from './modules/index.js';
|
|
9
|
+
import { type SessionDetails } from './modules/validators/smart-sessions.js';
|
|
10
|
+
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/index.js';
|
|
11
|
+
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.js';
|
|
12
12
|
interface RhinestoneAccount {
|
|
13
13
|
config: RhinestoneAccountConfig;
|
|
14
14
|
deploy: (chain: Chain, params?: {
|
|
@@ -60,7 +60,7 @@ interface RhinestoneAccount {
|
|
|
60
60
|
*/
|
|
61
61
|
declare function createRhinestoneAccount(config: RhinestoneConfig): Promise<RhinestoneAccount>;
|
|
62
62
|
declare class RhinestoneSDK {
|
|
63
|
-
private
|
|
63
|
+
private authProvider;
|
|
64
64
|
private endpointUrl?;
|
|
65
65
|
private provider?;
|
|
66
66
|
private bundler?;
|
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,EACpB,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAapE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;
|
|
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,EACpB,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAapE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAE9D,OAAO,EAML,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAEzB,MA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ACtB,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"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,31 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const execution_1 = require("./execution");
|
|
12
|
-
const permit2_1 = require("./execution/permit2");
|
|
13
|
-
Object.defineProperty(exports, "checkERC20AllowanceDirect", { enumerable: true, get: function () { return permit2_1.checkERC20AllowanceDirect; } });
|
|
14
|
-
Object.defineProperty(exports, "getPermit2Address", { enumerable: true, get: function () { return permit2_1.getPermit2Address; } });
|
|
15
|
-
Object.defineProperty(exports, "signPermit2Batch", { enumerable: true, get: function () { return permit2_1.signPermit2Batch; } });
|
|
16
|
-
Object.defineProperty(exports, "signPermit2Sequential", { enumerable: true, get: function () { return permit2_1.signPermit2Sequential; } });
|
|
17
|
-
const utils_1 = require("./execution/utils");
|
|
18
|
-
const modules_1 = require("./modules");
|
|
19
|
-
Object.defineProperty(exports, "MULTI_FACTOR_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return modules_1.MULTI_FACTOR_VALIDATOR_ADDRESS; } });
|
|
20
|
-
Object.defineProperty(exports, "OWNABLE_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return modules_1.OWNABLE_VALIDATOR_ADDRESS; } });
|
|
21
|
-
Object.defineProperty(exports, "SMART_SESSION_EMISSARY_ADDRESS", { enumerable: true, get: function () { return modules_1.SMART_SESSION_EMISSARY_ADDRESS; } });
|
|
22
|
-
Object.defineProperty(exports, "WEBAUTHN_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return modules_1.WEBAUTHN_VALIDATOR_ADDRESS; } });
|
|
23
|
-
const smart_sessions_1 = require("./modules/validators/smart-sessions");
|
|
24
|
-
const orchestrator_1 = require("./orchestrator");
|
|
25
|
-
Object.defineProperty(exports, "getAllSupportedChainsAndTokens", { enumerable: true, get: function () { return orchestrator_1.getAllSupportedChainsAndTokens; } });
|
|
26
|
-
Object.defineProperty(exports, "getSupportedTokens", { enumerable: true, get: function () { return orchestrator_1.getSupportedTokens; } });
|
|
27
|
-
Object.defineProperty(exports, "getTokenAddress", { enumerable: true, get: function () { return orchestrator_1.getTokenAddress; } });
|
|
28
|
-
Object.defineProperty(exports, "getTokenDecimals", { enumerable: true, get: function () { return orchestrator_1.getTokenDecimals; } });
|
|
1
|
+
import { checkAddress, deploy as deployInternal, FactoryArgsNotAvailableError, getAccountProvider, getAddress as getAddressInternal, getInitCode, isDeployed as isDeployedInternal, OwnersFieldRequiredError, setup as setupInternal, signEip7702InitData as signEip7702InitDataInternal, } from './accounts/index.js';
|
|
2
|
+
import { walletClientToAccount, wrapParaAccount } from './accounts/walletClient.js';
|
|
3
|
+
import { deployAccountsForOwners } from './actions/deployment.js';
|
|
4
|
+
import { createAuthProvider } from './auth/provider.js';
|
|
5
|
+
import { getIntentStatus as getIntentStatusInternal, getPortfolio as getPortfolioInternal, sendTransaction as sendTransactionInternal, sendUserOperation as sendUserOperationInternal, splitIntents as splitIntentsInternal, waitForExecution as waitForExecutionInternal, } from './execution/index.js';
|
|
6
|
+
import { checkERC20AllowanceDirect, checkERC20Allowance as checkERC20AllowanceInternal, getPermit2Address, signPermit2Batch, signPermit2Sequential, } from './execution/permit2.js';
|
|
7
|
+
import { getTransactionMessages as getTransactionMessagesInternal, prepareTransaction as prepareTransactionInternal, prepareUserOperation as prepareUserOperationInternal, signAuthorizations as signAuthorizationsInternal, signMessage as signMessageInternal, signTransaction as signTransactionInternal, signTypedData as signTypedDataInternal, signUserOperation as signUserOperationInternal, submitTransaction as submitTransactionInternal, submitUserOperation as submitUserOperationInternal, } from './execution/utils.js';
|
|
8
|
+
import { getExecutors as getExecutorsInternal, getOwners as getOwnersInternal, getSessionDetails as getSessionDetailsInternal, getValidators as getValidatorsInternal, MULTI_FACTOR_VALIDATOR_ADDRESS, OWNABLE_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, signEnableSession as signEnableSessionInternal, WEBAUTHN_VALIDATOR_ADDRESS, } from './modules/index.js';
|
|
9
|
+
import { isSessionEnabled as isSessionEnabledInternal, } from './modules/validators/smart-sessions.js';
|
|
10
|
+
import { getAllSupportedChainsAndTokens, getSupportedTokens, getTokenAddress, getTokenDecimals, } from './orchestrator/index.js';
|
|
29
11
|
/**
|
|
30
12
|
* Initialize a Rhinestone account
|
|
31
13
|
* Note: accounts are deployed onchain only when the first transaction is sent.
|
|
@@ -35,10 +17,10 @@ Object.defineProperty(exports, "getTokenDecimals", { enumerable: true, get: func
|
|
|
35
17
|
async function createRhinestoneAccount(config) {
|
|
36
18
|
// Sanity check for existing (externally created) accounts
|
|
37
19
|
// Ensures we decode the initdata correctly
|
|
38
|
-
|
|
20
|
+
checkAddress(config);
|
|
39
21
|
// Validate that owners field is provided for non-EOA accounts
|
|
40
22
|
if (config.account?.type !== 'eoa' && !config.owners) {
|
|
41
|
-
throw new
|
|
23
|
+
throw new OwnersFieldRequiredError();
|
|
42
24
|
}
|
|
43
25
|
/**
|
|
44
26
|
* Deploys the account on a given chain
|
|
@@ -46,7 +28,7 @@ async function createRhinestoneAccount(config) {
|
|
|
46
28
|
* @param session Session to deploy the account on (optional)
|
|
47
29
|
*/
|
|
48
30
|
function deploy(chain, params) {
|
|
49
|
-
return (
|
|
31
|
+
return deployInternal(config, chain, params);
|
|
50
32
|
}
|
|
51
33
|
/**
|
|
52
34
|
* Checks if the account is deployed on a given chain
|
|
@@ -54,7 +36,7 @@ async function createRhinestoneAccount(config) {
|
|
|
54
36
|
* @returns true if the account is deployed, false otherwise
|
|
55
37
|
*/
|
|
56
38
|
function isDeployed(chain) {
|
|
57
|
-
return (
|
|
39
|
+
return isDeployedInternal(config, chain);
|
|
58
40
|
}
|
|
59
41
|
/**
|
|
60
42
|
* Sets up the existing account on a given chain
|
|
@@ -62,19 +44,19 @@ async function createRhinestoneAccount(config) {
|
|
|
62
44
|
* @param chain Chain to set up the account on
|
|
63
45
|
*/
|
|
64
46
|
function setup(chain) {
|
|
65
|
-
return (
|
|
47
|
+
return setupInternal(config, chain);
|
|
66
48
|
}
|
|
67
49
|
/**
|
|
68
50
|
* Get the account initialization data. Used for deploying the account onchain.
|
|
69
51
|
* @returns factory address and factory data
|
|
70
52
|
*/
|
|
71
53
|
function getInitData() {
|
|
72
|
-
const initData =
|
|
54
|
+
const initData = getInitCode(config);
|
|
73
55
|
if (!initData) {
|
|
74
|
-
throw new
|
|
56
|
+
throw new FactoryArgsNotAvailableError();
|
|
75
57
|
}
|
|
76
58
|
if (!('factory' in initData)) {
|
|
77
|
-
throw new
|
|
59
|
+
throw new FactoryArgsNotAvailableError();
|
|
78
60
|
}
|
|
79
61
|
return {
|
|
80
62
|
factory: initData.factory,
|
|
@@ -86,7 +68,7 @@ async function createRhinestoneAccount(config) {
|
|
|
86
68
|
* @returns init data signature
|
|
87
69
|
*/
|
|
88
70
|
function signEip7702InitData() {
|
|
89
|
-
return (
|
|
71
|
+
return signEip7702InitDataInternal(config);
|
|
90
72
|
}
|
|
91
73
|
/**
|
|
92
74
|
* Prepare a transaction data
|
|
@@ -94,7 +76,7 @@ async function createRhinestoneAccount(config) {
|
|
|
94
76
|
* @returns prepared transaction data
|
|
95
77
|
*/
|
|
96
78
|
function prepareTransaction(transaction) {
|
|
97
|
-
return (
|
|
79
|
+
return prepareTransactionInternal(config, transaction);
|
|
98
80
|
}
|
|
99
81
|
/**
|
|
100
82
|
* Get the transaction typed data message to sign
|
|
@@ -102,7 +84,7 @@ async function createRhinestoneAccount(config) {
|
|
|
102
84
|
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
103
85
|
*/
|
|
104
86
|
function getTransactionMessages(preparedTransaction) {
|
|
105
|
-
return (
|
|
87
|
+
return getTransactionMessagesInternal(config, preparedTransaction);
|
|
106
88
|
}
|
|
107
89
|
/**
|
|
108
90
|
* Sign a transaction
|
|
@@ -111,7 +93,7 @@ async function createRhinestoneAccount(config) {
|
|
|
111
93
|
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
112
94
|
*/
|
|
113
95
|
function signTransaction(preparedTransaction) {
|
|
114
|
-
return (
|
|
96
|
+
return signTransactionInternal(config, preparedTransaction);
|
|
115
97
|
}
|
|
116
98
|
/**
|
|
117
99
|
* Sign the required EIP-7702 authorizations for a transaction
|
|
@@ -120,7 +102,7 @@ async function createRhinestoneAccount(config) {
|
|
|
120
102
|
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
121
103
|
*/
|
|
122
104
|
function signAuthorizations(preparedTransaction) {
|
|
123
|
-
return (
|
|
105
|
+
return signAuthorizationsInternal(config, preparedTransaction);
|
|
124
106
|
}
|
|
125
107
|
/**
|
|
126
108
|
* Sign a message (EIP-191)
|
|
@@ -130,7 +112,7 @@ async function createRhinestoneAccount(config) {
|
|
|
130
112
|
* @returns signature
|
|
131
113
|
*/
|
|
132
114
|
function signMessage(message, chain, signers) {
|
|
133
|
-
return (
|
|
115
|
+
return signMessageInternal(config, message, chain, signers);
|
|
134
116
|
}
|
|
135
117
|
/**
|
|
136
118
|
* Sign a typed data (EIP-712)
|
|
@@ -140,7 +122,7 @@ async function createRhinestoneAccount(config) {
|
|
|
140
122
|
* @returns signature
|
|
141
123
|
*/
|
|
142
124
|
function signTypedData(parameters, chain, signers) {
|
|
143
|
-
return (
|
|
125
|
+
return signTypedDataInternal(config, parameters, chain, signers);
|
|
144
126
|
}
|
|
145
127
|
/**
|
|
146
128
|
* Submit a transaction
|
|
@@ -152,7 +134,7 @@ async function createRhinestoneAccount(config) {
|
|
|
152
134
|
* @see {@link dryRun} true when intent is not executed onchain (internal use only)
|
|
153
135
|
*/
|
|
154
136
|
function submitTransaction(signedTransaction, authorizations, dryRun) {
|
|
155
|
-
return (
|
|
137
|
+
return submitTransactionInternal(config, signedTransaction, authorizations ?? [], dryRun);
|
|
156
138
|
}
|
|
157
139
|
/**
|
|
158
140
|
* Prepare a user operation data
|
|
@@ -160,7 +142,7 @@ async function createRhinestoneAccount(config) {
|
|
|
160
142
|
* @returns prepared user operation data
|
|
161
143
|
*/
|
|
162
144
|
function prepareUserOperation(transaction) {
|
|
163
|
-
return (
|
|
145
|
+
return prepareUserOperationInternal(config, transaction);
|
|
164
146
|
}
|
|
165
147
|
/**
|
|
166
148
|
* Sign a user operation
|
|
@@ -169,7 +151,7 @@ async function createRhinestoneAccount(config) {
|
|
|
169
151
|
* @see {@link prepareUserOperation} to prepare the user operation data for signing
|
|
170
152
|
*/
|
|
171
153
|
function signUserOperation(preparedUserOperation) {
|
|
172
|
-
return (
|
|
154
|
+
return signUserOperationInternal(config, preparedUserOperation);
|
|
173
155
|
}
|
|
174
156
|
/**
|
|
175
157
|
* Submit a transaction
|
|
@@ -178,7 +160,7 @@ async function createRhinestoneAccount(config) {
|
|
|
178
160
|
* @see {@link signUserOperation} to sign the user operation data
|
|
179
161
|
*/
|
|
180
162
|
function submitUserOperation(signedUserOperation) {
|
|
181
|
-
return (
|
|
163
|
+
return submitUserOperationInternal(config, signedUserOperation);
|
|
182
164
|
}
|
|
183
165
|
/**
|
|
184
166
|
* Sign and send a transaction
|
|
@@ -186,7 +168,7 @@ async function createRhinestoneAccount(config) {
|
|
|
186
168
|
* @returns transaction result object (an intent ID)
|
|
187
169
|
*/
|
|
188
170
|
function sendTransaction(transaction) {
|
|
189
|
-
return (
|
|
171
|
+
return sendTransactionInternal(config, transaction);
|
|
190
172
|
}
|
|
191
173
|
/**
|
|
192
174
|
* Sign and send a user operation
|
|
@@ -194,17 +176,17 @@ async function createRhinestoneAccount(config) {
|
|
|
194
176
|
* @returns user operation result object (a UserOp hash)
|
|
195
177
|
*/
|
|
196
178
|
function sendUserOperation(transaction) {
|
|
197
|
-
return (
|
|
179
|
+
return sendUserOperationInternal(config, transaction);
|
|
198
180
|
}
|
|
199
181
|
function waitForExecution(result, acceptsPreconfirmations = true) {
|
|
200
|
-
return (
|
|
182
|
+
return waitForExecutionInternal(config, result, acceptsPreconfirmations);
|
|
201
183
|
}
|
|
202
184
|
/**
|
|
203
185
|
* Get account address
|
|
204
186
|
* @returns Address of the smart account
|
|
205
187
|
*/
|
|
206
188
|
function getAddress() {
|
|
207
|
-
return (
|
|
189
|
+
return getAddressInternal(config);
|
|
208
190
|
}
|
|
209
191
|
/**
|
|
210
192
|
* Get account portfolio
|
|
@@ -212,7 +194,7 @@ async function createRhinestoneAccount(config) {
|
|
|
212
194
|
* @returns Account balances
|
|
213
195
|
*/
|
|
214
196
|
function getPortfolio(onTestnets = false) {
|
|
215
|
-
return (
|
|
197
|
+
return getPortfolioInternal(config, onTestnets);
|
|
216
198
|
}
|
|
217
199
|
/**
|
|
218
200
|
* Get account owners (ECDSA)
|
|
@@ -221,7 +203,7 @@ async function createRhinestoneAccount(config) {
|
|
|
221
203
|
*/
|
|
222
204
|
function getOwners(chain) {
|
|
223
205
|
const account = getAddress();
|
|
224
|
-
return (
|
|
206
|
+
return getOwnersInternal(account, chain, config.provider);
|
|
225
207
|
}
|
|
226
208
|
/**
|
|
227
209
|
* Get account validator modules
|
|
@@ -229,25 +211,25 @@ async function createRhinestoneAccount(config) {
|
|
|
229
211
|
* @returns List of account validators
|
|
230
212
|
*/
|
|
231
213
|
function getValidators(chain) {
|
|
232
|
-
const accountType =
|
|
214
|
+
const accountType = getAccountProvider(config).type;
|
|
233
215
|
const account = getAddress();
|
|
234
|
-
return (
|
|
216
|
+
return getValidatorsInternal(accountType, account, chain, config.provider);
|
|
235
217
|
}
|
|
236
218
|
function getExecutors(chain) {
|
|
237
|
-
const accountType =
|
|
219
|
+
const accountType = getAccountProvider(config).type;
|
|
238
220
|
const account = getAddress();
|
|
239
|
-
return (
|
|
221
|
+
return getExecutorsInternal(accountType, account, chain, config.provider);
|
|
240
222
|
}
|
|
241
223
|
function experimental_getSessionDetails(sessions) {
|
|
242
224
|
const account = getAddress();
|
|
243
|
-
return (
|
|
225
|
+
return getSessionDetailsInternal(account, sessions, config.provider, config.useDevContracts);
|
|
244
226
|
}
|
|
245
227
|
function experimental_isSessionEnabled(session) {
|
|
246
228
|
const account = getAddress();
|
|
247
|
-
return (
|
|
229
|
+
return isSessionEnabledInternal(account, config.provider, session, config.useDevContracts);
|
|
248
230
|
}
|
|
249
231
|
function experimental_signEnableSession(details) {
|
|
250
|
-
return (
|
|
232
|
+
return signEnableSessionInternal(config, details);
|
|
251
233
|
}
|
|
252
234
|
/**
|
|
253
235
|
* Check ERC20 allowance for the account owner and token (using Permit2 as spender)
|
|
@@ -259,7 +241,7 @@ async function createRhinestoneAccount(config) {
|
|
|
259
241
|
if (!config.provider) {
|
|
260
242
|
throw new Error('Provider configuration is required');
|
|
261
243
|
}
|
|
262
|
-
return (
|
|
244
|
+
return checkERC20AllowanceInternal(tokenAddress, chain, config);
|
|
263
245
|
}
|
|
264
246
|
return {
|
|
265
247
|
config,
|
|
@@ -293,7 +275,7 @@ async function createRhinestoneAccount(config) {
|
|
|
293
275
|
};
|
|
294
276
|
}
|
|
295
277
|
class RhinestoneSDK {
|
|
296
|
-
|
|
278
|
+
authProvider;
|
|
297
279
|
endpointUrl;
|
|
298
280
|
provider;
|
|
299
281
|
bundler;
|
|
@@ -301,7 +283,7 @@ class RhinestoneSDK {
|
|
|
301
283
|
useDevContracts;
|
|
302
284
|
headers;
|
|
303
285
|
constructor(options) {
|
|
304
|
-
this.
|
|
286
|
+
this.authProvider = createAuthProvider(options);
|
|
305
287
|
this.endpointUrl = options.endpointUrl;
|
|
306
288
|
this.provider = options.provider;
|
|
307
289
|
this.bundler = options.bundler;
|
|
@@ -312,7 +294,7 @@ class RhinestoneSDK {
|
|
|
312
294
|
createAccount(config) {
|
|
313
295
|
const rhinestoneConfig = {
|
|
314
296
|
...config,
|
|
315
|
-
|
|
297
|
+
_authProvider: this.authProvider,
|
|
316
298
|
endpointUrl: this.endpointUrl,
|
|
317
299
|
provider: this.provider,
|
|
318
300
|
bundler: this.bundler,
|
|
@@ -323,10 +305,18 @@ class RhinestoneSDK {
|
|
|
323
305
|
return createRhinestoneAccount(rhinestoneConfig);
|
|
324
306
|
}
|
|
325
307
|
getIntentStatus(intentId) {
|
|
326
|
-
return (
|
|
308
|
+
return getIntentStatusInternal(this.authProvider, this.endpointUrl, intentId, this.headers);
|
|
327
309
|
}
|
|
328
310
|
splitIntents(input) {
|
|
329
|
-
return (
|
|
311
|
+
return splitIntentsInternal(this.authProvider, this.endpointUrl, input, this.headers);
|
|
330
312
|
}
|
|
331
313
|
}
|
|
332
|
-
|
|
314
|
+
export { RhinestoneSDK, createRhinestoneAccount, deployAccountsForOwners, walletClientToAccount, wrapParaAccount,
|
|
315
|
+
// Validator addresses
|
|
316
|
+
OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS,
|
|
317
|
+
// Registry functions
|
|
318
|
+
getSupportedTokens, getTokenAddress, getTokenDecimals, getAllSupportedChainsAndTokens,
|
|
319
|
+
// Permit2 helpers
|
|
320
|
+
checkERC20AllowanceDirect, getPermit2Address,
|
|
321
|
+
// Multi-chain permit2 signing
|
|
322
|
+
signPermit2Batch, signPermit2Sequential, };
|
|
@@ -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,19 @@
|
|
|
1
|
+
import { jcsCanonicalise } from './jcs.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compute a deterministic hex-encoded SHA-256 digest of an intent input object.
|
|
4
|
+
*
|
|
5
|
+
* 1. JCS-canonicalise the intent input (RFC 8785)
|
|
6
|
+
* 2. SHA-256 hash the UTF-8 bytes
|
|
7
|
+
* 3. Return lowercase hex string
|
|
8
|
+
*
|
|
9
|
+
* Uses the Web Crypto API (available in Node.js ≥ 15 and all modern browsers).
|
|
10
|
+
*/
|
|
11
|
+
export async function computeIntentInputDigest(intentInput) {
|
|
12
|
+
const canonical = jcsCanonicalise(intentInput);
|
|
13
|
+
const encoded = new TextEncoder().encode(canonical);
|
|
14
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', encoded);
|
|
15
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
16
|
+
return Array.from(hashArray)
|
|
17
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
18
|
+
.join('');
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type JwtHandlerConfig } from './handlers.js';
|
|
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":"AACA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAA;AAInB,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { createCoreAccessTokenHandler, createCoreExtensionTokenHandler, } from './handlers.js';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
export function createExpressRouter(config) {
|
|
5
|
+
// Dynamic import avoidance: we type the router interface manually
|
|
6
|
+
// so express doesn't need to be installed unless this function is called.
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
8
|
+
const { Router } = require('express');
|
|
9
|
+
const router = Router();
|
|
10
|
+
const handleAccessToken = createCoreAccessTokenHandler(config);
|
|
11
|
+
const handleExtensionToken = createCoreExtensionTokenHandler(config);
|
|
12
|
+
router.get('/access-token', async (_req, res) => {
|
|
13
|
+
const result = await handleAccessToken();
|
|
14
|
+
res.status(result.status).json(result.body);
|
|
15
|
+
});
|
|
16
|
+
router.post('/extension-token', async (req, res) => {
|
|
17
|
+
const body = req.body;
|
|
18
|
+
const intentInput = body?.intentInput;
|
|
19
|
+
const result = await handleExtensionToken(intentInput);
|
|
20
|
+
res.status(result.status).json(result.body);
|
|
21
|
+
});
|
|
22
|
+
return router;
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type JwtSignerConfig } from './signer.js';
|
|
2
|
+
export type JwtHandlerConfig = JwtSignerConfig;
|
|
3
|
+
interface HandlerResult {
|
|
4
|
+
status: number;
|
|
5
|
+
body: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare function createCoreAccessTokenHandler(config: JwtHandlerConfig): () => Promise<HandlerResult>;
|
|
8
|
+
export declare function createCoreExtensionTokenHandler(config: JwtHandlerConfig): (intentInput: unknown) => Promise<HandlerResult>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../jwt-server/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,UAAU,CAAA;AAGhE,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAA;AAE9C,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,gBAAgB,GACvB,MAAM,OAAO,CAAC,aAAa,CAAC,CAa9B;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,gBAAgB,GACvB,CAAC,WAAW,EAAE,OAAO,KAAK,OAAO,CAAC,aAAa,CAAC,CAuBlD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createJwtSigner } from './signer.js';
|
|
2
|
+
import { SponsorshipDeniedError } from './sponsorship.js';
|
|
3
|
+
export function createCoreAccessTokenHandler(config) {
|
|
4
|
+
const signer = createJwtSigner(config);
|
|
5
|
+
return async () => {
|
|
6
|
+
try {
|
|
7
|
+
const token = await signer.accessToken();
|
|
8
|
+
return { status: 200, body: { token } };
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
const message = error instanceof Error ? error.message : 'Internal server error';
|
|
12
|
+
return { status: 500, body: { error: message } };
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function createCoreExtensionTokenHandler(config) {
|
|
17
|
+
const signer = createJwtSigner(config);
|
|
18
|
+
return async (intentInput) => {
|
|
19
|
+
if (intentInput === undefined || intentInput === null) {
|
|
20
|
+
return {
|
|
21
|
+
status: 400,
|
|
22
|
+
body: { error: 'Missing intentInput in request body' },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const token = await signer.getIntentExtensionToken(intentInput);
|
|
27
|
+
return { status: 200, body: { token } };
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof SponsorshipDeniedError) {
|
|
31
|
+
return { status: 403, body: { error: error.message } };
|
|
32
|
+
}
|
|
33
|
+
const message = error instanceof Error ? error.message : 'Internal server error';
|
|
34
|
+
return { status: 500, body: { error: message } };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { computeIntentInputDigest } from './digest.js';
|
|
2
|
+
export { createExpressRouter } from './express.js';
|
|
3
|
+
export type { JwtHandlerConfig } from './handlers.js';
|
|
4
|
+
export { jcsCanonicalise } from './jcs.js';
|
|
5
|
+
export { createJwtSigner, type JwtCredentials, type JwtSignerConfig, } from './signer.js';
|
|
6
|
+
export { SponsorshipDeniedError, type SponsorshipFilter, shouldSponsor, } from './sponsorship.js';
|
|
7
|
+
export { createAccessTokenHandler, createExtensionTokenHandler, } from './web.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jwt-server/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,wBAAwB,EACxB,2BAA2B,GAC5B,MAAM,OAAO,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// biome-ignore lint/performance/noBarrelFile: subpath entry point for @rhinestone/sdk/jwt-server
|
|
2
|
+
export { computeIntentInputDigest } from './digest.js';
|
|
3
|
+
export { createExpressRouter } from './express.js';
|
|
4
|
+
export { jcsCanonicalise } from './jcs.js';
|
|
5
|
+
export { createJwtSigner, } from './signer.js';
|
|
6
|
+
export { SponsorshipDeniedError, shouldSponsor, } from './sponsorship.js';
|
|
7
|
+
export { createAccessTokenHandler, createExtensionTokenHandler, } from './web.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 8785 JSON Canonicalization Scheme (JCS).
|
|
3
|
+
*
|
|
4
|
+
* Produces a deterministic JSON serialization by:
|
|
5
|
+
* 1. Sorting object keys lexicographically (Unicode code-point order)
|
|
6
|
+
* 2. Using ES2015+ `JSON.stringify` number serialization (IEEE 754 → shortest round-trip)
|
|
7
|
+
* 3. No whitespace
|
|
8
|
+
*
|
|
9
|
+
* Reference: https://www.rfc-editor.org/rfc/rfc8785
|
|
10
|
+
*/
|
|
11
|
+
export declare function jcsCanonicalise(value: unknown): string;
|
|
12
|
+
//# sourceMappingURL=jcs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jcs.d.ts","sourceRoot":"","sources":["../../../jwt-server/jcs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 8785 JSON Canonicalization Scheme (JCS).
|
|
3
|
+
*
|
|
4
|
+
* Produces a deterministic JSON serialization by:
|
|
5
|
+
* 1. Sorting object keys lexicographically (Unicode code-point order)
|
|
6
|
+
* 2. Using ES2015+ `JSON.stringify` number serialization (IEEE 754 → shortest round-trip)
|
|
7
|
+
* 3. No whitespace
|
|
8
|
+
*
|
|
9
|
+
* Reference: https://www.rfc-editor.org/rfc/rfc8785
|
|
10
|
+
*/
|
|
11
|
+
export function jcsCanonicalise(value) {
|
|
12
|
+
return serialize(value);
|
|
13
|
+
}
|
|
14
|
+
function serialize(value) {
|
|
15
|
+
if (value === null || value === undefined) {
|
|
16
|
+
return 'null';
|
|
17
|
+
}
|
|
18
|
+
switch (typeof value) {
|
|
19
|
+
case 'boolean':
|
|
20
|
+
return value ? 'true' : 'false';
|
|
21
|
+
case 'number':
|
|
22
|
+
if (!Number.isFinite(value)) {
|
|
23
|
+
throw new Error(`JCS: non-finite number: ${value}`);
|
|
24
|
+
}
|
|
25
|
+
// ES2015 Number-to-String satisfies RFC 8785 §3.2.2.3
|
|
26
|
+
return Object.is(value, -0) ? '0' : String(value);
|
|
27
|
+
case 'string':
|
|
28
|
+
return JSON.stringify(value);
|
|
29
|
+
case 'bigint':
|
|
30
|
+
// BigInt is not valid JSON; coerce to bare decimal string.
|
|
31
|
+
// Values above MAX_SAFE_INTEGER are rejected because downstream
|
|
32
|
+
// JSON parsers using IEEE 754 doubles would silently lose precision,
|
|
33
|
+
// producing a different digest.
|
|
34
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER) ||
|
|
35
|
+
value < BigInt(-Number.MAX_SAFE_INTEGER)) {
|
|
36
|
+
throw new Error(`JCS: BigInt ${value} exceeds safe integer range — convert to string before calling`);
|
|
37
|
+
}
|
|
38
|
+
return String(value);
|
|
39
|
+
default:
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
const items = value.map((item) => serialize(item));
|
|
44
|
+
return `[${items.join(',')}]`;
|
|
45
|
+
}
|
|
46
|
+
// Object — sort keys by Unicode code-point order
|
|
47
|
+
const obj = value;
|
|
48
|
+
const keys = Object.keys(obj).sort();
|
|
49
|
+
const members = [];
|
|
50
|
+
for (const key of keys) {
|
|
51
|
+
const v = obj[key];
|
|
52
|
+
if (v === undefined)
|
|
53
|
+
continue; // skip undefined properties
|
|
54
|
+
members.push(`${JSON.stringify(key)}:${serialize(v)}`);
|
|
55
|
+
}
|
|
56
|
+
return `{${members.join(',')}}`;
|
|
57
|
+
}
|