@heyanon-arp/sdk 0.0.32 → 0.0.34
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 +0 -2
- package/dist/canonical/canonicalize.d.ts +1 -1
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/post-commit.d.ts +0 -1
- package/dist/escrow/create-lock.d.ts +16 -6
- package/dist/escrow/index.d.ts +2 -2
- package/dist/escrow/lock-account.d.ts +0 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -75
- package/dist/index.mjs +6 -69
- package/dist/purpose.d.ts +0 -13
- package/dist/settlement/index.d.ts +0 -2
- package/dist/types/body.d.ts +3 -21
- package/dist/types/discovery.d.ts +0 -1
- package/dist/types/envelope.d.ts +0 -13
- package/dist/types/inbox.d.ts +0 -1
- package/dist/types/index.d.ts +4 -4
- package/package.json +1 -1
- package/dist/settlement/token-program.d.ts +0 -56
package/dist/assets.d.ts
CHANGED
|
@@ -82,8 +82,6 @@ export declare const WELL_KNOWN_ASSETS: Readonly<Record<string, AssetIdentifier>
|
|
|
82
82
|
* Lookup table keys exported for `--help` choices in the CLI.
|
|
83
83
|
*/
|
|
84
84
|
export declare const WELL_KNOWN_ASSET_KEYS: readonly string[];
|
|
85
|
-
/** Whitelisted assets for one cluster (defensive copies). */
|
|
86
|
-
export declare function listWhitelistedAssets(cluster: SolanaCluster): AssetIdentifier[];
|
|
87
85
|
/**
|
|
88
86
|
* Reverse lookup: CAIP-19 `asset_id` → whitelist entry + its cluster
|
|
89
87
|
* and shorthand key. Returns `null` for anything not whitelisted.
|
|
@@ -28,6 +28,6 @@ export declare function canonicalBytes(value: unknown): Uint8Array;
|
|
|
28
28
|
/**
|
|
29
29
|
* sha256 of `canonical_json(value)`, formatted as the protocol's
|
|
30
30
|
* `sha256:<hex>` string. Used for `body_hash`, `attachments_hash`,
|
|
31
|
-
*
|
|
31
|
+
* etc.
|
|
32
32
|
*/
|
|
33
33
|
export declare function canonicalSha256Hex(value: unknown): Sha256Hex;
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, isPostCommitErrorCode } from './post-commit';
|
|
2
|
-
export type { PostCommitErrorCode } from './post-commit';
|
|
3
2
|
export { DELEGATION_OFFER_REJECTION_CODES, DelegationOfferRejectionCodes, CLI_AUTH_TOKEN_ERROR_CODES, CliAuthTokenErrorCodes } from './codes';
|
|
4
3
|
export type { ApiErrorBody, DelegationOfferRejectionCode, CliAuthTokenErrorCode } from './codes';
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
* (the server was missing `RECEIPT_INVALID_STATE`). It is now owned here.
|
|
17
17
|
*/
|
|
18
18
|
export declare const POST_COMMIT_ERROR_CODES: readonly ["DELEGATION_ALREADY_EXISTS", "DELEGATION_INVALID_STATE", "DELEGATION_NOT_FOUND", "DELEGATION_RELATIONSHIP_MISMATCH", "DELEGATION_ACCEPTER_IS_OFFERER", "DELEGATION_DECLINER_IS_OFFERER", "DELEGATION_CANCELER_NOT_OFFERER", "DELEGATION_ASSET_NOT_ALLOWED", "DELEGATION_PRICING_MISMATCH", "DELEGATION_CAPACITY_EXCEEDED", "DELEGATION_PENDING_LOCK", "DELEGATION_FUNDER_NOT_OFFERER", "DELEGATION_ALREADY_FUNDED", "WORK_DELEGATION_NOT_FOUND", "WORK_DELEGATION_NOT_ACTIVE", "WORK_RELATIONSHIP_MISMATCH", "WORK_REQUESTER_NOT_OFFERER", "WORK_REQUEST_ALREADY_EXISTS", "WORK_REQUEST_NOT_FOUND", "WORK_RESPONDER_IS_CALLER", "WORK_INVALID_STATE", "RECEIPT_ALREADY_EXISTS", "RECEIPT_DELEGATION_NOT_FOUND", "RECEIPT_DELEGATION_NOT_ACTIVE", "RECEIPT_RELATIONSHIP_MISMATCH", "RECEIPT_ISSUER_IS_CALLER", "RECEIPT_NOT_FOUND", "RECEIPT_INVALID_STATE", "RECEIPT_RESPONSE_HASH_NOT_FOUND", "RECEIPT_REQUEST_HASH_NOT_FOUND", "RECEIPT_DELIVERABLE_HASH_MISMATCH"];
|
|
19
|
-
export type PostCommitErrorCode = (typeof POST_COMMIT_ERROR_CODES)[number];
|
|
20
19
|
/**
|
|
21
20
|
* Code-FAMILY prefixes that are always post-commit, enumerated rather
|
|
22
21
|
* than listed member-by-member because they grow over time:
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the canonical instruction-data byte sequence for a Solana
|
|
3
|
+
* `create_lock` instruction. Pure-bytes builder: callers compose
|
|
4
|
+
* this around a Solana Transaction object (in arp-server's
|
|
5
|
+
* ReleaseTxBuilderService style) or hand it to a separate CLI
|
|
6
|
+
* Solana web3 wrapper.
|
|
7
|
+
*
|
|
8
|
+
* The SDK doesn't depend on `@solana/web3.js` — that's a workspace
|
|
9
|
+
* rule (keeps the SDK installable in browser contexts that don't
|
|
10
|
+
* want the full Solana SDK pulled in). Callers feed in pre-derived
|
|
11
|
+
* PDAs / pubkeys; we return the 80-byte ix data buffer.
|
|
12
|
+
*
|
|
13
|
+
* Anchor 8-byte instruction discriminators:
|
|
14
|
+
* sha256("global:create_lock")[0..8] = ab d8 5c a7 a5 08 99 5a
|
|
15
|
+
* sha256("global:create_lock_native")[0..8] = ea 13 da 24 17 4a da 6c
|
|
16
|
+
*/
|
|
1
17
|
export declare const CREATE_LOCK_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
2
18
|
/** sha256("global:create_lock_native")[0..8] — the lamport-path variant. */
|
|
3
19
|
export declare const CREATE_LOCK_NATIVE_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
@@ -33,9 +49,3 @@ export interface CreateLockArgs {
|
|
|
33
49
|
export declare function buildCreateLockIxData(args: CreateLockArgs, opts?: {
|
|
34
50
|
native?: boolean;
|
|
35
51
|
}): Uint8Array;
|
|
36
|
-
/**
|
|
37
|
-
* Sanity check: confirm the hard-coded discriminator matches what
|
|
38
|
-
* sha256("global:create_lock")[0..8] should produce. Exposed for the
|
|
39
|
-
* SDK test suite; not used at runtime.
|
|
40
|
-
*/
|
|
41
|
-
export declare function computeCreateLockDiscriminator(): Uint8Array;
|
package/dist/escrow/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { deriveLockId, delegationIdToBytes16, bytes16ToDelegationId } from './lo
|
|
|
2
2
|
export { deriveDelegationConditionHash, type DelegationTermsSubset, type DelegationTermsInput } from './condition-hash';
|
|
3
3
|
export { parseCaip19SolanaAssetId, type ParsedSolanaAssetId } from './caip19';
|
|
4
4
|
export type { EscrowConfigStatus } from './config-status';
|
|
5
|
-
export { buildCreateLockIxData,
|
|
5
|
+
export { buildCreateLockIxData, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, type CreateLockArgs, } from './create-lock';
|
|
6
6
|
export { ESCROW_PDA_SEEDS, NO_ARG_LIFECYCLE_INSTRUCTIONS, type NoArgLifecycleInstruction, instructionDiscriminator, buildLifecycleIxData, buildResolveDisputeIxData, type ResolveDisputeArgs, } from './lifecycle-instructions';
|
|
7
|
-
export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, NATIVE_SOL_MINT_BASE58, type LockStateName, type LockTerminalState, type EscrowReleaseMethodName, isEscrowReleaseMethod, type DecodedLockAccount, decodeLockAccount,
|
|
7
|
+
export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, NATIVE_SOL_MINT_BASE58, type LockStateName, type LockTerminalState, type EscrowReleaseMethodName, isEscrowReleaseMethod, type DecodedLockAccount, decodeLockAccount, } from './lock-account';
|
|
8
8
|
export * from './instructions';
|
|
@@ -97,5 +97,3 @@ export interface DecodedLockAccount {
|
|
|
97
97
|
* beats silently-wrong fields.
|
|
98
98
|
*/
|
|
99
99
|
export declare function decodeLockAccount(data: Uint8Array): DecodedLockAccount;
|
|
100
|
-
/** Test hook: the canonical discriminator computation. */
|
|
101
|
-
export declare function computeLockAccountDiscriminator(): Uint8Array;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - challenge — ARP-CHALLENGE-v1 ownership proof (registration)
|
|
11
11
|
* - attestation — scrypt key-link owner attestation
|
|
12
12
|
* - server-chain — signed_message_hash, server_event_hash, audit walker
|
|
13
|
-
* - settlement —
|
|
13
|
+
* - settlement — canonical Solana program-id base58 constants
|
|
14
14
|
* - purpose — domain separators (`ARP-*-v1`)
|
|
15
15
|
* - utils — uuid v4, sender_nonce, RFC 3339, expires_at
|
|
16
16
|
* - types — wire-level TypeScript types (Envelope, body union, identity)
|
package/dist/index.js
CHANGED
|
@@ -160,23 +160,10 @@ var Purpose = {
|
|
|
160
160
|
ENVELOPE: "ARP-ENVELOPE-v1",
|
|
161
161
|
/** Receipt domain separator (delegation completion). */
|
|
162
162
|
RECEIPT: "ARP-RECEIPT-v1",
|
|
163
|
-
/** Dispute response domain separator. */
|
|
164
|
-
DISPUTE_RESPONSE: "ARP-DISPUTE-RESPONSE-v1",
|
|
165
163
|
/** Identity ownership challenge proof. */
|
|
166
164
|
CHALLENGE: "ARP-CHALLENGE-v1",
|
|
167
|
-
/** Verifiable Credential issued by the platform. */
|
|
168
|
-
VC: "ARP-VC-v1",
|
|
169
165
|
/** Owner attestation linking identity ↔ settlement keys at registration. */
|
|
170
|
-
KEY_LINK: "ARP-KEY-LINK-v1"
|
|
171
|
-
/**
|
|
172
|
-
* Settlement-key signature authorising an on-chain `release_lock`.
|
|
173
|
-
* The digest binds fee_bps_at_lock + fee_recipient_at_lock.
|
|
174
|
-
*/
|
|
175
|
-
SOLANA_RELEASE: "ARP-SOLANA-RELEASE-v1.5",
|
|
176
|
-
/** Settlement-key signature authorising an on-chain co-signed `refund_lock`. */
|
|
177
|
-
SOLANA_REFUND: "ARP-SOLANA-REFUND-v1",
|
|
178
|
-
/** Admin (platform multisig) signature authorising `resolve_dispute`. */
|
|
179
|
-
SOLANA_RESOLVE_DISPUTE: "ARP-SOLANA-RESOLVE-DISPUTE-v1"
|
|
166
|
+
KEY_LINK: "ARP-KEY-LINK-v1"
|
|
180
167
|
};
|
|
181
168
|
|
|
182
169
|
// src/challenge/challenge.ts
|
|
@@ -315,41 +302,6 @@ var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
|
315
302
|
var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
316
303
|
var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
|
|
317
304
|
var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
|
|
318
|
-
|
|
319
|
-
// src/settlement/token-program.ts
|
|
320
|
-
function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
|
|
321
|
-
if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
|
|
322
|
-
return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
|
|
323
|
-
}
|
|
324
|
-
if (mintAccountOwnerBase58 === TOKEN_2022_PROGRAM_ID_BASE58) {
|
|
325
|
-
throw new Error(
|
|
326
|
-
`detectTokenProgram: mint owner is the Token-2022 program (${TOKEN_2022_PROGRAM_ID_BASE58}), which ARP escrow does not support; use a legacy SPL Token mint (${SPL_TOKEN_PROGRAM_ID_BASE58}) or native SOL`
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
throw new Error(`detectTokenProgram: unsupported mint owner ${mintAccountOwnerBase58}; ARP escrow supports legacy SPL Token (${SPL_TOKEN_PROGRAM_ID_BASE58}) only`);
|
|
330
|
-
}
|
|
331
|
-
function detectTokenProgramFromOwnerBytes(mintAccountOwnerBytes) {
|
|
332
|
-
if (mintAccountOwnerBytes.length !== 32) {
|
|
333
|
-
throw new Error(`detectTokenProgram: mintAccountOwnerBytes must be 32 bytes, got ${mintAccountOwnerBytes.length}`);
|
|
334
|
-
}
|
|
335
|
-
return detectTokenProgramFromOwner(bytesToBase58(mintAccountOwnerBytes));
|
|
336
|
-
}
|
|
337
|
-
function bytesToBase58(bytes) {
|
|
338
|
-
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
339
|
-
let zeros = 0;
|
|
340
|
-
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) zeros++;
|
|
341
|
-
let num = 0n;
|
|
342
|
-
for (const b of bytes) {
|
|
343
|
-
num = num * 256n + BigInt(b);
|
|
344
|
-
}
|
|
345
|
-
let out = "";
|
|
346
|
-
while (num > 0n) {
|
|
347
|
-
const rem = Number(num % 58n);
|
|
348
|
-
num = num / 58n;
|
|
349
|
-
out = ALPHABET[rem] + out;
|
|
350
|
-
}
|
|
351
|
-
return "1".repeat(zeros) + out;
|
|
352
|
-
}
|
|
353
305
|
function uuidV4() {
|
|
354
306
|
const bytes = utils.randomBytes(16);
|
|
355
307
|
bytes[6] = bytes[6] & 15 | 64;
|
|
@@ -465,7 +417,7 @@ var ReceiptVerdicts = {
|
|
|
465
417
|
ACCEPTED_WITH_NOTES: "accepted_with_notes",
|
|
466
418
|
REJECTED: "rejected"
|
|
467
419
|
};
|
|
468
|
-
var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt"
|
|
420
|
+
var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt"];
|
|
469
421
|
function isBodyType(v) {
|
|
470
422
|
return typeof v === "string" && BODY_TYPES.includes(v);
|
|
471
423
|
}
|
|
@@ -475,8 +427,7 @@ var BodyTypes = {
|
|
|
475
427
|
DELEGATION: "delegation",
|
|
476
428
|
WORK_REQUEST: "work_request",
|
|
477
429
|
WORK_RESPONSE: "work_response",
|
|
478
|
-
RECEIPT: "receipt"
|
|
479
|
-
DISPUTE: "dispute"
|
|
430
|
+
RECEIPT: "receipt"
|
|
480
431
|
};
|
|
481
432
|
|
|
482
433
|
// src/types/delegation.ts
|
|
@@ -546,9 +497,6 @@ var ReadModelStatuses = {
|
|
|
546
497
|
|
|
547
498
|
// src/types/discovery.ts
|
|
548
499
|
var DISCOVERY_SORTS = ["reputation", "recent", "created"];
|
|
549
|
-
function isDiscoverySort(v) {
|
|
550
|
-
return typeof v === "string" && DISCOVERY_SORTS.includes(v);
|
|
551
|
-
}
|
|
552
500
|
var DiscoverySorts = {
|
|
553
501
|
REPUTATION: "reputation",
|
|
554
502
|
RECENT: "recent",
|
|
@@ -557,9 +505,6 @@ var DiscoverySorts = {
|
|
|
557
505
|
|
|
558
506
|
// src/types/inbox.ts
|
|
559
507
|
var INBOX_BLOCK_SCOPES = ["account", "did"];
|
|
560
|
-
function isInboxBlockScope(v) {
|
|
561
|
-
return typeof v === "string" && INBOX_BLOCK_SCOPES.includes(v);
|
|
562
|
-
}
|
|
563
508
|
var InboxBlockScopes = {
|
|
564
509
|
ACCOUNT: "account",
|
|
565
510
|
DID: "did"
|
|
@@ -669,9 +614,6 @@ var WELL_KNOWN_ASSETS = Object.fromEntries(
|
|
|
669
614
|
Object.entries(ASSET_WHITELIST).flatMap(([cluster, assets]) => assets.map((asset) => [`${asset.symbol}:${cluster}`, asset]))
|
|
670
615
|
);
|
|
671
616
|
var WELL_KNOWN_ASSET_KEYS = Object.keys(WELL_KNOWN_ASSETS);
|
|
672
|
-
function listWhitelistedAssets(cluster) {
|
|
673
|
-
return ASSET_WHITELIST[cluster].map((a) => ({ ...a }));
|
|
674
|
-
}
|
|
675
617
|
function findAssetByAssetId(assetId) {
|
|
676
618
|
for (const [cluster, assets] of Object.entries(ASSET_WHITELIST)) {
|
|
677
619
|
const asset = assets.find((a) => a.asset_id === assetId);
|
|
@@ -780,6 +722,8 @@ function parseCaip19SolanaAssetId(assetId) {
|
|
|
780
722
|
}
|
|
781
723
|
throw new Error(`Unsupported CAIP-19 namespace: ${JSON.stringify(namespaceRaw)} (only 'spl' and 'slip44' are supported on Solana)`);
|
|
782
724
|
}
|
|
725
|
+
|
|
726
|
+
// src/escrow/create-lock.ts
|
|
783
727
|
var CREATE_LOCK_DISCRIMINATOR = new Uint8Array([171, 216, 92, 167, 165, 8, 153, 90]);
|
|
784
728
|
var CREATE_LOCK_NATIVE_DISCRIMINATOR = new Uint8Array([234, 19, 218, 36, 23, 74, 218, 108]);
|
|
785
729
|
function buildCreateLockIxData(args, opts = {}) {
|
|
@@ -813,10 +757,6 @@ function writeU64LE(buf, off, value) {
|
|
|
813
757
|
v >>= 8n;
|
|
814
758
|
}
|
|
815
759
|
}
|
|
816
|
-
function computeCreateLockDiscriminator() {
|
|
817
|
-
const h = sha2.sha256(new TextEncoder().encode("global:create_lock"));
|
|
818
|
-
return h.slice(0, 8);
|
|
819
|
-
}
|
|
820
760
|
var ESCROW_PDA_SEEDS = {
|
|
821
761
|
LOCK: "lock",
|
|
822
762
|
ESCROW: "escrow",
|
|
@@ -927,9 +867,6 @@ function decodeLockAccount(data) {
|
|
|
927
867
|
bump: data[268]
|
|
928
868
|
};
|
|
929
869
|
}
|
|
930
|
-
function computeLockAccountDiscriminator() {
|
|
931
|
-
return sha2.sha256(new TextEncoder().encode("account:Lock")).slice(0, 8);
|
|
932
|
-
}
|
|
933
870
|
function toHex(bytes) {
|
|
934
871
|
let hex = "";
|
|
935
872
|
for (const b of bytes) hex += b.toString(16).padStart(2, "0");
|
|
@@ -1360,8 +1297,6 @@ exports.bytes16ToDelegationId = bytes16ToDelegationId;
|
|
|
1360
1297
|
exports.canonicalBytes = canonicalBytes;
|
|
1361
1298
|
exports.canonicalJson = canonicalJson;
|
|
1362
1299
|
exports.canonicalSha256Hex = canonicalSha256Hex;
|
|
1363
|
-
exports.computeCreateLockDiscriminator = computeCreateLockDiscriminator;
|
|
1364
|
-
exports.computeLockAccountDiscriminator = computeLockAccountDiscriminator;
|
|
1365
1300
|
exports.decodeLockAccount = decodeLockAccount;
|
|
1366
1301
|
exports.delegationIdToBytes16 = delegationIdToBytes16;
|
|
1367
1302
|
exports.deriveAta = deriveAta;
|
|
@@ -1376,8 +1311,6 @@ exports.deriveLockPda = deriveLockPda;
|
|
|
1376
1311
|
exports.deriveOperatorAuthPda = deriveOperatorAuthPda;
|
|
1377
1312
|
exports.deriveScryptKey = deriveScryptKey;
|
|
1378
1313
|
exports.deriveStakeVaultPda = deriveStakeVaultPda;
|
|
1379
|
-
exports.detectTokenProgramFromOwner = detectTokenProgramFromOwner;
|
|
1380
|
-
exports.detectTokenProgramFromOwnerBytes = detectTokenProgramFromOwnerBytes;
|
|
1381
1314
|
exports.expiresAt = expiresAt;
|
|
1382
1315
|
exports.fetchLockAccount = fetchLockAccount;
|
|
1383
1316
|
exports.findAssetByAssetId = findAssetByAssetId;
|
|
@@ -1393,10 +1326,8 @@ exports.isDecimalAmountString = isDecimalAmountString;
|
|
|
1393
1326
|
exports.isDeclineReason = isDeclineReason;
|
|
1394
1327
|
exports.isDelegationAction = isDelegationAction;
|
|
1395
1328
|
exports.isDelegationState = isDelegationState;
|
|
1396
|
-
exports.isDiscoverySort = isDiscoverySort;
|
|
1397
1329
|
exports.isEscrowReleaseMethod = isEscrowReleaseMethod;
|
|
1398
1330
|
exports.isHandshakeDecision = isHandshakeDecision;
|
|
1399
|
-
exports.isInboxBlockScope = isInboxBlockScope;
|
|
1400
1331
|
exports.isPostCommitErrorCode = isPostCommitErrorCode;
|
|
1401
1332
|
exports.isReadModelStatus = isReadModelStatus;
|
|
1402
1333
|
exports.isReceiptVerdict = isReceiptVerdict;
|
|
@@ -1407,7 +1338,6 @@ exports.isValidAgentName = isValidAgentName;
|
|
|
1407
1338
|
exports.isValidDid = isValidDid;
|
|
1408
1339
|
exports.isWhitelistedAssetId = isWhitelistedAssetId;
|
|
1409
1340
|
exports.isWorkLogState = isWorkLogState;
|
|
1410
|
-
exports.listWhitelistedAssets = listWhitelistedAssets;
|
|
1411
1341
|
exports.normalizeName = normalizeName;
|
|
1412
1342
|
exports.parseCaip19SolanaAssetId = parseCaip19SolanaAssetId;
|
|
1413
1343
|
exports.parseDid = parseDid;
|
package/dist/index.mjs
CHANGED
|
@@ -135,23 +135,10 @@ var Purpose = {
|
|
|
135
135
|
ENVELOPE: "ARP-ENVELOPE-v1",
|
|
136
136
|
/** Receipt domain separator (delegation completion). */
|
|
137
137
|
RECEIPT: "ARP-RECEIPT-v1",
|
|
138
|
-
/** Dispute response domain separator. */
|
|
139
|
-
DISPUTE_RESPONSE: "ARP-DISPUTE-RESPONSE-v1",
|
|
140
138
|
/** Identity ownership challenge proof. */
|
|
141
139
|
CHALLENGE: "ARP-CHALLENGE-v1",
|
|
142
|
-
/** Verifiable Credential issued by the platform. */
|
|
143
|
-
VC: "ARP-VC-v1",
|
|
144
140
|
/** Owner attestation linking identity ↔ settlement keys at registration. */
|
|
145
|
-
KEY_LINK: "ARP-KEY-LINK-v1"
|
|
146
|
-
/**
|
|
147
|
-
* Settlement-key signature authorising an on-chain `release_lock`.
|
|
148
|
-
* The digest binds fee_bps_at_lock + fee_recipient_at_lock.
|
|
149
|
-
*/
|
|
150
|
-
SOLANA_RELEASE: "ARP-SOLANA-RELEASE-v1.5",
|
|
151
|
-
/** Settlement-key signature authorising an on-chain co-signed `refund_lock`. */
|
|
152
|
-
SOLANA_REFUND: "ARP-SOLANA-REFUND-v1",
|
|
153
|
-
/** Admin (platform multisig) signature authorising `resolve_dispute`. */
|
|
154
|
-
SOLANA_RESOLVE_DISPUTE: "ARP-SOLANA-RESOLVE-DISPUTE-v1"
|
|
141
|
+
KEY_LINK: "ARP-KEY-LINK-v1"
|
|
155
142
|
};
|
|
156
143
|
|
|
157
144
|
// src/challenge/challenge.ts
|
|
@@ -290,41 +277,6 @@ var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
|
290
277
|
var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
291
278
|
var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
|
|
292
279
|
var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
|
|
293
|
-
|
|
294
|
-
// src/settlement/token-program.ts
|
|
295
|
-
function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
|
|
296
|
-
if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
|
|
297
|
-
return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
|
|
298
|
-
}
|
|
299
|
-
if (mintAccountOwnerBase58 === TOKEN_2022_PROGRAM_ID_BASE58) {
|
|
300
|
-
throw new Error(
|
|
301
|
-
`detectTokenProgram: mint owner is the Token-2022 program (${TOKEN_2022_PROGRAM_ID_BASE58}), which ARP escrow does not support; use a legacy SPL Token mint (${SPL_TOKEN_PROGRAM_ID_BASE58}) or native SOL`
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
throw new Error(`detectTokenProgram: unsupported mint owner ${mintAccountOwnerBase58}; ARP escrow supports legacy SPL Token (${SPL_TOKEN_PROGRAM_ID_BASE58}) only`);
|
|
305
|
-
}
|
|
306
|
-
function detectTokenProgramFromOwnerBytes(mintAccountOwnerBytes) {
|
|
307
|
-
if (mintAccountOwnerBytes.length !== 32) {
|
|
308
|
-
throw new Error(`detectTokenProgram: mintAccountOwnerBytes must be 32 bytes, got ${mintAccountOwnerBytes.length}`);
|
|
309
|
-
}
|
|
310
|
-
return detectTokenProgramFromOwner(bytesToBase58(mintAccountOwnerBytes));
|
|
311
|
-
}
|
|
312
|
-
function bytesToBase58(bytes) {
|
|
313
|
-
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
314
|
-
let zeros = 0;
|
|
315
|
-
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) zeros++;
|
|
316
|
-
let num = 0n;
|
|
317
|
-
for (const b of bytes) {
|
|
318
|
-
num = num * 256n + BigInt(b);
|
|
319
|
-
}
|
|
320
|
-
let out = "";
|
|
321
|
-
while (num > 0n) {
|
|
322
|
-
const rem = Number(num % 58n);
|
|
323
|
-
num = num / 58n;
|
|
324
|
-
out = ALPHABET[rem] + out;
|
|
325
|
-
}
|
|
326
|
-
return "1".repeat(zeros) + out;
|
|
327
|
-
}
|
|
328
280
|
function uuidV4() {
|
|
329
281
|
const bytes = randomBytes(16);
|
|
330
282
|
bytes[6] = bytes[6] & 15 | 64;
|
|
@@ -440,7 +392,7 @@ var ReceiptVerdicts = {
|
|
|
440
392
|
ACCEPTED_WITH_NOTES: "accepted_with_notes",
|
|
441
393
|
REJECTED: "rejected"
|
|
442
394
|
};
|
|
443
|
-
var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt"
|
|
395
|
+
var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt"];
|
|
444
396
|
function isBodyType(v) {
|
|
445
397
|
return typeof v === "string" && BODY_TYPES.includes(v);
|
|
446
398
|
}
|
|
@@ -450,8 +402,7 @@ var BodyTypes = {
|
|
|
450
402
|
DELEGATION: "delegation",
|
|
451
403
|
WORK_REQUEST: "work_request",
|
|
452
404
|
WORK_RESPONSE: "work_response",
|
|
453
|
-
RECEIPT: "receipt"
|
|
454
|
-
DISPUTE: "dispute"
|
|
405
|
+
RECEIPT: "receipt"
|
|
455
406
|
};
|
|
456
407
|
|
|
457
408
|
// src/types/delegation.ts
|
|
@@ -521,9 +472,6 @@ var ReadModelStatuses = {
|
|
|
521
472
|
|
|
522
473
|
// src/types/discovery.ts
|
|
523
474
|
var DISCOVERY_SORTS = ["reputation", "recent", "created"];
|
|
524
|
-
function isDiscoverySort(v) {
|
|
525
|
-
return typeof v === "string" && DISCOVERY_SORTS.includes(v);
|
|
526
|
-
}
|
|
527
475
|
var DiscoverySorts = {
|
|
528
476
|
REPUTATION: "reputation",
|
|
529
477
|
RECENT: "recent",
|
|
@@ -532,9 +480,6 @@ var DiscoverySorts = {
|
|
|
532
480
|
|
|
533
481
|
// src/types/inbox.ts
|
|
534
482
|
var INBOX_BLOCK_SCOPES = ["account", "did"];
|
|
535
|
-
function isInboxBlockScope(v) {
|
|
536
|
-
return typeof v === "string" && INBOX_BLOCK_SCOPES.includes(v);
|
|
537
|
-
}
|
|
538
483
|
var InboxBlockScopes = {
|
|
539
484
|
ACCOUNT: "account",
|
|
540
485
|
DID: "did"
|
|
@@ -644,9 +589,6 @@ var WELL_KNOWN_ASSETS = Object.fromEntries(
|
|
|
644
589
|
Object.entries(ASSET_WHITELIST).flatMap(([cluster, assets]) => assets.map((asset) => [`${asset.symbol}:${cluster}`, asset]))
|
|
645
590
|
);
|
|
646
591
|
var WELL_KNOWN_ASSET_KEYS = Object.keys(WELL_KNOWN_ASSETS);
|
|
647
|
-
function listWhitelistedAssets(cluster) {
|
|
648
|
-
return ASSET_WHITELIST[cluster].map((a) => ({ ...a }));
|
|
649
|
-
}
|
|
650
592
|
function findAssetByAssetId(assetId) {
|
|
651
593
|
for (const [cluster, assets] of Object.entries(ASSET_WHITELIST)) {
|
|
652
594
|
const asset = assets.find((a) => a.asset_id === assetId);
|
|
@@ -755,6 +697,8 @@ function parseCaip19SolanaAssetId(assetId) {
|
|
|
755
697
|
}
|
|
756
698
|
throw new Error(`Unsupported CAIP-19 namespace: ${JSON.stringify(namespaceRaw)} (only 'spl' and 'slip44' are supported on Solana)`);
|
|
757
699
|
}
|
|
700
|
+
|
|
701
|
+
// src/escrow/create-lock.ts
|
|
758
702
|
var CREATE_LOCK_DISCRIMINATOR = new Uint8Array([171, 216, 92, 167, 165, 8, 153, 90]);
|
|
759
703
|
var CREATE_LOCK_NATIVE_DISCRIMINATOR = new Uint8Array([234, 19, 218, 36, 23, 74, 218, 108]);
|
|
760
704
|
function buildCreateLockIxData(args, opts = {}) {
|
|
@@ -788,10 +732,6 @@ function writeU64LE(buf, off, value) {
|
|
|
788
732
|
v >>= 8n;
|
|
789
733
|
}
|
|
790
734
|
}
|
|
791
|
-
function computeCreateLockDiscriminator() {
|
|
792
|
-
const h = sha256(new TextEncoder().encode("global:create_lock"));
|
|
793
|
-
return h.slice(0, 8);
|
|
794
|
-
}
|
|
795
735
|
var ESCROW_PDA_SEEDS = {
|
|
796
736
|
LOCK: "lock",
|
|
797
737
|
ESCROW: "escrow",
|
|
@@ -902,9 +842,6 @@ function decodeLockAccount(data) {
|
|
|
902
842
|
bump: data[268]
|
|
903
843
|
};
|
|
904
844
|
}
|
|
905
|
-
function computeLockAccountDiscriminator() {
|
|
906
|
-
return sha256(new TextEncoder().encode("account:Lock")).slice(0, 8);
|
|
907
|
-
}
|
|
908
845
|
function toHex(bytes) {
|
|
909
846
|
let hex = "";
|
|
910
847
|
for (const b of bytes) hex += b.toString(16).padStart(2, "0");
|
|
@@ -1238,4 +1175,4 @@ var CliAuthTokenErrorCodes = {
|
|
|
1238
1175
|
REQUIRED: "AUTH_TOKEN_REQUIRED"
|
|
1239
1176
|
};
|
|
1240
1177
|
|
|
1241
|
-
export { AGENT_NAME_REGEX, AGENT_TAG_REGEX, ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CLI_AUTH_TOKEN_ERROR_CODES, CLI_LOGIN_SESSION_STATES, CLI_LOGIN_SESSION_STORED_STATES, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, CliAuthTokenErrorCodes, CliLoginSessionStates, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_OFFER_REJECTION_CODES, DELEGATION_STATES, DEVNET_MINTS, DID_ARP_REGEX, DISCOVERY_SORTS, DelegationActions, DelegationOfferRejectionCodes, 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, LockTerminalStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, PROTOCOL_VERSIONS, Purpose, READ_MODEL_STATUSES, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, RESERVED_NAMES, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID, 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, buildAcceptLockIx, buildCancelLockIx, buildClaimExpiredWorkIx, buildClaimWorkPaymentIx, buildCloseDisputeIx, buildCreateLockIx, buildCreateLockIxData, buildLifecycleIxData, buildOpenDisputeIx, buildResolveDisputeIx, buildResolveDisputeIxData, buildSubmitWorkIx, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex,
|
|
1178
|
+
export { AGENT_NAME_REGEX, AGENT_TAG_REGEX, ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CLI_AUTH_TOKEN_ERROR_CODES, CLI_LOGIN_SESSION_STATES, CLI_LOGIN_SESSION_STORED_STATES, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, CliAuthTokenErrorCodes, CliLoginSessionStates, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_OFFER_REJECTION_CODES, DELEGATION_STATES, DEVNET_MINTS, DID_ARP_REGEX, DISCOVERY_SORTS, DelegationActions, DelegationOfferRejectionCodes, 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, LockTerminalStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, PROTOCOL_VERSIONS, Purpose, READ_MODEL_STATUSES, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, RESERVED_NAMES, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID, 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, buildAcceptLockIx, buildCancelLockIx, buildClaimExpiredWorkIx, buildClaimWorkPaymentIx, buildCloseDisputeIx, buildCreateLockIx, buildCreateLockIxData, buildLifecycleIxData, buildOpenDisputeIx, buildResolveDisputeIx, buildResolveDisputeIxData, buildSubmitWorkIx, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, decodeLockAccount, delegationIdToBytes16, deriveAta, deriveCollateralConfigPda, deriveConfigPda, deriveDelegationConditionHash, deriveDisputeResolutionPda, deriveEscrowPda, deriveEventAuthorityPda, deriveLockId, deriveLockPda, deriveOperatorAuthPda, deriveScryptKey, deriveStakeVaultPda, expiresAt, fetchLockAccount, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isCliLoginSessionWireState, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isEscrowReleaseMethod, isHandshakeDecision, isPostCommitErrorCode, isReadModelStatus, isReceiptVerdict, isRelationshipState, isReservedName, isSha256Hex, isValidAgentName, isValidDid, isWhitelistedAssetId, isWorkLogState, normalizeName, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
|
package/dist/purpose.d.ts
CHANGED
|
@@ -15,22 +15,9 @@ export declare const Purpose: {
|
|
|
15
15
|
readonly ENVELOPE: "ARP-ENVELOPE-v1";
|
|
16
16
|
/** Receipt domain separator (delegation completion). */
|
|
17
17
|
readonly RECEIPT: "ARP-RECEIPT-v1";
|
|
18
|
-
/** Dispute response domain separator. */
|
|
19
|
-
readonly DISPUTE_RESPONSE: "ARP-DISPUTE-RESPONSE-v1";
|
|
20
18
|
/** Identity ownership challenge proof. */
|
|
21
19
|
readonly CHALLENGE: "ARP-CHALLENGE-v1";
|
|
22
|
-
/** Verifiable Credential issued by the platform. */
|
|
23
|
-
readonly VC: "ARP-VC-v1";
|
|
24
20
|
/** Owner attestation linking identity ↔ settlement keys at registration. */
|
|
25
21
|
readonly KEY_LINK: "ARP-KEY-LINK-v1";
|
|
26
|
-
/**
|
|
27
|
-
* Settlement-key signature authorising an on-chain `release_lock`.
|
|
28
|
-
* The digest binds fee_bps_at_lock + fee_recipient_at_lock.
|
|
29
|
-
*/
|
|
30
|
-
readonly SOLANA_RELEASE: "ARP-SOLANA-RELEASE-v1.5";
|
|
31
|
-
/** Settlement-key signature authorising an on-chain co-signed `refund_lock`. */
|
|
32
|
-
readonly SOLANA_REFUND: "ARP-SOLANA-REFUND-v1";
|
|
33
|
-
/** Admin (platform multisig) signature authorising `resolve_dispute`. */
|
|
34
|
-
readonly SOLANA_RESOLVE_DISPUTE: "ARP-SOLANA-RESOLVE-DISPUTE-v1";
|
|
35
22
|
};
|
|
36
23
|
export type PurposeValue = (typeof Purpose)[keyof typeof Purpose];
|
|
@@ -1,3 +1 @@
|
|
|
1
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';
|
|
3
|
-
export type { TokenProgramKind, TokenProgramDetection } from './token-program';
|
package/dist/types/body.d.ts
CHANGED
|
@@ -227,27 +227,11 @@ export interface ReceiptContent {
|
|
|
227
227
|
notes_hash?: Sha256Hex;
|
|
228
228
|
[extra: string]: unknown;
|
|
229
229
|
}
|
|
230
|
-
/**
|
|
231
|
-
* `dispute` — challenge against a delegation outcome. `action`
|
|
232
|
-
* discriminates lifecycle events.
|
|
233
|
-
*/
|
|
234
|
-
export interface DisputeBody extends Body<DisputeContent> {
|
|
235
|
-
type: 'dispute';
|
|
236
|
-
}
|
|
237
|
-
export interface DisputeContent {
|
|
238
|
-
action: 'open' | 'respond' | 'escalate' | 'withdraw';
|
|
239
|
-
dispute_id: string;
|
|
240
|
-
delegation_id: string;
|
|
241
|
-
claim?: string;
|
|
242
|
-
remedy_requested?: 'refund' | 'rework' | 'release';
|
|
243
|
-
evidence_refs?: string[];
|
|
244
|
-
response_text?: string;
|
|
245
|
-
}
|
|
246
230
|
/**
|
|
247
231
|
* Union over every standard body type. Consumers can narrow on
|
|
248
232
|
* `body.type` via discriminated dispatch.
|
|
249
233
|
*/
|
|
250
|
-
export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | WorkRequestBody | WorkResponseBody | ReceiptBody
|
|
234
|
+
export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | WorkRequestBody | WorkResponseBody | ReceiptBody;
|
|
251
235
|
/**
|
|
252
236
|
* The closed taxonomy of envelope `body.type` values — the runtime
|
|
253
237
|
* companion to `AnyBody` (`BodyType` is derived from it, so the two
|
|
@@ -255,9 +239,8 @@ export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | W
|
|
|
255
239
|
* `00-core/protocol.md`.
|
|
256
240
|
*
|
|
257
241
|
* NOTE: this is the FULL taxonomy. A consumer's *acceptance policy* may
|
|
258
|
-
* deliberately admit only a subset
|
|
259
|
-
*
|
|
260
|
-
* thing and must NOT be regenerated from this array.
|
|
242
|
+
* deliberately admit only a subset — that allowlist is a separate,
|
|
243
|
+
* hand-curated thing and must NOT be regenerated from this array.
|
|
261
244
|
*/
|
|
262
245
|
export type BodyType = AnyBody['type'];
|
|
263
246
|
export declare const BODY_TYPES: readonly BodyType[];
|
|
@@ -270,5 +253,4 @@ export declare const BodyTypes: {
|
|
|
270
253
|
readonly WORK_REQUEST: "work_request";
|
|
271
254
|
readonly WORK_RESPONSE: "work_response";
|
|
272
255
|
readonly RECEIPT: "receipt";
|
|
273
|
-
readonly DISPUTE: "dispute";
|
|
274
256
|
};
|
|
@@ -10,7 +10,6 @@ import type { AcceptPrefs, AgentReputation } from './agent';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const DISCOVERY_SORTS: readonly ["reputation", "recent", "created"];
|
|
12
12
|
export type DiscoverySort = (typeof DISCOVERY_SORTS)[number];
|
|
13
|
-
export declare function isDiscoverySort(v: unknown): v is DiscoverySort;
|
|
14
13
|
/** Named-member accessor for {@link DiscoverySort} (vocab-tested). */
|
|
15
14
|
export declare const DiscoverySorts: {
|
|
16
15
|
readonly REPUTATION: "reputation";
|
package/dist/types/envelope.d.ts
CHANGED
|
@@ -112,16 +112,3 @@ export interface Envelope<TBody extends Body = Body> {
|
|
|
112
112
|
attachments?: Attachments;
|
|
113
113
|
sender_signature: Ed25519Sig;
|
|
114
114
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Server-side projection of an accepted event. Adds chain fields
|
|
117
|
-
* (server-assigned, NOT in signing input). Returned by the ingestion
|
|
118
|
-
* endpoint and persisted on the events table.
|
|
119
|
-
*/
|
|
120
|
-
export interface PersistedEvent<TBody extends Body = Body> extends Envelope<TBody> {
|
|
121
|
-
event_id: string;
|
|
122
|
-
relationship_event_index: number;
|
|
123
|
-
prev_server_event_hash: string | null;
|
|
124
|
-
server_event_hash: string;
|
|
125
|
-
signed_message_hash: string;
|
|
126
|
-
server_timestamp: string;
|
|
127
|
-
}
|
package/dist/types/inbox.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const INBOX_BLOCK_SCOPES: readonly ["account", "did"];
|
|
11
11
|
export type InboxBlockScope = (typeof INBOX_BLOCK_SCOPES)[number];
|
|
12
|
-
export declare function isInboxBlockScope(v: unknown): v is InboxBlockScope;
|
|
13
12
|
/** Named-member accessor for {@link InboxBlockScope} (vocab-tested). */
|
|
14
13
|
export declare const InboxBlockScopes: {
|
|
15
14
|
readonly ACCOUNT: "account";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type { Sha256Hex, Ed25519Sig, Did, ProtocolVersion, ProtectedBlock, Body, Attachments, EscrowLockAttachment, Envelope,
|
|
1
|
+
export type { Sha256Hex, Ed25519Sig, Did, ProtocolVersion, ProtectedBlock, Body, Attachments, EscrowLockAttachment, Envelope, } from './envelope';
|
|
2
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,
|
|
3
|
+
export type { HandshakeBody, HandshakeContent, HandshakeResponseBody, HandshakeResponseContent, HandshakeDecision, DelegationBody, DelegationContent, DelegationAction, WorkRequestBody, WorkRequestContent, WorkResponseBody, WorkResponseContent, ReceiptBody, ReceiptContent, ReceiptVerdict, AnyBody, BodyType, DeclineReason, AssetIdentifier, } from './body';
|
|
4
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
6
|
export { DELEGATION_STATES, DELEGATION_ACTIVE_STATES, DelegationStates, isDelegationState } from './delegation';
|
|
@@ -11,9 +11,9 @@ export { WORK_LOG_STATES, WorkLogStates, isWorkLogState } from './work-log';
|
|
|
11
11
|
export type { ReadModelStatus } from './event';
|
|
12
12
|
export { READ_MODEL_STATUSES, ReadModelStatuses, isReadModelStatus } from './event';
|
|
13
13
|
export type { DiscoverySort, DiscoverySearchQuery, DiscoveryReputation, DiscoveryLiveness, DiscoveryResult, DiscoveryPagination, DiscoverySearchResponse, DiscoveryProfile, } from './discovery';
|
|
14
|
-
export { DISCOVERY_SORTS, DiscoverySorts
|
|
14
|
+
export { DISCOVERY_SORTS, DiscoverySorts } from './discovery';
|
|
15
15
|
export type { InboxBlockScope, InboxBlock, BlockInboxBody } from './inbox';
|
|
16
|
-
export { INBOX_BLOCK_SCOPES, InboxBlockScopes
|
|
16
|
+
export { INBOX_BLOCK_SCOPES, InboxBlockScopes } from './inbox';
|
|
17
17
|
export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary, CliLoginSessionStoredState, CliLoginSessionWireState, } from './cli-auth';
|
|
18
18
|
export { CLI_LOGIN_SESSION_STORED_STATES, CLI_LOGIN_SESSION_STATES, CliLoginSessionStates, isCliLoginSessionWireState } from './cli-auth';
|
|
19
19
|
export type { AssetIdentifierWire, DelegationPublic, DisputeResolutionPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult, SenderSequenceResponse, InboxUnblockResult, ListRelationshipsQuery, ListInboxQuery, ListEventsQuery, ListDelegationsQuery, ListWorkLogsQuery, ListReceiptsQuery, } from './read-model';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyanon-arp/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
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": [
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token program detection helpers.
|
|
3
|
-
*
|
|
4
|
-
* ARP escrow settles in native SOL or a legacy SPL Token mint. The
|
|
5
|
-
* escrow contract dispatches transfer / close-account CPIs based on the
|
|
6
|
-
* mint's program kind, detected on-chain from the mint account's `owner`
|
|
7
|
-
* field; this helper mirrors that logic for off-chain consumers (tx
|
|
8
|
-
* builders, indexers, decoders).
|
|
9
|
-
*
|
|
10
|
-
* Token-2022 (the token-extensions program) is NOT supported — a mint
|
|
11
|
-
* owned by it is rejected here so it can never enter the escrow flow.
|
|
12
|
-
*
|
|
13
|
-
* The function takes the mint account's `owner` pubkey — the program
|
|
14
|
-
* that minted it — NOT the mint's mint_authority. Confusingly, both are
|
|
15
|
-
* called "owner" in different contexts.
|
|
16
|
-
*/
|
|
17
|
-
export { SPL_TOKEN_PROGRAM_ID_BASE58 } from './program-ids';
|
|
18
|
-
/**
|
|
19
|
-
* Token program kind. Maps to the contract's `token_program_kind` u8 on
|
|
20
|
-
* `LockCreated` events: `native` → 0, `legacy` → 1. (The contract also
|
|
21
|
-
* defines `2` for Token-2022, but ARP no longer supports it — such a
|
|
22
|
-
* lock is rejected before it is tracked, so this type never carries it.)
|
|
23
|
-
*
|
|
24
|
-
* `detectTokenProgramFromOwner` resolves the kind for a NON-native mint
|
|
25
|
-
* by looking at its `.owner` field; native locks are detected from the
|
|
26
|
-
* mint slot value, not from this helper.
|
|
27
|
-
*/
|
|
28
|
-
export type TokenProgramKind = 'legacy' | 'native';
|
|
29
|
-
/**
|
|
30
|
-
* Result of `detectTokenProgram`: the program kind + a typed branding for
|
|
31
|
-
* downstream consumers.
|
|
32
|
-
*/
|
|
33
|
-
export interface TokenProgramDetection {
|
|
34
|
-
kind: TokenProgramKind;
|
|
35
|
-
/** The detected program ID in base58 form (always the canonical address). */
|
|
36
|
-
programIdBase58: string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Detect a mint's token program kind from its OWNER pubkey (the program
|
|
40
|
-
* that owns the mint account in Solana account terms).
|
|
41
|
-
*
|
|
42
|
-
* Returns `legacy` for a legacy SPL Token mint. Throws for a Token-2022
|
|
43
|
-
* mint (unsupported) or any other owner — escrow would otherwise
|
|
44
|
-
* dispatch a CPI to a surface it does not handle.
|
|
45
|
-
*
|
|
46
|
-
* @param mintAccountOwnerBase58 — the mint account's `.owner` field as
|
|
47
|
-
* a base58 string. From `connection.getAccountInfo(mintPubkey)`, this is
|
|
48
|
-
* `accountInfo.owner.toBase58()`.
|
|
49
|
-
*/
|
|
50
|
-
export declare function detectTokenProgramFromOwner(mintAccountOwnerBase58: string): TokenProgramDetection;
|
|
51
|
-
/**
|
|
52
|
-
* Same as `detectTokenProgramFromOwner` but accepts a 32-byte raw owner
|
|
53
|
-
* buffer instead of base58 string. Useful for callers that already have
|
|
54
|
-
* the binary owner bytes (e.g. from a parsed AccountInfo).
|
|
55
|
-
*/
|
|
56
|
-
export declare function detectTokenProgramFromOwnerBytes(mintAccountOwnerBytes: Uint8Array): TokenProgramDetection;
|