@iveri/contracts 0.95.0 → 0.96.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/api/chat/chat-app-webhook.type.d.ts +10 -2
- package/dist/api/conduit/connection.type.d.ts +24 -0
- package/dist/api/conduit/connector-signature-format.enum.d.ts +4 -0
- package/dist/api/conduit/connector-signature-format.enum.js +4 -0
- package/dist/api/conduit/connector.type.d.ts +7 -0
- package/dist/api/conduit/connector.type.js +7 -0
- package/package.json +1 -1
|
@@ -17,6 +17,12 @@ export interface ChatAppWebhook {
|
|
|
17
17
|
url: string;
|
|
18
18
|
events: ChatWebhookEvent[];
|
|
19
19
|
isActive: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Until when the secret the last rotation replaced still signs beside the new one, or null when only one does.
|
|
22
|
+
* Every delivery meanwhile carries a `v1` for each, so a server still checking the old secret keeps accepting them.
|
|
23
|
+
* Ended early by `POST …/end-secret-overlap`.
|
|
24
|
+
*/
|
|
25
|
+
previousSecretExpiresAt: Nullable<IsoDateTime>;
|
|
20
26
|
createdAt: IsoDateTime;
|
|
21
27
|
updatedAt: IsoDateTime;
|
|
22
28
|
}
|
|
@@ -35,7 +41,8 @@ export interface UpdateChatAppWebhookRequest {
|
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
37
43
|
* `POST /apps/:appId/webhooks` and `POST …/rotate-secret`. The only answers that hold the signing secret: Baasi does
|
|
38
|
-
* not keep it
|
|
44
|
+
* not keep it. After a rotation the old secret keeps signing beside the new one until `previousSecretExpiresAt` (a day,
|
|
45
|
+
* unless the deployment says otherwise), so the server can be moved over without refusing a delivery.
|
|
39
46
|
*/
|
|
40
47
|
export interface CreatedChatAppWebhook extends ChatAppWebhook {
|
|
41
48
|
/** `bwh_` and 32 random bytes in base64url. The HMAC key for `Baasi-Signature`. */
|
|
@@ -61,7 +68,8 @@ export interface ChatAppWebhookDelivery {
|
|
|
61
68
|
export type ChatAppWebhookDeliveriesPage = CursorPage<ChatAppWebhookDelivery>;
|
|
62
69
|
/**
|
|
63
70
|
* The body every webhook carries, signed with `Baasi-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of
|
|
64
|
-
* "<t>.<body>"
|
|
71
|
+
* "<t>.<body>">`, with a second `v1=` for the replaced secret while a rotation overlaps: accept the request when any
|
|
72
|
+
* `v1` matches. Users are named by the app's own ids for them. `id` is stable across retries, so a server that has
|
|
65
73
|
* seen it may answer 200 and do nothing.
|
|
66
74
|
*/
|
|
67
75
|
export interface ChatWebhookPayload<TType extends ChatWebhookEvent = ChatWebhookEvent, TData = unknown> {
|
|
@@ -70,6 +70,15 @@ export interface Connection {
|
|
|
70
70
|
* usable: the client id and secret are typed in, the token is only ever granted.
|
|
71
71
|
*/
|
|
72
72
|
connectedAt: Nullable<IsoDateTime>;
|
|
73
|
+
/**
|
|
74
|
+
* Until when the signing secret this connection's last rotation replaced still signs beside the
|
|
75
|
+
* new one, or null when only one secret signs.
|
|
76
|
+
*
|
|
77
|
+
* Only an `hmac-signature` connection ever has one, and only after an update that replaced its
|
|
78
|
+
* `secret` with {@link UpdateConnectionBody.previousSigningSecretValidForSeconds}. Null once that
|
|
79
|
+
* moment has passed, so a reader never has to compare it with the clock.
|
|
80
|
+
*/
|
|
81
|
+
previousSigningSecretExpiresAt: Nullable<IsoDateTime>;
|
|
73
82
|
/** Stops *new* dispatches being accepted. Does not cancel ones already queued. */
|
|
74
83
|
isActive: boolean;
|
|
75
84
|
createdAt: IsoDateTime;
|
|
@@ -129,6 +138,21 @@ export interface UpdateConnectionBody {
|
|
|
129
138
|
credentials?: Nullable<Record<string, string>>;
|
|
130
139
|
variables?: Nullable<Record<string, string>>;
|
|
131
140
|
isActive?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Keeps the `secret` this update replaces signing beside the new one for this many seconds,
|
|
143
|
+
* 1 to `MAX_SIGNING_SECRET_OVERLAP_SECONDS`. **`hmac-signature` connections only**, and
|
|
144
|
+
* only with a `credentials` object that changes the `secret`; anything else is refused.
|
|
145
|
+
*
|
|
146
|
+
* Omitted, the replaced secret stops signing at once, as it always has. A receiver still
|
|
147
|
+
* checking the old secret then refuses every request until it is updated, and those requests
|
|
148
|
+
* dead-letter on the 4xx. With an overlap, every request carries a `v1` for each secret, so a
|
|
149
|
+
* receiver holding either accepts it.
|
|
150
|
+
*
|
|
151
|
+
* **At most two secrets sign at once.** Rotating again during an overlap keeps the secret this
|
|
152
|
+
* update replaces and drops the older one. Ending an overlap early is
|
|
153
|
+
* `DELETE /api/v1/connections/:id/previous-signing-secret`.
|
|
154
|
+
*/
|
|
155
|
+
previousSigningSecretValidForSeconds?: number;
|
|
132
156
|
}
|
|
133
157
|
/**
|
|
134
158
|
* `POST /api/v1/connections/:id/verify`.
|
|
@@ -13,6 +13,10 @@ export declare enum ConnectorSignatureFormat {
|
|
|
13
13
|
* header on commas, recompute over the timestamp, a dot and the body exactly as received,
|
|
14
14
|
* compare in constant time, and refuse a timestamp older than a few minutes. A request with no
|
|
15
15
|
* body is signed over `<t>.` alone.
|
|
16
|
+
*
|
|
17
|
+
* While a replaced secret is still within its overlap the header carries one `v1=` per live
|
|
18
|
+
* secret, the newest first (`t=…,v1=<new>,v1=<old>`), which is how Stripe signs during a roll:
|
|
19
|
+
* a receiver accepts the request when any `v1` matches the secret it holds.
|
|
16
20
|
*/
|
|
17
21
|
STRIPE_V1 = "stripe-v1"
|
|
18
22
|
}
|
|
@@ -14,6 +14,10 @@ export var ConnectorSignatureFormat;
|
|
|
14
14
|
* header on commas, recompute over the timestamp, a dot and the body exactly as received,
|
|
15
15
|
* compare in constant time, and refuse a timestamp older than a few minutes. A request with no
|
|
16
16
|
* body is signed over `<t>.` alone.
|
|
17
|
+
*
|
|
18
|
+
* While a replaced secret is still within its overlap the header carries one `v1=` per live
|
|
19
|
+
* secret, the newest first (`t=…,v1=<new>,v1=<old>`), which is how Stripe signs during a roll:
|
|
20
|
+
* a receiver accepts the request when any `v1` matches the secret it holds.
|
|
17
21
|
*/
|
|
18
22
|
ConnectorSignatureFormat["STRIPE_V1"] = "stripe-v1";
|
|
19
23
|
})(ConnectorSignatureFormat || (ConnectorSignatureFormat = {}));
|
|
@@ -31,6 +31,13 @@ export declare const CONNECTOR_CREDENTIAL_PRIVATE_KEY_ID = "privateKeyId";
|
|
|
31
31
|
* that could rename it could only name it wrongly.
|
|
32
32
|
*/
|
|
33
33
|
export declare const CONNECTOR_CREDENTIAL_SECRET = "secret";
|
|
34
|
+
/**
|
|
35
|
+
* The longest a replaced signing secret may keep signing beside its successor: seven days.
|
|
36
|
+
*
|
|
37
|
+
* Long enough for a receiver deployed weekly to pick up the new secret, short enough that a secret
|
|
38
|
+
* somebody replaced because it leaked stops being accepted within a week of their saying so.
|
|
39
|
+
*/
|
|
40
|
+
export declare const MAX_SIGNING_SECRET_OVERLAP_SECONDS = 604800;
|
|
34
41
|
/**
|
|
35
42
|
* How a request is signed. `HMAC_SIGNATURE` only.
|
|
36
43
|
*
|
|
@@ -26,3 +26,10 @@ export const CONNECTOR_CREDENTIAL_PRIVATE_KEY_ID = 'privateKeyId';
|
|
|
26
26
|
* that could rename it could only name it wrongly.
|
|
27
27
|
*/
|
|
28
28
|
export const CONNECTOR_CREDENTIAL_SECRET = 'secret';
|
|
29
|
+
/**
|
|
30
|
+
* The longest a replaced signing secret may keep signing beside its successor: seven days.
|
|
31
|
+
*
|
|
32
|
+
* Long enough for a receiver deployed weekly to pick up the new secret, short enough that a secret
|
|
33
|
+
* somebody replaced because it leaked stops being accepted within a week of their saying so.
|
|
34
|
+
*/
|
|
35
|
+
export const MAX_SIGNING_SECRET_OVERLAP_SECONDS = 604_800;
|