@heyanon-arp/sdk 0.0.15 → 0.0.18

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/assets.d.ts CHANGED
@@ -113,10 +113,34 @@ export declare function isWhitelistedAssetId(assetId: string, cluster?: SolanaCl
113
113
  * asset_reference = [-.%a-zA-Z0-9]{1,128}
114
114
  */
115
115
  export declare const CAIP19_REGEX: RegExp;
116
+ /**
117
+ * `AssetIdentifier.decimals` bounds — base-unit exponent, inclusive
118
+ * [0, 18]. 18 is the max any whitelisted asset uses and matches the
119
+ * decimal-amount fraction cap below. NOT the SPL u8 mint-decimals
120
+ * range (0–255) — that's a distinct on-chain concept the CLI keeps
121
+ * local to base-unit conversion.
122
+ */
123
+ export declare const ASSET_DECIMALS_MIN = 0;
124
+ export declare const ASSET_DECIMALS_MAX = 18;
125
+ /** `AssetIdentifier.symbol` length bounds (inclusive) when present. */
126
+ export declare const ASSET_SYMBOL_MIN_LEN = 1;
127
+ export declare const ASSET_SYMBOL_MAX_LEN = 16;
128
+ /**
129
+ * Canonical decimal-as-string AMOUNT shape: unsigned, ≥1 integer
130
+ * digit, optional fraction, bounded 30 integer / 18 fraction digits so
131
+ * BigInt scaling stays cheap and a hostile kilobyte-long "amount" is
132
+ * rejected up front (18 == {@link ASSET_DECIMALS_MAX}). The protocol's
133
+ * amount fields (delegation.offer amount, accept-prefs min/max) are
134
+ * decimal strings — server + CLI both validate against THIS regex so
135
+ * they can never disagree on what a valid amount looks like.
136
+ */
137
+ export declare const DECIMAL_AMOUNT_REGEX: RegExp;
138
+ export declare function isDecimalAmountString(v: unknown): v is string;
116
139
  /**
117
140
  * Type guard for `AssetIdentifier`. Validates structural shape +
118
141
  * CAIP-19 conformance of `asset_id` + decimals range. Symbol is
119
- * optional but if present must be 1-16 chars.
142
+ * optional but if present must be {@link ASSET_SYMBOL_MIN_LEN}–
143
+ * {@link ASSET_SYMBOL_MAX_LEN} chars.
120
144
  */
121
145
  export declare function isAssetIdentifier(value: unknown): value is AssetIdentifier;
122
146
  /**
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Live on-chain escrow Config PDA snapshot — the shape the server's
3
+ * `GET /v1/escrow/config` returns and the CLI consumes. Single source
4
+ * of truth for the read-model contract: the server's config-reader
5
+ * service annotates its `readConfig()` return with this, and the CLI's
6
+ * `getEscrowConfig` types its response with it, so the two cannot drift.
7
+ *
8
+ * Framework-agnostic plain interface (no decorators) — the server reads
9
+ * it from a service, not a NestJS DTO class, so there is nothing to
10
+ * decorate; lamport amounts are decimal STRINGS (u64-safe), windows +
11
+ * fee_bps are numbers.
12
+ */
13
+ export interface EscrowConfigStatus {
14
+ /** Config.fee_enabled bit. */
15
+ feeEnabled: boolean;
16
+ /** fee_bps as a number (u16). 0 when disabled or explicitly zero. */
17
+ feeBps: number;
18
+ /** base58 fee_recipient. The all-zero address sentinel means "no recipient configured". */
19
+ feeRecipient: string;
20
+ /** base58 treasury (receives the treasury share of dispute stakes). */
21
+ treasury: string;
22
+ /** Lamports the WORKER must stake at accept_lock. */
23
+ workerStakeLamports: string;
24
+ /** Lamports the operator collects per resolve_dispute. */
25
+ operatorDisputeFeeLamports: string;
26
+ /** Seconds the worker has to submit_work after accept_lock. */
27
+ workWindowSecs: number;
28
+ /** Seconds the buyer has to approve/dispute after submit_work. */
29
+ reviewWindowSecs: number;
30
+ /** Seconds the operator has to resolve after open_dispute. */
31
+ disputeWindowSecs: number;
32
+ /** Whether the contract is paused. */
33
+ paused: boolean;
34
+ /** The admin pubkey. */
35
+ admin: string;
36
+ /** The on-chain program id. */
37
+ programId: string;
38
+ }
@@ -1,6 +1,7 @@
1
1
  export { deriveLockId, delegationIdToBytes16, bytes16ToDelegationId } from './lock-id';
2
2
  export { deriveDelegationConditionHash, type DelegationTermsSubset, type DelegationTermsInput } from './condition-hash';
3
3
  export { parseCaip19SolanaAssetId, type ParsedSolanaAssetId } from './caip19';
4
+ export type { EscrowConfigStatus } from './config-status';
4
5
  export { buildCreateLockIxData, computeCreateLockDiscriminator, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, type CreateLockArgs, } from './create-lock';
5
6
  export { ESCROW_PDA_SEEDS, NO_ARG_LIFECYCLE_INSTRUCTIONS, type NoArgLifecycleInstruction, instructionDiscriminator, buildLifecycleIxData, buildResolveDisputeIxData, type ResolveDisputeArgs, } from './lifecycle-instructions';
6
- export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, NATIVE_SOL_MINT_BASE58, type LockStateName, type DecodedLockAccount, decodeLockAccount, computeLockAccountDiscriminator, } from './lock-account';
7
+ export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, NATIVE_SOL_MINT_BASE58, type LockStateName, type LockTerminalState, type EscrowReleaseMethodName, isEscrowReleaseMethod, type DecodedLockAccount, decodeLockAccount, computeLockAccountDiscriminator, } from './lock-account';
@@ -8,7 +8,46 @@ export declare const LOCK_ACCOUNT_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
8
8
  export declare const LOCK_STATE_NAMES: readonly ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
9
9
  export type LockStateName = (typeof LOCK_STATE_NAMES)[number];
10
10
  /** Terminal lock states — no further on-chain transition exists. */
11
- export declare const LOCK_TERMINAL_STATES: readonly LockStateName[];
11
+ export declare const LOCK_TERMINAL_STATES: readonly ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
12
+ /**
13
+ * The terminal subset of {@link LockStateName}. A receipt's
14
+ * `release_status` IS the on-chain lock's terminal state, so the
15
+ * server `ReceiptReleaseStatus` enum and the CLI `releaseStatus` DTO
16
+ * field both source this type instead of re-listing the literals.
17
+ */
18
+ export type LockTerminalState = (typeof LOCK_TERMINAL_STATES)[number];
19
+ /**
20
+ * On-chain `WorkPaymentClaimed.claim_type` → how a paid lock was
21
+ * released. Discriminant order = u8 value (0 = buyer_approved,
22
+ * 1 = review_timeout). The server's `EscrowReleaseMethod` enum and the
23
+ * CLI claim `role` both source these values.
24
+ */
25
+ export declare const ESCROW_RELEASE_METHODS: readonly ["buyer_approved", "review_timeout"];
26
+ export type EscrowReleaseMethodName = (typeof ESCROW_RELEASE_METHODS)[number];
27
+ export declare function isEscrowReleaseMethod(v: unknown): v is EscrowReleaseMethodName;
28
+ /**
29
+ * Named-member accessor for the on-chain lock FSM — lets consumers
30
+ * write `state === LockStates.SUBMITTED` / `case LockStates.PAID:`
31
+ * instead of bare strings. Values are the wire/decoder strings (== the
32
+ * {@link LockStateName} union), so they stay assignable everywhere with
33
+ * no casts. Parity with {@link LOCK_STATE_NAMES} is vocab-tested.
34
+ */
35
+ export declare const LockStates: {
36
+ readonly CREATED: "created";
37
+ readonly CANCELED: "canceled";
38
+ readonly IN_PROGRESS: "in_progress";
39
+ readonly SUBMITTED: "submitted";
40
+ readonly PAID: "paid";
41
+ readonly REVOKED: "revoked";
42
+ readonly DISPUTING: "disputing";
43
+ readonly DISPUTE_RESOLVED: "dispute_resolved";
44
+ readonly DISPUTE_CLOSED: "dispute_closed";
45
+ };
46
+ /** Named-member accessor for {@link EscrowReleaseMethodName} (vocab-tested). */
47
+ export declare const EscrowReleaseMethods: {
48
+ readonly BUYER_APPROVED: "buyer_approved";
49
+ readonly REVIEW_TIMEOUT: "review_timeout";
50
+ };
12
51
  /** The contract's native-SOL sentinel mint, base58 form of [0u8;32]. */
13
52
  export declare const NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
14
53
  export interface DecodedLockAccount {
package/dist/index.js CHANGED
@@ -312,6 +312,7 @@ var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
312
312
  var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
313
313
  var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
314
314
  var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
315
+ var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
315
316
 
316
317
  // src/settlement/token-program.ts
317
318
  function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
@@ -427,6 +428,7 @@ function isSha256Hex(v) {
427
428
  }
428
429
  var ED25519_SIG_PREFIX = "ed25519:";
429
430
  var PROTOCOL_VERSIONS = ["arp/0.1"];
431
+ var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
430
432
 
431
433
  // src/types/body.ts
432
434
  var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
@@ -437,18 +439,43 @@ var HANDSHAKE_DECISIONS = ["accept", "decline"];
437
439
  function isHandshakeDecision(v) {
438
440
  return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
439
441
  }
442
+ var HandshakeDecisions = {
443
+ ACCEPT: "accept",
444
+ DECLINE: "decline"
445
+ };
440
446
  var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
441
447
  function isDelegationAction(v) {
442
448
  return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
443
449
  }
450
+ var DelegationActions = {
451
+ OFFER: "offer",
452
+ ACCEPT: "accept",
453
+ DECLINE: "decline",
454
+ CANCEL: "cancel",
455
+ FUND: "fund"
456
+ };
444
457
  var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
445
458
  function isReceiptVerdict(v) {
446
459
  return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
447
460
  }
461
+ var ReceiptVerdicts = {
462
+ ACCEPTED: "accepted",
463
+ ACCEPTED_WITH_NOTES: "accepted_with_notes",
464
+ REJECTED: "rejected"
465
+ };
448
466
  var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
449
467
  function isBodyType(v) {
450
468
  return typeof v === "string" && BODY_TYPES.includes(v);
451
469
  }
470
+ var BodyTypes = {
471
+ HANDSHAKE: "handshake",
472
+ HANDSHAKE_RESPONSE: "handshake_response",
473
+ DELEGATION: "delegation",
474
+ WORK_REQUEST: "work_request",
475
+ WORK_RESPONSE: "work_response",
476
+ RECEIPT: "receipt",
477
+ DISPUTE: "dispute"
478
+ };
452
479
 
453
480
  // src/types/delegation.ts
454
481
  var DELEGATION_STATES = [
@@ -468,6 +495,19 @@ var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalizatio
468
495
  function isDelegationState(v) {
469
496
  return typeof v === "string" && DELEGATION_STATES.includes(v);
470
497
  }
498
+ var DelegationStates = {
499
+ OFFERED: "offered",
500
+ ACCEPTED: "accepted",
501
+ PENDING_LOCK_FINALIZATION: "pending_lock_finalization",
502
+ LOCKED: "locked",
503
+ DISPUTING: "disputing",
504
+ COMPLETED: "completed",
505
+ DECLINED: "declined",
506
+ CANCELED: "canceled",
507
+ FAILED: "failed",
508
+ REFUNDED: "refunded",
509
+ DISPUTE_RESOLVED: "dispute_resolved"
510
+ };
471
511
 
472
512
  // src/types/relationship.ts
473
513
  var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
@@ -475,12 +515,53 @@ var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
475
515
  function isRelationshipState(v) {
476
516
  return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
477
517
  }
518
+ var RelationshipStates = {
519
+ PENDING: "pending",
520
+ ACTIVE: "active",
521
+ PAUSED: "paused",
522
+ CLOSED: "closed"
523
+ };
478
524
 
479
525
  // src/types/work-log.ts
480
526
  var WORK_LOG_STATES = ["requested", "responded"];
481
527
  function isWorkLogState(v) {
482
528
  return typeof v === "string" && WORK_LOG_STATES.includes(v);
483
529
  }
530
+ var WorkLogStates = {
531
+ REQUESTED: "requested",
532
+ RESPONDED: "responded"
533
+ };
534
+
535
+ // src/types/event.ts
536
+ var READ_MODEL_STATUSES = ["materialized", "rejected"];
537
+ function isReadModelStatus(v) {
538
+ return typeof v === "string" && READ_MODEL_STATUSES.includes(v);
539
+ }
540
+ var ReadModelStatuses = {
541
+ MATERIALIZED: "materialized",
542
+ REJECTED: "rejected"
543
+ };
544
+
545
+ // src/types/discovery.ts
546
+ var DISCOVERY_SORTS = ["reputation", "recent", "created"];
547
+ function isDiscoverySort(v) {
548
+ return typeof v === "string" && DISCOVERY_SORTS.includes(v);
549
+ }
550
+ var DiscoverySorts = {
551
+ REPUTATION: "reputation",
552
+ RECENT: "recent",
553
+ CREATED: "created"
554
+ };
555
+
556
+ // src/types/inbox.ts
557
+ var INBOX_BLOCK_SCOPES = ["account", "did"];
558
+ function isInboxBlockScope(v) {
559
+ return typeof v === "string" && INBOX_BLOCK_SCOPES.includes(v);
560
+ }
561
+ var InboxBlockScopes = {
562
+ ACCOUNT: "account",
563
+ DID: "did"
564
+ };
484
565
 
485
566
  // src/assets.ts
486
567
  var SOLANA_CLUSTER_IDS = {
@@ -552,12 +633,20 @@ function isWhitelistedAssetId(assetId, cluster) {
552
633
  return cluster === void 0 || hit.cluster === cluster;
553
634
  }
554
635
  var CAIP19_REGEX = /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}$/;
636
+ var ASSET_DECIMALS_MIN = 0;
637
+ var ASSET_DECIMALS_MAX = 18;
638
+ var ASSET_SYMBOL_MIN_LEN = 1;
639
+ var ASSET_SYMBOL_MAX_LEN = 16;
640
+ var DECIMAL_AMOUNT_REGEX = /^\d{1,30}(\.\d{1,18})?$/;
641
+ function isDecimalAmountString(v) {
642
+ return typeof v === "string" && DECIMAL_AMOUNT_REGEX.test(v);
643
+ }
555
644
  function isAssetIdentifier(value) {
556
645
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
557
646
  const v = value;
558
647
  if (typeof v.asset_id !== "string" || !CAIP19_REGEX.test(v.asset_id)) return false;
559
- if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals < 0 || v.decimals > 18) return false;
560
- if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length === 0 || v.symbol.length > 16)) return false;
648
+ if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals < ASSET_DECIMALS_MIN || v.decimals > ASSET_DECIMALS_MAX) return false;
649
+ if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length < ASSET_SYMBOL_MIN_LEN || v.symbol.length > ASSET_SYMBOL_MAX_LEN)) return false;
561
650
  return true;
562
651
  }
563
652
  function resolveAsset(input) {
@@ -724,6 +813,25 @@ var LOCK_ACCOUNT_SIZE = 269;
724
813
  var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
725
814
  var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
726
815
  var LOCK_TERMINAL_STATES = ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
816
+ var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
817
+ function isEscrowReleaseMethod(v) {
818
+ return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
819
+ }
820
+ var LockStates = {
821
+ CREATED: "created",
822
+ CANCELED: "canceled",
823
+ IN_PROGRESS: "in_progress",
824
+ SUBMITTED: "submitted",
825
+ PAID: "paid",
826
+ REVOKED: "revoked",
827
+ DISPUTING: "disputing",
828
+ DISPUTE_RESOLVED: "dispute_resolved",
829
+ DISPUTE_CLOSED: "dispute_closed"
830
+ };
831
+ var EscrowReleaseMethods = {
832
+ BUYER_APPROVED: "buyer_approved",
833
+ REVIEW_TIMEOUT: "review_timeout"
834
+ };
727
835
  var NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
728
836
  function decodeLockAccount(data) {
729
837
  if (data.length !== LOCK_ACCOUNT_SIZE) {
@@ -776,25 +884,43 @@ function readU64LE(buf, off) {
776
884
  return v;
777
885
  }
778
886
 
887
+ exports.ASSET_DECIMALS_MAX = ASSET_DECIMALS_MAX;
888
+ exports.ASSET_DECIMALS_MIN = ASSET_DECIMALS_MIN;
889
+ exports.ASSET_SYMBOL_MAX_LEN = ASSET_SYMBOL_MAX_LEN;
890
+ exports.ASSET_SYMBOL_MIN_LEN = ASSET_SYMBOL_MIN_LEN;
779
891
  exports.ASSET_WHITELIST = ASSET_WHITELIST;
780
892
  exports.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = ASSOCIATED_TOKEN_PROGRAM_ID_BASE58;
781
893
  exports.BODY_TYPES = BODY_TYPES;
894
+ exports.BodyTypes = BodyTypes;
782
895
  exports.CAIP19_REGEX = CAIP19_REGEX;
783
896
  exports.CREATE_LOCK_DISCRIMINATOR = CREATE_LOCK_DISCRIMINATOR;
784
897
  exports.CREATE_LOCK_NATIVE_DISCRIMINATOR = CREATE_LOCK_NATIVE_DISCRIMINATOR;
898
+ exports.CURRENT_PROTOCOL_VERSION = CURRENT_PROTOCOL_VERSION;
899
+ exports.DECIMAL_AMOUNT_REGEX = DECIMAL_AMOUNT_REGEX;
785
900
  exports.DECLINE_REASONS = DECLINE_REASONS;
786
901
  exports.DELEGATION_ACTIONS = DELEGATION_ACTIONS;
787
902
  exports.DELEGATION_ACTIVE_STATES = DELEGATION_ACTIVE_STATES;
788
903
  exports.DELEGATION_STATES = DELEGATION_STATES;
789
904
  exports.DEVNET_MINTS = DEVNET_MINTS;
905
+ exports.DISCOVERY_SORTS = DISCOVERY_SORTS;
906
+ exports.DelegationActions = DelegationActions;
907
+ exports.DelegationStates = DelegationStates;
908
+ exports.DiscoverySorts = DiscoverySorts;
790
909
  exports.ED25519_SIG_PREFIX = ED25519_SIG_PREFIX;
791
910
  exports.ESCROW_PDA_SEEDS = ESCROW_PDA_SEEDS;
911
+ exports.ESCROW_PROGRAM_ID_BASE58 = ESCROW_PROGRAM_ID_BASE58;
912
+ exports.ESCROW_RELEASE_METHODS = ESCROW_RELEASE_METHODS;
913
+ exports.EscrowReleaseMethods = EscrowReleaseMethods;
792
914
  exports.HANDSHAKE_DECISIONS = HANDSHAKE_DECISIONS;
915
+ exports.HandshakeDecisions = HandshakeDecisions;
916
+ exports.INBOX_BLOCK_SCOPES = INBOX_BLOCK_SCOPES;
917
+ exports.InboxBlockScopes = InboxBlockScopes;
793
918
  exports.LIVE_RELATIONSHIP_STATE_NAMES = LIVE_RELATIONSHIP_STATE_NAMES;
794
919
  exports.LOCK_ACCOUNT_DISCRIMINATOR = LOCK_ACCOUNT_DISCRIMINATOR;
795
920
  exports.LOCK_ACCOUNT_SIZE = LOCK_ACCOUNT_SIZE;
796
921
  exports.LOCK_STATE_NAMES = LOCK_STATE_NAMES;
797
922
  exports.LOCK_TERMINAL_STATES = LOCK_TERMINAL_STATES;
923
+ exports.LockStates = LockStates;
798
924
  exports.MAINNET_MINTS = MAINNET_MINTS;
799
925
  exports.MAX_CLOCK_SKEW_SECONDS = MAX_CLOCK_SKEW_SECONDS;
800
926
  exports.MAX_ENVELOPE_TTL_SECONDS = MAX_ENVELOPE_TTL_SECONDS;
@@ -803,8 +929,12 @@ exports.NO_ARG_LIFECYCLE_INSTRUCTIONS = NO_ARG_LIFECYCLE_INSTRUCTIONS;
803
929
  exports.OWNER_SIGNING_METHODS = OWNER_SIGNING_METHODS;
804
930
  exports.PROTOCOL_VERSIONS = PROTOCOL_VERSIONS;
805
931
  exports.Purpose = Purpose;
932
+ exports.READ_MODEL_STATUSES = READ_MODEL_STATUSES;
806
933
  exports.RECEIPT_VERDICTS = RECEIPT_VERDICTS;
807
934
  exports.RELATIONSHIP_STATE_NAMES = RELATIONSHIP_STATE_NAMES;
935
+ exports.ReadModelStatuses = ReadModelStatuses;
936
+ exports.ReceiptVerdicts = ReceiptVerdicts;
937
+ exports.RelationshipStates = RelationshipStates;
808
938
  exports.SCRYPT_PARAMS = SCRYPT_PARAMS;
809
939
  exports.SHA256_HEX_RE = SHA256_HEX_RE;
810
940
  exports.SLIP44_SOLANA = SLIP44_SOLANA;
@@ -815,6 +945,7 @@ exports.TOKEN_2022_PROGRAM_ID_BASE58 = TOKEN_2022_PROGRAM_ID_BASE58;
815
945
  exports.WELL_KNOWN_ASSETS = WELL_KNOWN_ASSETS;
816
946
  exports.WELL_KNOWN_ASSET_KEYS = WELL_KNOWN_ASSET_KEYS;
817
947
  exports.WORK_LOG_STATES = WORK_LOG_STATES;
948
+ exports.WorkLogStates = WorkLogStates;
818
949
  exports.base58btcDecode = base58btcDecode;
819
950
  exports.base58btcEncode = base58btcEncode;
820
951
  exports.buildCreateLockIxData = buildCreateLockIxData;
@@ -842,10 +973,15 @@ exports.getPublicKey = getPublicKey2;
842
973
  exports.instructionDiscriminator = instructionDiscriminator;
843
974
  exports.isAssetIdentifier = isAssetIdentifier;
844
975
  exports.isBodyType = isBodyType;
976
+ exports.isDecimalAmountString = isDecimalAmountString;
845
977
  exports.isDeclineReason = isDeclineReason;
846
978
  exports.isDelegationAction = isDelegationAction;
847
979
  exports.isDelegationState = isDelegationState;
980
+ exports.isDiscoverySort = isDiscoverySort;
981
+ exports.isEscrowReleaseMethod = isEscrowReleaseMethod;
848
982
  exports.isHandshakeDecision = isHandshakeDecision;
983
+ exports.isInboxBlockScope = isInboxBlockScope;
984
+ exports.isReadModelStatus = isReadModelStatus;
849
985
  exports.isReceiptVerdict = isReceiptVerdict;
850
986
  exports.isRelationshipState = isRelationshipState;
851
987
  exports.isSha256Hex = isSha256Hex;
package/dist/index.mjs CHANGED
@@ -287,6 +287,7 @@ var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
287
287
  var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
288
288
  var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
289
289
  var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
290
+ var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
290
291
 
291
292
  // src/settlement/token-program.ts
292
293
  function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
@@ -402,6 +403,7 @@ function isSha256Hex(v) {
402
403
  }
403
404
  var ED25519_SIG_PREFIX = "ed25519:";
404
405
  var PROTOCOL_VERSIONS = ["arp/0.1"];
406
+ var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
405
407
 
406
408
  // src/types/body.ts
407
409
  var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
@@ -412,18 +414,43 @@ var HANDSHAKE_DECISIONS = ["accept", "decline"];
412
414
  function isHandshakeDecision(v) {
413
415
  return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
414
416
  }
417
+ var HandshakeDecisions = {
418
+ ACCEPT: "accept",
419
+ DECLINE: "decline"
420
+ };
415
421
  var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
416
422
  function isDelegationAction(v) {
417
423
  return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
418
424
  }
425
+ var DelegationActions = {
426
+ OFFER: "offer",
427
+ ACCEPT: "accept",
428
+ DECLINE: "decline",
429
+ CANCEL: "cancel",
430
+ FUND: "fund"
431
+ };
419
432
  var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
420
433
  function isReceiptVerdict(v) {
421
434
  return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
422
435
  }
436
+ var ReceiptVerdicts = {
437
+ ACCEPTED: "accepted",
438
+ ACCEPTED_WITH_NOTES: "accepted_with_notes",
439
+ REJECTED: "rejected"
440
+ };
423
441
  var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
424
442
  function isBodyType(v) {
425
443
  return typeof v === "string" && BODY_TYPES.includes(v);
426
444
  }
445
+ var BodyTypes = {
446
+ HANDSHAKE: "handshake",
447
+ HANDSHAKE_RESPONSE: "handshake_response",
448
+ DELEGATION: "delegation",
449
+ WORK_REQUEST: "work_request",
450
+ WORK_RESPONSE: "work_response",
451
+ RECEIPT: "receipt",
452
+ DISPUTE: "dispute"
453
+ };
427
454
 
428
455
  // src/types/delegation.ts
429
456
  var DELEGATION_STATES = [
@@ -443,6 +470,19 @@ var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalizatio
443
470
  function isDelegationState(v) {
444
471
  return typeof v === "string" && DELEGATION_STATES.includes(v);
445
472
  }
473
+ var DelegationStates = {
474
+ OFFERED: "offered",
475
+ ACCEPTED: "accepted",
476
+ PENDING_LOCK_FINALIZATION: "pending_lock_finalization",
477
+ LOCKED: "locked",
478
+ DISPUTING: "disputing",
479
+ COMPLETED: "completed",
480
+ DECLINED: "declined",
481
+ CANCELED: "canceled",
482
+ FAILED: "failed",
483
+ REFUNDED: "refunded",
484
+ DISPUTE_RESOLVED: "dispute_resolved"
485
+ };
446
486
 
447
487
  // src/types/relationship.ts
448
488
  var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
@@ -450,12 +490,53 @@ var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
450
490
  function isRelationshipState(v) {
451
491
  return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
452
492
  }
493
+ var RelationshipStates = {
494
+ PENDING: "pending",
495
+ ACTIVE: "active",
496
+ PAUSED: "paused",
497
+ CLOSED: "closed"
498
+ };
453
499
 
454
500
  // src/types/work-log.ts
455
501
  var WORK_LOG_STATES = ["requested", "responded"];
456
502
  function isWorkLogState(v) {
457
503
  return typeof v === "string" && WORK_LOG_STATES.includes(v);
458
504
  }
505
+ var WorkLogStates = {
506
+ REQUESTED: "requested",
507
+ RESPONDED: "responded"
508
+ };
509
+
510
+ // src/types/event.ts
511
+ var READ_MODEL_STATUSES = ["materialized", "rejected"];
512
+ function isReadModelStatus(v) {
513
+ return typeof v === "string" && READ_MODEL_STATUSES.includes(v);
514
+ }
515
+ var ReadModelStatuses = {
516
+ MATERIALIZED: "materialized",
517
+ REJECTED: "rejected"
518
+ };
519
+
520
+ // src/types/discovery.ts
521
+ var DISCOVERY_SORTS = ["reputation", "recent", "created"];
522
+ function isDiscoverySort(v) {
523
+ return typeof v === "string" && DISCOVERY_SORTS.includes(v);
524
+ }
525
+ var DiscoverySorts = {
526
+ REPUTATION: "reputation",
527
+ RECENT: "recent",
528
+ CREATED: "created"
529
+ };
530
+
531
+ // src/types/inbox.ts
532
+ var INBOX_BLOCK_SCOPES = ["account", "did"];
533
+ function isInboxBlockScope(v) {
534
+ return typeof v === "string" && INBOX_BLOCK_SCOPES.includes(v);
535
+ }
536
+ var InboxBlockScopes = {
537
+ ACCOUNT: "account",
538
+ DID: "did"
539
+ };
459
540
 
460
541
  // src/assets.ts
461
542
  var SOLANA_CLUSTER_IDS = {
@@ -527,12 +608,20 @@ function isWhitelistedAssetId(assetId, cluster) {
527
608
  return cluster === void 0 || hit.cluster === cluster;
528
609
  }
529
610
  var CAIP19_REGEX = /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}$/;
611
+ var ASSET_DECIMALS_MIN = 0;
612
+ var ASSET_DECIMALS_MAX = 18;
613
+ var ASSET_SYMBOL_MIN_LEN = 1;
614
+ var ASSET_SYMBOL_MAX_LEN = 16;
615
+ var DECIMAL_AMOUNT_REGEX = /^\d{1,30}(\.\d{1,18})?$/;
616
+ function isDecimalAmountString(v) {
617
+ return typeof v === "string" && DECIMAL_AMOUNT_REGEX.test(v);
618
+ }
530
619
  function isAssetIdentifier(value) {
531
620
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
532
621
  const v = value;
533
622
  if (typeof v.asset_id !== "string" || !CAIP19_REGEX.test(v.asset_id)) return false;
534
- if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals < 0 || v.decimals > 18) return false;
535
- if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length === 0 || v.symbol.length > 16)) return false;
623
+ if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals < ASSET_DECIMALS_MIN || v.decimals > ASSET_DECIMALS_MAX) return false;
624
+ if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length < ASSET_SYMBOL_MIN_LEN || v.symbol.length > ASSET_SYMBOL_MAX_LEN)) return false;
536
625
  return true;
537
626
  }
538
627
  function resolveAsset(input) {
@@ -699,6 +788,25 @@ var LOCK_ACCOUNT_SIZE = 269;
699
788
  var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
700
789
  var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
701
790
  var LOCK_TERMINAL_STATES = ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
791
+ var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
792
+ function isEscrowReleaseMethod(v) {
793
+ return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
794
+ }
795
+ var LockStates = {
796
+ CREATED: "created",
797
+ CANCELED: "canceled",
798
+ IN_PROGRESS: "in_progress",
799
+ SUBMITTED: "submitted",
800
+ PAID: "paid",
801
+ REVOKED: "revoked",
802
+ DISPUTING: "disputing",
803
+ DISPUTE_RESOLVED: "dispute_resolved",
804
+ DISPUTE_CLOSED: "dispute_closed"
805
+ };
806
+ var EscrowReleaseMethods = {
807
+ BUYER_APPROVED: "buyer_approved",
808
+ REVIEW_TIMEOUT: "review_timeout"
809
+ };
702
810
  var NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
703
811
  function decodeLockAccount(data) {
704
812
  if (data.length !== LOCK_ACCOUNT_SIZE) {
@@ -751,4 +859,4 @@ function readU64LE(buf, off) {
751
859
  return v;
752
860
  }
753
861
 
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 };
862
+ export { ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_STATES, DEVNET_MINTS, DISCOVERY_SORTS, DelegationActions, DelegationStates, DiscoverySorts, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, ESCROW_PROGRAM_ID_BASE58, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, HANDSHAKE_DECISIONS, HandshakeDecisions, INBOX_BLOCK_SCOPES, InboxBlockScopes, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, PROTOCOL_VERSIONS, Purpose, READ_MODEL_STATUSES, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, 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, WorkLogStates, 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, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isDiscoverySort, isEscrowReleaseMethod, isHandshakeDecision, isInboxBlockScope, isReadModelStatus, 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,3 +1,3 @@
1
- export { SPL_TOKEN_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58 } from './program-ids';
1
+ export { SPL_TOKEN_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, ESCROW_PROGRAM_ID_BASE58 } from './program-ids';
2
2
  export { detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes } from './token-program';
3
3
  export type { TokenProgramKind, TokenProgramDetection } from './token-program';
@@ -25,3 +25,15 @@ export declare const ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZ
25
25
  * escrow module), not this constant: same string, different semantics.
26
26
  */
27
27
  export declare const SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
28
+ /**
29
+ * ARP escrow program id (current V2 devnet deployment). This is the
30
+ * canonical DEFAULT only — both the CLI and server resolve the program
31
+ * id at runtime (flag / env / config / server probe) and that
32
+ * precedence chain stays authoritative; this constant is the single
33
+ * source for the fallback default so the two packages can't ship
34
+ * DIFFERENT defaults (the CLI previously hardcoded the contract's
35
+ * `declare_id` placeholder while the server defaulted to the deployed
36
+ * id). When a mainnet deployment exists, promote this to a per-cluster
37
+ * map keyed by `SOLANA_CLUSTER_IDS`.
38
+ */
39
+ export declare const ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
@@ -81,6 +81,11 @@ export declare function isDeclineReason(v: unknown): v is DeclineReason;
81
81
  export type HandshakeDecision = 'accept' | 'decline';
82
82
  export declare const HANDSHAKE_DECISIONS: readonly HandshakeDecision[];
83
83
  export declare function isHandshakeDecision(v: unknown): v is HandshakeDecision;
84
+ /** Named-member accessor for {@link HandshakeDecision} (values are the wire strings; vocab-tested). */
85
+ export declare const HandshakeDecisions: {
86
+ readonly ACCEPT: "accept";
87
+ readonly DECLINE: "decline";
88
+ };
84
89
  /**
85
90
  * Lifecycle action on a `delegation` body. `offer` opens the
86
91
  * delegation; `accept`/`decline` are the counterparty's response;
@@ -90,6 +95,14 @@ export declare function isHandshakeDecision(v: unknown): v is HandshakeDecision;
90
95
  export type DelegationAction = 'offer' | 'accept' | 'decline' | 'cancel' | 'fund';
91
96
  export declare const DELEGATION_ACTIONS: readonly DelegationAction[];
92
97
  export declare function isDelegationAction(v: unknown): v is DelegationAction;
98
+ /** Named-member accessor for {@link DelegationAction} (e.g. `action === DelegationActions.CANCEL`; vocab-tested). */
99
+ export declare const DelegationActions: {
100
+ readonly OFFER: "offer";
101
+ readonly ACCEPT: "accept";
102
+ readonly DECLINE: "decline";
103
+ readonly CANCEL: "cancel";
104
+ readonly FUND: "fund";
105
+ };
93
106
  /**
94
107
  * Payee's proposed verdict on a `receipt` body. The record is
95
108
  * off-chain; settlement happens on-chain via `claim_work_payment`.
@@ -97,6 +110,12 @@ export declare function isDelegationAction(v: unknown): v is DelegationAction;
97
110
  export type ReceiptVerdict = 'accepted' | 'accepted_with_notes' | 'rejected';
98
111
  export declare const RECEIPT_VERDICTS: readonly ReceiptVerdict[];
99
112
  export declare function isReceiptVerdict(v: unknown): v is ReceiptVerdict;
113
+ /** Named-member accessor for {@link ReceiptVerdict} (values are the wire strings; vocab-tested). */
114
+ export declare const ReceiptVerdicts: {
115
+ readonly ACCEPTED: "accepted";
116
+ readonly ACCEPTED_WITH_NOTES: "accepted_with_notes";
117
+ readonly REJECTED: "rejected";
118
+ };
100
119
  /**
101
120
  * `handshake` — first signed exchange between two agents. Establishes
102
121
  * the relationship; carries no terms (those live on the delegation).
@@ -243,3 +262,13 @@ export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | W
243
262
  export type BodyType = AnyBody['type'];
244
263
  export declare const BODY_TYPES: readonly BodyType[];
245
264
  export declare function isBodyType(v: unknown): v is BodyType;
265
+ /** Named-member accessor for {@link BodyType} (values are the wire strings; vocab-tested). */
266
+ export declare const BodyTypes: {
267
+ readonly HANDSHAKE: "handshake";
268
+ readonly HANDSHAKE_RESPONSE: "handshake_response";
269
+ readonly DELEGATION: "delegation";
270
+ readonly WORK_REQUEST: "work_request";
271
+ readonly WORK_RESPONSE: "work_response";
272
+ readonly RECEIPT: "receipt";
273
+ readonly DISPUTE: "dispute";
274
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `heyarp login` (cli-auth) wire response shapes. Single source of
3
+ * truth for the server's cli-auth-flow service return types and the
4
+ * CLI's response types — both are plain framework-agnostic interfaces
5
+ * (the server declares them in a service, not a NestJS DTO class), so
6
+ * this is a pure lift-and-share with no decorator coupling.
7
+ *
8
+ * NOT included here: the cli-auth SESSION-STATE union
9
+ * ('pending'|'confirmed'|'consumed'|...) — the CLI and server disagree
10
+ * on the terminal members, so it needs reconciliation before it can be
11
+ * centralized.
12
+ */
13
+ /** `POST /v1/auth/cli/sessions` → a new login session. */
14
+ export interface CliSessionCreated {
15
+ sessionId: string;
16
+ verificationUrl: string;
17
+ }
18
+ /** One-time token exchange result (PKCE-style clientSecret-gated). */
19
+ export interface CliTokenIssued {
20
+ token: string;
21
+ wallet: string;
22
+ }
23
+ /** `GET /v1/accounts/me` → who the bearer token authenticates as. */
24
+ export interface CliWhoami {
25
+ wallet: string;
26
+ agentCount: number;
27
+ }
28
+ /**
29
+ * One agent owned by the presented account — the shape `GET
30
+ * /v1/accounts/me/agents` returns. Carries enough to drive recovery
31
+ * (DID + attestation id the CLI rebuilds local state with) plus profile
32
+ * for display. The owner `accountId` itself is NEVER included.
33
+ */
34
+ export interface MyAgentSummary {
35
+ did: string;
36
+ name: string | null;
37
+ description: string | null;
38
+ tags: string[];
39
+ currentAttestationId: string;
40
+ registeredAt: string;
41
+ }
@@ -20,3 +20,24 @@ export type DelegationState = (typeof DELEGATION_STATES)[number];
20
20
  */
21
21
  export declare const DELEGATION_ACTIVE_STATES: readonly ["offered", "accepted", "pending_lock_finalization", "locked"];
22
22
  export declare function isDelegationState(v: unknown): v is DelegationState;
23
+ /**
24
+ * Named-member accessor for the delegation FSM — lets consumers write
25
+ * `state === DelegationStates.LOCKED` / `case DelegationStates.OFFERED:`
26
+ * instead of bare magic strings, while the values stay the exact wire
27
+ * strings (so they remain assignable to {@link DelegationState} with no
28
+ * casts, unlike a TS string-enum). Parity with {@link DELEGATION_STATES}
29
+ * is pinned by the vocab test.
30
+ */
31
+ export declare const DelegationStates: {
32
+ readonly OFFERED: "offered";
33
+ readonly ACCEPTED: "accepted";
34
+ readonly PENDING_LOCK_FINALIZATION: "pending_lock_finalization";
35
+ readonly LOCKED: "locked";
36
+ readonly DISPUTING: "disputing";
37
+ readonly COMPLETED: "completed";
38
+ readonly DECLINED: "declined";
39
+ readonly CANCELED: "canceled";
40
+ readonly FAILED: "failed";
41
+ readonly REFUNDED: "refunded";
42
+ readonly DISPUTE_RESOLVED: "dispute_resolved";
43
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Discovery catalog sort order for `GET /v1/discovery/agents`. Single
3
+ * source of truth for the server's `@IsIn`/`@ApiProperty` allowlist and
4
+ * the CLI's `--sort` union. Same `as const` array + union + guard +
5
+ * named-member const-object shape as the protocol vocabularies.
6
+ *
7
+ * `reputation` = composite score desc (default); `recent` = newest
8
+ * first; `created` = registration order.
9
+ */
10
+ export declare const DISCOVERY_SORTS: readonly ["reputation", "recent", "created"];
11
+ export type DiscoverySort = (typeof DISCOVERY_SORTS)[number];
12
+ export declare function isDiscoverySort(v: unknown): v is DiscoverySort;
13
+ /** Named-member accessor for {@link DiscoverySort} (vocab-tested). */
14
+ export declare const DiscoverySorts: {
15
+ readonly REPUTATION: "reputation";
16
+ readonly RECENT: "recent";
17
+ readonly CREATED: "created";
18
+ };
@@ -33,6 +33,13 @@ export type Did = `did:arp:${string}`;
33
33
  */
34
34
  export declare const PROTOCOL_VERSIONS: readonly ["arp/0.1"];
35
35
  export type ProtocolVersion = (typeof PROTOCOL_VERSIONS)[number];
36
+ /**
37
+ * The wire version this SDK emits. Always the newest entry in
38
+ * {@link PROTOCOL_VERSIONS}. CLI envelope builders sign this instead of
39
+ * the bare `'arp/0.1'` literal, so a version bump is the one-line array
40
+ * change above.
41
+ */
42
+ export declare const CURRENT_PROTOCOL_VERSION: ProtocolVersion;
36
43
  /**
37
44
  * Client-signed `protected` block. All fields here are part of the
38
45
  * signing input. Server-assigned chain fields (`relationship_event_index`,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Read-model projection outcome for a relationship event: `materialized`
3
+ * (the event was applied to the read model) → `rejected` (the event was
4
+ * recorded on the hash chain but the projector declined to apply it,
5
+ * e.g. an integrity mismatch). Single source of truth for the server's
6
+ * Mongoose `@Prop({ enum })` + the two event-query DTOs and the CLI's
7
+ * `EventPublic.readModelStatus` union / `--read-model-status` filter.
8
+ */
9
+ export declare const READ_MODEL_STATUSES: readonly ["materialized", "rejected"];
10
+ export type ReadModelStatus = (typeof READ_MODEL_STATUSES)[number];
11
+ export declare function isReadModelStatus(v: unknown): v is ReadModelStatus;
12
+ /**
13
+ * Named-member accessor for the read-model projection outcome (see
14
+ * {@link READ_MODEL_STATUSES}). Values are the wire strings; parity is
15
+ * vocab-tested.
16
+ */
17
+ export declare const ReadModelStatuses: {
18
+ readonly MATERIALIZED: "materialized";
19
+ readonly REJECTED: "rejected";
20
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Inbox-block scope — whether a block targets a whole ACCOUNT (all the
3
+ * blocked party's agents) or a single DID. Single source of truth for
4
+ * the server's Mongoose `@Prop({ enum })` value list and the CLI's
5
+ * `scope` union. Same `as const` array + union + guard + named-member
6
+ * const-object shape as the protocol vocabularies; the server keeps a
7
+ * local enum for member access and sources its @Prop allowlist from
8
+ * `INBOX_BLOCK_SCOPES` with a parity spec.
9
+ */
10
+ export declare const INBOX_BLOCK_SCOPES: readonly ["account", "did"];
11
+ export type InboxBlockScope = (typeof INBOX_BLOCK_SCOPES)[number];
12
+ export declare function isInboxBlockScope(v: unknown): v is InboxBlockScope;
13
+ /** Named-member accessor for {@link InboxBlockScope} (vocab-tested). */
14
+ export declare const InboxBlockScopes: {
15
+ readonly ACCOUNT: "account";
16
+ readonly DID: "did";
17
+ };
@@ -1,13 +1,20 @@
1
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';
2
+ export { SHA256_HEX_RE, isSha256Hex, ED25519_SIG_PREFIX, PROTOCOL_VERSIONS, CURRENT_PROTOCOL_VERSION } from './envelope';
3
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';
4
+ export { DECLINE_REASONS, isDeclineReason, HANDSHAKE_DECISIONS, HandshakeDecisions, isHandshakeDecision, DELEGATION_ACTIONS, DelegationActions, isDelegationAction, RECEIPT_VERDICTS, ReceiptVerdicts, isReceiptVerdict, BODY_TYPES, BodyTypes, isBodyType, } from './body';
5
5
  export type { DelegationState } from './delegation';
6
- export { DELEGATION_STATES, DELEGATION_ACTIVE_STATES, isDelegationState } from './delegation';
6
+ export { DELEGATION_STATES, DELEGATION_ACTIVE_STATES, DelegationStates, isDelegationState } from './delegation';
7
7
  export type { RelationshipState } from './relationship';
8
- export { RELATIONSHIP_STATE_NAMES, LIVE_RELATIONSHIP_STATE_NAMES, isRelationshipState } from './relationship';
8
+ export { RELATIONSHIP_STATE_NAMES, LIVE_RELATIONSHIP_STATE_NAMES, RelationshipStates, isRelationshipState } from './relationship';
9
9
  export type { WorkLogState } from './work-log';
10
- export { WORK_LOG_STATES, isWorkLogState } from './work-log';
10
+ export { WORK_LOG_STATES, WorkLogStates, isWorkLogState } from './work-log';
11
+ export type { ReadModelStatus } from './event';
12
+ export { READ_MODEL_STATUSES, ReadModelStatuses, isReadModelStatus } from './event';
13
+ export type { DiscoverySort } from './discovery';
14
+ export { DISCOVERY_SORTS, DiscoverySorts, isDiscoverySort } from './discovery';
15
+ export type { InboxBlockScope } from './inbox';
16
+ export { INBOX_BLOCK_SCOPES, InboxBlockScopes, isInboxBlockScope } from './inbox';
17
+ export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary } from './cli-auth';
11
18
  export type { AcceptPrefs, AcceptCurrency } from './agent';
12
19
  export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
13
20
  export { SCRYPT_PARAMS, OWNER_SIGNING_METHODS } from './identity';
@@ -14,3 +14,14 @@ export type RelationshipState = (typeof RELATIONSHIP_STATE_NAMES)[number];
14
14
  */
15
15
  export declare const LIVE_RELATIONSHIP_STATE_NAMES: readonly ["pending", "active", "paused"];
16
16
  export declare function isRelationshipState(v: unknown): v is RelationshipState;
17
+ /**
18
+ * Named-member accessor for the relationship FSM (see
19
+ * {@link DelegationStates} for the rationale). Values are the wire
20
+ * strings; parity with {@link RELATIONSHIP_STATE_NAMES} is vocab-tested.
21
+ */
22
+ export declare const RelationshipStates: {
23
+ readonly PENDING: "pending";
24
+ readonly ACTIVE: "active";
25
+ readonly PAUSED: "paused";
26
+ readonly CLOSED: "closed";
27
+ };
@@ -8,3 +8,11 @@
8
8
  export declare const WORK_LOG_STATES: readonly ["requested", "responded"];
9
9
  export type WorkLogState = (typeof WORK_LOG_STATES)[number];
10
10
  export declare function isWorkLogState(v: unknown): v is WorkLogState;
11
+ /**
12
+ * Named-member accessor for the work-log FSM (see {@link WORK_LOG_STATES}).
13
+ * Values are the wire strings; parity is vocab-tested.
14
+ */
15
+ export declare const WorkLogStates: {
16
+ readonly REQUESTED: "requested";
17
+ readonly RESPONDED: "responded";
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon-arp/sdk",
3
- "version": "0.0.15",
3
+ "version": "0.0.18",
4
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": [