@celljs/ta-host 4.17.0 → 4.19.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/esm/node/account-service.d.ts +73 -0
- package/esm/node/account-service.js +304 -0
- package/esm/node/app-commands.d.ts +1 -1
- package/esm/node/app-commands.js +46 -29
- package/esm/node/credentials.d.ts +12 -0
- package/esm/node/credentials.js +35 -0
- package/esm/node/host-protocol.d.ts +2 -0
- package/esm/node/host-protocol.js +2 -0
- package/esm/node/index.d.ts +3 -0
- package/esm/node/index.js +3 -0
- package/esm/node/keep-awake.d.ts +3 -0
- package/esm/node/keep-awake.js +6 -1
- package/esm/node/package-hosts.d.ts +4 -0
- package/esm/node/package-hosts.js +18 -1
- package/esm/node/relay-bridge.js +1 -1
- package/esm/node/rooms-bridge.d.ts +10 -1
- package/esm/node/rooms-bridge.js +25 -0
- package/esm/node/screen-share/desktop-picture.d.ts +51 -0
- package/esm/node/screen-share/desktop-picture.js +133 -0
- package/esm/node/screen-share/desktop-session.d.ts +128 -0
- package/esm/node/screen-share/desktop-session.js +437 -0
- package/esm/node/screen-share/desktop-targets.d.ts +24 -0
- package/esm/node/screen-share/desktop-targets.js +80 -0
- package/esm/node/screen-share/desktop-viewer.d.ts +146 -0
- package/esm/node/screen-share/desktop-viewer.js +339 -0
- package/esm/node/screen-share/index.d.ts +8 -0
- package/esm/node/screen-share/index.js +9 -0
- package/esm/node/screen-share/rfb-client.d.ts +54 -0
- package/esm/node/screen-share/rfb-client.js +179 -0
- package/esm/node/screen-share/rfb-des.d.ts +11 -0
- package/esm/node/screen-share/rfb-des.js +143 -0
- package/esm/node/screen-share/rfb-encodings.d.ts +71 -0
- package/esm/node/screen-share/rfb-encodings.js +288 -0
- package/esm/node/screen-share/rfb-framebuffer.d.ts +16 -0
- package/esm/node/screen-share/rfb-framebuffer.js +53 -0
- package/esm/node/screen-share/rfb-protocol.d.ts +90 -0
- package/esm/node/screen-share/rfb-protocol.js +36 -0
- package/esm/node/screen-share/rfb-reader.d.ts +34 -0
- package/esm/node/screen-share/rfb-reader.js +110 -0
- package/esm/node/screen-share/rfb-security.d.ts +30 -0
- package/esm/node/screen-share/rfb-security.js +136 -0
- package/esm/node/screen-share/rfb-test-server.d.ts +37 -0
- package/esm/node/screen-share/rfb-test-server.js +116 -0
- package/esm/node/screen-share/screen-share-server-impl.d.ts +37 -0
- package/esm/node/screen-share/screen-share-server-impl.js +76 -0
- package/esm/node/screen-share/screen-shares.d.ts +123 -0
- package/esm/node/screen-share/screen-shares.js +463 -0
- package/esm/node/session-info-util.d.ts +10 -11
- package/esm/node/session-info-util.js +16 -94
- package/esm/node/settings-store.d.ts +1 -1
- package/esm/node/settings-store.js +7 -4
- package/esm/node/sign-in/access-store.d.ts +1 -1
- package/esm/node/sign-in/access-store.js +4 -1
- package/esm/node/sign-in/index.d.ts +2 -0
- package/esm/node/sign-in/index.js +2 -0
- package/esm/node/sign-in/polled-sign-in.d.ts +50 -0
- package/esm/node/sign-in/polled-sign-in.js +83 -0
- package/esm/node/sign-in/sign-in-devices.d.ts +55 -0
- package/esm/node/sign-in/sign-in-devices.js +113 -0
- package/esm/node/sign-in/sign-in-flow.d.ts +38 -4
- package/esm/node/sign-in/sign-in-flow.js +79 -4
- package/esm/node/sign-in/sign-in-pages.d.ts +8 -0
- package/esm/node/sign-in/sign-in-pages.js +137 -8
- package/esm/node/sign-in/sign-in-provider.d.ts +6 -0
- package/esm/node/sign-in/sign-in-provider.js +15 -0
- package/esm/node/sources-extension.d.ts +10 -0
- package/esm/node/sources-extension.js +18 -0
- package/esm/node/ta-server-impl.js +3 -3
- package/esm/node/ta-session-factory.js +2 -0
- package/esm/node/team/team-calls.js +35 -0
- package/esm/node/voice-bridge.d.ts +3 -1
- package/esm/node/voice-bridge.js +10 -3
- package/esm/node/voices-file.d.ts +5 -0
- package/esm/node/voices-file.js +14 -3
- package/esm/node/working-directory.d.ts +8 -2
- package/esm/node/working-directory.js +7 -0
- package/lib/node/account-service.d.ts +74 -0
- package/lib/node/account-service.js +307 -0
- package/lib/node/app-commands.d.ts +1 -1
- package/lib/node/app-commands.js +46 -29
- package/lib/node/credentials.d.ts +13 -0
- package/lib/node/credentials.js +38 -0
- package/lib/node/host-protocol.d.ts +2 -0
- package/lib/node/host-protocol.js +3 -1
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.js +3 -0
- package/lib/node/keep-awake.d.ts +3 -0
- package/lib/node/keep-awake.js +6 -1
- package/lib/node/package-hosts.d.ts +4 -0
- package/lib/node/package-hosts.js +17 -0
- package/lib/node/relay-bridge.js +1 -1
- package/lib/node/rooms-bridge.d.ts +10 -1
- package/lib/node/rooms-bridge.js +25 -0
- package/lib/node/screen-share/desktop-picture.d.ts +52 -0
- package/lib/node/screen-share/desktop-picture.js +136 -0
- package/lib/node/screen-share/desktop-session.d.ts +129 -0
- package/lib/node/screen-share/desktop-session.js +442 -0
- package/lib/node/screen-share/desktop-targets.d.ts +25 -0
- package/lib/node/screen-share/desktop-targets.js +84 -0
- package/lib/node/screen-share/desktop-viewer.d.ts +147 -0
- package/lib/node/screen-share/desktop-viewer.js +343 -0
- package/lib/node/screen-share/index.d.ts +9 -0
- package/lib/node/screen-share/index.js +25 -0
- package/lib/node/screen-share/rfb-client.d.ts +55 -0
- package/lib/node/screen-share/rfb-client.js +183 -0
- package/lib/node/screen-share/rfb-des.d.ts +12 -0
- package/lib/node/screen-share/rfb-des.js +146 -0
- package/lib/node/screen-share/rfb-encodings.d.ts +72 -0
- package/lib/node/screen-share/rfb-encodings.js +295 -0
- package/lib/node/screen-share/rfb-framebuffer.d.ts +17 -0
- package/lib/node/screen-share/rfb-framebuffer.js +57 -0
- package/lib/node/screen-share/rfb-protocol.d.ts +91 -0
- package/lib/node/screen-share/rfb-protocol.js +39 -0
- package/lib/node/screen-share/rfb-reader.d.ts +35 -0
- package/lib/node/screen-share/rfb-reader.js +115 -0
- package/lib/node/screen-share/rfb-security.d.ts +31 -0
- package/lib/node/screen-share/rfb-security.js +141 -0
- package/lib/node/screen-share/rfb-test-server.d.ts +38 -0
- package/lib/node/screen-share/rfb-test-server.js +120 -0
- package/lib/node/screen-share/screen-share-server-impl.d.ts +38 -0
- package/lib/node/screen-share/screen-share-server-impl.js +79 -0
- package/lib/node/screen-share/screen-shares.d.ts +124 -0
- package/lib/node/screen-share/screen-shares.js +464 -0
- package/lib/node/session-info-util.d.ts +10 -11
- package/lib/node/session-info-util.js +15 -93
- package/lib/node/settings-store.d.ts +1 -1
- package/lib/node/settings-store.js +6 -3
- package/lib/node/sign-in/access-store.d.ts +1 -1
- package/lib/node/sign-in/access-store.js +4 -1
- package/lib/node/sign-in/index.d.ts +2 -0
- package/lib/node/sign-in/index.js +2 -0
- package/lib/node/sign-in/polled-sign-in.d.ts +51 -0
- package/lib/node/sign-in/polled-sign-in.js +87 -0
- package/lib/node/sign-in/sign-in-devices.d.ts +56 -0
- package/lib/node/sign-in/sign-in-devices.js +117 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +38 -4
- package/lib/node/sign-in/sign-in-flow.js +80 -5
- package/lib/node/sign-in/sign-in-pages.d.ts +8 -0
- package/lib/node/sign-in/sign-in-pages.js +136 -7
- package/lib/node/sign-in/sign-in-provider.d.ts +6 -0
- package/lib/node/sign-in/sign-in-provider.js +15 -0
- package/lib/node/sources-extension.d.ts +11 -0
- package/lib/node/sources-extension.js +22 -0
- package/lib/node/ta-server-impl.js +2 -2
- package/lib/node/ta-session-factory.js +2 -0
- package/lib/node/team/team-calls.js +35 -0
- package/lib/node/voice-bridge.d.ts +3 -1
- package/lib/node/voice-bridge.js +9 -2
- package/lib/node/voices-file.d.ts +5 -0
- package/lib/node/voices-file.js +14 -3
- package/lib/node/working-directory.d.ts +8 -2
- package/lib/node/working-directory.js +7 -0
- package/package.json +14 -10
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
1
|
+
import { TaSaid } from '@celljs/ta-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* What a list of conversations shows of one: its first message, as pi's session list does, and when it last changed.
|
|
4
|
+
* What was said is read by TaSaid, which leaves out every mark of the model.
|
|
5
|
+
*/
|
|
3
6
|
export var SessionInfoUtil;
|
|
4
7
|
(function (SessionInfoUtil) {
|
|
5
8
|
const LENGTH = 120;
|
|
6
|
-
/** Of the text of the last message, what lastMessage reads: its lines are joined, many of them empty or marks only. */
|
|
7
|
-
const PREVIEW_READ = 2000;
|
|
8
9
|
/**
|
|
9
|
-
* The first line of the first message of the user that
|
|
10
|
-
* a skill
|
|
10
|
+
* The first line of the first message of the user that says something, cut to a title's length: what they typed
|
|
11
|
+
* (TaSaid.words), a skill they ran as `/skill:name` and what follows; never a notice of a part of Ta (TaSaid.notice).
|
|
11
12
|
*/
|
|
12
13
|
function firstMessage(messages) {
|
|
13
|
-
var _a;
|
|
14
14
|
for (const message of messages) {
|
|
15
|
-
if (message.role !== 'user') {
|
|
15
|
+
if (message.role !== 'user' || TaSaid.notice(message)) {
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
|
-
const line = (
|
|
18
|
+
const line = TaSaid.of(message)
|
|
19
19
|
.split('\n')
|
|
20
20
|
.map(part => part.trim())
|
|
21
21
|
.find(Boolean);
|
|
@@ -27,89 +27,25 @@ export var SessionInfoUtil;
|
|
|
27
27
|
}
|
|
28
28
|
SessionInfoUtil.firstMessage = firstMessage;
|
|
29
29
|
/**
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* (TaTaskNote) says the task: how one ended is its title and what it said, one handed to the double its title,
|
|
35
|
-
* and a note of a new id, for the double only, is passed over.
|
|
30
|
+
* The last thing the user or the agent said, on one line and cut to a preview's length, as a messaging app shows
|
|
31
|
+
* it under the name of a chat (TaSaid.line of TaSaid.words): without the marks of the model and of Markdown, the
|
|
32
|
+
* thinking and tool calls of the agent; a notice of a part of Ta (TaSaid.notice) and a message that says nothing for a person (the summary an agent compacted
|
|
33
|
+
* its context to, a note of a task's new id) is passed over.
|
|
36
34
|
*/
|
|
37
35
|
function lastMessage(messages) {
|
|
38
36
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
39
37
|
const message = messages[i];
|
|
40
|
-
if (message.role !== 'user' && message.role !== 'assistant') {
|
|
38
|
+
if ((message.role !== 'user' && message.role !== 'assistant') || TaSaid.notice(message)) {
|
|
41
39
|
continue;
|
|
42
40
|
}
|
|
43
|
-
const
|
|
44
|
-
if (said === undefined) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
// A list asks for it every few seconds: only the start of a long reply is read, enough for a preview.
|
|
48
|
-
const read = said.slice(0, PREVIEW_READ);
|
|
49
|
-
const line = plain(withoutFences(read) || read)
|
|
50
|
-
.split('\n')
|
|
51
|
-
.map(part => part
|
|
52
|
-
.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+\.\s+)/, '')
|
|
53
|
-
.replace(/[*`]{1,3}|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, '')
|
|
54
|
-
.trim())
|
|
55
|
-
.filter(Boolean)
|
|
56
|
-
.join(' ')
|
|
57
|
-
.replace(/\s+/g, ' ');
|
|
41
|
+
const line = TaSaid.line(TaSaid.of(message), { chars: LENGTH });
|
|
58
42
|
if (line) {
|
|
59
|
-
return line
|
|
43
|
+
return line;
|
|
60
44
|
}
|
|
61
45
|
}
|
|
62
46
|
return undefined;
|
|
63
47
|
}
|
|
64
48
|
SessionInfoUtil.lastMessage = lastMessage;
|
|
65
|
-
/**
|
|
66
|
-
* The text without its fenced blocks, as a messenger says no more than [code] of them: code, and the cards a
|
|
67
|
-
* reply draws (a card's language, as `ta-glance`), are not what was said.
|
|
68
|
-
*/
|
|
69
|
-
function withoutFences(text) {
|
|
70
|
-
var _a;
|
|
71
|
-
const kept = [];
|
|
72
|
-
let fence;
|
|
73
|
-
for (const line of text.split('\n')) {
|
|
74
|
-
const mark = (_a = /^\s*(`{3,}|~{3,})/.exec(line)) === null || _a === void 0 ? void 0 : _a[1];
|
|
75
|
-
if (!fence && mark) {
|
|
76
|
-
fence = mark;
|
|
77
|
-
}
|
|
78
|
-
else if (fence && mark && mark[0] === fence[0] && mark.length >= fence.length && !line.trim().slice(mark.length)) {
|
|
79
|
-
fence = undefined;
|
|
80
|
-
}
|
|
81
|
-
else if (!fence) {
|
|
82
|
-
kept.push(line);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return kept.join('\n').trim();
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Markdown's pictures and links as a messenger says them: a link by its words, pictures left out of a message that
|
|
89
|
-
* says something else, and by the words that name them in one of pictures only.
|
|
90
|
-
*/
|
|
91
|
-
function plain(text) {
|
|
92
|
-
const linked = text.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
93
|
-
const words = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, '').trim();
|
|
94
|
-
return words || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
95
|
-
}
|
|
96
|
-
/** What the user typed of a message: without its context and pi's notes of images, a skill as `/skill:name` and what follows. */
|
|
97
|
-
function userWords(content) {
|
|
98
|
-
const said = TaImageNote.strip(TaMessageContext.strip(content));
|
|
99
|
-
const skill = TaSkillUse.parse(said);
|
|
100
|
-
return skill ? TaSkillUse.command(skill) : said;
|
|
101
|
-
}
|
|
102
|
-
/** What a message of the user says when it is a note of a task: its title and how it ended; undefined for one the double alone reads. */
|
|
103
|
-
function noteWords(said) {
|
|
104
|
-
const note = TaTaskNote.parse(said);
|
|
105
|
-
if (!note) {
|
|
106
|
-
return said;
|
|
107
|
-
}
|
|
108
|
-
if (note.kind === 'renamed') {
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
return note.kind === 'update' && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
112
|
-
}
|
|
113
49
|
/** The time of the last message that has one, else `fallback`. */
|
|
114
50
|
function updatedAt(messages, fallback) {
|
|
115
51
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -121,19 +57,5 @@ export var SessionInfoUtil;
|
|
|
121
57
|
return fallback;
|
|
122
58
|
}
|
|
123
59
|
SessionInfoUtil.updatedAt = updatedAt;
|
|
124
|
-
/** The text of the content of a message. */
|
|
125
|
-
function text(content) {
|
|
126
|
-
if (typeof content === 'string') {
|
|
127
|
-
return content;
|
|
128
|
-
}
|
|
129
|
-
if (!Array.isArray(content)) {
|
|
130
|
-
return '';
|
|
131
|
-
}
|
|
132
|
-
return content
|
|
133
|
-
.filter((part) => (part === null || part === void 0 ? void 0 : part.type) === 'text' && typeof part.text === 'string')
|
|
134
|
-
.map(part => part.text)
|
|
135
|
-
.join('\n');
|
|
136
|
-
}
|
|
137
|
-
SessionInfoUtil.text = text;
|
|
138
60
|
})(SessionInfoUtil || (SessionInfoUtil = {}));
|
|
139
61
|
//# sourceMappingURL=session-info-util.js.map
|
|
@@ -57,7 +57,7 @@ export declare class TaSettingsStoreImpl implements TaSettingsStore {
|
|
|
57
57
|
trust(): void;
|
|
58
58
|
}>;
|
|
59
59
|
protected read(file: string): Promise<Record<string, unknown>>;
|
|
60
|
-
protected models(): Promise<Pick<TaSettingsSnapshot, 'models' | 'modelNames' | 'providerNames'>>;
|
|
60
|
+
protected models(): Promise<Pick<TaSettingsSnapshot, 'models' | 'agents' | 'modelNames' | 'providerNames'>>;
|
|
61
61
|
protected reloadSessions(scope: TaSettingsScope, cwd: string): Promise<void>;
|
|
62
62
|
}
|
|
63
63
|
export {};
|
|
@@ -11,7 +11,7 @@ import { mkdir, readFile, rename, rmdir, stat, writeFile } from 'node:fs/promise
|
|
|
11
11
|
import { dirname, join } from 'node:path';
|
|
12
12
|
import { CODING_AGENT_OPTIONS, ModelRuntimeProvider, PiSdkUtil } from '@celljs/ai-coding-agent';
|
|
13
13
|
import { Autowired, Component, Value } from '@celljs/core';
|
|
14
|
-
import { TA_SETTINGS } from '@celljs/ta-protocol';
|
|
14
|
+
import { TA_AGENT_API_PREFIX, TA_SETTINGS } from '@celljs/ta-protocol';
|
|
15
15
|
import { ExtensionProviders } from './extension-providers.js';
|
|
16
16
|
import { TaSessionRegistry } from './host-protocol.js';
|
|
17
17
|
import { PiDirectories } from './remote/remote-protocol.js';
|
|
@@ -204,7 +204,7 @@ let TaSettingsStoreImpl = class TaSettingsStoreImpl {
|
|
|
204
204
|
}
|
|
205
205
|
async get(cwd) {
|
|
206
206
|
const { userFile, projectFile, trusted } = await this.files(cwd);
|
|
207
|
-
const [user, project, { models, modelNames, providerNames }] = await Promise.all([this.read(userFile), this.read(projectFile), this.models()]);
|
|
207
|
+
const [user, project, { models, agents, modelNames, providerNames }] = await Promise.all([this.read(userFile), this.read(projectFile), this.models()]);
|
|
208
208
|
return {
|
|
209
209
|
user: TaSettingsUtil.read(user),
|
|
210
210
|
project: TaSettingsUtil.read(project),
|
|
@@ -213,6 +213,7 @@ let TaSettingsStoreImpl = class TaSettingsStoreImpl {
|
|
|
213
213
|
projectFile,
|
|
214
214
|
projectTrusted: trusted !== false,
|
|
215
215
|
models,
|
|
216
|
+
agents,
|
|
216
217
|
modelNames,
|
|
217
218
|
providerNames,
|
|
218
219
|
};
|
|
@@ -312,10 +313,12 @@ let TaSettingsStoreImpl = class TaSettingsStoreImpl {
|
|
|
312
313
|
providerNames[provider.id] = provider.name;
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
|
-
|
|
316
|
+
const name = (model) => `${model.provider}/${model.id}`;
|
|
317
|
+
const agents = available.filter(model => String(model.api).startsWith(TA_AGENT_API_PREFIX)).map(name);
|
|
318
|
+
return { models: available.map(name), agents, modelNames, providerNames };
|
|
316
319
|
}
|
|
317
320
|
catch (_a) {
|
|
318
|
-
return { models: [], modelNames: {}, providerNames: {} };
|
|
321
|
+
return { models: [], agents: [], modelNames: {}, providerNames: {} };
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
324
|
async reloadSessions(scope, cwd) {
|
|
@@ -25,7 +25,7 @@ interface AccessFile {
|
|
|
25
25
|
export declare namespace AccessUtil {
|
|
26
26
|
/** Logins and addresses are the same whatever their case; the ids of WeChat and `sub`s are not. */
|
|
27
27
|
function normalize(account: string): string;
|
|
28
|
-
/** `google:*@corp.com` lets in every address of the domain; anything else, one account. */
|
|
28
|
+
/** `google:*@corp.com` lets in every address of the domain, `oidc:*` every account of the provider; anything else, one account. */
|
|
29
29
|
function matches(pattern: string, account: string): boolean;
|
|
30
30
|
/** TA_ALLOWED_USERS: accounts separated by commas, spaces or new lines. */
|
|
31
31
|
function parseList(list: string | undefined): string[];
|
|
@@ -14,9 +14,12 @@ export var AccessUtil;
|
|
|
14
14
|
return value.startsWith('github:') || value.includes('@') ? value.toLowerCase() : value;
|
|
15
15
|
}
|
|
16
16
|
AccessUtil.normalize = normalize;
|
|
17
|
-
/** `google:*@corp.com` lets in every address of the domain; anything else, one account. */
|
|
17
|
+
/** `google:*@corp.com` lets in every address of the domain, `oidc:*` every account of the provider; anything else, one account. */
|
|
18
18
|
function matches(pattern, account) {
|
|
19
19
|
const [want, have] = [normalize(pattern), normalize(account)];
|
|
20
|
+
if (want.endsWith(':*') && want.indexOf(':') === want.length - 2) {
|
|
21
|
+
return have.startsWith(want.slice(0, -1)) && have.length > want.length - 1;
|
|
22
|
+
}
|
|
20
23
|
const star = want.indexOf(':*@');
|
|
21
24
|
if (star > 0) {
|
|
22
25
|
return have.startsWith(want.slice(0, star + 1)) && have.endsWith(want.slice(star + 2));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './access-server-impl.js';
|
|
2
2
|
export * from './access-store.js';
|
|
3
|
+
export * from './polled-sign-in.js';
|
|
4
|
+
export * from './sign-in-devices.js';
|
|
3
5
|
export * from './sign-in-flow.js';
|
|
4
6
|
export * from './sign-in-middleware.js';
|
|
5
7
|
export * from './sign-in-pages.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './access-server-impl.js';
|
|
2
2
|
export * from './access-store.js';
|
|
3
|
+
export * from './polled-sign-in.js';
|
|
4
|
+
export * from './sign-in-devices.js';
|
|
3
5
|
export * from './sign-in-flow.js';
|
|
4
6
|
export * from './sign-in-middleware.js';
|
|
5
7
|
export * from './sign-in-pages.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { TaSignInProvider } from '@celljs/ta-protocol';
|
|
2
|
+
import { type SignInAccount } from './sign-in-provider.js';
|
|
3
|
+
/**
|
|
4
|
+
* A provider the browser signs in at without coming back to Ta: the request is pushed to it (PAR, RFC 9126), the user
|
|
5
|
+
* agrees in a browser, and Ta asks it for the result until it has one (a company's sign-in for CLIs, as
|
|
6
|
+
* `<par endpoint>/poll`). Needs no secret and no address to come back to: a client id is all.
|
|
7
|
+
*/
|
|
8
|
+
export interface PolledSignInProvider extends TaSignInProvider {
|
|
9
|
+
readonly polled: true;
|
|
10
|
+
/** A sign-in under way: where the browser goes, how long it is good for, and its result asked for. */
|
|
11
|
+
begin(): Promise<PolledSignIn>;
|
|
12
|
+
}
|
|
13
|
+
export interface PolledSignIn {
|
|
14
|
+
url: string;
|
|
15
|
+
/** Seconds. */
|
|
16
|
+
expiresIn: number;
|
|
17
|
+
/** The account once agreed to; `pending` while not yet. Throws once refused or too late. */
|
|
18
|
+
poll(): Promise<SignInAccount | 'pending'>;
|
|
19
|
+
}
|
|
20
|
+
interface PolledConfiguration {
|
|
21
|
+
authorization_endpoint: string;
|
|
22
|
+
token_endpoint: string;
|
|
23
|
+
userinfo_endpoint: string;
|
|
24
|
+
pushed_authorization_request_endpoint: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PushedSignInOptions {
|
|
27
|
+
/** The account is `<id>:<sub>`. */
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
issuer: string;
|
|
31
|
+
clientId: string;
|
|
32
|
+
/** What the provider shows the user its sign-in is for, when it knows several of one client. */
|
|
33
|
+
cliId?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The server of `issuer` (its openid-configuration says where): PAR, then `<par endpoint>/poll`, the code and userinfo. The
|
|
37
|
+
* account is `<id>:<username>` (as TA_GATEWAY_ADMINS and Settings, Access name it), `<id>:<sub>` without one.
|
|
38
|
+
*/
|
|
39
|
+
export declare class PushedSignIn implements PolledSignInProvider {
|
|
40
|
+
protected readonly options: PushedSignInOptions;
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly polled: true;
|
|
44
|
+
protected configuration?: Promise<PolledConfiguration>;
|
|
45
|
+
constructor(options: PushedSignInOptions);
|
|
46
|
+
begin(): Promise<PolledSignIn>;
|
|
47
|
+
protected poll(config: PolledConfiguration, url: string, verifier: string): Promise<SignInAccount | 'pending'>;
|
|
48
|
+
protected discover(): Promise<PolledConfiguration>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { SignInUtil } from './sign-in-flow.js';
|
|
3
|
+
import { SignInError, SignInHttp } from './sign-in-provider.js';
|
|
4
|
+
/**
|
|
5
|
+
* The server of `issuer` (its openid-configuration says where): PAR, then `<par endpoint>/poll`, the code and userinfo. The
|
|
6
|
+
* account is `<id>:<username>` (as TA_GATEWAY_ADMINS and Settings, Access name it), `<id>:<sub>` without one.
|
|
7
|
+
*/
|
|
8
|
+
export class PushedSignIn {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.polled = true;
|
|
12
|
+
this.id = options.id;
|
|
13
|
+
this.name = options.name;
|
|
14
|
+
}
|
|
15
|
+
async begin() {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const config = await this.discover();
|
|
18
|
+
if (!config.pushed_authorization_request_endpoint) {
|
|
19
|
+
throw new SignInError(`${this.name}: no pushed authorization requests`);
|
|
20
|
+
}
|
|
21
|
+
const { verifier, challenge } = SignInUtil.pkce();
|
|
22
|
+
const pushed = await SignInHttp.json(config.pushed_authorization_request_endpoint, SignInHttp.form({
|
|
23
|
+
client_id: this.options.clientId,
|
|
24
|
+
response_type: 'code',
|
|
25
|
+
code_challenge: challenge,
|
|
26
|
+
code_challenge_method: 'S256',
|
|
27
|
+
state: randomBytes(18).toString('base64url'),
|
|
28
|
+
scope: 'openid profile email',
|
|
29
|
+
login_only: 'true',
|
|
30
|
+
}));
|
|
31
|
+
if (!pushed.request_uri) {
|
|
32
|
+
throw new SignInError(`${this.name}: ${(_b = (_a = pushed.error_description) !== null && _a !== void 0 ? _a : pushed.error) !== null && _b !== void 0 ? _b : 'no request'}`);
|
|
33
|
+
}
|
|
34
|
+
const requestUri = pushed.request_uri;
|
|
35
|
+
const url = SignInHttp.url(config.authorization_endpoint, { client_id: this.options.clientId, request_uri: requestUri, cliId: this.options.cliId });
|
|
36
|
+
const poll = SignInHttp.url(`${config.pushed_authorization_request_endpoint}/poll`, { request_uri: requestUri, client_id: this.options.clientId });
|
|
37
|
+
return { url, expiresIn: Number(pushed.expires_in) || 300, poll: () => this.poll(config, poll, verifier) };
|
|
38
|
+
}
|
|
39
|
+
async poll(config, url, verifier) {
|
|
40
|
+
var _a;
|
|
41
|
+
var _b, _c, _d, _e;
|
|
42
|
+
const response = await fetch(url, { headers: { Accept: 'application/json' }, signal: AbortSignal.timeout(10000) });
|
|
43
|
+
if (response.status === 404) {
|
|
44
|
+
throw new SignInError(`${this.name}: the sign-in expired`);
|
|
45
|
+
}
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
// Down for a moment: asked again.
|
|
48
|
+
return 'pending';
|
|
49
|
+
}
|
|
50
|
+
const result = (await response.json().catch(() => ({})));
|
|
51
|
+
if (result.status === 'pending' || (result.status === 'completed' && !result.code) || !result.status) {
|
|
52
|
+
return 'pending';
|
|
53
|
+
}
|
|
54
|
+
if (result.status !== 'completed' || !result.code) {
|
|
55
|
+
throw new SignInError(`${this.name}: ${(_c = (_b = result.error_description) !== null && _b !== void 0 ? _b : result.error) !== null && _c !== void 0 ? _c : result.status}`);
|
|
56
|
+
}
|
|
57
|
+
const token = await SignInHttp.json(config.token_endpoint, SignInHttp.form({
|
|
58
|
+
grant_type: 'authorization_code',
|
|
59
|
+
code: result.code,
|
|
60
|
+
code_verifier: verifier,
|
|
61
|
+
client_id: this.options.clientId,
|
|
62
|
+
...(result.redirect_uri ? { redirect_uri: result.redirect_uri } : {}),
|
|
63
|
+
}));
|
|
64
|
+
if (!token.access_token) {
|
|
65
|
+
throw new SignInError(`${this.name}: ${(_e = (_d = token.error_description) !== null && _d !== void 0 ? _d : token.error) !== null && _e !== void 0 ? _e : 'no access token'}`);
|
|
66
|
+
}
|
|
67
|
+
const user = await SignInHttp.json(config.userinfo_endpoint, { headers: { Authorization: `Bearer ${token.access_token}`, Accept: 'application/json' } });
|
|
68
|
+
// The login a company's people know each other by (`username`), else the id it gives: `iam:<login>`, as `user:<login>` of a link.
|
|
69
|
+
const login = (_a = (user.username || user.preferred_username || user.sub)) === null || _a === void 0 ? void 0 : _a.trim();
|
|
70
|
+
if (!login) {
|
|
71
|
+
throw new SignInError(`${this.name}: the account has no id`);
|
|
72
|
+
}
|
|
73
|
+
return { id: `${this.id}:${login}`, name: user.name || user.nickname || login, avatar: user.picture };
|
|
74
|
+
}
|
|
75
|
+
discover() {
|
|
76
|
+
if (!this.configuration) {
|
|
77
|
+
this.configuration = SignInHttp.json(`${this.options.issuer.replace(/\/+$/, '')}/.well-known/openid-configuration`);
|
|
78
|
+
this.configuration.catch(() => (this.configuration = undefined));
|
|
79
|
+
}
|
|
80
|
+
return this.configuration;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=polled-sign-in.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { TaDeviceSignInState } from '@celljs/ta-protocol';
|
|
2
|
+
import type { AccessStore } from './access-store.js';
|
|
3
|
+
import type { SignInAccount } from './sign-in-provider.js';
|
|
4
|
+
/** How long the user has to sign in in a browser once the device asked. */
|
|
5
|
+
export declare const DEVICE_CODE_TTL_MS: number;
|
|
6
|
+
/** How long a device signed in by an account not let in yet waits for it to be: it gets its token once it is. */
|
|
7
|
+
export declare const DEVICE_WAIT_TTL_MS: number;
|
|
8
|
+
/** How often a device polls. */
|
|
9
|
+
export declare const DEVICE_POLL_MS = 2000;
|
|
10
|
+
/** Devices under way at most: anyone may ask for a code. */
|
|
11
|
+
export declare const MAX_DEVICE_SIGN_INS = 1000;
|
|
12
|
+
interface DeviceSignIn {
|
|
13
|
+
device: string;
|
|
14
|
+
code: string;
|
|
15
|
+
/** What the device says it is, for the list of sign-ins. */
|
|
16
|
+
name?: string;
|
|
17
|
+
at: number;
|
|
18
|
+
/** Who signed in for it, in a browser. */
|
|
19
|
+
account?: SignInAccount;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace SignInDevicesUtil {
|
|
22
|
+
/** `ABCD-EFGH`: 25⁸ codes, of which a few hundred live at once, each for minutes. */
|
|
23
|
+
function code(): string;
|
|
24
|
+
/** A code as the user may type it: any case, with or without its dash. */
|
|
25
|
+
function normalize(code: string): string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Devices signing in as OAuth 2.0's device flow (TA_DEVICE_SIGN_IN_PATH): kept in memory, as the sign-ins under way
|
|
29
|
+
* of SignInFlow; a device that asked before a restart asks again. Whether an account is let in stays the store's: a
|
|
30
|
+
* device of one not let in waits, its account among the requests, and gets its token once let in.
|
|
31
|
+
*/
|
|
32
|
+
export declare class SignInDevices {
|
|
33
|
+
protected readonly store: AccessStore;
|
|
34
|
+
protected readonly byCode: Map<string, DeviceSignIn>;
|
|
35
|
+
protected readonly byDevice: Map<string, DeviceSignIn>;
|
|
36
|
+
constructor(store: AccessStore);
|
|
37
|
+
start(name: string | undefined, now?: number): {
|
|
38
|
+
device: string;
|
|
39
|
+
code: string;
|
|
40
|
+
expiresAt: number;
|
|
41
|
+
};
|
|
42
|
+
/** What the device of a code said it is (its user agent), for the page that lets it in to show; none once used or late. */
|
|
43
|
+
name(code: string, now?: number): string | undefined;
|
|
44
|
+
/** Whether a code waits for someone to sign in for it, as a browser takes it to the provider and back. */
|
|
45
|
+
open(code: string, now?: number): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* `account` signed in for the device of `code`, in a browser: let in, the device gets its token at its next poll; not,
|
|
48
|
+
* it waits among the requests. False for a code unknown, too late or signed in for already.
|
|
49
|
+
*/
|
|
50
|
+
signedIn(code: string, account: SignInAccount, now?: number): boolean;
|
|
51
|
+
poll(device: string, now?: number): TaDeviceSignInState;
|
|
52
|
+
protected remove(entry: DeviceSignIn): void;
|
|
53
|
+
protected prune(now: number): void;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { randomBytes, randomInt } from 'node:crypto';
|
|
2
|
+
/** How long the user has to sign in in a browser once the device asked. */
|
|
3
|
+
export const DEVICE_CODE_TTL_MS = 10 * 60 * 1000;
|
|
4
|
+
/** How long a device signed in by an account not let in yet waits for it to be: it gets its token once it is. */
|
|
5
|
+
export const DEVICE_WAIT_TTL_MS = 24 * 3600 * 1000;
|
|
6
|
+
/** How often a device polls. */
|
|
7
|
+
export const DEVICE_POLL_MS = 2000;
|
|
8
|
+
/** Devices under way at most: anyone may ask for a code. */
|
|
9
|
+
export const MAX_DEVICE_SIGN_INS = 1000;
|
|
10
|
+
/** No 0/O, 1/I/L, 2/Z, 5/S, 8/B: read off one screen and checked against another. */
|
|
11
|
+
const ALPHABET = 'ACDEFGHJKMNPQRTUVWXY34679';
|
|
12
|
+
export var SignInDevicesUtil;
|
|
13
|
+
(function (SignInDevicesUtil) {
|
|
14
|
+
/** `ABCD-EFGH`: 25⁸ codes, of which a few hundred live at once, each for minutes. */
|
|
15
|
+
function code() {
|
|
16
|
+
let text = '';
|
|
17
|
+
for (let i = 0; i < 8; i++) {
|
|
18
|
+
text += ALPHABET[randomInt(ALPHABET.length)];
|
|
19
|
+
}
|
|
20
|
+
return `${text.slice(0, 4)}-${text.slice(4)}`;
|
|
21
|
+
}
|
|
22
|
+
SignInDevicesUtil.code = code;
|
|
23
|
+
/** A code as the user may type it: any case, with or without its dash. */
|
|
24
|
+
function normalize(code) {
|
|
25
|
+
const plain = code.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
|
26
|
+
return plain.length === 8 ? `${plain.slice(0, 4)}-${plain.slice(4)}` : '';
|
|
27
|
+
}
|
|
28
|
+
SignInDevicesUtil.normalize = normalize;
|
|
29
|
+
})(SignInDevicesUtil || (SignInDevicesUtil = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Devices signing in as OAuth 2.0's device flow (TA_DEVICE_SIGN_IN_PATH): kept in memory, as the sign-ins under way
|
|
32
|
+
* of SignInFlow; a device that asked before a restart asks again. Whether an account is let in stays the store's: a
|
|
33
|
+
* device of one not let in waits, its account among the requests, and gets its token once let in.
|
|
34
|
+
*/
|
|
35
|
+
export class SignInDevices {
|
|
36
|
+
constructor(store) {
|
|
37
|
+
this.store = store;
|
|
38
|
+
this.byCode = new Map();
|
|
39
|
+
this.byDevice = new Map();
|
|
40
|
+
}
|
|
41
|
+
start(name, now = Date.now()) {
|
|
42
|
+
this.prune(now);
|
|
43
|
+
for (const oldest of this.byCode.values()) {
|
|
44
|
+
if (this.byCode.size < MAX_DEVICE_SIGN_INS) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
this.remove(oldest);
|
|
48
|
+
}
|
|
49
|
+
let code = SignInDevicesUtil.code();
|
|
50
|
+
while (this.byCode.has(code)) {
|
|
51
|
+
code = SignInDevicesUtil.code();
|
|
52
|
+
}
|
|
53
|
+
const entry = { device: randomBytes(32).toString('base64url'), code, name: (name === null || name === void 0 ? void 0 : name.trim().slice(0, 100)) || undefined, at: now };
|
|
54
|
+
this.byCode.set(code, entry);
|
|
55
|
+
this.byDevice.set(entry.device, entry);
|
|
56
|
+
return { device: entry.device, code, expiresAt: now + DEVICE_CODE_TTL_MS };
|
|
57
|
+
}
|
|
58
|
+
/** What the device of a code said it is (its user agent), for the page that lets it in to show; none once used or late. */
|
|
59
|
+
name(code, now = Date.now()) {
|
|
60
|
+
const entry = this.byCode.get(SignInDevicesUtil.normalize(code));
|
|
61
|
+
return entry && !entry.account && now - entry.at <= DEVICE_CODE_TTL_MS ? entry.name : undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Whether a code waits for someone to sign in for it, as a browser takes it to the provider and back. */
|
|
64
|
+
open(code, now = Date.now()) {
|
|
65
|
+
const entry = this.byCode.get(SignInDevicesUtil.normalize(code));
|
|
66
|
+
return Boolean(entry && !entry.account && now - entry.at <= DEVICE_CODE_TTL_MS);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* `account` signed in for the device of `code`, in a browser: let in, the device gets its token at its next poll; not,
|
|
70
|
+
* it waits among the requests. False for a code unknown, too late or signed in for already.
|
|
71
|
+
*/
|
|
72
|
+
signedIn(code, account, now = Date.now()) {
|
|
73
|
+
const entry = this.byCode.get(SignInDevicesUtil.normalize(code));
|
|
74
|
+
if (!entry || entry.account || now - entry.at > DEVICE_CODE_TTL_MS) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
entry.account = account;
|
|
78
|
+
entry.at = now;
|
|
79
|
+
if (!this.store.allows(account.id)) {
|
|
80
|
+
this.store.request(account, now);
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
poll(device, now = Date.now()) {
|
|
85
|
+
const entry = this.byDevice.get(device);
|
|
86
|
+
if (!entry || now - entry.at > (entry.account ? DEVICE_WAIT_TTL_MS : DEVICE_CODE_TTL_MS)) {
|
|
87
|
+
if (entry) {
|
|
88
|
+
this.remove(entry);
|
|
89
|
+
}
|
|
90
|
+
return { status: 'expired' };
|
|
91
|
+
}
|
|
92
|
+
if (!entry.account) {
|
|
93
|
+
return { status: 'pending' };
|
|
94
|
+
}
|
|
95
|
+
if (!this.store.allows(entry.account.id)) {
|
|
96
|
+
return { status: 'waiting', account: entry.account.id };
|
|
97
|
+
}
|
|
98
|
+
this.remove(entry);
|
|
99
|
+
return { status: 'done', token: this.store.signIn(entry.account, entry.name, now), account: entry.account.id };
|
|
100
|
+
}
|
|
101
|
+
remove(entry) {
|
|
102
|
+
this.byCode.delete(entry.code);
|
|
103
|
+
this.byDevice.delete(entry.device);
|
|
104
|
+
}
|
|
105
|
+
prune(now) {
|
|
106
|
+
for (const entry of this.byCode.values()) {
|
|
107
|
+
if (now - entry.at > (entry.account ? DEVICE_WAIT_TTL_MS : DEVICE_CODE_TTL_MS)) {
|
|
108
|
+
this.remove(entry);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=sign-in-devices.js.map
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'node:http';
|
|
2
2
|
import type { AccessStore } from './access-store.js';
|
|
3
|
+
import type { PolledSignInProvider } from './polled-sign-in.js';
|
|
4
|
+
import { SignInDevices } from './sign-in-devices.js';
|
|
3
5
|
import { type SignInAccount, type SignInProvider } from './sign-in-provider.js';
|
|
4
6
|
/** Sign-ins under way at most: anyone may start one without a token, and each is kept until it ends or expires. */
|
|
5
7
|
export declare const MAX_PENDING_SIGN_INS = 1000;
|
|
8
|
+
/** How often a polled provider is asked whether the user agreed. */
|
|
9
|
+
export declare const POLL_MS = 2000;
|
|
6
10
|
interface Pending {
|
|
7
11
|
provider: string;
|
|
8
12
|
verifier: string;
|
|
@@ -11,13 +15,20 @@ interface Pending {
|
|
|
11
15
|
bind: boolean;
|
|
12
16
|
/** Only says who signed in (TaHostAccounts.verify): lets no one into ta serve. */
|
|
13
17
|
verify?: true;
|
|
18
|
+
/** For the device of this code (SignInDevices), not the browser: the browser gets no token. */
|
|
19
|
+
device?: string;
|
|
14
20
|
at: number;
|
|
15
21
|
}
|
|
22
|
+
/** In with a token, told to wait, or signed in for a device (`allowed`: it gets its token at once, else once let in). */
|
|
16
23
|
export type SignInResult = {
|
|
17
24
|
token: string;
|
|
18
25
|
account: SignInAccount;
|
|
19
26
|
} | {
|
|
20
27
|
denied: SignInAccount;
|
|
28
|
+
} | {
|
|
29
|
+
device: string;
|
|
30
|
+
account: SignInAccount;
|
|
31
|
+
allowed: boolean;
|
|
21
32
|
};
|
|
22
33
|
export declare namespace SignInUtil {
|
|
23
34
|
/**
|
|
@@ -41,8 +52,31 @@ export declare class SignInFlow {
|
|
|
41
52
|
providers: SignInProvider[];
|
|
42
53
|
readonly store: AccessStore;
|
|
43
54
|
readonly publicUrl?: string | undefined;
|
|
44
|
-
|
|
55
|
+
/** Those the browser signs in at without coming back (PolledSignInProvider): for devices, whose code they sign in for. */
|
|
56
|
+
polled: PolledSignInProvider[];
|
|
57
|
+
constructor(providers: SignInProvider[], store: AccessStore, publicUrl?: string | undefined,
|
|
58
|
+
/** Those the browser signs in at without coming back (PolledSignInProvider): for devices, whose code they sign in for. */
|
|
59
|
+
polled?: PolledSignInProvider[]);
|
|
60
|
+
/** What Ta asks each polled provider for, by the code of the device it is for: one at a time for a code. */
|
|
61
|
+
protected readonly polling: Map<string, {
|
|
62
|
+
stopped: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
protected pollMs: number;
|
|
65
|
+
/**
|
|
66
|
+
* Signs in with a polled provider for the device of `code`: where the browser goes; Ta asks the provider until it says
|
|
67
|
+
* who agreed, and lets the device in as them (SignInDevices.signedIn), or until it is too late or the code taken.
|
|
68
|
+
*/
|
|
69
|
+
startPolled(providerId: string, code: string, now?: number): Promise<string>;
|
|
70
|
+
protected pollUntil(provider: PolledSignInProvider, signIn: {
|
|
71
|
+
poll(): Promise<SignInAccount | 'pending'>;
|
|
72
|
+
}, code: string, run: {
|
|
73
|
+
stopped: boolean;
|
|
74
|
+
}, deadline: number): Promise<void>;
|
|
75
|
+
/** Stops what is asked of polled providers: the server closes. */
|
|
76
|
+
stopPolling(): void;
|
|
45
77
|
protected readonly pending: Map<string, Pending>;
|
|
78
|
+
/** The devices that sign in through a browser (TA_DEVICE_SIGN_IN_PATH). */
|
|
79
|
+
readonly devices: SignInDevices;
|
|
46
80
|
protected readonly binds: Map<string, {
|
|
47
81
|
provider: string;
|
|
48
82
|
at: number;
|
|
@@ -50,8 +84,8 @@ export declare class SignInFlow {
|
|
|
50
84
|
provider(id: string): SignInProvider | undefined;
|
|
51
85
|
/** A link, used once, that signs in with `provider` and lets the account in. */
|
|
52
86
|
bindUrl(provider: string, now?: number): string;
|
|
53
|
-
/** Where the browser goes, and the state that comes back with it. */
|
|
54
|
-
start(providerId: string, origin: string, bind?: string, now?: number): Promise<{
|
|
87
|
+
/** Where the browser goes, and the state that comes back with it; with `device`, it signs in for the device of that code. */
|
|
88
|
+
start(providerId: string, origin: string, bind?: string, now?: number, device?: string): Promise<{
|
|
55
89
|
url: string;
|
|
56
90
|
state: string;
|
|
57
91
|
}>;
|
|
@@ -62,7 +96,7 @@ export declare class SignInFlow {
|
|
|
62
96
|
}>;
|
|
63
97
|
/** The account of a sign-in of {@link startVerify}: no token, nothing let in. */
|
|
64
98
|
verify(state: string, code: string, now?: number): Promise<SignInAccount>;
|
|
65
|
-
protected begin(providerId: string, redirectUri: string, kind: Pick<Pending, 'bind' | 'verify'>, now: number): Promise<{
|
|
99
|
+
protected begin(providerId: string, redirectUri: string, kind: Pick<Pending, 'bind' | 'verify' | 'device'>, now: number): Promise<{
|
|
66
100
|
url: string;
|
|
67
101
|
state: string;
|
|
68
102
|
}>;
|