@heyanon-arp/sdk 0.0.14 → 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 +25 -1
- package/dist/escrow/config-status.d.ts +38 -0
- package/dist/escrow/index.d.ts +2 -1
- package/dist/escrow/lock-account.d.ts +40 -1
- package/dist/index.js +232 -5
- package/dist/index.mjs +179 -6
- package/dist/settlement/index.d.ts +2 -1
- package/dist/settlement/program-ids.d.ts +39 -0
- package/dist/settlement/token-program.d.ts +1 -4
- package/dist/types/body.d.ts +72 -3
- package/dist/types/cli-auth.d.ts +41 -0
- package/dist/types/delegation.d.ts +43 -0
- package/dist/types/discovery.d.ts +18 -0
- package/dist/types/envelope.d.ts +27 -2
- package/dist/types/event.d.ts +20 -0
- package/dist/types/identity.d.ts +6 -3
- package/dist/types/inbox.d.ts +17 -0
- package/dist/types/index.d.ts +18 -4
- package/dist/types/relationship.d.ts +27 -0
- package/dist/types/work-log.d.ts +18 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/time-windows.d.ts +13 -0
- package/package.json +1 -1
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
|
|
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
|
+
}
|
package/dist/escrow/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
@@ -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,14 @@ function bytesToHex2(b) {
|
|
|
306
307
|
return s;
|
|
307
308
|
}
|
|
308
309
|
|
|
309
|
-
// src/settlement/
|
|
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
|
+
var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
|
|
316
|
+
|
|
317
|
+
// src/settlement/token-program.ts
|
|
312
318
|
function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
|
|
313
319
|
if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
|
|
314
320
|
return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
|
|
@@ -360,6 +366,10 @@ function senderNonce() {
|
|
|
360
366
|
return base.base64urlnopad.encode(utils.randomBytes(16));
|
|
361
367
|
}
|
|
362
368
|
|
|
369
|
+
// src/utils/time-windows.ts
|
|
370
|
+
var MAX_CLOCK_SKEW_SECONDS = 300;
|
|
371
|
+
var MAX_ENVELOPE_TTL_SECONDS = 86400;
|
|
372
|
+
|
|
363
373
|
// src/utils/timestamp.ts
|
|
364
374
|
function rfc3339(at = /* @__PURE__ */ new Date()) {
|
|
365
375
|
return `${at.toISOString().slice(0, 19)}Z`;
|
|
@@ -368,8 +378,8 @@ function expiresAt(ttlSeconds, now = /* @__PURE__ */ new Date()) {
|
|
|
368
378
|
if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
|
|
369
379
|
throw new Error(`expiresAt: ttlSeconds must be positive, got ${ttlSeconds}`);
|
|
370
380
|
}
|
|
371
|
-
if (ttlSeconds >
|
|
372
|
-
throw new Error(`expiresAt: ttlSeconds exceeds 24h cap, got ${ttlSeconds}`);
|
|
381
|
+
if (ttlSeconds > MAX_ENVELOPE_TTL_SECONDS) {
|
|
382
|
+
throw new Error(`expiresAt: ttlSeconds exceeds ${MAX_ENVELOPE_TTL_SECONDS}s (24h) cap, got ${ttlSeconds}`);
|
|
373
383
|
}
|
|
374
384
|
return rfc3339(new Date(now.getTime() + ttlSeconds * 1e3));
|
|
375
385
|
}
|
|
@@ -411,11 +421,147 @@ function sleepWithAbort(ms, signal) {
|
|
|
411
421
|
});
|
|
412
422
|
}
|
|
413
423
|
|
|
424
|
+
// src/types/envelope.ts
|
|
425
|
+
var SHA256_HEX_RE = /^sha256:[0-9a-f]{64}$/;
|
|
426
|
+
function isSha256Hex(v) {
|
|
427
|
+
return typeof v === "string" && SHA256_HEX_RE.test(v);
|
|
428
|
+
}
|
|
429
|
+
var ED25519_SIG_PREFIX = "ed25519:";
|
|
430
|
+
var PROTOCOL_VERSIONS = ["arp/0.1"];
|
|
431
|
+
var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
|
|
432
|
+
|
|
414
433
|
// src/types/body.ts
|
|
415
434
|
var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
|
|
416
435
|
function isDeclineReason(v) {
|
|
417
436
|
return typeof v === "string" && DECLINE_REASONS.includes(v);
|
|
418
437
|
}
|
|
438
|
+
var HANDSHAKE_DECISIONS = ["accept", "decline"];
|
|
439
|
+
function isHandshakeDecision(v) {
|
|
440
|
+
return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
|
|
441
|
+
}
|
|
442
|
+
var HandshakeDecisions = {
|
|
443
|
+
ACCEPT: "accept",
|
|
444
|
+
DECLINE: "decline"
|
|
445
|
+
};
|
|
446
|
+
var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
|
|
447
|
+
function isDelegationAction(v) {
|
|
448
|
+
return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
|
|
449
|
+
}
|
|
450
|
+
var DelegationActions = {
|
|
451
|
+
OFFER: "offer",
|
|
452
|
+
ACCEPT: "accept",
|
|
453
|
+
DECLINE: "decline",
|
|
454
|
+
CANCEL: "cancel",
|
|
455
|
+
FUND: "fund"
|
|
456
|
+
};
|
|
457
|
+
var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
|
|
458
|
+
function isReceiptVerdict(v) {
|
|
459
|
+
return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
|
|
460
|
+
}
|
|
461
|
+
var ReceiptVerdicts = {
|
|
462
|
+
ACCEPTED: "accepted",
|
|
463
|
+
ACCEPTED_WITH_NOTES: "accepted_with_notes",
|
|
464
|
+
REJECTED: "rejected"
|
|
465
|
+
};
|
|
466
|
+
var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
|
|
467
|
+
function isBodyType(v) {
|
|
468
|
+
return typeof v === "string" && BODY_TYPES.includes(v);
|
|
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
|
+
};
|
|
479
|
+
|
|
480
|
+
// src/types/delegation.ts
|
|
481
|
+
var DELEGATION_STATES = [
|
|
482
|
+
"offered",
|
|
483
|
+
"accepted",
|
|
484
|
+
"pending_lock_finalization",
|
|
485
|
+
"locked",
|
|
486
|
+
"disputing",
|
|
487
|
+
"completed",
|
|
488
|
+
"declined",
|
|
489
|
+
"canceled",
|
|
490
|
+
"failed",
|
|
491
|
+
"refunded",
|
|
492
|
+
"dispute_resolved"
|
|
493
|
+
];
|
|
494
|
+
var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalization", "locked"];
|
|
495
|
+
function isDelegationState(v) {
|
|
496
|
+
return typeof v === "string" && DELEGATION_STATES.includes(v);
|
|
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
|
+
};
|
|
511
|
+
|
|
512
|
+
// src/types/relationship.ts
|
|
513
|
+
var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
|
|
514
|
+
var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
|
|
515
|
+
function isRelationshipState(v) {
|
|
516
|
+
return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
|
|
517
|
+
}
|
|
518
|
+
var RelationshipStates = {
|
|
519
|
+
PENDING: "pending",
|
|
520
|
+
ACTIVE: "active",
|
|
521
|
+
PAUSED: "paused",
|
|
522
|
+
CLOSED: "closed"
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
// src/types/work-log.ts
|
|
526
|
+
var WORK_LOG_STATES = ["requested", "responded"];
|
|
527
|
+
function isWorkLogState(v) {
|
|
528
|
+
return typeof v === "string" && WORK_LOG_STATES.includes(v);
|
|
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
|
+
};
|
|
419
565
|
|
|
420
566
|
// src/assets.ts
|
|
421
567
|
var SOLANA_CLUSTER_IDS = {
|
|
@@ -487,12 +633,20 @@ function isWhitelistedAssetId(assetId, cluster) {
|
|
|
487
633
|
return cluster === void 0 || hit.cluster === cluster;
|
|
488
634
|
}
|
|
489
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
|
+
}
|
|
490
644
|
function isAssetIdentifier(value) {
|
|
491
645
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
492
646
|
const v = value;
|
|
493
647
|
if (typeof v.asset_id !== "string" || !CAIP19_REGEX.test(v.asset_id)) return false;
|
|
494
|
-
if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals <
|
|
495
|
-
if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length
|
|
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;
|
|
496
650
|
return true;
|
|
497
651
|
}
|
|
498
652
|
function resolveAsset(input) {
|
|
@@ -659,6 +813,25 @@ var LOCK_ACCOUNT_SIZE = 269;
|
|
|
659
813
|
var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
|
|
660
814
|
var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
661
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
|
+
};
|
|
662
835
|
var NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
|
|
663
836
|
function decodeLockAccount(data) {
|
|
664
837
|
if (data.length !== LOCK_ACCOUNT_SIZE) {
|
|
@@ -711,27 +884,68 @@ function readU64LE(buf, off) {
|
|
|
711
884
|
return v;
|
|
712
885
|
}
|
|
713
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;
|
|
714
891
|
exports.ASSET_WHITELIST = ASSET_WHITELIST;
|
|
892
|
+
exports.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = ASSOCIATED_TOKEN_PROGRAM_ID_BASE58;
|
|
893
|
+
exports.BODY_TYPES = BODY_TYPES;
|
|
894
|
+
exports.BodyTypes = BodyTypes;
|
|
715
895
|
exports.CAIP19_REGEX = CAIP19_REGEX;
|
|
716
896
|
exports.CREATE_LOCK_DISCRIMINATOR = CREATE_LOCK_DISCRIMINATOR;
|
|
717
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;
|
|
718
900
|
exports.DECLINE_REASONS = DECLINE_REASONS;
|
|
901
|
+
exports.DELEGATION_ACTIONS = DELEGATION_ACTIONS;
|
|
902
|
+
exports.DELEGATION_ACTIVE_STATES = DELEGATION_ACTIVE_STATES;
|
|
903
|
+
exports.DELEGATION_STATES = DELEGATION_STATES;
|
|
719
904
|
exports.DEVNET_MINTS = DEVNET_MINTS;
|
|
905
|
+
exports.DISCOVERY_SORTS = DISCOVERY_SORTS;
|
|
906
|
+
exports.DelegationActions = DelegationActions;
|
|
907
|
+
exports.DelegationStates = DelegationStates;
|
|
908
|
+
exports.DiscoverySorts = DiscoverySorts;
|
|
909
|
+
exports.ED25519_SIG_PREFIX = ED25519_SIG_PREFIX;
|
|
720
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;
|
|
914
|
+
exports.HANDSHAKE_DECISIONS = HANDSHAKE_DECISIONS;
|
|
915
|
+
exports.HandshakeDecisions = HandshakeDecisions;
|
|
916
|
+
exports.INBOX_BLOCK_SCOPES = INBOX_BLOCK_SCOPES;
|
|
917
|
+
exports.InboxBlockScopes = InboxBlockScopes;
|
|
918
|
+
exports.LIVE_RELATIONSHIP_STATE_NAMES = LIVE_RELATIONSHIP_STATE_NAMES;
|
|
721
919
|
exports.LOCK_ACCOUNT_DISCRIMINATOR = LOCK_ACCOUNT_DISCRIMINATOR;
|
|
722
920
|
exports.LOCK_ACCOUNT_SIZE = LOCK_ACCOUNT_SIZE;
|
|
723
921
|
exports.LOCK_STATE_NAMES = LOCK_STATE_NAMES;
|
|
724
922
|
exports.LOCK_TERMINAL_STATES = LOCK_TERMINAL_STATES;
|
|
923
|
+
exports.LockStates = LockStates;
|
|
725
924
|
exports.MAINNET_MINTS = MAINNET_MINTS;
|
|
925
|
+
exports.MAX_CLOCK_SKEW_SECONDS = MAX_CLOCK_SKEW_SECONDS;
|
|
926
|
+
exports.MAX_ENVELOPE_TTL_SECONDS = MAX_ENVELOPE_TTL_SECONDS;
|
|
726
927
|
exports.NATIVE_SOL_MINT_BASE58 = NATIVE_SOL_MINT_BASE58;
|
|
727
928
|
exports.NO_ARG_LIFECYCLE_INSTRUCTIONS = NO_ARG_LIFECYCLE_INSTRUCTIONS;
|
|
929
|
+
exports.OWNER_SIGNING_METHODS = OWNER_SIGNING_METHODS;
|
|
930
|
+
exports.PROTOCOL_VERSIONS = PROTOCOL_VERSIONS;
|
|
728
931
|
exports.Purpose = Purpose;
|
|
932
|
+
exports.READ_MODEL_STATUSES = READ_MODEL_STATUSES;
|
|
933
|
+
exports.RECEIPT_VERDICTS = RECEIPT_VERDICTS;
|
|
934
|
+
exports.RELATIONSHIP_STATE_NAMES = RELATIONSHIP_STATE_NAMES;
|
|
935
|
+
exports.ReadModelStatuses = ReadModelStatuses;
|
|
936
|
+
exports.ReceiptVerdicts = ReceiptVerdicts;
|
|
937
|
+
exports.RelationshipStates = RelationshipStates;
|
|
729
938
|
exports.SCRYPT_PARAMS = SCRYPT_PARAMS;
|
|
939
|
+
exports.SHA256_HEX_RE = SHA256_HEX_RE;
|
|
730
940
|
exports.SLIP44_SOLANA = SLIP44_SOLANA;
|
|
731
941
|
exports.SOLANA_CLUSTER_IDS = SOLANA_CLUSTER_IDS;
|
|
732
942
|
exports.SPL_TOKEN_PROGRAM_ID_BASE58 = SPL_TOKEN_PROGRAM_ID_BASE58;
|
|
943
|
+
exports.SYSTEM_PROGRAM_ID_BASE58 = SYSTEM_PROGRAM_ID_BASE58;
|
|
944
|
+
exports.TOKEN_2022_PROGRAM_ID_BASE58 = TOKEN_2022_PROGRAM_ID_BASE58;
|
|
733
945
|
exports.WELL_KNOWN_ASSETS = WELL_KNOWN_ASSETS;
|
|
734
946
|
exports.WELL_KNOWN_ASSET_KEYS = WELL_KNOWN_ASSET_KEYS;
|
|
947
|
+
exports.WORK_LOG_STATES = WORK_LOG_STATES;
|
|
948
|
+
exports.WorkLogStates = WorkLogStates;
|
|
735
949
|
exports.base58btcDecode = base58btcDecode;
|
|
736
950
|
exports.base58btcEncode = base58btcEncode;
|
|
737
951
|
exports.buildCreateLockIxData = buildCreateLockIxData;
|
|
@@ -758,9 +972,22 @@ exports.generateKeyPair = generateKeyPair;
|
|
|
758
972
|
exports.getPublicKey = getPublicKey2;
|
|
759
973
|
exports.instructionDiscriminator = instructionDiscriminator;
|
|
760
974
|
exports.isAssetIdentifier = isAssetIdentifier;
|
|
975
|
+
exports.isBodyType = isBodyType;
|
|
976
|
+
exports.isDecimalAmountString = isDecimalAmountString;
|
|
761
977
|
exports.isDeclineReason = isDeclineReason;
|
|
978
|
+
exports.isDelegationAction = isDelegationAction;
|
|
979
|
+
exports.isDelegationState = isDelegationState;
|
|
980
|
+
exports.isDiscoverySort = isDiscoverySort;
|
|
981
|
+
exports.isEscrowReleaseMethod = isEscrowReleaseMethod;
|
|
982
|
+
exports.isHandshakeDecision = isHandshakeDecision;
|
|
983
|
+
exports.isInboxBlockScope = isInboxBlockScope;
|
|
984
|
+
exports.isReadModelStatus = isReadModelStatus;
|
|
985
|
+
exports.isReceiptVerdict = isReceiptVerdict;
|
|
986
|
+
exports.isRelationshipState = isRelationshipState;
|
|
987
|
+
exports.isSha256Hex = isSha256Hex;
|
|
762
988
|
exports.isValidDid = isValidDid;
|
|
763
989
|
exports.isWhitelistedAssetId = isWhitelistedAssetId;
|
|
990
|
+
exports.isWorkLogState = isWorkLogState;
|
|
764
991
|
exports.listWhitelistedAssets = listWhitelistedAssets;
|
|
765
992
|
exports.parseCaip19SolanaAssetId = parseCaip19SolanaAssetId;
|
|
766
993
|
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,14 @@ function bytesToHex2(b) {
|
|
|
281
282
|
return s;
|
|
282
283
|
}
|
|
283
284
|
|
|
284
|
-
// src/settlement/
|
|
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
|
+
var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
|
|
291
|
+
|
|
292
|
+
// src/settlement/token-program.ts
|
|
287
293
|
function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
|
|
288
294
|
if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
|
|
289
295
|
return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
|
|
@@ -335,6 +341,10 @@ function senderNonce() {
|
|
|
335
341
|
return base64urlnopad.encode(randomBytes(16));
|
|
336
342
|
}
|
|
337
343
|
|
|
344
|
+
// src/utils/time-windows.ts
|
|
345
|
+
var MAX_CLOCK_SKEW_SECONDS = 300;
|
|
346
|
+
var MAX_ENVELOPE_TTL_SECONDS = 86400;
|
|
347
|
+
|
|
338
348
|
// src/utils/timestamp.ts
|
|
339
349
|
function rfc3339(at = /* @__PURE__ */ new Date()) {
|
|
340
350
|
return `${at.toISOString().slice(0, 19)}Z`;
|
|
@@ -343,8 +353,8 @@ function expiresAt(ttlSeconds, now = /* @__PURE__ */ new Date()) {
|
|
|
343
353
|
if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
|
|
344
354
|
throw new Error(`expiresAt: ttlSeconds must be positive, got ${ttlSeconds}`);
|
|
345
355
|
}
|
|
346
|
-
if (ttlSeconds >
|
|
347
|
-
throw new Error(`expiresAt: ttlSeconds exceeds 24h cap, got ${ttlSeconds}`);
|
|
356
|
+
if (ttlSeconds > MAX_ENVELOPE_TTL_SECONDS) {
|
|
357
|
+
throw new Error(`expiresAt: ttlSeconds exceeds ${MAX_ENVELOPE_TTL_SECONDS}s (24h) cap, got ${ttlSeconds}`);
|
|
348
358
|
}
|
|
349
359
|
return rfc3339(new Date(now.getTime() + ttlSeconds * 1e3));
|
|
350
360
|
}
|
|
@@ -386,11 +396,147 @@ function sleepWithAbort(ms, signal) {
|
|
|
386
396
|
});
|
|
387
397
|
}
|
|
388
398
|
|
|
399
|
+
// src/types/envelope.ts
|
|
400
|
+
var SHA256_HEX_RE = /^sha256:[0-9a-f]{64}$/;
|
|
401
|
+
function isSha256Hex(v) {
|
|
402
|
+
return typeof v === "string" && SHA256_HEX_RE.test(v);
|
|
403
|
+
}
|
|
404
|
+
var ED25519_SIG_PREFIX = "ed25519:";
|
|
405
|
+
var PROTOCOL_VERSIONS = ["arp/0.1"];
|
|
406
|
+
var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
|
|
407
|
+
|
|
389
408
|
// src/types/body.ts
|
|
390
409
|
var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
|
|
391
410
|
function isDeclineReason(v) {
|
|
392
411
|
return typeof v === "string" && DECLINE_REASONS.includes(v);
|
|
393
412
|
}
|
|
413
|
+
var HANDSHAKE_DECISIONS = ["accept", "decline"];
|
|
414
|
+
function isHandshakeDecision(v) {
|
|
415
|
+
return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
|
|
416
|
+
}
|
|
417
|
+
var HandshakeDecisions = {
|
|
418
|
+
ACCEPT: "accept",
|
|
419
|
+
DECLINE: "decline"
|
|
420
|
+
};
|
|
421
|
+
var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
|
|
422
|
+
function isDelegationAction(v) {
|
|
423
|
+
return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
|
|
424
|
+
}
|
|
425
|
+
var DelegationActions = {
|
|
426
|
+
OFFER: "offer",
|
|
427
|
+
ACCEPT: "accept",
|
|
428
|
+
DECLINE: "decline",
|
|
429
|
+
CANCEL: "cancel",
|
|
430
|
+
FUND: "fund"
|
|
431
|
+
};
|
|
432
|
+
var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
|
|
433
|
+
function isReceiptVerdict(v) {
|
|
434
|
+
return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
|
|
435
|
+
}
|
|
436
|
+
var ReceiptVerdicts = {
|
|
437
|
+
ACCEPTED: "accepted",
|
|
438
|
+
ACCEPTED_WITH_NOTES: "accepted_with_notes",
|
|
439
|
+
REJECTED: "rejected"
|
|
440
|
+
};
|
|
441
|
+
var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
|
|
442
|
+
function isBodyType(v) {
|
|
443
|
+
return typeof v === "string" && BODY_TYPES.includes(v);
|
|
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
|
+
};
|
|
454
|
+
|
|
455
|
+
// src/types/delegation.ts
|
|
456
|
+
var DELEGATION_STATES = [
|
|
457
|
+
"offered",
|
|
458
|
+
"accepted",
|
|
459
|
+
"pending_lock_finalization",
|
|
460
|
+
"locked",
|
|
461
|
+
"disputing",
|
|
462
|
+
"completed",
|
|
463
|
+
"declined",
|
|
464
|
+
"canceled",
|
|
465
|
+
"failed",
|
|
466
|
+
"refunded",
|
|
467
|
+
"dispute_resolved"
|
|
468
|
+
];
|
|
469
|
+
var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalization", "locked"];
|
|
470
|
+
function isDelegationState(v) {
|
|
471
|
+
return typeof v === "string" && DELEGATION_STATES.includes(v);
|
|
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
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/types/relationship.ts
|
|
488
|
+
var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
|
|
489
|
+
var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
|
|
490
|
+
function isRelationshipState(v) {
|
|
491
|
+
return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
|
|
492
|
+
}
|
|
493
|
+
var RelationshipStates = {
|
|
494
|
+
PENDING: "pending",
|
|
495
|
+
ACTIVE: "active",
|
|
496
|
+
PAUSED: "paused",
|
|
497
|
+
CLOSED: "closed"
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
// src/types/work-log.ts
|
|
501
|
+
var WORK_LOG_STATES = ["requested", "responded"];
|
|
502
|
+
function isWorkLogState(v) {
|
|
503
|
+
return typeof v === "string" && WORK_LOG_STATES.includes(v);
|
|
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
|
+
};
|
|
394
540
|
|
|
395
541
|
// src/assets.ts
|
|
396
542
|
var SOLANA_CLUSTER_IDS = {
|
|
@@ -462,12 +608,20 @@ function isWhitelistedAssetId(assetId, cluster) {
|
|
|
462
608
|
return cluster === void 0 || hit.cluster === cluster;
|
|
463
609
|
}
|
|
464
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
|
+
}
|
|
465
619
|
function isAssetIdentifier(value) {
|
|
466
620
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
467
621
|
const v = value;
|
|
468
622
|
if (typeof v.asset_id !== "string" || !CAIP19_REGEX.test(v.asset_id)) return false;
|
|
469
|
-
if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals <
|
|
470
|
-
if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length
|
|
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;
|
|
471
625
|
return true;
|
|
472
626
|
}
|
|
473
627
|
function resolveAsset(input) {
|
|
@@ -634,6 +788,25 @@ var LOCK_ACCOUNT_SIZE = 269;
|
|
|
634
788
|
var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
|
|
635
789
|
var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
636
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
|
+
};
|
|
637
810
|
var NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
|
|
638
811
|
function decodeLockAccount(data) {
|
|
639
812
|
if (data.length !== LOCK_ACCOUNT_SIZE) {
|
|
@@ -686,4 +859,4 @@ function readU64LE(buf, off) {
|
|
|
686
859
|
return v;
|
|
687
860
|
}
|
|
688
861
|
|
|
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 };
|
|
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,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
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
|
+
export { detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes } from './token-program';
|
|
2
3
|
export type { TokenProgramKind, TokenProgramDetection } from './token-program';
|
|
@@ -0,0 +1,39 @@
|
|
|
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";
|
|
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";
|
|
@@ -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
|
package/dist/types/body.d.ts
CHANGED
|
@@ -71,6 +71,51 @@ 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
|
+
/** 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
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Lifecycle action on a `delegation` body. `offer` opens the
|
|
91
|
+
* delegation; `accept`/`decline` are the counterparty's response;
|
|
92
|
+
* `cancel` withdraws an unaccepted offer; `fund` attaches the escrow
|
|
93
|
+
* lock to an already-accepted delegation.
|
|
94
|
+
*/
|
|
95
|
+
export type DelegationAction = 'offer' | 'accept' | 'decline' | 'cancel' | 'fund';
|
|
96
|
+
export declare const DELEGATION_ACTIONS: readonly DelegationAction[];
|
|
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
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Payee's proposed verdict on a `receipt` body. The record is
|
|
108
|
+
* off-chain; settlement happens on-chain via `claim_work_payment`.
|
|
109
|
+
*/
|
|
110
|
+
export type ReceiptVerdict = 'accepted' | 'accepted_with_notes' | 'rejected';
|
|
111
|
+
export declare const RECEIPT_VERDICTS: readonly ReceiptVerdict[];
|
|
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
|
+
};
|
|
74
119
|
/**
|
|
75
120
|
* `handshake` — first signed exchange between two agents. Establishes
|
|
76
121
|
* the relationship; carries no terms (those live on the delegation).
|
|
@@ -97,7 +142,7 @@ export interface HandshakeResponseBody extends Body<HandshakeResponseContent> {
|
|
|
97
142
|
type: 'handshake_response';
|
|
98
143
|
}
|
|
99
144
|
export interface HandshakeResponseContent {
|
|
100
|
-
decision:
|
|
145
|
+
decision: HandshakeDecision;
|
|
101
146
|
notes?: string;
|
|
102
147
|
/** Machine-readable reason — REQUIRED when `decision === 'decline'`. See `DeclineReason`. */
|
|
103
148
|
reason?: DeclineReason;
|
|
@@ -113,7 +158,7 @@ export interface DelegationBody extends Body<DelegationContent> {
|
|
|
113
158
|
type: 'delegation';
|
|
114
159
|
}
|
|
115
160
|
export interface DelegationContent {
|
|
116
|
-
action:
|
|
161
|
+
action: DelegationAction;
|
|
117
162
|
delegation_id: string;
|
|
118
163
|
title?: string;
|
|
119
164
|
brief?: Record<string, unknown>;
|
|
@@ -177,7 +222,7 @@ export interface ReceiptContent {
|
|
|
177
222
|
model?: string;
|
|
178
223
|
computed_amount?: string;
|
|
179
224
|
};
|
|
180
|
-
verdict_proposed:
|
|
225
|
+
verdict_proposed: ReceiptVerdict;
|
|
181
226
|
deliverable_hash?: Sha256Hex;
|
|
182
227
|
notes_hash?: Sha256Hex;
|
|
183
228
|
[extra: string]: unknown;
|
|
@@ -203,3 +248,27 @@ export interface DisputeContent {
|
|
|
203
248
|
* `body.type` via discriminated dispatch.
|
|
204
249
|
*/
|
|
205
250
|
export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | WorkRequestBody | WorkResponseBody | ReceiptBody | DisputeBody;
|
|
251
|
+
/**
|
|
252
|
+
* The closed taxonomy of envelope `body.type` values — the runtime
|
|
253
|
+
* companion to `AnyBody` (`BodyType` is derived from it, so the two
|
|
254
|
+
* can't drift). Names are wire-facing and MUST match
|
|
255
|
+
* `00-core/protocol.md`.
|
|
256
|
+
*
|
|
257
|
+
* NOTE: this is the FULL taxonomy. A consumer's *acceptance policy* may
|
|
258
|
+
* deliberately admit only a subset (e.g. the server rejects `dispute`
|
|
259
|
+
* as not-yet-implemented) — that allowlist is a separate, hand-curated
|
|
260
|
+
* thing and must NOT be regenerated from this array.
|
|
261
|
+
*/
|
|
262
|
+
export type BodyType = AnyBody['type'];
|
|
263
|
+
export declare const BODY_TYPES: readonly BodyType[];
|
|
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
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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;
|
|
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
|
+
};
|
package/dist/types/envelope.d.ts
CHANGED
|
@@ -11,10 +11,35 @@ 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 =
|
|
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];
|
|
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;
|
|
18
43
|
/**
|
|
19
44
|
* Client-signed `protected` block. All fields here are part of the
|
|
20
45
|
* signing input. Server-assigned chain fields (`relationship_event_index`,
|
|
@@ -22,7 +47,7 @@ export type Did = `did:arp:${string}`;
|
|
|
22
47
|
* sign them.
|
|
23
48
|
*/
|
|
24
49
|
export interface ProtectedBlock {
|
|
25
|
-
protocol_version:
|
|
50
|
+
protocol_version: ProtocolVersion;
|
|
26
51
|
purpose: PurposeValue;
|
|
27
52
|
message_id: string;
|
|
28
53
|
sender_did: Did;
|
|
@@ -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
|
+
};
|
package/dist/types/identity.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
@@ -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
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
export type { Sha256Hex, Ed25519Sig, Did, ProtectedBlock, Body, Attachments, EscrowLockAttachment, Envelope, PersistedEvent, } from './envelope';
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
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, CURRENT_PROTOCOL_VERSION } 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, HandshakeDecisions, isHandshakeDecision, DELEGATION_ACTIONS, DelegationActions, isDelegationAction, RECEIPT_VERDICTS, ReceiptVerdicts, isReceiptVerdict, BODY_TYPES, BodyTypes, isBodyType, } from './body';
|
|
5
|
+
export type { DelegationState } from './delegation';
|
|
6
|
+
export { DELEGATION_STATES, DELEGATION_ACTIVE_STATES, DelegationStates, isDelegationState } from './delegation';
|
|
7
|
+
export type { RelationshipState } from './relationship';
|
|
8
|
+
export { RELATIONSHIP_STATE_NAMES, LIVE_RELATIONSHIP_STATE_NAMES, RelationshipStates, isRelationshipState } from './relationship';
|
|
9
|
+
export type { WorkLogState } 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';
|
|
4
18
|
export type { AcceptPrefs, AcceptCurrency } from './agent';
|
|
5
19
|
export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
|
|
6
|
-
export { SCRYPT_PARAMS } from './identity';
|
|
20
|
+
export { SCRYPT_PARAMS, OWNER_SIGNING_METHODS } from './identity';
|
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
|
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
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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;
|
|
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/dist/utils/index.d.ts
CHANGED
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyanon-arp/sdk",
|
|
3
|
-
"version": "0.0.
|
|
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": [
|