@celljs/ta-host 4.13.1 → 4.15.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/README.en.md +3 -1
- package/README.md +3 -1
- package/esm/node/auth-server-impl.d.ts +12 -2
- package/esm/node/auth-server-impl.js +102 -3
- package/esm/node/custom-providers.d.ts +50 -0
- package/esm/node/custom-providers.js +335 -0
- package/esm/node/host-protocol.d.ts +17 -1
- package/esm/node/host-protocol.js +1 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/node/package-hosts.d.ts +2 -1
- package/esm/node/package-hosts.js +6 -2
- package/esm/node/presence-book.d.ts +38 -0
- package/esm/node/presence-book.js +159 -0
- package/esm/node/presence-server-impl.d.ts +13 -0
- package/esm/node/presence-server-impl.js +45 -0
- package/esm/node/rooms-bridge.d.ts +6 -1
- package/esm/node/rooms-bridge.js +21 -3
- package/esm/node/session-list-feed.js +2 -1
- package/esm/node/sign-in/access-server-impl.d.ts +5 -1
- package/esm/node/sign-in/access-server-impl.js +22 -1
- package/esm/node/sign-in/sign-in-flow.d.ts +14 -1
- package/esm/node/sign-in/sign-in-flow.js +24 -7
- package/esm/node/sign-in/sign-in-provider.d.ts +84 -1
- package/esm/node/sign-in/sign-in-provider.js +194 -7
- package/esm/node/sign-in/ta-sign-in.d.ts +12 -3
- package/esm/node/sign-in/ta-sign-in.js +36 -4
- package/esm/node/ta-server-impl.d.ts +7 -0
- package/esm/node/ta-server-impl.js +44 -7
- package/esm/node/ta-session-registry.d.ts +10 -3
- package/esm/node/ta-session-registry.js +29 -3
- package/esm/node/ta-session.d.ts +2 -0
- package/esm/node/ta-session.js +6 -0
- package/esm/node/team/host-team.d.ts +2 -1
- package/esm/node/team/host-team.js +11 -1
- package/esm/node/team/index.d.ts +1 -0
- package/esm/node/team/index.js +1 -0
- package/esm/node/team/member-accounts.d.ts +30 -0
- package/esm/node/team/member-accounts.js +117 -0
- package/esm/node/team/team-calls.d.ts +2 -1
- package/esm/node/team/team-calls.js +11 -0
- package/esm/node/team/team-gate.js +1 -1
- package/esm/node/team/team-protocol.d.ts +5 -1
- package/esm/node/team/team-protocol.js +2 -0
- package/esm/node/web-extension-util.js +1 -0
- package/lib/node/auth-server-impl.d.ts +12 -2
- package/lib/node/auth-server-impl.js +101 -2
- package/lib/node/custom-providers.d.ts +51 -0
- package/lib/node/custom-providers.js +338 -0
- package/lib/node/host-protocol.d.ts +17 -1
- package/lib/node/host-protocol.js +2 -1
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.js +2 -0
- package/lib/node/package-hosts.d.ts +2 -1
- package/lib/node/package-hosts.js +5 -1
- package/lib/node/presence-book.d.ts +39 -0
- package/lib/node/presence-book.js +162 -0
- package/lib/node/presence-server-impl.d.ts +14 -0
- package/lib/node/presence-server-impl.js +48 -0
- package/lib/node/rooms-bridge.d.ts +6 -1
- package/lib/node/rooms-bridge.js +20 -2
- package/lib/node/session-list-feed.js +2 -1
- package/lib/node/sign-in/access-server-impl.d.ts +5 -1
- package/lib/node/sign-in/access-server-impl.js +21 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +14 -1
- package/lib/node/sign-in/sign-in-flow.js +24 -7
- package/lib/node/sign-in/sign-in-provider.d.ts +84 -1
- package/lib/node/sign-in/sign-in-provider.js +197 -9
- package/lib/node/sign-in/ta-sign-in.d.ts +12 -3
- package/lib/node/sign-in/ta-sign-in.js +36 -4
- package/lib/node/ta-server-impl.d.ts +7 -0
- package/lib/node/ta-server-impl.js +43 -6
- package/lib/node/ta-session-registry.d.ts +10 -3
- package/lib/node/ta-session-registry.js +27 -1
- package/lib/node/ta-session.d.ts +2 -0
- package/lib/node/ta-session.js +6 -0
- package/lib/node/team/host-team.d.ts +2 -1
- package/lib/node/team/host-team.js +10 -0
- package/lib/node/team/index.d.ts +1 -0
- package/lib/node/team/index.js +1 -0
- package/lib/node/team/member-accounts.d.ts +31 -0
- package/lib/node/team/member-accounts.js +120 -0
- package/lib/node/team/team-calls.d.ts +2 -1
- package/lib/node/team/team-calls.js +11 -0
- package/lib/node/team/team-gate.js +1 -1
- package/lib/node/team/team-protocol.d.ts +5 -1
- package/lib/node/team/team-protocol.js +3 -1
- package/lib/node/web-extension-util.js +1 -0
- package/package.json +12 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TaSignInProvider } from '@celljs/ta-protocol';
|
|
1
|
+
import type { TaSignInKind, TaSignInProvider, TaSignInSetup } from '@celljs/ta-protocol';
|
|
2
2
|
/** Who signed in, as the provider says: `id` is the account as TA_ALLOWED_USERS names it (`github:<login>`). */
|
|
3
3
|
export interface SignInAccount {
|
|
4
4
|
id: string;
|
|
@@ -36,6 +36,8 @@ export interface GitHubEndpoints {
|
|
|
36
36
|
authorize: string;
|
|
37
37
|
token: string;
|
|
38
38
|
user: string;
|
|
39
|
+
/** Where a code to type is asked for (the device flow). */
|
|
40
|
+
device: string;
|
|
39
41
|
}
|
|
40
42
|
/** GitHub's OAuth apps; the account is `github:<login>`. GitHub Enterprise Server has the same at its own address. */
|
|
41
43
|
export declare class GitHubSignIn implements SignInProvider {
|
|
@@ -45,6 +47,8 @@ export declare class GitHubSignIn implements SignInProvider {
|
|
|
45
47
|
readonly id = "github";
|
|
46
48
|
readonly name = "GitHub";
|
|
47
49
|
static endpoints(url?: string): GitHubEndpoints;
|
|
50
|
+
/** Who a token of GitHub is. */
|
|
51
|
+
static user(endpoints: GitHubEndpoints, token: string): Promise<SignInAccount>;
|
|
48
52
|
constructor(clientId: string, clientSecret: string, endpoints?: GitHubEndpoints);
|
|
49
53
|
authorizeUrl({ redirectUri, state, challenge }: {
|
|
50
54
|
redirectUri: string;
|
|
@@ -57,6 +61,40 @@ export declare class GitHubSignIn implements SignInProvider {
|
|
|
57
61
|
verifier: string;
|
|
58
62
|
}): Promise<SignInAccount>;
|
|
59
63
|
}
|
|
64
|
+
/** A code to type at the provider, and how often to ask whether it was (OAuth 2.0's device authorization, RFC 8628). */
|
|
65
|
+
export interface DeviceCode {
|
|
66
|
+
deviceCode: string;
|
|
67
|
+
userCode: string;
|
|
68
|
+
uri: string;
|
|
69
|
+
/** Seconds between asks. */
|
|
70
|
+
interval: number;
|
|
71
|
+
/** Seconds the code is good for. */
|
|
72
|
+
expiresIn: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A provider one signs in with by typing a code at it, the device flow: no secret and no address to come back to, so
|
|
76
|
+
* Ta ships one of its own and anyone's Ta knows who asks to come in without setting anything up (TaHostAccounts). It
|
|
77
|
+
* lets no one into ta serve: that is SignInFlow, with a provider of the operator's.
|
|
78
|
+
*/
|
|
79
|
+
export interface DeviceSignInProvider extends TaSignInProvider {
|
|
80
|
+
readonly device: true;
|
|
81
|
+
code(): Promise<DeviceCode>;
|
|
82
|
+
/** The account once the code was typed and agreed to; `pending` while not yet, `slowDown` when asked too often. */
|
|
83
|
+
poll(deviceCode: string): Promise<SignInAccount | 'pending' | 'slowDown'>;
|
|
84
|
+
}
|
|
85
|
+
/** GitHub's device flow, with Ta's own OAuth app by default; the account is `github:<login>`, as GitHubSignIn's. */
|
|
86
|
+
export declare class GitHubDeviceSignIn implements DeviceSignInProvider {
|
|
87
|
+
protected readonly clientId: string;
|
|
88
|
+
protected readonly endpoints: GitHubEndpoints;
|
|
89
|
+
readonly id = "github";
|
|
90
|
+
readonly name = "GitHub";
|
|
91
|
+
readonly device: true;
|
|
92
|
+
/** Ta's own OAuth app on GitHub.com, its device flow on: a client id is public, and the device flow needs no secret. */
|
|
93
|
+
static readonly CLIENT_ID = "Ov23lip46sRQDlDM1xt7";
|
|
94
|
+
constructor(clientId?: string, endpoints?: GitHubEndpoints);
|
|
95
|
+
code(): Promise<DeviceCode>;
|
|
96
|
+
poll(deviceCode: string): Promise<SignInAccount | 'pending' | 'slowDown'>;
|
|
97
|
+
}
|
|
60
98
|
interface OidcConfiguration {
|
|
61
99
|
authorization_endpoint: string;
|
|
62
100
|
token_endpoint: string;
|
|
@@ -126,6 +164,51 @@ export declare class WeChatSignIn implements SignInProvider {
|
|
|
126
164
|
export declare namespace SignInProviders {
|
|
127
165
|
/** TA_PUBLIC_URL without its trailing `/`. */
|
|
128
166
|
function publicUrl(env: Record<string, string | undefined>): string | undefined;
|
|
167
|
+
/** Each kind of provider: its name, its fields in sign-in.json with the variable of the environment of each, and its secret's. */
|
|
168
|
+
const KINDS: readonly {
|
|
169
|
+
id: TaSignInKind;
|
|
170
|
+
name: string;
|
|
171
|
+
fields: Record<string, string>;
|
|
172
|
+
required: string[];
|
|
173
|
+
secret: [string, string];
|
|
174
|
+
}[];
|
|
175
|
+
/** How each kind is set up, by the environment first, then sign-in.json; no secret in it. */
|
|
176
|
+
function setups(env: Record<string, string | undefined>, config: Config | undefined): TaSignInSetup[];
|
|
177
|
+
/**
|
|
178
|
+
* sign-in.json with a kind set up anew (`null`: taken out): the fields given, trimmed; an empty secret keeps the
|
|
179
|
+
* one kept. Throws for a kind it does not know, or one without what it needs.
|
|
180
|
+
*/
|
|
181
|
+
function withProvider(config: Config | undefined, id: string, input: Record<string, unknown> | null): Config;
|
|
182
|
+
/** sign-in.json of the agent directory: the same providers as the environment, for a Ta not started from a shell. */
|
|
183
|
+
interface Config {
|
|
184
|
+
github?: {
|
|
185
|
+
clientId?: string;
|
|
186
|
+
clientSecret?: string;
|
|
187
|
+
url?: string;
|
|
188
|
+
};
|
|
189
|
+
google?: {
|
|
190
|
+
clientId?: string;
|
|
191
|
+
clientSecret?: string;
|
|
192
|
+
};
|
|
193
|
+
wechat?: {
|
|
194
|
+
appId?: string;
|
|
195
|
+
appSecret?: string;
|
|
196
|
+
};
|
|
197
|
+
oidc?: {
|
|
198
|
+
issuer?: string;
|
|
199
|
+
clientId?: string;
|
|
200
|
+
clientSecret?: string;
|
|
201
|
+
name?: string;
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/** The environment's variables that sign-in.json stands for: what the environment sets wins. */
|
|
205
|
+
function withConfig(env: Record<string, string | undefined>, config: Config | undefined): Record<string, string | undefined>;
|
|
206
|
+
/**
|
|
207
|
+
* GitHub by a code, for those asking to come in, when GitHub is not set up with its secret (which goes there and back
|
|
208
|
+
* instead): `TA_GITHUB_DEVICE` is `off`, or `<client id>` or `<client id>@<address of GitHub>` of an OAuth app of
|
|
209
|
+
* one's own with its device flow on; by default Ta's own, on GitHub.com.
|
|
210
|
+
*/
|
|
211
|
+
function device(env: Record<string, string | undefined>): DeviceSignInProvider | undefined;
|
|
129
212
|
/**
|
|
130
213
|
* The providers the operator configured in the environment of ta serve: a provider is offered when it
|
|
131
214
|
* has its id and its secret.
|
|
@@ -44,7 +44,22 @@ export class GitHubSignIn {
|
|
|
44
44
|
static endpoints(url = 'https://github.com') {
|
|
45
45
|
const base = url.replace(/\/+$/, '');
|
|
46
46
|
const api = base === 'https://github.com' ? 'https://api.github.com' : `${base}/api/v3`;
|
|
47
|
-
return {
|
|
47
|
+
return {
|
|
48
|
+
authorize: `${base}/login/oauth/authorize`,
|
|
49
|
+
token: `${base}/login/oauth/access_token`,
|
|
50
|
+
user: `${api}/user`,
|
|
51
|
+
device: `${base}/login/device/code`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Who a token of GitHub is. */
|
|
55
|
+
static async user(endpoints, token) {
|
|
56
|
+
const user = await SignInHttp.json(endpoints.user, {
|
|
57
|
+
headers: { Authorization: `Bearer ${token}`, Accept: 'application/vnd.github+json', 'User-Agent': 'Ta' },
|
|
58
|
+
});
|
|
59
|
+
if (!user.login) {
|
|
60
|
+
throw new SignInError('GitHub: the user has no login');
|
|
61
|
+
}
|
|
62
|
+
return { id: `github:${user.login.toLowerCase()}`, name: user.name || user.login, avatar: user.avatar_url };
|
|
48
63
|
}
|
|
49
64
|
constructor(clientId, clientSecret, endpoints = GitHubSignIn.endpoints()) {
|
|
50
65
|
this.clientId = clientId;
|
|
@@ -70,15 +85,49 @@ export class GitHubSignIn {
|
|
|
70
85
|
if (!token.access_token) {
|
|
71
86
|
throw new SignInError(`GitHub: ${(_b = (_a = token.error_description) !== null && _a !== void 0 ? _a : token.error) !== null && _b !== void 0 ? _b : 'no access token'}`);
|
|
72
87
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
return GitHubSignIn.user(this.endpoints, token.access_token);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** GitHub's device flow, with Ta's own OAuth app by default; the account is `github:<login>`, as GitHubSignIn's. */
|
|
92
|
+
export class GitHubDeviceSignIn {
|
|
93
|
+
constructor(clientId = GitHubDeviceSignIn.CLIENT_ID, endpoints = GitHubSignIn.endpoints()) {
|
|
94
|
+
this.clientId = clientId;
|
|
95
|
+
this.endpoints = endpoints;
|
|
96
|
+
this.id = 'github';
|
|
97
|
+
this.name = 'GitHub';
|
|
98
|
+
this.device = true;
|
|
99
|
+
}
|
|
100
|
+
async code() {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
const answer = await SignInHttp.json(this.endpoints.device, SignInHttp.form({ client_id: this.clientId, scope: 'read:user' }));
|
|
103
|
+
if (!answer.device_code || !answer.user_code || !answer.verification_uri || !/^https?:\/\//.test(answer.verification_uri)) {
|
|
104
|
+
throw new SignInError(`GitHub: ${(_b = (_a = answer.error_description) !== null && _a !== void 0 ? _a : answer.error) !== null && _b !== void 0 ? _b : 'no code'}`);
|
|
78
105
|
}
|
|
79
|
-
return {
|
|
106
|
+
return {
|
|
107
|
+
deviceCode: answer.device_code,
|
|
108
|
+
userCode: answer.user_code,
|
|
109
|
+
uri: answer.verification_uri,
|
|
110
|
+
interval: Number((_c = answer.interval) !== null && _c !== void 0 ? _c : 5),
|
|
111
|
+
expiresIn: Number((_d = answer.expires_in) !== null && _d !== void 0 ? _d : 900),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async poll(deviceCode) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const token = await SignInHttp.json(this.endpoints.token, SignInHttp.form({ client_id: this.clientId, device_code: deviceCode, grant_type: 'urn:ietf:params:oauth:grant-type:device_code' }));
|
|
117
|
+
if (token.access_token) {
|
|
118
|
+
return GitHubSignIn.user(this.endpoints, token.access_token);
|
|
119
|
+
}
|
|
120
|
+
if (token.error === 'authorization_pending') {
|
|
121
|
+
return 'pending';
|
|
122
|
+
}
|
|
123
|
+
if (token.error === 'slow_down') {
|
|
124
|
+
return 'slowDown';
|
|
125
|
+
}
|
|
126
|
+
throw new SignInError(`GitHub: ${(_b = (_a = token.error_description) !== null && _a !== void 0 ? _a : token.error) !== null && _b !== void 0 ? _b : 'no access token'}`);
|
|
80
127
|
}
|
|
81
128
|
}
|
|
129
|
+
/** Ta's own OAuth app on GitHub.com, its device flow on: a client id is public, and the device flow needs no secret. */
|
|
130
|
+
GitHubDeviceSignIn.CLIENT_ID = 'Ov23lip46sRQDlDM1xt7';
|
|
82
131
|
/**
|
|
83
132
|
* OpenID Connect, found from the issuer (`/.well-known/openid-configuration`): Google, and the provider of
|
|
84
133
|
* the operator (Microsoft Entra, Okta, Keycloak, Authing...). The account is `<id>:<email>` when the
|
|
@@ -195,6 +244,144 @@ export var SignInProviders;
|
|
|
195
244
|
return ((_a = env.TA_PUBLIC_URL) === null || _a === void 0 ? void 0 : _a.trim().replace(/\/+$/, '')) || undefined;
|
|
196
245
|
}
|
|
197
246
|
SignInProviders.publicUrl = publicUrl;
|
|
247
|
+
/** Each kind of provider: its name, its fields in sign-in.json with the variable of the environment of each, and its secret's. */
|
|
248
|
+
SignInProviders.KINDS = [
|
|
249
|
+
{
|
|
250
|
+
id: 'github',
|
|
251
|
+
name: 'GitHub',
|
|
252
|
+
fields: { clientId: 'TA_GITHUB_CLIENT_ID', url: 'TA_GITHUB_URL' },
|
|
253
|
+
required: ['clientId'],
|
|
254
|
+
secret: ['clientSecret', 'TA_GITHUB_CLIENT_SECRET'],
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
id: 'google',
|
|
258
|
+
name: 'Google',
|
|
259
|
+
fields: { clientId: 'TA_GOOGLE_CLIENT_ID' },
|
|
260
|
+
required: ['clientId'],
|
|
261
|
+
secret: ['clientSecret', 'TA_GOOGLE_CLIENT_SECRET'],
|
|
262
|
+
},
|
|
263
|
+
{ id: 'wechat', name: 'WeChat', fields: { appId: 'TA_WECHAT_APP_ID' }, required: ['appId'], secret: ['appSecret', 'TA_WECHAT_APP_SECRET'] },
|
|
264
|
+
{
|
|
265
|
+
id: 'oidc',
|
|
266
|
+
name: 'SSO',
|
|
267
|
+
fields: { issuer: 'TA_OIDC_ISSUER', clientId: 'TA_OIDC_CLIENT_ID', name: 'TA_OIDC_NAME' },
|
|
268
|
+
required: ['issuer', 'clientId'],
|
|
269
|
+
secret: ['clientSecret', 'TA_OIDC_CLIENT_SECRET'],
|
|
270
|
+
},
|
|
271
|
+
];
|
|
272
|
+
/** How each kind is set up, by the environment first, then sign-in.json; no secret in it. */
|
|
273
|
+
function setups(env, config) {
|
|
274
|
+
return SignInProviders.KINDS.map(kind => {
|
|
275
|
+
var _a;
|
|
276
|
+
const file = ((_a = config === null || config === void 0 ? void 0 : config[kind.id]) !== null && _a !== void 0 ? _a : {});
|
|
277
|
+
const fromEnv = !!env[kind.secret[1]] || Object.values(kind.fields).some(key => !!env[key]);
|
|
278
|
+
const value = (field) => (fromEnv ? env[kind.fields[field]] : typeof file[field] === 'string' ? file[field] : undefined);
|
|
279
|
+
const fields = {};
|
|
280
|
+
for (const field of Object.keys(kind.fields)) {
|
|
281
|
+
const one = value(field);
|
|
282
|
+
if (one) {
|
|
283
|
+
fields[field] = one;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
const secret = fromEnv ? !!env[kind.secret[1]] : typeof file[kind.secret[0]] === 'string' && !!file[kind.secret[0]];
|
|
287
|
+
const configured = secret && kind.required.every(field => !!fields[field]);
|
|
288
|
+
const any = fromEnv || Object.keys(fields).length > 0 || secret;
|
|
289
|
+
return {
|
|
290
|
+
id: kind.id,
|
|
291
|
+
name: kind.id === 'oidc' && fields.name ? fields.name : kind.name,
|
|
292
|
+
configured,
|
|
293
|
+
...(any ? { source: fromEnv ? 'env' : 'file' } : {}),
|
|
294
|
+
fields,
|
|
295
|
+
secret,
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
SignInProviders.setups = setups;
|
|
300
|
+
/**
|
|
301
|
+
* sign-in.json with a kind set up anew (`null`: taken out): the fields given, trimmed; an empty secret keeps the
|
|
302
|
+
* one kept. Throws for a kind it does not know, or one without what it needs.
|
|
303
|
+
*/
|
|
304
|
+
function withProvider(config, id, input) {
|
|
305
|
+
var _a;
|
|
306
|
+
const kind = SignInProviders.KINDS.find(one => one.id === id);
|
|
307
|
+
if (!kind) {
|
|
308
|
+
throw new SignInError(`No such way to sign in: ${id}`);
|
|
309
|
+
}
|
|
310
|
+
const next = { ...(config !== null && config !== void 0 ? config : {}) };
|
|
311
|
+
if (!input) {
|
|
312
|
+
delete next[kind.id];
|
|
313
|
+
return next;
|
|
314
|
+
}
|
|
315
|
+
const kept = ((_a = next[kind.id]) !== null && _a !== void 0 ? _a : {});
|
|
316
|
+
const one = {};
|
|
317
|
+
for (const field of Object.keys(kind.fields)) {
|
|
318
|
+
const value = typeof input[field] === 'string' ? input[field].trim().slice(0, 500) : '';
|
|
319
|
+
if (value) {
|
|
320
|
+
one[field] = value;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
const secret = typeof input[kind.secret[0]] === 'string' ? input[kind.secret[0]].trim().slice(0, 500) : '';
|
|
324
|
+
const keptSecret = typeof kept[kind.secret[0]] === 'string' ? kept[kind.secret[0]] : '';
|
|
325
|
+
if (secret || keptSecret) {
|
|
326
|
+
one[kind.secret[0]] = secret || keptSecret;
|
|
327
|
+
}
|
|
328
|
+
const missing = [...kind.required, kind.secret[0]].filter(field => !one[field]);
|
|
329
|
+
if (missing.length) {
|
|
330
|
+
throw new SignInError(`${kind.name} needs ${missing.join(', ')}`);
|
|
331
|
+
}
|
|
332
|
+
if (one.issuer && !/^https:\/\//.test(one.issuer) && !/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/.test(one.issuer)) {
|
|
333
|
+
throw new SignInError('The issuer is an https address.');
|
|
334
|
+
}
|
|
335
|
+
if (one.url && !/^https?:\/\//.test(one.url)) {
|
|
336
|
+
throw new SignInError('The address of GitHub Enterprise is an http(s) address.');
|
|
337
|
+
}
|
|
338
|
+
next[kind.id] = one;
|
|
339
|
+
return next;
|
|
340
|
+
}
|
|
341
|
+
SignInProviders.withProvider = withProvider;
|
|
342
|
+
/** The environment's variables that sign-in.json stands for: what the environment sets wins. */
|
|
343
|
+
function withConfig(env, config) {
|
|
344
|
+
const { github, google, wechat, oidc } = config !== null && config !== void 0 ? config : {};
|
|
345
|
+
const file = {
|
|
346
|
+
TA_GITHUB_CLIENT_ID: github === null || github === void 0 ? void 0 : github.clientId,
|
|
347
|
+
TA_GITHUB_CLIENT_SECRET: github === null || github === void 0 ? void 0 : github.clientSecret,
|
|
348
|
+
TA_GITHUB_URL: github === null || github === void 0 ? void 0 : github.url,
|
|
349
|
+
TA_GOOGLE_CLIENT_ID: google === null || google === void 0 ? void 0 : google.clientId,
|
|
350
|
+
TA_GOOGLE_CLIENT_SECRET: google === null || google === void 0 ? void 0 : google.clientSecret,
|
|
351
|
+
TA_WECHAT_APP_ID: wechat === null || wechat === void 0 ? void 0 : wechat.appId,
|
|
352
|
+
TA_WECHAT_APP_SECRET: wechat === null || wechat === void 0 ? void 0 : wechat.appSecret,
|
|
353
|
+
TA_OIDC_ISSUER: oidc === null || oidc === void 0 ? void 0 : oidc.issuer,
|
|
354
|
+
TA_OIDC_CLIENT_ID: oidc === null || oidc === void 0 ? void 0 : oidc.clientId,
|
|
355
|
+
TA_OIDC_CLIENT_SECRET: oidc === null || oidc === void 0 ? void 0 : oidc.clientSecret,
|
|
356
|
+
TA_OIDC_NAME: oidc === null || oidc === void 0 ? void 0 : oidc.name,
|
|
357
|
+
};
|
|
358
|
+
const merged = { ...env };
|
|
359
|
+
for (const [key, value] of Object.entries(file)) {
|
|
360
|
+
if (typeof value === 'string' && value && !env[key]) {
|
|
361
|
+
merged[key] = value;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return merged;
|
|
365
|
+
}
|
|
366
|
+
SignInProviders.withConfig = withConfig;
|
|
367
|
+
/**
|
|
368
|
+
* GitHub by a code, for those asking to come in, when GitHub is not set up with its secret (which goes there and back
|
|
369
|
+
* instead): `TA_GITHUB_DEVICE` is `off`, or `<client id>` or `<client id>@<address of GitHub>` of an OAuth app of
|
|
370
|
+
* one's own with its device flow on; by default Ta's own, on GitHub.com.
|
|
371
|
+
*/
|
|
372
|
+
function device(env) {
|
|
373
|
+
var _a;
|
|
374
|
+
var _b;
|
|
375
|
+
const value = (_b = (_a = env.TA_GITHUB_DEVICE) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
|
|
376
|
+
if (value === 'off' || (env.TA_GITHUB_CLIENT_ID && env.TA_GITHUB_CLIENT_SECRET)) {
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
const at = value.indexOf('@');
|
|
380
|
+
const clientId = at < 0 ? value : value.slice(0, at);
|
|
381
|
+
const url = at < 0 ? undefined : value.slice(at + 1);
|
|
382
|
+
return new GitHubDeviceSignIn(clientId || GitHubDeviceSignIn.CLIENT_ID, GitHubSignIn.endpoints(url || undefined));
|
|
383
|
+
}
|
|
384
|
+
SignInProviders.device = device;
|
|
198
385
|
/**
|
|
199
386
|
* The providers the operator configured in the environment of ta serve: a provider is offered when it
|
|
200
387
|
* has its id and its secret.
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import type { TaSignInKind, TaSignInSetup } from '@celljs/ta-protocol';
|
|
1
2
|
import { SignInFlow } from './sign-in-flow.js';
|
|
3
|
+
import { type DeviceSignInProvider } from './sign-in-provider.js';
|
|
2
4
|
export declare const TA_SIGN_IN: unique symbol;
|
|
3
5
|
/**
|
|
4
|
-
* Signing in to ta serve with an account, besides its token. The providers come from the environment
|
|
5
|
-
*
|
|
6
|
-
*
|
|
6
|
+
* Signing in to ta serve with an account, besides its token. The providers come from the environment, then
|
|
7
|
+
* sign-in.json of the agent directory (SignInProviders.withConfig), which Settings, Access writes (setProvider) and
|
|
8
|
+
* which is read again then; who may sign in from TA_ALLOWED_USERS and the accounts added in the web client
|
|
9
|
+
* (AccessStore). Someone else who signs in is told to wait, and shows up as a request. Those asking to come in by a
|
|
10
|
+
* link sign in with the same providers to say who they are (TaHostAccounts), which lets them into nothing, or, when GitHub
|
|
11
|
+
* is not set up, with GitHub by a code, Ta's own app (`device`, SignInProviders.device).
|
|
7
12
|
*/
|
|
8
13
|
export declare class TaSignIn extends SignInFlow {
|
|
14
|
+
device: DeviceSignInProvider | undefined;
|
|
9
15
|
constructor();
|
|
16
|
+
setups(): TaSignInSetup[];
|
|
17
|
+
/** Sets a kind up in sign-in.json (readable by the user alone), offered at once; not one the environment sets. */
|
|
18
|
+
setProvider(id: TaSignInKind, fields: Record<string, unknown> | null): void;
|
|
10
19
|
}
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
10
11
|
import { join } from 'node:path';
|
|
11
12
|
import { Component } from '@celljs/core';
|
|
12
13
|
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
@@ -14,14 +15,45 @@ import { AccessStore, AccessUtil } from './access-store.js';
|
|
|
14
15
|
import { SignInFlow } from './sign-in-flow.js';
|
|
15
16
|
import { SignInProviders } from './sign-in-provider.js';
|
|
16
17
|
export const TA_SIGN_IN = Symbol('TaSignIn');
|
|
18
|
+
function file() {
|
|
19
|
+
return join(TaBrand.agentDir(), 'sign-in.json');
|
|
20
|
+
}
|
|
21
|
+
/** sign-in.json of the agent directory (SignInProviders.Config); none when it is not there or not JSON. */
|
|
22
|
+
function config() {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(readFileSync(file(), 'utf8'));
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
17
30
|
/**
|
|
18
|
-
* Signing in to ta serve with an account, besides its token. The providers come from the environment
|
|
19
|
-
*
|
|
20
|
-
*
|
|
31
|
+
* Signing in to ta serve with an account, besides its token. The providers come from the environment, then
|
|
32
|
+
* sign-in.json of the agent directory (SignInProviders.withConfig), which Settings, Access writes (setProvider) and
|
|
33
|
+
* which is read again then; who may sign in from TA_ALLOWED_USERS and the accounts added in the web client
|
|
34
|
+
* (AccessStore). Someone else who signs in is told to wait, and shows up as a request. Those asking to come in by a
|
|
35
|
+
* link sign in with the same providers to say who they are (TaHostAccounts), which lets them into nothing, or, when GitHub
|
|
36
|
+
* is not set up, with GitHub by a code, Ta's own app (`device`, SignInProviders.device).
|
|
21
37
|
*/
|
|
22
38
|
let TaSignIn = class TaSignIn extends SignInFlow {
|
|
23
39
|
constructor() {
|
|
24
|
-
super(SignInProviders.fromEnv(process.env), new AccessStore(join(TaBrand.agentDir(), 'access.json'), AccessUtil.parseList(process.env.TA_ALLOWED_USERS)), SignInProviders.publicUrl(process.env));
|
|
40
|
+
super(SignInProviders.fromEnv(SignInProviders.withConfig(process.env, config())), new AccessStore(join(TaBrand.agentDir(), 'access.json'), AccessUtil.parseList(process.env.TA_ALLOWED_USERS)), SignInProviders.publicUrl(process.env));
|
|
41
|
+
this.device = SignInProviders.device(SignInProviders.withConfig(process.env, config()));
|
|
42
|
+
}
|
|
43
|
+
setups() {
|
|
44
|
+
const device = this.device;
|
|
45
|
+
return SignInProviders.setups(process.env, config()).map(setup => ((device === null || device === void 0 ? void 0 : device.id) === setup.id && !setup.configured ? { ...setup, device: true } : setup));
|
|
46
|
+
}
|
|
47
|
+
/** Sets a kind up in sign-in.json (readable by the user alone), offered at once; not one the environment sets. */
|
|
48
|
+
setProvider(id, fields) {
|
|
49
|
+
var _a;
|
|
50
|
+
if (((_a = this.setups().find(one => one.id === id)) === null || _a === void 0 ? void 0 : _a.source) === 'env') {
|
|
51
|
+
throw new Error(`${id} is set up by the environment of ta serve, not here.`);
|
|
52
|
+
}
|
|
53
|
+
const next = SignInProviders.withProvider(config(), id, fields);
|
|
54
|
+
writeFileSync(file(), `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
|
|
55
|
+
this.providers = SignInProviders.fromEnv(SignInProviders.withConfig(process.env, next));
|
|
56
|
+
this.device = SignInProviders.device(SignInProviders.withConfig(process.env, next));
|
|
25
57
|
}
|
|
26
58
|
};
|
|
27
59
|
TaSignIn = __decorate([
|
|
@@ -38,6 +38,13 @@ export declare class TaServerImpl implements TaServer {
|
|
|
38
38
|
prompt(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
39
39
|
steer(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
40
40
|
followUp(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
41
|
+
/**
|
|
42
|
+
* A message as written by who sends it (TaMessageAuthor): the line of one let in, never one a page wrote. The
|
|
43
|
+
* owner's has none, as before anyone was let in.
|
|
44
|
+
*/
|
|
45
|
+
protected signed(input: TaPromptInput): TaPromptInput;
|
|
46
|
+
/** Whether the principal of this call may take back a waiting message: the owner any, another only their own. */
|
|
47
|
+
protected mayTakeBack(text: string): boolean;
|
|
41
48
|
/** Logs how long the run took to end here: with the times the box keeps (stop.times of @celljs/ta-web), where a slow stop went. */
|
|
42
49
|
abort(sessionId: string): Promise<void>;
|
|
43
50
|
clearQueue(sessionId: string): Promise<TaCommandResult<'clear_queue'>>;
|
|
@@ -15,7 +15,7 @@ import { Rpc } from '@celljs/rpc';
|
|
|
15
15
|
import { RpcContext } from '@celljs/rpc/lib/node';
|
|
16
16
|
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
17
17
|
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
18
|
-
import { TaServer, } from '@celljs/ta-protocol';
|
|
18
|
+
import { TA_OWNER, TaMessageAuthor, TaServer, } from '@celljs/ta-protocol';
|
|
19
19
|
import { TaSessionCatalog, TaSessionFactory, TaSessionRegistry } from './host-protocol.js';
|
|
20
20
|
import { SessionInfoUtil } from './session-info-util.js';
|
|
21
21
|
import { SlashCommandUtil } from './slash-command-util.js';
|
|
@@ -67,7 +67,7 @@ let TaServerImpl = class TaServerImpl {
|
|
|
67
67
|
return this.guard(() => this.sessions.close(sessionId));
|
|
68
68
|
}
|
|
69
69
|
async listSessions() {
|
|
70
|
-
return this.
|
|
70
|
+
return this.sessions.infos(RpcContext.connection());
|
|
71
71
|
}
|
|
72
72
|
async watchSessions() {
|
|
73
73
|
return this.sessions.watch(RpcContext.requireConnection());
|
|
@@ -112,16 +112,35 @@ let TaServerImpl = class TaServerImpl {
|
|
|
112
112
|
prompt(sessionId, input) {
|
|
113
113
|
return this.on(sessionId, session => {
|
|
114
114
|
this.runs.prompted(sessionId);
|
|
115
|
-
return session.prompt(input);
|
|
115
|
+
return session.prompt(this.signed(input));
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
steer(sessionId, input) {
|
|
119
119
|
this.runs.prompted(sessionId);
|
|
120
|
-
return this.on(sessionId, session => session.steer(input));
|
|
120
|
+
return this.on(sessionId, session => session.steer(this.signed(input)));
|
|
121
121
|
}
|
|
122
122
|
followUp(sessionId, input) {
|
|
123
123
|
this.runs.prompted(sessionId);
|
|
124
|
-
return this.on(sessionId, session => session.followUp(input));
|
|
124
|
+
return this.on(sessionId, session => session.followUp(this.signed(input)));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A message as written by who sends it (TaMessageAuthor): the line of one let in, never one a page wrote. The
|
|
128
|
+
* owner's has none, as before anyone was let in.
|
|
129
|
+
*/
|
|
130
|
+
signed(input) {
|
|
131
|
+
if (typeof (input === null || input === void 0 ? void 0 : input.message) !== 'string') {
|
|
132
|
+
return input;
|
|
133
|
+
}
|
|
134
|
+
const principal = this.principals.current();
|
|
135
|
+
const member = principal === TA_OWNER ? undefined : this.authority.describe(principal);
|
|
136
|
+
const message = member ? TaMessageAuthor.mark(input.message, principal, member.name) : TaMessageAuthor.strip(input.message);
|
|
137
|
+
return message === input.message ? input : { ...input, message };
|
|
138
|
+
}
|
|
139
|
+
/** Whether the principal of this call may take back a waiting message: the owner any, another only their own. */
|
|
140
|
+
mayTakeBack(text) {
|
|
141
|
+
var _a;
|
|
142
|
+
const principal = this.principals.current();
|
|
143
|
+
return principal === TA_OWNER || ((_a = TaMessageAuthor.of(text)) === null || _a === void 0 ? void 0 : _a.id) === principal;
|
|
125
144
|
}
|
|
126
145
|
/** Logs how long the run took to end here: with the times the box keeps (stop.times of @celljs/ta-web), where a slow stop went. */
|
|
127
146
|
async abort(sessionId) {
|
|
@@ -130,10 +149,28 @@ let TaServerImpl = class TaServerImpl {
|
|
|
130
149
|
console.log(`[${new Date().toISOString()}] ta serve: stopped ${sessionId.slice(0, 8)} in ${Date.now() - start} ms`);
|
|
131
150
|
}
|
|
132
151
|
clearQueue(sessionId) {
|
|
133
|
-
return this.on(sessionId,
|
|
152
|
+
return this.on(sessionId, session => {
|
|
153
|
+
if (this.principals.current() === TA_OWNER) {
|
|
154
|
+
return session.pi.clearQueue();
|
|
155
|
+
}
|
|
156
|
+
// One let in takes back their own, the others' stay.
|
|
157
|
+
const taken = { steering: [], followUp: [] };
|
|
158
|
+
for (const kind of ['steering', 'followUp']) {
|
|
159
|
+
const texts = session.queued(kind);
|
|
160
|
+
for (let index = texts.length - 1; index >= 0; index--) {
|
|
161
|
+
if (this.mayTakeBack(texts[index]) && session.removeQueued(kind, index)) {
|
|
162
|
+
taken[kind].unshift(texts[index]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return taken;
|
|
167
|
+
});
|
|
134
168
|
}
|
|
135
169
|
removeQueued(sessionId, kind, index) {
|
|
136
|
-
return this.on(sessionId, session =>
|
|
170
|
+
return this.on(sessionId, session => {
|
|
171
|
+
const text = session.queued(kind)[index];
|
|
172
|
+
return text !== undefined && this.mayTakeBack(text) && session.removeQueued(kind, index);
|
|
173
|
+
});
|
|
137
174
|
}
|
|
138
175
|
newSession(sessionId, parentSession) {
|
|
139
176
|
return this.authored(sessionId, ({ runtime }) => runtime.newSession(parentSession ? { parentSession } : undefined));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
2
|
-
import type
|
|
2
|
+
import { type TaEvent, type TaOpenSessionOptions, type TaSessionInfo } from '@celljs/ta-protocol';
|
|
3
3
|
import { ClientChannel } from './client-channel.js';
|
|
4
|
-
import { type TaHostOptions, TaSessionFactory, TaSessionRegistry } from './host-protocol.js';
|
|
4
|
+
import { type TaHostOptions, TaPresenceBook, TaSessionFactory, TaSessionRegistry } from './host-protocol.js';
|
|
5
5
|
import { TaSessionHandles } from './session-handles.js';
|
|
6
6
|
import { SessionListFeed } from './session-list-feed.js';
|
|
7
7
|
import type { TaSession } from './ta-session.js';
|
|
8
|
-
import { TaVisibility } from './team/team-protocol.js';
|
|
8
|
+
import { TaPrincipals, TaVisibility } from './team/team-protocol.js';
|
|
9
9
|
/**
|
|
10
10
|
* The open sessions. A session's id outlives its memory: closed while idle or by a restart, it opens again
|
|
11
11
|
* from its file under the same id at the next call (TaSessionHandles), so clients never see it go.
|
|
@@ -25,6 +25,10 @@ export declare class DefaultTaSessionRegistry implements TaSessionRegistry {
|
|
|
25
25
|
protected readonly waking: Map<string, Promise<TaSession>>;
|
|
26
26
|
/** What each connection may see of the list (docs/design/ta-team.md): all of it for the owner's. */
|
|
27
27
|
protected readonly visibility: TaVisibility;
|
|
28
|
+
protected readonly principals: TaPrincipals;
|
|
29
|
+
/** Who else is at each conversation: what each connection is told of the others (TaSessionInfo.people). */
|
|
30
|
+
protected readonly presence: TaPresenceBook;
|
|
31
|
+
protected presenceWatched: boolean;
|
|
28
32
|
protected readonly feed: SessionListFeed;
|
|
29
33
|
locate(sessionId: string): {
|
|
30
34
|
sessionFile?: string;
|
|
@@ -34,7 +38,10 @@ export declare class DefaultTaSessionRegistry implements TaSessionRegistry {
|
|
|
34
38
|
require(sessionId: string): TaSession;
|
|
35
39
|
resolve(sessionId: string): Promise<TaSession>;
|
|
36
40
|
list(): TaSession[];
|
|
41
|
+
infos(connection: RpcConnection | undefined): TaSessionInfo[];
|
|
37
42
|
watch(connection: RpcConnection): TaSessionInfo[];
|
|
43
|
+
/** Each with the others at it, as the principal of `connection` is told: never themselves. */
|
|
44
|
+
protected withPeople(connection: RpcConnection | undefined, list: TaSessionInfo[]): TaSessionInfo[];
|
|
38
45
|
get watching(): number;
|
|
39
46
|
get watchedAt(): number;
|
|
40
47
|
onSessionEvent(listener: (session: TaSession, event: TaEvent) => void): () => void;
|
|
@@ -11,12 +11,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
};
|
|
12
12
|
import { existsSync } from 'node:fs';
|
|
13
13
|
import { Autowired, Component, Value } from '@celljs/core';
|
|
14
|
+
import { TA_OWNER } from '@celljs/ta-protocol';
|
|
14
15
|
import { ClientChannel } from './client-channel.js';
|
|
15
|
-
import { TA_HOST_OPTIONS, TaSessionFactory, TaSessionRegistry } from './host-protocol.js';
|
|
16
|
+
import { TA_HOST_OPTIONS, TaPresenceBook, TaSessionFactory, TaSessionRegistry } from './host-protocol.js';
|
|
16
17
|
import { TaSessionHandles } from './session-handles.js';
|
|
17
18
|
import { SessionListFeed } from './session-list-feed.js';
|
|
18
19
|
import { TaErrors } from './ta-errors.js';
|
|
19
|
-
import { TaVisibility } from './team/team-protocol.js';
|
|
20
|
+
import { TaPrincipals, TaVisibility } from './team/team-protocol.js';
|
|
20
21
|
/**
|
|
21
22
|
* The open sessions. A session's id outlives its memory: closed while idle or by a restart, it opens again
|
|
22
23
|
* from its file under the same id at the next call (TaSessionHandles), so clients never see it go.
|
|
@@ -32,7 +33,8 @@ let DefaultTaSessionRegistry = class DefaultTaSessionRegistry {
|
|
|
32
33
|
this.closing = new Map();
|
|
33
34
|
/** Sessions opening again under their ids: the calls that come meanwhile wait for the same. */
|
|
34
35
|
this.waking = new Map();
|
|
35
|
-
this.
|
|
36
|
+
this.presenceWatched = false;
|
|
37
|
+
this.feed = new SessionListFeed(() => this.list().map(session => session.info()), undefined, (connection, list) => this.withPeople(connection, this.visibility.sessions(connection, list)));
|
|
36
38
|
}
|
|
37
39
|
locate(sessionId) {
|
|
38
40
|
const session = this.sessions.get(sessionId);
|
|
@@ -79,9 +81,25 @@ let DefaultTaSessionRegistry = class DefaultTaSessionRegistry {
|
|
|
79
81
|
list() {
|
|
80
82
|
return [...this.sessions.values()];
|
|
81
83
|
}
|
|
84
|
+
infos(connection) {
|
|
85
|
+
return this.withPeople(connection, this.visibility.sessions(connection, this.list().map(session => session.info())));
|
|
86
|
+
}
|
|
82
87
|
watch(connection) {
|
|
88
|
+
// Once a page watches, every component is made: who is where tells the lists again as it changes.
|
|
89
|
+
if (!this.presenceWatched) {
|
|
90
|
+
this.presenceWatched = true;
|
|
91
|
+
this.presence.onChange(() => this.feed.changed());
|
|
92
|
+
}
|
|
83
93
|
return this.feed.watch(connection);
|
|
84
94
|
}
|
|
95
|
+
/** Each with the others at it, as the principal of `connection` is told: never themselves. */
|
|
96
|
+
withPeople(connection, list) {
|
|
97
|
+
const principal = connection ? this.principals.of(connection) : TA_OWNER;
|
|
98
|
+
return list.map(info => {
|
|
99
|
+
const people = this.presence.people(info.sessionId, principal, info.isStreaming);
|
|
100
|
+
return people ? { ...info, people } : info;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
85
103
|
get watching() {
|
|
86
104
|
return this.feed.watching;
|
|
87
105
|
}
|
|
@@ -186,6 +204,14 @@ __decorate([
|
|
|
186
204
|
Autowired({ id: TaVisibility, detached: true }),
|
|
187
205
|
__metadata("design:type", Object)
|
|
188
206
|
], DefaultTaSessionRegistry.prototype, "visibility", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
Autowired({ id: TaPrincipals, detached: true }),
|
|
209
|
+
__metadata("design:type", Object)
|
|
210
|
+
], DefaultTaSessionRegistry.prototype, "principals", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
Autowired({ id: TaPresenceBook, detached: true }),
|
|
213
|
+
__metadata("design:type", Object)
|
|
214
|
+
], DefaultTaSessionRegistry.prototype, "presence", void 0);
|
|
189
215
|
DefaultTaSessionRegistry = __decorate([
|
|
190
216
|
Component(TaSessionRegistry)
|
|
191
217
|
], DefaultTaSessionRegistry);
|
package/esm/node/ta-session.d.ts
CHANGED
|
@@ -75,6 +75,8 @@ export declare class TaSession {
|
|
|
75
75
|
* Takes one waiting message out of the queue. pi only clears the whole of it, so this reaches into its
|
|
76
76
|
* two lists: the texts it shows and the messages its agent will take, which keep their images.
|
|
77
77
|
*/
|
|
78
|
+
/** The texts of the messages waiting, of one kind, in their order. */
|
|
79
|
+
queued(kind: 'steering' | 'followUp'): readonly string[];
|
|
78
80
|
removeQueued(kind: 'steering' | 'followUp', index: number): boolean;
|
|
79
81
|
/** pi's runtime says nothing of a move in the tree: the clients are told to read the conversation again. */
|
|
80
82
|
navigateTree(targetId: string, options?: Parameters<AgentSession['navigateTree']>[1]): Promise<TaNavigateResult>;
|
package/esm/node/ta-session.js
CHANGED
|
@@ -157,6 +157,12 @@ export class TaSession {
|
|
|
157
157
|
* Takes one waiting message out of the queue. pi only clears the whole of it, so this reaches into its
|
|
158
158
|
* two lists: the texts it shows and the messages its agent will take, which keep their images.
|
|
159
159
|
*/
|
|
160
|
+
/** The texts of the messages waiting, of one kind, in their order. */
|
|
161
|
+
queued(kind) {
|
|
162
|
+
var _a;
|
|
163
|
+
const pi = this.pi;
|
|
164
|
+
return [...((_a = (kind === 'steering' ? pi._steeringMessages : pi._followUpMessages)) !== null && _a !== void 0 ? _a : [])];
|
|
165
|
+
}
|
|
160
166
|
removeQueued(kind, index) {
|
|
161
167
|
const pi = this.pi;
|
|
162
168
|
const texts = kind === 'steering' ? pi._steeringMessages : pi._followUpMessages;
|