kawasekit 0.5.0 → 0.7.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/{chunk-6CNAYQOL.js → chunk-7YKRKV6D.js} +18 -4
- package/dist/chunk-7YKRKV6D.js.map +1 -0
- package/dist/{chunk-S2ZSX2VS.js → chunk-NY6VLXQB.js} +3 -3
- package/dist/{chunk-S2ZSX2VS.js.map → chunk-NY6VLXQB.js.map} +1 -1
- package/dist/chunk-UIDDRHLW.js +65 -0
- package/dist/chunk-UIDDRHLW.js.map +1 -0
- package/dist/chunk-Y2LOACWO.js +88 -0
- package/dist/chunk-Y2LOACWO.js.map +1 -0
- package/dist/cli/index.cjs +41 -9
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +5 -5
- package/dist/index.cjs +87 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -3
- package/dist/index.d.ts +78 -3
- package/dist/index.js +4 -4
- package/dist/policy/index.cjs +42 -10
- package/dist/policy/index.cjs.map +1 -1
- package/dist/policy/index.d.cts +41 -3
- package/dist/policy/index.d.ts +41 -3
- package/dist/policy/index.js +2 -2
- package/dist/signer/index.cjs.map +1 -1
- package/dist/signer/index.d.cts +1 -1
- package/dist/signer/index.d.ts +1 -1
- package/dist/signer/index.js +2 -2
- package/dist/{spending-policy-BD2Mpm-L.d.ts → spending-policy-BBgXDrVD.d.ts} +10 -3
- package/dist/{spending-policy-CGIaBpg-.d.cts → spending-policy-CwXcTFD_.d.cts} +10 -3
- package/package.json +1 -1
- package/dist/chunk-6CNAYQOL.js.map +0 -1
- package/dist/chunk-E47SIVFY.js +0 -44
- package/dist/chunk-E47SIVFY.js.map +0 -1
- package/dist/chunk-RJLDKDWL.js +0 -43
- package/dist/chunk-RJLDKDWL.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { transferJpyc } from '../chunk-
|
|
2
|
+
import { transferJpyc } from '../chunk-Y2LOACWO.js';
|
|
3
3
|
import '../chunk-P5563RGP.js';
|
|
4
4
|
import '../chunk-PVUKX6IF.js';
|
|
5
5
|
import '../chunk-LEHWRDVS.js';
|
|
6
6
|
import '../chunk-TTX3RBIZ.js';
|
|
7
7
|
import '../chunk-QHUCU5YX.js';
|
|
8
8
|
import { issueSessionKey, serializeSessionEnvelope, restoreSessionAccount, revokeSessionKey, rotateSessionKey, parseSessionEnvelope } from '../chunk-N3CVLISJ.js';
|
|
9
|
-
import '../chunk-
|
|
9
|
+
import '../chunk-NY6VLXQB.js';
|
|
10
10
|
import '../chunk-VJUXTVSW.js';
|
|
11
11
|
import '../chunk-WMVJNPX2.js';
|
|
12
|
-
import { createJpycDailyLimitPolicies } from '../chunk-
|
|
13
|
-
import '../chunk-
|
|
12
|
+
import { createJpycDailyLimitPolicies } from '../chunk-UIDDRHLW.js';
|
|
13
|
+
import '../chunk-7YKRKV6D.js';
|
|
14
14
|
import { JPYC_DECIMALS, getJpycAddress, jpycAbi } from '../chunk-KT7XDT2T.js';
|
|
15
15
|
import { zerodevRpcUrl, polygon, polygonAmoy } from '../chunk-SOTYGX67.js';
|
|
16
16
|
import { __commonJS, __require, __toESM } from '../chunk-7D4SUZUM.js';
|
|
@@ -980,7 +980,7 @@ function registerTransferCommand(program2) {
|
|
|
980
980
|
}
|
|
981
981
|
|
|
982
982
|
// cli/index.ts
|
|
983
|
-
var CLI_VERSION = "0.
|
|
983
|
+
var CLI_VERSION = "0.7.0" ;
|
|
984
984
|
var program = new Command();
|
|
985
985
|
program.name("kawasekit").description(
|
|
986
986
|
"kawasekit \u2014 CLI for the kawasekit SDK (AI-agent stablecoin payments, Japan-first, JPYC-native)."
|
package/dist/index.cjs
CHANGED
|
@@ -363,19 +363,36 @@ async function transferJpyc(kernelClient, params) {
|
|
|
363
363
|
success: receipt.success
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
|
|
367
|
-
|
|
366
|
+
function normalizeRecipientAllowlist(allowlist) {
|
|
367
|
+
const seen = /* @__PURE__ */ new Set();
|
|
368
|
+
const normalized = [];
|
|
369
|
+
for (const entry of allowlist) {
|
|
370
|
+
const checksummed = viem.getAddress(entry);
|
|
371
|
+
if (!seen.has(checksummed)) {
|
|
372
|
+
seen.add(checksummed);
|
|
373
|
+
normalized.push(checksummed);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return normalized;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/policy/jpyc-call-policy.ts
|
|
380
|
+
function buildJpycTransferCallPolicy(params) {
|
|
368
381
|
if (params.maxPerTransfer <= 0n) {
|
|
382
|
+
throw new Error(`maxPerTransfer must be positive, got ${params.maxPerTransfer}.`);
|
|
383
|
+
}
|
|
384
|
+
const recipients = params.recipientAllowlist === void 0 || params.recipientAllowlist === "any" ? null : normalizeRecipientAllowlist(params.recipientAllowlist);
|
|
385
|
+
if (recipients !== null && recipients.length === 0) {
|
|
369
386
|
throw new Error(
|
|
370
|
-
|
|
387
|
+
'recipientAllowlist must not be empty \u2014 omit it or pass "any" to allow any recipient.'
|
|
371
388
|
);
|
|
372
389
|
}
|
|
373
|
-
if (
|
|
390
|
+
if (recipients !== null && params.callPolicyVersion === policies.CallPolicyVersion.V0_0_1) {
|
|
374
391
|
throw new Error(
|
|
375
|
-
|
|
392
|
+
"recipientAllowlist requires callPolicyVersion V0_0_2 or later (the ONE_OF condition is unsupported on V0_0_1)."
|
|
376
393
|
);
|
|
377
394
|
}
|
|
378
|
-
|
|
395
|
+
return policies.toCallPolicy({
|
|
379
396
|
policyVersion: params.callPolicyVersion ?? policies.CallPolicyVersion.V0_0_4,
|
|
380
397
|
permissions: [
|
|
381
398
|
{
|
|
@@ -383,8 +400,9 @@ function createJpycDailyLimitPolicies(params) {
|
|
|
383
400
|
abi: jpycAbi,
|
|
384
401
|
functionName: "transfer",
|
|
385
402
|
args: [
|
|
386
|
-
// Recipient:
|
|
387
|
-
|
|
403
|
+
// Recipient (`to`): unrestricted (`null`) unless an allowlist resolved
|
|
404
|
+
// above, in which case it is constrained via the ONE_OF condition.
|
|
405
|
+
recipients === null ? null : { condition: policies.ParamCondition.ONE_OF, value: recipients },
|
|
388
406
|
// value: must be ≤ maxPerTransfer.
|
|
389
407
|
{
|
|
390
408
|
condition: policies.ParamCondition.LESS_THAN_OR_EQUAL,
|
|
@@ -394,6 +412,65 @@ function createJpycDailyLimitPolicies(params) {
|
|
|
394
412
|
}
|
|
395
413
|
]
|
|
396
414
|
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// src/policy/buy-list.ts
|
|
418
|
+
function createBuyListPolicies(params) {
|
|
419
|
+
if (params.merchants.length === 0) {
|
|
420
|
+
throw new Error(
|
|
421
|
+
"createBuyListPolicies: merchants must not be empty \u2014 a buy-list must target at least one merchant."
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
if (!Number.isInteger(params.maxTransfers) || params.maxTransfers < 1) {
|
|
425
|
+
throw new Error(
|
|
426
|
+
`createBuyListPolicies: maxTransfers must be a positive integer, got ${params.maxTransfers}.`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
if (!Number.isInteger(params.validUntil) || params.validUntil <= 0) {
|
|
430
|
+
throw new Error(
|
|
431
|
+
`createBuyListPolicies: validUntil must be a positive unix-seconds integer, got ${params.validUntil}.`
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
const validAfter = params.validAfter ?? 0;
|
|
435
|
+
if (!Number.isInteger(validAfter) || validAfter < 0) {
|
|
436
|
+
throw new Error(
|
|
437
|
+
`createBuyListPolicies: validAfter must be a non-negative unix-seconds integer, got ${params.validAfter}.`
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
if (validAfter >= params.validUntil) {
|
|
441
|
+
throw new Error(
|
|
442
|
+
`createBuyListPolicies: validAfter (${validAfter}) must be before validUntil (${params.validUntil}).`
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
const callPolicy = buildJpycTransferCallPolicy({
|
|
446
|
+
jpycAddress: params.jpycAddress,
|
|
447
|
+
maxPerTransfer: params.maxPerTransfer,
|
|
448
|
+
recipientAllowlist: params.merchants,
|
|
449
|
+
callPolicyVersion: params.callPolicyVersion
|
|
450
|
+
});
|
|
451
|
+
const rateLimitPolicy = policies.toRateLimitPolicy({
|
|
452
|
+
interval: params.validUntil - validAfter,
|
|
453
|
+
count: params.maxTransfers,
|
|
454
|
+
startAt: validAfter
|
|
455
|
+
});
|
|
456
|
+
const timestampPolicy = policies.toTimestampPolicy(
|
|
457
|
+
params.validAfter === void 0 ? { validUntil: params.validUntil } : { validAfter: params.validAfter, validUntil: params.validUntil }
|
|
458
|
+
);
|
|
459
|
+
return [callPolicy, rateLimitPolicy, timestampPolicy];
|
|
460
|
+
}
|
|
461
|
+
var ONE_DAY_SECONDS = 86400;
|
|
462
|
+
function createJpycDailyLimitPolicies(params) {
|
|
463
|
+
if (!Number.isInteger(params.maxTransfersPerDay) || params.maxTransfersPerDay < 1) {
|
|
464
|
+
throw new Error(
|
|
465
|
+
`createJpycDailyLimitPolicies: maxTransfersPerDay must be a positive integer, got ${params.maxTransfersPerDay}.`
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
const callPolicy = buildJpycTransferCallPolicy({
|
|
469
|
+
jpycAddress: params.jpycAddress,
|
|
470
|
+
maxPerTransfer: params.maxPerTransfer,
|
|
471
|
+
recipientAllowlist: params.recipientAllowlist,
|
|
472
|
+
callPolicyVersion: params.callPolicyVersion
|
|
473
|
+
});
|
|
397
474
|
const rateLimitPolicy = policies.toRateLimitPolicy({
|
|
398
475
|
interval: ONE_DAY_SECONDS,
|
|
399
476
|
count: params.maxTransfersPerDay
|
|
@@ -501,7 +578,7 @@ function createSpendingPolicy(params) {
|
|
|
501
578
|
}
|
|
502
579
|
return { token, maxPerSign: l.maxPerSign };
|
|
503
580
|
});
|
|
504
|
-
const recipientAllowlist = params.recipientAllowlist === "any" ? "any" : params.recipientAllowlist
|
|
581
|
+
const recipientAllowlist = params.recipientAllowlist === "any" ? "any" : normalizeRecipientAllowlist(params.recipientAllowlist);
|
|
505
582
|
return {
|
|
506
583
|
version: "1",
|
|
507
584
|
session: { id: params.session.id, notAfter: params.session.notAfter },
|
|
@@ -3208,6 +3285,7 @@ exports.cancelAuthorizationTypes = cancelAuthorizationTypes;
|
|
|
3208
3285
|
exports.canonicalRequestBytes = canonicalRequestBytes;
|
|
3209
3286
|
exports.chainIdToX402Network = chainIdToX402Network;
|
|
3210
3287
|
exports.createAgentSmartAccount = createAgentSmartAccount;
|
|
3288
|
+
exports.createBuyListPolicies = createBuyListPolicies;
|
|
3211
3289
|
exports.createCoinbaseFacilitator = createCoinbaseFacilitator;
|
|
3212
3290
|
exports.createHttpFacilitator = createHttpFacilitator;
|
|
3213
3291
|
exports.createIdempotencyKeyBuilder = createIdempotencyKeyBuilder;
|