@provenonce/sdk 0.14.0 → 0.17.0

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/README.md CHANGED
@@ -25,13 +25,13 @@ console.log(creds.hash); // unique agent identity
25
25
  console.log(creds.api_key); // use this for BeatAgent
26
26
  console.log(creds.secret); // save — shown only once
27
27
 
28
- // Solana self-custody wallet (opt-in)
28
+ // Operator wallet registration (Solana bring your own wallet)
29
29
  const withWallet = await register('my-org', {
30
30
  registryUrl: 'https://provenonce.io',
31
- walletModel: 'self-custody',
31
+ walletModel: 'operator',
32
+ walletAddress: '<your-solana-address>',
33
+ walletSignFn: (msg) => signWithYourWallet(msg),
32
34
  });
33
- // withWallet.wallet.address = Solana address
34
- // withWallet.wallet.secret_key = SAVE — cannot be recovered
35
35
 
36
36
  // Child registration (requires parent credentials)
37
37
  const child = await register('worker-1', {
@@ -63,7 +63,7 @@ const sigil = await agent.purchaseSigil({
63
63
  });
64
64
 
65
65
  // Start heartbeating (paid liveness proofs)
66
- agent.startHeartbeat();
66
+ agent.startHeartbeat(async () => 'your-solana-tx-signature');
67
67
 
68
68
  // Get your Passport (latest lineage proof)
69
69
  const passport = await agent.getPassport();
@@ -71,7 +71,7 @@ console.log(passport?.identity_class); // 'autonomous'
71
71
  console.log(passport?.provenonce_signature); // Ed25519 signed
72
72
 
73
73
  // Verify any proof offline — no API call needed
74
- const valid = BeatAgent.verifyProofLocally(passport, authorityPubKeyHex);
74
+ const valid = BeatAgent.verifyPassportLocally(passport, authorityPubKeyHex);
75
75
 
76
76
  agent.stopHeartbeat();
77
77
  ```
@@ -85,15 +85,16 @@ agent.stopHeartbeat();
85
85
  | `init()` | Initialize the agent's Beat chain (birth in Logical Time) |
86
86
  | `purchaseSigil(opts)` | Purchase a SIGIL identity (required for heartbeating) |
87
87
  | `updateMetadata(fields)` | Update mutable SIGIL metadata fields |
88
- | `heartbeat(paymentTx?, globalAnchor?)` | Submit a paid heartbeat and receive a signed lineage proof |
89
- | `startHeartbeat()` | Start autonomous heartbeat loop |
88
+ | `heartbeat(paymentTx, globalAnchor?)` | Submit a paid heartbeat and receive a signed passport |
89
+ | `startHeartbeat(paymentTxFn)` | Start autonomous heartbeat loop |
90
90
  | `stopHeartbeat()` | Stop heartbeat |
91
- | `getPassport()` | Get latest lineage proof (Passport) |
92
- | `reissueProof(paymentTx?)` | Reissue proof without extending lineage |
91
+ | `getPassport()` | Get latest passport (cached, no network call) |
92
+ | `getLatestPassport()` | Get latest passport (alias for getPassport) |
93
+ | `reissuePassport(paymentTx?)` | Reissue passport without extending lineage |
93
94
  | `requestSpawn(name?)` | Spawn a child agent (requires accumulated beats) |
94
95
  | `getStatus()` | Get full beat status from registry |
95
96
  | `getLocalState()` | Get local state (no network call) |
96
- | `static verifyProofLocally(proof, pubKey)` | Verify a lineage proof offline |
97
+ | `static verifyPassportLocally(proof, pubKey)` | Verify a passport offline |
97
98
 
98
99
  ### `BeatAgentConfig`
99
100
 
@@ -113,7 +114,7 @@ agent.stopHeartbeat();
113
114
  |--------|-------------|
114
115
  | `registryUrl` | Registry URL (required) |
115
116
  | `registrationSecret` | Registration gate (mainnet) |
116
- | `walletModel` | `'self-custody'` or `'operator'` (opt-in wallet) |
117
+ | `walletModel` | `'operator'` (opt-in BYO wallet) |
117
118
  | `walletChain` | `'solana'` or `'ethereum'` |
118
119
  | `walletAddress` | Ethereum BYO address |
119
120
  | `walletSignFn` | Signing function for BYO wallets |
@@ -127,9 +128,9 @@ Returns `RegistrationResult` with `hash`, `api_key`, `secret`, `wallet?`.
127
128
  ### Phase 2 Types
128
129
 
129
130
  ```typescript
130
- import type { Passport, LineageProof, IdentityClass, SigilResult, HeartbeatResult } from '@provenonce/sdk';
131
+ import type { Passport, IdentityClass, SigilResult, HeartbeatResult } from '@provenonce/sdk';
131
132
 
132
- // Passport = LineageProof (type alias)
133
+ // Passport is the primary type. LineageProof is a deprecated alias (sunset 2026-09-01).
133
134
  // Contains: agent_hash, agent_public_key, identity_class, lineage_chain_hash,
134
135
  // provenonce_signature, issued_at, valid_until, etc.
135
136
 
@@ -143,7 +144,7 @@ await agent.purchaseSigil({
143
144
  identity_class: 'narrow_task' | 'autonomous' | 'orchestrator',
144
145
  principal: 'my-agent',
145
146
  tier: 'sov' | 'org' | 'ind' | 'eph' | 'sbx',
146
- payment_tx: 'solana-tx-signature...', // or 'devnet-skip' on devnet
147
+ payment_tx: 'solana-tx-signature...',
147
148
  name: 'optional-display-name'
148
149
  });
149
150
  ```
package/dist/index.d.mts CHANGED
@@ -40,14 +40,16 @@ type SigilProtocol = 'http' | 'grpc' | 'websocket' | 'mcp' | 'a2a' | 'custom';
40
40
  /** Compliance regime */
41
41
  type ComplianceRegime = 'gdpr' | 'pdpa' | 'hipaa' | 'sox' | 'aisi' | 'none' | 'custom';
42
42
  /**
43
- * Ed25519-signed lineage proof — portable, offline-verifiable credential.
44
- * Also known as the agent's "passport" a cryptographic proof of identity
45
- * that can be verified offline without any API call or SOL cost.
43
+ * Ed25519-signed passportthe agent's portable, offline-verifiable credential.
44
+ * A cryptographic proof of identity that can be verified offline without any
45
+ * API call or SOL cost.
46
46
  */
47
- interface LineageProof {
47
+ interface Passport {
48
+ format_version?: number;
48
49
  agent_hash: string;
49
50
  agent_public_key: string | null;
50
- identity_class: IdentityClass;
51
+ authority_key_id?: string;
52
+ identity_class: IdentityClass | null;
51
53
  registered_at_beat: number;
52
54
  sigil_issued_at_beat: number | null;
53
55
  last_heartbeat_beat: number;
@@ -56,8 +58,38 @@ interface LineageProof {
56
58
  valid_until: number;
57
59
  provenonce_signature: string;
58
60
  }
59
- /** Passport = LineageProof. The agent's portable, offline-verifiable credential. */
60
- type Passport = LineageProof;
61
+ /** @deprecated Use `Passport` instead. Sunset 2026-09-01. */
62
+ type LineageProof = Passport;
63
+ /** W3C Verifiable Credential envelope wrapping a LineageProof */
64
+ interface ProvenoncePassportVC {
65
+ '@context': [string, string];
66
+ type: ['VerifiableCredential', 'ProvenoncePassport'];
67
+ issuer: {
68
+ id: string;
69
+ authority_key_id: string;
70
+ };
71
+ issuanceDate: string;
72
+ expirationDate: string;
73
+ credentialSubject: {
74
+ id: string;
75
+ agent_hash: string;
76
+ agent_public_key: string | null;
77
+ identity_class: IdentityClass | null;
78
+ registered_at_beat: number;
79
+ sigil_issued_at_beat: number | null;
80
+ last_heartbeat_beat: number;
81
+ lineage_chain_hash: string;
82
+ };
83
+ proof: {
84
+ type: 'Ed25519Signature2020';
85
+ created: string;
86
+ verificationMethod: string;
87
+ proofPurpose: 'assertionMethod';
88
+ cryptosuite: 'eddsa-provenonce-2026';
89
+ proofValue: string;
90
+ };
91
+ format_version: number;
92
+ }
61
93
  /** Options for purchasing a SIGIL with full namespace */
62
94
  interface SigilPurchaseOptions {
63
95
  identity_class: IdentityClass;
@@ -65,6 +97,9 @@ interface SigilPurchaseOptions {
65
97
  tier: SigilTier;
66
98
  name?: string;
67
99
  payment_tx: string;
100
+ at?: string;
101
+ skill_hash?: string;
102
+ ref?: string;
68
103
  substrate?: Substrate;
69
104
  substrate_provider?: SubstrateProvider;
70
105
  substrate_model?: string;
@@ -77,6 +112,14 @@ interface SigilPurchaseOptions {
77
112
  endpoint?: string;
78
113
  compliance_regime?: ComplianceRegime;
79
114
  }
115
+ /** Result from getSigilAttribution() */
116
+ interface SigilAttributionResult {
117
+ ok: boolean;
118
+ attribution_token?: string;
119
+ signup_url?: string | null;
120
+ already_has_sigil?: boolean;
121
+ error?: string;
122
+ }
80
123
  /** Mutable SIGIL metadata fields for PATCH updates */
81
124
  interface SigilMutableFields {
82
125
  substrate?: Substrate;
@@ -105,7 +148,9 @@ interface SigilResult {
105
148
  birth_tx: string | null;
106
149
  explorer_url: string | null;
107
150
  };
108
- lineage_proof?: LineageProof;
151
+ passport?: Passport;
152
+ /** @deprecated Use `passport` instead. Sunset 2026-09-01. */
153
+ lineage_proof?: Passport;
109
154
  fee?: {
110
155
  amount_sol: number;
111
156
  amount_lamports: number;
@@ -139,7 +184,10 @@ interface VerificationResult {
139
184
  /** Result from a paid heartbeat */
140
185
  interface HeartbeatResult {
141
186
  ok: boolean;
142
- lineage_proof?: LineageProof;
187
+ sigil_required?: boolean;
188
+ passport?: Passport;
189
+ /** @deprecated Use `passport` instead. Sunset 2026-09-01. */
190
+ lineage_proof?: Passport;
143
191
  heartbeat_count_epoch?: number;
144
192
  billing_epoch?: number;
145
193
  current_beat?: number;
@@ -149,6 +197,24 @@ interface HeartbeatResult {
149
197
  tier: number;
150
198
  payment_tx: string | null;
151
199
  };
200
+ sponsor?: {
201
+ parent_hash: string;
202
+ };
203
+ error?: string;
204
+ }
205
+ /** RFC-021: Sponsorship record returned by the /agent/sponsor endpoint. */
206
+ interface SponsorshipRecord {
207
+ parent_hash: string;
208
+ child_hash: string;
209
+ status: 'active' | 'revoked' | 'expired';
210
+ max_heartbeats_epoch: number;
211
+ heartbeats_used_epoch: number;
212
+ expires_at: string | null;
213
+ created_at?: string;
214
+ }
215
+ interface SponsorshipResult {
216
+ ok: boolean;
217
+ sponsorship?: SponsorshipRecord;
152
218
  error?: string;
153
219
  }
154
220
  interface Beat {
@@ -369,6 +435,7 @@ declare class BeatAgent {
369
435
  private heartbeatInterval;
370
436
  private globalBeat;
371
437
  private globalAnchorHash;
438
+ private cachedIdentityClass;
372
439
  constructor(config: BeatAgentConfig);
373
440
  /**
374
441
  * Initialize the agent's Beat chain.
@@ -386,10 +453,9 @@ declare class BeatAgent {
386
453
  * Start the autonomous heartbeat loop.
387
454
  * Phase 2: Sends paid heartbeats at regular intervals.
388
455
  *
389
- * @param paymentTxFn - Optional function that returns a payment tx for each heartbeat.
390
- * If not provided, uses 'devnet-skip' (devnet only).
456
+ * @param paymentTxFn - Function that returns a Solana payment tx signature for each heartbeat (required).
391
457
  */
392
- startHeartbeat(paymentTxFn?: () => Promise<string> | string): void;
458
+ startHeartbeat(paymentTxFn: () => Promise<string> | string): void;
393
459
  /**
394
460
  * Stop the heartbeat loop.
395
461
  */
@@ -450,8 +516,8 @@ declare class BeatAgent {
450
516
  childName?: string;
451
517
  beatsNeeded?: number;
452
518
  }): Promise<SpawnResult>;
453
- /** Cached lineage proof from the most recent heartbeat or SIGIL purchase */
454
- private cachedProof;
519
+ /** Cached passport from the most recent heartbeat or SIGIL purchase */
520
+ private cachedPassport;
455
521
  /**
456
522
  * Purchase a SIGIL (cryptographic identity) for this agent.
457
523
  * SIGILs gate heartbeating, lineage proofs, and offline verification.
@@ -464,6 +530,19 @@ declare class BeatAgent {
464
530
  * @param paymentTx - Solana transaction signature or 'devnet-skip'
465
531
  */
466
532
  purchaseSigil(optionsOrClass: SigilPurchaseOptions | IdentityClass, paymentTx?: string): Promise<SigilResult>;
533
+ /**
534
+ * Get a SIGIL attribution token from a partner skill's ref_token (RFC-018).
535
+ *
536
+ * Call this after receiving a skill's ref_token in its response.
537
+ * Returns a pvr_ attribution token to include as `at` in purchaseSigil().
538
+ *
539
+ * This is the agent-side half of the two-sided witnessed proof:
540
+ * the skill's server already called /sigil/check for this agent hash.
541
+ * This call completes the proof — our server witnesses both sides.
542
+ *
543
+ * @param partnerRef - The skill's 16-char ref_token
544
+ */
545
+ getSigilAttribution(partnerRef: string): Promise<SigilAttributionResult>;
467
546
  /**
468
547
  * Update mutable SIGIL metadata fields.
469
548
  * Requires a SIGIL. Cannot modify immutable fields.
@@ -476,44 +555,102 @@ declare class BeatAgent {
476
555
  * Requires a SIGIL. Returns a signed lineage proof.
477
556
  * This is the Phase 2 replacement for pulse() + checkin().
478
557
  *
479
- * @param paymentTx - Solana transaction signature. Omit or 'devnet-skip' on devnet.
558
+ * @param paymentTx - Solana transaction signature (required).
480
559
  * @param globalAnchor - Optional: the global anchor index to reference.
481
560
  */
482
- heartbeat(paymentTx?: string, globalAnchor?: number): Promise<HeartbeatResult>;
561
+ heartbeat(paymentTx: string, globalAnchor?: number, opts?: {
562
+ sponsoredBy?: string;
563
+ }): Promise<HeartbeatResult>;
483
564
  /**
484
- * Reissue a lineage proof. "Reprint, not a renewal."
565
+ * Reissue a passport. "Reprint, not a renewal."
485
566
  * Does NOT create a new lineage event.
486
567
  *
487
- * @param paymentTx - Solana transaction signature. Omit or 'devnet-skip' on devnet.
568
+ * @param paymentTx - Solana transaction signature (required).
569
+ */
570
+ reissuePassport(paymentTx: string): Promise<{
571
+ ok: boolean;
572
+ passport?: Passport;
573
+ lineage_proof?: Passport;
574
+ error?: string;
575
+ }>;
576
+ /** @deprecated Use `reissuePassport()` instead. Sunset 2026-09-01. */
577
+ reissueProof(paymentTx: string): Promise<{
578
+ ok: boolean;
579
+ passport?: Passport;
580
+ lineage_proof?: Passport;
581
+ error?: string;
582
+ }>;
583
+ /**
584
+ * Sponsor a child agent's heartbeats.
585
+ * The authenticated agent (this instance) becomes the sponsor, paying heartbeat
586
+ * fees on behalf of the specified child from this agent's operator wallet.
587
+ *
588
+ * @param childHash - Hash of the child agent to sponsor
589
+ * @param opts.maxHeartbeatsEpoch - Max heartbeats per billing epoch (default: 100, max: 10,000)
590
+ * @param opts.expiresInHours - Optional TTL for the sponsorship
488
591
  */
489
- reissueProof(paymentTx?: string): Promise<{
592
+ sponsorChild(childHash: string, opts?: {
593
+ maxHeartbeatsEpoch?: number;
594
+ expiresInHours?: number;
595
+ }): Promise<SponsorshipResult>;
596
+ /**
597
+ * Revoke a sponsorship for a child agent.
598
+ * The child will no longer be able to use this agent's wallet for heartbeat payments.
599
+ */
600
+ revokeSponsor(childHash: string): Promise<{
490
601
  ok: boolean;
491
- lineage_proof?: LineageProof;
492
602
  error?: string;
493
603
  }>;
494
604
  /**
495
- * Get the latest cached lineage proof (no network call).
496
- * Returns null if no proof has been obtained yet.
605
+ * List all active sponsorships for this agent (as parent).
497
606
  */
498
- getLatestProof(): LineageProof | null;
607
+ listSponsorships(): Promise<{
608
+ ok: boolean;
609
+ sponsorships?: SponsorshipRecord[];
610
+ error?: string;
611
+ }>;
499
612
  /**
500
- * Get the agent's passport (alias for getLatestProof).
613
+ * Get the latest cached passport (no network call).
614
+ * Returns null if no passport has been obtained yet.
615
+ */
616
+ getLatestPassport(): Passport | null;
617
+ /** @deprecated Use `getLatestPassport()` instead. Sunset 2026-09-01. */
618
+ getLatestProof(): Passport | null;
619
+ /**
620
+ * Get the agent's passport (alias for getLatestPassport).
501
621
  * The passport is the agent's portable, offline-verifiable credential.
502
622
  * Returns null if no passport has been issued yet (requires SIGIL + heartbeat).
503
623
  */
504
624
  getPassport(): Passport | null;
505
625
  /**
506
- * Verify a lineage proof locally using the authority public key.
626
+ * Export this agent's passport in both flat (Passport) and W3C VC envelope formats.
627
+ * Fetches a freshly signed passport from the server. Free endpoint, rate-limited 10/hr.
628
+ * Returns null if the request fails.
629
+ */
630
+ exportPassport(): Promise<{
631
+ passport: Passport;
632
+ passport_vc: ProvenoncePassportVC;
633
+ lineage_proof: Passport;
634
+ } | null>;
635
+ /**
636
+ * Wrap a Passport in a W3C Verifiable Credential envelope (client-side).
637
+ * Does not make any network call. Requires the passport to have authority_key_id.
638
+ */
639
+ static proofToPassportVC(proof: Passport, authorityKeyId?: string): ProvenoncePassportVC;
640
+ /**
641
+ * Verify a passport locally using the authority public key.
507
642
  * Offline verification — no API call, no SOL cost.
508
643
  *
509
644
  * Returns a VerificationResult object. The object is truthy when valid,
510
- * so `if (BeatAgent.verifyProofLocally(proof, key))` still works.
645
+ * so `if (BeatAgent.verifyPassportLocally(proof, key))` still works.
511
646
  *
512
- * @param proof - The LineageProof to verify
647
+ * @param proof - The Passport to verify
513
648
  * @param authorityPubKeyHex - 32-byte hex-encoded Ed25519 public key from /.well-known/provenonce-authority.json
514
649
  * @param currentBeat - Optional current global beat index (for beatsSinceHeartbeat calculation)
515
650
  */
516
- static verifyProofLocally(proof: LineageProof, authorityPubKeyHex: string, currentBeat?: number): VerificationResult;
651
+ static verifyPassportLocally(proof: Passport, authorityPubKeyHex: string, currentBeat?: number): VerificationResult;
652
+ /** @deprecated Use `verifyPassportLocally()` instead. Sunset 2026-09-01. */
653
+ static verifyProofLocally(proof: Passport, authorityPubKeyHex: string, currentBeat?: number): VerificationResult;
517
654
  /**
518
655
  * Get this agent's full beat status from the registry.
519
656
  */
@@ -530,6 +667,12 @@ declare class BeatAgent {
530
667
  globalBeat: number;
531
668
  chainLength: number;
532
669
  };
670
+ /**
671
+ * Returns true if this agent has purchased a SIGIL in this session,
672
+ * or if a cached passport contains an identity_class.
673
+ * For an authoritative check, use GET /api/v1/agent/me.
674
+ */
675
+ hasSigil(): boolean;
533
676
  private syncGlobal;
534
677
  private refreshState;
535
678
  private api;
@@ -569,6 +712,7 @@ declare enum ErrorCode {
569
712
  VALIDATION = "VALIDATION",
570
713
  AUTH_INVALID = "AUTH_INVALID",
571
714
  AUTH_MISSING = "AUTH_MISSING",
715
+ SIGIL_REQUIRED = "SIGIL_REQUIRED",
572
716
  RATE_LIMITED = "RATE_LIMITED",
573
717
  AGENT_FROZEN = "AGENT_FROZEN",
574
718
  AGENT_NOT_INITIALIZED = "AGENT_NOT_INITIALIZED",
@@ -596,6 +740,10 @@ declare class ValidationError extends ProvenonceError {
596
740
  declare class AuthError extends ProvenonceError {
597
741
  constructor(message: string, code?: ErrorCode.AUTH_INVALID | ErrorCode.AUTH_MISSING, statusCode?: number);
598
742
  }
743
+ /** Thrown on 403 SIGIL_REQUIRED — agent has not purchased a SIGIL */
744
+ declare class SigilRequiredError extends ProvenonceError {
745
+ constructor(message?: string);
746
+ }
599
747
  /** Thrown on 429 — rate limit exceeded */
600
748
  declare class RateLimitError extends ProvenonceError {
601
749
  /** Milliseconds until the rate limit resets (if provided by server) */
@@ -625,4 +773,4 @@ declare class ServerError extends ProvenonceError {
625
773
  constructor(message: string, statusCode?: number);
626
774
  }
627
775
 
628
- export { type AgentStatus, AuthError, type Beat, BeatAgent, type BeatAgentConfig, type Capability, type CheckinResult, type ComplianceRegime, ErrorCode, FrozenError, type HeartbeatResult, type IdentityClass, type LineageProof, type MetadataUpdateResult, NetworkError, NotFoundError, type Passport, ProvenonceError, RateLimitError, type RegisterOptions, type RegistrationResult, ServerError, type SigilMutableFields, type SigilProtocol, type SigilPurchaseOptions, type SigilResult, type SigilTier, type SpawnResult, StateError, type Substrate, type SubstrateProvider, ValidationError, type VerificationResult, type WalletInfo, type WorkProofReceipt, type WorkProofResult, computeBeat, computeBeatsLite, register, verifyAnchorHash };
776
+ export { type AgentStatus, AuthError, type Beat, BeatAgent, type BeatAgentConfig, type Capability, type CheckinResult, type ComplianceRegime, ErrorCode, FrozenError, type HeartbeatResult, type IdentityClass, type LineageProof, type MetadataUpdateResult, NetworkError, NotFoundError, type Passport, ProvenonceError, type ProvenoncePassportVC, RateLimitError, type RegisterOptions, type RegistrationResult, ServerError, type SigilAttributionResult, type SigilMutableFields, type SigilProtocol, type SigilPurchaseOptions, SigilRequiredError, type SigilResult, type SigilTier, type SpawnResult, type SponsorshipRecord, type SponsorshipResult, StateError, type Substrate, type SubstrateProvider, ValidationError, type VerificationResult, type WalletInfo, type WorkProofReceipt, type WorkProofResult, computeBeat, computeBeatsLite, register, verifyAnchorHash };