notaryos 2.1.0 → 2.2.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
@@ -1,8 +1,8 @@
1
1
  # NotaryOS SDK for TypeScript
2
2
 
3
- Cryptographic receipts for AI agent actions. Issue, verify, and audit agent behavior with Ed25519 signatures.
3
+ > **v2.2.0** — Cryptographic receipts for AI agent actions.
4
4
 
5
- **Zero dependencies.** Uses native `fetch()` and Web Crypto API. Works in Node 18+, Deno, Bun, and modern browsers.
5
+ Issue, verify, and audit agent behavior with Ed25519 signatures. Zero dependencies uses native `fetch()` and Web Crypto API. Works in Node 18+, Deno, Bun, and modern browsers.
6
6
 
7
7
  ## Install
8
8
 
@@ -10,86 +10,140 @@ Cryptographic receipts for AI agent actions. Issue, verify, and audit agent beha
10
10
  npm install notaryos
11
11
  ```
12
12
 
13
- ## Quick Start
14
-
15
- ### Issue a Receipt (3 lines)
13
+ ## Quick Start — 3 Lines
16
14
 
17
15
  ```typescript
18
16
  import { NotaryClient } from 'notaryos';
19
17
 
20
- const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
21
- const receipt = await notary.issue('data_processing', { key: 'value' });
22
- console.log(receipt.verify_url); // https://api.agenttownsquare.com/v1/notary/r/abc123
18
+ const notary = new NotaryClient(); // works instantly, no signup needed
19
+ const receipt = await notary.seal('data_processing', { key: 'value' });
23
20
  ```
24
21
 
25
- ### Verify a Receipt (no API key needed)
22
+ That's it. No API key needed to start — the SDK uses a free demo key automatically (10 req/min).
23
+ For production, sign up at [notaryos.org](https://notaryos.org) and pass your own key:
26
24
 
27
25
  ```typescript
28
- import { verifyReceipt } from 'notaryos';
29
-
30
- const isValid = await verifyReceipt(receiptJson);
31
- // true
26
+ const notary = new NotaryClient({ apiKey: 'notary_live_xxx' }); // unlimited
32
27
  ```
33
28
 
34
- ### Full Example
29
+ ## What You Get
30
+
31
+ Every receipt includes:
32
+ - **Ed25519 signature** — tamper-evident proof
33
+ - **Merkle chain linking** — ordered history via `previous_receipt_hash`
34
+ - **Receipt hash** — SHA-256 for public lookup
35
+ - **Verify URL** — anyone can verify without an API key
36
+
37
+ ## Examples
38
+
39
+ ### Seal an Action
35
40
 
36
41
  ```typescript
37
42
  import { NotaryClient } from 'notaryos';
38
43
 
39
44
  const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
40
45
 
41
- // Issue a receipt for an agent action
42
- const receipt = await notary.issue('financial.transfer', {
46
+ // Positional arguments (recommended)
47
+ const receipt = await notary.seal('financial.transfer', {
43
48
  from: 'billing-agent',
44
49
  to: 'ledger-agent',
45
50
  amount: 150.00,
46
51
  currency: 'USD',
47
52
  });
48
53
 
49
- // Verify it
54
+ // Object form (also works)
55
+ const receipt2 = await notary.seal({
56
+ actionType: 'financial.transfer',
57
+ payload: { amount: 150.00, currency: 'USD' },
58
+ });
59
+
60
+ console.log(receipt.receipt_id); // receipt_abc123...
61
+ console.log(receipt.receipt_hash); // sha256 hex
62
+ console.log(receipt.signature); // Ed25519 signature
63
+ console.log(receipt.chain_sequence); // position in chain
64
+ ```
65
+
66
+ ### Verify a Receipt
67
+
68
+ ```typescript
69
+ // With API key (full details)
50
70
  const result = await notary.verify(receipt);
51
71
  console.log(result.valid); // true
52
72
  console.log(result.signature_ok); // true
73
+ console.log(result.structure_ok); // true
74
+
75
+ // Without API key (public, returns boolean)
76
+ import { verifyReceipt } from 'notaryos';
77
+ const isValid = await verifyReceipt(receiptJson); // true
78
+ ```
79
+
80
+ ### Compute Hashes (Client-Side)
53
81
 
54
- // Check service health
55
- const status = await notary.status();
56
- console.log(status.status); // "active"
82
+ ```typescript
83
+ import { computeHash } from 'notaryos';
57
84
 
58
- // Get public key for offline verification
59
- const keyInfo = await notary.publicKey();
60
- console.log(keyInfo.public_key_pem);
85
+ const hash = await computeHash({ key: 'value' });
86
+ // Matches server-side SHA-256 computation
61
87
  ```
62
88
 
63
- ## API Reference
89
+ ## Full API Reference
64
90
 
65
91
  ### `NotaryClient`
66
92
 
93
+ ```typescript
94
+ const notary = new NotaryClient({
95
+ apiKey: 'notary_live_xxx', // Required
96
+ baseUrl: 'https://...', // Default: https://api.agenttownsquare.com
97
+ timeout: 30_000, // Default: 30s
98
+ maxRetries: 2, // Default: 2
99
+ });
100
+ ```
101
+
67
102
  | Method | Auth | Description |
68
103
  |--------|------|-------------|
104
+ | `seal(actionType, payload, options?)` | API Key | Issue a signed receipt (alias for `issue`) |
105
+ | `seal({ actionType, payload, ... })` | API Key | Object-form issue |
69
106
  | `issue(actionType, payload, options?)` | API Key | Issue a signed receipt |
70
- | `verify(receipt)` | API Key | Verify a receipt |
71
- | `verifyById(receiptId)` | API Key | Verify by receipt ID |
107
+ | `issue({ actionType, payload, ... })` | API Key | Object-form issue |
108
+ | `verify(receipt)` | API Key | Verify a receipt's signature and integrity |
109
+ | `verifyById(receiptId)` | API Key | Verify by receipt ID (server-side lookup) |
72
110
  | `status()` | API Key | Service health check |
73
- | `publicKey()` | API Key | Get Ed25519 public key |
74
- | `me()` | API Key | Authenticated agent info |
75
-
76
- ### `verifyReceipt(receipt, baseUrl?)`
77
-
78
- Public verification without API key. Returns `boolean`.
111
+ | `publicKey()` | API Key | Get Ed25519 public key for offline verification |
112
+ | `me()` | API Key | Get authenticated agent info (id, tier, scopes) |
79
113
 
80
- ### `computeHash(payload)`
114
+ ### Standalone Functions
81
115
 
82
- SHA-256 hash matching server-side computation. Returns hex string.
116
+ | Function | Auth | Description |
117
+ |----------|------|-------------|
118
+ | `verifyReceipt(receipt, baseUrl?)` | Public | Quick verification, returns `boolean` |
119
+ | `computeHash(payload)` | None | SHA-256 hash matching server computation |
83
120
 
84
- ## Configuration
121
+ ### Types
85
122
 
86
123
  ```typescript
87
- const notary = new NotaryClient({
88
- apiKey: 'notary_live_xxx', // Required
89
- baseUrl: 'https://...', // Default: https://api.agenttownsquare.com
90
- timeout: 30_000, // Default: 30s
91
- maxRetries: 2, // Default: 2
92
- });
124
+ interface Receipt {
125
+ receipt_id: string;
126
+ timestamp: string;
127
+ agent_id: string;
128
+ action_type: string;
129
+ payload_hash: string;
130
+ signature: string;
131
+ signature_type: string;
132
+ key_id: string;
133
+ chain_sequence?: number;
134
+ previous_receipt_hash?: string;
135
+ receipt_hash?: string;
136
+ verify_url?: string;
137
+ }
138
+
139
+ interface VerificationResult {
140
+ valid: boolean;
141
+ signature_ok: boolean;
142
+ structure_ok: boolean;
143
+ chain_ok?: boolean;
144
+ reason: string;
145
+ details: Record<string, unknown>;
146
+ }
93
147
  ```
94
148
 
95
149
  ## Error Handling
@@ -98,30 +152,45 @@ const notary = new NotaryClient({
98
152
  import { NotaryClient, AuthenticationError, RateLimitError, ValidationError } from 'notaryos';
99
153
 
100
154
  try {
101
- const receipt = await notary.issue('action', payload);
155
+ const receipt = await notary.seal('action', { key: 'value' });
102
156
  } catch (err) {
103
157
  if (err instanceof AuthenticationError) {
104
- // Invalid API key
158
+ // Invalid or expired API key (401)
105
159
  } else if (err instanceof RateLimitError) {
106
- // Wait err.retryAfter seconds
160
+ // Too many requests — wait err.retryAfter seconds (429)
107
161
  } else if (err instanceof ValidationError) {
108
- // Check err.details
162
+ // Request validation failed — check err.details (422)
109
163
  }
110
164
  }
111
165
  ```
112
166
 
167
+ ## Works With Any AI Stack
168
+
169
+ NotaryOS is LLM-agnostic. It seals *actions*, not model calls:
170
+
171
+ ```typescript
172
+ // Your custom LLM — any model, any provider
173
+ const result = await myCustomLLM.generate('Analyze this document');
174
+
175
+ // Seal the proof
176
+ const receipt = await notary.seal('llm.inference', {
177
+ model: 'my-custom-llm-v3',
178
+ outputHash: await computeHash(result),
179
+ });
180
+ ```
181
+
113
182
  ## Get an API Key
114
183
 
115
- 1. Sign up at [agenttownsquare.com/notary](https://agenttownsquare.com/notary)
184
+ 1. Sign up at [notaryos.org](https://notaryos.org)
116
185
  2. Generate an API key from the dashboard
117
186
  3. Keys start with `notary_live_` (production) or `notary_test_` (sandbox)
118
187
 
119
188
  ## Links
120
189
 
121
- - [NotaryOS Documentation](https://agenttownsquare.com/notary)
122
- - [API Reference](https://api.agenttownsquare.com/v1/notary/status)
123
- - [Public Verification](https://api.agenttownsquare.com/v1/notary/r/{hash})
190
+ - [NotaryOS Documentation](https://notaryos.org/docs)
191
+ - [API Reference](https://notaryos.org/api-docs)
192
+ - [GitHub](https://github.com/hellothere012/notaryos)
124
193
 
125
194
  ## License
126
195
 
127
- MIT
196
+ BSL 1.1 (Apache 2.0 after 2029-02-25)
package/dist/index.d.mts CHANGED
@@ -4,11 +4,15 @@
4
4
  * Issue, verify, and audit agent behavior with Ed25519 signatures.
5
5
  * Zero dependencies. Uses native fetch() and Web Crypto API.
6
6
  *
7
- * Quick start:
7
+ * Quick start (no signup needed):
8
8
  *
9
9
  * import { NotaryClient } from 'notaryos';
10
+ * const notary = new NotaryClient(); // uses free demo key (10 req/min)
11
+ * const receipt = await notary.seal('my_action', { key: 'value' });
12
+ *
13
+ * Production (unlimited):
14
+ *
10
15
  * const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
11
- * const receipt = await notary.issue('my_action', { key: 'value' });
12
16
  *
13
17
  * Verify without API key:
14
18
  *
@@ -17,11 +21,11 @@
17
21
  *
18
22
  * @packageDocumentation
19
23
  */
20
- declare const SDK_VERSION = "2.1.0";
24
+ declare const SDK_VERSION = "2.2.0";
21
25
  /** Client configuration options. */
22
26
  interface NotaryConfig {
23
- /** Your Notary API key (notary_live_xxx or notary_test_xxx). */
24
- apiKey: string;
27
+ /** Your Notary API key. If omitted, uses the free demo key (10 req/min). */
28
+ apiKey?: string;
25
29
  /** API base URL (default: https://api.agenttownsquare.com). */
26
30
  baseUrl?: string;
27
31
  /** Request timeout in milliseconds (default: 30000). */
@@ -124,17 +128,16 @@ declare class ValidationError extends NotaryError {
124
128
  *
125
129
  * @example
126
130
  * ```typescript
127
- * const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
131
+ * // No signup needed uses free demo key (10 req/min)
132
+ * const notary = new NotaryClient();
133
+ * const receipt = await notary.seal('data_processing', { key: 'value' });
128
134
  *
129
- * // Issue a receipt
130
- * const receipt = await notary.issue('data_processing', { key: 'value' });
135
+ * // Production (unlimited)
136
+ * const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
131
137
  *
132
138
  * // Verify a receipt
133
139
  * const result = await notary.verify(receipt);
134
140
  * console.log(result.valid); // true
135
- *
136
- * // Check service health
137
- * const status = await notary.status();
138
141
  * ```
139
142
  */
140
143
  declare class NotaryClient {
@@ -144,7 +147,8 @@ declare class NotaryClient {
144
147
  private maxRetries;
145
148
  static readonly DEFAULT_BASE_URL = "https://api.agenttownsquare.com";
146
149
  static readonly DEFAULT_TIMEOUT = 30000;
147
- constructor(config: NotaryConfig);
150
+ static readonly DEMO_API_KEY = "notary_test_public_demo_b0821da365e0e8ce";
151
+ constructor(config?: NotaryConfig);
148
152
  private request;
149
153
  private sleep;
150
154
  /**
package/dist/index.d.ts CHANGED
@@ -4,11 +4,15 @@
4
4
  * Issue, verify, and audit agent behavior with Ed25519 signatures.
5
5
  * Zero dependencies. Uses native fetch() and Web Crypto API.
6
6
  *
7
- * Quick start:
7
+ * Quick start (no signup needed):
8
8
  *
9
9
  * import { NotaryClient } from 'notaryos';
10
+ * const notary = new NotaryClient(); // uses free demo key (10 req/min)
11
+ * const receipt = await notary.seal('my_action', { key: 'value' });
12
+ *
13
+ * Production (unlimited):
14
+ *
10
15
  * const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
11
- * const receipt = await notary.issue('my_action', { key: 'value' });
12
16
  *
13
17
  * Verify without API key:
14
18
  *
@@ -17,11 +21,11 @@
17
21
  *
18
22
  * @packageDocumentation
19
23
  */
20
- declare const SDK_VERSION = "2.1.0";
24
+ declare const SDK_VERSION = "2.2.0";
21
25
  /** Client configuration options. */
22
26
  interface NotaryConfig {
23
- /** Your Notary API key (notary_live_xxx or notary_test_xxx). */
24
- apiKey: string;
27
+ /** Your Notary API key. If omitted, uses the free demo key (10 req/min). */
28
+ apiKey?: string;
25
29
  /** API base URL (default: https://api.agenttownsquare.com). */
26
30
  baseUrl?: string;
27
31
  /** Request timeout in milliseconds (default: 30000). */
@@ -124,17 +128,16 @@ declare class ValidationError extends NotaryError {
124
128
  *
125
129
  * @example
126
130
  * ```typescript
127
- * const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
131
+ * // No signup needed uses free demo key (10 req/min)
132
+ * const notary = new NotaryClient();
133
+ * const receipt = await notary.seal('data_processing', { key: 'value' });
128
134
  *
129
- * // Issue a receipt
130
- * const receipt = await notary.issue('data_processing', { key: 'value' });
135
+ * // Production (unlimited)
136
+ * const notary = new NotaryClient({ apiKey: 'notary_live_xxx' });
131
137
  *
132
138
  * // Verify a receipt
133
139
  * const result = await notary.verify(receipt);
134
140
  * console.log(result.valid); // true
135
- *
136
- * // Check service health
137
- * const status = await notary.status();
138
141
  * ```
139
142
  */
140
143
  declare class NotaryClient {
@@ -144,7 +147,8 @@ declare class NotaryClient {
144
147
  private maxRetries;
145
148
  static readonly DEFAULT_BASE_URL = "https://api.agenttownsquare.com";
146
149
  static readonly DEFAULT_TIMEOUT = 30000;
147
- constructor(config: NotaryConfig);
150
+ static readonly DEMO_API_KEY = "notary_test_public_demo_b0821da365e0e8ce";
151
+ constructor(config?: NotaryConfig);
148
152
  private request;
149
153
  private sleep;
150
154
  /**
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ __export(index_exports, {
30
30
  verifyReceipt: () => verifyReceipt
31
31
  });
32
32
  module.exports = __toCommonJS(index_exports);
33
- var SDK_VERSION = "2.1.0";
33
+ var SDK_VERSION = "2.2.0";
34
34
  var NotaryError = class extends Error {
35
35
  constructor(message, code = "", status = 0, details = {}) {
36
36
  super(message);
@@ -60,13 +60,14 @@ var ValidationError = class extends NotaryError {
60
60
  }
61
61
  };
62
62
  var _NotaryClient = class _NotaryClient {
63
- constructor(config) {
63
+ constructor(config = {}) {
64
64
  /** Alias: seal() → issue() for the 3-line integration pattern. */
65
65
  this.seal = this.issue.bind(this);
66
- const { apiKey, baseUrl, timeout, maxRetries } = config;
67
- if (!apiKey || !(apiKey.startsWith("notary_live_") || apiKey.startsWith("notary_test_"))) {
66
+ const { baseUrl, timeout, maxRetries } = config;
67
+ const apiKey = config.apiKey || _NotaryClient.DEMO_API_KEY;
68
+ if (!(apiKey.startsWith("notary_live_") || apiKey.startsWith("notary_test_"))) {
68
69
  throw new AuthenticationError(
69
- "Invalid API key format. Keys must start with notary_live_ or notary_test_"
70
+ "Invalid API key format. Keys must start with notary_live_ or notary_test_.\n\n Quick start (no signup):\n new NotaryClient() // uses free demo key\n\n Production (unlimited):\n Sign up at https://notaryos.org to get your own key.\n"
70
71
  );
71
72
  }
72
73
  this.apiKey = apiKey;
@@ -175,6 +176,9 @@ var _NotaryClient = class _NotaryClient {
175
176
  actionType = actionTypeOrRequest;
176
177
  actionPayload = payload || {};
177
178
  }
179
+ if (!actionType || typeof actionType !== "string") {
180
+ throw new ValidationError("actionType is required and must be a non-empty string");
181
+ }
178
182
  const body = {
179
183
  action_type: actionType,
180
184
  payload: actionPayload
@@ -237,6 +241,7 @@ var _NotaryClient = class _NotaryClient {
237
241
  };
238
242
  _NotaryClient.DEFAULT_BASE_URL = "https://api.agenttownsquare.com";
239
243
  _NotaryClient.DEFAULT_TIMEOUT = 3e4;
244
+ _NotaryClient.DEMO_API_KEY = "notary_test_public_demo_b0821da365e0e8ce";
240
245
  var NotaryClient = _NotaryClient;
241
246
  async function verifyReceipt(receipt, baseUrl = NotaryClient.DEFAULT_BASE_URL) {
242
247
  try {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- var SDK_VERSION = "2.1.0";
2
+ var SDK_VERSION = "2.2.0";
3
3
  var NotaryError = class extends Error {
4
4
  constructor(message, code = "", status = 0, details = {}) {
5
5
  super(message);
@@ -29,13 +29,14 @@ var ValidationError = class extends NotaryError {
29
29
  }
30
30
  };
31
31
  var _NotaryClient = class _NotaryClient {
32
- constructor(config) {
32
+ constructor(config = {}) {
33
33
  /** Alias: seal() → issue() for the 3-line integration pattern. */
34
34
  this.seal = this.issue.bind(this);
35
- const { apiKey, baseUrl, timeout, maxRetries } = config;
36
- if (!apiKey || !(apiKey.startsWith("notary_live_") || apiKey.startsWith("notary_test_"))) {
35
+ const { baseUrl, timeout, maxRetries } = config;
36
+ const apiKey = config.apiKey || _NotaryClient.DEMO_API_KEY;
37
+ if (!(apiKey.startsWith("notary_live_") || apiKey.startsWith("notary_test_"))) {
37
38
  throw new AuthenticationError(
38
- "Invalid API key format. Keys must start with notary_live_ or notary_test_"
39
+ "Invalid API key format. Keys must start with notary_live_ or notary_test_.\n\n Quick start (no signup):\n new NotaryClient() // uses free demo key\n\n Production (unlimited):\n Sign up at https://notaryos.org to get your own key.\n"
39
40
  );
40
41
  }
41
42
  this.apiKey = apiKey;
@@ -144,6 +145,9 @@ var _NotaryClient = class _NotaryClient {
144
145
  actionType = actionTypeOrRequest;
145
146
  actionPayload = payload || {};
146
147
  }
148
+ if (!actionType || typeof actionType !== "string") {
149
+ throw new ValidationError("actionType is required and must be a non-empty string");
150
+ }
147
151
  const body = {
148
152
  action_type: actionType,
149
153
  payload: actionPayload
@@ -206,6 +210,7 @@ var _NotaryClient = class _NotaryClient {
206
210
  };
207
211
  _NotaryClient.DEFAULT_BASE_URL = "https://api.agenttownsquare.com";
208
212
  _NotaryClient.DEFAULT_TIMEOUT = 3e4;
213
+ _NotaryClient.DEMO_API_KEY = "notary_test_public_demo_b0821da365e0e8ce";
209
214
  var NotaryClient = _NotaryClient;
210
215
  async function verifyReceipt(receipt, baseUrl = NotaryClient.DEFAULT_BASE_URL) {
211
216
  try {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "notaryos",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "NotaryOS SDK - Cryptographic receipts for AI agent actions. Issue, verify, and audit agent behavior with Ed25519 signatures.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
+ "types": "./dist/index.d.ts",
10
11
  "import": "./dist/index.mjs",
11
- "require": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
12
+ "require": "./dist/index.js"
13
13
  }
14
14
  },
15
15
  "files": [
@@ -37,18 +37,18 @@
37
37
  "agent-to-agent"
38
38
  ],
39
39
  "author": {
40
- "name": "Agent Town Square",
41
- "email": "hello@agenttownsquare.com",
42
- "url": "https://agenttownsquare.com"
40
+ "name": "NotaryOS",
41
+ "email": "hello@notaryos.org",
42
+ "url": "https://notaryos.org"
43
43
  },
44
- "license": "MIT",
44
+ "license": "BSL-1.1",
45
45
  "repository": {
46
46
  "type": "git",
47
- "url": "https://github.com/agenttownsquare/notaryos-sdk-typescript"
47
+ "url": "https://github.com/hellothere012/notaryos"
48
48
  },
49
- "homepage": "https://agenttownsquare.com/notary",
49
+ "homepage": "https://notaryos.org",
50
50
  "bugs": {
51
- "url": "https://github.com/agenttownsquare/notaryos-sdk-typescript/issues"
51
+ "url": "https://github.com/hellothere012/notaryos/issues"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=18.0.0"