@heyanon-arp/sdk 0.0.23 → 0.0.25

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.
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Syntactic `did:arp:` shape — prefix + non-empty Bitcoin base58
3
+ * (no 0/O/I/l). A cheap regex gate for class-validator `@Matches` and
4
+ * the like; it does NOT verify the body decodes to a 32-byte pubkey
5
+ * (use {@link isValidDid} / {@link parseDid} for that). Single source
6
+ * of truth so server DTOs stop each hardcoding their own copy.
7
+ */
8
+ export declare const DID_ARP_REGEX: RegExp;
1
9
  /**
2
10
  * Format an Ed25519 identity public key as a `did:arp:<base58btc>` DID.
3
11
  *
@@ -1,2 +1,2 @@
1
- export { formatDid, parseDid, isValidDid } from './format';
1
+ export { formatDid, parseDid, isValidDid, DID_ARP_REGEX } from './format';
2
2
  export type { DidDocument, VerificationMethod } from './document';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Wire error envelope + the specific error-code sets that BOTH the
3
+ * server (emits) and the CLI (branches on to map remediation hints)
4
+ * depend on. Centralised here so a rename can't silently break the
5
+ * CLI's hint mapping. The full ARP error-code catalogue stays open
6
+ * (see `00-core/errors.md`) — only the cross-consumed sets are pinned.
7
+ */
8
+ /** Structured error body the server returns on the wire and the CLI parses. */
9
+ export interface ApiErrorBody {
10
+ code: string;
11
+ message: string;
12
+ details?: unknown;
13
+ }
14
+ /**
15
+ * Pre-materialization rejection codes for a delegation OFFER. The CLI
16
+ * maps each to a tailored remediation hint; the server throws them from
17
+ * the offer-validation gates. Same `as const` array + union +
18
+ * const-object shape as the protocol vocabularies.
19
+ */
20
+ export declare const DELEGATION_OFFER_REJECTION_CODES: readonly ["DELEGATION_ASSET_NOT_ALLOWED", "DELEGATION_PRICING_MISMATCH", "DELEGATION_CAPACITY_EXCEEDED"];
21
+ export type DelegationOfferRejectionCode = (typeof DELEGATION_OFFER_REJECTION_CODES)[number];
22
+ /** Named-member accessor for {@link DelegationOfferRejectionCode}. */
23
+ export declare const DelegationOfferRejectionCodes: {
24
+ readonly ASSET_NOT_ALLOWED: "DELEGATION_ASSET_NOT_ALLOWED";
25
+ readonly PRICING_MISMATCH: "DELEGATION_PRICING_MISMATCH";
26
+ readonly CAPACITY_EXCEEDED: "DELEGATION_CAPACITY_EXCEEDED";
27
+ };
28
+ /**
29
+ * CLI-auth bearer-token error codes. The CLI maps either to a
30
+ * "run heyarp login again" recovery hint; the server throws them from
31
+ * token validation + the registration auth guard.
32
+ */
33
+ export declare const CLI_AUTH_TOKEN_ERROR_CODES: readonly ["AUTH_TOKEN_INVALID", "AUTH_TOKEN_REQUIRED"];
34
+ export type CliAuthTokenErrorCode = (typeof CLI_AUTH_TOKEN_ERROR_CODES)[number];
35
+ /** Named-member accessor for {@link CliAuthTokenErrorCode}. */
36
+ export declare const CliAuthTokenErrorCodes: {
37
+ readonly INVALID: "AUTH_TOKEN_INVALID";
38
+ readonly REQUIRED: "AUTH_TOKEN_REQUIRED";
39
+ };
@@ -1,2 +1,4 @@
1
1
  export { POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, isPostCommitErrorCode } from './post-commit';
2
2
  export type { PostCommitErrorCode } from './post-commit';
3
+ export { DELEGATION_OFFER_REJECTION_CODES, DelegationOfferRejectionCodes, CLI_AUTH_TOKEN_ERROR_CODES, CliAuthTokenErrorCodes } from './codes';
4
+ export type { ApiErrorBody, DelegationOfferRejectionCode, CliAuthTokenErrorCode } from './codes';
package/dist/index.js CHANGED
@@ -78,6 +78,7 @@ function verify2(signature, message, publicKey) {
78
78
  // src/did/format.ts
79
79
  var DID_PREFIX = "did:arp:";
80
80
  var ED25519_PUBKEY_LENGTH = 32;
81
+ var DID_ARP_REGEX = /^did:arp:[1-9A-HJ-NP-Za-km-z]+$/;
81
82
  function formatDid(identityPublicKey) {
82
83
  if (identityPublicKey.length !== ED25519_PUBKEY_LENGTH) {
83
84
  throw new Error(`formatDid: expected ${ED25519_PUBKEY_LENGTH}-byte Ed25519 pubkey, got ${identityPublicKey.length}`);
@@ -563,6 +564,22 @@ var InboxBlockScopes = {
563
564
  DID: "did"
564
565
  };
565
566
 
567
+ // src/types/cli-auth.ts
568
+ var CLI_LOGIN_SESSION_STORED_STATES = ["pending", "confirmed", "consumed"];
569
+ var CLI_LOGIN_SESSION_STATES = ["pending", "confirmed", "consumed", "expired"];
570
+ function isCliLoginSessionWireState(v) {
571
+ return typeof v === "string" && CLI_LOGIN_SESSION_STATES.includes(v);
572
+ }
573
+ var CliLoginSessionStates = {
574
+ PENDING: "pending",
575
+ CONFIRMED: "confirmed",
576
+ CONSUMED: "consumed",
577
+ EXPIRED: "expired"
578
+ };
579
+
580
+ // src/types/agent.ts
581
+ var AGENT_TAG_REGEX = /^[a-z0-9][a-z0-9_-]{0,38}[a-z0-9]$|^[a-z0-9]$/;
582
+
566
583
  // src/assets.ts
567
584
  var SOLANA_CLUSTER_IDS = {
568
585
  "solana-mainnet": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
@@ -934,6 +951,20 @@ function isPostCommitErrorCode(code) {
934
951
  return POST_COMMIT_SET.has(code) || POST_COMMIT_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
935
952
  }
936
953
 
954
+ // src/errors/codes.ts
955
+ var DELEGATION_OFFER_REJECTION_CODES = ["DELEGATION_ASSET_NOT_ALLOWED", "DELEGATION_PRICING_MISMATCH", "DELEGATION_CAPACITY_EXCEEDED"];
956
+ var DelegationOfferRejectionCodes = {
957
+ ASSET_NOT_ALLOWED: "DELEGATION_ASSET_NOT_ALLOWED",
958
+ PRICING_MISMATCH: "DELEGATION_PRICING_MISMATCH",
959
+ CAPACITY_EXCEEDED: "DELEGATION_CAPACITY_EXCEEDED"
960
+ };
961
+ var CLI_AUTH_TOKEN_ERROR_CODES = ["AUTH_TOKEN_INVALID", "AUTH_TOKEN_REQUIRED"];
962
+ var CliAuthTokenErrorCodes = {
963
+ INVALID: "AUTH_TOKEN_INVALID",
964
+ REQUIRED: "AUTH_TOKEN_REQUIRED"
965
+ };
966
+
967
+ exports.AGENT_TAG_REGEX = AGENT_TAG_REGEX;
937
968
  exports.ASSET_DECIMALS_MAX = ASSET_DECIMALS_MAX;
938
969
  exports.ASSET_DECIMALS_MIN = ASSET_DECIMALS_MIN;
939
970
  exports.ASSET_SYMBOL_MAX_LEN = ASSET_SYMBOL_MAX_LEN;
@@ -943,17 +974,25 @@ exports.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = ASSOCIATED_TOKEN_PROGRAM_ID_BASE58;
943
974
  exports.BODY_TYPES = BODY_TYPES;
944
975
  exports.BodyTypes = BodyTypes;
945
976
  exports.CAIP19_REGEX = CAIP19_REGEX;
977
+ exports.CLI_AUTH_TOKEN_ERROR_CODES = CLI_AUTH_TOKEN_ERROR_CODES;
978
+ exports.CLI_LOGIN_SESSION_STATES = CLI_LOGIN_SESSION_STATES;
979
+ exports.CLI_LOGIN_SESSION_STORED_STATES = CLI_LOGIN_SESSION_STORED_STATES;
946
980
  exports.CREATE_LOCK_DISCRIMINATOR = CREATE_LOCK_DISCRIMINATOR;
947
981
  exports.CREATE_LOCK_NATIVE_DISCRIMINATOR = CREATE_LOCK_NATIVE_DISCRIMINATOR;
948
982
  exports.CURRENT_PROTOCOL_VERSION = CURRENT_PROTOCOL_VERSION;
983
+ exports.CliAuthTokenErrorCodes = CliAuthTokenErrorCodes;
984
+ exports.CliLoginSessionStates = CliLoginSessionStates;
949
985
  exports.DECIMAL_AMOUNT_REGEX = DECIMAL_AMOUNT_REGEX;
950
986
  exports.DECLINE_REASONS = DECLINE_REASONS;
951
987
  exports.DELEGATION_ACTIONS = DELEGATION_ACTIONS;
952
988
  exports.DELEGATION_ACTIVE_STATES = DELEGATION_ACTIVE_STATES;
989
+ exports.DELEGATION_OFFER_REJECTION_CODES = DELEGATION_OFFER_REJECTION_CODES;
953
990
  exports.DELEGATION_STATES = DELEGATION_STATES;
954
991
  exports.DEVNET_MINTS = DEVNET_MINTS;
992
+ exports.DID_ARP_REGEX = DID_ARP_REGEX;
955
993
  exports.DISCOVERY_SORTS = DISCOVERY_SORTS;
956
994
  exports.DelegationActions = DelegationActions;
995
+ exports.DelegationOfferRejectionCodes = DelegationOfferRejectionCodes;
957
996
  exports.DelegationStates = DelegationStates;
958
997
  exports.DiscoverySorts = DiscoverySorts;
959
998
  exports.ED25519_SIG_PREFIX = ED25519_SIG_PREFIX;
@@ -1026,6 +1065,7 @@ exports.getPublicKey = getPublicKey2;
1026
1065
  exports.instructionDiscriminator = instructionDiscriminator;
1027
1066
  exports.isAssetIdentifier = isAssetIdentifier;
1028
1067
  exports.isBodyType = isBodyType;
1068
+ exports.isCliLoginSessionWireState = isCliLoginSessionWireState;
1029
1069
  exports.isDecimalAmountString = isDecimalAmountString;
1030
1070
  exports.isDeclineReason = isDeclineReason;
1031
1071
  exports.isDelegationAction = isDelegationAction;
package/dist/index.mjs CHANGED
@@ -53,6 +53,7 @@ function verify2(signature, message, publicKey) {
53
53
  // src/did/format.ts
54
54
  var DID_PREFIX = "did:arp:";
55
55
  var ED25519_PUBKEY_LENGTH = 32;
56
+ var DID_ARP_REGEX = /^did:arp:[1-9A-HJ-NP-Za-km-z]+$/;
56
57
  function formatDid(identityPublicKey) {
57
58
  if (identityPublicKey.length !== ED25519_PUBKEY_LENGTH) {
58
59
  throw new Error(`formatDid: expected ${ED25519_PUBKEY_LENGTH}-byte Ed25519 pubkey, got ${identityPublicKey.length}`);
@@ -538,6 +539,22 @@ var InboxBlockScopes = {
538
539
  DID: "did"
539
540
  };
540
541
 
542
+ // src/types/cli-auth.ts
543
+ var CLI_LOGIN_SESSION_STORED_STATES = ["pending", "confirmed", "consumed"];
544
+ var CLI_LOGIN_SESSION_STATES = ["pending", "confirmed", "consumed", "expired"];
545
+ function isCliLoginSessionWireState(v) {
546
+ return typeof v === "string" && CLI_LOGIN_SESSION_STATES.includes(v);
547
+ }
548
+ var CliLoginSessionStates = {
549
+ PENDING: "pending",
550
+ CONFIRMED: "confirmed",
551
+ CONSUMED: "consumed",
552
+ EXPIRED: "expired"
553
+ };
554
+
555
+ // src/types/agent.ts
556
+ var AGENT_TAG_REGEX = /^[a-z0-9][a-z0-9_-]{0,38}[a-z0-9]$|^[a-z0-9]$/;
557
+
541
558
  // src/assets.ts
542
559
  var SOLANA_CLUSTER_IDS = {
543
560
  "solana-mainnet": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
@@ -909,4 +926,17 @@ function isPostCommitErrorCode(code) {
909
926
  return POST_COMMIT_SET.has(code) || POST_COMMIT_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
910
927
  }
911
928
 
912
- export { ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_STATES, DEVNET_MINTS, DISCOVERY_SORTS, DelegationActions, DelegationStates, DiscoverySorts, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, ESCROW_PROGRAM_ID_BASE58, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, HANDSHAKE_DECISIONS, HandshakeDecisions, INBOX_BLOCK_SCOPES, InboxBlockScopes, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, 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, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, WORK_LOG_STATES, WorkLogStates, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildLifecycleIxData, buildResolveDisputeIxData, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isDiscoverySort, isEscrowReleaseMethod, isHandshakeDecision, isInboxBlockScope, isPostCommitErrorCode, isReadModelStatus, isReceiptVerdict, isRelationshipState, isSha256Hex, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
929
+ // src/errors/codes.ts
930
+ var DELEGATION_OFFER_REJECTION_CODES = ["DELEGATION_ASSET_NOT_ALLOWED", "DELEGATION_PRICING_MISMATCH", "DELEGATION_CAPACITY_EXCEEDED"];
931
+ var DelegationOfferRejectionCodes = {
932
+ ASSET_NOT_ALLOWED: "DELEGATION_ASSET_NOT_ALLOWED",
933
+ PRICING_MISMATCH: "DELEGATION_PRICING_MISMATCH",
934
+ CAPACITY_EXCEEDED: "DELEGATION_CAPACITY_EXCEEDED"
935
+ };
936
+ var CLI_AUTH_TOKEN_ERROR_CODES = ["AUTH_TOKEN_INVALID", "AUTH_TOKEN_REQUIRED"];
937
+ var CliAuthTokenErrorCodes = {
938
+ INVALID: "AUTH_TOKEN_INVALID",
939
+ REQUIRED: "AUTH_TOKEN_REQUIRED"
940
+ };
941
+
942
+ export { AGENT_TAG_REGEX, ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, 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_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, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, WORK_LOG_STATES, WorkLogStates, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildLifecycleIxData, buildResolveDisputeIxData, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isCliLoginSessionWireState, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isDiscoverySort, isEscrowReleaseMethod, isHandshakeDecision, isInboxBlockScope, isPostCommitErrorCode, isReadModelStatus, isReceiptVerdict, isRelationshipState, isSha256Hex, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
@@ -136,3 +136,42 @@ export interface AgentReputation {
136
136
  computed: boolean;
137
137
  lastComputedAt?: string | null;
138
138
  }
139
+ /**
140
+ * Agent capability-tag charset — lowercase alphanumeric + dash +
141
+ * underscore, 1-40 chars. Single source of truth for the server's
142
+ * `@Matches` on register + update (both DTOs hardcoded an identical copy
143
+ * before). The catalog filters on the persisted set.
144
+ */
145
+ export declare const AGENT_TAG_REGEX: RegExp;
146
+ /** Response for `POST /v1/agents/challenge` (server DTO `IssueChallengeResponseDto`). */
147
+ export interface ChallengeResponse {
148
+ /** UUID — opaque handle passed back in challenge-response + register. */
149
+ challengeId: string;
150
+ /** Challenge bytes, base64url-no-pad (32 random bytes). */
151
+ challengeB64: string;
152
+ /** RFC 3339 expiry; after this the challenge is TTL-evicted. */
153
+ expiresAt: string;
154
+ }
155
+ /**
156
+ * Request body for `POST /v1/agents` (registration). The server DTO is
157
+ * `RegisterAgentDto`; `ownerAttestation` mirrors the SDK
158
+ * `ScryptPasswordAttestation<KeyLinkPayload>` wire shape but stays a
159
+ * generic object here — its inner fields are verified by canonical-JSON
160
+ * + HMAC at the server, not structurally.
161
+ */
162
+ export interface RegisterAgentRequest {
163
+ challengeId: string;
164
+ identityPublicKey: string;
165
+ settlementPublicKey: string;
166
+ ownerAttestation: {
167
+ payload: Record<string, unknown>;
168
+ sig: string;
169
+ scrypt_salt_id: string;
170
+ };
171
+ scryptKeyB64: string;
172
+ scryptSaltB64: string;
173
+ name?: string;
174
+ description?: string;
175
+ /** Capability tags — lowercase alphanumeric + dash/underscore, max 20. */
176
+ tags?: string[];
177
+ }
@@ -4,12 +4,36 @@
4
4
  * CLI's response types — both are plain framework-agnostic interfaces
5
5
  * (the server declares them in a service, not a NestJS DTO class), so
6
6
  * this is a pure lift-and-share with no decorator coupling.
7
+ */
8
+ /**
9
+ * `heyarp login` session lifecycle. TWO tiers because the wire vocab is
10
+ * a strict superset of what's persisted:
11
+ *
12
+ * - {@link CLI_LOGIN_SESSION_STORED_STATES} — what the server's Mongo
13
+ * row actually holds (`@Prop enum`): `pending` → `confirmed` →
14
+ * `consumed`.
15
+ * - {@link CLI_LOGIN_SESSION_STATES} — what the `GET …/sessions/:id`
16
+ * endpoint can RETURN. Adds `expired`, which the service COMPUTES on
17
+ * read for a `pending` row past its TTL (and the CLI also derives
18
+ * from a 404). `expired` is never stored.
7
19
  *
8
- * NOT included here: the cli-auth SESSION-STATE union
9
- * ('pending'|'confirmed'|'consumed'|...) the CLI and server disagree
10
- * on the terminal members, so it needs reconciliation before it can be
11
- * centralized.
20
+ * Same `as const` array + union + guard + const-object shape as the
21
+ * protocol vocabularies; the server sources its `@Prop enum` from the
22
+ * stored array and types the read endpoint with the full wire union,
23
+ * and the CLI types its wire response from the full union.
12
24
  */
25
+ export declare const CLI_LOGIN_SESSION_STORED_STATES: readonly ["pending", "confirmed", "consumed"];
26
+ export type CliLoginSessionStoredState = (typeof CLI_LOGIN_SESSION_STORED_STATES)[number];
27
+ export declare const CLI_LOGIN_SESSION_STATES: readonly ["pending", "confirmed", "consumed", "expired"];
28
+ export type CliLoginSessionWireState = (typeof CLI_LOGIN_SESSION_STATES)[number];
29
+ export declare function isCliLoginSessionWireState(v: unknown): v is CliLoginSessionWireState;
30
+ /** Named-member accessor for {@link CliLoginSessionWireState} (vocab-tested). */
31
+ export declare const CliLoginSessionStates: {
32
+ readonly PENDING: "pending";
33
+ readonly CONFIRMED: "confirmed";
34
+ readonly CONSUMED: "consumed";
35
+ readonly EXPIRED: "expired";
36
+ };
13
37
  /** `POST /v1/auth/cli/sessions` → a new login session. */
14
38
  export interface CliSessionCreated {
15
39
  sessionId: string;
@@ -17,6 +17,30 @@ export declare const DiscoverySorts: {
17
17
  readonly RECENT: "recent";
18
18
  readonly CREATED: "created";
19
19
  };
20
+ /**
21
+ * Query for `GET /v1/discovery/search` (server DTO
22
+ * `DiscoverySearchQueryDto`). Every field optional; filters AND-compose.
23
+ * Reputation is a SOFT sort, never a gate.
24
+ */
25
+ export interface DiscoverySearchQuery {
26
+ /** Full-text over name + description. */
27
+ q?: string;
28
+ /** Capability tags — AND-require all. */
29
+ tag?: string[];
30
+ /** Creator wallet (base58) — you must already know it; never echoed back. */
31
+ accountId?: string;
32
+ /** CAIP-19 payment asset; matches explicit listers AND accept-anything agents. */
33
+ accepts?: string;
34
+ /** Only agents seen within the liveness window. */
35
+ online?: boolean;
36
+ /** `reputation` (composite desc, default) | `recent` | `created` (cursor). */
37
+ sort?: DiscoverySort;
38
+ /** Zero-based page index (offset = page × limit) — reputation/recent sorts. */
39
+ page?: number;
40
+ /** Cursor for `sort=created`: the previous page's last row id. */
41
+ after?: string;
42
+ limit?: number;
43
+ }
20
44
  /** Reputation digest carried inline on each discovery row (the soft-sort key). */
21
45
  export interface DiscoveryReputation {
22
46
  composite: number;
@@ -31,3 +31,16 @@ export interface InboxBlock {
31
31
  /** When the block was set (ISO 8601). */
32
32
  blockedAt: string;
33
33
  }
34
+ /**
35
+ * Body for `POST /v1/inbox/blocks` (server DTO `CreateInboxBlockDto`).
36
+ * You always NAME a DID; by default the server resolves its owner and
37
+ * blocks every sibling agent (account scope). The target account id is
38
+ * never returned.
39
+ */
40
+ export interface BlockInboxBody {
41
+ did: string;
42
+ /** Block only this exact DID instead of the whole owner account. */
43
+ didOnly?: boolean;
44
+ /** Optional private note (max 512 chars). Visible only to you. */
45
+ reason?: string;
46
+ }
@@ -10,12 +10,14 @@ export type { WorkLogState } from './work-log';
10
10
  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
- export type { DiscoverySort, DiscoveryReputation, DiscoveryLiveness, DiscoveryResult, DiscoveryPagination, DiscoverySearchResponse, DiscoveryProfile, } from './discovery';
13
+ export type { DiscoverySort, DiscoverySearchQuery, DiscoveryReputation, DiscoveryLiveness, DiscoveryResult, DiscoveryPagination, DiscoverySearchResponse, DiscoveryProfile, } from './discovery';
14
14
  export { DISCOVERY_SORTS, DiscoverySorts, isDiscoverySort } from './discovery';
15
- export type { InboxBlockScope, InboxBlock } from './inbox';
15
+ export type { InboxBlockScope, InboxBlock, BlockInboxBody } from './inbox';
16
16
  export { INBOX_BLOCK_SCOPES, InboxBlockScopes, isInboxBlockScope } from './inbox';
17
- export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary } from './cli-auth';
18
- export type { AssetIdentifierWire, DelegationPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult } from './read-model';
19
- export type { AcceptPrefs, AcceptCurrency, AgentRegisteredResponse, AgentPublic, UpdateAgentBody, ReputationScores, ReputationCounters, AgentReputation, } from './agent';
17
+ export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary, CliLoginSessionStoredState, CliLoginSessionWireState, } from './cli-auth';
18
+ export { CLI_LOGIN_SESSION_STORED_STATES, CLI_LOGIN_SESSION_STATES, CliLoginSessionStates, isCliLoginSessionWireState } from './cli-auth';
19
+ export type { AssetIdentifierWire, DelegationPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult, SenderSequenceResponse, InboxUnblockResult, ListRelationshipsQuery, ListInboxQuery, ListEventsQuery, ListDelegationsQuery, ListWorkLogsQuery, ListReceiptsQuery, } from './read-model';
20
+ export type { AcceptPrefs, AcceptCurrency, AgentRegisteredResponse, AgentPublic, UpdateAgentBody, RegisterAgentRequest, ChallengeResponse, ReputationScores, ReputationCounters, AgentReputation, } from './agent';
21
+ export { AGENT_TAG_REGEX } from './agent';
20
22
  export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
21
23
  export { SCRYPT_PARAMS, OWNER_SIGNING_METHODS } from './identity';
@@ -158,3 +158,62 @@ export interface IngestResult {
158
158
  serverTimestamp: string;
159
159
  relationshipId: string;
160
160
  }
161
+ /** Response for `GET /v1/agents/:did/sender-sequence`. */
162
+ export interface SenderSequenceResponse {
163
+ lastSenderSequence: number;
164
+ }
165
+ /** Response for `DELETE /v1/inbox/blocks` (unblock). */
166
+ export interface InboxUnblockResult {
167
+ removed: boolean;
168
+ }
169
+ /** Query for `GET /v1/agents/:did/relationships`. */
170
+ export interface ListRelationshipsQuery {
171
+ /** Filter by relationship state. Omitted ⇒ all live + closed rows. */
172
+ state?: RelationshipState;
173
+ limit?: number;
174
+ }
175
+ /**
176
+ * Query for `GET /v1/agents/:did/inbox`. Two composite cursors:
177
+ * - `(before, beforeEventId)` walks BACK through history.
178
+ * - `(since, sinceEventId)` walks FORWARD from a watermark (polling).
179
+ * Pair each timestamp with its eventId tiebreaker to avoid skipping
180
+ * events that share a millisecond.
181
+ */
182
+ export interface ListInboxQuery {
183
+ before?: string;
184
+ beforeEventId?: string;
185
+ since?: string;
186
+ sinceEventId?: string;
187
+ limit?: number;
188
+ }
189
+ /** Query for `GET /v1/relationships/:id/events`. */
190
+ export interface ListEventsQuery {
191
+ /** Return events with `relationshipEventIndex >= since` (cursor). */
192
+ since?: number;
193
+ limit?: number;
194
+ /** Server-side read-model-outcome filter (success-only / rejected-only). */
195
+ readModelStatus?: ReadModelStatus;
196
+ }
197
+ /** Query for `GET /v1/relationships/:id/delegations`. */
198
+ export interface ListDelegationsQuery {
199
+ /** Exact-match state filter (NOT a live/terminal classifier). */
200
+ state?: DelegationState;
201
+ /** Opaque per-row cursor — the previous page's last `id`. */
202
+ after?: string;
203
+ limit?: number;
204
+ }
205
+ /** Query for `GET /v1/relationships/:id/work`. */
206
+ export interface ListWorkLogsQuery {
207
+ state?: WorkLogState;
208
+ /** Narrow to work under a specific delegation id. */
209
+ delegationId?: string;
210
+ after?: string;
211
+ limit?: number;
212
+ }
213
+ /** Query for `GET /v1/relationships/:id/receipts`. */
214
+ export interface ListReceiptsQuery {
215
+ /** Narrow to receipts under a specific delegation id. */
216
+ delegationId?: string;
217
+ after?: string;
218
+ limit?: number;
219
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon-arp/sdk",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
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": [