@rhinestone/sdk 1.5.1 → 2.0.0-beta.1
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 +1 -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.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +7 -9
- 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 +2 -2
- 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 +1 -1
- package/dist/src/auth/provider.js +1 -4
- package/dist/src/errors/index.d.ts +4 -4
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +12 -54
- package/dist/src/execution/compact.d.ts +1 -144
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +1 -117
- package/dist/src/execution/error.d.ts +10 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +9 -11
- package/dist/src/execution/index.d.ts +10 -11
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +64 -75
- package/dist/src/execution/permit2.d.ts +2 -138
- package/dist/src/execution/permit2.d.ts.map +1 -1
- package/dist/src/execution/permit2.js +5 -239
- package/dist/src/execution/utils.d.ts +31 -15
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +283 -256
- package/dist/src/index.d.ts +15 -14
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +57 -68
- package/dist/src/jwt-server/digest.js +3 -6
- package/dist/src/jwt-server/express.d.ts +1 -1
- package/dist/src/jwt-server/express.d.ts.map +1 -1
- package/dist/src/jwt-server/express.js +6 -7
- package/dist/src/jwt-server/handlers.d.ts +1 -1
- package/dist/src/jwt-server/handlers.js +7 -11
- package/dist/src/jwt-server/index.d.ts +7 -7
- package/dist/src/jwt-server/index.js +6 -17
- package/dist/src/jwt-server/jcs.js +1 -4
- package/dist/src/jwt-server/signer.d.ts +1 -1
- package/dist/src/jwt-server/signer.js +10 -13
- package/dist/src/jwt-server/sponsorship.js +2 -7
- package/dist/src/jwt-server/web.d.ts +1 -1
- package/dist/src/jwt-server/web.js +5 -9
- 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 +3 -3
- package/dist/src/modules/validators/smart-sessions.js +65 -94
- package/dist/src/orchestrator/caip2.d.ts +7 -0
- package/dist/src/orchestrator/caip2.d.ts.map +1 -0
- package/dist/src/orchestrator/caip2.js +17 -0
- package/dist/src/orchestrator/client.d.ts +12 -12
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +199 -305
- package/dist/src/orchestrator/consts.d.ts +2 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +3 -9
- package/dist/src/orchestrator/error.d.ts +72 -217
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +117 -227
- package/dist/src/orchestrator/index.d.ts +9 -9
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +7 -56
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.d.ts +97 -232
- 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 +5 -7
- 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 +15 -98
- package/dist/src/execution/singleChainOps.d.ts +0 -41
- package/dist/src/execution/singleChainOps.d.ts.map +0 -1
- package/dist/src/execution/singleChainOps.js +0 -44
- package/dist/src/execution/types.d.ts +0 -36
- package/dist/src/execution/types.d.ts.map +0 -1
- package/dist/src/execution/types.js +0 -2
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 {
|
|
7
|
-
import { type
|
|
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
|
|
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 { checkERC20AllowanceDirect, getPermit2Address } from './execution/permit2.js';
|
|
7
|
+
import { type PreparedQuotes, type PreparedTransactionData, type PreparedUserOperationData, type QuoteSelection, 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 IntentOpStatus, type Portfolio, type SettlementLayer, 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?: {
|
|
@@ -23,11 +23,12 @@ interface RhinestoneAccount {
|
|
|
23
23
|
};
|
|
24
24
|
signEip7702InitData: () => Promise<Hex>;
|
|
25
25
|
prepareTransaction: (transaction: Transaction) => Promise<PreparedTransactionData>;
|
|
26
|
-
getTransactionMessages: (preparedTransaction: PreparedTransactionData) => {
|
|
26
|
+
getTransactionMessages: (preparedTransaction: PreparedTransactionData, options?: QuoteSelection) => {
|
|
27
27
|
origin: TypedDataDefinition[];
|
|
28
28
|
destination: TypedDataDefinition;
|
|
29
|
+
targetExecution?: TypedDataDefinition;
|
|
29
30
|
};
|
|
30
|
-
signTransaction: (preparedTransaction: PreparedTransactionData) => Promise<SignedTransactionData>;
|
|
31
|
+
signTransaction: (preparedTransaction: PreparedTransactionData, options?: QuoteSelection) => Promise<SignedTransactionData>;
|
|
31
32
|
signAuthorizations: (preparedTransaction: PreparedTransactionData) => Promise<SignedAuthorizationList>;
|
|
32
33
|
signMessage: (message: SignableMessage, chain: Chain, signers: SignerSet | undefined) => Promise<Hex>;
|
|
33
34
|
signTypedData: <typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(parameters: HashTypedDataParameters<typedData, primaryType>, chain: Chain, signers: SignerSet | undefined) => Promise<Hex>;
|
|
@@ -69,11 +70,11 @@ declare class RhinestoneSDK {
|
|
|
69
70
|
private headers?;
|
|
70
71
|
constructor(options: RhinestoneSDKConfig);
|
|
71
72
|
createAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
72
|
-
getIntentStatus(intentId:
|
|
73
|
+
getIntentStatus(intentId: string): Promise<TransactionStatus & {
|
|
73
74
|
status: IntentOpStatus["status"];
|
|
74
75
|
}>;
|
|
75
76
|
splitIntents(input: SplitIntentsInput): Promise<SplitIntentsResult>;
|
|
76
77
|
}
|
|
77
|
-
export { RhinestoneSDK, createRhinestoneAccount, deployAccountsForOwners, walletClientToAccount, wrapParaAccount, OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, getSupportedTokens, getTokenAddress, getTokenDecimals, getAllSupportedChainsAndTokens, checkERC20AllowanceDirect, getPermit2Address,
|
|
78
|
-
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,
|
|
78
|
+
export { RhinestoneSDK, createRhinestoneAccount, deployAccountsForOwners, walletClientToAccount, wrapParaAccount, OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, getSupportedTokens, getTokenAddress, getTokenDecimals, getAllSupportedChainsAndTokens, checkERC20AllowanceDirect, getPermit2Address, };
|
|
79
|
+
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, PreparedQuotes, PreparedTransactionData, QuoteSelection, SignedTransactionData, TransactionResult, PreparedUserOperationData, SignedUserOperationData, UserOperationResult, AuxiliaryFunds, IntentInput, IntentOpStatus, SettlementLayer, SplitIntentsInput, SplitIntentsResult, Portfolio, TokenRequirements, WrapRequired, ApprovalRequired, };
|
|
79
80
|
//# 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,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,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,
|
|
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,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,yBAAyB,EAEzB,iBAAiB,EAClB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAG9B,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAQ7B,MAAM,mBAAmB,C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N,kBAAkB,EAClB,mCAAmC,EACnC,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,GACjB,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const provider_1 = require("./auth/provider");
|
|
12
|
-
const execution_1 = require("./execution");
|
|
13
|
-
const permit2_1 = require("./execution/permit2");
|
|
14
|
-
Object.defineProperty(exports, "checkERC20AllowanceDirect", { enumerable: true, get: function () { return permit2_1.checkERC20AllowanceDirect; } });
|
|
15
|
-
Object.defineProperty(exports, "getPermit2Address", { enumerable: true, get: function () { return permit2_1.getPermit2Address; } });
|
|
16
|
-
Object.defineProperty(exports, "signPermit2Batch", { enumerable: true, get: function () { return permit2_1.signPermit2Batch; } });
|
|
17
|
-
Object.defineProperty(exports, "signPermit2Sequential", { enumerable: true, get: function () { return permit2_1.signPermit2Sequential; } });
|
|
18
|
-
const utils_1 = require("./execution/utils");
|
|
19
|
-
const modules_1 = require("./modules");
|
|
20
|
-
Object.defineProperty(exports, "MULTI_FACTOR_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return modules_1.MULTI_FACTOR_VALIDATOR_ADDRESS; } });
|
|
21
|
-
Object.defineProperty(exports, "OWNABLE_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return modules_1.OWNABLE_VALIDATOR_ADDRESS; } });
|
|
22
|
-
Object.defineProperty(exports, "SMART_SESSION_EMISSARY_ADDRESS", { enumerable: true, get: function () { return modules_1.SMART_SESSION_EMISSARY_ADDRESS; } });
|
|
23
|
-
Object.defineProperty(exports, "WEBAUTHN_VALIDATOR_ADDRESS", { enumerable: true, get: function () { return modules_1.WEBAUTHN_VALIDATOR_ADDRESS; } });
|
|
24
|
-
const smart_sessions_1 = require("./modules/validators/smart-sessions");
|
|
25
|
-
const orchestrator_1 = require("./orchestrator");
|
|
26
|
-
Object.defineProperty(exports, "getAllSupportedChainsAndTokens", { enumerable: true, get: function () { return orchestrator_1.getAllSupportedChainsAndTokens; } });
|
|
27
|
-
Object.defineProperty(exports, "getSupportedTokens", { enumerable: true, get: function () { return orchestrator_1.getSupportedTokens; } });
|
|
28
|
-
Object.defineProperty(exports, "getTokenAddress", { enumerable: true, get: function () { return orchestrator_1.getTokenAddress; } });
|
|
29
|
-
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, } 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';
|
|
30
11
|
/**
|
|
31
12
|
* Initialize a Rhinestone account
|
|
32
13
|
* Note: accounts are deployed onchain only when the first transaction is sent.
|
|
@@ -36,10 +17,10 @@ Object.defineProperty(exports, "getTokenDecimals", { enumerable: true, get: func
|
|
|
36
17
|
async function createRhinestoneAccount(config) {
|
|
37
18
|
// Sanity check for existing (externally created) accounts
|
|
38
19
|
// Ensures we decode the initdata correctly
|
|
39
|
-
|
|
20
|
+
checkAddress(config);
|
|
40
21
|
// Validate that owners field is provided for non-EOA accounts
|
|
41
22
|
if (config.account?.type !== 'eoa' && !config.owners) {
|
|
42
|
-
throw new
|
|
23
|
+
throw new OwnersFieldRequiredError();
|
|
43
24
|
}
|
|
44
25
|
/**
|
|
45
26
|
* Deploys the account on a given chain
|
|
@@ -47,7 +28,7 @@ async function createRhinestoneAccount(config) {
|
|
|
47
28
|
* @param session Session to deploy the account on (optional)
|
|
48
29
|
*/
|
|
49
30
|
function deploy(chain, params) {
|
|
50
|
-
return (
|
|
31
|
+
return deployInternal(config, chain, params);
|
|
51
32
|
}
|
|
52
33
|
/**
|
|
53
34
|
* Checks if the account is deployed on a given chain
|
|
@@ -55,7 +36,7 @@ async function createRhinestoneAccount(config) {
|
|
|
55
36
|
* @returns true if the account is deployed, false otherwise
|
|
56
37
|
*/
|
|
57
38
|
function isDeployed(chain) {
|
|
58
|
-
return (
|
|
39
|
+
return isDeployedInternal(config, chain);
|
|
59
40
|
}
|
|
60
41
|
/**
|
|
61
42
|
* Sets up the existing account on a given chain
|
|
@@ -63,19 +44,19 @@ async function createRhinestoneAccount(config) {
|
|
|
63
44
|
* @param chain Chain to set up the account on
|
|
64
45
|
*/
|
|
65
46
|
function setup(chain) {
|
|
66
|
-
return (
|
|
47
|
+
return setupInternal(config, chain);
|
|
67
48
|
}
|
|
68
49
|
/**
|
|
69
50
|
* Get the account initialization data. Used for deploying the account onchain.
|
|
70
51
|
* @returns factory address and factory data
|
|
71
52
|
*/
|
|
72
53
|
function getInitData() {
|
|
73
|
-
const initData =
|
|
54
|
+
const initData = getInitCode(config);
|
|
74
55
|
if (!initData) {
|
|
75
|
-
throw new
|
|
56
|
+
throw new FactoryArgsNotAvailableError();
|
|
76
57
|
}
|
|
77
58
|
if (!('factory' in initData)) {
|
|
78
|
-
throw new
|
|
59
|
+
throw new FactoryArgsNotAvailableError();
|
|
79
60
|
}
|
|
80
61
|
return {
|
|
81
62
|
factory: initData.factory,
|
|
@@ -87,7 +68,7 @@ async function createRhinestoneAccount(config) {
|
|
|
87
68
|
* @returns init data signature
|
|
88
69
|
*/
|
|
89
70
|
function signEip7702InitData() {
|
|
90
|
-
return (
|
|
71
|
+
return signEip7702InitDataInternal(config);
|
|
91
72
|
}
|
|
92
73
|
/**
|
|
93
74
|
* Prepare a transaction data
|
|
@@ -95,24 +76,26 @@ async function createRhinestoneAccount(config) {
|
|
|
95
76
|
* @returns prepared transaction data
|
|
96
77
|
*/
|
|
97
78
|
function prepareTransaction(transaction) {
|
|
98
|
-
return (
|
|
79
|
+
return prepareTransactionInternal(config, transaction);
|
|
99
80
|
}
|
|
100
81
|
/**
|
|
101
82
|
* Get the transaction typed data message to sign
|
|
102
83
|
* @param preparedTransaction Prepared transaction data
|
|
84
|
+
* @param options Optional override; pass `{ intentId }` to inspect a specific quote from `preparedTransaction.quotes.all`
|
|
103
85
|
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
104
86
|
*/
|
|
105
|
-
function getTransactionMessages(preparedTransaction) {
|
|
106
|
-
return (
|
|
87
|
+
function getTransactionMessages(preparedTransaction, options) {
|
|
88
|
+
return getTransactionMessagesInternal(config, preparedTransaction, options);
|
|
107
89
|
}
|
|
108
90
|
/**
|
|
109
91
|
* Sign a transaction
|
|
110
92
|
* @param preparedTransaction Prepared transaction data
|
|
93
|
+
* @param options Optional override; pass `{ intentId }` to sign a specific quote from `preparedTransaction.quotes.all`
|
|
111
94
|
* @returns signed transaction data
|
|
112
95
|
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
113
96
|
*/
|
|
114
|
-
function signTransaction(preparedTransaction) {
|
|
115
|
-
return (
|
|
97
|
+
function signTransaction(preparedTransaction, options) {
|
|
98
|
+
return signTransactionInternal(config, preparedTransaction, options);
|
|
116
99
|
}
|
|
117
100
|
/**
|
|
118
101
|
* Sign the required EIP-7702 authorizations for a transaction
|
|
@@ -121,7 +104,7 @@ async function createRhinestoneAccount(config) {
|
|
|
121
104
|
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
122
105
|
*/
|
|
123
106
|
function signAuthorizations(preparedTransaction) {
|
|
124
|
-
return (
|
|
107
|
+
return signAuthorizationsInternal(config, preparedTransaction);
|
|
125
108
|
}
|
|
126
109
|
/**
|
|
127
110
|
* Sign a message (EIP-191)
|
|
@@ -131,7 +114,7 @@ async function createRhinestoneAccount(config) {
|
|
|
131
114
|
* @returns signature
|
|
132
115
|
*/
|
|
133
116
|
function signMessage(message, chain, signers) {
|
|
134
|
-
return (
|
|
117
|
+
return signMessageInternal(config, message, chain, signers);
|
|
135
118
|
}
|
|
136
119
|
/**
|
|
137
120
|
* Sign a typed data (EIP-712)
|
|
@@ -141,7 +124,7 @@ async function createRhinestoneAccount(config) {
|
|
|
141
124
|
* @returns signature
|
|
142
125
|
*/
|
|
143
126
|
function signTypedData(parameters, chain, signers) {
|
|
144
|
-
return (
|
|
127
|
+
return signTypedDataInternal(config, parameters, chain, signers);
|
|
145
128
|
}
|
|
146
129
|
/**
|
|
147
130
|
* Submit a transaction
|
|
@@ -153,7 +136,7 @@ async function createRhinestoneAccount(config) {
|
|
|
153
136
|
* @see {@link dryRun} true when intent is not executed onchain (internal use only)
|
|
154
137
|
*/
|
|
155
138
|
function submitTransaction(signedTransaction, authorizations, dryRun) {
|
|
156
|
-
return (
|
|
139
|
+
return submitTransactionInternal(config, signedTransaction, authorizations ?? [], dryRun);
|
|
157
140
|
}
|
|
158
141
|
/**
|
|
159
142
|
* Prepare a user operation data
|
|
@@ -161,7 +144,7 @@ async function createRhinestoneAccount(config) {
|
|
|
161
144
|
* @returns prepared user operation data
|
|
162
145
|
*/
|
|
163
146
|
function prepareUserOperation(transaction) {
|
|
164
|
-
return (
|
|
147
|
+
return prepareUserOperationInternal(config, transaction);
|
|
165
148
|
}
|
|
166
149
|
/**
|
|
167
150
|
* Sign a user operation
|
|
@@ -170,7 +153,7 @@ async function createRhinestoneAccount(config) {
|
|
|
170
153
|
* @see {@link prepareUserOperation} to prepare the user operation data for signing
|
|
171
154
|
*/
|
|
172
155
|
function signUserOperation(preparedUserOperation) {
|
|
173
|
-
return (
|
|
156
|
+
return signUserOperationInternal(config, preparedUserOperation);
|
|
174
157
|
}
|
|
175
158
|
/**
|
|
176
159
|
* Submit a transaction
|
|
@@ -179,7 +162,7 @@ async function createRhinestoneAccount(config) {
|
|
|
179
162
|
* @see {@link signUserOperation} to sign the user operation data
|
|
180
163
|
*/
|
|
181
164
|
function submitUserOperation(signedUserOperation) {
|
|
182
|
-
return (
|
|
165
|
+
return submitUserOperationInternal(config, signedUserOperation);
|
|
183
166
|
}
|
|
184
167
|
/**
|
|
185
168
|
* Sign and send a transaction
|
|
@@ -187,7 +170,7 @@ async function createRhinestoneAccount(config) {
|
|
|
187
170
|
* @returns transaction result object (an intent ID)
|
|
188
171
|
*/
|
|
189
172
|
function sendTransaction(transaction) {
|
|
190
|
-
return (
|
|
173
|
+
return sendTransactionInternal(config, transaction);
|
|
191
174
|
}
|
|
192
175
|
/**
|
|
193
176
|
* Sign and send a user operation
|
|
@@ -195,17 +178,17 @@ async function createRhinestoneAccount(config) {
|
|
|
195
178
|
* @returns user operation result object (a UserOp hash)
|
|
196
179
|
*/
|
|
197
180
|
function sendUserOperation(transaction) {
|
|
198
|
-
return (
|
|
181
|
+
return sendUserOperationInternal(config, transaction);
|
|
199
182
|
}
|
|
200
183
|
function waitForExecution(result, acceptsPreconfirmations = true) {
|
|
201
|
-
return (
|
|
184
|
+
return waitForExecutionInternal(config, result, acceptsPreconfirmations);
|
|
202
185
|
}
|
|
203
186
|
/**
|
|
204
187
|
* Get account address
|
|
205
188
|
* @returns Address of the smart account
|
|
206
189
|
*/
|
|
207
190
|
function getAddress() {
|
|
208
|
-
return (
|
|
191
|
+
return getAddressInternal(config);
|
|
209
192
|
}
|
|
210
193
|
/**
|
|
211
194
|
* Get account portfolio
|
|
@@ -213,7 +196,7 @@ async function createRhinestoneAccount(config) {
|
|
|
213
196
|
* @returns Account balances
|
|
214
197
|
*/
|
|
215
198
|
function getPortfolio(onTestnets = false) {
|
|
216
|
-
return (
|
|
199
|
+
return getPortfolioInternal(config, onTestnets);
|
|
217
200
|
}
|
|
218
201
|
/**
|
|
219
202
|
* Get account owners (ECDSA)
|
|
@@ -222,7 +205,7 @@ async function createRhinestoneAccount(config) {
|
|
|
222
205
|
*/
|
|
223
206
|
function getOwners(chain) {
|
|
224
207
|
const account = getAddress();
|
|
225
|
-
return (
|
|
208
|
+
return getOwnersInternal(account, chain, config.provider);
|
|
226
209
|
}
|
|
227
210
|
/**
|
|
228
211
|
* Get account validator modules
|
|
@@ -230,25 +213,25 @@ async function createRhinestoneAccount(config) {
|
|
|
230
213
|
* @returns List of account validators
|
|
231
214
|
*/
|
|
232
215
|
function getValidators(chain) {
|
|
233
|
-
const accountType =
|
|
216
|
+
const accountType = getAccountProvider(config).type;
|
|
234
217
|
const account = getAddress();
|
|
235
|
-
return (
|
|
218
|
+
return getValidatorsInternal(accountType, account, chain, config.provider);
|
|
236
219
|
}
|
|
237
220
|
function getExecutors(chain) {
|
|
238
|
-
const accountType =
|
|
221
|
+
const accountType = getAccountProvider(config).type;
|
|
239
222
|
const account = getAddress();
|
|
240
|
-
return (
|
|
223
|
+
return getExecutorsInternal(accountType, account, chain, config.provider);
|
|
241
224
|
}
|
|
242
225
|
function experimental_getSessionDetails(sessions) {
|
|
243
226
|
const account = getAddress();
|
|
244
|
-
return (
|
|
227
|
+
return getSessionDetailsInternal(account, sessions, config.provider, config.useDevContracts);
|
|
245
228
|
}
|
|
246
229
|
function experimental_isSessionEnabled(session) {
|
|
247
230
|
const account = getAddress();
|
|
248
|
-
return (
|
|
231
|
+
return isSessionEnabledInternal(account, config.provider, session, config.useDevContracts);
|
|
249
232
|
}
|
|
250
233
|
function experimental_signEnableSession(details) {
|
|
251
|
-
return (
|
|
234
|
+
return signEnableSessionInternal(config, details);
|
|
252
235
|
}
|
|
253
236
|
/**
|
|
254
237
|
* Check ERC20 allowance for the account owner and token (using Permit2 as spender)
|
|
@@ -260,7 +243,7 @@ async function createRhinestoneAccount(config) {
|
|
|
260
243
|
if (!config.provider) {
|
|
261
244
|
throw new Error('Provider configuration is required');
|
|
262
245
|
}
|
|
263
|
-
return (
|
|
246
|
+
return checkERC20AllowanceInternal(tokenAddress, chain, config);
|
|
264
247
|
}
|
|
265
248
|
return {
|
|
266
249
|
config,
|
|
@@ -302,7 +285,7 @@ class RhinestoneSDK {
|
|
|
302
285
|
useDevContracts;
|
|
303
286
|
headers;
|
|
304
287
|
constructor(options) {
|
|
305
|
-
this.authProvider =
|
|
288
|
+
this.authProvider = createAuthProvider(options);
|
|
306
289
|
this.endpointUrl = options.endpointUrl;
|
|
307
290
|
this.provider = options.provider;
|
|
308
291
|
this.bundler = options.bundler;
|
|
@@ -324,10 +307,16 @@ class RhinestoneSDK {
|
|
|
324
307
|
return createRhinestoneAccount(rhinestoneConfig);
|
|
325
308
|
}
|
|
326
309
|
getIntentStatus(intentId) {
|
|
327
|
-
return (
|
|
310
|
+
return getIntentStatusInternal(this.authProvider, this.endpointUrl, intentId, this.headers);
|
|
328
311
|
}
|
|
329
312
|
splitIntents(input) {
|
|
330
|
-
return (
|
|
313
|
+
return splitIntentsInternal(this.authProvider, this.endpointUrl, input, this.headers);
|
|
331
314
|
}
|
|
332
315
|
}
|
|
333
|
-
|
|
316
|
+
export { RhinestoneSDK, createRhinestoneAccount, deployAccountsForOwners, walletClientToAccount, wrapParaAccount,
|
|
317
|
+
// Validator addresses
|
|
318
|
+
OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS,
|
|
319
|
+
// Registry functions
|
|
320
|
+
getSupportedTokens, getTokenAddress, getTokenDecimals, getAllSupportedChainsAndTokens,
|
|
321
|
+
// Permit2 helpers
|
|
322
|
+
checkERC20AllowanceDirect, getPermit2Address, };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.computeIntentInputDigest = computeIntentInputDigest;
|
|
4
|
-
const jcs_1 = require("./jcs");
|
|
1
|
+
import { jcsCanonicalise } from './jcs.js';
|
|
5
2
|
/**
|
|
6
3
|
* Compute a deterministic hex-encoded SHA-256 digest of an intent input object.
|
|
7
4
|
*
|
|
@@ -11,8 +8,8 @@ const jcs_1 = require("./jcs");
|
|
|
11
8
|
*
|
|
12
9
|
* Uses the Web Crypto API (available in Node.js ≥ 15 and all modern browsers).
|
|
13
10
|
*/
|
|
14
|
-
async function computeIntentInputDigest(intentInput) {
|
|
15
|
-
const canonical =
|
|
11
|
+
export async function computeIntentInputDigest(intentInput) {
|
|
12
|
+
const canonical = jcsCanonicalise(intentInput);
|
|
16
13
|
const encoded = new TextEncoder().encode(canonical);
|
|
17
14
|
const hashBuffer = await crypto.subtle.digest('SHA-256', encoded);
|
|
18
15
|
const hashArray = new Uint8Array(hashBuffer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../jwt-server/express.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function createExpressRouter(config) {
|
|
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) {
|
|
6
5
|
// Dynamic import avoidance: we type the router interface manually
|
|
7
6
|
// so express doesn't need to be installed unless this function is called.
|
|
8
7
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
9
8
|
const { Router } = require('express');
|
|
10
9
|
const router = Router();
|
|
11
|
-
const handleAccessToken =
|
|
12
|
-
const handleExtensionToken =
|
|
10
|
+
const handleAccessToken = createCoreAccessTokenHandler(config);
|
|
11
|
+
const handleExtensionToken = createCoreExtensionTokenHandler(config);
|
|
13
12
|
router.get('/access-token', async (_req, res) => {
|
|
14
13
|
const result = await handleAccessToken();
|
|
15
14
|
res.status(result.status).json(result.body);
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const signer_1 = require("./signer");
|
|
6
|
-
const sponsorship_1 = require("./sponsorship");
|
|
7
|
-
function createCoreAccessTokenHandler(config) {
|
|
8
|
-
const signer = (0, signer_1.createJwtSigner)(config);
|
|
1
|
+
import { createJwtSigner } from './signer.js';
|
|
2
|
+
import { SponsorshipDeniedError } from './sponsorship.js';
|
|
3
|
+
export function createCoreAccessTokenHandler(config) {
|
|
4
|
+
const signer = createJwtSigner(config);
|
|
9
5
|
return async () => {
|
|
10
6
|
try {
|
|
11
7
|
const token = await signer.accessToken();
|
|
@@ -17,8 +13,8 @@ function createCoreAccessTokenHandler(config) {
|
|
|
17
13
|
}
|
|
18
14
|
};
|
|
19
15
|
}
|
|
20
|
-
function createCoreExtensionTokenHandler(config) {
|
|
21
|
-
const signer =
|
|
16
|
+
export function createCoreExtensionTokenHandler(config) {
|
|
17
|
+
const signer = createJwtSigner(config);
|
|
22
18
|
return async (intentInput) => {
|
|
23
19
|
if (intentInput === undefined || intentInput === null) {
|
|
24
20
|
return {
|
|
@@ -31,7 +27,7 @@ function createCoreExtensionTokenHandler(config) {
|
|
|
31
27
|
return { status: 200, body: { token } };
|
|
32
28
|
}
|
|
33
29
|
catch (error) {
|
|
34
|
-
if (error instanceof
|
|
30
|
+
if (error instanceof SponsorshipDeniedError) {
|
|
35
31
|
return { status: 403, body: { error: error.message } };
|
|
36
32
|
}
|
|
37
33
|
const message = error instanceof Error ? error.message : 'Internal server error';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { computeIntentInputDigest } from './digest';
|
|
2
|
-
export { createExpressRouter } from './express';
|
|
3
|
-
export type { JwtHandlerConfig } from './handlers';
|
|
4
|
-
export { jcsCanonicalise } from './jcs';
|
|
5
|
-
export { createJwtSigner, type JwtCredentials, type JwtSignerConfig, } from './signer';
|
|
6
|
-
export { SponsorshipDeniedError, type SponsorshipFilter, shouldSponsor, } from './sponsorship';
|
|
7
|
-
export { createAccessTokenHandler, createExtensionTokenHandler, } from './web';
|
|
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
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createExtensionTokenHandler = exports.createAccessTokenHandler = exports.shouldSponsor = exports.SponsorshipDeniedError = exports.createJwtSigner = exports.jcsCanonicalise = exports.createExpressRouter = exports.computeIntentInputDigest = void 0;
|
|
4
1
|
// biome-ignore lint/performance/noBarrelFile: subpath entry point for @rhinestone/sdk/jwt-server
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var signer_1 = require("./signer");
|
|
12
|
-
Object.defineProperty(exports, "createJwtSigner", { enumerable: true, get: function () { return signer_1.createJwtSigner; } });
|
|
13
|
-
var sponsorship_1 = require("./sponsorship");
|
|
14
|
-
Object.defineProperty(exports, "SponsorshipDeniedError", { enumerable: true, get: function () { return sponsorship_1.SponsorshipDeniedError; } });
|
|
15
|
-
Object.defineProperty(exports, "shouldSponsor", { enumerable: true, get: function () { return sponsorship_1.shouldSponsor; } });
|
|
16
|
-
var web_1 = require("./web");
|
|
17
|
-
Object.defineProperty(exports, "createAccessTokenHandler", { enumerable: true, get: function () { return web_1.createAccessTokenHandler; } });
|
|
18
|
-
Object.defineProperty(exports, "createExtensionTokenHandler", { enumerable: true, get: function () { return web_1.createExtensionTokenHandler; } });
|
|
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';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* RFC 8785 JSON Canonicalization Scheme (JCS).
|
|
4
3
|
*
|
|
@@ -9,9 +8,7 @@
|
|
|
9
8
|
*
|
|
10
9
|
* Reference: https://www.rfc-editor.org/rfc/rfc8785
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
exports.jcsCanonicalise = jcsCanonicalise;
|
|
14
|
-
function jcsCanonicalise(value) {
|
|
11
|
+
export function jcsCanonicalise(value) {
|
|
15
12
|
return serialize(value);
|
|
16
13
|
}
|
|
17
14
|
function serialize(value) {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jose_1 = require("jose");
|
|
5
|
-
const digest_1 = require("./digest");
|
|
6
|
-
const sponsorship_1 = require("./sponsorship");
|
|
1
|
+
import { importJWK, SignJWT } from 'jose';
|
|
2
|
+
import { computeIntentInputDigest } from './digest.js';
|
|
3
|
+
import { shouldSponsor as checkSponsor, SponsorshipDeniedError, } from './sponsorship.js';
|
|
7
4
|
function pickAlg(jwk) {
|
|
8
5
|
if (jwk.kty === 'EC') {
|
|
9
6
|
if (jwk.crv === 'P-256')
|
|
@@ -18,19 +15,19 @@ function pickAlg(jwk) {
|
|
|
18
15
|
return 'RS256';
|
|
19
16
|
throw new Error(`Unsupported JWK kty: ${jwk.kty}`);
|
|
20
17
|
}
|
|
21
|
-
function createJwtSigner(config) {
|
|
18
|
+
export function createJwtSigner(config) {
|
|
22
19
|
const { jwt: { privateKey, integratorId, projectId, appId, keyId, audience = 'rhinestone-api', }, shouldSponsor: filters, } = config;
|
|
23
20
|
const alg = pickAlg(privateKey);
|
|
24
21
|
let cachedKey = null;
|
|
25
22
|
async function getKey() {
|
|
26
23
|
if (!cachedKey) {
|
|
27
|
-
cachedKey = (await
|
|
24
|
+
cachedKey = (await importJWK(privateKey, alg));
|
|
28
25
|
}
|
|
29
26
|
return cachedKey;
|
|
30
27
|
}
|
|
31
28
|
async function accessToken() {
|
|
32
29
|
const key = await getKey();
|
|
33
|
-
return new
|
|
30
|
+
return new SignJWT({ typ: 'access', app_id: appId })
|
|
34
31
|
.setProtectedHeader({ alg, kid: keyId })
|
|
35
32
|
.setIssuer(integratorId)
|
|
36
33
|
.setSubject(projectId)
|
|
@@ -41,14 +38,14 @@ function createJwtSigner(config) {
|
|
|
41
38
|
}
|
|
42
39
|
async function getIntentExtensionToken(intentInput) {
|
|
43
40
|
if (filters) {
|
|
44
|
-
const allowed = await (
|
|
41
|
+
const allowed = await checkSponsor(intentInput, filters);
|
|
45
42
|
if (!allowed) {
|
|
46
|
-
throw new
|
|
43
|
+
throw new SponsorshipDeniedError();
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
46
|
const key = await getKey();
|
|
50
|
-
const digest = await
|
|
51
|
-
return new
|
|
47
|
+
const digest = await computeIntentInputDigest(intentInput);
|
|
48
|
+
return new SignJWT({
|
|
52
49
|
typ: 'intent_extension',
|
|
53
50
|
app_id: appId,
|
|
54
51
|
jti: crypto.randomUUID(),
|