@heyanon-arp/sdk 0.0.37 → 0.0.38
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/attestation/attestation.d.ts +15 -9
- package/dist/attestation/index.d.ts +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -68
- package/dist/index.mjs +29 -64
- package/dist/types/agent.d.ts +3 -6
- package/dist/types/identity.d.ts +15 -21
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/attestation/scrypt-proof.d.ts +0 -28
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Ed25519KeyLinkAttestation, KeyLinkPayload } from '../types/identity';
|
|
2
2
|
/**
|
|
3
|
-
* Build an `ARP-KEY-LINK-v1` attestation
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Build an `ARP-KEY-LINK-v1` attestation signed via `ed25519_owner_key`:
|
|
4
|
+
* the agent's IDENTITY key signs `canonicalBytes(payload)`. The identity
|
|
5
|
+
* key is already proven at registration (the ARP-CHALLENGE-v1 step), so
|
|
6
|
+
* the key-link is self-certified with NO owner password / shared secret.
|
|
7
7
|
*
|
|
8
8
|
* Identity keys are immutable in alpha (no rotation); the KEY-LINK
|
|
9
9
|
* attestation is the single owner-signed link between identity and
|
|
@@ -11,7 +11,13 @@ import type { KeyLinkPayload, ScryptPasswordAttestation } from '../types/identit
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function signKeyLinkAttestation(input: {
|
|
13
13
|
payload: KeyLinkPayload;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
identitySecretKey: Uint8Array;
|
|
15
|
+
}): Ed25519KeyLinkAttestation<KeyLinkPayload>;
|
|
16
|
+
/**
|
|
17
|
+
* Verify a key-link attestation against the identity key EMBEDDED in its
|
|
18
|
+
* payload (`payload.identity_public_key`). The caller is responsible for
|
|
19
|
+
* cross-checking that key against the agent DID / request body — this
|
|
20
|
+
* function only proves the payload was signed by the identity key it
|
|
21
|
+
* names. Returns false on any malformed input (no throw).
|
|
22
|
+
*/
|
|
23
|
+
export declare function verifyKeyLinkAttestation(attestation: Ed25519KeyLinkAttestation<KeyLinkPayload>): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - did — `did:arp:<...>` parse/format + DID document types
|
|
9
9
|
* - envelope — sign / verify envelope (steps 4-6 of protocol verification)
|
|
10
10
|
* - challenge — ARP-CHALLENGE-v1 ownership proof (registration)
|
|
11
|
-
* - attestation —
|
|
11
|
+
* - attestation — ed25519 key-link owner attestation
|
|
12
12
|
* - server-chain — signed_message_hash, server_event_hash, audit walker
|
|
13
13
|
* - settlement — canonical Solana program-id base58 constants
|
|
14
14
|
* - purpose — domain separators (`ARP-*-v1`)
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,6 @@ var utils = require('@noble/hashes/utils');
|
|
|
5
5
|
var canonicalize = require('canonicalize');
|
|
6
6
|
var base = require('@scure/base');
|
|
7
7
|
var ed = require('@noble/ed25519');
|
|
8
|
-
var hmac = require('@noble/hashes/hmac');
|
|
9
|
-
var scrypt = require('@noble/hashes/scrypt');
|
|
10
8
|
var web3_js = require('@solana/web3.js');
|
|
11
9
|
|
|
12
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -189,73 +187,37 @@ function verifyChallenge(challengeBytes, signature, identityPubkey) {
|
|
|
189
187
|
if (signature.length !== 64) return false;
|
|
190
188
|
return verify2(signature, buildSigningInput(challengeBytes), identityPubkey);
|
|
191
189
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
N: 32768,
|
|
197
|
-
r: 8,
|
|
198
|
-
p: 1,
|
|
199
|
-
dkLen: 32
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
// src/attestation/scrypt-proof.ts
|
|
203
|
-
function deriveScryptKey(password, salt) {
|
|
204
|
-
if (salt.length !== 16) {
|
|
205
|
-
throw new Error(`deriveScryptKey: expected 16-byte salt, got ${salt.length}`);
|
|
190
|
+
var ED25519_SIG_PREFIX = "ed25519:";
|
|
191
|
+
function signKeyLinkAttestation(input) {
|
|
192
|
+
if (input.payload.purpose !== "ARP-KEY-LINK-v1") {
|
|
193
|
+
throw new Error(`signKeyLinkAttestation: expected purpose ARP-KEY-LINK-v1, got ${input.payload.purpose}`);
|
|
206
194
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
N: SCRYPT_PARAMS.N,
|
|
210
|
-
r: SCRYPT_PARAMS.r,
|
|
211
|
-
p: SCRYPT_PARAMS.p,
|
|
212
|
-
dkLen: SCRYPT_PARAMS.dkLen
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
function scryptPasswordProofSign(payload, scryptKey) {
|
|
216
|
-
if (scryptKey.length !== SCRYPT_PARAMS.dkLen) {
|
|
217
|
-
throw new Error(`scryptPasswordProofSign: expected ${SCRYPT_PARAMS.dkLen}-byte scrypt key, got ${scryptKey.length}`);
|
|
195
|
+
if (input.payload.owner_signing_method !== "ed25519_owner_key") {
|
|
196
|
+
throw new Error(`signKeyLinkAttestation: this helper handles ed25519_owner_key only; got ${input.payload.owner_signing_method}`);
|
|
218
197
|
}
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (
|
|
225
|
-
|
|
198
|
+
const sig = sign2(canonicalBytes(input.payload), input.identitySecretKey);
|
|
199
|
+
return { payload: input.payload, sig: `${ED25519_SIG_PREFIX}${base.base64.encode(sig)}` };
|
|
200
|
+
}
|
|
201
|
+
function verifyKeyLinkAttestation(attestation) {
|
|
202
|
+
const { payload, sig } = attestation;
|
|
203
|
+
if (payload.purpose !== "ARP-KEY-LINK-v1") return false;
|
|
204
|
+
if (payload.owner_signing_method !== "ed25519_owner_key") return false;
|
|
205
|
+
if (typeof sig !== "string" || !sig.startsWith(ED25519_SIG_PREFIX)) return false;
|
|
206
|
+
let sigBytes;
|
|
226
207
|
try {
|
|
227
|
-
|
|
208
|
+
sigBytes = base.base64.decode(sig.slice(ED25519_SIG_PREFIX.length));
|
|
228
209
|
} catch {
|
|
229
210
|
return false;
|
|
230
211
|
}
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (a.length !== b.length) return false;
|
|
238
|
-
let diff = 0;
|
|
239
|
-
for (let i = 0; i < a.length; i++) {
|
|
240
|
-
diff |= a[i] ^ b[i];
|
|
241
|
-
}
|
|
242
|
-
return diff === 0;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// src/attestation/attestation.ts
|
|
246
|
-
function signKeyLinkAttestation(input) {
|
|
247
|
-
if (input.payload.purpose !== "ARP-KEY-LINK-v1") {
|
|
248
|
-
throw new Error(`signKeyLinkAttestation: expected purpose ARP-KEY-LINK-v1, got ${input.payload.purpose}`);
|
|
249
|
-
}
|
|
250
|
-
if (input.payload.owner_signing_method !== "scrypt_password_proof") {
|
|
251
|
-
throw new Error(`signKeyLinkAttestation: this helper handles scrypt_password_proof only; got ${input.payload.owner_signing_method}`);
|
|
212
|
+
if (sigBytes.length !== 64) return false;
|
|
213
|
+
let identityPubkey;
|
|
214
|
+
try {
|
|
215
|
+
identityPubkey = base58btcDecode(payload.identity_public_key);
|
|
216
|
+
} catch {
|
|
217
|
+
return false;
|
|
252
218
|
}
|
|
253
|
-
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
function verifyKeyLinkAttestation(attestation, scryptKey) {
|
|
257
|
-
if (attestation.payload.purpose !== "ARP-KEY-LINK-v1") return false;
|
|
258
|
-
return scryptPasswordProofVerify(attestation.payload, attestation.sig, scryptKey);
|
|
219
|
+
if (identityPubkey.length !== 32) return false;
|
|
220
|
+
return verify2(sigBytes, canonicalBytes(payload), identityPubkey);
|
|
259
221
|
}
|
|
260
222
|
function signedMessageHash(envelope) {
|
|
261
223
|
const input = envelope.attachments === void 0 ? { protected: envelope.protected, body: envelope.body } : { protected: envelope.protected, body: envelope.body, attachments: envelope.attachments };
|
|
@@ -380,7 +342,7 @@ var SHA256_HEX_RE = /^sha256:[0-9a-f]{64}$/;
|
|
|
380
342
|
function isSha256Hex(v) {
|
|
381
343
|
return typeof v === "string" && SHA256_HEX_RE.test(v);
|
|
382
344
|
}
|
|
383
|
-
var
|
|
345
|
+
var ED25519_SIG_PREFIX2 = "ed25519:";
|
|
384
346
|
var PROTOCOL_VERSIONS = ["arp/0.1"];
|
|
385
347
|
var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
|
|
386
348
|
|
|
@@ -569,6 +531,9 @@ function isReservedName(name) {
|
|
|
569
531
|
function isValidAgentName(name) {
|
|
570
532
|
return AGENT_NAME_REGEX.test(normalizeName(name));
|
|
571
533
|
}
|
|
534
|
+
|
|
535
|
+
// src/types/identity.ts
|
|
536
|
+
var OWNER_SIGNING_METHODS = ["ed25519_owner_key", "totp+passphrase"];
|
|
572
537
|
var LOCK_ACCOUNT_SIZE = 269;
|
|
573
538
|
var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
|
|
574
539
|
var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
@@ -1257,7 +1222,7 @@ exports.DelegationActions = DelegationActions;
|
|
|
1257
1222
|
exports.DelegationOfferRejectionCodes = DelegationOfferRejectionCodes;
|
|
1258
1223
|
exports.DelegationStates = DelegationStates;
|
|
1259
1224
|
exports.DiscoverySorts = DiscoverySorts;
|
|
1260
|
-
exports.ED25519_SIG_PREFIX =
|
|
1225
|
+
exports.ED25519_SIG_PREFIX = ED25519_SIG_PREFIX2;
|
|
1261
1226
|
exports.ESCROW_PDA_SEEDS = ESCROW_PDA_SEEDS;
|
|
1262
1227
|
exports.ESCROW_PROGRAM_ID_BASE58 = ESCROW_PROGRAM_ID_BASE58;
|
|
1263
1228
|
exports.ESCROW_RELEASE_METHODS = ESCROW_RELEASE_METHODS;
|
|
@@ -1291,7 +1256,6 @@ exports.RESERVED_NAMES = RESERVED_NAMES;
|
|
|
1291
1256
|
exports.ReadModelStatuses = ReadModelStatuses;
|
|
1292
1257
|
exports.ReceiptVerdicts = ReceiptVerdicts;
|
|
1293
1258
|
exports.RelationshipStates = RelationshipStates;
|
|
1294
|
-
exports.SCRYPT_PARAMS = SCRYPT_PARAMS;
|
|
1295
1259
|
exports.SHA256_HEX_RE = SHA256_HEX_RE;
|
|
1296
1260
|
exports.SLIP44_SOLANA = SLIP44_SOLANA;
|
|
1297
1261
|
exports.SOLANA_CLUSTER_IDS = SOLANA_CLUSTER_IDS;
|
|
@@ -1333,7 +1297,6 @@ exports.deriveEventAuthorityPda = deriveEventAuthorityPda;
|
|
|
1333
1297
|
exports.deriveLockId = deriveLockId;
|
|
1334
1298
|
exports.deriveLockPda = deriveLockPda;
|
|
1335
1299
|
exports.deriveOperatorAuthPda = deriveOperatorAuthPda;
|
|
1336
|
-
exports.deriveScryptKey = deriveScryptKey;
|
|
1337
1300
|
exports.deriveStakeVaultPda = deriveStakeVaultPda;
|
|
1338
1301
|
exports.expiresAt = expiresAt;
|
|
1339
1302
|
exports.fetchLockAccount = fetchLockAccount;
|
|
@@ -1370,8 +1333,6 @@ exports.parseDid = parseDid;
|
|
|
1370
1333
|
exports.pollUntil = pollUntil;
|
|
1371
1334
|
exports.resolveAsset = resolveAsset;
|
|
1372
1335
|
exports.rfc3339 = rfc3339;
|
|
1373
|
-
exports.scryptPasswordProofSign = scryptPasswordProofSign;
|
|
1374
|
-
exports.scryptPasswordProofVerify = scryptPasswordProofVerify;
|
|
1375
1336
|
exports.senderNonce = senderNonce;
|
|
1376
1337
|
exports.serverEventHash = serverEventHash;
|
|
1377
1338
|
exports.sign = sign2;
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,6 @@ import { bytesToHex, randomBytes } from '@noble/hashes/utils';
|
|
|
3
3
|
import canonicalize from 'canonicalize';
|
|
4
4
|
import { base58, base64, base64urlnopad } from '@scure/base';
|
|
5
5
|
import * as ed from '@noble/ed25519';
|
|
6
|
-
import { hmac } from '@noble/hashes/hmac';
|
|
7
|
-
import { scrypt } from '@noble/hashes/scrypt';
|
|
8
6
|
import { PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
|
|
9
7
|
|
|
10
8
|
// src/canonical/canonicalize.ts
|
|
@@ -164,73 +162,37 @@ function verifyChallenge(challengeBytes, signature, identityPubkey) {
|
|
|
164
162
|
if (signature.length !== 64) return false;
|
|
165
163
|
return verify2(signature, buildSigningInput(challengeBytes), identityPubkey);
|
|
166
164
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
N: 32768,
|
|
172
|
-
r: 8,
|
|
173
|
-
p: 1,
|
|
174
|
-
dkLen: 32
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// src/attestation/scrypt-proof.ts
|
|
178
|
-
function deriveScryptKey(password, salt) {
|
|
179
|
-
if (salt.length !== 16) {
|
|
180
|
-
throw new Error(`deriveScryptKey: expected 16-byte salt, got ${salt.length}`);
|
|
165
|
+
var ED25519_SIG_PREFIX = "ed25519:";
|
|
166
|
+
function signKeyLinkAttestation(input) {
|
|
167
|
+
if (input.payload.purpose !== "ARP-KEY-LINK-v1") {
|
|
168
|
+
throw new Error(`signKeyLinkAttestation: expected purpose ARP-KEY-LINK-v1, got ${input.payload.purpose}`);
|
|
181
169
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
N: SCRYPT_PARAMS.N,
|
|
185
|
-
r: SCRYPT_PARAMS.r,
|
|
186
|
-
p: SCRYPT_PARAMS.p,
|
|
187
|
-
dkLen: SCRYPT_PARAMS.dkLen
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
function scryptPasswordProofSign(payload, scryptKey) {
|
|
191
|
-
if (scryptKey.length !== SCRYPT_PARAMS.dkLen) {
|
|
192
|
-
throw new Error(`scryptPasswordProofSign: expected ${SCRYPT_PARAMS.dkLen}-byte scrypt key, got ${scryptKey.length}`);
|
|
170
|
+
if (input.payload.owner_signing_method !== "ed25519_owner_key") {
|
|
171
|
+
throw new Error(`signKeyLinkAttestation: this helper handles ed25519_owner_key only; got ${input.payload.owner_signing_method}`);
|
|
193
172
|
}
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (
|
|
200
|
-
|
|
173
|
+
const sig = sign2(canonicalBytes(input.payload), input.identitySecretKey);
|
|
174
|
+
return { payload: input.payload, sig: `${ED25519_SIG_PREFIX}${base64.encode(sig)}` };
|
|
175
|
+
}
|
|
176
|
+
function verifyKeyLinkAttestation(attestation) {
|
|
177
|
+
const { payload, sig } = attestation;
|
|
178
|
+
if (payload.purpose !== "ARP-KEY-LINK-v1") return false;
|
|
179
|
+
if (payload.owner_signing_method !== "ed25519_owner_key") return false;
|
|
180
|
+
if (typeof sig !== "string" || !sig.startsWith(ED25519_SIG_PREFIX)) return false;
|
|
181
|
+
let sigBytes;
|
|
201
182
|
try {
|
|
202
|
-
|
|
183
|
+
sigBytes = base64.decode(sig.slice(ED25519_SIG_PREFIX.length));
|
|
203
184
|
} catch {
|
|
204
185
|
return false;
|
|
205
186
|
}
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (a.length !== b.length) return false;
|
|
213
|
-
let diff = 0;
|
|
214
|
-
for (let i = 0; i < a.length; i++) {
|
|
215
|
-
diff |= a[i] ^ b[i];
|
|
216
|
-
}
|
|
217
|
-
return diff === 0;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/attestation/attestation.ts
|
|
221
|
-
function signKeyLinkAttestation(input) {
|
|
222
|
-
if (input.payload.purpose !== "ARP-KEY-LINK-v1") {
|
|
223
|
-
throw new Error(`signKeyLinkAttestation: expected purpose ARP-KEY-LINK-v1, got ${input.payload.purpose}`);
|
|
224
|
-
}
|
|
225
|
-
if (input.payload.owner_signing_method !== "scrypt_password_proof") {
|
|
226
|
-
throw new Error(`signKeyLinkAttestation: this helper handles scrypt_password_proof only; got ${input.payload.owner_signing_method}`);
|
|
187
|
+
if (sigBytes.length !== 64) return false;
|
|
188
|
+
let identityPubkey;
|
|
189
|
+
try {
|
|
190
|
+
identityPubkey = base58btcDecode(payload.identity_public_key);
|
|
191
|
+
} catch {
|
|
192
|
+
return false;
|
|
227
193
|
}
|
|
228
|
-
|
|
229
|
-
return
|
|
230
|
-
}
|
|
231
|
-
function verifyKeyLinkAttestation(attestation, scryptKey) {
|
|
232
|
-
if (attestation.payload.purpose !== "ARP-KEY-LINK-v1") return false;
|
|
233
|
-
return scryptPasswordProofVerify(attestation.payload, attestation.sig, scryptKey);
|
|
194
|
+
if (identityPubkey.length !== 32) return false;
|
|
195
|
+
return verify2(sigBytes, canonicalBytes(payload), identityPubkey);
|
|
234
196
|
}
|
|
235
197
|
function signedMessageHash(envelope) {
|
|
236
198
|
const input = envelope.attachments === void 0 ? { protected: envelope.protected, body: envelope.body } : { protected: envelope.protected, body: envelope.body, attachments: envelope.attachments };
|
|
@@ -355,7 +317,7 @@ var SHA256_HEX_RE = /^sha256:[0-9a-f]{64}$/;
|
|
|
355
317
|
function isSha256Hex(v) {
|
|
356
318
|
return typeof v === "string" && SHA256_HEX_RE.test(v);
|
|
357
319
|
}
|
|
358
|
-
var
|
|
320
|
+
var ED25519_SIG_PREFIX2 = "ed25519:";
|
|
359
321
|
var PROTOCOL_VERSIONS = ["arp/0.1"];
|
|
360
322
|
var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
|
|
361
323
|
|
|
@@ -544,6 +506,9 @@ function isReservedName(name) {
|
|
|
544
506
|
function isValidAgentName(name) {
|
|
545
507
|
return AGENT_NAME_REGEX.test(normalizeName(name));
|
|
546
508
|
}
|
|
509
|
+
|
|
510
|
+
// src/types/identity.ts
|
|
511
|
+
var OWNER_SIGNING_METHODS = ["ed25519_owner_key", "totp+passphrase"];
|
|
547
512
|
var LOCK_ACCOUNT_SIZE = 269;
|
|
548
513
|
var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
|
|
549
514
|
var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
@@ -1197,4 +1162,4 @@ var CliAuthTokenErrorCodes = {
|
|
|
1197
1162
|
REQUIRED: "AUTH_TOKEN_REQUIRED"
|
|
1198
1163
|
};
|
|
1199
1164
|
|
|
1200
|
-
export { AGENT_BADGES, 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, AgentBadges, 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,
|
|
1165
|
+
export { AGENT_BADGES, 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, AgentBadges, 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_PREFIX2 as 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, 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, deriveStakeVaultPda, expiresAt, fetchLockAccount, findAssetByAssetId, findAssetMetaByMint, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAgentBadge, 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, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -255,9 +255,9 @@ export interface ChallengeResponse {
|
|
|
255
255
|
/**
|
|
256
256
|
* Request body for `POST /v1/agents` (registration). The server DTO is
|
|
257
257
|
* `RegisterAgentDto`; `ownerAttestation` mirrors the SDK
|
|
258
|
-
* `
|
|
259
|
-
* generic object here — its
|
|
260
|
-
*
|
|
258
|
+
* `Ed25519KeyLinkAttestation<KeyLinkPayload>` wire shape but stays a
|
|
259
|
+
* generic object here — its `sig` is verified against the payload's
|
|
260
|
+
* identity key (Ed25519) at the server, not structurally.
|
|
261
261
|
*/
|
|
262
262
|
export interface RegisterAgentRequest {
|
|
263
263
|
challengeId: string;
|
|
@@ -266,10 +266,7 @@ export interface RegisterAgentRequest {
|
|
|
266
266
|
ownerAttestation: {
|
|
267
267
|
payload: Record<string, unknown>;
|
|
268
268
|
sig: string;
|
|
269
|
-
scrypt_salt_id: string;
|
|
270
269
|
};
|
|
271
|
-
scryptKeyB64: string;
|
|
272
|
-
scryptSaltB64: string;
|
|
273
270
|
/**
|
|
274
271
|
* Unique, immutable handle — lowercase `^[a-z0-9_]{3,32}$`
|
|
275
272
|
* ({@link AGENT_NAME_REGEX}), REQUIRED. The server normalizes it and
|
package/dist/types/identity.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Did } from './envelope';
|
|
2
2
|
/**
|
|
3
|
-
* Owner attestation methods
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
3
|
+
* Owner attestation methods. `ed25519_owner_key` is active (index 0):
|
|
4
|
+
* the agent's IDENTITY key self-signs the key-link, so there is NO
|
|
5
|
+
* separate owner password. `totp+passphrase` is a reserved placeholder
|
|
6
|
+
* for forward-compat. Backed by an `as const` array so the server's
|
|
7
|
+
* attestation schema sources the active method from
|
|
8
|
+
* `OWNER_SIGNING_METHODS[0]` instead of re-hardcoding the literal.
|
|
9
9
|
*/
|
|
10
|
-
export declare const OWNER_SIGNING_METHODS: readonly ["
|
|
10
|
+
export declare const OWNER_SIGNING_METHODS: readonly ["ed25519_owner_key", "totp+passphrase"];
|
|
11
11
|
export type OwnerSigningMethod = (typeof OWNER_SIGNING_METHODS)[number];
|
|
12
12
|
/**
|
|
13
|
-
* `ARP-KEY-LINK-v1` payload — the canonical-JSON-hashed object
|
|
13
|
+
* `ARP-KEY-LINK-v1` payload — the canonical-JSON-hashed object the owner
|
|
14
14
|
* signs at registration. Carries the link between identity and settlement
|
|
15
15
|
* keys plus owner identity / method metadata.
|
|
16
16
|
*/
|
|
@@ -25,20 +25,14 @@ export interface KeyLinkPayload {
|
|
|
25
25
|
nonce: string;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* `
|
|
29
|
-
*
|
|
30
|
-
* base64-
|
|
31
|
-
*
|
|
28
|
+
* `ed25519_owner_key` key-link attestation. The `sig` is the agent's
|
|
29
|
+
* IDENTITY Ed25519 key signing `canonicalBytes(payload)`, formatted as
|
|
30
|
+
* `ed25519:<base64(64-byte sig)>` — the same convention as envelope
|
|
31
|
+
* signatures. SELF-VERIFYING: the verifier checks `sig` against the
|
|
32
|
+
* payload's `identity_public_key`; there is no shared secret and no
|
|
33
|
+
* password (the identity key is already challenge-proven at register).
|
|
32
34
|
*/
|
|
33
|
-
export interface
|
|
35
|
+
export interface Ed25519KeyLinkAttestation<TPayload extends KeyLinkPayload = KeyLinkPayload> {
|
|
34
36
|
payload: TPayload;
|
|
35
37
|
sig: string;
|
|
36
|
-
scrypt_salt_id: string;
|
|
37
38
|
}
|
|
38
|
-
/** Standard scrypt parameters used for owner password proofs. */
|
|
39
|
-
export declare const SCRYPT_PARAMS: {
|
|
40
|
-
readonly N: 32768;
|
|
41
|
-
readonly r: 8;
|
|
42
|
-
readonly p: 1;
|
|
43
|
-
readonly dkLen: 32;
|
|
44
|
-
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export { CLI_LOGIN_SESSION_STORED_STATES, CLI_LOGIN_SESSION_STATES, CliLoginSess
|
|
|
19
19
|
export type { AssetIdentifierWire, DelegationPublic, DisputeResolutionPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult, SenderSequenceResponse, InboxUnblockResult, ListRelationshipsQuery, ListInboxQuery, ListEventsQuery, ListDelegationsQuery, ListWorkLogsQuery, ListReceiptsQuery, } from './read-model';
|
|
20
20
|
export type { AcceptPrefs, AcceptCurrency, AgentRegisteredResponse, AgentPublic, UpdateAgentBody, RegisterAgentRequest, ChallengeResponse, ReputationScores, ReputationCounters, AgentReputation, AssetVolume, AgentSettlementVolume, AgentStatsRates, AgentStats, } from './agent';
|
|
21
21
|
export { AGENT_TAG_REGEX, AGENT_NAME_REGEX, RESERVED_NAMES, isReservedName, isValidAgentName, normalizeName } from './agent';
|
|
22
|
-
export type { OwnerSigningMethod, KeyLinkPayload,
|
|
23
|
-
export {
|
|
22
|
+
export type { OwnerSigningMethod, KeyLinkPayload, Ed25519KeyLinkAttestation } from './identity';
|
|
23
|
+
export { OWNER_SIGNING_METHODS } 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.38",
|
|
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,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Derive the scrypt key from an owner's password + salt. Uses the
|
|
3
|
-
* standard parameters: N=32768, r=8, p=1, dkLen=32. Designed to be
|
|
4
|
-
* computed once at owner registration time and stored encrypted-at-rest;
|
|
5
|
-
* subsequent attestation verification recomputes the HMAC, not scrypt.
|
|
6
|
-
*
|
|
7
|
-
* Synchronous variant is intentional — keys derive at low frequency
|
|
8
|
-
* (once per owner registration); the worst case is a few hundred ms
|
|
9
|
-
* which is acceptable. Async variants can be layered on top by the
|
|
10
|
-
* consumer if needed.
|
|
11
|
-
*/
|
|
12
|
-
export declare function deriveScryptKey(password: string, salt: Uint8Array): Uint8Array;
|
|
13
|
-
/**
|
|
14
|
-
* Compute the scrypt-password-proof signature over the canonical
|
|
15
|
-
* payload bytes, returning the base64-encoded MAC.
|
|
16
|
-
*
|
|
17
|
-
* Steps per [00-core/identity.md](../../../00-core/identity.md):
|
|
18
|
-
* 1. payload_digest = sha256(canonical_json(payload))
|
|
19
|
-
* 2. mac = HMAC-SHA256(scrypt_key, payload_digest)
|
|
20
|
-
* 3. sig = base64(mac)
|
|
21
|
-
*/
|
|
22
|
-
export declare function scryptPasswordProofSign(payload: unknown, scryptKey: Uint8Array): string;
|
|
23
|
-
/**
|
|
24
|
-
* Verify a scrypt-password-proof signature. Constant-time compare on
|
|
25
|
-
* MAC bytes — never compares strings directly because base64 decoding
|
|
26
|
-
* normalises some inputs which would mask differences.
|
|
27
|
-
*/
|
|
28
|
-
export declare function scryptPasswordProofVerify(payload: unknown, sigBase64: string, scryptKey: Uint8Array): boolean;
|