@volter/twin-openai 2.0.0 → 2.0.1

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.
@@ -1,4 +1,4 @@
1
- import { nodeBuiltin } from '@volter/world-core';
1
+ import { nodeBuiltin, worldNow } from '@volter/world-core';
2
2
  function nodeCrypto() {
3
3
  // eslint-disable-next-line @typescript-eslint/no-require-imports
4
4
  return nodeBuiltin('node:crypto');
@@ -40,7 +40,7 @@ export function verifyOpenAIWebhook(payload, headers, secret, opts = {}) {
40
40
  if (!id || !sigHeader || !Number.isFinite(ts))
41
41
  throw new OpenAIWebhookVerificationError('Missing required webhook headers (webhook-id / webhook-timestamp / webhook-signature).');
42
42
  if (opts.tolerance !== undefined) {
43
- const now = opts.now ?? Math.floor(Date.now() / 1000);
43
+ const now = opts.now ?? Math.floor(Date.parse(worldNow()) / 1000);
44
44
  if (Math.abs(now - ts) > opts.tolerance)
45
45
  throw new OpenAIWebhookVerificationError('Webhook timestamp outside tolerance.');
46
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/twin-openai",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Local OpenAI twin — a faithful, stateful local OpenAI API your real `openai` SDK talks to unmodified. The model is stubbed (deterministic) and embeddings are deterministic pseudo-vectors, but the protocol envelope (chat completions/streaming/tool_calls, the Responses API, embeddings, models, files, batches, moderations, fine-tuning, vector stores) is vendor-faithful. Built on @volter/world-core.",
5
5
  "keywords": [
6
6
  "twin",
@@ -54,10 +54,10 @@
54
54
  "postpack": "node ../../../scripts/publish/prepare-publish.mjs postpack"
55
55
  },
56
56
  "peerDependencies": {
57
- "@volter/world-core": "2.0.0"
57
+ "@volter/world-core": "2.0.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@volter/world-core": "2.0.0",
60
+ "@volter/world-core": "2.0.1",
61
61
  "@volter/world-tooling": "0.1.0",
62
62
  "openai": "^4.104.0",
63
63
  "@types/bun": "^1.2.20",
@@ -68,6 +68,6 @@
68
68
  "node": ">=22.3"
69
69
  },
70
70
  "dependencies": {
71
- "@volter/world-ui": "0.1.0"
71
+ "@volter/world-ui": "0.1.1"
72
72
  }
73
73
  }
@@ -1,4 +1,4 @@
1
- import { nodeBuiltin } from '@volter/world-core';
1
+ import { nodeBuiltin, worldNow } from '@volter/world-core';
2
2
  // OpenAI webhooks — REAL HMAC-signed delivery, Standard-Webhooks scheme.
3
3
  //
4
4
  // Real OpenAI delivers asynchronous job-completion notifications (batch / fine-tuning /
@@ -64,7 +64,7 @@ export function verifyOpenAIWebhook(payload: string, headers: Record<string, str
64
64
  const sigHeader = lower['webhook-signature'];
65
65
  if (!id || !sigHeader || !Number.isFinite(ts)) throw new OpenAIWebhookVerificationError('Missing required webhook headers (webhook-id / webhook-timestamp / webhook-signature).');
66
66
  if (opts.tolerance !== undefined) {
67
- const now = opts.now ?? Math.floor(Date.now() / 1000);
67
+ const now = opts.now ?? Math.floor(Date.parse(worldNow()) / 1000);
68
68
  if (Math.abs(now - ts) > opts.tolerance) throw new OpenAIWebhookVerificationError('Webhook timestamp outside tolerance.');
69
69
  }
70
70
  const expected = computeOpenAIWebhookSignature(id, ts, payload, secret).slice('v1,'.length);