@aastar/sdk 0.24.1 → 0.25.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 (132) hide show
  1. package/dist/UserClient-5PQP6APK.js +6 -0
  2. package/dist/{UserClient-KYDCMAIU.js.map → UserClient-5PQP6APK.js.map} +1 -1
  3. package/dist/UserClient-CD7R3335.cjs +15 -0
  4. package/dist/{UserClient-S6LS3CB6.cjs.map → UserClient-CD7R3335.cjs.map} +1 -1
  5. package/dist/account.cjs +8 -8
  6. package/dist/account.js +3 -3
  7. package/dist/addresses-D12T3kLs.d.cts +210 -0
  8. package/dist/addresses-D12T3kLs.d.ts +210 -0
  9. package/dist/admin.cjs +4 -4
  10. package/dist/admin.js +3 -3
  11. package/dist/airaccount.cjs +111 -103
  12. package/dist/airaccount.d.cts +1 -1
  13. package/dist/airaccount.d.ts +1 -1
  14. package/dist/airaccount.js +3 -3
  15. package/dist/channel.cjs +7 -7
  16. package/dist/channel.js +3 -3
  17. package/dist/{chunk-72JZKARR.cjs → chunk-2RHBOBL7.cjs} +6 -6
  18. package/dist/{chunk-72JZKARR.cjs.map → chunk-2RHBOBL7.cjs.map} +1 -1
  19. package/dist/{chunk-BYVG7MO7.js → chunk-6DZCDV4Q.js} +2137 -13
  20. package/dist/chunk-6DZCDV4Q.js.map +1 -0
  21. package/dist/{chunk-VEAYV52I.cjs → chunk-6IZASQSB.cjs} +236 -109
  22. package/dist/chunk-6IZASQSB.cjs.map +1 -0
  23. package/dist/{chunk-NVYVTCHJ.cjs → chunk-7HTUDNH3.cjs} +11 -11
  24. package/dist/{chunk-NVYVTCHJ.cjs.map → chunk-7HTUDNH3.cjs.map} +1 -1
  25. package/dist/{chunk-PNBK2CLK.js → chunk-7JVL5CU3.js} +3 -3
  26. package/dist/{chunk-PNBK2CLK.js.map → chunk-7JVL5CU3.js.map} +1 -1
  27. package/dist/{chunk-654GQ7G7.js → chunk-A4FO6FKN.js} +3 -3
  28. package/dist/{chunk-654GQ7G7.js.map → chunk-A4FO6FKN.js.map} +1 -1
  29. package/dist/{chunk-A4ICWCHR.cjs → chunk-CI4UJW5Y.cjs} +5 -5
  30. package/dist/{chunk-A4ICWCHR.cjs.map → chunk-CI4UJW5Y.cjs.map} +1 -1
  31. package/dist/{chunk-RZ2M2RVP.js → chunk-COTHBCR2.js} +3 -3
  32. package/dist/{chunk-RZ2M2RVP.js.map → chunk-COTHBCR2.js.map} +1 -1
  33. package/dist/{chunk-2UC7UPHV.js → chunk-D2RDBN46.js} +227 -102
  34. package/dist/chunk-D2RDBN46.js.map +1 -0
  35. package/dist/{chunk-WVOJV4Q5.cjs → chunk-FIMXPANS.cjs} +4 -4
  36. package/dist/{chunk-WVOJV4Q5.cjs.map → chunk-FIMXPANS.cjs.map} +1 -1
  37. package/dist/{chunk-MXJEULSE.cjs → chunk-G33MXEHU.cjs} +29 -2
  38. package/dist/chunk-G33MXEHU.cjs.map +1 -0
  39. package/dist/{chunk-D667CUUS.cjs → chunk-GASCTLKR.cjs} +9 -9
  40. package/dist/{chunk-D667CUUS.cjs.map → chunk-GASCTLKR.cjs.map} +1 -1
  41. package/dist/{chunk-PXQDAFXD.js → chunk-IG4BG25C.js} +6 -6
  42. package/dist/{chunk-PXQDAFXD.js.map → chunk-IG4BG25C.js.map} +1 -1
  43. package/dist/{chunk-5PH5CSM7.cjs → chunk-J3UAXGNP.cjs} +16 -16
  44. package/dist/{chunk-5PH5CSM7.cjs.map → chunk-J3UAXGNP.cjs.map} +1 -1
  45. package/dist/{chunk-WC25H5VG.js → chunk-JCEUTCFZ.js} +4 -4
  46. package/dist/{chunk-WC25H5VG.js.map → chunk-JCEUTCFZ.js.map} +1 -1
  47. package/dist/{chunk-MOJJ7QF6.cjs → chunk-KOWTQJIX.cjs} +2177 -49
  48. package/dist/chunk-KOWTQJIX.cjs.map +1 -0
  49. package/dist/chunk-L6D2AGTF.js +500 -0
  50. package/dist/chunk-L6D2AGTF.js.map +1 -0
  51. package/dist/{chunk-VHY6R2PI.cjs → chunk-LRPAX5AG.cjs} +32 -32
  52. package/dist/{chunk-VHY6R2PI.cjs.map → chunk-LRPAX5AG.cjs.map} +1 -1
  53. package/dist/{chunk-UCLK6LTB.js → chunk-MBWBHKUE.js} +28 -3
  54. package/dist/chunk-MBWBHKUE.js.map +1 -0
  55. package/dist/{chunk-BOVDJSMK.cjs → chunk-NHDZQPDE.cjs} +26 -26
  56. package/dist/{chunk-BOVDJSMK.cjs.map → chunk-NHDZQPDE.cjs.map} +1 -1
  57. package/dist/{chunk-HNJBQR5U.cjs → chunk-OBPTMV5W.cjs} +5 -5
  58. package/dist/{chunk-HNJBQR5U.cjs.map → chunk-OBPTMV5W.cjs.map} +1 -1
  59. package/dist/{chunk-JMW5AHLC.js → chunk-QTXPAGNX.js} +9 -9
  60. package/dist/{chunk-JMW5AHLC.js.map → chunk-QTXPAGNX.js.map} +1 -1
  61. package/dist/{chunk-WVJ4LQVB.js → chunk-UANSP3OK.js} +3 -3
  62. package/dist/{chunk-WVJ4LQVB.js.map → chunk-UANSP3OK.js.map} +1 -1
  63. package/dist/{chunk-DAMWXGKD.js → chunk-UTSFTWFC.js} +3 -3
  64. package/dist/{chunk-DAMWXGKD.js.map → chunk-UTSFTWFC.js.map} +1 -1
  65. package/dist/chunk-WTURYJEA.cjs +504 -0
  66. package/dist/chunk-WTURYJEA.cjs.map +1 -0
  67. package/dist/{chunk-LDARLWS3.js → chunk-YR7CTWY6.js} +3 -3
  68. package/dist/{chunk-LDARLWS3.js.map → chunk-YR7CTWY6.js.map} +1 -1
  69. package/dist/{contract-addresses-RABD77VP.cjs → contract-addresses-6K6IB5OB.cjs} +13 -13
  70. package/dist/{contract-addresses-RABD77VP.cjs.map → contract-addresses-6K6IB5OB.cjs.map} +1 -1
  71. package/dist/{contract-addresses-TVXSRQ7I.js → contract-addresses-CHZ7PK5H.js} +3 -3
  72. package/dist/{contract-addresses-TVXSRQ7I.js.map → contract-addresses-CHZ7PK5H.js.map} +1 -1
  73. package/dist/core.cjs +285 -261
  74. package/dist/core.d.cts +6 -175
  75. package/dist/core.d.ts +6 -175
  76. package/dist/core.js +2 -2
  77. package/dist/dapp.cjs +6 -6
  78. package/dist/dapp.js +3 -3
  79. package/dist/email.cjs +91 -0
  80. package/dist/email.cjs.map +1 -0
  81. package/dist/email.d.cts +115 -0
  82. package/dist/email.d.ts +115 -0
  83. package/dist/email.js +88 -0
  84. package/dist/email.js.map +1 -0
  85. package/dist/enduser.cjs +7 -7
  86. package/dist/enduser.js +4 -4
  87. package/dist/identity.cjs +6 -6
  88. package/dist/identity.js +3 -3
  89. package/dist/index.cjs +406 -374
  90. package/dist/index.d.cts +3 -2
  91. package/dist/index.d.ts +3 -2
  92. package/dist/index.js +17 -17
  93. package/dist/kms.cjs +111 -103
  94. package/dist/kms.d.cts +199 -19
  95. package/dist/kms.d.ts +199 -19
  96. package/dist/kms.js +3 -3
  97. package/dist/operator.cjs +7 -7
  98. package/dist/operator.js +3 -3
  99. package/dist/paymaster.cjs +16 -16
  100. package/dist/paymaster.js +3 -3
  101. package/dist/{src-N72HAQXS.cjs → src-DNURNUIA.cjs} +287 -263
  102. package/dist/src-DNURNUIA.cjs.map +1 -0
  103. package/dist/{src-72GWEAPA.cjs → src-DZDH3BSU.cjs} +18 -18
  104. package/dist/src-DZDH3BSU.cjs.map +1 -0
  105. package/dist/{src-UNS5B7FX.js → src-EVM7OESP.js} +5 -5
  106. package/dist/src-EVM7OESP.js.map +1 -0
  107. package/dist/src-FY3KAPPC.js +5 -0
  108. package/dist/src-FY3KAPPC.js.map +1 -0
  109. package/dist/tokens.cjs +12 -4
  110. package/dist/tokens.d.cts +133 -1
  111. package/dist/tokens.d.ts +133 -1
  112. package/dist/tokens.js +3 -3
  113. package/dist/x402.cjs +26 -26
  114. package/dist/x402.js +3 -3
  115. package/package.json +17 -2
  116. package/dist/UserClient-KYDCMAIU.js +0 -6
  117. package/dist/UserClient-S6LS3CB6.cjs +0 -15
  118. package/dist/chunk-2UC7UPHV.js.map +0 -1
  119. package/dist/chunk-7RVONA2R.js +0 -226
  120. package/dist/chunk-7RVONA2R.js.map +0 -1
  121. package/dist/chunk-BYVG7MO7.js.map +0 -1
  122. package/dist/chunk-GDH4DSVM.cjs +0 -228
  123. package/dist/chunk-GDH4DSVM.cjs.map +0 -1
  124. package/dist/chunk-MOJJ7QF6.cjs.map +0 -1
  125. package/dist/chunk-MXJEULSE.cjs.map +0 -1
  126. package/dist/chunk-UCLK6LTB.js.map +0 -1
  127. package/dist/chunk-VEAYV52I.cjs.map +0 -1
  128. package/dist/src-5URXSFKD.js +0 -5
  129. package/dist/src-5URXSFKD.js.map +0 -1
  130. package/dist/src-72GWEAPA.cjs.map +0 -1
  131. package/dist/src-N72HAQXS.cjs.map +0 -1
  132. package/dist/src-UNS5B7FX.js.map +0 -1
@@ -1,6 +1,6 @@
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, needsValidatorRouter, airAccountActions, airAccountFactoryActions } from './chunk-BYVG7MO7.js';
3
- import { CANONICAL_ADDRESSES, getCanonicalAddresses } from './chunk-UCLK6LTB.js';
2
+ import { buildInitConfig, needsValidatorRouter, airAccountActions, airAccountFactoryActions } from './chunk-6DZCDV4Q.js';
3
+ import { CANONICAL_ADDRESSES, getCanonicalAddresses } from './chunk-MBWBHKUE.js';
4
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';
@@ -1610,7 +1610,12 @@ var TransferManager = class {
1610
1610
  );
1611
1611
  const userOpHash = await this.ethereum.getUserOpHash(userOp, version);
1612
1612
  await this.signer.ensureSigner(userId);
1613
- const assertionCtx = params.passkeyAssertion ? { assertion: params.passkeyAssertion } : void 0;
1613
+ if (params.webAuthnAssertion && params.passkeyAssertion) {
1614
+ throw new Error(
1615
+ "Provide either webAuthnAssertion (preferred) or passkeyAssertion, not both."
1616
+ );
1617
+ }
1618
+ const assertionCtx = params.webAuthnAssertion ? { webAuthnAssertion: params.webAuthnAssertion } : params.passkeyAssertion ? { assertion: params.passkeyAssertion } : void 0;
1614
1619
  let useECDSA = false;
1615
1620
  let isCompositeValidator = false;
1616
1621
  if (version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */) {
@@ -1620,6 +1625,11 @@ var TransferManager = class {
1620
1625
  account.address
1621
1626
  ));
1622
1627
  }
1628
+ if (assertionCtx && "webAuthnAssertion" in assertionCtx && !useECDSA && !(params.useAirAccountTiering && this.guardChecker)) {
1629
+ throw new Error(
1630
+ "A one-time webAuthnAssertion cannot authorize the legacy non-tiered BLS dual-sign (two owner signatures, one spent challenge). Use useAirAccountTiering:true (single owner signature), or supply two assertions via the legacy path."
1631
+ );
1632
+ }
1623
1633
  if (useECDSA) {
1624
1634
  const ecdsaSig = await this.signer.signMessage(
1625
1635
  userId,
@@ -2116,7 +2126,7 @@ var BLSSignatureService = class {
2116
2126
  }
2117
2127
  return nodes;
2118
2128
  }
2119
- async generateBLSSignature(userId, userOpHash, ctx) {
2129
+ async generateBLSSignature(userId, userOpHash, ctx, options) {
2120
2130
  const manager = await this.ensureInitialized();
2121
2131
  const activeNodes = await this.getActiveSignerNodes();
2122
2132
  if (activeNodes.length < 1) {
@@ -2175,11 +2185,7 @@ var BLSSignatureService = class {
2175
2185
  `Wallet address mismatch! Wallet: ${walletAddress}, Expected: ${account.signerAddress}`
2176
2186
  );
2177
2187
  }
2178
- const aaSignature = await this.signer.signMessage(
2179
- userId,
2180
- hexToBytes(userOpHash),
2181
- ctx
2182
- );
2188
+ const aaSignature = options?.skipOwnerOpSignature ? "0x" : await this.signer.signMessage(userId, hexToBytes(userOpHash), ctx);
2183
2189
  const messagePointHash = keccak256(messagePoint);
2184
2190
  const messagePointSignature = await this.signer.signMessage(
2185
2191
  userId,
@@ -2196,6 +2202,11 @@ var BLSSignatureService = class {
2196
2202
  };
2197
2203
  }
2198
2204
  async packSignature(blsData) {
2205
+ if (!blsData.aaSignature || blsData.aaSignature === "0x") {
2206
+ throw new Error(
2207
+ "packSignature requires aaSignature; this BLSSignatureData was generated with skipOwnerOpSignature (Tier-2/3 only). Use packCumulativeT2/T3Signature instead."
2208
+ );
2209
+ }
2199
2210
  const manager = await this.ensureInitialized();
2200
2211
  return manager.packSignature(blsData);
2201
2212
  }
@@ -2225,7 +2236,9 @@ var BLSSignatureService = class {
2225
2236
  if (!p256Signature) {
2226
2237
  throw new Error(`P256 signature required for Tier ${tier}`);
2227
2238
  }
2228
- const blsData = await this.generateBLSSignature(userId, userOpHash, ctx);
2239
+ const blsData = await this.generateBLSSignature(userId, userOpHash, ctx, {
2240
+ skipOwnerOpSignature: true
2241
+ });
2229
2242
  if (tier === 2) {
2230
2243
  const t2Data = {
2231
2244
  p256Signature,
@@ -2253,6 +2266,84 @@ var BLSSignatureService = class {
2253
2266
  return manager.packCumulativeT3Signature(t3Data);
2254
2267
  }
2255
2268
  };
2269
+ var ALG_NAMES = {
2270
+ [ALG_BLS]: "BLS (0x01)",
2271
+ [ALG_ECDSA]: "ECDSA (0x02)",
2272
+ [ALG_P256]: "P256 (0x03)",
2273
+ [ALG_CUMULATIVE_T2]: "Cumulative T2 (0x04)",
2274
+ [ALG_CUMULATIVE_T3]: "Cumulative T3 (0x05)"
2275
+ };
2276
+ var GuardChecker = class {
2277
+ constructor(ethereum, logger) {
2278
+ this.ethereum = ethereum;
2279
+ this.logger = logger ?? new ConsoleLogger("[GuardChecker]");
2280
+ }
2281
+ logger;
2282
+ /**
2283
+ * Fetch tier limits from an AirAccount contract.
2284
+ */
2285
+ async fetchTierConfig(accountAddress) {
2286
+ const account = this.ethereum.getAccountContract(accountAddress);
2287
+ return readAccountTierLimits(account);
2288
+ }
2289
+ /**
2290
+ * Fetch guard status from the account's GlobalGuard.
2291
+ */
2292
+ async fetchGuardStatus(accountAddress) {
2293
+ const account = this.ethereum.getAccountContract(accountAddress);
2294
+ const guardAddress = await readAccountGuardAddress(account);
2295
+ if (guardAddress === zeroAddress) {
2296
+ return {
2297
+ hasGuard: false,
2298
+ guardAddress: zeroAddress,
2299
+ dailyLimit: 0n,
2300
+ dailyRemaining: 0n
2301
+ };
2302
+ }
2303
+ const guard = getContract({
2304
+ address: guardAddress,
2305
+ abi: parseAbi(GLOBAL_GUARD_ABI),
2306
+ client: this.ethereum.getProvider()
2307
+ });
2308
+ const { dailyLimit, dailyRemaining } = await readGuardDailyAllowance(guard);
2309
+ return {
2310
+ hasGuard: true,
2311
+ guardAddress,
2312
+ dailyLimit,
2313
+ dailyRemaining
2314
+ };
2315
+ }
2316
+ /**
2317
+ * Pre-check a transaction: determine tier, check guard limits and algorithm approval.
2318
+ * Returns errors array (empty = OK to proceed).
2319
+ */
2320
+ async preCheck(accountAddress, value) {
2321
+ const errors = [];
2322
+ const tierConfig = await this.fetchTierConfig(accountAddress);
2323
+ const tier = resolveTier(value, tierConfig);
2324
+ const algId = algIdForTier(tier);
2325
+ const guard = await this.fetchGuardStatus(accountAddress);
2326
+ if (!guard.hasGuard) {
2327
+ return { ok: true, errors: [], tier, algId };
2328
+ }
2329
+ if (guard.dailyLimit > 0n && value > guard.dailyRemaining) {
2330
+ errors.push(
2331
+ `Daily limit exceeded: requesting ${value} wei but only ${guard.dailyRemaining} remaining (limit: ${guard.dailyLimit})`
2332
+ );
2333
+ }
2334
+ const accountContract = this.ethereum.getAccountContract(accountAddress);
2335
+ const isApproved = await readAlgorithmApproved(accountContract, algId);
2336
+ if (!isApproved) {
2337
+ errors.push(
2338
+ `Algorithm ${ALG_NAMES[algId] ?? `0x${algId.toString(16)}`} is not approved by the account`
2339
+ );
2340
+ }
2341
+ if (errors.length > 0) {
2342
+ this.logger.warn(`Pre-check failed for ${accountAddress}: ${errors.join("; ")}`);
2343
+ }
2344
+ return { ok: errors.length === 0, errors, tier, algId };
2345
+ }
2346
+ };
2256
2347
  var ERC20_ABI_PARSED = parseAbi(ERC20_ABI);
2257
2348
  var TokenService = class {
2258
2349
  constructor(ethereum) {
@@ -2379,7 +2470,8 @@ var AirAccountServerClient = class {
2379
2470
  this.tokens,
2380
2471
  config.storage,
2381
2472
  config.signer,
2382
- logger
2473
+ logger,
2474
+ new GuardChecker(this.ethereum, logger)
2383
2475
  );
2384
2476
  }
2385
2477
  };
@@ -2914,84 +3006,6 @@ async function isOapdDeployed(provider, config) {
2914
3006
  const code = await provider.getCode({ address });
2915
3007
  return code !== void 0 && code !== "0x";
2916
3008
  }
2917
- var ALG_NAMES = {
2918
- [ALG_BLS]: "BLS (0x01)",
2919
- [ALG_ECDSA]: "ECDSA (0x02)",
2920
- [ALG_P256]: "P256 (0x03)",
2921
- [ALG_CUMULATIVE_T2]: "Cumulative T2 (0x04)",
2922
- [ALG_CUMULATIVE_T3]: "Cumulative T3 (0x05)"
2923
- };
2924
- var GuardChecker = class {
2925
- constructor(ethereum, logger) {
2926
- this.ethereum = ethereum;
2927
- this.logger = logger ?? new ConsoleLogger("[GuardChecker]");
2928
- }
2929
- logger;
2930
- /**
2931
- * Fetch tier limits from an AirAccount contract.
2932
- */
2933
- async fetchTierConfig(accountAddress) {
2934
- const account = this.ethereum.getAccountContract(accountAddress);
2935
- return readAccountTierLimits(account);
2936
- }
2937
- /**
2938
- * Fetch guard status from the account's GlobalGuard.
2939
- */
2940
- async fetchGuardStatus(accountAddress) {
2941
- const account = this.ethereum.getAccountContract(accountAddress);
2942
- const guardAddress = await readAccountGuardAddress(account);
2943
- if (guardAddress === zeroAddress) {
2944
- return {
2945
- hasGuard: false,
2946
- guardAddress: zeroAddress,
2947
- dailyLimit: 0n,
2948
- dailyRemaining: 0n
2949
- };
2950
- }
2951
- const guard = getContract({
2952
- address: guardAddress,
2953
- abi: parseAbi(GLOBAL_GUARD_ABI),
2954
- client: this.ethereum.getProvider()
2955
- });
2956
- const { dailyLimit, dailyRemaining } = await readGuardDailyAllowance(guard);
2957
- return {
2958
- hasGuard: true,
2959
- guardAddress,
2960
- dailyLimit,
2961
- dailyRemaining
2962
- };
2963
- }
2964
- /**
2965
- * Pre-check a transaction: determine tier, check guard limits and algorithm approval.
2966
- * Returns errors array (empty = OK to proceed).
2967
- */
2968
- async preCheck(accountAddress, value) {
2969
- const errors = [];
2970
- const tierConfig = await this.fetchTierConfig(accountAddress);
2971
- const tier = resolveTier(value, tierConfig);
2972
- const algId = algIdForTier(tier);
2973
- const guard = await this.fetchGuardStatus(accountAddress);
2974
- if (!guard.hasGuard) {
2975
- return { ok: true, errors: [], tier, algId };
2976
- }
2977
- if (guard.dailyLimit > 0n && value > guard.dailyRemaining) {
2978
- errors.push(
2979
- `Daily limit exceeded: requesting ${value} wei but only ${guard.dailyRemaining} remaining (limit: ${guard.dailyLimit})`
2980
- );
2981
- }
2982
- const accountContract = this.ethereum.getAccountContract(accountAddress);
2983
- const isApproved = await readAlgorithmApproved(accountContract, algId);
2984
- if (!isApproved) {
2985
- errors.push(
2986
- `Algorithm ${ALG_NAMES[algId] ?? `0x${algId.toString(16)}`} is not approved by the account`
2987
- );
2988
- }
2989
- if (errors.length > 0) {
2990
- this.logger.warn(`Pre-check failed for ${accountAddress}: ${errors.join("; ")}`);
2991
- }
2992
- return { ok: errors.length === 0, errors, tier, algId };
2993
- }
2994
- };
2995
3009
  var FORCE_EXIT_ABI = [
2996
3010
  // ERC-7579 module lifecycle
2997
3011
  "function onInstall(bytes calldata data) external",
@@ -4244,14 +4258,21 @@ async function buildAuthenticationCredential(opts) {
4244
4258
  }
4245
4259
  };
4246
4260
  }
4261
+ function commitChallenge(nonceBase64Url, payload) {
4262
+ const nonce = base64UrlDecode(nonceBase64Url);
4263
+ const payloadBytes = typeof payload === "string" ? hexToBytes4(payload) : payload;
4264
+ const committed = createHash("sha256").update(nonce).update(payloadBytes).digest();
4265
+ return base64UrlEncode(new Uint8Array(committed));
4266
+ }
4247
4267
  async function runWebAuthnCeremony(begin, options) {
4248
4268
  const begun = await begin();
4249
- const challenge = begun?.Options?.challenge;
4250
- if (!begun?.ChallengeId || !challenge) {
4269
+ const nonce = begun?.Options?.challenge;
4270
+ if (!begun?.ChallengeId || !nonce) {
4251
4271
  throw new Error(
4252
4272
  "WebAuthn ceremony: begin endpoint did not return a ChallengeId + Options.challenge"
4253
4273
  );
4254
4274
  }
4275
+ const challenge = options.payload ? commitChallenge(nonce, options.payload) : nonce;
4255
4276
  const credential = await buildAuthenticationCredential({
4256
4277
  challenge,
4257
4278
  signer: options.signer,
@@ -4577,27 +4598,100 @@ var KmsManager = class {
4577
4598
  return this.client.post("/BeginAuthentication", { KeyId: keyId });
4578
4599
  }
4579
4600
  // ── Factory ─────────────────────────────────────────────────────
4601
+ /**
4602
+ * Create a KMS signer that authorizes each signature with a LEGACY raw passkey
4603
+ * assertion (reusable, no challenge consumption).
4604
+ *
4605
+ * @deprecated The KMS (v0.20.0+) rejects legacy raw passkey assertions for
4606
+ * signing/mutating operations (`/SignHash` → 400, "no challenge binding —
4607
+ * replayable"), unless `KMS_ALLOW_LEGACY_PASSKEY=1` is set on the KMS (test
4608
+ * only). Prefer {@link createKmsSignerWithCeremony}, which runs a one-time
4609
+ * challenge-bound WebAuthn ceremony per signature.
4610
+ */
4580
4611
  createKmsSigner(keyId, address, assertionProvider) {
4581
4612
  this.ensureEnabled();
4582
- return new KmsSigner(keyId, address, this, assertionProvider);
4613
+ return new KmsSigner(keyId, address, this, { mode: "legacy", assertionProvider });
4614
+ }
4615
+ /**
4616
+ * Create a KMS signer that authorizes each signature with a one-time,
4617
+ * challenge-bound WebAuthn ceremony (production-safe; replay-protected).
4618
+ *
4619
+ * Every `signMessage` call runs a FRESH ceremony (BeginAuthentication →
4620
+ * authenticator assertion → `/SignHash` with the `WebAuthn` field), because the
4621
+ * KMS consumes the challenge atomically (one challenge ⇒ one signature). A
4622
+ * Tier-2/3 BLS transfer that needs N owner signatures therefore triggers N
4623
+ * ceremonies — see {@link BLSSignatureService} (which now skips the unused
4624
+ * userOpHash owner-ECDSA for tiered signatures, so Tier-2 needs only one).
4625
+ *
4626
+ * @param ceremonySigner authenticator that signs the WebAuthn challenge
4627
+ * (a browser passkey on the client, or {@link P256PasskeySigner} server-side).
4628
+ */
4629
+ createKmsSignerWithCeremony(keyId, address, ceremonySigner, ceremonyOptions, commitPayload = false) {
4630
+ this.ensureEnabled();
4631
+ return new KmsSigner(keyId, address, this, {
4632
+ mode: "ceremony",
4633
+ ceremonySigner,
4634
+ ceremonyOptions,
4635
+ commitPayload
4636
+ });
4583
4637
  }
4584
4638
  };
4585
4639
  var KmsSigner = class {
4586
- constructor(keyId, _address, kmsManager, assertionProvider) {
4640
+ constructor(keyId, _address, kmsManager, auth) {
4587
4641
  this.keyId = keyId;
4588
4642
  this._address = _address;
4589
4643
  this.kmsManager = kmsManager;
4590
- this.assertionProvider = assertionProvider;
4644
+ this.auth = auth;
4591
4645
  }
4592
4646
  async getAddress() {
4593
4647
  return this._address;
4594
4648
  }
4595
- async signMessage(message) {
4649
+ /**
4650
+ * EIP-191 personal-sign over a digest. A string is hashed as UTF-8 text, a byte
4651
+ * array as raw bytes — byte-identical to ethers `hashMessage`.
4652
+ *
4653
+ * @param webAuthnAssertion OPTIONAL pre-built, one-time ceremony assertion. Use
4654
+ * this in server flows where the passkey lives on the USER's device: the
4655
+ * frontend runs the BeginAuthentication ceremony and the backend forwards the
4656
+ * resulting `{ ChallengeId, Credential }` here. When supplied it takes
4657
+ * precedence over the signer's baked-in auth mode. Each assertion is one-time
4658
+ * (the KMS consumes the challenge), so a caller that needs N signatures must
4659
+ * supply N distinct assertions.
4660
+ *
4661
+ * WYSIWYS (AirAccount #68): the frontend MUST build the assertion over the
4662
+ * payload-committed challenge `commitChallenge(nonce, hashOf(message))`, not the
4663
+ * raw nonce — otherwise a compromised host could swap the signed payload. The
4664
+ * raw-nonce assertion only works while the KMS runs in transition mode. (The
4665
+ * signer's own ceremony mode does this automatically.)
4666
+ */
4667
+ async signMessage(message, webAuthnAssertion) {
4596
4668
  const messageHash = hashMessage(message);
4597
- const assertion = await this.assertionProvider();
4598
- const signResponse = await this.kmsManager.signHash(messageHash, assertion, {
4599
- Address: this._address
4600
- });
4669
+ const target = { Address: this._address };
4670
+ if (webAuthnAssertion) {
4671
+ const signResponse2 = await this.kmsManager.signHashWithWebAuthn(
4672
+ messageHash,
4673
+ webAuthnAssertion.ChallengeId,
4674
+ webAuthnAssertion.Credential,
4675
+ target
4676
+ );
4677
+ return "0x" + signResponse2.Signature;
4678
+ }
4679
+ if (this.auth.mode === "ceremony") {
4680
+ const assertion2 = await this.kmsManager.runAuthenticationCeremony(
4681
+ this.keyId,
4682
+ this.auth.ceremonySigner,
4683
+ this.auth.commitPayload ? { ...this.auth.ceremonyOptions, payload: messageHash } : this.auth.ceremonyOptions
4684
+ );
4685
+ const signResponse2 = await this.kmsManager.signHashWithWebAuthn(
4686
+ messageHash,
4687
+ assertion2.ChallengeId,
4688
+ assertion2.Credential,
4689
+ target
4690
+ );
4691
+ return "0x" + signResponse2.Signature;
4692
+ }
4693
+ const assertion = await this.auth.assertionProvider();
4694
+ const signResponse = await this.kmsManager.signHash(messageHash, assertion, target);
4601
4695
  return "0x" + signResponse.Signature;
4602
4696
  }
4603
4697
  };
@@ -4983,12 +5077,43 @@ var LocalWalletSigner = class {
4983
5077
  return { address: this.account.address };
4984
5078
  }
4985
5079
  };
5080
+
5081
+ // ../airaccount/src/server/adapters/kms-signer-adapter.ts
5082
+ var KmsSignerAdapter = class {
5083
+ constructor(kms, resolveKey) {
5084
+ this.kms = kms;
5085
+ this.resolveKey = resolveKey;
5086
+ }
5087
+ async getAddress(userId) {
5088
+ return (await this.resolveKey(userId)).address;
5089
+ }
5090
+ async ensureSigner(userId) {
5091
+ return { address: (await this.resolveKey(userId)).address };
5092
+ }
5093
+ async signMessage(userId, message, ctx) {
5094
+ const { address } = await this.resolveKey(userId);
5095
+ const hash = hashMessage(message);
5096
+ const target = { Address: address };
5097
+ if (ctx && "webAuthnAssertion" in ctx) {
5098
+ const { ChallengeId, Credential } = ctx.webAuthnAssertion;
5099
+ const res = await this.kms.signHashWithWebAuthn(hash, ChallengeId, Credential, target);
5100
+ return "0x" + res.Signature;
5101
+ }
5102
+ if (ctx && "assertion" in ctx) {
5103
+ const res = await this.kms.signHash(hash, ctx.assertion, target);
5104
+ return "0x" + res.Signature;
5105
+ }
5106
+ throw new Error(
5107
+ "KmsSignerAdapter: KMS signing requires an auth context \u2014 pass a one-time WebAuthnCeremonyContext { webAuthnAssertion } (preferred)."
5108
+ );
5109
+ }
5110
+ };
4986
5111
  /*! Bundled license information:
4987
5112
 
4988
5113
  @noble/curves/nist.js:
4989
5114
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
4990
5115
  */
4991
5116
 
4992
- 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 };
4993
- //# sourceMappingURL=chunk-2UC7UPHV.js.map
4994
- //# sourceMappingURL=chunk-2UC7UPHV.js.map
5117
+ 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, KmsSignerAdapter, 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, commitChallenge, computeOapdSalt, erc8004AddressesForChain, getOapdAddress, getOapdAddressWithChainId, initConfigFromRecord, initConfigToTuple, isExecuteUserOpWrapped, isOapdDeployed, isPendingConfirmation, packP256SessionSignature, packSecp256k1SessionSignature, runAuthenticationCeremony, runGrantSessionCeremony, runWebAuthnCeremony, sepoliaV07Config, serializeGuardianSpecs, toGuardianSpecs, validateConfig, wrapExecuteUserOp };
5118
+ //# sourceMappingURL=chunk-D2RDBN46.js.map
5119
+ //# sourceMappingURL=chunk-D2RDBN46.js.map