@aastar/sdk 0.23.0 → 0.24.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.
Files changed (105) hide show
  1. package/dist/UserClient-KYDCMAIU.js +6 -0
  2. package/dist/{UserClient-XTHQ2AP3.js.map → UserClient-KYDCMAIU.js.map} +1 -1
  3. package/dist/UserClient-S6LS3CB6.cjs +15 -0
  4. package/dist/{UserClient-J3JPDIG7.cjs.map → UserClient-S6LS3CB6.cjs.map} +1 -1
  5. package/dist/account.cjs +7 -7
  6. package/dist/account.js +2 -2
  7. package/dist/admin.cjs +3 -3
  8. package/dist/admin.js +2 -2
  9. package/dist/airaccount.cjs +102 -102
  10. package/dist/airaccount.js +2 -2
  11. package/dist/channel.cjs +6 -6
  12. package/dist/channel.js +2 -2
  13. package/dist/{chunk-CGKPULZX.cjs → chunk-5PH5CSM7.cjs} +16 -16
  14. package/dist/{chunk-CGKPULZX.cjs.map → chunk-5PH5CSM7.cjs.map} +1 -1
  15. package/dist/{chunk-EZC7Q3SG.js → chunk-654GQ7G7.js} +3 -3
  16. package/dist/{chunk-EZC7Q3SG.js.map → chunk-654GQ7G7.js.map} +1 -1
  17. package/dist/{chunk-W4ENVPZH.cjs → chunk-72JZKARR.cjs} +6 -6
  18. package/dist/{chunk-W4ENVPZH.cjs.map → chunk-72JZKARR.cjs.map} +1 -1
  19. package/dist/{chunk-H5EQBNC6.js → chunk-7RVONA2R.js} +8 -8
  20. package/dist/{chunk-H5EQBNC6.js.map → chunk-7RVONA2R.js.map} +1 -1
  21. package/dist/{chunk-2GZMRCQW.cjs → chunk-A4ICWCHR.cjs} +5 -5
  22. package/dist/{chunk-2GZMRCQW.cjs.map → chunk-A4ICWCHR.cjs.map} +1 -1
  23. package/dist/{chunk-6PJAHZZ2.cjs → chunk-BOVDJSMK.cjs} +26 -26
  24. package/dist/{chunk-6PJAHZZ2.cjs.map → chunk-BOVDJSMK.cjs.map} +1 -1
  25. package/dist/{chunk-5G5SB6CP.js → chunk-BYVG7MO7.js} +34 -3
  26. package/dist/chunk-BYVG7MO7.js.map +1 -0
  27. package/dist/{chunk-E37CPC2U.cjs → chunk-D667CUUS.cjs} +9 -9
  28. package/dist/{chunk-E37CPC2U.cjs.map → chunk-D667CUUS.cjs.map} +1 -1
  29. package/dist/{chunk-PFMCPSS4.js → chunk-DAMWXGKD.js} +3 -3
  30. package/dist/{chunk-PFMCPSS4.js.map → chunk-DAMWXGKD.js.map} +1 -1
  31. package/dist/{chunk-XFJSY5LG.cjs → chunk-GDH4DSVM.cjs} +12 -12
  32. package/dist/{chunk-XFJSY5LG.cjs.map → chunk-GDH4DSVM.cjs.map} +1 -1
  33. package/dist/{chunk-UULR2KA6.cjs → chunk-HNJBQR5U.cjs} +5 -5
  34. package/dist/{chunk-UULR2KA6.cjs.map → chunk-HNJBQR5U.cjs.map} +1 -1
  35. package/dist/{chunk-2DDWYKF2.js → chunk-JMW5AHLC.js} +9 -9
  36. package/dist/{chunk-2DDWYKF2.js.map → chunk-JMW5AHLC.js.map} +1 -1
  37. package/dist/{chunk-D23CZFOM.js → chunk-LDARLWS3.js} +3 -3
  38. package/dist/{chunk-D23CZFOM.js.map → chunk-LDARLWS3.js.map} +1 -1
  39. package/dist/{chunk-MFBTMF5U.cjs → chunk-MOJJ7QF6.cjs} +39 -2
  40. package/dist/{chunk-MFBTMF5U.cjs.map → chunk-MOJJ7QF6.cjs.map} +1 -1
  41. package/dist/{chunk-6I22EW6V.cjs → chunk-NVYVTCHJ.cjs} +11 -11
  42. package/dist/{chunk-6I22EW6V.cjs.map → chunk-NVYVTCHJ.cjs.map} +1 -1
  43. package/dist/{chunk-SXLWFZFX.js → chunk-PNBK2CLK.js} +3 -3
  44. package/dist/{chunk-SXLWFZFX.js.map → chunk-PNBK2CLK.js.map} +1 -1
  45. package/dist/{chunk-2UDF62XV.js → chunk-PXQDAFXD.js} +6 -6
  46. package/dist/{chunk-2UDF62XV.js.map → chunk-PXQDAFXD.js.map} +1 -1
  47. package/dist/{chunk-2WBSYPUY.js → chunk-RZ2M2RVP.js} +3 -3
  48. package/dist/{chunk-2WBSYPUY.js.map → chunk-RZ2M2RVP.js.map} +1 -1
  49. package/dist/{chunk-PKYWLTIJ.cjs → chunk-VHY6R2PI.cjs} +32 -32
  50. package/dist/{chunk-PKYWLTIJ.cjs.map → chunk-VHY6R2PI.cjs.map} +1 -1
  51. package/dist/{chunk-UMTCWOQV.js → chunk-WC25H5VG.js} +4 -4
  52. package/dist/{chunk-UMTCWOQV.js.map → chunk-WC25H5VG.js.map} +1 -1
  53. package/dist/{chunk-TM2LH4ZE.js → chunk-WVJ4LQVB.js} +3 -3
  54. package/dist/{chunk-TM2LH4ZE.js.map → chunk-WVJ4LQVB.js.map} +1 -1
  55. package/dist/{chunk-UQMMEDHO.cjs → chunk-WVOJV4Q5.cjs} +4 -4
  56. package/dist/{chunk-UQMMEDHO.cjs.map → chunk-WVOJV4Q5.cjs.map} +1 -1
  57. package/dist/{chunk-LAZA3JD7.cjs → chunk-Y5U7URNZ.cjs} +83 -5
  58. package/dist/chunk-Y5U7URNZ.cjs.map +1 -0
  59. package/dist/{chunk-V65JXHM6.js → chunk-YUFQIYLR.js} +83 -5
  60. package/dist/chunk-YUFQIYLR.js.map +1 -0
  61. package/dist/core.cjs +226 -202
  62. package/dist/core.d.cts +101 -1
  63. package/dist/core.d.ts +101 -1
  64. package/dist/core.js +1 -1
  65. package/dist/dapp.cjs +5 -5
  66. package/dist/dapp.js +2 -2
  67. package/dist/enduser.cjs +6 -6
  68. package/dist/enduser.js +3 -3
  69. package/dist/identity.cjs +5 -5
  70. package/dist/identity.js +2 -2
  71. package/dist/index.cjs +327 -303
  72. package/dist/index.d.cts +1 -1
  73. package/dist/index.d.ts +1 -1
  74. package/dist/index.js +15 -15
  75. package/dist/kms.cjs +102 -102
  76. package/dist/kms.d.cts +41 -1
  77. package/dist/kms.d.ts +41 -1
  78. package/dist/kms.js +2 -2
  79. package/dist/operator.cjs +6 -6
  80. package/dist/operator.js +2 -2
  81. package/dist/paymaster.cjs +15 -15
  82. package/dist/paymaster.js +2 -2
  83. package/dist/src-5URXSFKD.js +5 -0
  84. package/dist/src-5URXSFKD.js.map +1 -0
  85. package/dist/{src-HECKBVR2.cjs → src-72GWEAPA.cjs} +17 -17
  86. package/dist/src-72GWEAPA.cjs.map +1 -0
  87. package/dist/{src-4Q2WFLO2.cjs → src-N72HAQXS.cjs} +228 -204
  88. package/dist/src-N72HAQXS.cjs.map +1 -0
  89. package/dist/{src-KLP4Q2Y3.js → src-UNS5B7FX.js} +4 -4
  90. package/dist/src-UNS5B7FX.js.map +1 -0
  91. package/dist/tokens.cjs +3 -3
  92. package/dist/tokens.js +2 -2
  93. package/dist/x402.cjs +25 -25
  94. package/dist/x402.js +2 -2
  95. package/package.json +1 -1
  96. package/dist/UserClient-J3JPDIG7.cjs +0 -15
  97. package/dist/UserClient-XTHQ2AP3.js +0 -6
  98. package/dist/chunk-5G5SB6CP.js.map +0 -1
  99. package/dist/chunk-LAZA3JD7.cjs.map +0 -1
  100. package/dist/chunk-V65JXHM6.js.map +0 -1
  101. package/dist/src-2P72LYVT.js +0 -5
  102. package/dist/src-2P72LYVT.js.map +0 -1
  103. package/dist/src-4Q2WFLO2.cjs.map +0 -1
  104. package/dist/src-HECKBVR2.cjs.map +0 -1
  105. package/dist/src-KLP4Q2Y3.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { selectorFromId, keccak256, solidityPacked, ERC4337Utils, BLSManager, resolveTier, algIdForTier, encodeAbiParams, ecdsa, ALG_CUMULATIVE_T3, ALG_CUMULATIVE_T2, ALG_P256, ALG_ECDSA, ALG_BLS, weierstrass, sha256 } from './chunk-X3AMH53O.js';
2
- import { buildInitConfig } from './chunk-5G5SB6CP.js';
3
- import { CANONICAL_ADDRESSES } from './chunk-UCLK6LTB.js';
4
- import { parseAbi, createPublicClient, http, getContract, formatEther, parseUnits, parseEther, encodeFunctionData, concat, numberToHex, zeroAddress, hexToBytes, formatUnits, encodeAbiParameters, keccak256 as keccak256$1, hashMessage as hashMessage$1, toRlp, concatHex, recoverAddress as recoverAddress$1 } from 'viem';
2
+ import { buildInitConfig, needsValidatorRouter, airAccountActions } from './chunk-BYVG7MO7.js';
3
+ import { CANONICAL_ADDRESSES, getCanonicalAddresses } from './chunk-UCLK6LTB.js';
4
+ import { parseAbi, createPublicClient, http, getContract, formatEther, parseUnits, parseEther, encodeFunctionData, zeroAddress, concat, numberToHex, hexToBytes, formatUnits, encodeAbiParameters, keccak256 as keccak256$1, hashMessage as hashMessage$1, toRlp, concatHex, recoverAddress as recoverAddress$1 } from 'viem';
5
5
  import axios from 'axios';
6
6
  import { createHash } from 'crypto';
7
7
  import { privateKeyToAccount } from 'viem/accounts';
@@ -465,6 +465,10 @@ var EthereumProvider = class {
465
465
  getBundlerProvider() {
466
466
  return this.bundlerProvider;
467
467
  }
468
+ /** EVM chain id from the validated ServerConfig (deterministic — no RPC round-trip). */
469
+ getChainId() {
470
+ return this.config.chainId;
471
+ }
468
472
  /**
469
473
  * Raw bundler JSON-RPC call. The bundler exposes non-standard methods
470
474
  * (eth_sendUserOperation, pimlico_getUserOperationGasPrice, ...) that are not in
@@ -1099,8 +1103,82 @@ var AccountManager = class {
1099
1103
  this.logger.log(
1100
1104
  `[AccountManager] account created with ${params.p256Guardians.length} P-256 guardian(s): ${accountAddress}`
1101
1105
  );
1106
+ if (needsValidatorRouter(config.approvedAlgIds)) {
1107
+ this.logger.log(
1108
+ `[AccountManager] account ${accountAddress} approved a router-delegated algorithm (approvedAlgIds=[${config.approvedAlgIds.join(", ")}]); call ensureValidatorRouter(userId) AFTER the account is deployed to wire setValidator(router) \u2014 required for those algIds to validate.`
1109
+ );
1110
+ }
1102
1111
  return account;
1103
1112
  }
1113
+ /**
1114
+ * Gap B — wire the validator router for an account that approved a ROUTER-DELEGATED signature
1115
+ * algorithm (BLS 0x01, cumulative T2 0x04, T3 0x05, weighted 0x07, session 0x08, ...). Such an
1116
+ * account's `_validateTripleSignature` / `_callBLSValidator` return `1` (FAIL) while
1117
+ * `validator() == address(0)`, so the algorithm is non-functional until the owner calls
1118
+ * `setValidator(router)` (onlyOwner, SET-ONCE). Inline algIds (ECDSA 0x02, P256 0x03, COMBINED_T1
1119
+ * 0x06) need no router and are a no-op here.
1120
+ *
1121
+ * MUST be called AFTER the account is deployed (setValidator is onlyOwner and needs code) — the
1122
+ * lazy/counterfactual deploy path cannot setValidator at predict-time. Idempotent: re-running after
1123
+ * the validator is set is a no-op (`reason: 'validator already set'`).
1124
+ *
1125
+ * On-chain access matches the rest of this package: reads via the EthereumProvider's PublicClient
1126
+ * (`getAccountContract(...).read.validator()` and `getProvider().getCode()`); the state-changing
1127
+ * `setValidator` is sent through a caller-supplied `WalletClient` whose account is the owner —
1128
+ * the same convention used by `PaymasterManager.updatePrice` / `ForceExitService` (this manager's
1129
+ * narrow `ISignerAdapter` only EIP-191 personal-signs and cannot send transactions).
1130
+ *
1131
+ * @param userId the account owner's user id (storage key)
1132
+ * @param opts.router override the router address (defaults to the chain's canonical
1133
+ * `aaStarValidator`); pass to target a non-canonical router
1134
+ * @param opts.walletClient viem WalletClient signing as the account OWNER — REQUIRED to send the tx
1135
+ */
1136
+ async ensureValidatorRouter(userId, opts) {
1137
+ const account = await this.storage.findAccountByUserId(userId);
1138
+ if (!account) throw new Error("Account not found");
1139
+ const approvedAlgIds = account.approvedAlgIds;
1140
+ if (!approvedAlgIds || approvedAlgIds.length === 0) {
1141
+ return { set: false, reason: "no approvedAlgIds / not router-delegated" };
1142
+ }
1143
+ if (!needsValidatorRouter(approvedAlgIds)) {
1144
+ return { set: false, reason: "no router-delegated algorithm" };
1145
+ }
1146
+ const chainId = this.ethereum.getChainId();
1147
+ const canonicalRouter = getCanonicalAddresses(chainId)?.aaStarValidator;
1148
+ const router = opts?.router ?? canonicalRouter;
1149
+ if (!router || router.toLowerCase() === zeroAddress) {
1150
+ return { set: false, reason: `no canonical validator router for chain ${chainId}` };
1151
+ }
1152
+ let deployed = false;
1153
+ try {
1154
+ const code = await this.ethereum.getProvider().getCode({ address: account.address });
1155
+ deployed = !!code && code !== "0x";
1156
+ } catch {
1157
+ }
1158
+ if (!deployed) {
1159
+ return { set: false, reason: "account not deployed yet \u2014 call after deploy" };
1160
+ }
1161
+ const current = await this.ethereum.getAccountContract(account.address).read.validator([]);
1162
+ if (current && current.toLowerCase() !== zeroAddress) {
1163
+ return { set: false, reason: "validator already set" };
1164
+ }
1165
+ const walletClient = opts?.walletClient;
1166
+ if (!walletClient || !walletClient.account) {
1167
+ return {
1168
+ set: false,
1169
+ reason: "walletClient (account owner) required to send setValidator",
1170
+ router
1171
+ };
1172
+ }
1173
+ const tx = await airAccountActions(account.address)(walletClient).setValidator({
1174
+ validator: router,
1175
+ account: walletClient.account
1176
+ });
1177
+ this.logger.log(
1178
+ `[AccountManager] setValidator(${router}) sent for account ${account.address} (tx ${tx})`
1179
+ );
1180
+ return { set: true, tx, router };
1181
+ }
1104
1182
  };
1105
1183
  var EXECUTE_USER_OP_SELECTOR = selectorFromId(
1106
1184
  "executeUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)"
@@ -4864,5 +4942,5 @@ var LocalWalletSigner = class {
4864
4942
  */
4865
4943
 
4866
4944
  export { ACCOUNT_ABI, AGENT_SESSION_KEY_VALIDATOR_ABI, AIRACCOUNT_ABI, AIRACCOUNT_ADDRESSES, AIRACCOUNT_FACTORY_ABI, AIR_ACCOUNT_COMPOSITE_VALIDATOR_ABI, AIR_ACCOUNT_DELEGATE_ABI, AIR_ACCOUNT_DELEGATE_ADDRESS, ALG_ID, AccountManager, AgentRegistryService, AirAccountServerClient, BLSSignatureService, CALLDATA_PARSER_REGISTRY_ABI, ConsoleLogger, DEFAULT_CREDENTIAL_ID, DEFAULT_KMS_ENDPOINT, DEFAULT_ORIGIN, DEFAULT_RP_ID, DvtPendingConfirmationError, EIP7702DelegateService, ENTRYPOINT_ABI_V6, ENTRYPOINT_ABI_V7_V8, ENTRYPOINT_ADDRESSES, ERC20_ABI, ERC8004Service, ERC8004_ADDRESSES, EXECUTE_BATCH_SELECTOR, EXECUTE_SELECTOR, EXECUTE_USER_OP_SELECTOR, EntryPointVersion, EthereumProvider, FACTORY_ABI_V6, FACTORY_ABI_V7_V8, FORCE_EXIT_MODULE_ABI, ForceExitService, GLOBAL_GUARD_ABI, GuardChecker, GuardStateReader, KmsAgentService, KmsHttpClient, KmsManager, KmsMonitorService, KmsPaymentSigner, KmsSessionService, KmsSigner, L2_TYPE, LocalWalletSigner, MAX_GUARDIANS, MODULE_TYPE, MemoryStorage, ModuleManager, P256PasskeySigner, PaymasterManager, PaymasterPriceStalenessError, RECOVERY_THRESHOLD, RECOVERY_TIMELOCK_SECONDS, RecoveryService, SESSION_KEY_VALIDATOR_ABI, SessionKeyService, SilentLogger, TIER_GUARD_HOOK_ABI, TokenService, TransferManager, VALIDATOR_ABI, WEIGHT_CHANGE_EXPIRY_SECONDS, WEIGHT_CHANGE_THRESHOLD, WEIGHT_CHANGE_TIMELOCK_SECONDS, WalletManager, WeightedSignatureService, YAAAServerClient, base64UrlDecode, base64UrlEncode, beginAuthenticationChallenge, beginGrantSessionChallenge, buildAuthenticationCredential, buildAuthenticatorData, buildClientDataJSON, buildFullInitConfig, buildInstallModuleHash, buildUninstallModuleHash, computeOapdSalt, erc8004AddressesForChain, getOapdAddress, getOapdAddressWithChainId, initConfigFromRecord, initConfigToTuple, isExecuteUserOpWrapped, isOapdDeployed, isPendingConfirmation, packP256SessionSignature, packSecp256k1SessionSignature, runAuthenticationCeremony, runGrantSessionCeremony, runWebAuthnCeremony, sepoliaV07Config, serializeGuardianSpecs, toGuardianSpecs, validateConfig, wrapExecuteUserOp };
4867
- //# sourceMappingURL=chunk-V65JXHM6.js.map
4868
- //# sourceMappingURL=chunk-V65JXHM6.js.map
4945
+ //# sourceMappingURL=chunk-YUFQIYLR.js.map
4946
+ //# sourceMappingURL=chunk-YUFQIYLR.js.map