@iveri/contracts 0.87.1 → 0.89.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-console.type.d.ts +34 -0
- package/dist/api/chat/chat-app-console.type.js +1 -0
- package/dist/api/chat/chat-app-push.type.d.ts +24 -0
- package/dist/api/chat/chat-app-push.type.js +1 -0
- package/dist/api/chat/chat-app-webhook.type.d.ts +110 -0
- package/dist/api/chat/chat-app-webhook.type.js +1 -0
- package/dist/api/chat/chat-app.constant.d.ts +6 -0
- package/dist/api/chat/chat-app.constant.js +6 -0
- package/dist/api/chat/chat-app.type.d.ts +2 -0
- package/dist/api/chat/chat-push-credential-kind.enum.d.ts +7 -0
- package/dist/api/chat/chat-push-credential-kind.enum.js +8 -0
- package/dist/api/chat/chat-push-token-kind.enum.d.ts +9 -0
- package/dist/api/chat/chat-push-token-kind.enum.js +10 -0
- package/dist/api/chat/chat-realtime.type.d.ts +3 -0
- package/dist/api/chat/chat-webhook-delivery-status.enum.d.ts +12 -0
- package/dist/api/chat/chat-webhook-delivery-status.enum.js +13 -0
- package/dist/api/chat/chat-webhook-event.enum.d.ts +9 -0
- package/dist/api/chat/chat-webhook-event.enum.js +10 -0
- package/dist/api/chat/index.d.ts +7 -0
- package/dist/api/chat/index.js +7 -0
- package/dist/api/conduit/connector-auth-type.enum.d.ts +15 -1
- package/dist/api/conduit/connector-auth-type.enum.js +14 -0
- package/dist/api/conduit/connector-signature-format.enum.d.ts +18 -0
- package/dist/api/conduit/connector-signature-format.enum.js +19 -0
- package/dist/api/conduit/connector.type.d.ts +24 -0
- package/dist/api/conduit/connector.type.js +7 -0
- package/dist/api/conduit/index.d.ts +1 -0
- package/dist/api/conduit/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CursorPage } from '../../type/cursor-page.type.js';
|
|
2
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
3
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
4
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
5
|
+
import type { ChatAppUser } from './chat-app.type.js';
|
|
6
|
+
import type { ChatConversationKind } from './chat-conversation-kind.enum.js';
|
|
7
|
+
/** `GET /apps/:appId/users`. */
|
|
8
|
+
export type ChatAppUsersPage = CursorPage<ChatAppUser>;
|
|
9
|
+
/** Somebody in a conversation, as a console lists them: the app's id for them and the name they show. */
|
|
10
|
+
export interface ChatAppConversationParticipant {
|
|
11
|
+
externalId: Nullable<string>;
|
|
12
|
+
displayName: Nullable<string>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A conversation as a customer's console lists it: who is in it and when it was last used. **Never what it says**: a
|
|
16
|
+
* console reads a conversation only through a report, the rule Baasi's own staff work under.
|
|
17
|
+
*/
|
|
18
|
+
export interface ChatAppConversationSummary {
|
|
19
|
+
id: UUID;
|
|
20
|
+
kind: ChatConversationKind;
|
|
21
|
+
/** A group's own name, or the product's title for a conversation it opened. */
|
|
22
|
+
title: Nullable<string>;
|
|
23
|
+
context: Nullable<{
|
|
24
|
+
product: string;
|
|
25
|
+
type: string;
|
|
26
|
+
id: string;
|
|
27
|
+
}>;
|
|
28
|
+
participants: ChatAppConversationParticipant[];
|
|
29
|
+
lastActivityAt: IsoDateTime;
|
|
30
|
+
closedAt: Nullable<IsoDateTime>;
|
|
31
|
+
createdAt: IsoDateTime;
|
|
32
|
+
}
|
|
33
|
+
/** `GET /apps/:appId/conversations`. Most recently used first. */
|
|
34
|
+
export type ChatAppConversationsPage = CursorPage<ChatAppConversationSummary>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { ChatPushCredentialKind } from './chat-push-credential-kind.enum.js';
|
|
3
|
+
/** `GET /apps/:appId/push-credentials`: which kinds are set and since when. Never the key itself. */
|
|
4
|
+
export interface ChatAppPushCredential {
|
|
5
|
+
kind: ChatPushCredentialKind;
|
|
6
|
+
createdAt: IsoDateTime;
|
|
7
|
+
}
|
|
8
|
+
/** `PUT /apps/:appId/push-credentials/apns`. Replaces the app's APNs key. */
|
|
9
|
+
export interface PutChatApnsCredentialRequest {
|
|
10
|
+
/** The ten-character key id Apple shows beside the `.p8`. */
|
|
11
|
+
keyId: string;
|
|
12
|
+
teamId: string;
|
|
13
|
+
/** The app's bundle id, sent as `apns-topic`. */
|
|
14
|
+
bundleId: string;
|
|
15
|
+
/** The `.p8` file's contents, PEM. */
|
|
16
|
+
privateKey: string;
|
|
17
|
+
/** `true` sends to Apple's production service, `false` to its sandbox. */
|
|
18
|
+
production: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** `PUT /apps/:appId/push-credentials/fcm`. Replaces the app's Firebase service account. */
|
|
21
|
+
export interface PutChatFcmCredentialRequest {
|
|
22
|
+
/** The service account's JSON key file, as text. */
|
|
23
|
+
serviceAccountJson: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { CursorPage } from '../../type/cursor-page.type.js';
|
|
2
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
3
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
4
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
5
|
+
import type { ChatAttachmentKind } from './chat-attachment-kind.enum.js';
|
|
6
|
+
import type { ChatCaseDecision } from './chat-case-decision.enum.js';
|
|
7
|
+
import type { ChatMessageKind } from './chat-message-kind.enum.js';
|
|
8
|
+
import type { ChatReportReason } from './chat-report-reason.enum.js';
|
|
9
|
+
import type { ChatReportTarget } from './chat-report-target.enum.js';
|
|
10
|
+
import type { ChatWebhookDeliveryStatus } from './chat-webhook-delivery-status.enum.js';
|
|
11
|
+
import type { ChatWebhookEvent } from './chat-webhook-event.enum.js';
|
|
12
|
+
/** An address an app's server listens at, and what it wants to hear about. */
|
|
13
|
+
export interface ChatAppWebhook {
|
|
14
|
+
id: UUID;
|
|
15
|
+
appId: UUID;
|
|
16
|
+
/** `https://`, or `http://` only where the deployment allows private addresses. */
|
|
17
|
+
url: string;
|
|
18
|
+
events: ChatWebhookEvent[];
|
|
19
|
+
isActive: boolean;
|
|
20
|
+
createdAt: IsoDateTime;
|
|
21
|
+
updatedAt: IsoDateTime;
|
|
22
|
+
}
|
|
23
|
+
/** `POST /apps/:appId/webhooks`. */
|
|
24
|
+
export interface CreateChatAppWebhookRequest {
|
|
25
|
+
url: string;
|
|
26
|
+
/** At least one. */
|
|
27
|
+
events: ChatWebhookEvent[];
|
|
28
|
+
/** Omitted means active. */
|
|
29
|
+
isActive?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** `PATCH /apps/:appId/webhooks/:webhookId`. The address is fixed: a new address is a new webhook. */
|
|
32
|
+
export interface UpdateChatAppWebhookRequest {
|
|
33
|
+
events?: ChatWebhookEvent[];
|
|
34
|
+
isActive?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `POST /apps/:appId/webhooks` and `POST …/rotate-secret`. The only answers that hold the signing secret: Baasi does
|
|
38
|
+
* not keep it, and after a rotation the old one stops signing at once.
|
|
39
|
+
*/
|
|
40
|
+
export interface CreatedChatAppWebhook extends ChatAppWebhook {
|
|
41
|
+
/** `bwh_` and 32 random bytes in base64url. The HMAC key for `Baasi-Signature`. */
|
|
42
|
+
signingSecret: string;
|
|
43
|
+
}
|
|
44
|
+
/** One attempt by Baasi to tell an app's server something, read from the delivery queue. */
|
|
45
|
+
export interface ChatAppWebhookDelivery {
|
|
46
|
+
id: UUID;
|
|
47
|
+
/** The event's own id, which is also the `id` of the body the server received. */
|
|
48
|
+
eventId: Nullable<string>;
|
|
49
|
+
status: ChatWebhookDeliveryStatus;
|
|
50
|
+
attemptCount: number;
|
|
51
|
+
maxAttempts: number;
|
|
52
|
+
nextAttemptAt: IsoDateTime;
|
|
53
|
+
lastAttemptAt: Nullable<IsoDateTime>;
|
|
54
|
+
/** What the app's server answered last. Null when nothing answered. */
|
|
55
|
+
lastResponseStatus: Nullable<number>;
|
|
56
|
+
lastError: Nullable<string>;
|
|
57
|
+
completedAt: Nullable<IsoDateTime>;
|
|
58
|
+
createdAt: IsoDateTime;
|
|
59
|
+
}
|
|
60
|
+
/** `GET /apps/:appId/webhooks/:webhookId/deliveries`. Newest first. */
|
|
61
|
+
export type ChatAppWebhookDeliveriesPage = CursorPage<ChatAppWebhookDelivery>;
|
|
62
|
+
/**
|
|
63
|
+
* The body every webhook carries, signed with `Baasi-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of
|
|
64
|
+
* "<t>.<body>">`. Users are named by the app's own ids for them. `id` is stable across retries, so a server that has
|
|
65
|
+
* seen it may answer 200 and do nothing.
|
|
66
|
+
*/
|
|
67
|
+
export interface ChatWebhookPayload<TType extends ChatWebhookEvent = ChatWebhookEvent, TData = unknown> {
|
|
68
|
+
id: UUID;
|
|
69
|
+
type: TType;
|
|
70
|
+
appId: UUID;
|
|
71
|
+
createdAt: IsoDateTime;
|
|
72
|
+
data: TData;
|
|
73
|
+
}
|
|
74
|
+
/** A conversation's product context, when the app's server opened it about something. */
|
|
75
|
+
export interface ChatWebhookConversationContext {
|
|
76
|
+
product: string;
|
|
77
|
+
type: string;
|
|
78
|
+
id: string;
|
|
79
|
+
}
|
|
80
|
+
/** `message.created`. The text is the app's own data on its way to its own server. */
|
|
81
|
+
export interface ChatWebhookMessageCreatedData {
|
|
82
|
+
conversationId: UUID;
|
|
83
|
+
context: Nullable<ChatWebhookConversationContext>;
|
|
84
|
+
messageId: UUID;
|
|
85
|
+
seq: number;
|
|
86
|
+
/** The app's own id for whoever wrote it. */
|
|
87
|
+
senderExternalId: Nullable<string>;
|
|
88
|
+
kind: ChatMessageKind;
|
|
89
|
+
text: Nullable<string>;
|
|
90
|
+
attachmentKinds: ChatAttachmentKind[];
|
|
91
|
+
}
|
|
92
|
+
/** `report.created`. The reporter is not named: a report is the reporter's own and staff decide it. */
|
|
93
|
+
export interface ChatWebhookReportCreatedData {
|
|
94
|
+
caseId: UUID;
|
|
95
|
+
target: ChatReportTarget;
|
|
96
|
+
reason: ChatReportReason;
|
|
97
|
+
reportedExternalId: Nullable<string>;
|
|
98
|
+
conversationId: Nullable<UUID>;
|
|
99
|
+
messageId: Nullable<UUID>;
|
|
100
|
+
}
|
|
101
|
+
/** `person.sanctioned`. The moderator's note stays in the record. */
|
|
102
|
+
export interface ChatWebhookPersonSanctionedData {
|
|
103
|
+
externalId: Nullable<string>;
|
|
104
|
+
decision: ChatCaseDecision;
|
|
105
|
+
suspendedUntil: Nullable<IsoDateTime>;
|
|
106
|
+
caseId: Nullable<UUID>;
|
|
107
|
+
}
|
|
108
|
+
export type ChatWebhookMessageCreated = ChatWebhookPayload<ChatWebhookEvent.MESSAGE_CREATED, ChatWebhookMessageCreatedData>;
|
|
109
|
+
export type ChatWebhookReportCreated = ChatWebhookPayload<ChatWebhookEvent.REPORT_CREATED, ChatWebhookReportCreatedData>;
|
|
110
|
+
export type ChatWebhookPersonSanctioned = ChatWebhookPayload<ChatWebhookEvent.PERSON_SANCTIONED, ChatWebhookPersonSanctionedData>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,3 +10,9 @@ export declare const CHAT_APP_TOKEN_MAX_TTL_SECONDS = 86400;
|
|
|
10
10
|
export declare const CHAT_APP_TOKEN_DEFAULT_TTL_SECONDS = 3600;
|
|
11
11
|
/** The longest id an app may give one of its users. */
|
|
12
12
|
export declare const CHAT_EXTERNAL_USER_ID_MAX_LENGTH = 255;
|
|
13
|
+
/** At most this many webhooks per app. */
|
|
14
|
+
export declare const CHAT_APP_MAX_WEBHOOKS = 5;
|
|
15
|
+
/** What a webhook's signing secret looks like: this prefix, then 32 random bytes in base64url. */
|
|
16
|
+
export declare const CHAT_WEBHOOK_SECRET_PREFIX = "bwh_";
|
|
17
|
+
/** The header every webhook is signed in: `t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<body>">`. */
|
|
18
|
+
export declare const CHAT_WEBHOOK_SIGNATURE_HEADER = "Baasi-Signature";
|
|
@@ -10,3 +10,9 @@ export const CHAT_APP_TOKEN_MAX_TTL_SECONDS = 86_400;
|
|
|
10
10
|
export const CHAT_APP_TOKEN_DEFAULT_TTL_SECONDS = 3_600;
|
|
11
11
|
/** The longest id an app may give one of its users. */
|
|
12
12
|
export const CHAT_EXTERNAL_USER_ID_MAX_LENGTH = 255;
|
|
13
|
+
/** At most this many webhooks per app. */
|
|
14
|
+
export const CHAT_APP_MAX_WEBHOOKS = 5;
|
|
15
|
+
/** What a webhook's signing secret looks like: this prefix, then 32 random bytes in base64url. */
|
|
16
|
+
export const CHAT_WEBHOOK_SECRET_PREFIX = 'bwh_';
|
|
17
|
+
/** The header every webhook is signed in: `t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<body>">`. */
|
|
18
|
+
export const CHAT_WEBHOOK_SIGNATURE_HEADER = 'Baasi-Signature';
|
|
@@ -59,6 +59,8 @@ export interface ChatAppUser {
|
|
|
59
59
|
/** Their tokens signed before this moment are refused. */
|
|
60
60
|
tokensNotBefore: Nullable<IsoDateTime>;
|
|
61
61
|
createdAt: IsoDateTime;
|
|
62
|
+
/** Their last request, to the minute. Null for a user created ahead of time who has not signed in yet. */
|
|
63
|
+
lastActiveAt: Nullable<IsoDateTime>;
|
|
62
64
|
}
|
|
63
65
|
/** `POST /server/tokens`. For a company that would rather not sign a token itself. */
|
|
64
66
|
export interface MintChatTokenRequest {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Whose servers an app's own push credential talks to. */
|
|
2
|
+
export declare enum ChatPushCredentialKind {
|
|
3
|
+
/** Apple Push Notification service, with the app's `.p8` key. */
|
|
4
|
+
APNS = "apns",
|
|
5
|
+
/** Firebase Cloud Messaging, with the app's service account. */
|
|
6
|
+
FCM = "fcm"
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Whose servers an app's own push credential talks to. */
|
|
2
|
+
export var ChatPushCredentialKind;
|
|
3
|
+
(function (ChatPushCredentialKind) {
|
|
4
|
+
/** Apple Push Notification service, with the app's `.p8` key. */
|
|
5
|
+
ChatPushCredentialKind["APNS"] = "apns";
|
|
6
|
+
/** Firebase Cloud Messaging, with the app's service account. */
|
|
7
|
+
ChatPushCredentialKind["FCM"] = "fcm";
|
|
8
|
+
})(ChatPushCredentialKind || (ChatPushCredentialKind = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** What kind of push token a device holds, which decides who delivers to it. */
|
|
2
|
+
export declare enum ChatPushTokenKind {
|
|
3
|
+
/** An Expo push token, sent through Expo. What every Iveri app holds. */
|
|
4
|
+
EXPO = "expo",
|
|
5
|
+
/** A raw APNs device token, sent through Apple with the app's own key. */
|
|
6
|
+
APNS = "apns",
|
|
7
|
+
/** A raw FCM registration token, sent through Firebase with the app's own service account. */
|
|
8
|
+
FCM = "fcm"
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What kind of push token a device holds, which decides who delivers to it. */
|
|
2
|
+
export var ChatPushTokenKind;
|
|
3
|
+
(function (ChatPushTokenKind) {
|
|
4
|
+
/** An Expo push token, sent through Expo. What every Iveri app holds. */
|
|
5
|
+
ChatPushTokenKind["EXPO"] = "expo";
|
|
6
|
+
/** A raw APNs device token, sent through Apple with the app's own key. */
|
|
7
|
+
ChatPushTokenKind["APNS"] = "apns";
|
|
8
|
+
/** A raw FCM registration token, sent through Firebase with the app's own service account. */
|
|
9
|
+
ChatPushTokenKind["FCM"] = "fcm";
|
|
10
|
+
})(ChatPushTokenKind || (ChatPushTokenKind = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Nullable } from '../../type/nil.type.js';
|
|
2
2
|
import type { UUID } from '../../type/uuid.type.js';
|
|
3
3
|
import type { ChatDevicePlatform } from './chat-device-platform.enum.js';
|
|
4
|
+
import type { ChatPushTokenKind } from './chat-push-token-kind.enum.js';
|
|
4
5
|
import type { ChatRealtimeEvent } from './chat-realtime-event.enum.js';
|
|
5
6
|
/** What a socket receives. Identifiers only, and never a tenant id. */
|
|
6
7
|
export interface ChatRealtimeFrame {
|
|
@@ -16,5 +17,7 @@ export interface RegisterChatDeviceRequest {
|
|
|
16
17
|
installationId: string;
|
|
17
18
|
platform: ChatDevicePlatform;
|
|
18
19
|
pushToken: string;
|
|
20
|
+
/** Omitted means `expo`, which is what every Iveri app holds. An app's own build may hold a raw APNs or FCM token. */
|
|
21
|
+
tokenKind?: ChatPushTokenKind;
|
|
19
22
|
locale?: Nullable<string>;
|
|
20
23
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where one webhook delivery is. The same states Conduit's outbound queue has, under Baasi's own name, so a console
|
|
3
|
+
* never imports Conduit's contract to read its own app's log.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ChatWebhookDeliveryStatus {
|
|
6
|
+
PENDING = "pending",
|
|
7
|
+
IN_FLIGHT = "in-flight",
|
|
8
|
+
DELIVERED = "delivered",
|
|
9
|
+
/** Every attempt failed. It can be sent again from the console. */
|
|
10
|
+
DEAD_LETTERED = "dead-lettered",
|
|
11
|
+
CANCELLED = "cancelled"
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where one webhook delivery is. The same states Conduit's outbound queue has, under Baasi's own name, so a console
|
|
3
|
+
* never imports Conduit's contract to read its own app's log.
|
|
4
|
+
*/
|
|
5
|
+
export var ChatWebhookDeliveryStatus;
|
|
6
|
+
(function (ChatWebhookDeliveryStatus) {
|
|
7
|
+
ChatWebhookDeliveryStatus["PENDING"] = "pending";
|
|
8
|
+
ChatWebhookDeliveryStatus["IN_FLIGHT"] = "in-flight";
|
|
9
|
+
ChatWebhookDeliveryStatus["DELIVERED"] = "delivered";
|
|
10
|
+
/** Every attempt failed. It can be sent again from the console. */
|
|
11
|
+
ChatWebhookDeliveryStatus["DEAD_LETTERED"] = "dead-lettered";
|
|
12
|
+
ChatWebhookDeliveryStatus["CANCELLED"] = "cancelled";
|
|
13
|
+
})(ChatWebhookDeliveryStatus || (ChatWebhookDeliveryStatus = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** What an app's server can be told about, through a webhook it registered. */
|
|
2
|
+
export declare enum ChatWebhookEvent {
|
|
3
|
+
/** Somebody wrote in one of the app's conversations. A product's own notice is not one. */
|
|
4
|
+
MESSAGE_CREATED = "message.created",
|
|
5
|
+
/** One of the app's users reported a message or a person. */
|
|
6
|
+
REPORT_CREATED = "report.created",
|
|
7
|
+
/** A moderator warned, suspended or banned one of the app's users, or reinstated them. */
|
|
8
|
+
PERSON_SANCTIONED = "person.sanctioned"
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What an app's server can be told about, through a webhook it registered. */
|
|
2
|
+
export var ChatWebhookEvent;
|
|
3
|
+
(function (ChatWebhookEvent) {
|
|
4
|
+
/** Somebody wrote in one of the app's conversations. A product's own notice is not one. */
|
|
5
|
+
ChatWebhookEvent["MESSAGE_CREATED"] = "message.created";
|
|
6
|
+
/** One of the app's users reported a message or a person. */
|
|
7
|
+
ChatWebhookEvent["REPORT_CREATED"] = "report.created";
|
|
8
|
+
/** A moderator warned, suspended or banned one of the app's users, or reinstated them. */
|
|
9
|
+
ChatWebhookEvent["PERSON_SANCTIONED"] = "person.sanctioned";
|
|
10
|
+
})(ChatWebhookEvent || (ChatWebhookEvent = {}));
|
package/dist/api/chat/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from './chat-app-console.type.js';
|
|
1
2
|
export * from './chat-app-conversation-mode.enum.js';
|
|
3
|
+
export * from './chat-app-push.type.js';
|
|
4
|
+
export * from './chat-app-webhook.type.js';
|
|
2
5
|
export * from './chat-app.constant.js';
|
|
3
6
|
export * from './chat-app.type.js';
|
|
4
7
|
export * from './chat-attachment-kind.enum.js';
|
|
@@ -18,8 +21,12 @@ export * from './chat-participant-role.enum.js';
|
|
|
18
21
|
export * from './chat-participant-status.enum.js';
|
|
19
22
|
export * from './chat-person-status.enum.js';
|
|
20
23
|
export * from './chat-person.type.js';
|
|
24
|
+
export * from './chat-push-credential-kind.enum.js';
|
|
25
|
+
export * from './chat-push-token-kind.enum.js';
|
|
21
26
|
export * from './chat-realtime-event.enum.js';
|
|
22
27
|
export * from './chat-realtime.type.js';
|
|
23
28
|
export * from './chat-refusal.enum.js';
|
|
24
29
|
export * from './chat-report-reason.enum.js';
|
|
25
30
|
export * from './chat-report-target.enum.js';
|
|
31
|
+
export * from './chat-webhook-delivery-status.enum.js';
|
|
32
|
+
export * from './chat-webhook-event.enum.js';
|
package/dist/api/chat/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from './chat-app-console.type.js';
|
|
1
2
|
export * from './chat-app-conversation-mode.enum.js';
|
|
3
|
+
export * from './chat-app-push.type.js';
|
|
4
|
+
export * from './chat-app-webhook.type.js';
|
|
2
5
|
export * from './chat-app.constant.js';
|
|
3
6
|
export * from './chat-app.type.js';
|
|
4
7
|
export * from './chat-attachment-kind.enum.js';
|
|
@@ -18,8 +21,12 @@ export * from './chat-participant-role.enum.js';
|
|
|
18
21
|
export * from './chat-participant-status.enum.js';
|
|
19
22
|
export * from './chat-person-status.enum.js';
|
|
20
23
|
export * from './chat-person.type.js';
|
|
24
|
+
export * from './chat-push-credential-kind.enum.js';
|
|
25
|
+
export * from './chat-push-token-kind.enum.js';
|
|
21
26
|
export * from './chat-realtime-event.enum.js';
|
|
22
27
|
export * from './chat-realtime.type.js';
|
|
23
28
|
export * from './chat-refusal.enum.js';
|
|
24
29
|
export * from './chat-report-reason.enum.js';
|
|
25
30
|
export * from './chat-report-target.enum.js';
|
|
31
|
+
export * from './chat-webhook-delivery-status.enum.js';
|
|
32
|
+
export * from './chat-webhook-event.enum.js';
|
|
@@ -73,5 +73,19 @@ export declare enum ConnectorAuthType {
|
|
|
73
73
|
* refresh token exists — the key signs a fresh assertion whenever one is needed — so, unlike
|
|
74
74
|
* {@link OAUTH2_REFRESH_TOKEN}, two replicas minting at once costs a token, not a connection.
|
|
75
75
|
*/
|
|
76
|
-
OAUTH2_JWT_BEARER = "oauth2-jwt-bearer"
|
|
76
|
+
OAUTH2_JWT_BEARER = "oauth2-jwt-bearer",
|
|
77
|
+
/**
|
|
78
|
+
* Every request is **signed** with a shared secret, and nothing is sent as a credential.
|
|
79
|
+
*
|
|
80
|
+
* The receiver holds the same secret and recomputes the signature over the bytes it received,
|
|
81
|
+
* so a request that was altered, or forged by somebody without the secret, fails its check.
|
|
82
|
+
* This is how a webhook is authenticated to whoever receives it: Baasi's webhooks to a
|
|
83
|
+
* customer's server are dispatches on a connector of this type.
|
|
84
|
+
*
|
|
85
|
+
* The connection's `secret` credential is the key ({@link CONNECTOR_CREDENTIAL_SECRET}), and
|
|
86
|
+
* the manifest's `signature` names the header and the format. **The signature covers the exact
|
|
87
|
+
* bytes sent and a timestamp of that attempt**, so a retried attempt carries a fresh signature,
|
|
88
|
+
* and a receiver that refuses old timestamps refuses a replayed request.
|
|
89
|
+
*/
|
|
90
|
+
HMAC_SIGNATURE = "hmac-signature"
|
|
77
91
|
}
|
|
@@ -75,4 +75,18 @@ export var ConnectorAuthType;
|
|
|
75
75
|
* {@link OAUTH2_REFRESH_TOKEN}, two replicas minting at once costs a token, not a connection.
|
|
76
76
|
*/
|
|
77
77
|
ConnectorAuthType["OAUTH2_JWT_BEARER"] = "oauth2-jwt-bearer";
|
|
78
|
+
/**
|
|
79
|
+
* Every request is **signed** with a shared secret, and nothing is sent as a credential.
|
|
80
|
+
*
|
|
81
|
+
* The receiver holds the same secret and recomputes the signature over the bytes it received,
|
|
82
|
+
* so a request that was altered, or forged by somebody without the secret, fails its check.
|
|
83
|
+
* This is how a webhook is authenticated to whoever receives it: Baasi's webhooks to a
|
|
84
|
+
* customer's server are dispatches on a connector of this type.
|
|
85
|
+
*
|
|
86
|
+
* The connection's `secret` credential is the key ({@link CONNECTOR_CREDENTIAL_SECRET}), and
|
|
87
|
+
* the manifest's `signature` names the header and the format. **The signature covers the exact
|
|
88
|
+
* bytes sent and a timestamp of that attempt**, so a retried attempt carries a fresh signature,
|
|
89
|
+
* and a receiver that refuses old timestamps refuses a replayed request.
|
|
90
|
+
*/
|
|
91
|
+
ConnectorAuthType["HMAC_SIGNATURE"] = "hmac-signature";
|
|
78
92
|
})(ConnectorAuthType || (ConnectorAuthType = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an `HMAC_SIGNATURE` connector writes the signature header.
|
|
3
|
+
*
|
|
4
|
+
* One format today. A receiver has to implement whichever format it is sent, so each member is a
|
|
5
|
+
* documented, stable wire format rather than a knob.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ConnectorSignatureFormat {
|
|
8
|
+
/**
|
|
9
|
+
* `t=<unix seconds>,v1=<signature>`, where the signature is the lowercase hex HMAC-SHA256 of
|
|
10
|
+
* `<t>.<raw body bytes>` keyed by the connection's secret.
|
|
11
|
+
*
|
|
12
|
+
* Stripe's webhook scheme, chosen because receivers already know how to verify it: split the
|
|
13
|
+
* header on commas, recompute over the timestamp, a dot and the body exactly as received,
|
|
14
|
+
* compare in constant time, and refuse a timestamp older than a few minutes. A request with no
|
|
15
|
+
* body is signed over `<t>.` alone.
|
|
16
|
+
*/
|
|
17
|
+
STRIPE_V1 = "stripe-v1"
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an `HMAC_SIGNATURE` connector writes the signature header.
|
|
3
|
+
*
|
|
4
|
+
* One format today. A receiver has to implement whichever format it is sent, so each member is a
|
|
5
|
+
* documented, stable wire format rather than a knob.
|
|
6
|
+
*/
|
|
7
|
+
export var ConnectorSignatureFormat;
|
|
8
|
+
(function (ConnectorSignatureFormat) {
|
|
9
|
+
/**
|
|
10
|
+
* `t=<unix seconds>,v1=<signature>`, where the signature is the lowercase hex HMAC-SHA256 of
|
|
11
|
+
* `<t>.<raw body bytes>` keyed by the connection's secret.
|
|
12
|
+
*
|
|
13
|
+
* Stripe's webhook scheme, chosen because receivers already know how to verify it: split the
|
|
14
|
+
* header on commas, recompute over the timestamp, a dot and the body exactly as received,
|
|
15
|
+
* compare in constant time, and refuse a timestamp older than a few minutes. A request with no
|
|
16
|
+
* body is signed over `<t>.` alone.
|
|
17
|
+
*/
|
|
18
|
+
ConnectorSignatureFormat["STRIPE_V1"] = "stripe-v1";
|
|
19
|
+
})(ConnectorSignatureFormat || (ConnectorSignatureFormat = {}));
|
|
@@ -2,6 +2,7 @@ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
|
2
2
|
import type { Nullable } from '../../type/nil.type.js';
|
|
3
3
|
import type { UUID } from '../../type/uuid.type.js';
|
|
4
4
|
import type { ConnectorAuthType } from './connector-auth-type.enum.js';
|
|
5
|
+
import type { ConnectorSignatureFormat } from './connector-signature-format.enum.js';
|
|
5
6
|
/**
|
|
6
7
|
* Credential names an OAuth manifest expects to find on a connection.
|
|
7
8
|
*
|
|
@@ -23,6 +24,24 @@ export declare const CONNECTOR_CREDENTIAL_REFRESH_TOKEN = "refreshToken";
|
|
|
23
24
|
export declare const CONNECTOR_CREDENTIAL_CLIENT_EMAIL = "clientEmail";
|
|
24
25
|
export declare const CONNECTOR_CREDENTIAL_PRIVATE_KEY = "privateKey";
|
|
25
26
|
export declare const CONNECTOR_CREDENTIAL_PRIVATE_KEY_ID = "privateKeyId";
|
|
27
|
+
/**
|
|
28
|
+
* Credential name an `HMAC_SIGNATURE` manifest signs with.
|
|
29
|
+
*
|
|
30
|
+
* Fixed for the same reason as the OAuth names: the scheme has exactly one secret, so a manifest
|
|
31
|
+
* that could rename it could only name it wrongly.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CONNECTOR_CREDENTIAL_SECRET = "secret";
|
|
34
|
+
/**
|
|
35
|
+
* How a request is signed. `HMAC_SIGNATURE` only.
|
|
36
|
+
*
|
|
37
|
+
* The header and the format are the manifest's; the secret is the connection's, under
|
|
38
|
+
* {@link CONNECTOR_CREDENTIAL_SECRET}.
|
|
39
|
+
*/
|
|
40
|
+
export interface ConnectorRequestSignature {
|
|
41
|
+
/** Lowercase header the signature is sent in, e.g. `baasi-signature`. */
|
|
42
|
+
header: string;
|
|
43
|
+
format: ConnectorSignatureFormat;
|
|
44
|
+
}
|
|
26
45
|
/**
|
|
27
46
|
* How a connector authenticates, as data.
|
|
28
47
|
*
|
|
@@ -108,6 +127,10 @@ export interface ConnectorAuthManifest {
|
|
|
108
127
|
* calendar shared with it directly. Null means it always acts as itself.
|
|
109
128
|
*/
|
|
110
129
|
subjectVariable: Nullable<string>;
|
|
130
|
+
/**
|
|
131
|
+
* Where and how each request is signed. `HMAC_SIGNATURE` only, and required there.
|
|
132
|
+
*/
|
|
133
|
+
signature: Nullable<ConnectorRequestSignature>;
|
|
111
134
|
}
|
|
112
135
|
/** {@link ConnectorAuthManifest} as sent on create/update: nullable fields may simply be omitted. */
|
|
113
136
|
export interface ConnectorAuthManifestInput {
|
|
@@ -123,6 +146,7 @@ export interface ConnectorAuthManifestInput {
|
|
|
123
146
|
personAuthorizationParams?: Nullable<Record<string, string>>;
|
|
124
147
|
tokenObjectPaths?: Nullable<string[]>;
|
|
125
148
|
subjectVariable?: Nullable<string>;
|
|
149
|
+
signature?: Nullable<ConnectorRequestSignature>;
|
|
126
150
|
}
|
|
127
151
|
/**
|
|
128
152
|
* One thing a connector can be asked to do.
|
|
@@ -19,3 +19,10 @@ export const CONNECTOR_CREDENTIAL_REFRESH_TOKEN = 'refreshToken';
|
|
|
19
19
|
export const CONNECTOR_CREDENTIAL_CLIENT_EMAIL = 'clientEmail';
|
|
20
20
|
export const CONNECTOR_CREDENTIAL_PRIVATE_KEY = 'privateKey';
|
|
21
21
|
export const CONNECTOR_CREDENTIAL_PRIVATE_KEY_ID = 'privateKeyId';
|
|
22
|
+
/**
|
|
23
|
+
* Credential name an `HMAC_SIGNATURE` manifest signs with.
|
|
24
|
+
*
|
|
25
|
+
* Fixed for the same reason as the OAuth names: the scheme has exactly one secret, so a manifest
|
|
26
|
+
* that could rename it could only name it wrongly.
|
|
27
|
+
*/
|
|
28
|
+
export const CONNECTOR_CREDENTIAL_SECRET = 'secret';
|
|
@@ -4,6 +4,7 @@ export * from './connect.type.js';
|
|
|
4
4
|
export * from './connection-verification-verdict.enum.js';
|
|
5
5
|
export * from './connection.type.js';
|
|
6
6
|
export * from './connector-auth-type.enum.js';
|
|
7
|
+
export * from './connector-signature-format.enum.js';
|
|
7
8
|
export * from './connector.type.js';
|
|
8
9
|
export * from './delivery-status.enum.js';
|
|
9
10
|
export * from './delivery.type.js';
|
|
@@ -4,6 +4,7 @@ export * from './connect.type.js';
|
|
|
4
4
|
export * from './connection-verification-verdict.enum.js';
|
|
5
5
|
export * from './connection.type.js';
|
|
6
6
|
export * from './connector-auth-type.enum.js';
|
|
7
|
+
export * from './connector-signature-format.enum.js';
|
|
7
8
|
export * from './connector.type.js';
|
|
8
9
|
export * from './delivery-status.enum.js';
|
|
9
10
|
export * from './delivery.type.js';
|