@heyanon-arp/sdk 0.0.13 → 0.0.15

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/index.js CHANGED
@@ -202,6 +202,7 @@ function verifyChallenge(challengeBytes, signature, identityPubkey) {
202
202
  }
203
203
 
204
204
  // src/types/identity.ts
205
+ var OWNER_SIGNING_METHODS = ["scrypt_password_proof", "ed25519_owner_key", "totp+passphrase"];
205
206
  var SCRYPT_PARAMS = {
206
207
  N: 32768,
207
208
  r: 8,
@@ -306,9 +307,13 @@ function bytesToHex2(b) {
306
307
  return s;
307
308
  }
308
309
 
309
- // src/settlement/token-program.ts
310
+ // src/settlement/program-ids.ts
310
311
  var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
311
312
  var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
313
+ var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
314
+ var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
315
+
316
+ // src/settlement/token-program.ts
312
317
  function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
313
318
  if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
314
319
  return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
@@ -360,6 +365,10 @@ function senderNonce() {
360
365
  return base.base64urlnopad.encode(utils.randomBytes(16));
361
366
  }
362
367
 
368
+ // src/utils/time-windows.ts
369
+ var MAX_CLOCK_SKEW_SECONDS = 300;
370
+ var MAX_ENVELOPE_TTL_SECONDS = 86400;
371
+
363
372
  // src/utils/timestamp.ts
364
373
  function rfc3339(at = /* @__PURE__ */ new Date()) {
365
374
  return `${at.toISOString().slice(0, 19)}Z`;
@@ -368,8 +377,8 @@ function expiresAt(ttlSeconds, now = /* @__PURE__ */ new Date()) {
368
377
  if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
369
378
  throw new Error(`expiresAt: ttlSeconds must be positive, got ${ttlSeconds}`);
370
379
  }
371
- if (ttlSeconds > 24 * 60 * 60) {
372
- throw new Error(`expiresAt: ttlSeconds exceeds 24h cap, got ${ttlSeconds}`);
380
+ if (ttlSeconds > MAX_ENVELOPE_TTL_SECONDS) {
381
+ throw new Error(`expiresAt: ttlSeconds exceeds ${MAX_ENVELOPE_TTL_SECONDS}s (24h) cap, got ${ttlSeconds}`);
373
382
  }
374
383
  return rfc3339(new Date(now.getTime() + ttlSeconds * 1e3));
375
384
  }
@@ -411,11 +420,67 @@ function sleepWithAbort(ms, signal) {
411
420
  });
412
421
  }
413
422
 
423
+ // src/types/envelope.ts
424
+ var SHA256_HEX_RE = /^sha256:[0-9a-f]{64}$/;
425
+ function isSha256Hex(v) {
426
+ return typeof v === "string" && SHA256_HEX_RE.test(v);
427
+ }
428
+ var ED25519_SIG_PREFIX = "ed25519:";
429
+ var PROTOCOL_VERSIONS = ["arp/0.1"];
430
+
414
431
  // src/types/body.ts
415
432
  var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
416
433
  function isDeclineReason(v) {
417
434
  return typeof v === "string" && DECLINE_REASONS.includes(v);
418
435
  }
436
+ var HANDSHAKE_DECISIONS = ["accept", "decline"];
437
+ function isHandshakeDecision(v) {
438
+ return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
439
+ }
440
+ var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
441
+ function isDelegationAction(v) {
442
+ return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
443
+ }
444
+ var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
445
+ function isReceiptVerdict(v) {
446
+ return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
447
+ }
448
+ var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
449
+ function isBodyType(v) {
450
+ return typeof v === "string" && BODY_TYPES.includes(v);
451
+ }
452
+
453
+ // src/types/delegation.ts
454
+ var DELEGATION_STATES = [
455
+ "offered",
456
+ "accepted",
457
+ "pending_lock_finalization",
458
+ "locked",
459
+ "disputing",
460
+ "completed",
461
+ "declined",
462
+ "canceled",
463
+ "failed",
464
+ "refunded",
465
+ "dispute_resolved"
466
+ ];
467
+ var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalization", "locked"];
468
+ function isDelegationState(v) {
469
+ return typeof v === "string" && DELEGATION_STATES.includes(v);
470
+ }
471
+
472
+ // src/types/relationship.ts
473
+ var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
474
+ var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
475
+ function isRelationshipState(v) {
476
+ return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
477
+ }
478
+
479
+ // src/types/work-log.ts
480
+ var WORK_LOG_STATES = ["requested", "responded"];
481
+ function isWorkLogState(v) {
482
+ return typeof v === "string" && WORK_LOG_STATES.includes(v);
483
+ }
419
484
 
420
485
  // src/assets.ts
421
486
  var SOLANA_CLUSTER_IDS = {
@@ -712,26 +777,44 @@ function readU64LE(buf, off) {
712
777
  }
713
778
 
714
779
  exports.ASSET_WHITELIST = ASSET_WHITELIST;
780
+ exports.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = ASSOCIATED_TOKEN_PROGRAM_ID_BASE58;
781
+ exports.BODY_TYPES = BODY_TYPES;
715
782
  exports.CAIP19_REGEX = CAIP19_REGEX;
716
783
  exports.CREATE_LOCK_DISCRIMINATOR = CREATE_LOCK_DISCRIMINATOR;
717
784
  exports.CREATE_LOCK_NATIVE_DISCRIMINATOR = CREATE_LOCK_NATIVE_DISCRIMINATOR;
718
785
  exports.DECLINE_REASONS = DECLINE_REASONS;
786
+ exports.DELEGATION_ACTIONS = DELEGATION_ACTIONS;
787
+ exports.DELEGATION_ACTIVE_STATES = DELEGATION_ACTIVE_STATES;
788
+ exports.DELEGATION_STATES = DELEGATION_STATES;
719
789
  exports.DEVNET_MINTS = DEVNET_MINTS;
790
+ exports.ED25519_SIG_PREFIX = ED25519_SIG_PREFIX;
720
791
  exports.ESCROW_PDA_SEEDS = ESCROW_PDA_SEEDS;
792
+ exports.HANDSHAKE_DECISIONS = HANDSHAKE_DECISIONS;
793
+ exports.LIVE_RELATIONSHIP_STATE_NAMES = LIVE_RELATIONSHIP_STATE_NAMES;
721
794
  exports.LOCK_ACCOUNT_DISCRIMINATOR = LOCK_ACCOUNT_DISCRIMINATOR;
722
795
  exports.LOCK_ACCOUNT_SIZE = LOCK_ACCOUNT_SIZE;
723
796
  exports.LOCK_STATE_NAMES = LOCK_STATE_NAMES;
724
797
  exports.LOCK_TERMINAL_STATES = LOCK_TERMINAL_STATES;
725
798
  exports.MAINNET_MINTS = MAINNET_MINTS;
799
+ exports.MAX_CLOCK_SKEW_SECONDS = MAX_CLOCK_SKEW_SECONDS;
800
+ exports.MAX_ENVELOPE_TTL_SECONDS = MAX_ENVELOPE_TTL_SECONDS;
726
801
  exports.NATIVE_SOL_MINT_BASE58 = NATIVE_SOL_MINT_BASE58;
727
802
  exports.NO_ARG_LIFECYCLE_INSTRUCTIONS = NO_ARG_LIFECYCLE_INSTRUCTIONS;
803
+ exports.OWNER_SIGNING_METHODS = OWNER_SIGNING_METHODS;
804
+ exports.PROTOCOL_VERSIONS = PROTOCOL_VERSIONS;
728
805
  exports.Purpose = Purpose;
806
+ exports.RECEIPT_VERDICTS = RECEIPT_VERDICTS;
807
+ exports.RELATIONSHIP_STATE_NAMES = RELATIONSHIP_STATE_NAMES;
729
808
  exports.SCRYPT_PARAMS = SCRYPT_PARAMS;
809
+ exports.SHA256_HEX_RE = SHA256_HEX_RE;
730
810
  exports.SLIP44_SOLANA = SLIP44_SOLANA;
731
811
  exports.SOLANA_CLUSTER_IDS = SOLANA_CLUSTER_IDS;
732
812
  exports.SPL_TOKEN_PROGRAM_ID_BASE58 = SPL_TOKEN_PROGRAM_ID_BASE58;
813
+ exports.SYSTEM_PROGRAM_ID_BASE58 = SYSTEM_PROGRAM_ID_BASE58;
814
+ exports.TOKEN_2022_PROGRAM_ID_BASE58 = TOKEN_2022_PROGRAM_ID_BASE58;
733
815
  exports.WELL_KNOWN_ASSETS = WELL_KNOWN_ASSETS;
734
816
  exports.WELL_KNOWN_ASSET_KEYS = WELL_KNOWN_ASSET_KEYS;
817
+ exports.WORK_LOG_STATES = WORK_LOG_STATES;
735
818
  exports.base58btcDecode = base58btcDecode;
736
819
  exports.base58btcEncode = base58btcEncode;
737
820
  exports.buildCreateLockIxData = buildCreateLockIxData;
@@ -758,9 +841,17 @@ exports.generateKeyPair = generateKeyPair;
758
841
  exports.getPublicKey = getPublicKey2;
759
842
  exports.instructionDiscriminator = instructionDiscriminator;
760
843
  exports.isAssetIdentifier = isAssetIdentifier;
844
+ exports.isBodyType = isBodyType;
761
845
  exports.isDeclineReason = isDeclineReason;
846
+ exports.isDelegationAction = isDelegationAction;
847
+ exports.isDelegationState = isDelegationState;
848
+ exports.isHandshakeDecision = isHandshakeDecision;
849
+ exports.isReceiptVerdict = isReceiptVerdict;
850
+ exports.isRelationshipState = isRelationshipState;
851
+ exports.isSha256Hex = isSha256Hex;
762
852
  exports.isValidDid = isValidDid;
763
853
  exports.isWhitelistedAssetId = isWhitelistedAssetId;
854
+ exports.isWorkLogState = isWorkLogState;
764
855
  exports.listWhitelistedAssets = listWhitelistedAssets;
765
856
  exports.parseCaip19SolanaAssetId = parseCaip19SolanaAssetId;
766
857
  exports.parseDid = parseDid;
package/dist/index.mjs CHANGED
@@ -177,6 +177,7 @@ function verifyChallenge(challengeBytes, signature, identityPubkey) {
177
177
  }
178
178
 
179
179
  // src/types/identity.ts
180
+ var OWNER_SIGNING_METHODS = ["scrypt_password_proof", "ed25519_owner_key", "totp+passphrase"];
180
181
  var SCRYPT_PARAMS = {
181
182
  N: 32768,
182
183
  r: 8,
@@ -281,9 +282,13 @@ function bytesToHex2(b) {
281
282
  return s;
282
283
  }
283
284
 
284
- // src/settlement/token-program.ts
285
+ // src/settlement/program-ids.ts
285
286
  var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
286
287
  var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
288
+ var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
289
+ var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
290
+
291
+ // src/settlement/token-program.ts
287
292
  function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
288
293
  if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
289
294
  return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
@@ -335,6 +340,10 @@ function senderNonce() {
335
340
  return base64urlnopad.encode(randomBytes(16));
336
341
  }
337
342
 
343
+ // src/utils/time-windows.ts
344
+ var MAX_CLOCK_SKEW_SECONDS = 300;
345
+ var MAX_ENVELOPE_TTL_SECONDS = 86400;
346
+
338
347
  // src/utils/timestamp.ts
339
348
  function rfc3339(at = /* @__PURE__ */ new Date()) {
340
349
  return `${at.toISOString().slice(0, 19)}Z`;
@@ -343,8 +352,8 @@ function expiresAt(ttlSeconds, now = /* @__PURE__ */ new Date()) {
343
352
  if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
344
353
  throw new Error(`expiresAt: ttlSeconds must be positive, got ${ttlSeconds}`);
345
354
  }
346
- if (ttlSeconds > 24 * 60 * 60) {
347
- throw new Error(`expiresAt: ttlSeconds exceeds 24h cap, got ${ttlSeconds}`);
355
+ if (ttlSeconds > MAX_ENVELOPE_TTL_SECONDS) {
356
+ throw new Error(`expiresAt: ttlSeconds exceeds ${MAX_ENVELOPE_TTL_SECONDS}s (24h) cap, got ${ttlSeconds}`);
348
357
  }
349
358
  return rfc3339(new Date(now.getTime() + ttlSeconds * 1e3));
350
359
  }
@@ -386,11 +395,67 @@ function sleepWithAbort(ms, signal) {
386
395
  });
387
396
  }
388
397
 
398
+ // src/types/envelope.ts
399
+ var SHA256_HEX_RE = /^sha256:[0-9a-f]{64}$/;
400
+ function isSha256Hex(v) {
401
+ return typeof v === "string" && SHA256_HEX_RE.test(v);
402
+ }
403
+ var ED25519_SIG_PREFIX = "ed25519:";
404
+ var PROTOCOL_VERSIONS = ["arp/0.1"];
405
+
389
406
  // src/types/body.ts
390
407
  var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
391
408
  function isDeclineReason(v) {
392
409
  return typeof v === "string" && DECLINE_REASONS.includes(v);
393
410
  }
411
+ var HANDSHAKE_DECISIONS = ["accept", "decline"];
412
+ function isHandshakeDecision(v) {
413
+ return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
414
+ }
415
+ var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
416
+ function isDelegationAction(v) {
417
+ return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
418
+ }
419
+ var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
420
+ function isReceiptVerdict(v) {
421
+ return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
422
+ }
423
+ var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
424
+ function isBodyType(v) {
425
+ return typeof v === "string" && BODY_TYPES.includes(v);
426
+ }
427
+
428
+ // src/types/delegation.ts
429
+ var DELEGATION_STATES = [
430
+ "offered",
431
+ "accepted",
432
+ "pending_lock_finalization",
433
+ "locked",
434
+ "disputing",
435
+ "completed",
436
+ "declined",
437
+ "canceled",
438
+ "failed",
439
+ "refunded",
440
+ "dispute_resolved"
441
+ ];
442
+ var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalization", "locked"];
443
+ function isDelegationState(v) {
444
+ return typeof v === "string" && DELEGATION_STATES.includes(v);
445
+ }
446
+
447
+ // src/types/relationship.ts
448
+ var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
449
+ var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
450
+ function isRelationshipState(v) {
451
+ return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
452
+ }
453
+
454
+ // src/types/work-log.ts
455
+ var WORK_LOG_STATES = ["requested", "responded"];
456
+ function isWorkLogState(v) {
457
+ return typeof v === "string" && WORK_LOG_STATES.includes(v);
458
+ }
394
459
 
395
460
  // src/assets.ts
396
461
  var SOLANA_CLUSTER_IDS = {
@@ -686,4 +751,4 @@ function readU64LE(buf, off) {
686
751
  return v;
687
752
  }
688
753
 
689
- export { ASSET_WHITELIST, CAIP19_REGEX, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, DECLINE_REASONS, DEVNET_MINTS, ESCROW_PDA_SEEDS, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, MAINNET_MINTS, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, Purpose, SCRYPT_PARAMS, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildLifecycleIxData, buildResolveDisputeIxData, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isDeclineReason, isValidDid, isWhitelistedAssetId, listWhitelistedAssets, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
754
+ export { ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, CAIP19_REGEX, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_STATES, DEVNET_MINTS, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, HANDSHAKE_DECISIONS, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, PROTOCOL_VERSIONS, Purpose, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, WORK_LOG_STATES, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildLifecycleIxData, buildResolveDisputeIxData, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isDeclineReason, isDelegationAction, isDelegationState, isHandshakeDecision, isReceiptVerdict, isRelationshipState, isSha256Hex, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
@@ -1,2 +1,3 @@
1
- export { detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, SPL_TOKEN_PROGRAM_ID_BASE58 } from './token-program';
1
+ export { SPL_TOKEN_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58 } from './program-ids';
2
+ export { detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes } from './token-program';
2
3
  export type { TokenProgramKind, TokenProgramDetection } from './token-program';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Canonical Solana program-id base58 strings shared by the escrow tx
3
+ * builders / decoders (server + CLI).
4
+ *
5
+ * Kept as plain base58 STRINGS, never `@solana/web3.js` `PublicKey`
6
+ * objects, so the SDK stays framework- and web3.js-agnostic; consumers
7
+ * wrap them in `new PublicKey(...)` at the call site. Single source of
8
+ * truth — these were previously hand-duplicated in
9
+ * `server/lock-tx-decoder.service.ts` and `cli/wallet.ts`.
10
+ */
11
+ /** Legacy SPL Token program. */
12
+ export declare const SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
13
+ /**
14
+ * Token-2022 (token-extensions) program — NOT supported by ARP escrow.
15
+ * Exported so consumers can recognise it and reject with a precise
16
+ * error; a Token-2022 mint never enters the escrow flow.
17
+ */
18
+ export declare const TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
19
+ /** Associated Token Account program — derives a wallet's canonical ATA. */
20
+ export declare const ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
21
+ /**
22
+ * System Program. This is also the base58 rendering of the all-zero
23
+ * pubkey that the escrow contract reuses as its native-SOL sentinel
24
+ * mint — but for THAT meaning use `NATIVE_SOL_MINT_BASE58` (from the
25
+ * escrow module), not this constant: same string, different semantics.
26
+ */
27
+ export declare const SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
@@ -14,10 +14,7 @@
14
14
  * that minted it — NOT the mint's mint_authority. Confusingly, both are
15
15
  * called "owner" in different contexts.
16
16
  */
17
- /**
18
- * Legacy SPL Token program ID (base58: `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`).
19
- */
20
- export declare const SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
17
+ export { SPL_TOKEN_PROGRAM_ID_BASE58 } from './program-ids';
21
18
  /**
22
19
  * Token program kind. Maps to the contract's `token_program_kind` u8 on
23
20
  * `LockCreated` events: `native` → 0, `legacy` → 1. (The contract also
@@ -71,6 +71,32 @@ export declare const DECLINE_REASONS: readonly DeclineReason[];
71
71
  * server validator + CLI parsers.
72
72
  */
73
73
  export declare function isDeclineReason(v: unknown): v is DeclineReason;
74
+ /**
75
+ * Lifecycle decision on a `handshake_response` body. When
76
+ * `decision === 'decline'` the companion `reason` (a `DeclineReason`)
77
+ * is required at the validator level. Same `type` + `as const` array +
78
+ * guard shape as `DeclineReason` so the server validator and CLI parse
79
+ * against one source of truth.
80
+ */
81
+ export type HandshakeDecision = 'accept' | 'decline';
82
+ export declare const HANDSHAKE_DECISIONS: readonly HandshakeDecision[];
83
+ export declare function isHandshakeDecision(v: unknown): v is HandshakeDecision;
84
+ /**
85
+ * Lifecycle action on a `delegation` body. `offer` opens the
86
+ * delegation; `accept`/`decline` are the counterparty's response;
87
+ * `cancel` withdraws an unaccepted offer; `fund` attaches the escrow
88
+ * lock to an already-accepted delegation.
89
+ */
90
+ export type DelegationAction = 'offer' | 'accept' | 'decline' | 'cancel' | 'fund';
91
+ export declare const DELEGATION_ACTIONS: readonly DelegationAction[];
92
+ export declare function isDelegationAction(v: unknown): v is DelegationAction;
93
+ /**
94
+ * Payee's proposed verdict on a `receipt` body. The record is
95
+ * off-chain; settlement happens on-chain via `claim_work_payment`.
96
+ */
97
+ export type ReceiptVerdict = 'accepted' | 'accepted_with_notes' | 'rejected';
98
+ export declare const RECEIPT_VERDICTS: readonly ReceiptVerdict[];
99
+ export declare function isReceiptVerdict(v: unknown): v is ReceiptVerdict;
74
100
  /**
75
101
  * `handshake` — first signed exchange between two agents. Establishes
76
102
  * the relationship; carries no terms (those live on the delegation).
@@ -97,7 +123,7 @@ export interface HandshakeResponseBody extends Body<HandshakeResponseContent> {
97
123
  type: 'handshake_response';
98
124
  }
99
125
  export interface HandshakeResponseContent {
100
- decision: 'accept' | 'decline';
126
+ decision: HandshakeDecision;
101
127
  notes?: string;
102
128
  /** Machine-readable reason — REQUIRED when `decision === 'decline'`. See `DeclineReason`. */
103
129
  reason?: DeclineReason;
@@ -113,7 +139,7 @@ export interface DelegationBody extends Body<DelegationContent> {
113
139
  type: 'delegation';
114
140
  }
115
141
  export interface DelegationContent {
116
- action: 'offer' | 'accept' | 'decline' | 'cancel' | 'fund';
142
+ action: DelegationAction;
117
143
  delegation_id: string;
118
144
  title?: string;
119
145
  brief?: Record<string, unknown>;
@@ -177,7 +203,7 @@ export interface ReceiptContent {
177
203
  model?: string;
178
204
  computed_amount?: string;
179
205
  };
180
- verdict_proposed: 'accepted' | 'accepted_with_notes' | 'rejected';
206
+ verdict_proposed: ReceiptVerdict;
181
207
  deliverable_hash?: Sha256Hex;
182
208
  notes_hash?: Sha256Hex;
183
209
  [extra: string]: unknown;
@@ -203,3 +229,17 @@ export interface DisputeContent {
203
229
  * `body.type` via discriminated dispatch.
204
230
  */
205
231
  export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | WorkRequestBody | WorkResponseBody | ReceiptBody | DisputeBody;
232
+ /**
233
+ * The closed taxonomy of envelope `body.type` values — the runtime
234
+ * companion to `AnyBody` (`BodyType` is derived from it, so the two
235
+ * can't drift). Names are wire-facing and MUST match
236
+ * `00-core/protocol.md`.
237
+ *
238
+ * NOTE: this is the FULL taxonomy. A consumer's *acceptance policy* may
239
+ * deliberately admit only a subset (e.g. the server rejects `dispute`
240
+ * as not-yet-implemented) — that allowlist is a separate, hand-curated
241
+ * thing and must NOT be regenerated from this array.
242
+ */
243
+ export type BodyType = AnyBody['type'];
244
+ export declare const BODY_TYPES: readonly BodyType[];
245
+ export declare function isBodyType(v: unknown): v is BodyType;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Persisted delegation lifecycle — the FSM on the `delegations` row.
3
+ *
4
+ * Distinct from the wire-level `DelegationAction` verb in `body.ts`
5
+ * (`offer`/`accept`/…): that is what an envelope DOES; this is what the
6
+ * row IS. Single source of truth for the server's Mongoose
7
+ * `@Prop({ enum })` value list and the CLI's `DelegationPublic.state`
8
+ * union, so the FSM vocabulary bumps in exactly one place.
9
+ *
10
+ * Same `as const` array + derived type + guard shape as
11
+ * `DECLINE_REASONS` in `body.ts`.
12
+ */
13
+ export declare const DELEGATION_STATES: readonly ["offered", "accepted", "pending_lock_finalization", "locked", "disputing", "completed", "declined", "canceled", "failed", "refunded", "dispute_resolved"];
14
+ export type DelegationState = (typeof DELEGATION_STATES)[number];
15
+ /**
16
+ * Non-terminal "the cycle is still live" subset — offered through
17
+ * locked. Used for worker capacity counting and the CLI's active-cycle
18
+ * view. Declared `satisfies readonly DelegationState[]` so it can never
19
+ * name a state that isn't in `DELEGATION_STATES`.
20
+ */
21
+ export declare const DELEGATION_ACTIVE_STATES: readonly ["offered", "accepted", "pending_lock_finalization", "locked"];
22
+ export declare function isDelegationState(v: unknown): v is DelegationState;
@@ -11,10 +11,28 @@ import type { PurposeValue } from '../purpose';
11
11
  */
12
12
  /** Hash string in protocol format `sha256:<64-char hex>`. */
13
13
  export type Sha256Hex = `sha256:${string}`;
14
+ /**
15
+ * Strict runtime validator for `Sha256Hex`. The template-literal type
16
+ * above cannot constrain hex/length in TS, so consumers that need a
17
+ * real check (CLI id parsers, the receipt validator) use this instead
18
+ * of hand-rolling their own copy. Pattern: `sha256:` + exactly 64
19
+ * lowercase hex chars.
20
+ */
21
+ export declare const SHA256_HEX_RE: RegExp;
22
+ export declare function isSha256Hex(v: unknown): v is Sha256Hex;
23
+ /** Wire prefix for an Ed25519 signature value (`ed25519:<base64>`). */
24
+ export declare const ED25519_SIG_PREFIX: "ed25519:";
14
25
  /** Ed25519 signature in protocol format `ed25519:<base64>`. */
15
- export type Ed25519Sig = `ed25519:${string}`;
26
+ export type Ed25519Sig = `${typeof ED25519_SIG_PREFIX}${string}`;
16
27
  /** DID format `did:arp:<base58btc>`. */
17
28
  export type Did = `did:arp:${string}`;
29
+ /**
30
+ * Protocol versions this SDK speaks. The server validator's accept-list
31
+ * and the signed `protected.protocol_version` field both source from
32
+ * this array, so bumping the wire version is a one-line change here.
33
+ */
34
+ export declare const PROTOCOL_VERSIONS: readonly ["arp/0.1"];
35
+ export type ProtocolVersion = (typeof PROTOCOL_VERSIONS)[number];
18
36
  /**
19
37
  * Client-signed `protected` block. All fields here are part of the
20
38
  * signing input. Server-assigned chain fields (`relationship_event_index`,
@@ -22,7 +40,7 @@ export type Did = `did:arp:${string}`;
22
40
  * sign them.
23
41
  */
24
42
  export interface ProtectedBlock {
25
- protocol_version: 'arp/0.1';
43
+ protocol_version: ProtocolVersion;
26
44
  purpose: PurposeValue;
27
45
  message_id: string;
28
46
  sender_did: Did;
@@ -2,10 +2,13 @@ import type { Did } from './envelope';
2
2
  /**
3
3
  * Owner attestation methods per [00-core/identity.md](../../../00-core/identity.md).
4
4
  *
5
- * Only `scrypt_password_proof` is active; the others are reserved
6
- * placeholders for forward-compat.
5
+ * Only `scrypt_password_proof` is active (index 0); the others are
6
+ * reserved placeholders for forward-compat. Backed by an `as const`
7
+ * array so the server's attestation schema can source the active method
8
+ * from `OWNER_SIGNING_METHODS[0]` instead of re-hardcoding the literal.
7
9
  */
8
- export type OwnerSigningMethod = 'scrypt_password_proof' | 'ed25519_owner_key' | 'totp+passphrase';
10
+ export declare const OWNER_SIGNING_METHODS: readonly ["scrypt_password_proof", "ed25519_owner_key", "totp+passphrase"];
11
+ export type OwnerSigningMethod = (typeof OWNER_SIGNING_METHODS)[number];
9
12
  /**
10
13
  * `ARP-KEY-LINK-v1` payload — the canonical-JSON-hashed object an owner
11
14
  * signs at registration. Carries the link between identity and settlement
@@ -1,6 +1,13 @@
1
- export type { Sha256Hex, Ed25519Sig, Did, ProtectedBlock, Body, Attachments, EscrowLockAttachment, Envelope, PersistedEvent, } from './envelope';
2
- export type { HandshakeBody, HandshakeContent, HandshakeResponseBody, HandshakeResponseContent, DelegationBody, DelegationContent, WorkRequestBody, WorkRequestContent, WorkResponseBody, WorkResponseContent, ReceiptBody, ReceiptContent, DisputeBody, DisputeContent, AnyBody, DeclineReason, AssetIdentifier, } from './body';
3
- export { DECLINE_REASONS, isDeclineReason } from './body';
1
+ export type { Sha256Hex, Ed25519Sig, Did, ProtocolVersion, ProtectedBlock, Body, Attachments, EscrowLockAttachment, Envelope, PersistedEvent, } from './envelope';
2
+ export { SHA256_HEX_RE, isSha256Hex, ED25519_SIG_PREFIX, PROTOCOL_VERSIONS } from './envelope';
3
+ export type { HandshakeBody, HandshakeContent, HandshakeResponseBody, HandshakeResponseContent, HandshakeDecision, DelegationBody, DelegationContent, DelegationAction, WorkRequestBody, WorkRequestContent, WorkResponseBody, WorkResponseContent, ReceiptBody, ReceiptContent, ReceiptVerdict, DisputeBody, DisputeContent, AnyBody, BodyType, DeclineReason, AssetIdentifier, } from './body';
4
+ export { DECLINE_REASONS, isDeclineReason, HANDSHAKE_DECISIONS, isHandshakeDecision, DELEGATION_ACTIONS, isDelegationAction, RECEIPT_VERDICTS, isReceiptVerdict, BODY_TYPES, isBodyType, } from './body';
5
+ export type { DelegationState } from './delegation';
6
+ export { DELEGATION_STATES, DELEGATION_ACTIVE_STATES, isDelegationState } from './delegation';
7
+ export type { RelationshipState } from './relationship';
8
+ export { RELATIONSHIP_STATE_NAMES, LIVE_RELATIONSHIP_STATE_NAMES, isRelationshipState } from './relationship';
9
+ export type { WorkLogState } from './work-log';
10
+ export { WORK_LOG_STATES, isWorkLogState } from './work-log';
4
11
  export type { AcceptPrefs, AcceptCurrency } from './agent';
5
12
  export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
6
- export { SCRYPT_PARAMS } from './identity';
13
+ export { SCRYPT_PARAMS, OWNER_SIGNING_METHODS } from './identity';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Per-pair relationship lifecycle. `pending` after a handshake →
3
+ * `active` once the counterparty replies → `paused` soft-disable →
4
+ * `closed` terminal. Single source of truth for the server's Mongoose
5
+ * `@Prop({ enum })` and the CLI's relationship-state unions.
6
+ */
7
+ export declare const RELATIONSHIP_STATE_NAMES: readonly ["pending", "active", "paused", "closed"];
8
+ export type RelationshipState = (typeof RELATIONSHIP_STATE_NAMES)[number];
9
+ /**
10
+ * "Live" subset — every state EXCEPT `closed`. Feeds the Mongo
11
+ * partial-unique index that enforces one live row per DID pair, so a
12
+ * re-handshake after a close can mint a fresh row. `closed` MUST stay
13
+ * excluded. Declared `satisfies readonly RelationshipState[]`.
14
+ */
15
+ export declare const LIVE_RELATIONSHIP_STATE_NAMES: readonly ["pending", "active", "paused"];
16
+ export declare function isRelationshipState(v: unknown): v is RelationshipState;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Work-log row state: `requested` (caller sent a `work_request`) →
3
+ * `responded` (payee replied with output or error). Work-logs do NOT
4
+ * mutate delegation state — they're the audit record pairing each
5
+ * request with its response. Single source of truth for the server's
6
+ * Mongoose `@Prop({ enum })` and the CLI's work-log state union/filter.
7
+ */
8
+ export declare const WORK_LOG_STATES: readonly ["requested", "responded"];
9
+ export type WorkLogState = (typeof WORK_LOG_STATES)[number];
10
+ export declare function isWorkLogState(v: unknown): v is WorkLogState;
@@ -1,4 +1,5 @@
1
1
  export { uuidV4 } from './uuid';
2
2
  export { senderNonce } from './nonce';
3
3
  export { rfc3339, expiresAt } from './timestamp';
4
+ export { MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS } from './time-windows';
4
5
  export { pollUntil, type PollUntilOptions, type PollUntilResult } from './poll';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Protocol time windows, in SECONDS. Single source of truth for the
3
+ * server's clock-skew tolerance and the envelope TTL cap; the CLI
4
+ * surfaces the TTL in its `--ttl` help text and the server enforces
5
+ * both at validation time.
6
+ *
7
+ * Unit note: these are SECONDS. The server's `MAX_TIME_SKEW_MS` derives
8
+ * from `MAX_CLOCK_SKEW_SECONDS * 1000`.
9
+ */
10
+ /** Max abs(now − protected.timestamp) the server accepts: ±5 minutes. */
11
+ export declare const MAX_CLOCK_SKEW_SECONDS = 300;
12
+ /** Max envelope validity (`expires_at − now`): 24 hours. */
13
+ export declare const MAX_ENVELOPE_TTL_SECONDS = 86400;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heyanon-arp/sdk",
3
- "version": "0.0.13",
4
- "description": "TypeScript SDK for the Agent Relationship Protocol — canonical JSON, Ed25519 envelope sign/verify, did:arp identity, receipt co-signatures, scrypt key attestation, chain-audit helpers.",
3
+ "version": "0.0.15",
4
+ "description": "TypeScript SDK for the Agent Relationship Protocol — canonical JSON, Ed25519 envelope sign/verify, did:arp identity, scrypt key attestation, chain-audit helpers.",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "arp",
@@ -11,7 +11,6 @@
11
11
  "jcs",
12
12
  "canonical-json",
13
13
  "envelope",
14
- "cosignature",
15
14
  "a2a"
16
15
  ],
17
16
  "main": "dist/index.js",