@aastar/sdk 0.25.0 → 0.26.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/dist/airaccount.cjs +127 -103
- package/dist/airaccount.d.cts +1 -1
- package/dist/airaccount.d.ts +1 -1
- package/dist/airaccount.js +1 -1
- package/dist/{chunk-D2RDBN46.js → chunk-4GJSK7E6.js} +334 -17
- package/dist/chunk-4GJSK7E6.js.map +1 -0
- package/dist/{chunk-6IZASQSB.cjs → chunk-UZE7IPOK.cjs} +338 -15
- package/dist/chunk-UZE7IPOK.cjs.map +1 -0
- package/dist/kms.cjs +127 -103
- package/dist/kms.d.cts +138 -14
- package/dist/kms.d.ts +138 -14
- package/dist/kms.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-6IZASQSB.cjs.map +0 -1
- package/dist/chunk-D2RDBN46.js.map +0 -1
|
@@ -4201,6 +4201,9 @@ function hexToBytes4(hex) {
|
|
|
4201
4201
|
if (clean.length % 2 !== 0) {
|
|
4202
4202
|
throw new Error("hexToBytes: odd-length hex string");
|
|
4203
4203
|
}
|
|
4204
|
+
if (clean.length > 0 && !/^[0-9a-fA-F]+$/.test(clean)) {
|
|
4205
|
+
throw new Error("hexToBytes: non-hex characters in input");
|
|
4206
|
+
}
|
|
4204
4207
|
const out = new Uint8Array(clean.length / 2);
|
|
4205
4208
|
for (let i = 0; i < out.length; i++) {
|
|
4206
4209
|
out[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
|
|
@@ -4235,11 +4238,14 @@ function buildClientDataJSON(challenge, origin = DEFAULT_ORIGIN) {
|
|
|
4235
4238
|
return new TextEncoder().encode(json);
|
|
4236
4239
|
}
|
|
4237
4240
|
function buildAuthenticatorData(rpId = DEFAULT_RP_ID, signCount = 1) {
|
|
4241
|
+
if (!Number.isInteger(signCount) || signCount < 0 || signCount > 4294967295) {
|
|
4242
|
+
throw new Error(`buildAuthenticatorData: signCount must be a uint32 (0..2^32-1), got ${signCount}`);
|
|
4243
|
+
}
|
|
4238
4244
|
const rpIdHash = crypto.createHash("sha256").update(rpId).digest();
|
|
4239
4245
|
const out = new Uint8Array(37);
|
|
4240
4246
|
out.set(rpIdHash, 0);
|
|
4241
4247
|
out[32] = 5;
|
|
4242
|
-
new DataView(out.buffer).setUint32(33, signCount
|
|
4248
|
+
new DataView(out.buffer).setUint32(33, signCount, false);
|
|
4243
4249
|
return out;
|
|
4244
4250
|
}
|
|
4245
4251
|
async function buildAuthenticationCredential(opts) {
|
|
@@ -4267,6 +4273,9 @@ async function buildAuthenticationCredential(opts) {
|
|
|
4267
4273
|
function commitChallenge(nonceBase64Url, payload) {
|
|
4268
4274
|
const nonce = base64UrlDecode(nonceBase64Url);
|
|
4269
4275
|
const payloadBytes = typeof payload === "string" ? hexToBytes4(payload) : payload;
|
|
4276
|
+
if (payloadBytes.length !== 32) {
|
|
4277
|
+
throw new Error(`commitChallenge: payload must be a 32-byte digest, got ${payloadBytes.length} bytes`);
|
|
4278
|
+
}
|
|
4270
4279
|
const committed = crypto.createHash("sha256").update(nonce).update(payloadBytes).digest();
|
|
4271
4280
|
return base64UrlEncode(new Uint8Array(committed));
|
|
4272
4281
|
}
|
|
@@ -4284,10 +4293,19 @@ async function runWebAuthnCeremony(begin, options) {
|
|
|
4284
4293
|
signer: options.signer,
|
|
4285
4294
|
rpId: options.rpId,
|
|
4286
4295
|
origin: options.origin,
|
|
4287
|
-
signCount
|
|
4296
|
+
// The KMS enforces a strictly-increasing authenticator signCount (anti-clone). A
|
|
4297
|
+
// server-held signer (P256PasskeySigner) has no native counter, so default to a
|
|
4298
|
+
// monotonic value — else a second signature on the same key fails
|
|
4299
|
+
// "signCount not incremented". A real device passkey passes its own counter.
|
|
4300
|
+
signCount: options.signCount ?? nextSignCount()
|
|
4288
4301
|
});
|
|
4289
4302
|
return { ChallengeId: begun.ChallengeId, Credential: credential };
|
|
4290
4303
|
}
|
|
4304
|
+
var _signCountCounter = Math.floor(Date.now() / 1e3);
|
|
4305
|
+
function nextSignCount() {
|
|
4306
|
+
_signCountCounter = _signCountCounter + 1 >>> 0;
|
|
4307
|
+
return _signCountCounter;
|
|
4308
|
+
}
|
|
4291
4309
|
function beginAuthenticationChallenge(http2, keyId) {
|
|
4292
4310
|
return http2.post("/BeginAuthentication", { KeyId: keyId });
|
|
4293
4311
|
}
|
|
@@ -4310,6 +4328,133 @@ function runGrantSessionCeremony(http2, keyId, signer, options) {
|
|
|
4310
4328
|
}
|
|
4311
4329
|
|
|
4312
4330
|
// ../airaccount/src/server/services/kms-signer.ts
|
|
4331
|
+
function eip712Digest(params) {
|
|
4332
|
+
const types = Object.fromEntries(
|
|
4333
|
+
params.types.filter((t) => t.name !== "EIP712Domain").map((t) => [t.name, t.fields])
|
|
4334
|
+
);
|
|
4335
|
+
const message = Object.fromEntries(params.message.map((f) => [f.name, f.value]));
|
|
4336
|
+
return viem.hashTypedData({
|
|
4337
|
+
domain: params.domain,
|
|
4338
|
+
types,
|
|
4339
|
+
primaryType: params.primaryType,
|
|
4340
|
+
message
|
|
4341
|
+
});
|
|
4342
|
+
}
|
|
4343
|
+
function u256(x) {
|
|
4344
|
+
if (typeof x === "number" && !Number.isSafeInteger(x)) {
|
|
4345
|
+
throw new Error(`u256: number ${x} exceeds safe-integer range \u2014 pass a bigint or string`);
|
|
4346
|
+
}
|
|
4347
|
+
return BigInt(x);
|
|
4348
|
+
}
|
|
4349
|
+
var MINT_TAGS = { agent: "AA-AGENT-MINT-v1", p256: "AA-P256-SESSION-MINT-v1" };
|
|
4350
|
+
function mintDigest(p) {
|
|
4351
|
+
const hex = p.walletId.replace(/-/g, "");
|
|
4352
|
+
if (hex.length !== 32 || !/^[0-9a-fA-F]+$/.test(hex)) {
|
|
4353
|
+
throw new Error("mintDigest: walletId must be a 16-byte UUID");
|
|
4354
|
+
}
|
|
4355
|
+
if (!Number.isInteger(p.index) || p.index < 0 || p.index > 4294967295) {
|
|
4356
|
+
throw new Error(`mintDigest: index must be a uint32, got ${p.index}`);
|
|
4357
|
+
}
|
|
4358
|
+
if (typeof p.ttlSecs === "number" && !Number.isInteger(p.ttlSecs)) {
|
|
4359
|
+
throw new Error(`mintDigest: ttlSecs must be an integer, got ${p.ttlSecs}`);
|
|
4360
|
+
}
|
|
4361
|
+
const ttlBig = BigInt(p.ttlSecs);
|
|
4362
|
+
if (ttlBig < -(1n << 63n) || ttlBig > (1n << 63n) - 1n) {
|
|
4363
|
+
throw new Error(`mintDigest: ttlSecs out of int64 range: ${ttlBig}`);
|
|
4364
|
+
}
|
|
4365
|
+
const sha2562 = (b) => new Uint8Array(crypto.createHash("sha256").update(b).digest());
|
|
4366
|
+
const utf8 = (s) => new TextEncoder().encode(s);
|
|
4367
|
+
const walletBytes = new Uint8Array(16);
|
|
4368
|
+
for (let i = 0; i < 16; i++) walletBytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
4369
|
+
const idx = new Uint8Array(4);
|
|
4370
|
+
new DataView(idx.buffer).setUint32(0, p.index, false);
|
|
4371
|
+
const ttl = new Uint8Array(8);
|
|
4372
|
+
new DataView(ttl.buffer).setBigInt64(0, ttlBig, false);
|
|
4373
|
+
const parts = [utf8(MINT_TAGS[p.kind]), walletBytes, idx, ttl, sha2562(utf8(p.subject))];
|
|
4374
|
+
const total = parts.reduce((n, a) => n + a.length, 0);
|
|
4375
|
+
const buf = new Uint8Array(total);
|
|
4376
|
+
let off = 0;
|
|
4377
|
+
for (const a of parts) {
|
|
4378
|
+
buf.set(a, off);
|
|
4379
|
+
off += a.length;
|
|
4380
|
+
}
|
|
4381
|
+
return "0x" + Buffer.from(sha2562(buf)).toString("hex");
|
|
4382
|
+
}
|
|
4383
|
+
function grantSessionFinalHash(p) {
|
|
4384
|
+
const callTargetsHash = viem.keccak256(viem.encodePacked(["address[]"], [p.callTargets]));
|
|
4385
|
+
const selectorsHash = viem.keccak256(viem.encodePacked(["bytes4[]"], [p.selectorAllowlist]));
|
|
4386
|
+
const isP256 = "keyX" in p;
|
|
4387
|
+
const inner = isP256 ? viem.keccak256(
|
|
4388
|
+
viem.encodeAbiParameters(
|
|
4389
|
+
[
|
|
4390
|
+
{ type: "string" },
|
|
4391
|
+
{ type: "uint256" },
|
|
4392
|
+
{ type: "address" },
|
|
4393
|
+
{ type: "address" },
|
|
4394
|
+
{ type: "bytes32" },
|
|
4395
|
+
{ type: "bytes32" },
|
|
4396
|
+
{ type: "uint48" },
|
|
4397
|
+
{ type: "address" },
|
|
4398
|
+
{ type: "bytes4" },
|
|
4399
|
+
{ type: "uint16" },
|
|
4400
|
+
{ type: "uint32" },
|
|
4401
|
+
{ type: "bytes32" },
|
|
4402
|
+
{ type: "bytes32" },
|
|
4403
|
+
{ type: "uint256" }
|
|
4404
|
+
],
|
|
4405
|
+
[
|
|
4406
|
+
"GRANT_P256_SESSION_V2",
|
|
4407
|
+
u256(p.chainId),
|
|
4408
|
+
p.verifyingContract,
|
|
4409
|
+
p.account,
|
|
4410
|
+
p.keyX,
|
|
4411
|
+
p.keyY,
|
|
4412
|
+
p.expiry,
|
|
4413
|
+
p.contractScope,
|
|
4414
|
+
p.selectorScope,
|
|
4415
|
+
p.velocityLimit,
|
|
4416
|
+
p.velocityWindow,
|
|
4417
|
+
callTargetsHash,
|
|
4418
|
+
selectorsHash,
|
|
4419
|
+
u256(p.nonce)
|
|
4420
|
+
]
|
|
4421
|
+
)
|
|
4422
|
+
) : viem.keccak256(
|
|
4423
|
+
viem.encodeAbiParameters(
|
|
4424
|
+
[
|
|
4425
|
+
{ type: "string" },
|
|
4426
|
+
{ type: "uint256" },
|
|
4427
|
+
{ type: "address" },
|
|
4428
|
+
{ type: "address" },
|
|
4429
|
+
{ type: "address" },
|
|
4430
|
+
{ type: "uint48" },
|
|
4431
|
+
{ type: "address" },
|
|
4432
|
+
{ type: "bytes4" },
|
|
4433
|
+
{ type: "uint16" },
|
|
4434
|
+
{ type: "uint32" },
|
|
4435
|
+
{ type: "bytes32" },
|
|
4436
|
+
{ type: "bytes32" },
|
|
4437
|
+
{ type: "uint256" }
|
|
4438
|
+
],
|
|
4439
|
+
[
|
|
4440
|
+
"GRANT_SESSION_V2",
|
|
4441
|
+
u256(p.chainId),
|
|
4442
|
+
p.verifyingContract,
|
|
4443
|
+
p.account,
|
|
4444
|
+
p.sessionKey,
|
|
4445
|
+
p.expiry,
|
|
4446
|
+
p.contractScope,
|
|
4447
|
+
p.selectorScope,
|
|
4448
|
+
p.velocityLimit,
|
|
4449
|
+
p.velocityWindow,
|
|
4450
|
+
callTargetsHash,
|
|
4451
|
+
selectorsHash,
|
|
4452
|
+
u256(p.nonce)
|
|
4453
|
+
]
|
|
4454
|
+
)
|
|
4455
|
+
);
|
|
4456
|
+
return viem.hashMessage({ raw: inner });
|
|
4457
|
+
}
|
|
4313
4458
|
var KmsManager = class {
|
|
4314
4459
|
client;
|
|
4315
4460
|
logger;
|
|
@@ -4399,6 +4544,29 @@ var KmsManager = class {
|
|
|
4399
4544
|
this.ensureEnabled();
|
|
4400
4545
|
return this.amzPost("/ChangePasskey", "TrentService.ChangePasskey", params);
|
|
4401
4546
|
}
|
|
4547
|
+
// ── Ceremony wrappers for non-signing passkey ops (strict-readiness #135 item 2) ──
|
|
4548
|
+
// These are NON-signing ops, so the challenge is the raw nonce (no payload commitment),
|
|
4549
|
+
// but they MUST go through the ceremony (clientDataJSON present) — strict mode hard-rejects
|
|
4550
|
+
// any assertion without clientDataJSON. Run the ceremony internally so callers never reach
|
|
4551
|
+
// for the deprecated legacy `Passkey` field.
|
|
4552
|
+
/** Schedule key deletion, running the WebAuthn ceremony internally (raw-nonce). */
|
|
4553
|
+
async deleteKeyWithCeremony(params, signer, options) {
|
|
4554
|
+
this.ensureEnabled();
|
|
4555
|
+
const WebAuthn = await this.runAuthenticationCeremony(params.KeyId, signer, options);
|
|
4556
|
+
return this.deleteKey({ ...params, WebAuthn });
|
|
4557
|
+
}
|
|
4558
|
+
/** Unfreeze a dormant key, running the WebAuthn ceremony internally (raw-nonce). */
|
|
4559
|
+
async unfreezeKeyWithCeremony(params, signer, options) {
|
|
4560
|
+
this.ensureEnabled();
|
|
4561
|
+
const WebAuthn = await this.runAuthenticationCeremony(params.KeyId, signer, options);
|
|
4562
|
+
return this.unfreezeKey({ ...params, WebAuthn });
|
|
4563
|
+
}
|
|
4564
|
+
/** Rotate the bound passkey, running the WebAuthn ceremony internally (raw-nonce). */
|
|
4565
|
+
async changePasskeyWithCeremony(params, signer, options) {
|
|
4566
|
+
this.ensureEnabled();
|
|
4567
|
+
const WebAuthn = await this.runAuthenticationCeremony(params.KeyId, signer, options);
|
|
4568
|
+
return this.changePasskey({ ...params, WebAuthn });
|
|
4569
|
+
}
|
|
4402
4570
|
/**
|
|
4403
4571
|
* Sign a message or an EIP-155 transaction (WebAuthn-gated).
|
|
4404
4572
|
* Provide exactly one of `Message` (hex) or `Transaction`. For a raw 32-byte
|
|
@@ -4540,24 +4708,50 @@ var KmsManager = class {
|
|
|
4540
4708
|
return this.deriveAddress({ ...params, WebAuthn });
|
|
4541
4709
|
}
|
|
4542
4710
|
/**
|
|
4543
|
-
* Sign a message or EIP-155 transaction
|
|
4544
|
-
*
|
|
4711
|
+
* Sign a message or EIP-155 transaction via `/Sign`, running the ceremony internally.
|
|
4712
|
+
* `params.KeyId` is required.
|
|
4713
|
+
*
|
|
4714
|
+
* ⚠️ STRICT MODE: unlike {@link signHashWithCeremony} / {@link signTypedDataWithCeremony},
|
|
4715
|
+
* this does NOT auto-bind a payload commitment, because the TA derives the signed digest
|
|
4716
|
+
* from `Message` / `Transaction` host-side (EIP-191 / RLP) and the SDK can't reproduce it
|
|
4717
|
+
* byte-exactly for every input. So it sends the RAW nonce by default — which the KMS will
|
|
4718
|
+
* REJECT once strict mode (#63) is on. For strict-safe signing either:
|
|
4719
|
+
* - pass `options.payload` = the exact digest the TA will sign (you computed it), or
|
|
4720
|
+
* - prefer {@link signHashWithCeremony} (commits to a known 32-byte hash).
|
|
4545
4721
|
*/
|
|
4546
4722
|
async signWithCeremony(params, signer, options) {
|
|
4547
4723
|
this.ensureEnabled();
|
|
4548
4724
|
const WebAuthn = await this.runAuthenticationCeremony(params.KeyId, signer, options);
|
|
4549
4725
|
return this.sign({ ...params, WebAuthn });
|
|
4550
4726
|
}
|
|
4551
|
-
/**
|
|
4727
|
+
/**
|
|
4728
|
+
* Sign a 32-byte digest, running the challenge-binding ceremony internally.
|
|
4729
|
+
* Binds the challenge to `hash` (WYSIWYS commitment, #68) by default — pass an
|
|
4730
|
+
* explicit `options.payload` only to override.
|
|
4731
|
+
*/
|
|
4552
4732
|
async signHashWithCeremony(hash, target, signer, options) {
|
|
4553
4733
|
this.ensureEnabled();
|
|
4554
|
-
const assertion = await this.runAuthenticationCeremony(target.KeyId, signer,
|
|
4734
|
+
const assertion = await this.runAuthenticationCeremony(target.KeyId, signer, {
|
|
4735
|
+
...options,
|
|
4736
|
+
payload: options?.payload ?? hash
|
|
4737
|
+
});
|
|
4555
4738
|
return this.signHashWithWebAuthn(hash, assertion.ChallengeId, assertion.Credential, target);
|
|
4556
4739
|
}
|
|
4557
|
-
/**
|
|
4740
|
+
/**
|
|
4741
|
+
* Sign EIP-712 typed data, running the challenge-binding ceremony internally.
|
|
4742
|
+
* Auto-binds the WYSIWYS commitment (#68): the ceremony challenge is
|
|
4743
|
+
* `SHA-256(nonce ‖ eip712Digest)`, where `eip712Digest` is the standard EIP-712
|
|
4744
|
+
* digest the KMS hashes host-side — computed here via {@link eip712Digest} so the
|
|
4745
|
+
* user's signature commits to the exact typed-data payload. Pass an explicit
|
|
4746
|
+
* `options.payload` only to override.
|
|
4747
|
+
*/
|
|
4558
4748
|
async signTypedDataWithCeremony(params, signer, options) {
|
|
4559
4749
|
this.ensureEnabled();
|
|
4560
|
-
const
|
|
4750
|
+
const payload = options?.payload ?? eip712Digest(params);
|
|
4751
|
+
const webAuthnAssertion = await this.runAuthenticationCeremony(params.keyId, signer, {
|
|
4752
|
+
...options,
|
|
4753
|
+
payload
|
|
4754
|
+
});
|
|
4561
4755
|
return this.signTypedDataWithWebAuthn({ ...params, webAuthnAssertion });
|
|
4562
4756
|
}
|
|
4563
4757
|
/**
|
|
@@ -4566,7 +4760,10 @@ var KmsManager = class {
|
|
|
4566
4760
|
*/
|
|
4567
4761
|
async signGrantSessionWithCeremony(params, signer, options) {
|
|
4568
4762
|
this.ensureEnabled();
|
|
4569
|
-
const webAuthnAssertion = await this.runGrantSessionCeremony(params.keyId, signer,
|
|
4763
|
+
const webAuthnAssertion = await this.runGrantSessionCeremony(params.keyId, signer, {
|
|
4764
|
+
...options,
|
|
4765
|
+
payload: options?.payload ?? grantSessionFinalHash(params)
|
|
4766
|
+
});
|
|
4570
4767
|
return this.signGrantSession({ ...params, webAuthnAssertion });
|
|
4571
4768
|
}
|
|
4572
4769
|
/**
|
|
@@ -4575,7 +4772,10 @@ var KmsManager = class {
|
|
|
4575
4772
|
*/
|
|
4576
4773
|
async signP256GrantSessionWithCeremony(params, signer, options) {
|
|
4577
4774
|
this.ensureEnabled();
|
|
4578
|
-
const webAuthnAssertion = await this.runGrantSessionCeremony(params.keyId, signer,
|
|
4775
|
+
const webAuthnAssertion = await this.runGrantSessionCeremony(params.keyId, signer, {
|
|
4776
|
+
...options,
|
|
4777
|
+
payload: options?.payload ?? grantSessionFinalHash(params)
|
|
4778
|
+
});
|
|
4579
4779
|
return this.signP256GrantSession({ ...params, webAuthnAssertion });
|
|
4580
4780
|
}
|
|
4581
4781
|
// ── WebAuthn Ceremonies ─────────────────────────────────────────
|
|
@@ -4632,7 +4832,7 @@ var KmsManager = class {
|
|
|
4632
4832
|
* @param ceremonySigner authenticator that signs the WebAuthn challenge
|
|
4633
4833
|
* (a browser passkey on the client, or {@link P256PasskeySigner} server-side).
|
|
4634
4834
|
*/
|
|
4635
|
-
createKmsSignerWithCeremony(keyId, address, ceremonySigner, ceremonyOptions, commitPayload =
|
|
4835
|
+
createKmsSignerWithCeremony(keyId, address, ceremonySigner, ceremonyOptions, commitPayload = true) {
|
|
4636
4836
|
this.ensureEnabled();
|
|
4637
4837
|
return new KmsSigner(keyId, address, this, {
|
|
4638
4838
|
mode: "ceremony",
|
|
@@ -4760,7 +4960,15 @@ var KmsAgentService = class {
|
|
|
4760
4960
|
// challenge bound to the HUMAN key. These helpers run the full ceremony
|
|
4761
4961
|
// (begin → clientDataJSON → assertion) via the shared
|
|
4762
4962
|
// {@link runAuthenticationCeremony} helper, then invoke the endpoint.
|
|
4763
|
-
/**
|
|
4963
|
+
/**
|
|
4964
|
+
* Mint an agent key, running the challenge-binding ceremony internally.
|
|
4965
|
+
*
|
|
4966
|
+
* STRICT MODE (AirAccount #115): bind the mint params by passing `options.payload =
|
|
4967
|
+
* mintDigest({ kind: "agent", walletId, index, ttlSecs, subject })` — `index` is the
|
|
4968
|
+
* agent_index the KMS will assign (query it first), `subject` the JWT sub (human key id),
|
|
4969
|
+
* `ttlSecs` the JWT lifetime. Without a payload the ceremony sends the raw nonce, which
|
|
4970
|
+
* strict mode rejects.
|
|
4971
|
+
*/
|
|
4764
4972
|
async createAgentKeyWithCeremony(params, signer, options) {
|
|
4765
4973
|
this.http.ensureEnabled();
|
|
4766
4974
|
const webAuthnAssertion = await runAuthenticationCeremony(
|
|
@@ -4847,7 +5055,15 @@ var KmsSessionService = class {
|
|
|
4847
5055
|
// Create + revoke gate on the generic purpose="authentication" challenge bound
|
|
4848
5056
|
// to the HUMAN key. These helpers run the full ceremony (begin → clientDataJSON
|
|
4849
5057
|
// → assertion) via the shared {@link runAuthenticationCeremony} helper.
|
|
4850
|
-
/**
|
|
5058
|
+
/**
|
|
5059
|
+
* Create a P-256 session key, running the challenge-binding ceremony internally.
|
|
5060
|
+
*
|
|
5061
|
+
* STRICT MODE (AirAccount #115): bind the mint params by passing `options.payload =
|
|
5062
|
+
* mintDigest({ kind: "p256", walletId, index, ttlSecs, subject })` — `index` is the
|
|
5063
|
+
* session_index the KMS will assign (query it first), `subject` the JWT sub (human key
|
|
5064
|
+
* id), `ttlSecs` the JWT lifetime. Without a payload the ceremony sends the raw nonce,
|
|
5065
|
+
* which strict mode rejects.
|
|
5066
|
+
*/
|
|
4851
5067
|
async createP256SessionKeyWithCeremony(params, signer, options) {
|
|
4852
5068
|
this.http.ensureEnabled();
|
|
4853
5069
|
const webAuthnAssertion = await runAuthenticationCeremony(
|
|
@@ -4911,7 +5127,108 @@ var KmsPaymentSigner = class {
|
|
|
4911
5127
|
this.http.ensureEnabled();
|
|
4912
5128
|
return this.signWithAuth("/kms/SignX402Payment", { ...params }, auth);
|
|
4913
5129
|
}
|
|
5130
|
+
// ── Ceremony-internal variants with WYSIWYS payload commitment (#68 / #135 item 1) ──
|
|
5131
|
+
// Each payment endpoint is a fixed-schema SignTypedData host-side, so the commitment
|
|
5132
|
+
// payload is the EIP-712 digest of that schema. We compute it SDK-side (digest helpers
|
|
5133
|
+
// below, schemas mirrored from kms/host/src/api_server.rs) and bind the ceremony
|
|
5134
|
+
// challenge to it: challenge = SHA-256(nonce ‖ eip712Digest). Live-verified against KMS.
|
|
5135
|
+
/** Sign a MicroPaymentChannel voucher, running the committed ceremony internally. */
|
|
5136
|
+
async signMicropaymentVoucherWithCeremony(params, signer, options) {
|
|
5137
|
+
this.http.ensureEnabled();
|
|
5138
|
+
const webAuthnAssertion = await runAuthenticationCeremony(this.http, params.keyId, signer, {
|
|
5139
|
+
...options,
|
|
5140
|
+
payload: micropaymentVoucherDigest(params)
|
|
5141
|
+
});
|
|
5142
|
+
return this.signMicropaymentVoucher(params, { webAuthnAssertion });
|
|
5143
|
+
}
|
|
5144
|
+
/** Sign a GToken EIP-3009 authorization, running the committed ceremony internally. */
|
|
5145
|
+
async signGTokenAuthorizationWithCeremony(params, signer, options) {
|
|
5146
|
+
this.http.ensureEnabled();
|
|
5147
|
+
const webAuthnAssertion = await runAuthenticationCeremony(this.http, params.keyId, signer, {
|
|
5148
|
+
...options,
|
|
5149
|
+
payload: gTokenAuthorizationDigest(params)
|
|
5150
|
+
});
|
|
5151
|
+
return this.signGTokenAuthorization(params, { webAuthnAssertion });
|
|
5152
|
+
}
|
|
5153
|
+
/** Sign an x402 payment, running the committed ceremony internally. */
|
|
5154
|
+
async signX402PaymentWithCeremony(params, signer, options) {
|
|
5155
|
+
this.http.ensureEnabled();
|
|
5156
|
+
const webAuthnAssertion = await runAuthenticationCeremony(this.http, params.keyId, signer, {
|
|
5157
|
+
...options,
|
|
5158
|
+
payload: x402PaymentDigest(params)
|
|
5159
|
+
});
|
|
5160
|
+
return this.signX402Payment(params, { webAuthnAssertion });
|
|
5161
|
+
}
|
|
4914
5162
|
};
|
|
5163
|
+
function micropaymentVoucherDigest(p) {
|
|
5164
|
+
return eip712Digest({
|
|
5165
|
+
domain: { name: "MicroPaymentChannel", version: "1.0.0", chainId: p.chainId, verifyingContract: p.verifyingContract },
|
|
5166
|
+
primaryType: "Voucher",
|
|
5167
|
+
types: [
|
|
5168
|
+
{
|
|
5169
|
+
name: "Voucher",
|
|
5170
|
+
fields: [
|
|
5171
|
+
{ name: "channelId", type: "bytes32" },
|
|
5172
|
+
{ name: "cumulativeAmount", type: "uint256" }
|
|
5173
|
+
]
|
|
5174
|
+
}
|
|
5175
|
+
],
|
|
5176
|
+
message: [
|
|
5177
|
+
{ name: "channelId", value: p.channelId },
|
|
5178
|
+
{ name: "cumulativeAmount", value: p.cumulativeAmount }
|
|
5179
|
+
]
|
|
5180
|
+
});
|
|
5181
|
+
}
|
|
5182
|
+
function gTokenAuthorizationDigest(p) {
|
|
5183
|
+
return eip712Digest({
|
|
5184
|
+
domain: { name: "GToken", version: "1", chainId: p.chainId, verifyingContract: p.gTokenAddress },
|
|
5185
|
+
primaryType: "TransferWithAuthorization",
|
|
5186
|
+
types: [
|
|
5187
|
+
{
|
|
5188
|
+
name: "TransferWithAuthorization",
|
|
5189
|
+
fields: [
|
|
5190
|
+
{ name: "from", type: "address" },
|
|
5191
|
+
{ name: "to", type: "address" },
|
|
5192
|
+
{ name: "value", type: "uint256" },
|
|
5193
|
+
{ name: "validAfter", type: "uint256" },
|
|
5194
|
+
{ name: "validBefore", type: "uint256" },
|
|
5195
|
+
{ name: "nonce", type: "bytes32" }
|
|
5196
|
+
]
|
|
5197
|
+
}
|
|
5198
|
+
],
|
|
5199
|
+
message: [
|
|
5200
|
+
{ name: "from", value: p.from },
|
|
5201
|
+
{ name: "to", value: p.to },
|
|
5202
|
+
{ name: "value", value: p.value },
|
|
5203
|
+
{ name: "validAfter", value: p.validAfter },
|
|
5204
|
+
{ name: "validBefore", value: p.validBefore },
|
|
5205
|
+
{ name: "nonce", value: p.nonce }
|
|
5206
|
+
]
|
|
5207
|
+
});
|
|
5208
|
+
}
|
|
5209
|
+
function x402PaymentDigest(p) {
|
|
5210
|
+
return eip712Digest({
|
|
5211
|
+
domain: { name: "SuperPaymaster", version: "1", chainId: p.chainId, verifyingContract: p.verifyingContract },
|
|
5212
|
+
primaryType: "PaymentPayload",
|
|
5213
|
+
types: [
|
|
5214
|
+
{
|
|
5215
|
+
name: "PaymentPayload",
|
|
5216
|
+
fields: [
|
|
5217
|
+
{ name: "paymentId", type: "bytes32" },
|
|
5218
|
+
{ name: "amount", type: "uint256" },
|
|
5219
|
+
{ name: "recipient", type: "address" },
|
|
5220
|
+
{ name: "deadline", type: "uint256" }
|
|
5221
|
+
]
|
|
5222
|
+
}
|
|
5223
|
+
],
|
|
5224
|
+
message: [
|
|
5225
|
+
{ name: "paymentId", value: p.paymentId },
|
|
5226
|
+
{ name: "amount", value: p.amount },
|
|
5227
|
+
{ name: "recipient", value: p.recipient },
|
|
5228
|
+
{ name: "deadline", value: p.deadline }
|
|
5229
|
+
]
|
|
5230
|
+
});
|
|
5231
|
+
}
|
|
4915
5232
|
|
|
4916
5233
|
// ../airaccount/src/server/services/kms-monitor-service.ts
|
|
4917
5234
|
var KmsMonitorService = class {
|
|
@@ -5204,14 +5521,19 @@ exports.buildInstallModuleHash = buildInstallModuleHash;
|
|
|
5204
5521
|
exports.buildUninstallModuleHash = buildUninstallModuleHash;
|
|
5205
5522
|
exports.commitChallenge = commitChallenge;
|
|
5206
5523
|
exports.computeOapdSalt = computeOapdSalt;
|
|
5524
|
+
exports.eip712Digest = eip712Digest;
|
|
5207
5525
|
exports.erc8004AddressesForChain = erc8004AddressesForChain;
|
|
5526
|
+
exports.gTokenAuthorizationDigest = gTokenAuthorizationDigest;
|
|
5208
5527
|
exports.getOapdAddress = getOapdAddress;
|
|
5209
5528
|
exports.getOapdAddressWithChainId = getOapdAddressWithChainId;
|
|
5529
|
+
exports.grantSessionFinalHash = grantSessionFinalHash;
|
|
5210
5530
|
exports.initConfigFromRecord = initConfigFromRecord;
|
|
5211
5531
|
exports.initConfigToTuple = initConfigToTuple;
|
|
5212
5532
|
exports.isExecuteUserOpWrapped = isExecuteUserOpWrapped;
|
|
5213
5533
|
exports.isOapdDeployed = isOapdDeployed;
|
|
5214
5534
|
exports.isPendingConfirmation = isPendingConfirmation;
|
|
5535
|
+
exports.micropaymentVoucherDigest = micropaymentVoucherDigest;
|
|
5536
|
+
exports.mintDigest = mintDigest;
|
|
5215
5537
|
exports.packP256SessionSignature = packP256SessionSignature;
|
|
5216
5538
|
exports.packSecp256k1SessionSignature = packSecp256k1SessionSignature;
|
|
5217
5539
|
exports.runAuthenticationCeremony = runAuthenticationCeremony;
|
|
@@ -5222,5 +5544,6 @@ exports.serializeGuardianSpecs = serializeGuardianSpecs;
|
|
|
5222
5544
|
exports.toGuardianSpecs = toGuardianSpecs;
|
|
5223
5545
|
exports.validateConfig = validateConfig;
|
|
5224
5546
|
exports.wrapExecuteUserOp = wrapExecuteUserOp;
|
|
5225
|
-
|
|
5226
|
-
//# sourceMappingURL=chunk-
|
|
5547
|
+
exports.x402PaymentDigest = x402PaymentDigest;
|
|
5548
|
+
//# sourceMappingURL=chunk-UZE7IPOK.cjs.map
|
|
5549
|
+
//# sourceMappingURL=chunk-UZE7IPOK.cjs.map
|