@iveri/contracts 0.81.0 → 0.82.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.
- package/dist/api/chat/chat-app-conversation-mode.enum.d.ts +7 -0
- package/dist/api/chat/chat-app-conversation-mode.enum.js +8 -0
- package/dist/api/chat/chat-app.constant.d.ts +12 -0
- package/dist/api/chat/chat-app.constant.js +12 -0
- package/dist/api/chat/chat-app.type.d.ts +146 -0
- package/dist/api/chat/chat-app.type.js +1 -0
- package/dist/api/chat/chat-conversation.type.d.ts +12 -3
- package/dist/api/chat/chat-moderation.type.d.ts +2 -0
- package/dist/api/chat/chat-person.type.d.ts +4 -0
- package/dist/api/chat/index.d.ts +3 -0
- package/dist/api/chat/index.js +3 -0
- package/dist/enum/user-permission.enum.d.ts +6 -1
- package/dist/enum/user-permission.enum.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Who may start a conversation inside an outside app. */
|
|
2
|
+
export declare enum ChatAppConversationMode {
|
|
3
|
+
/** Only the app's server, through `PUT /server/conversations`. Its users use what it opened. */
|
|
4
|
+
SERVER = "server",
|
|
5
|
+
/** Its users too, naming each other by the app's own ids. There is no search and no contact list. */
|
|
6
|
+
USERS = "users"
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Who may start a conversation inside an outside app. */
|
|
2
|
+
export var ChatAppConversationMode;
|
|
3
|
+
(function (ChatAppConversationMode) {
|
|
4
|
+
/** Only the app's server, through `PUT /server/conversations`. Its users use what it opened. */
|
|
5
|
+
ChatAppConversationMode["SERVER"] = "server";
|
|
6
|
+
/** Its users too, naming each other by the app's own ids. There is no search and no contact list. */
|
|
7
|
+
ChatAppConversationMode["USERS"] = "users";
|
|
8
|
+
})(ChatAppConversationMode || (ChatAppConversationMode = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The `typ` claim of a socket ticket. A token without it is never read as a ticket. */
|
|
2
|
+
export declare const CHAT_SOCKET_TICKET_TYPE = "chat-socket";
|
|
3
|
+
/** What an app's secret looks like: this prefix, then 32 random bytes in base64url. */
|
|
4
|
+
export declare const CHAT_APP_SECRET_PREFIX = "bs_";
|
|
5
|
+
/** At most this many secrets of one app work at once, so a rotation never needs an outage and never piles up. */
|
|
6
|
+
export declare const CHAT_APP_MAX_ACTIVE_SECRETS = 2;
|
|
7
|
+
/** The longest an app's token may live, from `iat` to `exp`. */
|
|
8
|
+
export declare const CHAT_APP_TOKEN_MAX_TTL_SECONDS = 86400;
|
|
9
|
+
/** A minted token's lifetime when the server does not say. */
|
|
10
|
+
export declare const CHAT_APP_TOKEN_DEFAULT_TTL_SECONDS = 3600;
|
|
11
|
+
/** The longest id an app may give one of its users. */
|
|
12
|
+
export declare const CHAT_EXTERNAL_USER_ID_MAX_LENGTH = 255;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The `typ` claim of a socket ticket. A token without it is never read as a ticket. */
|
|
2
|
+
export const CHAT_SOCKET_TICKET_TYPE = 'chat-socket';
|
|
3
|
+
/** What an app's secret looks like: this prefix, then 32 random bytes in base64url. */
|
|
4
|
+
export const CHAT_APP_SECRET_PREFIX = 'bs_';
|
|
5
|
+
/** At most this many secrets of one app work at once, so a rotation never needs an outage and never piles up. */
|
|
6
|
+
export const CHAT_APP_MAX_ACTIVE_SECRETS = 2;
|
|
7
|
+
/** The longest an app's token may live, from `iat` to `exp`. */
|
|
8
|
+
export const CHAT_APP_TOKEN_MAX_TTL_SECONDS = 86_400;
|
|
9
|
+
/** A minted token's lifetime when the server does not say. */
|
|
10
|
+
export const CHAT_APP_TOKEN_DEFAULT_TTL_SECONDS = 3_600;
|
|
11
|
+
/** The longest id an app may give one of its users. */
|
|
12
|
+
export const CHAT_EXTERNAL_USER_ID_MAX_LENGTH = 255;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { IsoDateTime } from '../../type/iso-date-time.type.js';
|
|
2
|
+
import type { Nullable } from '../../type/nil.type.js';
|
|
3
|
+
import type { UUID } from '../../type/uuid.type.js';
|
|
4
|
+
import type { ChatAppConversationMode } from './chat-app-conversation-mode.enum.js';
|
|
5
|
+
import type { CHAT_SOCKET_TICKET_TYPE } from './chat-app.constant.js';
|
|
6
|
+
import type { EmbeddedChatParticipant, OpenEmbeddedChatRequest } from './chat-embed.type.js';
|
|
7
|
+
import type { ChatMessageKind } from './chat-message-kind.enum.js';
|
|
8
|
+
import type { ChatPersonStatus } from './chat-person-status.enum.js';
|
|
9
|
+
/**
|
|
10
|
+
* Baasi inside another company's product. An app is its own Baasi tenant, so its users, conversations and
|
|
11
|
+
* moderation queue are kept apart from every other app's, and its id is the `iss` of every token signed for it.
|
|
12
|
+
*/
|
|
13
|
+
export interface ChatApp {
|
|
14
|
+
id: UUID;
|
|
15
|
+
name: string;
|
|
16
|
+
conversationMode: ChatAppConversationMode;
|
|
17
|
+
/** Tokens signed before this moment are refused, for every user of the app. */
|
|
18
|
+
tokensNotBefore: Nullable<IsoDateTime>;
|
|
19
|
+
secrets: ChatAppSecretSummary[];
|
|
20
|
+
createdAt: IsoDateTime;
|
|
21
|
+
updatedAt: IsoDateTime;
|
|
22
|
+
}
|
|
23
|
+
/** A secret as it is listed afterwards: never the value, only enough to tell two apart. */
|
|
24
|
+
export interface ChatAppSecretSummary {
|
|
25
|
+
id: UUID;
|
|
26
|
+
/** The last four characters, so a person can tell which one a server holds. */
|
|
27
|
+
hint: string;
|
|
28
|
+
createdAt: IsoDateTime;
|
|
29
|
+
revokedAt: Nullable<IsoDateTime>;
|
|
30
|
+
}
|
|
31
|
+
/** `POST /apps/:appId/secrets`. The only answer that ever holds the value: it is not stored readable. */
|
|
32
|
+
export interface CreatedChatAppSecret extends ChatAppSecretSummary {
|
|
33
|
+
/** `bs_` and 32 random bytes in base64url. */
|
|
34
|
+
secret: string;
|
|
35
|
+
}
|
|
36
|
+
export interface CreateChatAppRequest {
|
|
37
|
+
name: string;
|
|
38
|
+
/** Omitted means `server`: only the company's server opens conversations. */
|
|
39
|
+
conversationMode?: ChatAppConversationMode;
|
|
40
|
+
}
|
|
41
|
+
export interface UpdateChatAppRequest {
|
|
42
|
+
name?: string;
|
|
43
|
+
conversationMode?: ChatAppConversationMode;
|
|
44
|
+
}
|
|
45
|
+
/** `PUT /server/users/:userId`, where `userId` is the app's own id for the person. */
|
|
46
|
+
export interface UpsertChatAppUserRequest {
|
|
47
|
+
displayName: string;
|
|
48
|
+
/** An address the app already serves publicly. `null` removes it. */
|
|
49
|
+
avatarUrl?: Nullable<string>;
|
|
50
|
+
}
|
|
51
|
+
/** A user of an app, as its server sees them. */
|
|
52
|
+
export interface ChatAppUser {
|
|
53
|
+
/** Baasi's own id for them, which every conversation and message names. */
|
|
54
|
+
userId: UUID;
|
|
55
|
+
externalId: string;
|
|
56
|
+
displayName: Nullable<string>;
|
|
57
|
+
avatarUrl: Nullable<string>;
|
|
58
|
+
status: ChatPersonStatus;
|
|
59
|
+
/** Their tokens signed before this moment are refused. */
|
|
60
|
+
tokensNotBefore: Nullable<IsoDateTime>;
|
|
61
|
+
createdAt: IsoDateTime;
|
|
62
|
+
}
|
|
63
|
+
/** `POST /server/tokens`. For a company that would rather not sign a token itself. */
|
|
64
|
+
export interface MintChatTokenRequest {
|
|
65
|
+
/** The app's own id for the person, 1 to 255 characters. */
|
|
66
|
+
userId: string;
|
|
67
|
+
/** Omitted means an hour. At most a day. */
|
|
68
|
+
ttlSeconds?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface ChatToken {
|
|
71
|
+
token: string;
|
|
72
|
+
expiresAt: IsoDateTime;
|
|
73
|
+
}
|
|
74
|
+
/** A participant as an app's server names them: by the app's own id for the person, 1 to 255 characters. */
|
|
75
|
+
export type ServerChatParticipant = Omit<EmbeddedChatParticipant, 'userId'> & {
|
|
76
|
+
userId: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* `PUT /server/conversations`: the embed request, with each participant named by the app's own id for them rather
|
|
80
|
+
* than a Baasi id.
|
|
81
|
+
*/
|
|
82
|
+
export type OpenServerChatRequest = Omit<OpenEmbeddedChatRequest, 'participants'> & {
|
|
83
|
+
participants: ServerChatParticipant[];
|
|
84
|
+
};
|
|
85
|
+
/** `GET /server/users/:userId/export`: everything Baasi holds about one user of an app. */
|
|
86
|
+
export interface ChatAppUserExport {
|
|
87
|
+
user: ChatAppUser;
|
|
88
|
+
conversations: ChatAppUserExportConversation[];
|
|
89
|
+
messages: ChatAppUserExportMessage[];
|
|
90
|
+
reactions: ChatAppUserExportReaction[];
|
|
91
|
+
devices: ChatAppUserExportDevice[];
|
|
92
|
+
exportedAt: IsoDateTime;
|
|
93
|
+
}
|
|
94
|
+
export interface ChatAppUserExportConversation {
|
|
95
|
+
conversationId: UUID;
|
|
96
|
+
kind: string;
|
|
97
|
+
title: Nullable<string>;
|
|
98
|
+
context: Nullable<{
|
|
99
|
+
product: string;
|
|
100
|
+
type: string;
|
|
101
|
+
id: string;
|
|
102
|
+
}>;
|
|
103
|
+
status: string;
|
|
104
|
+
joinedAt: IsoDateTime;
|
|
105
|
+
}
|
|
106
|
+
export interface ChatAppUserExportMessage {
|
|
107
|
+
messageId: UUID;
|
|
108
|
+
conversationId: UUID;
|
|
109
|
+
seq: number;
|
|
110
|
+
kind: ChatMessageKind;
|
|
111
|
+
text: Nullable<string>;
|
|
112
|
+
attachmentCount: number;
|
|
113
|
+
sentAt: IsoDateTime;
|
|
114
|
+
editedAt: Nullable<IsoDateTime>;
|
|
115
|
+
deletedAt: Nullable<IsoDateTime>;
|
|
116
|
+
}
|
|
117
|
+
export interface ChatAppUserExportReaction {
|
|
118
|
+
messageId: UUID;
|
|
119
|
+
emoji: string;
|
|
120
|
+
reactedAt: IsoDateTime;
|
|
121
|
+
}
|
|
122
|
+
export interface ChatAppUserExportDevice {
|
|
123
|
+
installationId: string;
|
|
124
|
+
platform: string;
|
|
125
|
+
locale: Nullable<string>;
|
|
126
|
+
registeredAt: IsoDateTime;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* `POST /realtime/ticket`. What a socket presents to `chat-realtime` when the person signed in with an app's token,
|
|
130
|
+
* so the app's secret stays in `chat-api`.
|
|
131
|
+
*/
|
|
132
|
+
export interface ChatSocketTicket {
|
|
133
|
+
ticket: string;
|
|
134
|
+
/** The presented token's own expiry: a ticket never outlives what it was traded for. */
|
|
135
|
+
expiresAt: IsoDateTime;
|
|
136
|
+
}
|
|
137
|
+
/** A socket ticket's claims, signed HS256 with the secret `chat-api` and `chat-realtime` share. */
|
|
138
|
+
export interface ChatSocketTicketClaims {
|
|
139
|
+
typ: typeof CHAT_SOCKET_TICKET_TYPE;
|
|
140
|
+
/** The tenant: an app's id, or an Iveri tenant. */
|
|
141
|
+
tid: UUID;
|
|
142
|
+
/** The person's Baasi id. */
|
|
143
|
+
sub: UUID;
|
|
144
|
+
iat: number;
|
|
145
|
+
exp: number;
|
|
146
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -103,20 +103,29 @@ export interface ChatInboxPage {
|
|
|
103
103
|
}
|
|
104
104
|
/** What `GET /conversations` can be narrowed to. */
|
|
105
105
|
export type ChatInboxFolder = 'inbox' | 'requests' | 'archived';
|
|
106
|
+
/**
|
|
107
|
+
* Exactly one of the two. Inside an outside app that lets its users start conversations, a person names the
|
|
108
|
+
* other by the app's own id for them, since that is the only id the app knows.
|
|
109
|
+
*/
|
|
106
110
|
export interface StartDirectChatRequest {
|
|
107
|
-
userId
|
|
111
|
+
userId?: UUID;
|
|
112
|
+
externalUserId?: string;
|
|
108
113
|
}
|
|
114
|
+
/** Exactly one of the two lists, as with {@link StartDirectChatRequest}. */
|
|
109
115
|
export interface CreateGroupChatRequest {
|
|
110
116
|
title: string;
|
|
111
|
-
memberUserIds
|
|
117
|
+
memberUserIds?: UUID[];
|
|
118
|
+
memberExternalIds?: string[];
|
|
112
119
|
}
|
|
113
120
|
export interface UpdateGroupChatRequest {
|
|
114
121
|
title?: string;
|
|
115
122
|
/** An uploaded photo attachment. `null` removes the photograph. */
|
|
116
123
|
avatarAttachmentId?: Nullable<UUID>;
|
|
117
124
|
}
|
|
125
|
+
/** Exactly one of the two lists, as with {@link StartDirectChatRequest}. */
|
|
118
126
|
export interface AddChatMembersRequest {
|
|
119
|
-
userIds
|
|
127
|
+
userIds?: UUID[];
|
|
128
|
+
externalUserIds?: string[];
|
|
120
129
|
}
|
|
121
130
|
export interface UpdateChatMemberRequest {
|
|
122
131
|
role: ChatParticipantRole;
|
|
@@ -75,6 +75,8 @@ export interface DecideChatCaseRequest {
|
|
|
75
75
|
export interface ChatStaffPerson {
|
|
76
76
|
userId: UUID;
|
|
77
77
|
tenantId: UUID;
|
|
78
|
+
/** The id an outside app knows this person by. Null for everybody signed in through Iveri. */
|
|
79
|
+
externalId: Nullable<string>;
|
|
78
80
|
handle: Nullable<string>;
|
|
79
81
|
displayName: Nullable<string>;
|
|
80
82
|
status: ChatPersonStatus;
|
|
@@ -6,6 +6,8 @@ import type { ChatPersonStatus } from './chat-person-status.enum.js';
|
|
|
6
6
|
/** Somebody as another person sees them. Nothing here is an email address or a phone number. */
|
|
7
7
|
export interface ChatPersonCard {
|
|
8
8
|
userId: UUID;
|
|
9
|
+
/** The id an outside app knows this person by. Null for everybody signed in through Iveri. */
|
|
10
|
+
externalId: Nullable<string>;
|
|
9
11
|
displayName: string;
|
|
10
12
|
/** Only in the Baasi network. A person inside a product has none. */
|
|
11
13
|
handle: Nullable<string>;
|
|
@@ -22,6 +24,8 @@ export interface ChatSettings {
|
|
|
22
24
|
/** The signed-in person's own profile. */
|
|
23
25
|
export interface ChatProfile {
|
|
24
26
|
userId: UUID;
|
|
27
|
+
/** The id an outside app knows me by. Null for everybody signed in through Iveri. */
|
|
28
|
+
externalId: Nullable<string>;
|
|
25
29
|
/** True in the Baasi tenant. Elsewhere a person only uses conversations their product opened. */
|
|
26
30
|
isNetwork: boolean;
|
|
27
31
|
/** False until a Baasi person has chosen a handle and a name. */
|
package/dist/api/chat/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export * from './chat-app-conversation-mode.enum.js';
|
|
2
|
+
export * from './chat-app.constant.js';
|
|
3
|
+
export * from './chat-app.type.js';
|
|
1
4
|
export * from './chat-attachment-kind.enum.js';
|
|
2
5
|
export * from './chat-attachment.type.js';
|
|
3
6
|
export * from './chat-case-decision.enum.js';
|
package/dist/api/chat/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export * from './chat-app-conversation-mode.enum.js';
|
|
2
|
+
export * from './chat-app.constant.js';
|
|
3
|
+
export * from './chat-app.type.js';
|
|
1
4
|
export * from './chat-attachment-kind.enum.js';
|
|
2
5
|
export * from './chat-attachment.type.js';
|
|
3
6
|
export * from './chat-case-decision.enum.js';
|
|
@@ -608,7 +608,12 @@ export declare enum UserPermission {
|
|
|
608
608
|
/** Suspend, ban or reinstate somebody without a report behind it. */
|
|
609
609
|
CHAT_PERSON_SANCTION = "chat:person:sanction",
|
|
610
610
|
/** Read the record of what staff looked at and did. */
|
|
611
|
-
CHAT_AUDIT_READ = "chat:audit:read"
|
|
611
|
+
CHAT_AUDIT_READ = "chat:audit:read",
|
|
612
|
+
/**
|
|
613
|
+
* Run Baasi inside another company's product: create its apps, issue and revoke their secrets, change who may
|
|
614
|
+
* start conversations, and refuse tokens signed before a moment. Held by that company's own staff.
|
|
615
|
+
*/
|
|
616
|
+
CHAT_APP_MANAGE = "chat:app:manage"
|
|
612
617
|
}
|
|
613
618
|
/**
|
|
614
619
|
* Every member, for seeding the owner role and validating custom-role input.
|
|
@@ -674,6 +674,11 @@ export var UserPermission;
|
|
|
674
674
|
UserPermission["CHAT_PERSON_SANCTION"] = "chat:person:sanction";
|
|
675
675
|
/** Read the record of what staff looked at and did. */
|
|
676
676
|
UserPermission["CHAT_AUDIT_READ"] = "chat:audit:read";
|
|
677
|
+
/**
|
|
678
|
+
* Run Baasi inside another company's product: create its apps, issue and revoke their secrets, change who may
|
|
679
|
+
* start conversations, and refuse tokens signed before a moment. Held by that company's own staff.
|
|
680
|
+
*/
|
|
681
|
+
UserPermission["CHAT_APP_MANAGE"] = "chat:app:manage";
|
|
677
682
|
})(UserPermission || (UserPermission = {}));
|
|
678
683
|
/**
|
|
679
684
|
* Every member, for seeding the owner role and validating custom-role input.
|