@openwop/openwop 1.8.0 → 2.0.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.
Files changed (60) hide show
  1. package/README.md +64 -117
  2. package/dist/client.d.ts +131 -245
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +233 -440
  5. package/dist/client.js.map +1 -1
  6. package/dist/cost-attribution.d.ts +2 -2
  7. package/dist/cost-attribution.js +2 -2
  8. package/dist/envelope-directive.d.ts +1 -1
  9. package/dist/envelope-directive.js +1 -1
  10. package/dist/event-helpers.js +1 -1
  11. package/dist/event-helpers.js.map +1 -1
  12. package/dist/generated.d.ts +17 -0
  13. package/dist/generated.d.ts.map +1 -0
  14. package/dist/generated.js +311 -0
  15. package/dist/generated.js.map +1 -0
  16. package/dist/index.d.ts +16 -16
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +26 -53
  19. package/dist/index.js.map +1 -1
  20. package/dist/run-helpers.d.ts +20 -21
  21. package/dist/run-helpers.d.ts.map +1 -1
  22. package/dist/run-helpers.js +23 -72
  23. package/dist/run-helpers.js.map +1 -1
  24. package/dist/sse.d.ts +33 -15
  25. package/dist/sse.d.ts.map +1 -1
  26. package/dist/sse.js +28 -30
  27. package/dist/sse.js.map +1 -1
  28. package/dist/types.d.ts +253 -559
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js.map +1 -1
  31. package/dist/webhook-header-families.d.ts +42 -0
  32. package/dist/webhook-header-families.d.ts.map +1 -0
  33. package/dist/webhook-header-families.js +58 -0
  34. package/dist/webhook-header-families.js.map +1 -0
  35. package/dist/webhook-helpers.browser.d.ts +15 -28
  36. package/dist/webhook-helpers.browser.d.ts.map +1 -1
  37. package/dist/webhook-helpers.browser.js +16 -27
  38. package/dist/webhook-helpers.browser.js.map +1 -1
  39. package/dist/webhook-helpers.d.ts +48 -32
  40. package/dist/webhook-helpers.d.ts.map +1 -1
  41. package/dist/webhook-helpers.js +52 -37
  42. package/dist/webhook-helpers.js.map +1 -1
  43. package/package.json +6 -4
  44. package/src/client.ts +255 -454
  45. package/src/cost-attribution.ts +2 -2
  46. package/src/envelope-directive.ts +1 -1
  47. package/src/event-helpers.ts +1 -1
  48. package/src/generated.ts +322 -0
  49. package/src/index.ts +78 -105
  50. package/src/run-helpers.ts +27 -85
  51. package/src/sse.ts +63 -42
  52. package/src/types.ts +268 -603
  53. package/src/webhook-header-families.ts +78 -0
  54. package/src/webhook-helpers.browser.ts +24 -28
  55. package/src/webhook-helpers.ts +87 -39
  56. package/dist/registry-helpers.d.ts +0 -118
  57. package/dist/registry-helpers.d.ts.map +0 -1
  58. package/dist/registry-helpers.js +0 -82
  59. package/dist/registry-helpers.js.map +0 -1
  60. package/src/registry-helpers.ts +0 -173
@@ -1,173 +0,0 @@
1
- /**
2
- * Public-registry read helpers per
3
- * `spec/v1/registry-operations.md`.
4
- *
5
- * The OpenWOP host SDK targets the host wire surface
6
- * (`/.well-known/openwop` + `/v1/runs/*` + `/v1/interrupts/*` etc).
7
- * The **public node-pack registry** at `packs.openwop.dev` is a
8
- * separate wire surface with its own discovery payload and pack-
9
- * versioned read endpoints. This module exposes a thin typed client
10
- * for that surface so adopters fetching pack manifests, indices, or
11
- * signature material don't roll their own HTTP plumbing.
12
- *
13
- * Read-only by design — the public registry uses pull-request-driven
14
- * publishing per `spec/v1/registry-operations.md` §"Submission flow"
15
- * + the `registry-publish.yml` GitHub workflow. There is no write API.
16
- *
17
- * No auth required for public reads.
18
- *
19
- * @module @openwop/openwop/registry-helpers
20
- */
21
-
22
- /** Public registry discovery payload per `registry-operations.md` §"Discovery". */
23
- export interface RegistryDiscovery {
24
- registryVersion: string;
25
- protocolVersion: string;
26
- name?: string;
27
- operator?: string;
28
- url?: string;
29
- supportedNamespaces: readonly string[];
30
- supportedSigningMethods: readonly string[];
31
- supportedTrustModes?: readonly string[];
32
- endpoints: {
33
- registryIndex: string;
34
- packMetadata: string;
35
- versionManifest: string;
36
- versionTarball: string;
37
- versionSignature: string;
38
- publicKey: string;
39
- };
40
- signingKeys?: ReadonlyArray<{
41
- keyId: string;
42
- algorithm: string;
43
- publicKeyUrl?: string;
44
- permittedNamespaces?: readonly string[];
45
- operator?: string;
46
- status?: string;
47
- }>;
48
- [key: string]: unknown;
49
- }
50
-
51
- /** Registry-wide index entry per `/v1/index.json` rows. */
52
- export interface RegistryIndexEntry {
53
- name: string;
54
- latestVersion: string;
55
- description?: string;
56
- scope?: string;
57
- [key: string]: unknown;
58
- }
59
-
60
- export interface RegistryIndex {
61
- packs: ReadonlyArray<RegistryIndexEntry>;
62
- generated?: string;
63
- packCount?: number;
64
- [key: string]: unknown;
65
- }
66
-
67
- /** Per-pack metadata document at `/v1/packs/{name}/index.json`. */
68
- export interface RegistryPackMetadata {
69
- name: string;
70
- description?: string;
71
- versions: ReadonlyArray<string>;
72
- latestVersion?: string;
73
- [key: string]: unknown;
74
- }
75
-
76
- /** Version manifest at `/v1/packs/{name}/-/{version}.json`. */
77
- export interface RegistryVersionManifest {
78
- name: string;
79
- version: string;
80
- description?: string;
81
- /** SRI hash: `sha256-<43-char-b64>=`. */
82
- integrity?: string;
83
- signing?: {
84
- method: 'ed25519' | 'manual' | string;
85
- keyId: string;
86
- publicKeyUrl?: string;
87
- };
88
- [key: string]: unknown;
89
- }
90
-
91
- export interface RegistryClientOptions {
92
- /** Base URL for the registry. Defaults to `https://packs.openwop.dev`. */
93
- baseUrl?: string;
94
- /** Custom fetch implementation; defaults to `globalThis.fetch`. */
95
- fetch?: typeof fetch;
96
- }
97
-
98
- /**
99
- * Typed client for the public OpenWOP node-pack registry. Read-only;
100
- * no auth required for the canonical public read surface.
101
- *
102
- * For host-side install-time verification (SRI + Ed25519 + lockfile),
103
- * see `examples/hosts/postgres/src/pack-consumer.ts` — the registry
104
- * client is the fetch surface; the consumer is the security surface.
105
- */
106
- export class RegistryClient {
107
- readonly baseUrl: string;
108
- readonly #fetch: typeof fetch;
109
-
110
- constructor(options: RegistryClientOptions = {}) {
111
- this.baseUrl = (options.baseUrl ?? 'https://packs.openwop.dev').replace(/\/$/, '');
112
- this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
113
- }
114
-
115
- /** `GET /.well-known/openwop-registry` — discovery + endpoint catalog. */
116
- async discovery(): Promise<RegistryDiscovery> {
117
- return this.#getJson<RegistryDiscovery>('/.well-known/openwop-registry');
118
- }
119
-
120
- /** `GET /v1/index.json` — registry-wide pack index. */
121
- async index(): Promise<RegistryIndex> {
122
- return this.#getJson<RegistryIndex>('/v1/index.json');
123
- }
124
-
125
- /** `GET /v1/packs/{name}/index.json` — per-pack metadata. */
126
- async pack(name: string): Promise<RegistryPackMetadata> {
127
- return this.#getJson<RegistryPackMetadata>(
128
- `/v1/packs/${encodeURIComponent(name)}/index.json`,
129
- );
130
- }
131
-
132
- /** `GET /v1/packs/{name}/-/{version}.json` — version manifest. */
133
- async version(name: string, version: string): Promise<RegistryVersionManifest> {
134
- return this.#getJson<RegistryVersionManifest>(
135
- `/v1/packs/${encodeURIComponent(name)}/-/${encodeURIComponent(version)}.json`,
136
- );
137
- }
138
-
139
- /** Fetch raw tarball bytes. Caller MUST verify SRI + signature before trust. */
140
- async tarball(name: string, version: string): Promise<Buffer> {
141
- return this.#getBinary(
142
- `/v1/packs/${encodeURIComponent(name)}/-/${encodeURIComponent(version)}.tgz`,
143
- );
144
- }
145
-
146
- /** Fetch raw 64-byte Ed25519 signature bytes. */
147
- async signature(name: string, version: string): Promise<Buffer> {
148
- return this.#getBinary(
149
- `/v1/packs/${encodeURIComponent(name)}/-/${encodeURIComponent(version)}.sig`,
150
- );
151
- }
152
-
153
- /** Fetch a publisher's public key as PEM text. */
154
- async publicKey(keyId: string): Promise<string> {
155
- const res = await this.#fetch(`${this.baseUrl}/keys/${encodeURIComponent(keyId)}.pub`);
156
- if (!res.ok) throw new Error(`registry: GET /keys/${keyId}.pub returned ${res.status}`);
157
- return res.text();
158
- }
159
-
160
- async #getJson<T>(path: string): Promise<T> {
161
- const res = await this.#fetch(`${this.baseUrl}${path}`, {
162
- headers: { Accept: 'application/json' },
163
- });
164
- if (!res.ok) throw new Error(`registry: GET ${path} returned ${res.status}`);
165
- return (await res.json()) as T;
166
- }
167
-
168
- async #getBinary(path: string): Promise<Buffer> {
169
- const res = await this.#fetch(`${this.baseUrl}${path}`);
170
- if (!res.ok) throw new Error(`registry: GET ${path} returned ${res.status}`);
171
- return Buffer.from(await res.arrayBuffer());
172
- }
173
- }