@heyanon-arp/sdk 0.0.26 → 0.0.29

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/index.js CHANGED
@@ -579,6 +579,40 @@ var CliLoginSessionStates = {
579
579
 
580
580
  // src/types/agent.ts
581
581
  var AGENT_TAG_REGEX = /^[a-z0-9][a-z0-9_-]{0,38}[a-z0-9]$|^[a-z0-9]$/;
582
+ var AGENT_NAME_REGEX = /^[a-z0-9_]{3,32}$/;
583
+ function normalizeName(input) {
584
+ return input.trim().replace(/^@+/, "").trim().toLowerCase();
585
+ }
586
+ var RESERVED_NAMES = [
587
+ "admin",
588
+ "administrator",
589
+ "system",
590
+ "root",
591
+ "owner",
592
+ "operator",
593
+ "did",
594
+ "arp",
595
+ "heyarp",
596
+ "heyanon",
597
+ "anon",
598
+ "self",
599
+ "you",
600
+ "null",
601
+ "undefined",
602
+ "none",
603
+ "api",
604
+ "www",
605
+ "support",
606
+ "help",
607
+ "info"
608
+ ];
609
+ var RESERVED_NAME_SET = new Set(RESERVED_NAMES);
610
+ function isReservedName(name) {
611
+ return RESERVED_NAME_SET.has(normalizeName(name));
612
+ }
613
+ function isValidAgentName(name) {
614
+ return AGENT_NAME_REGEX.test(normalizeName(name));
615
+ }
582
616
 
583
617
  // src/assets.ts
584
618
  var SOLANA_CLUSTER_IDS = {
@@ -964,6 +998,7 @@ var CliAuthTokenErrorCodes = {
964
998
  REQUIRED: "AUTH_TOKEN_REQUIRED"
965
999
  };
966
1000
 
1001
+ exports.AGENT_NAME_REGEX = AGENT_NAME_REGEX;
967
1002
  exports.AGENT_TAG_REGEX = AGENT_TAG_REGEX;
968
1003
  exports.ASSET_DECIMALS_MAX = ASSET_DECIMALS_MAX;
969
1004
  exports.ASSET_DECIMALS_MIN = ASSET_DECIMALS_MIN;
@@ -1024,6 +1059,7 @@ exports.Purpose = Purpose;
1024
1059
  exports.READ_MODEL_STATUSES = READ_MODEL_STATUSES;
1025
1060
  exports.RECEIPT_VERDICTS = RECEIPT_VERDICTS;
1026
1061
  exports.RELATIONSHIP_STATE_NAMES = RELATIONSHIP_STATE_NAMES;
1062
+ exports.RESERVED_NAMES = RESERVED_NAMES;
1027
1063
  exports.ReadModelStatuses = ReadModelStatuses;
1028
1064
  exports.ReceiptVerdicts = ReceiptVerdicts;
1029
1065
  exports.RelationshipStates = RelationshipStates;
@@ -1078,11 +1114,14 @@ exports.isPostCommitErrorCode = isPostCommitErrorCode;
1078
1114
  exports.isReadModelStatus = isReadModelStatus;
1079
1115
  exports.isReceiptVerdict = isReceiptVerdict;
1080
1116
  exports.isRelationshipState = isRelationshipState;
1117
+ exports.isReservedName = isReservedName;
1081
1118
  exports.isSha256Hex = isSha256Hex;
1119
+ exports.isValidAgentName = isValidAgentName;
1082
1120
  exports.isValidDid = isValidDid;
1083
1121
  exports.isWhitelistedAssetId = isWhitelistedAssetId;
1084
1122
  exports.isWorkLogState = isWorkLogState;
1085
1123
  exports.listWhitelistedAssets = listWhitelistedAssets;
1124
+ exports.normalizeName = normalizeName;
1086
1125
  exports.parseCaip19SolanaAssetId = parseCaip19SolanaAssetId;
1087
1126
  exports.parseDid = parseDid;
1088
1127
  exports.pollUntil = pollUntil;
package/dist/index.mjs CHANGED
@@ -554,6 +554,40 @@ var CliLoginSessionStates = {
554
554
 
555
555
  // src/types/agent.ts
556
556
  var AGENT_TAG_REGEX = /^[a-z0-9][a-z0-9_-]{0,38}[a-z0-9]$|^[a-z0-9]$/;
557
+ var AGENT_NAME_REGEX = /^[a-z0-9_]{3,32}$/;
558
+ function normalizeName(input) {
559
+ return input.trim().replace(/^@+/, "").trim().toLowerCase();
560
+ }
561
+ var RESERVED_NAMES = [
562
+ "admin",
563
+ "administrator",
564
+ "system",
565
+ "root",
566
+ "owner",
567
+ "operator",
568
+ "did",
569
+ "arp",
570
+ "heyarp",
571
+ "heyanon",
572
+ "anon",
573
+ "self",
574
+ "you",
575
+ "null",
576
+ "undefined",
577
+ "none",
578
+ "api",
579
+ "www",
580
+ "support",
581
+ "help",
582
+ "info"
583
+ ];
584
+ var RESERVED_NAME_SET = new Set(RESERVED_NAMES);
585
+ function isReservedName(name) {
586
+ return RESERVED_NAME_SET.has(normalizeName(name));
587
+ }
588
+ function isValidAgentName(name) {
589
+ return AGENT_NAME_REGEX.test(normalizeName(name));
590
+ }
557
591
 
558
592
  // src/assets.ts
559
593
  var SOLANA_CLUSTER_IDS = {
@@ -939,4 +973,4 @@ var CliAuthTokenErrorCodes = {
939
973
  REQUIRED: "AUTH_TOKEN_REQUIRED"
940
974
  };
941
975
 
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 };
976
+ export { AGENT_NAME_REGEX, AGENT_TAG_REGEX, ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_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, RESERVED_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, isReservedName, isSha256Hex, isValidAgentName, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, normalizeName, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
@@ -79,7 +79,14 @@ export interface AgentPublic {
79
79
  settlementPublicKey: string;
80
80
  /** attestationId of the live KEY-LINK row. */
81
81
  currentAttestationId: string;
82
- name?: string;
82
+ /**
83
+ * Unique, immutable, human-readable handle (the agent's "username").
84
+ * Lowercase `^[a-z0-9_]{3,32}$` ({@link AGENT_NAME_REGEX}). Set once at
85
+ * registration and globally unique, so it resolves 1:1 to the DID and
86
+ * can be used to address the agent instead of its DID. Trust still binds
87
+ * to the DID — the name is convenience.
88
+ */
89
+ name: string;
83
90
  description?: string;
84
91
  /** Capability tags — always present (empty array when none). */
85
92
  tags: string[];
@@ -93,9 +100,10 @@ export interface AgentPublic {
93
100
  * Partial profile-update body for `PATCH /v1/agents/:did`. Omitted
94
101
  * fields stay as-is; `tags` present REPLACES the whole list (send `[]`
95
102
  * to clear); `acceptPrefs` present REPLACES the object (`null` clears).
103
+ * `name` is intentionally NOT here — the agent name is immutable (set
104
+ * once at registration, like the DID).
96
105
  */
97
106
  export interface UpdateAgentBody {
98
- name?: string;
99
107
  description?: string;
100
108
  tags?: string[];
101
109
  acceptPrefs?: AcceptPrefs | null;
@@ -143,6 +151,38 @@ export interface AgentReputation {
143
151
  * before). The catalog filters on the persisted set.
144
152
  */
145
153
  export declare const AGENT_TAG_REGEX: RegExp;
154
+ /**
155
+ * Agent NAME charset — the unique, immutable handle ("username") used to
156
+ * address an agent in place of its DID. Stricter than {@link AGENT_TAG_REGEX}:
157
+ * lowercase alphanumeric + underscore only (no dash), 3–32 chars. Single
158
+ * source of truth for the server `@Matches` + the CLI name→DID resolver.
159
+ * Inputs are canonicalized with {@link normalizeName} before this test.
160
+ */
161
+ export declare const AGENT_NAME_REGEX: RegExp;
162
+ /**
163
+ * Canonicalize a user-supplied name to its stored / looked-up form: trim,
164
+ * drop a leading `@` (the `@` convention isn't used, but tolerate it if a
165
+ * user types it out of habit), then lowercase. The result is what gets
166
+ * uniqueness-checked, persisted, and resolved.
167
+ */
168
+ export declare function normalizeName(input: string): string;
169
+ /**
170
+ * Reserved names that may NOT be registered — protocol / role words whose
171
+ * use as a handle would be confusing or impersonation-prone. Checked
172
+ * (against the normalized form) at registration. Single source of truth for
173
+ * the server's reserved-name gate. Every entry is itself a structurally
174
+ * valid name, so the gate is actually reachable.
175
+ */
176
+ export declare const RESERVED_NAMES: readonly ["admin", "administrator", "system", "root", "owner", "operator", "did", "arp", "heyarp", "heyanon", "anon", "self", "you", "null", "undefined", "none", "api", "www", "support", "help", "info"];
177
+ /** True if `name` (after {@link normalizeName}) is in {@link RESERVED_NAMES}. */
178
+ export declare function isReservedName(name: string): boolean;
179
+ /**
180
+ * Structural-validity guard for an agent name: tests the NORMALIZED form
181
+ * against {@link AGENT_NAME_REGEX} (so `Alice` / `@alice` pass — they
182
+ * normalize to `alice`). Does NOT check reserved-ness or uniqueness; those
183
+ * are {@link isReservedName} and the server's unique index.
184
+ */
185
+ export declare function isValidAgentName(name: string): boolean;
146
186
  /** Response for `POST /v1/agents/challenge` (server DTO `IssueChallengeResponseDto`). */
147
187
  export interface ChallengeResponse {
148
188
  /** UUID — opaque handle passed back in challenge-response + register. */
@@ -170,7 +210,13 @@ export interface RegisterAgentRequest {
170
210
  };
171
211
  scryptKeyB64: string;
172
212
  scryptSaltB64: string;
173
- name?: string;
213
+ /**
214
+ * Unique, immutable handle — lowercase `^[a-z0-9_]{3,32}$`
215
+ * ({@link AGENT_NAME_REGEX}), REQUIRED. The server normalizes it and
216
+ * rejects taken (`AGENT_NAME_TAKEN`) or reserved (`AGENT_NAME_RESERVED`)
217
+ * names at registration.
218
+ */
219
+ name: string;
174
220
  description?: string;
175
221
  /** Capability tags — lowercase alphanumeric + dash/underscore, max 20. */
176
222
  tags?: string[];
@@ -66,7 +66,8 @@ export interface DiscoveryLiveness {
66
66
  export interface DiscoveryResult {
67
67
  id: string;
68
68
  did: string;
69
- name?: string;
69
+ /** Unique immutable handle — always present (every agent has one). */
70
+ name: string;
70
71
  description?: string;
71
72
  tags: string[];
72
73
  acceptPrefs?: AcceptPrefs;
@@ -98,7 +99,8 @@ export interface DiscoverySearchResponse {
98
99
  */
99
100
  export interface DiscoveryProfile {
100
101
  did: string;
101
- name?: string;
102
+ /** Unique immutable handle — always present (every agent has one). */
103
+ name: string;
102
104
  description?: string;
103
105
  tags: string[];
104
106
  acceptPrefs?: AcceptPrefs;
@@ -18,6 +18,6 @@ export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary, CliL
18
18
  export { CLI_LOGIN_SESSION_STORED_STATES, CLI_LOGIN_SESSION_STATES, CliLoginSessionStates, isCliLoginSessionWireState } from './cli-auth';
19
19
  export type { AssetIdentifierWire, DelegationPublic, 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, } from './agent';
21
- export { AGENT_TAG_REGEX } from './agent';
21
+ export { AGENT_TAG_REGEX, AGENT_NAME_REGEX, RESERVED_NAMES, isReservedName, isValidAgentName, normalizeName } from './agent';
22
22
  export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
23
23
  export { SCRYPT_PARAMS, 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.26",
3
+ "version": "0.0.29",
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": [