kawasekit 0.6.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/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { transferJpyc } from '../chunk-RJLDKDWL.js';
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';
@@ -9,7 +9,7 @@ import { issueSessionKey, serializeSessionEnvelope, restoreSessionAccount, revok
9
9
  import '../chunk-NY6VLXQB.js';
10
10
  import '../chunk-VJUXTVSW.js';
11
11
  import '../chunk-WMVJNPX2.js';
12
- import { createJpycDailyLimitPolicies } from '../chunk-X54U6GU4.js';
12
+ import { createJpycDailyLimitPolicies } from '../chunk-UIDDRHLW.js';
13
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';
@@ -980,7 +980,7 @@ function registerTransferCommand(program2) {
980
980
  }
981
981
 
982
982
  // cli/index.ts
983
- var CLI_VERSION = "0.6.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
@@ -376,31 +376,23 @@ function normalizeRecipientAllowlist(allowlist) {
376
376
  return normalized;
377
377
  }
378
378
 
379
- // src/policy/daily-limit.ts
380
- var ONE_DAY_SECONDS = 86400;
381
- function createJpycDailyLimitPolicies(params) {
379
+ // src/policy/jpyc-call-policy.ts
380
+ function buildJpycTransferCallPolicy(params) {
382
381
  if (params.maxPerTransfer <= 0n) {
383
- throw new Error(
384
- `createJpycDailyLimitPolicies: maxPerTransfer must be positive, got ${params.maxPerTransfer}.`
385
- );
386
- }
387
- if (!Number.isInteger(params.maxTransfersPerDay) || params.maxTransfersPerDay < 1) {
388
- throw new Error(
389
- `createJpycDailyLimitPolicies: maxTransfersPerDay must be a positive integer, got ${params.maxTransfersPerDay}.`
390
- );
382
+ throw new Error(`maxPerTransfer must be positive, got ${params.maxPerTransfer}.`);
391
383
  }
392
384
  const recipients = params.recipientAllowlist === void 0 || params.recipientAllowlist === "any" ? null : normalizeRecipientAllowlist(params.recipientAllowlist);
393
385
  if (recipients !== null && recipients.length === 0) {
394
386
  throw new Error(
395
- 'createJpycDailyLimitPolicies: recipientAllowlist must not be empty \u2014 omit it or pass "any" to allow any recipient.'
387
+ 'recipientAllowlist must not be empty \u2014 omit it or pass "any" to allow any recipient.'
396
388
  );
397
389
  }
398
390
  if (recipients !== null && params.callPolicyVersion === policies.CallPolicyVersion.V0_0_1) {
399
391
  throw new Error(
400
- "createJpycDailyLimitPolicies: recipientAllowlist requires callPolicyVersion V0_0_2 or later (the ONE_OF condition is unsupported on V0_0_1)."
392
+ "recipientAllowlist requires callPolicyVersion V0_0_2 or later (the ONE_OF condition is unsupported on V0_0_1)."
401
393
  );
402
394
  }
403
- const callPolicy = policies.toCallPolicy({
395
+ return policies.toCallPolicy({
404
396
  policyVersion: params.callPolicyVersion ?? policies.CallPolicyVersion.V0_0_4,
405
397
  permissions: [
406
398
  {
@@ -420,6 +412,65 @@ function createJpycDailyLimitPolicies(params) {
420
412
  }
421
413
  ]
422
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
+ });
423
474
  const rateLimitPolicy = policies.toRateLimitPolicy({
424
475
  interval: ONE_DAY_SECONDS,
425
476
  count: params.maxTransfersPerDay
@@ -3234,6 +3285,7 @@ exports.cancelAuthorizationTypes = cancelAuthorizationTypes;
3234
3285
  exports.canonicalRequestBytes = canonicalRequestBytes;
3235
3286
  exports.chainIdToX402Network = chainIdToX402Network;
3236
3287
  exports.createAgentSmartAccount = createAgentSmartAccount;
3288
+ exports.createBuyListPolicies = createBuyListPolicies;
3237
3289
  exports.createCoinbaseFacilitator = createCoinbaseFacilitator;
3238
3290
  exports.createHttpFacilitator = createHttpFacilitator;
3239
3291
  exports.createIdempotencyKeyBuilder = createIdempotencyKeyBuilder;