@openwop/openwop 1.7.0 → 1.8.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/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export { ACTIVE_RUN_STATUSES, TERMINAL_RUN_STATUSES, isTerminalRunStatus, HTTP_E
21
21
  export type { ActiveRunStatus, TerminalRunStatus, HttpErrorCode, RunErrorCode, RunError, } from './run-helpers.js';
22
22
  export { OPENWOP_COST_ATTRIBUTE_NAMES, sanitizeCostAttributes, } from './cost-attribution.js';
23
23
  export type { OpenwopCostAttributeName } from './cost-attribution.js';
24
+ /** @deprecated Import from `@openwop/openwop/webhooks` — server-only; removed from the barrel in the next major. */
24
25
  export { DEFAULT_WEBHOOK_FRESHNESS_WINDOW_SECONDS, verifyWebhookSignature, signWebhookDelivery, } from './webhook-helpers.js';
25
26
  export type { VerifyWebhookSignatureOptions, VerifyWebhookOutcome, } from './webhook-helpers.js';
26
27
  export { RegistryClient } from './registry-helpers.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EAEZ,kBAAkB,EAElB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,gBAAgB,EAChB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CAAwC,EACxC,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAI/B,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAEhB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,wBAAwB,EAExB,+BAA+B,EAC/B,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAW1E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -28,6 +28,18 @@ export { OPENWOP_COST_ATTRIBUTE_NAMES, sanitizeCostAttributes, } from './cost-at
28
28
  // HMAC-SHA256 + timestamp freshness window verification per
29
29
  // spec/v1/webhooks.md §"Signature recipe". Receivers MUST verify both
30
30
  // the HMAC AND the timestamp to defeat replay attacks.
31
+ //
32
+ // DEPRECATED ON THE BARREL (openwop-sdks#30). These re-exports are why a
33
+ // browser consumer importing anything at all from `@openwop/openwop` dragged
34
+ // in `node:crypto` and failed the build. Import them from
35
+ // `@openwop/openwop/webhooks` instead; the barrel re-export is retained for
36
+ // compatibility and will be removed in the next major.
37
+ //
38
+ // Until then the `browser` field in package.json substitutes a stub that
39
+ // throws with an explanatory message, so a browser build succeeds and only a
40
+ // browser CALL fails — which is the correct outcome either way, since the
41
+ // subscription secret must never reach a browser.
42
+ /** @deprecated Import from `@openwop/openwop/webhooks` — server-only; removed from the barrel in the next major. */
31
43
  export { DEFAULT_WEBHOOK_FRESHNESS_WINDOW_SECONDS, verifyWebhookSignature, signWebhookDelivery, } from './webhook-helpers.js';
32
44
  // Public-registry read helpers (SDK-5 close-out 2026-05-15). Read-only
33
45
  // typed client for the public node-pack registry at packs.openwop.dev
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA8GtC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,2EAA2E;AAC3E,6DAA6D;AAC7D,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAM5B,yEAAyE;AACzE,yEAAyE;AACzE,oBAAoB;AACpB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC;AAS1B,iDAAiD;AACj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CAAC;AAM5B,yEAAyE;AACzE,yEAAyE;AACzE,oBAAoB;AACpB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC;AAS1B,iDAAiD;AACjD,sEAAsE;AACtE,mEAAmE;AACnE,uDAAuD;AACvD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAG/B,sEAAsE;AACtE,4DAA4D;AAC5D,sEAAsE;AACtE,uDAAuD;AACvD,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,0DAA0D;AAC1D,4EAA4E;AAC5E,uDAAuD;AACvD,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,0EAA0E;AAC1E,kDAAkD;AAClD,oHAAoH;AACpH,OAAO,EACL,wCAAwC,EACxC,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAM9B,uEAAuE;AACvE,sEAAsE;AACtE,sCAAsC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA0CvD,oEAAoE;AACpE,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,uDAAuD;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,mEAAmE;AACnE,wEAAwE;AACxE,uEAAuE;AACvE,qEAAqE;AACrE,qEAAqE;AACrE,sEAAsE;AACtE,8DAA8D;AAC9D,sEAAsE;AACtE,oDAAoD;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Browser substitute for `webhook-helpers.ts` (openwop-sdks#30).
3
+ *
4
+ * ## Why this file exists
5
+ *
6
+ * `webhook-helpers.ts` imports `node:crypto` for `createHmac` and
7
+ * `timingSafeEqual`. The package barrel re-exports it, and the `exports` map
8
+ * offers only `"."` — so a browser consumer importing ANYTHING from
9
+ * `@openwop/openwop` pulled the barrel, pulled the webhook helpers, and pulled
10
+ * `node:crypto`. Vite/Rollup then failed the BUILD with
11
+ *
12
+ * "createHmac" is not exported by "__vite-browser-external"
13
+ *
14
+ * which names a bundler-internal shim rather than the real cause, so the error
15
+ * points nowhere useful. Reported 2026-05-26 and still reproducible against the
16
+ * published 1.7.0 fifteen months later.
17
+ *
18
+ * The `browser` field in package.json maps the Node module to this one, so the
19
+ * barrel is importable in a browser again. Webhook signature verification is a
20
+ * SERVER concern — a browser has no business holding the subscription secret —
21
+ * so the honest browser behaviour is to keep the import working and refuse the
22
+ * call, not to ship a second crypto implementation.
23
+ *
24
+ * ## Why it throws rather than returning a failure
25
+ *
26
+ * `verifyWebhookSignature` returning `{ ok: false }` in a browser would be a
27
+ * silent security downgrade: a caller that treats "not ok" as "reject the
28
+ * delivery" behaves identically whether the signature was forged or the
29
+ * platform simply could not check it. Those are different facts and only one of
30
+ * them is about the payload. Throwing keeps them distinguishable.
31
+ */
32
+ /** @see spec/v1/webhooks.md §"Replay attack protection" */
33
+ export declare const DEFAULT_WEBHOOK_FRESHNESS_WINDOW_SECONDS = 300;
34
+ export declare function verifyWebhookSignature(): never;
35
+ export declare function signWebhookDelivery(): never;
36
+ export type { VerifyWebhookSignatureOptions, VerifyWebhookOutcome } from './webhook-helpers.js';
37
+ //# sourceMappingURL=webhook-helpers.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-helpers.browser.d.ts","sourceRoot":"","sources":["../src/webhook-helpers.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAOH,2DAA2D;AAC3D,eAAO,MAAM,wCAAwC,MAAM,CAAC;AAE5D,wBAAgB,sBAAsB,IAAI,KAAK,CAE9C;AAED,wBAAgB,mBAAmB,IAAI,KAAK,CAE3C;AAED,YAAY,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Browser substitute for `webhook-helpers.ts` (openwop-sdks#30).
3
+ *
4
+ * ## Why this file exists
5
+ *
6
+ * `webhook-helpers.ts` imports `node:crypto` for `createHmac` and
7
+ * `timingSafeEqual`. The package barrel re-exports it, and the `exports` map
8
+ * offers only `"."` — so a browser consumer importing ANYTHING from
9
+ * `@openwop/openwop` pulled the barrel, pulled the webhook helpers, and pulled
10
+ * `node:crypto`. Vite/Rollup then failed the BUILD with
11
+ *
12
+ * "createHmac" is not exported by "__vite-browser-external"
13
+ *
14
+ * which names a bundler-internal shim rather than the real cause, so the error
15
+ * points nowhere useful. Reported 2026-05-26 and still reproducible against the
16
+ * published 1.7.0 fifteen months later.
17
+ *
18
+ * The `browser` field in package.json maps the Node module to this one, so the
19
+ * barrel is importable in a browser again. Webhook signature verification is a
20
+ * SERVER concern — a browser has no business holding the subscription secret —
21
+ * so the honest browser behaviour is to keep the import working and refuse the
22
+ * call, not to ship a second crypto implementation.
23
+ *
24
+ * ## Why it throws rather than returning a failure
25
+ *
26
+ * `verifyWebhookSignature` returning `{ ok: false }` in a browser would be a
27
+ * silent security downgrade: a caller that treats "not ok" as "reject the
28
+ * delivery" behaves identically whether the signature was forged or the
29
+ * platform simply could not check it. Those are different facts and only one of
30
+ * them is about the payload. Throwing keeps them distinguishable.
31
+ */
32
+ const REASON = 'openwop: webhook signature helpers require Node\'s crypto (HMAC-SHA256 + timingSafeEqual) and are not available in a browser build. '
33
+ + 'Webhook verification is a server-side concern — the subscription secret must never reach a browser. '
34
+ + 'Import them on the server from "@openwop/openwop/webhooks".';
35
+ /** @see spec/v1/webhooks.md §"Replay attack protection" */
36
+ export const DEFAULT_WEBHOOK_FRESHNESS_WINDOW_SECONDS = 300;
37
+ export function verifyWebhookSignature() {
38
+ throw new Error(REASON);
39
+ }
40
+ export function signWebhookDelivery() {
41
+ throw new Error(REASON);
42
+ }
43
+ //# sourceMappingURL=webhook-helpers.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-helpers.browser.js","sourceRoot":"","sources":["../src/webhook-helpers.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,MAAM,GACV,sIAAsI;MACpI,sGAAsG;MACtG,6DAA6D,CAAC;AAElE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,wCAAwC,GAAG,GAAG,CAAC;AAE5D,MAAM,UAAU,sBAAsB;IACpC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openwop/openwop",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Production-ready TypeScript reference SDK for OpenWOP v1.0 compliant servers.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,14 @@
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
+ "browser": "./dist/index.js",
17
18
  "import": "./dist/index.js"
18
- }
19
+ },
20
+ "./webhooks": {
21
+ "types": "./dist/webhook-helpers.d.ts",
22
+ "import": "./dist/webhook-helpers.js"
23
+ },
24
+ "./package.json": "./package.json"
19
25
  },
20
26
  "files": [
21
27
  "dist",
@@ -40,5 +46,8 @@
40
46
  },
41
47
  "overrides": {
42
48
  "esbuild": "^0.25.0"
49
+ },
50
+ "browser": {
51
+ "./dist/webhook-helpers.js": "./dist/webhook-helpers.browser.js"
43
52
  }
44
53
  }
package/src/index.ts CHANGED
@@ -188,6 +188,18 @@ export type { OpenwopCostAttributeName } from './cost-attribution.js';
188
188
  // HMAC-SHA256 + timestamp freshness window verification per
189
189
  // spec/v1/webhooks.md §"Signature recipe". Receivers MUST verify both
190
190
  // the HMAC AND the timestamp to defeat replay attacks.
191
+ //
192
+ // DEPRECATED ON THE BARREL (openwop-sdks#30). These re-exports are why a
193
+ // browser consumer importing anything at all from `@openwop/openwop` dragged
194
+ // in `node:crypto` and failed the build. Import them from
195
+ // `@openwop/openwop/webhooks` instead; the barrel re-export is retained for
196
+ // compatibility and will be removed in the next major.
197
+ //
198
+ // Until then the `browser` field in package.json substitutes a stub that
199
+ // throws with an explanatory message, so a browser build succeeds and only a
200
+ // browser CALL fails — which is the correct outcome either way, since the
201
+ // subscription secret must never reach a browser.
202
+ /** @deprecated Import from `@openwop/openwop/webhooks` — server-only; removed from the barrel in the next major. */
191
203
  export {
192
204
  DEFAULT_WEBHOOK_FRESHNESS_WINDOW_SECONDS,
193
205
  verifyWebhookSignature,
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Browser substitute for `webhook-helpers.ts` (openwop-sdks#30).
3
+ *
4
+ * ## Why this file exists
5
+ *
6
+ * `webhook-helpers.ts` imports `node:crypto` for `createHmac` and
7
+ * `timingSafeEqual`. The package barrel re-exports it, and the `exports` map
8
+ * offers only `"."` — so a browser consumer importing ANYTHING from
9
+ * `@openwop/openwop` pulled the barrel, pulled the webhook helpers, and pulled
10
+ * `node:crypto`. Vite/Rollup then failed the BUILD with
11
+ *
12
+ * "createHmac" is not exported by "__vite-browser-external"
13
+ *
14
+ * which names a bundler-internal shim rather than the real cause, so the error
15
+ * points nowhere useful. Reported 2026-05-26 and still reproducible against the
16
+ * published 1.7.0 fifteen months later.
17
+ *
18
+ * The `browser` field in package.json maps the Node module to this one, so the
19
+ * barrel is importable in a browser again. Webhook signature verification is a
20
+ * SERVER concern — a browser has no business holding the subscription secret —
21
+ * so the honest browser behaviour is to keep the import working and refuse the
22
+ * call, not to ship a second crypto implementation.
23
+ *
24
+ * ## Why it throws rather than returning a failure
25
+ *
26
+ * `verifyWebhookSignature` returning `{ ok: false }` in a browser would be a
27
+ * silent security downgrade: a caller that treats "not ok" as "reject the
28
+ * delivery" behaves identically whether the signature was forged or the
29
+ * platform simply could not check it. Those are different facts and only one of
30
+ * them is about the payload. Throwing keeps them distinguishable.
31
+ */
32
+
33
+ const REASON =
34
+ 'openwop: webhook signature helpers require Node\'s crypto (HMAC-SHA256 + timingSafeEqual) and are not available in a browser build. '
35
+ + 'Webhook verification is a server-side concern — the subscription secret must never reach a browser. '
36
+ + 'Import them on the server from "@openwop/openwop/webhooks".';
37
+
38
+ /** @see spec/v1/webhooks.md §"Replay attack protection" */
39
+ export const DEFAULT_WEBHOOK_FRESHNESS_WINDOW_SECONDS = 300;
40
+
41
+ export function verifyWebhookSignature(): never {
42
+ throw new Error(REASON);
43
+ }
44
+
45
+ export function signWebhookDelivery(): never {
46
+ throw new Error(REASON);
47
+ }
48
+
49
+ export type { VerifyWebhookSignatureOptions, VerifyWebhookOutcome } from './webhook-helpers.js';