@gnufoo/canaad 0.4.0 → 0.4.2

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.
Binary file
package/init.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Initialize WASM. Call once before using any WASM functions.
3
3
  *
4
- * @param wasmModule - Pass the WebAssembly.Module in Workers, omit in browser
4
+ * @param wasmModule - pass a precompiled WebAssembly.Module in Workers, omit in browser
5
5
  */
6
6
  export function initWasm(wasmModule?: WebAssembly.Module): Promise<void>;
7
7
 
8
8
  /**
9
- * Check if WASM has been initialized.
9
+ * True if WASM has been initialized via `initWasm()`.
10
10
  */
11
11
  export function isInitialized(): boolean;
package/init.js CHANGED
@@ -6,7 +6,7 @@ let initPromise = null;
6
6
  /**
7
7
  * Initialize WASM. Call once before using any WASM functions.
8
8
  *
9
- * @param {WebAssembly.Module | undefined} wasmModule - Pass the Module in Workers, omit in browser
9
+ * @param {WebAssembly.Module | undefined} wasmModule - pass a precompiled module in Workers, omit in browser
10
10
  */
11
11
  export async function initWasm(wasmModule) {
12
12
  if (initialized) return;
@@ -19,6 +19,9 @@ export async function initWasm(wasmModule) {
19
19
  return initPromise;
20
20
  }
21
21
 
22
+ /**
23
+ * True if WASM has been initialized via `initWasm()`.
24
+ */
22
25
  export function isInitialized() {
23
26
  return initialized;
24
27
  }
package/meta.d.ts CHANGED
@@ -1,11 +1,18 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ /** Validates and parses all AAD action inputs. */
3
4
  export declare const inputSchema: z.ZodType;
5
+
6
+ /** Validates and parses all AAD action outputs. */
4
7
  export declare const outputSchema: z.ZodType;
5
8
 
9
+ /** Discriminated union of all action input shapes. */
6
10
  export type CanaadInput = z.infer<typeof inputSchema>;
11
+
12
+ /** Discriminated union of all action output shapes. */
7
13
  export type CanaadOutput = z.infer<typeof outputSchema>;
8
14
 
15
+ /** Tool metadata: id, name, slug, description, category, execution type, positional args, and schemas. */
9
16
  export declare const meta: {
10
17
  id: string;
11
18
  name: string;
package/meta.js CHANGED
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
 
3
3
  const extensionSchema = z.object({
4
4
  key: z.string().regex(/^x_[a-z]+_[a-z_]+$/),
5
- value: z.union([z.string(), z.number().int().nonnegative()]),
5
+ value: z.union([z.string(), z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)]),
6
6
  });
7
7
 
8
8
  export const inputSchema = z.discriminatedUnion('action', [
@@ -22,10 +22,10 @@ export const inputSchema = z.discriminatedUnion('action', [
22
22
  }),
23
23
  z.object({
24
24
  action: z.literal('build'),
25
- tenant: z.string().min(1).max(256),
26
- resource: z.string().min(1).max(1024),
25
+ tenant: z.string().min(1).refine(s => new TextEncoder().encode(s).length <= 256, 'tenant exceeds 256 bytes'),
26
+ resource: z.string().min(1).refine(s => new TextEncoder().encode(s).length <= 1024, 'resource exceeds 1024 bytes'),
27
27
  purpose: z.string().min(1),
28
- timestamp: z.number().int().nonnegative().optional(),
28
+ timestamp: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional(),
29
29
  extensions: z.array(extensionSchema).optional(),
30
30
  outputFormat: z.enum(['bytes', 'string']).default('string'),
31
31
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gnufoo/canaad",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "main": "canaad_wasm.js",
6
6
  "types": "canaad_wasm.d.ts",
@@ -40,5 +40,12 @@
40
40
  "wasm"
41
41
  ],
42
42
  "license": "MIT OR Apache-2.0",
43
- "description": "AAD canonicalization library (RFC 8785)"
43
+ "description": "AAD canonicalization library (RFC 8785)",
44
+ "repository": {
45
+ "url": "https://gnu.foo/projects/canaad"
46
+ },
47
+ "homepage": "https://gnu.foo/projects/canaad",
48
+ "bugs": {
49
+ "email": "bugs@gnu.foo"
50
+ }
44
51
  }
package/tool.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import type { meta, CanaadInput, CanaadOutput } from './meta.js';
2
2
  import type { initWasm, isInitialized } from './init.js';
3
3
 
4
+ /**
5
+ * Main tool export. Merges AAD metadata with WASM lifecycle methods and the action dispatcher.
6
+ */
4
7
  export declare const toolDefinition: typeof meta & {
5
8
  initWasm: typeof initWasm;
6
9
  isInitialized: typeof isInitialized;
10
+ /** Dispatches an AAD action to WASM. Requires prior `initWasm()` call. */
7
11
  execute(input: CanaadInput): Promise<CanaadOutput>;
8
12
  };
package/tool.js CHANGED
@@ -5,16 +5,17 @@ import { canonicalize, canonicalizeString, hash, validate, AadBuilder } from './
5
5
  const bytesToHex = (bytes) => Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
6
6
  const bytesToBase64 = (bytes) => globalThis.btoa(String.fromCharCode(...bytes));
7
7
 
8
+ /**
9
+ * Main tool export. Merges AAD metadata with WASM lifecycle methods and the action dispatcher.
10
+ */
8
11
  export const toolDefinition = {
9
12
  ...meta,
10
-
11
- /**
12
- * Initialize WASM. Must be called before execute() in Workers.
13
- * In browsers with vite-plugin-wasm, this is optional.
14
- */
15
13
  initWasm,
16
14
  isInitialized,
17
15
 
16
+ /**
17
+ * Dispatches an AAD action to WASM. Requires prior `initWasm()` call.
18
+ */
18
19
  async execute(rawInput) {
19
20
  if (!isInitialized()) {
20
21
  throw new Error('WASM not initialized. Call initWasm() first.');