@semiotic-labs/agentium-sdk 0.7.0 → 0.9.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 +35 -24
- package/dist/index.d.ts +16 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -66
- package/dist/index.js.map +1 -1
- package/dist/wasm.d.ts +20 -2
- package/dist/wasm.d.ts.map +1 -1
- package/dist/wasm.js +25 -1
- package/dist/wasm.js.map +1 -1
- package/package.json +6 -1
- package/packages/agentium-native/wasm/pkg/agentium_sdk_wasm.d.ts +33 -1
- package/packages/agentium-native/wasm/pkg/agentium_sdk_wasm.js +62 -0
- package/packages/agentium-native/wasm/pkg/agentium_sdk_wasm_bg.wasm +0 -0
- package/packages/agentium-native/wasm/pkg/agentium_sdk_wasm_bg.wasm.d.ts +3 -1
package/README.md
CHANGED
|
@@ -39,6 +39,10 @@ const client = new AgentiumClient();
|
|
|
39
39
|
|
|
40
40
|
// Custom endpoint (for local/staging)
|
|
41
41
|
const client = new AgentiumClient({ baseURL: 'http://localhost:8080' });
|
|
42
|
+
|
|
43
|
+
// For bundlers like Vite that require explicit WASM URL
|
|
44
|
+
import wasmUrl from '@semiotic-labs/agentium-sdk/wasm?url';
|
|
45
|
+
const client = new AgentiumClient({ wasmUrl });
|
|
42
46
|
```
|
|
43
47
|
|
|
44
48
|
### Identity Connection
|
|
@@ -77,14 +81,6 @@ Refreshes an access token using a refresh token.
|
|
|
77
81
|
const newTokens = await client.refreshToken(currentRefreshToken);
|
|
78
82
|
```
|
|
79
83
|
|
|
80
|
-
#### `exchangePrivyToken(idToken)`
|
|
81
|
-
|
|
82
|
-
Exchanges a Privy ID token for JWT tokens.
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
const tokens = await client.exchangePrivyToken(privyIdToken);
|
|
86
|
-
```
|
|
87
|
-
|
|
88
84
|
### Verifiable Credentials
|
|
89
85
|
|
|
90
86
|
The SDK supports W3C Verifiable Credentials issued as JWTs with Ed25519 signatures.
|
|
@@ -141,19 +137,10 @@ const storedVc = client.getStoredCredential();
|
|
|
141
137
|
|
|
142
138
|
### WASM Utilities
|
|
143
139
|
|
|
144
|
-
Low-level cryptographic operations for Ed25519.
|
|
140
|
+
Low-level cryptographic operations for Ed25519. WASM is automatically initialized on first use — no manual setup required.
|
|
145
141
|
|
|
146
142
|
```typescript
|
|
147
|
-
import {
|
|
148
|
-
ensureWasmReady,
|
|
149
|
-
verifyJwt,
|
|
150
|
-
generateKeypair,
|
|
151
|
-
getPublicKey,
|
|
152
|
-
} from '@semiotic-labs/agentium-sdk';
|
|
153
|
-
|
|
154
|
-
// For bundlers like Vite, provide WASM URL explicitly
|
|
155
|
-
import wasmUrl from '@semiotic-labs/agentium-sdk/wasm?url';
|
|
156
|
-
await ensureWasmReady(wasmUrl);
|
|
143
|
+
import { verifyJwt, generateKeypair, getPublicKey } from '@semiotic-labs/agentium-sdk';
|
|
157
144
|
|
|
158
145
|
// Generate key pair
|
|
159
146
|
const { privateKey, publicKey } = await generateKeypair();
|
|
@@ -162,6 +149,19 @@ const { privateKey, publicKey } = await generateKeypair();
|
|
|
162
149
|
const result = await verifyJwt(jwtString, publicKeyJwk);
|
|
163
150
|
```
|
|
164
151
|
|
|
152
|
+
#### Bundler Configuration (Vite, etc.)
|
|
153
|
+
|
|
154
|
+
For bundlers like Vite that require explicit WASM URL resolution, pass `wasmUrl` to the client constructor (see [Client Setup](#client-setup)).
|
|
155
|
+
|
|
156
|
+
If using low-level WASM utilities directly (without `AgentiumClient`), initialize manually:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { ensureWasmReady } from '@semiotic-labs/agentium-sdk';
|
|
160
|
+
import wasmUrl from '@semiotic-labs/agentium-sdk/wasm?url';
|
|
161
|
+
|
|
162
|
+
await ensureWasmReady(wasmUrl);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
165
|
### Error Handling
|
|
166
166
|
|
|
167
167
|
All API methods throw `AgentiumApiError` on failure:
|
|
@@ -273,11 +273,14 @@ npm install
|
|
|
273
273
|
### Scripts
|
|
274
274
|
|
|
275
275
|
```bash
|
|
276
|
-
npm test
|
|
277
|
-
npm run build
|
|
278
|
-
npm run docs
|
|
279
|
-
npm run lint
|
|
280
|
-
npm run check
|
|
276
|
+
npm test # Run tests
|
|
277
|
+
npm run build # Build (WASM + TypeScript)
|
|
278
|
+
npm run docs # Generate API docs
|
|
279
|
+
npm run lint # Lint code
|
|
280
|
+
npm run check # Lint + format check
|
|
281
|
+
npm run check:python # Type-check Python code (mypy)
|
|
282
|
+
npm run format:all # Format all code (TS, Python, Rust)
|
|
283
|
+
npm run format:rust # Format Rust code
|
|
281
284
|
```
|
|
282
285
|
|
|
283
286
|
### REUSE Compliance
|
|
@@ -290,6 +293,14 @@ npm run reuse:check # Verify compliance
|
|
|
290
293
|
npm run reuse:write # Apply SPDX headers
|
|
291
294
|
```
|
|
292
295
|
|
|
296
|
+
## Python SDK
|
|
297
|
+
|
|
298
|
+
A Python SDK is also available with equivalent functionality. See the [Python SDK documentation](packages/agentium-native/python/README.md) for installation and usage.
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
pip install agentium
|
|
302
|
+
```
|
|
303
|
+
|
|
293
304
|
## License
|
|
294
305
|
|
|
295
306
|
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type WasmInitInput } from './wasm.js';
|
|
1
2
|
import type { VcStorage, VerificationResult, DidDocument, JwtHeader } from './vc/index.js';
|
|
2
3
|
export * from './vc/index.js';
|
|
3
|
-
export { ensureWasmReady, verifyJwt, generateKeypair, getPublicKey } from './wasm.js';
|
|
4
|
+
export { ensureWasmReady, verifyJwt, generateKeypair, getPublicKey, parseJwtHeader, extractPublicKeyJwk, type WasmInitInput, } from './wasm.js';
|
|
4
5
|
export { initTelemetry, consoleSink, nullSink, withLevelFilter, withTargetFilter, composeSinks, type TelemetryEvent, type TelemetryLevel, type TelemetrySink, type InitTelemetryOptions, } from './telemetry.js';
|
|
5
6
|
/**
|
|
6
7
|
* Options for configuring the AgentiumClient.
|
|
@@ -11,6 +12,15 @@ export interface AgentiumClientOptions {
|
|
|
11
12
|
* @default https://api.agentium.network
|
|
12
13
|
*/
|
|
13
14
|
baseURL?: string;
|
|
15
|
+
/**
|
|
16
|
+
* URL to the WASM binary. Required for bundlers like Vite that need explicit URL resolution.
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import wasmUrl from '@semiotic-labs/agentium-sdk/wasm?url';
|
|
20
|
+
* const client = new AgentiumClient({ wasmUrl });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
wasmUrl?: WasmInitInput;
|
|
14
24
|
}
|
|
15
25
|
/**
|
|
16
26
|
* Supported OAuth grant types for token exchange.
|
|
@@ -104,6 +114,7 @@ export declare class AgentiumClient {
|
|
|
104
114
|
private readonly axiosInstance;
|
|
105
115
|
private readonly DEFAULT_BASE_URL;
|
|
106
116
|
private readonly OAUTH_TOKEN_PATH;
|
|
117
|
+
private readonly wasmReady;
|
|
107
118
|
private vcStorage;
|
|
108
119
|
/**
|
|
109
120
|
* Creates an instance of the AgentiumClient.
|
|
@@ -135,13 +146,6 @@ export declare class AgentiumClient {
|
|
|
135
146
|
* @throws {AgentiumApiError} Will throw a custom API error if the call fails.
|
|
136
147
|
*/
|
|
137
148
|
refreshToken(refreshTokenValue: string): Promise<OAuthTokenResponse>;
|
|
138
|
-
/**
|
|
139
|
-
* Exchanges a Privy ID token for JWT tokens.
|
|
140
|
-
* @param idToken - The Privy ID token to exchange.
|
|
141
|
-
* @returns A promise that resolves with the OAuth token response.
|
|
142
|
-
* @throws {AgentiumApiError} Will throw a custom API error if the call fails.
|
|
143
|
-
*/
|
|
144
|
-
exchangePrivyToken(idToken: string): Promise<OAuthTokenResponse>;
|
|
145
149
|
/**
|
|
146
150
|
* Configures VC storage for persisting membership credentials.
|
|
147
151
|
* Call this with `createBrowserStorage()` in browser environments.
|
|
@@ -165,21 +169,23 @@ export declare class AgentiumClient {
|
|
|
165
169
|
fetchIssuerDidDocument(): Promise<DidDocument>;
|
|
166
170
|
/**
|
|
167
171
|
* Parses a JWT to extract the header (without verification).
|
|
172
|
+
* Delegates to WASM module for parsing.
|
|
168
173
|
*
|
|
169
174
|
* @param jwt - The JWT string
|
|
170
175
|
* @returns Parsed JWT header
|
|
171
|
-
* @throws {
|
|
176
|
+
* @throws {WasmVcError} If JWT format is invalid
|
|
172
177
|
*/
|
|
173
178
|
parseJwtHeader(jwt: string): JwtHeader;
|
|
174
179
|
/**
|
|
175
180
|
* Extracts the public key JWK from a DID document.
|
|
176
181
|
* If a key ID (kid) is provided, finds the matching verification method.
|
|
177
182
|
* Otherwise, uses the first verification method.
|
|
183
|
+
* Delegates to WASM module for extraction.
|
|
178
184
|
*
|
|
179
185
|
* @param didDocument - The DID document to extract from
|
|
180
186
|
* @param kid - Optional key ID to match (from JWT header)
|
|
181
187
|
* @returns The public key as a JSON string
|
|
182
|
-
* @throws {
|
|
188
|
+
* @throws {WasmVcError} If no matching public key is found
|
|
183
189
|
*/
|
|
184
190
|
extractPublicKeyJwk(didDocument: DidDocument, kid?: string): string;
|
|
185
191
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAK3E,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG3F,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,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AC;IAShE;;;;;;;;OAQG;IACG,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA2B5E"}
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: MIT
|
|
4
4
|
import axios, { isAxiosError } from 'axios';
|
|
5
|
-
import { verifyJwt } from './wasm.js';
|
|
5
|
+
import { ensureWasmReady, verifyJwt } from './wasm.js';
|
|
6
|
+
import { parse_jwt_header as wasmParseJwtHeader, extract_public_key_jwk as wasmExtractPublicKeyJwk, } from '../packages/agentium-native/wasm/pkg/agentium_sdk_wasm.js';
|
|
6
7
|
// Re-export VC module types and utilities
|
|
7
8
|
export * from './vc/index.js';
|
|
8
|
-
export { ensureWasmReady, verifyJwt, generateKeypair, getPublicKey } from './wasm.js';
|
|
9
|
+
export { ensureWasmReady, verifyJwt, generateKeypair, getPublicKey, parseJwtHeader, extractPublicKeyJwk, } from './wasm.js';
|
|
9
10
|
// Re-export telemetry module
|
|
10
11
|
export { initTelemetry, consoleSink, nullSink, withLevelFilter, withTargetFilter, composeSinks, } from './telemetry.js';
|
|
11
12
|
/**
|
|
@@ -36,6 +37,7 @@ export class AgentiumClient {
|
|
|
36
37
|
axiosInstance;
|
|
37
38
|
DEFAULT_BASE_URL = 'https://api.agentium.network';
|
|
38
39
|
OAUTH_TOKEN_PATH = '/oauth/token';
|
|
40
|
+
wasmReady;
|
|
39
41
|
vcStorage = null;
|
|
40
42
|
/**
|
|
41
43
|
* Creates an instance of the AgentiumClient.
|
|
@@ -46,6 +48,7 @@ export class AgentiumClient {
|
|
|
46
48
|
this.axiosInstance = axios.create({
|
|
47
49
|
baseURL: baseURL,
|
|
48
50
|
});
|
|
51
|
+
this.wasmReady = ensureWasmReady(options.wasmUrl);
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* Connects a Google identity to an Agentium identity.
|
|
@@ -125,27 +128,6 @@ export class AgentiumClient {
|
|
|
125
128
|
throw error;
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Exchanges a Privy ID token for JWT tokens.
|
|
130
|
-
* @param idToken - The Privy ID token to exchange.
|
|
131
|
-
* @returns A promise that resolves with the OAuth token response.
|
|
132
|
-
* @throws {AgentiumApiError} Will throw a custom API error if the call fails.
|
|
133
|
-
*/
|
|
134
|
-
async exchangePrivyToken(idToken) {
|
|
135
|
-
try {
|
|
136
|
-
const response = await this.axiosInstance.post(this.OAUTH_TOKEN_PATH, {
|
|
137
|
-
grant_type: 'privy_id_token',
|
|
138
|
-
id_token: idToken,
|
|
139
|
-
});
|
|
140
|
-
return response.data;
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
if (isAxiosError(error)) {
|
|
144
|
-
throw new AgentiumApiError(error.message, error.response?.status);
|
|
145
|
-
}
|
|
146
|
-
throw error;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
131
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
150
132
|
// Verifiable Credentials (VC) Methods
|
|
151
133
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -187,65 +169,28 @@ export class AgentiumClient {
|
|
|
187
169
|
}
|
|
188
170
|
/**
|
|
189
171
|
* Parses a JWT to extract the header (without verification).
|
|
172
|
+
* Delegates to WASM module for parsing.
|
|
190
173
|
*
|
|
191
174
|
* @param jwt - The JWT string
|
|
192
175
|
* @returns Parsed JWT header
|
|
193
|
-
* @throws {
|
|
176
|
+
* @throws {WasmVcError} If JWT format is invalid
|
|
194
177
|
*/
|
|
195
178
|
parseJwtHeader(jwt) {
|
|
196
|
-
|
|
197
|
-
throw new AgentiumApiError('Invalid JWT: expected non-empty string');
|
|
198
|
-
}
|
|
199
|
-
const parts = jwt.split('.');
|
|
200
|
-
if (parts.length !== 3) {
|
|
201
|
-
throw new AgentiumApiError('Invalid JWT format: expected 3 parts');
|
|
202
|
-
}
|
|
203
|
-
const headerPart = parts[0];
|
|
204
|
-
if (!headerPart) {
|
|
205
|
-
throw new AgentiumApiError('Invalid JWT format: missing header');
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
const headerJson = atob(headerPart.replace(/-/g, '+').replace(/_/g, '/'));
|
|
209
|
-
return JSON.parse(headerJson);
|
|
210
|
-
}
|
|
211
|
-
catch {
|
|
212
|
-
throw new AgentiumApiError('Invalid JWT header encoding');
|
|
213
|
-
}
|
|
179
|
+
return wasmParseJwtHeader(jwt);
|
|
214
180
|
}
|
|
215
181
|
/**
|
|
216
182
|
* Extracts the public key JWK from a DID document.
|
|
217
183
|
* If a key ID (kid) is provided, finds the matching verification method.
|
|
218
184
|
* Otherwise, uses the first verification method.
|
|
185
|
+
* Delegates to WASM module for extraction.
|
|
219
186
|
*
|
|
220
187
|
* @param didDocument - The DID document to extract from
|
|
221
188
|
* @param kid - Optional key ID to match (from JWT header)
|
|
222
189
|
* @returns The public key as a JSON string
|
|
223
|
-
* @throws {
|
|
190
|
+
* @throws {WasmVcError} If no matching public key is found
|
|
224
191
|
*/
|
|
225
192
|
extractPublicKeyJwk(didDocument, kid) {
|
|
226
|
-
|
|
227
|
-
if (!methods || methods.length === 0) {
|
|
228
|
-
throw new AgentiumApiError('No verification methods found in DID document');
|
|
229
|
-
}
|
|
230
|
-
let verificationMethod = methods[0];
|
|
231
|
-
// If kid is provided, find the matching verification method
|
|
232
|
-
if (kid) {
|
|
233
|
-
const matched = methods.find((m) => m.id === kid);
|
|
234
|
-
if (matched) {
|
|
235
|
-
verificationMethod = matched;
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
// kid might be just the fragment (e.g., "key-1"), try matching suffix
|
|
239
|
-
const matchedByFragment = methods.find((m) => m.id.endsWith(`#${kid}`) || m.id === kid);
|
|
240
|
-
if (matchedByFragment) {
|
|
241
|
-
verificationMethod = matchedByFragment;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (!verificationMethod?.publicKeyJwk) {
|
|
246
|
-
throw new AgentiumApiError(kid ? `No public key found for kid: ${kid}` : 'No public key found in DID document');
|
|
247
|
-
}
|
|
248
|
-
return JSON.stringify(verificationMethod.publicKeyJwk);
|
|
193
|
+
return wasmExtractPublicKeyJwk(JSON.stringify(didDocument), kid);
|
|
249
194
|
}
|
|
250
195
|
/**
|
|
251
196
|
* Fetches a membership credential from the backend.
|
|
@@ -280,6 +225,7 @@ export class AgentiumClient {
|
|
|
280
225
|
* @returns Verification result with validity status, decoded claims, and structured error if invalid
|
|
281
226
|
*/
|
|
282
227
|
async verifyCredential(jwt) {
|
|
228
|
+
await this.wasmReady;
|
|
283
229
|
// Extract kid from JWT header to find the correct key
|
|
284
230
|
const header = this.parseJwtHeader(jwt);
|
|
285
231
|
const didDocument = await this.fetchIssuerDidDocument();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,+BAA+B;AAE/B,OAAO,KAAK,EAAE,EAAE,YAAY,EAAsB,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,+BAA+B;AAE/B,OAAO,KAAK,EAAE,EAAE,YAAY,EAAsB,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAsB,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,gBAAgB,IAAI,kBAAkB,EACtC,sBAAsB,IAAI,uBAAuB,GAClD,MAAM,2DAA2D,CAAC;AAGnE,0CAA0C;AAC1C,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,GAEpB,MAAM,WAAW,CAAC;AAE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iBAChE;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/dist/wasm.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { VerificationResult, KeyPair } from './vc/types.js';
|
|
1
|
+
import type { InitInput } from '../packages/agentium-native/wasm/pkg/agentium_sdk_wasm.js';
|
|
2
|
+
import type { VerificationResult, KeyPair, JwtHeader, DidDocument } from './vc/types.js';
|
|
3
|
+
export type { InitInput as WasmInitInput };
|
|
3
4
|
/**
|
|
4
5
|
* Ensures the WASM module is loaded and ready.
|
|
5
6
|
* Uses lazy initialization - only loads on first call.
|
|
@@ -40,4 +41,21 @@ export declare function generateKeypair(): Promise<KeyPair>;
|
|
|
40
41
|
* @throws {WasmVcError} If the private key JWK is invalid or serialization fails.
|
|
41
42
|
*/
|
|
42
43
|
export declare function getPublicKey(privateKeyJwk: string): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Parse a JWT header without verifying the signature.
|
|
46
|
+
*
|
|
47
|
+
* @param jwt - The JWT string (compact format: header.payload.signature)
|
|
48
|
+
* @returns The parsed JWT header containing algorithm, type, and optional key ID
|
|
49
|
+
* @throws {WasmVcError} If the JWT format is invalid
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseJwtHeader(jwt: string): Promise<JwtHeader>;
|
|
52
|
+
/**
|
|
53
|
+
* Extract the public key JWK from a DID document.
|
|
54
|
+
*
|
|
55
|
+
* @param didDocument - The DID document
|
|
56
|
+
* @param kid - Optional key ID to match (from JWT header). Can be full ID or just fragment.
|
|
57
|
+
* @returns The public key as JWK JSON string
|
|
58
|
+
* @throws {WasmVcError} If no matching public key is found
|
|
59
|
+
*/
|
|
60
|
+
export declare function extractPublicKeyJwk(didDocument: DidDocument, kid?: string): Promise<string>;
|
|
43
61
|
//# sourceMappingURL=wasm.d.ts.map
|
package/dist/wasm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../src/wasm.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2DAA2D,CAAC;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEzF,YAAY,EAAE,SAAS,IAAI,aAAa,EAAE,CAAC;AAI3C;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxE;AAED;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG9F;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAGxD;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGzE;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAGpE;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIjG"}
|
package/dist/wasm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2025 Semiotic AI, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: MIT
|
|
4
|
-
import init, { verify_jwt as wasmVerifyJwt, generate_keypair as wasmGenerateKeypair, get_public_key as wasmGetPublicKey, } from '../packages/agentium-native/wasm/pkg/agentium_sdk_wasm.js';
|
|
4
|
+
import init, { verify_jwt as wasmVerifyJwt, generate_keypair as wasmGenerateKeypair, get_public_key as wasmGetPublicKey, parse_jwt_header as wasmParseJwtHeader, extract_public_key_jwk as wasmExtractPublicKeyJwk, } from '../packages/agentium-native/wasm/pkg/agentium_sdk_wasm.js';
|
|
5
5
|
let wasmInitialized = null;
|
|
6
6
|
/**
|
|
7
7
|
* Ensures the WASM module is loaded and ready.
|
|
@@ -59,4 +59,28 @@ export async function getPublicKey(privateKeyJwk) {
|
|
|
59
59
|
await ensureWasmReady();
|
|
60
60
|
return wasmGetPublicKey(privateKeyJwk);
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Parse a JWT header without verifying the signature.
|
|
64
|
+
*
|
|
65
|
+
* @param jwt - The JWT string (compact format: header.payload.signature)
|
|
66
|
+
* @returns The parsed JWT header containing algorithm, type, and optional key ID
|
|
67
|
+
* @throws {WasmVcError} If the JWT format is invalid
|
|
68
|
+
*/
|
|
69
|
+
export async function parseJwtHeader(jwt) {
|
|
70
|
+
await ensureWasmReady();
|
|
71
|
+
return wasmParseJwtHeader(jwt);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Extract the public key JWK from a DID document.
|
|
75
|
+
*
|
|
76
|
+
* @param didDocument - The DID document
|
|
77
|
+
* @param kid - Optional key ID to match (from JWT header). Can be full ID or just fragment.
|
|
78
|
+
* @returns The public key as JWK JSON string
|
|
79
|
+
* @throws {WasmVcError} If no matching public key is found
|
|
80
|
+
*/
|
|
81
|
+
export async function extractPublicKeyJwk(didDocument, kid) {
|
|
82
|
+
await ensureWasmReady();
|
|
83
|
+
const didDocumentJson = JSON.stringify(didDocument);
|
|
84
|
+
return wasmExtractPublicKeyJwk(didDocumentJson, kid);
|
|
85
|
+
}
|
|
62
86
|
//# sourceMappingURL=wasm.js.map
|
package/dist/wasm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../src/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C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,MAAM,eAAe,EAAE,CAAC;IACxB,OAAO,kBAAkB,CAAC,GAAG,CAAc,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,WAAwB,EAAE,GAAY;IAC9E,MAAM,eAAe,EAAE,CAAC;IACxB,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACpD,OAAO,uBAAuB,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semiotic-labs/agentium-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"lint": "eslint src/**/*.ts",
|
|
18
18
|
"format:check": "prettier --check .",
|
|
19
19
|
"format:write": "prettier --write .",
|
|
20
|
+
"format:python": "cd packages/agentium-native/python && ruff check . --fix && ruff format .",
|
|
21
|
+
"check:python": "cd packages/agentium-native/python && mypy agentium_sdk",
|
|
22
|
+
"format:rust": "cd packages/agentium-native && cargo fmt --all",
|
|
23
|
+
"format:rust:check": "cd packages/agentium-native && cargo fmt --all --check",
|
|
24
|
+
"format:all": "npm run format:write && npm run format:python && npm run format:rust",
|
|
20
25
|
"check": "npm run lint && npm run format:check",
|
|
21
26
|
"reuse:check": "reuse lint",
|
|
22
27
|
"reuse:write": "reuse annotate --license MIT --copyright \"Semiotic AI, Inc.\" --year 2025 -r . --fallback-dot-license --skip-existing"
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Extract the public key JWK from a DID document.
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* * `did_document_json` - The DID document as JSON string
|
|
9
|
+
* * `kid` - Optional key ID to match (from JWT header). Can be full ID or just fragment.
|
|
10
|
+
*
|
|
11
|
+
* # Returns
|
|
12
|
+
* The public key as JWK JSON string
|
|
13
|
+
*/
|
|
14
|
+
export function extract_public_key_jwk(did_document_json: string, kid?: string | null): string;
|
|
15
|
+
|
|
4
16
|
/**
|
|
5
17
|
* Generate a new Ed25519 key pair
|
|
6
18
|
*
|
|
@@ -20,8 +32,26 @@ export function generate_keypair(): any;
|
|
|
20
32
|
*/
|
|
21
33
|
export function get_public_key(private_key_jwk: string): string;
|
|
22
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Initialize tracing with a JavaScript callback sink.
|
|
37
|
+
*
|
|
38
|
+
* # Arguments
|
|
39
|
+
* * `sink` - JavaScript function that receives telemetry events as objects
|
|
40
|
+
* * `filter` - Optional filter string (e.g., "info", "debug", "agentium=trace")
|
|
41
|
+
*/
|
|
23
42
|
export function init_tracing(sink: Function, filter?: string | null): void;
|
|
24
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Parse a JWT header without verifying the signature.
|
|
46
|
+
*
|
|
47
|
+
* # Arguments
|
|
48
|
+
* * `jwt` - The JWT string (compact format: header.payload.signature)
|
|
49
|
+
*
|
|
50
|
+
* # Returns
|
|
51
|
+
* The parsed JWT header containing algorithm, type, and optional key ID.
|
|
52
|
+
*/
|
|
53
|
+
export function parse_jwt_header(jwt: string): any;
|
|
54
|
+
|
|
25
55
|
/**
|
|
26
56
|
* Verify a JWT against a public key
|
|
27
57
|
*
|
|
@@ -39,10 +69,12 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
39
69
|
|
|
40
70
|
export interface InitOutput {
|
|
41
71
|
readonly memory: WebAssembly.Memory;
|
|
72
|
+
readonly extract_public_key_jwk: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
42
73
|
readonly generate_keypair: () => [number, number, number];
|
|
43
74
|
readonly get_public_key: (a: number, b: number) => [number, number, number, number];
|
|
44
|
-
readonly verify_jwt: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
45
75
|
readonly init_tracing: (a: any, b: number, c: number) => void;
|
|
76
|
+
readonly parse_jwt_header: (a: number, b: number) => [number, number, number];
|
|
77
|
+
readonly verify_jwt: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
46
78
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
47
79
|
readonly __externref_table_alloc: () => number;
|
|
48
80
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
@@ -109,6 +109,42 @@ if (!('encodeInto' in cachedTextEncoder)) {
|
|
|
109
109
|
|
|
110
110
|
let WASM_VECTOR_LEN = 0;
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Extract the public key JWK from a DID document.
|
|
114
|
+
*
|
|
115
|
+
* # Arguments
|
|
116
|
+
* * `did_document_json` - The DID document as JSON string
|
|
117
|
+
* * `kid` - Optional key ID to match (from JWT header). Can be full ID or just fragment.
|
|
118
|
+
*
|
|
119
|
+
* # Returns
|
|
120
|
+
* The public key as JWK JSON string
|
|
121
|
+
* @param {string} did_document_json
|
|
122
|
+
* @param {string | null} [kid]
|
|
123
|
+
* @returns {string}
|
|
124
|
+
*/
|
|
125
|
+
export function extract_public_key_jwk(did_document_json, kid) {
|
|
126
|
+
let deferred4_0;
|
|
127
|
+
let deferred4_1;
|
|
128
|
+
try {
|
|
129
|
+
const ptr0 = passStringToWasm0(did_document_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
const len0 = WASM_VECTOR_LEN;
|
|
131
|
+
var ptr1 = isLikeNone(kid) ? 0 : passStringToWasm0(kid, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
132
|
+
var len1 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.extract_public_key_jwk(ptr0, len0, ptr1, len1);
|
|
134
|
+
var ptr3 = ret[0];
|
|
135
|
+
var len3 = ret[1];
|
|
136
|
+
if (ret[3]) {
|
|
137
|
+
ptr3 = 0; len3 = 0;
|
|
138
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
139
|
+
}
|
|
140
|
+
deferred4_0 = ptr3;
|
|
141
|
+
deferred4_1 = len3;
|
|
142
|
+
return getStringFromWasm0(ptr3, len3);
|
|
143
|
+
} finally {
|
|
144
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
112
148
|
/**
|
|
113
149
|
* Generate a new Ed25519 key pair
|
|
114
150
|
*
|
|
@@ -157,6 +193,11 @@ export function get_public_key(private_key_jwk) {
|
|
|
157
193
|
}
|
|
158
194
|
|
|
159
195
|
/**
|
|
196
|
+
* Initialize tracing with a JavaScript callback sink.
|
|
197
|
+
*
|
|
198
|
+
* # Arguments
|
|
199
|
+
* * `sink` - JavaScript function that receives telemetry events as objects
|
|
200
|
+
* * `filter` - Optional filter string (e.g., "info", "debug", "agentium=trace")
|
|
160
201
|
* @param {Function} sink
|
|
161
202
|
* @param {string | null} [filter]
|
|
162
203
|
*/
|
|
@@ -166,6 +207,27 @@ export function init_tracing(sink, filter) {
|
|
|
166
207
|
wasm.init_tracing(sink, ptr0, len0);
|
|
167
208
|
}
|
|
168
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Parse a JWT header without verifying the signature.
|
|
212
|
+
*
|
|
213
|
+
* # Arguments
|
|
214
|
+
* * `jwt` - The JWT string (compact format: header.payload.signature)
|
|
215
|
+
*
|
|
216
|
+
* # Returns
|
|
217
|
+
* The parsed JWT header containing algorithm, type, and optional key ID.
|
|
218
|
+
* @param {string} jwt
|
|
219
|
+
* @returns {any}
|
|
220
|
+
*/
|
|
221
|
+
export function parse_jwt_header(jwt) {
|
|
222
|
+
const ptr0 = passStringToWasm0(jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
223
|
+
const len0 = WASM_VECTOR_LEN;
|
|
224
|
+
const ret = wasm.parse_jwt_header(ptr0, len0);
|
|
225
|
+
if (ret[2]) {
|
|
226
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
227
|
+
}
|
|
228
|
+
return takeFromExternrefTable0(ret[0]);
|
|
229
|
+
}
|
|
230
|
+
|
|
169
231
|
/**
|
|
170
232
|
* Verify a JWT against a public key
|
|
171
233
|
*
|
|
Binary file
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const extract_public_key_jwk: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
4
5
|
export const generate_keypair: () => [number, number, number];
|
|
5
6
|
export const get_public_key: (a: number, b: number) => [number, number, number, number];
|
|
6
|
-
export const verify_jwt: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
7
7
|
export const init_tracing: (a: any, b: number, c: number) => void;
|
|
8
|
+
export const parse_jwt_header: (a: number, b: number) => [number, number, number];
|
|
9
|
+
export const verify_jwt: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
8
10
|
export const __wbindgen_exn_store: (a: number) => void;
|
|
9
11
|
export const __externref_table_alloc: () => number;
|
|
10
12
|
export const __wbindgen_externrefs: WebAssembly.Table;
|