@base44-preview/platform 0.6.0-pr.382.862c2c8 → 0.6.0-pr.396.e8e5bd2
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.
|
@@ -233,3 +233,5 @@ export interface WebhookEventMap {
|
|
|
233
233
|
}
|
|
234
234
|
/** Every event type in {@link WebhookEventMap}, so events from a newer Base44 can be told apart at runtime. @internal */
|
|
235
235
|
export declare const WEBHOOK_EVENT_TYPES: readonly ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "chat.turn_started.v1", "chat.turn_ended.v1"];
|
|
236
|
+
/** The deprecation notice of each deprecated event type, for verifyEvent()'s warning. @internal */
|
|
237
|
+
export declare const WEBHOOK_DEPRECATIONS: Partial<Record<string, string>>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// Generated by scripts/generate-webhook-types.mjs from the
|
|
1
|
+
// Generated by scripts/generate-webhook-types.mjs from the schema of each event
|
|
2
2
|
// published at https://base44.com/webhooks/schemas. Do not edit by hand; run `npm run generate:webhooks`.
|
|
3
3
|
/** Every event type in {@link WebhookEventMap}, so events from a newer Base44 can be told apart at runtime. @internal */
|
|
4
4
|
export const WEBHOOK_EVENT_TYPES = ["app.created.v1", "app.published.v1", "app.unpublished.v1", "app.deleted.v1", "app.restored.v1", "webhook.test.v1", "chat.turn_started.v1", "chat.turn_ended.v1"];
|
|
5
|
+
/** The deprecation notice of each deprecated event type, for verifyEvent()'s warning. @internal */
|
|
6
|
+
export const WEBHOOK_DEPRECATIONS = {};
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { WebhookConfigurationError, WebhookVerificationError } from "../errors.js";
|
|
2
2
|
import { anySignatureVerifies, importPublicKey, parsePublicKeys, parseSignatures, readHeader, signedPayload } from "./webhooks-signature.js";
|
|
3
|
-
import { WEBHOOK_EVENT_TYPES } from "./webhooks.events.generated.js";
|
|
3
|
+
import { WEBHOOK_DEPRECATIONS, WEBHOOK_EVENT_TYPES } from "./webhooks.events.generated.js";
|
|
4
4
|
const knownTypes = new Set(WEBHOOK_EVENT_TYPES);
|
|
5
5
|
const DEFAULT_TOLERANCE_SECONDS = 300;
|
|
6
|
+
// Types can't flag a deprecated event in a `switch` or a handler key, so the first delivery of each says so.
|
|
7
|
+
const warnedDeprecated = new Set();
|
|
8
|
+
function warnIfDeprecated(type) {
|
|
9
|
+
const notice = WEBHOOK_DEPRECATIONS[type];
|
|
10
|
+
if (!notice || warnedDeprecated.has(type))
|
|
11
|
+
return;
|
|
12
|
+
warnedDeprecated.add(type);
|
|
13
|
+
console.warn(`Base44 webhook event ${type}: ${notice}`);
|
|
14
|
+
}
|
|
6
15
|
/** Webhook receiving utilities. Verification is local: no network calls, no timers. */
|
|
7
16
|
export function createWebhooks() {
|
|
8
17
|
// Imported keys are cached by their wire form so a pinned key is imported once.
|
|
@@ -49,6 +58,7 @@ export function createWebhooks() {
|
|
|
49
58
|
if (typeof type !== "string" || typeof eventId !== "string" || typeof data !== "object" || data === null) {
|
|
50
59
|
throw new WebhookVerificationError("invalid_payload");
|
|
51
60
|
}
|
|
61
|
+
warnIfDeprecated(type);
|
|
52
62
|
// A type from a newer Base44 gets the client's unknown-event shape, so known types keep narrowing.
|
|
53
63
|
return (knownTypes.has(type) ? event : { ...event, type: "unknown", name: type });
|
|
54
64
|
};
|
|
@@ -127,6 +127,10 @@ export interface CreateHandlerOptions extends VerifyEventOptions {
|
|
|
127
127
|
* [event types](https://docs.base44.com/developers/references/outbound-webhooks/get-started/event-types)
|
|
128
128
|
* for what each one means.
|
|
129
129
|
*
|
|
130
|
+
* A deprecated event type's `data` interface and its `WebhookEventMap` entry are marked `@deprecated`.
|
|
131
|
+
* Editors don't flag a `case` label or a handler key, so `verifyEvent()` also logs a warning the
|
|
132
|
+
* first time each deprecated type arrives, saying what replaces it.
|
|
133
|
+
*
|
|
130
134
|
* The module verifies each delivery's signature with your workspace's public keys and returns the
|
|
131
135
|
* event with a typed payload. It runs on Node.js 20 and later and on edge runtimes, and makes
|
|
132
136
|
* no network requests.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/platform",
|
|
3
|
-
"version": "0.6.0-pr.
|
|
3
|
+
"version": "0.6.0-pr.396.e8e5bd2",
|
|
4
4
|
"description": "Base44 Platform SDK for white-label platforms: a browser client for following the AI chat and a server entrypoint for webhooks",
|
|
5
5
|
"main": "dist/client/index.js",
|
|
6
6
|
"types": "dist/client/index.d.ts",
|