@heyanon-arp/sdk 0.0.3 → 0.0.5
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/did/document.d.ts +4 -6
- package/dist/did/index.d.ts +1 -1
- package/dist/escrow/condition-hash.d.ts +41 -54
- package/dist/escrow/create-lock.d.ts +1 -1
- package/dist/escrow/index.d.ts +1 -1
- package/dist/escrow/lock-id.d.ts +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +20 -45
- package/dist/index.mjs +20 -42
- package/dist/purpose.d.ts +3 -5
- package/dist/settlement/index.d.ts +1 -1
- package/dist/settlement/token-program.d.ts +22 -35
- package/dist/types/body.d.ts +15 -52
- package/dist/types/envelope.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/webhook/index.d.ts +0 -2
- package/dist/webhook/webhook.d.ts +0 -38
package/dist/did/document.d.ts
CHANGED
|
@@ -5,11 +5,14 @@
|
|
|
5
5
|
* `identity_pubkey` from the document (not `decoded(did)`) because
|
|
6
6
|
* `identity_pubkey` may have rotated since registration while the DID
|
|
7
7
|
* itself stays stable.
|
|
8
|
+
*
|
|
9
|
+
* No `service[]` endpoint: delivery is server-mediated and agents
|
|
10
|
+
* pull (poll/SSE inbox), so there is no per-agent inbound endpoint
|
|
11
|
+
* to advertise.
|
|
8
12
|
*/
|
|
9
13
|
export interface DidDocument {
|
|
10
14
|
id: string;
|
|
11
15
|
verificationMethod: VerificationMethod[];
|
|
12
|
-
service: ServiceEndpoint[];
|
|
13
16
|
metadata: {
|
|
14
17
|
key_mode: KeyMode;
|
|
15
18
|
owner_attestation_id: string;
|
|
@@ -23,8 +26,3 @@ export interface VerificationMethod {
|
|
|
23
26
|
controller: string;
|
|
24
27
|
publicKeyMultibase: string;
|
|
25
28
|
}
|
|
26
|
-
export interface ServiceEndpoint {
|
|
27
|
-
id: string;
|
|
28
|
-
type: 'ARPEndpoint';
|
|
29
|
-
serviceEndpoint: string;
|
|
30
|
-
}
|
package/dist/did/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { formatDid, parseDid, isValidDid } from './format';
|
|
2
|
-
export type { DidDocument, KeyMode, VerificationMethod
|
|
2
|
+
export type { DidDocument, KeyMode, VerificationMethod } from './document';
|
|
@@ -1,79 +1,66 @@
|
|
|
1
1
|
import type { AssetIdentifier } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Subset of
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
3
|
+
* Subset of DELEGATION terms that the on-chain `condition_hash` binds:
|
|
4
|
+
* - `delegationId` is the identity binding — it is the root of the
|
|
5
|
+
* on-chain derivation chain (`lock_id = sha256("arp-lock-v1" ||
|
|
6
|
+
* delegationId_bytes16)`), so it is known before `create_lock` is
|
|
7
|
+
* built → NOT circular.
|
|
8
|
+
* - `currency` is the single `delegation.currency` field (the one
|
|
9
|
+
* asset for both rate + amount); the projection reads the REAL
|
|
10
|
+
* delegation field, so a raw delegation row binds currency with no
|
|
11
|
+
* caller pre-mapping.
|
|
10
12
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
14
|
-
*
|
|
13
|
+
* `amount` is intentionally NOT here — the concrete locked amount AND its
|
|
14
|
+
* mint are bound at settlement via the digest (`buildReleaseDigest` binds
|
|
15
|
+
* `amount` u64 + `mint` 32B) and on-chain in the Lock account. The
|
|
16
|
+
* condition_hash binds the agreed TERMS (scope / pricing / settlement /
|
|
17
|
+
* rate / unit / currency), not the amount.
|
|
18
|
+
*
|
|
19
|
+
* The shape MUST match server-side + CLI derivation byte-for-byte; the
|
|
20
|
+
* golden vectors in `condition-hash.test.ts` pin it.
|
|
15
21
|
*/
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
version: number;
|
|
22
|
+
export interface DelegationTermsSubset {
|
|
23
|
+
delegationId: string;
|
|
19
24
|
scopeSummary: string;
|
|
20
25
|
pricingModel: string;
|
|
21
26
|
settlementModel: string;
|
|
22
27
|
rateAmount?: string;
|
|
23
|
-
rateCurrency?: AssetIdentifier;
|
|
24
28
|
rateUnit?: string;
|
|
25
|
-
|
|
29
|
+
currency?: AssetIdentifier;
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
|
-
* Loose input
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* contract shape grows new fields.
|
|
34
|
-
*
|
|
35
|
-
* All fields are typed as optional here so a row pulled directly from
|
|
36
|
-
* Mongoose (where most contract fields are optional in the schema)
|
|
37
|
-
* fits the shape. The actual validity check happens inside
|
|
38
|
-
* `deriveConditionHash`, which throws if a required projected field
|
|
39
|
-
* is undefined — that surface is the right place to fail because
|
|
40
|
-
* `condition_hash` cannot be derived without it.
|
|
32
|
+
* Loose input for `deriveDelegationConditionHash`. Callers pass a whole
|
|
33
|
+
* delegation row / DTO; we project onto `DelegationTermsSubset` so extra
|
|
34
|
+
* fields (`state`, `relationshipId`, `amount`, timestamps, decline
|
|
35
|
+
* metadata, …) can NEVER influence the hash. Defensive projection:
|
|
36
|
+
* extra fields can NEVER influence the hash.
|
|
41
37
|
*/
|
|
42
|
-
export interface
|
|
43
|
-
|
|
44
|
-
version?: number;
|
|
38
|
+
export interface DelegationTermsInput {
|
|
39
|
+
delegationId?: string;
|
|
45
40
|
scopeSummary?: string;
|
|
46
41
|
pricingModel?: string;
|
|
47
42
|
settlementModel?: string;
|
|
48
43
|
rateAmount?: string;
|
|
49
|
-
rateCurrency?: AssetIdentifier;
|
|
50
44
|
rateUnit?: string;
|
|
51
|
-
|
|
45
|
+
currency?: AssetIdentifier;
|
|
52
46
|
[other: string]: unknown;
|
|
53
47
|
}
|
|
54
48
|
/**
|
|
55
|
-
* Compute the 32-byte sha256 condition_hash that binds an on-chain
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* The function performs an EXPLICIT FIELD PROJECTION before
|
|
59
|
-
* canonicalisation. Even if the caller passes a full contract row
|
|
60
|
-
* with `state`, `createdAt`, `declineReason`, etc., only the eight
|
|
61
|
-
* whitelisted fields are hashed. This is critical for digest
|
|
62
|
-
* stability across SDK versions: adding a field to the public
|
|
63
|
-
* contract shape MUST NOT change `condition_hash` values for existing
|
|
64
|
-
* contracts.
|
|
49
|
+
* Compute the 32-byte sha256 condition_hash that binds an on-chain lock
|
|
50
|
+
* to the off-chain DELEGATION terms.
|
|
65
51
|
*
|
|
66
|
-
* Wire procedure
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
52
|
+
* Wire procedure — explicit field
|
|
53
|
+
* projection → JCS canonicalize (`canonicalBytes`) → sha256. The
|
|
54
|
+
* projection is the security boundary: adding a field to the public
|
|
55
|
+
* delegation shape MUST NOT change `condition_hash` for existing
|
|
56
|
+
* delegations.
|
|
70
57
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* on-chain.
|
|
58
|
+
* Runs in THREE places that MUST agree byte-for-byte: the buyer's
|
|
59
|
+
* offer-prep (CLI), the server's `delegation.offer` validation
|
|
60
|
+
* (recompute + compare to the on-chain bound hash), and the settlement
|
|
61
|
+
* digest reconstruction. Any field-set drift produces a different hash
|
|
62
|
+
* → Ed25519 settlement verify fails on-chain.
|
|
76
63
|
*
|
|
77
64
|
* @returns 32-byte condition_hash
|
|
78
65
|
*/
|
|
79
|
-
export declare function
|
|
66
|
+
export declare function deriveDelegationConditionHash(delegation: DelegationTermsInput): Uint8Array;
|
|
@@ -4,7 +4,7 @@ export interface CreateLockArgs {
|
|
|
4
4
|
lockId: Uint8Array;
|
|
5
5
|
/** u64 amount in base units. */
|
|
6
6
|
amount: bigint;
|
|
7
|
-
/** 32-byte condition_hash (
|
|
7
|
+
/** 32-byte condition_hash (deriveDelegationConditionHash output). */
|
|
8
8
|
conditionHash: Uint8Array;
|
|
9
9
|
/** u64 unix-seconds expiry. */
|
|
10
10
|
expiry: bigint;
|
package/dist/escrow/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { deriveLockId, delegationIdToBytes16, bytes16ToDelegationId } from './lock-id';
|
|
2
|
-
export {
|
|
2
|
+
export { deriveDelegationConditionHash, type DelegationTermsSubset, type DelegationTermsInput } from './condition-hash';
|
|
3
3
|
export { parseCaip19SolanaAssetId, type ParsedSolanaAssetId } from './caip19';
|
|
4
4
|
export { buildCreateLockIxData, computeCreateLockDiscriminator, CREATE_LOCK_DISCRIMINATOR, type CreateLockArgs, } from './create-lock';
|
package/dist/escrow/lock-id.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare function deriveLockId(delegationId: string): Uint8Array;
|
|
|
41
41
|
* Either way, the same 16-byte representation comes out (UUID body is
|
|
42
42
|
* the lock-id substrate; the `del_` prefix is a wrapper that exists
|
|
43
43
|
* only so the wire shape is unambiguously a delegation reference vs.
|
|
44
|
-
* a
|
|
44
|
+
* a receipt id elsewhere in the canonical JSON). Pushing
|
|
45
45
|
* this normalization down into the SDK gives every caller — CLI,
|
|
46
46
|
* server, future TypeScript clients — a single source of truth.
|
|
47
47
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* - envelope — sign / verify envelope (steps 4-6 of protocol verification)
|
|
10
10
|
* - cosignature — receipt + dispute-response co-signatures
|
|
11
11
|
* - challenge — ARP-CHALLENGE-v1 ownership proof (registration / rotation)
|
|
12
|
-
* - webhook — ARP-WEBHOOK-v1 HMAC header (outbox delivery)
|
|
13
12
|
* - attestation — scrypt key-link + key-rotation attestations
|
|
14
13
|
* - server-chain — signed_message_hash, server_event_hash, audit walker
|
|
15
14
|
* - settlement — ARP-SOLANA-* digest stubs (V1.5)
|
|
@@ -27,7 +26,6 @@ export * from './did';
|
|
|
27
26
|
export * from './envelope';
|
|
28
27
|
export * from './cosignature';
|
|
29
28
|
export * from './challenge';
|
|
30
|
-
export * from './webhook';
|
|
31
29
|
export * from './attestation';
|
|
32
30
|
export * from './server-chain';
|
|
33
31
|
export * from './settlement';
|
package/dist/index.js
CHANGED
|
@@ -160,8 +160,6 @@ var Purpose = {
|
|
|
160
160
|
RECEIPT: "ARP-RECEIPT-v1",
|
|
161
161
|
/** Dispute response co-signature payload. */
|
|
162
162
|
DISPUTE_RESPONSE: "ARP-DISPUTE-RESPONSE-v1",
|
|
163
|
-
/** Webhook delivery HMAC signature payload. */
|
|
164
|
-
WEBHOOK: "ARP-WEBHOOK-v1",
|
|
165
163
|
/** Identity ownership challenge proof. */
|
|
166
164
|
CHALLENGE: "ARP-CHALLENGE-v1",
|
|
167
165
|
/** Verifiable Credential issued by the platform. */
|
|
@@ -267,23 +265,6 @@ function verifyChallenge(challengeBytes, signature, identityPubkey) {
|
|
|
267
265
|
if (signature.length !== 64) return false;
|
|
268
266
|
return verify2(signature, buildSigningInput(challengeBytes), identityPubkey);
|
|
269
267
|
}
|
|
270
|
-
function buildWebhookSignatureHeader(input, sharedSecret) {
|
|
271
|
-
const digest = sha2.sha256(canonicalBytes(input));
|
|
272
|
-
const mac = hmac.hmac(sha2.sha256, sharedSecret, digest);
|
|
273
|
-
return `${Purpose.WEBHOOK}=${base.base64.encode(mac)}`;
|
|
274
|
-
}
|
|
275
|
-
function verifyWebhookSignatureHeader(headerValue, input, sharedSecret) {
|
|
276
|
-
const expected = buildWebhookSignatureHeader(input, sharedSecret);
|
|
277
|
-
return constantTimeEqual(expected, headerValue);
|
|
278
|
-
}
|
|
279
|
-
function constantTimeEqual(a, b) {
|
|
280
|
-
if (a.length !== b.length) return false;
|
|
281
|
-
let diff = 0;
|
|
282
|
-
for (let i = 0; i < a.length; i++) {
|
|
283
|
-
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
284
|
-
}
|
|
285
|
-
return diff === 0;
|
|
286
|
-
}
|
|
287
268
|
|
|
288
269
|
// src/types/identity.ts
|
|
289
270
|
var SCRYPT_PARAMS = {
|
|
@@ -580,16 +561,15 @@ function u16LE(value) {
|
|
|
580
561
|
var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
581
562
|
var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
582
563
|
function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
`detectTokenProgram: unsupported mint owner ${mintAccountOwnerBase58}; ARP escrow supports legacy SPL Token (${SPL_TOKEN_PROGRAM_ID_BASE58}) and Token-2022 (${TOKEN_2022_PROGRAM_ID_BASE58}) only`
|
|
591
|
-
);
|
|
564
|
+
if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
|
|
565
|
+
return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
|
|
566
|
+
}
|
|
567
|
+
if (mintAccountOwnerBase58 === TOKEN_2022_PROGRAM_ID_BASE58) {
|
|
568
|
+
throw new Error(
|
|
569
|
+
`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`
|
|
570
|
+
);
|
|
592
571
|
}
|
|
572
|
+
throw new Error(`detectTokenProgram: unsupported mint owner ${mintAccountOwnerBase58}; ARP escrow supports legacy SPL Token (${SPL_TOKEN_PROGRAM_ID_BASE58}) only`);
|
|
593
573
|
}
|
|
594
574
|
function detectTokenProgramFromOwnerBytes(mintAccountOwnerBytes) {
|
|
595
575
|
if (mintAccountOwnerBytes.length !== 32) {
|
|
@@ -738,24 +718,22 @@ function resolveAsset(input) {
|
|
|
738
718
|
return null;
|
|
739
719
|
}
|
|
740
720
|
var WELL_KNOWN_ASSET_KEYS = Object.keys(WELL_KNOWN_ASSETS);
|
|
741
|
-
function
|
|
742
|
-
const required = ["
|
|
721
|
+
function deriveDelegationConditionHash(delegation) {
|
|
722
|
+
const required = ["delegationId", "scopeSummary", "pricingModel", "settlementModel"];
|
|
743
723
|
for (const field of required) {
|
|
744
|
-
if (
|
|
745
|
-
throw new Error(`
|
|
724
|
+
if (delegation[field] === void 0) {
|
|
725
|
+
throw new Error(`deriveDelegationConditionHash: required field '${String(field)}' is missing from the delegation input`);
|
|
746
726
|
}
|
|
747
727
|
}
|
|
748
728
|
const subset = {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
settlementModel: contract.settlementModel
|
|
729
|
+
delegationId: delegation.delegationId,
|
|
730
|
+
scopeSummary: delegation.scopeSummary,
|
|
731
|
+
pricingModel: delegation.pricingModel,
|
|
732
|
+
settlementModel: delegation.settlementModel
|
|
754
733
|
};
|
|
755
|
-
if (
|
|
756
|
-
if (
|
|
757
|
-
if (
|
|
758
|
-
if (contract.allowedDelegationTags !== void 0) subset.allowedDelegationTags = contract.allowedDelegationTags;
|
|
734
|
+
if (delegation.rateAmount !== void 0) subset.rateAmount = delegation.rateAmount;
|
|
735
|
+
if (delegation.rateUnit !== void 0) subset.rateUnit = delegation.rateUnit;
|
|
736
|
+
if (delegation.currency !== void 0) subset.currency = delegation.currency;
|
|
759
737
|
const bytes = canonicalBytes(subset);
|
|
760
738
|
return sha2.sha256(bytes);
|
|
761
739
|
}
|
|
@@ -835,7 +813,6 @@ exports.SETTLEMENT_PURPOSES = SETTLEMENT_PURPOSES;
|
|
|
835
813
|
exports.SLIP44_SOLANA = SLIP44_SOLANA;
|
|
836
814
|
exports.SOLANA_CLUSTER_IDS = SOLANA_CLUSTER_IDS;
|
|
837
815
|
exports.SPL_TOKEN_PROGRAM_ID_BASE58 = SPL_TOKEN_PROGRAM_ID_BASE58;
|
|
838
|
-
exports.TOKEN_2022_PROGRAM_ID_BASE58 = TOKEN_2022_PROGRAM_ID_BASE58;
|
|
839
816
|
exports.USDC_MINTS = USDC_MINTS;
|
|
840
817
|
exports.WELL_KNOWN_ASSETS = WELL_KNOWN_ASSETS;
|
|
841
818
|
exports.WELL_KNOWN_ASSET_KEYS = WELL_KNOWN_ASSET_KEYS;
|
|
@@ -845,14 +822,13 @@ exports.buildCreateLockIxData = buildCreateLockIxData;
|
|
|
845
822
|
exports.buildPartialReleaseDigest = buildPartialReleaseDigest;
|
|
846
823
|
exports.buildRefundDigest = buildRefundDigest;
|
|
847
824
|
exports.buildReleaseDigest = buildReleaseDigest;
|
|
848
|
-
exports.buildWebhookSignatureHeader = buildWebhookSignatureHeader;
|
|
849
825
|
exports.bytes16ToDelegationId = bytes16ToDelegationId;
|
|
850
826
|
exports.canonicalBytes = canonicalBytes;
|
|
851
827
|
exports.canonicalJson = canonicalJson;
|
|
852
828
|
exports.canonicalSha256Hex = canonicalSha256Hex;
|
|
853
829
|
exports.computeCreateLockDiscriminator = computeCreateLockDiscriminator;
|
|
854
830
|
exports.delegationIdToBytes16 = delegationIdToBytes16;
|
|
855
|
-
exports.
|
|
831
|
+
exports.deriveDelegationConditionHash = deriveDelegationConditionHash;
|
|
856
832
|
exports.deriveLockId = deriveLockId;
|
|
857
833
|
exports.deriveScryptKey = deriveScryptKey;
|
|
858
834
|
exports.detectTokenProgramFromOwner = detectTokenProgramFromOwner;
|
|
@@ -888,4 +864,3 @@ exports.verifyCosignature = verifyCosignature;
|
|
|
888
864
|
exports.verifyEnvelope = verifyEnvelope;
|
|
889
865
|
exports.verifyKeyLinkAttestation = verifyKeyLinkAttestation;
|
|
890
866
|
exports.verifyKeyRotationAttestation = verifyKeyRotationAttestation;
|
|
891
|
-
exports.verifyWebhookSignatureHeader = verifyWebhookSignatureHeader;
|
package/dist/index.mjs
CHANGED
|
@@ -135,8 +135,6 @@ var Purpose = {
|
|
|
135
135
|
RECEIPT: "ARP-RECEIPT-v1",
|
|
136
136
|
/** Dispute response co-signature payload. */
|
|
137
137
|
DISPUTE_RESPONSE: "ARP-DISPUTE-RESPONSE-v1",
|
|
138
|
-
/** Webhook delivery HMAC signature payload. */
|
|
139
|
-
WEBHOOK: "ARP-WEBHOOK-v1",
|
|
140
138
|
/** Identity ownership challenge proof. */
|
|
141
139
|
CHALLENGE: "ARP-CHALLENGE-v1",
|
|
142
140
|
/** Verifiable Credential issued by the platform. */
|
|
@@ -242,23 +240,6 @@ function verifyChallenge(challengeBytes, signature, identityPubkey) {
|
|
|
242
240
|
if (signature.length !== 64) return false;
|
|
243
241
|
return verify2(signature, buildSigningInput(challengeBytes), identityPubkey);
|
|
244
242
|
}
|
|
245
|
-
function buildWebhookSignatureHeader(input, sharedSecret) {
|
|
246
|
-
const digest = sha256(canonicalBytes(input));
|
|
247
|
-
const mac = hmac(sha256, sharedSecret, digest);
|
|
248
|
-
return `${Purpose.WEBHOOK}=${base64.encode(mac)}`;
|
|
249
|
-
}
|
|
250
|
-
function verifyWebhookSignatureHeader(headerValue, input, sharedSecret) {
|
|
251
|
-
const expected = buildWebhookSignatureHeader(input, sharedSecret);
|
|
252
|
-
return constantTimeEqual(expected, headerValue);
|
|
253
|
-
}
|
|
254
|
-
function constantTimeEqual(a, b) {
|
|
255
|
-
if (a.length !== b.length) return false;
|
|
256
|
-
let diff = 0;
|
|
257
|
-
for (let i = 0; i < a.length; i++) {
|
|
258
|
-
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
259
|
-
}
|
|
260
|
-
return diff === 0;
|
|
261
|
-
}
|
|
262
243
|
|
|
263
244
|
// src/types/identity.ts
|
|
264
245
|
var SCRYPT_PARAMS = {
|
|
@@ -555,16 +536,15 @@ function u16LE(value) {
|
|
|
555
536
|
var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
556
537
|
var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
557
538
|
function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
`detectTokenProgram: unsupported mint owner ${mintAccountOwnerBase58}; ARP escrow supports legacy SPL Token (${SPL_TOKEN_PROGRAM_ID_BASE58}) and Token-2022 (${TOKEN_2022_PROGRAM_ID_BASE58}) only`
|
|
566
|
-
);
|
|
539
|
+
if (mintAccountOwnerBase58 === SPL_TOKEN_PROGRAM_ID_BASE58) {
|
|
540
|
+
return { kind: "legacy", programIdBase58: SPL_TOKEN_PROGRAM_ID_BASE58 };
|
|
541
|
+
}
|
|
542
|
+
if (mintAccountOwnerBase58 === TOKEN_2022_PROGRAM_ID_BASE58) {
|
|
543
|
+
throw new Error(
|
|
544
|
+
`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`
|
|
545
|
+
);
|
|
567
546
|
}
|
|
547
|
+
throw new Error(`detectTokenProgram: unsupported mint owner ${mintAccountOwnerBase58}; ARP escrow supports legacy SPL Token (${SPL_TOKEN_PROGRAM_ID_BASE58}) only`);
|
|
568
548
|
}
|
|
569
549
|
function detectTokenProgramFromOwnerBytes(mintAccountOwnerBytes) {
|
|
570
550
|
if (mintAccountOwnerBytes.length !== 32) {
|
|
@@ -713,24 +693,22 @@ function resolveAsset(input) {
|
|
|
713
693
|
return null;
|
|
714
694
|
}
|
|
715
695
|
var WELL_KNOWN_ASSET_KEYS = Object.keys(WELL_KNOWN_ASSETS);
|
|
716
|
-
function
|
|
717
|
-
const required = ["
|
|
696
|
+
function deriveDelegationConditionHash(delegation) {
|
|
697
|
+
const required = ["delegationId", "scopeSummary", "pricingModel", "settlementModel"];
|
|
718
698
|
for (const field of required) {
|
|
719
|
-
if (
|
|
720
|
-
throw new Error(`
|
|
699
|
+
if (delegation[field] === void 0) {
|
|
700
|
+
throw new Error(`deriveDelegationConditionHash: required field '${String(field)}' is missing from the delegation input`);
|
|
721
701
|
}
|
|
722
702
|
}
|
|
723
703
|
const subset = {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
settlementModel: contract.settlementModel
|
|
704
|
+
delegationId: delegation.delegationId,
|
|
705
|
+
scopeSummary: delegation.scopeSummary,
|
|
706
|
+
pricingModel: delegation.pricingModel,
|
|
707
|
+
settlementModel: delegation.settlementModel
|
|
729
708
|
};
|
|
730
|
-
if (
|
|
731
|
-
if (
|
|
732
|
-
if (
|
|
733
|
-
if (contract.allowedDelegationTags !== void 0) subset.allowedDelegationTags = contract.allowedDelegationTags;
|
|
709
|
+
if (delegation.rateAmount !== void 0) subset.rateAmount = delegation.rateAmount;
|
|
710
|
+
if (delegation.rateUnit !== void 0) subset.rateUnit = delegation.rateUnit;
|
|
711
|
+
if (delegation.currency !== void 0) subset.currency = delegation.currency;
|
|
734
712
|
const bytes = canonicalBytes(subset);
|
|
735
713
|
return sha256(bytes);
|
|
736
714
|
}
|
|
@@ -795,4 +773,4 @@ function computeCreateLockDiscriminator() {
|
|
|
795
773
|
return h.slice(0, 8);
|
|
796
774
|
}
|
|
797
775
|
|
|
798
|
-
export { CAIP19_REGEX, COSIGNATURE_PURPOSES, CREATE_LOCK_DISCRIMINATOR, DECLINE_REASONS, PROTECTED_PURPOSES, PURPOSE_PARTIAL_RELEASE_STRING, PURPOSE_REFUND_STRING, PURPOSE_RELEASE_STRING, Purpose, REFUND_REASON_BYTES, SCRYPT_PARAMS, SETTLEMENT_PURPOSES, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58,
|
|
776
|
+
export { CAIP19_REGEX, COSIGNATURE_PURPOSES, CREATE_LOCK_DISCRIMINATOR, DECLINE_REASONS, PROTECTED_PURPOSES, PURPOSE_PARTIAL_RELEASE_STRING, PURPOSE_REFUND_STRING, PURPOSE_RELEASE_STRING, Purpose, REFUND_REASON_BYTES, SCRYPT_PARAMS, SETTLEMENT_PURPOSES, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, USDC_MINTS, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildPartialReleaseDigest, buildRefundDigest, buildReleaseDigest, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, isAssetIdentifier, isDeclineReason, isValidDid, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signCosignature, signEnvelope, signKeyLinkAttestation, signKeyRotationAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyCosignature, verifyEnvelope, verifyKeyLinkAttestation, verifyKeyRotationAttestation };
|
package/dist/purpose.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* "this byte string was signed" assertion is not enough; the bytes
|
|
8
8
|
* themselves carry the role).
|
|
9
9
|
*
|
|
10
|
-
* Adding a new purpose
|
|
11
|
-
* [00-core/protocol.md](../../00-core/protocol.md) in
|
|
10
|
+
* Adding a new purpose means adding an entry here and keeping
|
|
11
|
+
* [00-core/protocol.md](../../00-core/protocol.md) in sync.
|
|
12
12
|
*/
|
|
13
13
|
export declare const Purpose: {
|
|
14
14
|
/** Default for `protected.purpose` on body messages. */
|
|
@@ -17,8 +17,6 @@ export declare const Purpose: {
|
|
|
17
17
|
readonly RECEIPT: "ARP-RECEIPT-v1";
|
|
18
18
|
/** Dispute response co-signature payload. */
|
|
19
19
|
readonly DISPUTE_RESPONSE: "ARP-DISPUTE-RESPONSE-v1";
|
|
20
|
-
/** Webhook delivery HMAC signature payload. */
|
|
21
|
-
readonly WEBHOOK: "ARP-WEBHOOK-v1";
|
|
22
20
|
/** Identity ownership challenge proof. */
|
|
23
21
|
readonly CHALLENGE: "ARP-CHALLENGE-v1";
|
|
24
22
|
/** Verifiable Credential issued by the platform. */
|
|
@@ -45,7 +43,7 @@ export declare const Purpose: {
|
|
|
45
43
|
export type PurposeValue = (typeof Purpose)[keyof typeof Purpose];
|
|
46
44
|
/**
|
|
47
45
|
* `protected.purpose` accepts a subset — the others are payload-level
|
|
48
|
-
* (co-signature / settlement-signature
|
|
46
|
+
* (co-signature / settlement-signature).
|
|
49
47
|
*/
|
|
50
48
|
export declare const PROTECTED_PURPOSES: readonly PurposeValue[];
|
|
51
49
|
export declare const COSIGNATURE_PURPOSES: readonly PurposeValue[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { buildReleaseDigest, buildPartialReleaseDigest, buildRefundDigest, REFUND_REASON_BYTES, PURPOSE_RELEASE_STRING, PURPOSE_PARTIAL_RELEASE_STRING, PURPOSE_REFUND_STRING, } from './settlement';
|
|
2
2
|
export type { ReleaseDigestInput, PartialReleaseDigestInput, RefundDigestInput, RefundReasonByte } from './settlement';
|
|
3
|
-
export { detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, SPL_TOKEN_PROGRAM_ID_BASE58
|
|
3
|
+
export { detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, SPL_TOKEN_PROGRAM_ID_BASE58 } from './token-program';
|
|
4
4
|
export type { TokenProgramKind, TokenProgramDetection } from './token-program';
|
|
@@ -1,47 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Token
|
|
2
|
+
* Token program detection helpers.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
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
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* account's owner pubkey (in the wire-level AccountInfoSerialised shape
|
|
13
|
-
* used by getAccountInfo RPC's "encoding=base64" + custom layout). For
|
|
14
|
-
* the more common `getAccountInfo` response, callers should pass the
|
|
15
|
-
* `owner` field directly via a 32-byte buffer.
|
|
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.
|
|
16
12
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* contexts.
|
|
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.
|
|
21
16
|
*/
|
|
22
17
|
/**
|
|
23
18
|
* Legacy SPL Token program ID (base58: `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA`).
|
|
24
19
|
*/
|
|
25
20
|
export declare const SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
26
21
|
/**
|
|
27
|
-
* Token
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* Token program kind. Maps to the new contract's `token_program_kind`
|
|
32
|
-
* u8 emitted on `LockCreated` events
|
|
33
|
-
* (`apps/arp-solana-contract/programs/arp-solana-contract/src/events.rs`):
|
|
34
|
-
* 'native' → 0 (mint == `Pubkey::default()`; the program
|
|
35
|
-
* ignores the token_program slot but Anchor
|
|
36
|
-
* still requires SPL Token or Token-2022 in it)
|
|
37
|
-
* 'legacy' → 1 (legacy SPL Token program)
|
|
38
|
-
* 'token-2022' → 2 (Token-2022 program)
|
|
22
|
+
* Token program kind. Maps to the contract's `token_program_kind` u8 on
|
|
23
|
+
* `LockCreated` events: `native` → 0, `legacy` → 1. (The contract also
|
|
24
|
+
* defines `2` for Token-2022, but ARP no longer supports it — such a
|
|
25
|
+
* lock is rejected before it is tracked, so this type never carries it.)
|
|
39
26
|
*
|
|
40
|
-
* `detectTokenProgramFromOwner`
|
|
41
|
-
*
|
|
42
|
-
*
|
|
27
|
+
* `detectTokenProgramFromOwner` resolves the kind for a NON-native mint
|
|
28
|
+
* by looking at its `.owner` field; native locks are detected from the
|
|
29
|
+
* mint slot value, not from this helper.
|
|
43
30
|
*/
|
|
44
|
-
export type TokenProgramKind = 'legacy' | '
|
|
31
|
+
export type TokenProgramKind = 'legacy' | 'native';
|
|
45
32
|
/**
|
|
46
33
|
* Result of `detectTokenProgram`: the program kind + a typed branding for
|
|
47
34
|
* downstream consumers.
|
|
@@ -55,9 +42,9 @@ export interface TokenProgramDetection {
|
|
|
55
42
|
* Detect a mint's token program kind from its OWNER pubkey (the program
|
|
56
43
|
* that owns the mint account in Solana account terms).
|
|
57
44
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
45
|
+
* Returns `legacy` for a legacy SPL Token mint. Throws for a Token-2022
|
|
46
|
+
* mint (unsupported) or any other owner — escrow would otherwise
|
|
47
|
+
* dispatch a CPI to a surface it does not handle.
|
|
61
48
|
*
|
|
62
49
|
* @param mintAccountOwnerBase58 — the mint account's `.owner` field as
|
|
63
50
|
* a base58 string. From `connection.getAccountInfo(mintPubkey)`, this is
|
package/dist/types/body.d.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { Body, Did, Sha256Hex } from './envelope';
|
|
11
11
|
/**
|
|
12
|
-
* Chain-qualified asset identifier carried by `
|
|
13
|
-
*
|
|
12
|
+
* Chain-qualified asset identifier carried by `delegation.currency`
|
|
13
|
+
* (the single asset for both rate + amount). Replaces the V1 string-enum `'USDC'`
|
|
14
14
|
* placeholder — that shape can't disambiguate `USDC on Solana mainnet`
|
|
15
15
|
* from `USDC on Polygon` or `USDC.e bridged on Avalanche` (all the same
|
|
16
16
|
* ticker, different on-chain assets). It also can't represent native
|
|
@@ -28,14 +28,10 @@ import type { Body, Did, Sha256Hex } from './envelope';
|
|
|
28
28
|
* - `symbol` — short human-readable hint for UI ("USDC", "SOL").
|
|
29
29
|
* Not used for any logic — purely display sugar. Optional.
|
|
30
30
|
*
|
|
31
|
-
* Validation invariants (server-enforced
|
|
32
|
-
* contract and `currency` on the delegation):
|
|
31
|
+
* Validation invariants (server-enforced on `delegation.currency`):
|
|
33
32
|
* • `asset_id` ∈ /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}$/
|
|
34
33
|
* • `decimals` ∈ [0, 18]
|
|
35
34
|
* • `symbol` length ∈ [1, 16] if present
|
|
36
|
-
* • For `delegation.currency`: must match the contract's
|
|
37
|
-
* `rate_currency.asset_id` if the contract specifies one
|
|
38
|
-
* (a delegation under a USDC-priced contract can't quote in SOL).
|
|
39
35
|
*/
|
|
40
36
|
export interface AssetIdentifier {
|
|
41
37
|
/** CAIP-19 chain-qualified asset id — e.g. `solana:5eykt.../spl:EPjFWdd5...` */
|
|
@@ -47,9 +43,8 @@ export interface AssetIdentifier {
|
|
|
47
43
|
}
|
|
48
44
|
/**
|
|
49
45
|
* Closed enum of machine-readable decline reasons used across the
|
|
50
|
-
*
|
|
46
|
+
* two decline sites in V1:
|
|
51
47
|
* • `handshake_response.content.decision === 'decline'`
|
|
52
|
-
* • `contract.content.action === 'decline'`
|
|
53
48
|
* • `delegation.content.action === 'decline'`
|
|
54
49
|
*
|
|
55
50
|
* Required on every decline envelope so the counterparty's reactor
|
|
@@ -77,7 +72,7 @@ export declare const DECLINE_REASONS: readonly DeclineReason[];
|
|
|
77
72
|
export declare function isDeclineReason(v: unknown): v is DeclineReason;
|
|
78
73
|
/**
|
|
79
74
|
* `handshake` — first signed exchange between two agents. Establishes
|
|
80
|
-
* relationship;
|
|
75
|
+
* the relationship; carries no terms (those live on the delegation).
|
|
81
76
|
*/
|
|
82
77
|
export interface HandshakeBody extends Body<HandshakeContent> {
|
|
83
78
|
type: 'handshake';
|
|
@@ -110,32 +105,8 @@ export interface HandshakeResponseContent {
|
|
|
110
105
|
[extra: string]: unknown;
|
|
111
106
|
}
|
|
112
107
|
/**
|
|
113
|
-
* `
|
|
114
|
-
* discriminates lifecycle
|
|
115
|
-
*/
|
|
116
|
-
export interface ContractBody extends Body<ContractContent> {
|
|
117
|
-
type: 'contract';
|
|
118
|
-
}
|
|
119
|
-
export interface ContractContent {
|
|
120
|
-
action: 'proposal' | 'counter' | 'sign' | 'decline';
|
|
121
|
-
contract_id: string;
|
|
122
|
-
version: number;
|
|
123
|
-
scope_summary?: string;
|
|
124
|
-
pricing_model?: 'flat' | 'usage_based';
|
|
125
|
-
settlement_model?: 'prepaid' | 'escrow';
|
|
126
|
-
rate_amount?: string;
|
|
127
|
-
rate_currency?: AssetIdentifier;
|
|
128
|
-
rate_unit?: 'task' | 'thread' | 'handoff';
|
|
129
|
-
allowed_delegation_tags?: string[];
|
|
130
|
-
/** Machine-readable reason — REQUIRED when `action === 'decline'`. See `DeclineReason`. */
|
|
131
|
-
reason?: DeclineReason;
|
|
132
|
-
/** Optional free-text elaboration (e.g. "rate floor 0.20 USDC for current model pricing"). */
|
|
133
|
-
reason_detail?: string;
|
|
134
|
-
[extra: string]: unknown;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* `delegation` — concrete task offer or lifecycle action under an
|
|
138
|
-
* active contract. `action` discriminates the lifecycle event.
|
|
108
|
+
* `delegation` — concrete task offer or lifecycle action. `action`
|
|
109
|
+
* discriminates the lifecycle event.
|
|
139
110
|
*/
|
|
140
111
|
export interface DelegationBody extends Body<DelegationContent> {
|
|
141
112
|
type: 'delegation';
|
|
@@ -143,13 +114,17 @@ export interface DelegationBody extends Body<DelegationContent> {
|
|
|
143
114
|
export interface DelegationContent {
|
|
144
115
|
action: 'offer' | 'accept' | 'decline' | 'cancel';
|
|
145
116
|
delegation_id: string;
|
|
146
|
-
contract_id: string;
|
|
147
117
|
title?: string;
|
|
148
118
|
brief?: Record<string, unknown>;
|
|
149
119
|
acceptance_criteria?: string[];
|
|
150
120
|
deadline?: string;
|
|
151
121
|
amount?: string;
|
|
152
122
|
currency?: AssetIdentifier;
|
|
123
|
+
scope_summary?: string;
|
|
124
|
+
pricing_model?: 'flat' | 'usage_based';
|
|
125
|
+
settlement_model?: 'prepaid' | 'escrow';
|
|
126
|
+
rate_amount?: string;
|
|
127
|
+
rate_unit?: 'task' | 'thread' | 'handoff';
|
|
153
128
|
/** Machine-readable reason — REQUIRED when `action === 'decline'`. See `DeclineReason`. */
|
|
154
129
|
reason?: DeclineReason;
|
|
155
130
|
/** Optional free-text elaboration (e.g. "delegation offer missing required brief.goal field"). */
|
|
@@ -210,18 +185,6 @@ export interface ReceiptContent {
|
|
|
210
185
|
notes_hash?: Sha256Hex;
|
|
211
186
|
[extra: string]: unknown;
|
|
212
187
|
}
|
|
213
|
-
/**
|
|
214
|
-
* `memory_delta` — append-only update to a relationship's shared memory.
|
|
215
|
-
*/
|
|
216
|
-
export interface MemoryDeltaBody extends Body<MemoryDeltaContent> {
|
|
217
|
-
type: 'memory_delta';
|
|
218
|
-
}
|
|
219
|
-
export interface MemoryDeltaContent {
|
|
220
|
-
kind: 'intro' | 'handoff' | 'preference' | 'note' | 'decision' | 'continuity';
|
|
221
|
-
scope: 'thread_only' | 'thread_and_pilot';
|
|
222
|
-
content: string;
|
|
223
|
-
supersedes?: string;
|
|
224
|
-
}
|
|
225
188
|
/**
|
|
226
189
|
* `dispute` — challenge against a delegation outcome. `action`
|
|
227
190
|
* discriminates lifecycle events.
|
|
@@ -327,7 +290,7 @@ export interface SettlementSignatureContent {
|
|
|
327
290
|
* Unix seconds — the `expires_at` value the payee bound into the
|
|
328
291
|
* digest. Server re-uses it when reconstructing the digest and
|
|
329
292
|
* cross-checks against `expires_at > now` + `expires_at <=
|
|
330
|
-
* lock.expiry - DISPUTE_BUFFER_SECONDS
|
|
293
|
+
* lock.expiry - DISPUTE_BUFFER_SECONDS`. The payer
|
|
331
294
|
* echoes the SAME value on the cosign envelope's settlement_signatures
|
|
332
295
|
* block so both sides sign the same bytes.
|
|
333
296
|
*/
|
|
@@ -336,7 +299,7 @@ export interface SettlementSignatureContent {
|
|
|
336
299
|
* Base-unit decimal-integer string — required when `purpose ===
|
|
337
300
|
* 'ARP-SOLANA-PARTIAL-RELEASE-v1.5'`, omitted (or undefined) for
|
|
338
301
|
* full RELEASE. The server cross-checks it against
|
|
339
|
-
* `receipt.usage.computed_amount` for usage_based
|
|
302
|
+
* `receipt.usage.computed_amount` for usage_based delegations before
|
|
340
303
|
* verifying the digest (same invariant
|
|
341
304
|
* `ESC_USAGE_COMPUTED_AMOUNT_MISMATCH` already guards on the
|
|
342
305
|
* propose-time receipt body).
|
|
@@ -348,7 +311,7 @@ export interface SettlementSignatureContent {
|
|
|
348
311
|
* Union over every standard body type. Consumers can narrow on
|
|
349
312
|
* `body.type` via discriminated dispatch.
|
|
350
313
|
*/
|
|
351
|
-
export type AnyBody = HandshakeBody | HandshakeResponseBody |
|
|
314
|
+
export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | WorkRequestBody | WorkResponseBody | ReceiptBody | DisputeBody | SettlementSignatureBody;
|
|
352
315
|
/** Receipt co-signature payload — what gets `payload_hash`'d in `attachments.co_signature`. */
|
|
353
316
|
export interface ReceiptCosignPayload {
|
|
354
317
|
purpose: 'ARP-RECEIPT-v1';
|
package/dist/types/envelope.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PurposeValue } from '../purpose';
|
|
|
3
3
|
* Wire-level types per [00-core/protocol.md](../../../00-core/protocol.md)
|
|
4
4
|
* and [00-core/schemas.md](../../../00-core/schemas.md).
|
|
5
5
|
*
|
|
6
|
-
* Body-type-specific shapes (handshake /
|
|
6
|
+
* Body-type-specific shapes (handshake / delegation / receipt
|
|
7
7
|
* / etc.) live alongside their handlers in the consumer code — keeping
|
|
8
8
|
* them out of this file avoids the SDK becoming a kitchen-sink of every
|
|
9
9
|
* message type. A consumer who needs typed bodies can extend `Envelope<T>`
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { Sha256Hex, Ed25519Sig, Did, ProtectedBlock, Body, Attachments, CoSignature, SettlementSignatures, SettlementParty, EscrowLockAttachment, Envelope, PersistedEvent, } from './envelope';
|
|
2
|
-
export type { HandshakeBody, HandshakeContent, HandshakeResponseBody, HandshakeResponseContent,
|
|
2
|
+
export type { HandshakeBody, HandshakeContent, HandshakeResponseBody, HandshakeResponseContent, DelegationBody, DelegationContent, WorkRequestBody, WorkRequestContent, WorkResponseBody, WorkResponseContent, ReceiptBody, ReceiptContent, DisputeBody, DisputeContent, SettlementSignatureBody, SettlementSignatureContent, AnyBody, ReceiptCosignPayload, DisputeResponseCosignPayload, CosignPayload, DeclineReason, AssetIdentifier, } from './body';
|
|
3
3
|
export { DECLINE_REASONS, isDeclineReason } from './body';
|
|
4
4
|
export type { OwnerSigningMethod, KeyLinkPayload, KeyRotationPayload, ScryptPasswordAttestation } from './identity';
|
|
5
5
|
export { SCRYPT_PARAMS } from './identity';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyanon-arp/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "TypeScript SDK for the Agent Relationship Protocol — canonical JSON, Ed25519 envelope sign/verify, did:arp identity, receipt co-signatures, scrypt key attestation, chain-audit helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
package/dist/webhook/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `ARP-WEBHOOK-v1` HMAC over the canonical webhook envelope. Used by
|
|
3
|
-
* the OutboxDeliveryWorker for the `X-ARP-Signature` header.
|
|
4
|
-
*
|
|
5
|
-
* Inputs (per backend's outbox spec):
|
|
6
|
-
* - delivery_id — outbox row id
|
|
7
|
-
* - recipient_did
|
|
8
|
-
* - envelope_message_id — envelope being delivered
|
|
9
|
-
* - server_event_hash — chain head at delivery time
|
|
10
|
-
* - attempt_n — 1-based retry counter
|
|
11
|
-
* - served_at — RFC3339, when this attempt was generated
|
|
12
|
-
*
|
|
13
|
-
* Each retry produces a different MAC because `attempt_n` and
|
|
14
|
-
* `served_at` participate in canonical input — replays of an old
|
|
15
|
-
* header on a fresh attempt fail HMAC verification.
|
|
16
|
-
*/
|
|
17
|
-
export interface WebhookSignableInput {
|
|
18
|
-
delivery_id: string;
|
|
19
|
-
recipient_did: string;
|
|
20
|
-
envelope_message_id: string;
|
|
21
|
-
server_event_hash: string;
|
|
22
|
-
attempt_n: number;
|
|
23
|
-
served_at: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Compute `X-ARP-Signature` value: `<purpose>=<base64(HMAC-SHA256(secret, sha256(canonical_json(input))))>`.
|
|
27
|
-
*
|
|
28
|
-
* Recipients lookup their per-sender shared secret, recompute the
|
|
29
|
-
* HMAC over the same canonical input, and compare against the
|
|
30
|
-
* received header.
|
|
31
|
-
*/
|
|
32
|
-
export declare function buildWebhookSignatureHeader(input: WebhookSignableInput, sharedSecret: Uint8Array): string;
|
|
33
|
-
/**
|
|
34
|
-
* Constant-time compare an inbound `X-ARP-Signature` header against
|
|
35
|
-
* the expected one. Returns `false` on shape mismatch, missing
|
|
36
|
-
* purpose label, or HMAC mismatch — never throws.
|
|
37
|
-
*/
|
|
38
|
-
export declare function verifyWebhookSignatureHeader(headerValue: string, input: WebhookSignableInput, sharedSecret: Uint8Array): boolean;
|