@flipstream/sdk 0.0.0-stage → 0.5.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/CHANGELOG.md +102 -0
- package/LICENSE +202 -0
- package/README.md +491 -2
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -0
- package/dist/auth/discovery.d.ts +23 -0
- package/dist/auth/discovery.js +71 -0
- package/dist/auth/discovery.js.map +1 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/pkce.d.ts +10 -0
- package/dist/auth/pkce.js +25 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/signIn.d.ts +106 -0
- package/dist/auth/signIn.js +125 -0
- package/dist/auth/signIn.js.map +1 -0
- package/dist/auth/tokenEndpoint.d.ts +18 -0
- package/dist/auth/tokenEndpoint.js +36 -0
- package/dist/auth/tokenEndpoint.js.map +1 -0
- package/dist/auth/transport.d.ts +18 -0
- package/dist/auth/transport.js +26 -0
- package/dist/auth/transport.js.map +1 -0
- package/dist/core/body.d.ts +14 -0
- package/dist/core/body.js +69 -0
- package/dist/core/body.js.map +1 -0
- package/dist/core/call.d.ts +17 -0
- package/dist/core/call.js +116 -0
- package/dist/core/call.js.map +1 -0
- package/dist/core/fetch.d.ts +43 -0
- package/dist/core/fetch.js +130 -0
- package/dist/core/fetch.js.map +1 -0
- package/dist/core/read.d.ts +17 -0
- package/dist/core/read.js +92 -0
- package/dist/core/read.js.map +1 -0
- package/dist/core/result.d.ts +96 -0
- package/dist/core/result.js +42 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/retry.d.ts +40 -0
- package/dist/core/retry.js +41 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/transport.d.ts +62 -0
- package/dist/core/transport.js +9 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/flipstream.d.ts +52 -0
- package/dist/flipstream.js +36 -0
- package/dist/flipstream.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/node/clientSecret.d.ts +41 -0
- package/dist/node/clientSecret.js +124 -0
- package/dist/node/clientSecret.js.map +1 -0
- package/dist/node/fileLock.d.ts +27 -0
- package/dist/node/fileLock.js +248 -0
- package/dist/node/fileLock.js.map +1 -0
- package/dist/node/headless.d.ts +25 -0
- package/dist/node/headless.js +41 -0
- package/dist/node/headless.js.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.js +11 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/loopback.d.ts +77 -0
- package/dist/node/loopback.js +183 -0
- package/dist/node/loopback.js.map +1 -0
- package/dist/node/session.d.ts +192 -0
- package/dist/node/session.js +480 -0
- package/dist/node/session.js.map +1 -0
- package/dist/query/catalog.d.ts +15 -0
- package/dist/query/catalog.js +41 -0
- package/dist/query/catalog.js.map +1 -0
- package/dist/query/errors.d.ts +8 -0
- package/dist/query/errors.js +16 -0
- package/dist/query/errors.js.map +1 -0
- package/dist/query/health.d.ts +16 -0
- package/dist/query/health.js +18 -0
- package/dist/query/health.js.map +1 -0
- package/dist/query/query.d.ts +35 -0
- package/dist/query/query.js +47 -0
- package/dist/query/query.js.map +1 -0
- package/dist/recorded/query-planner/catalog-google_search_console.json +140 -0
- package/dist/recorded/query-planner/catalog.json +1234 -0
- package/dist/spec/query-planner/index.d.ts +1 -0
- package/dist/spec/query-planner/index.js +3 -0
- package/dist/spec/query-planner/index.js.map +1 -0
- package/dist/spec/query-planner/types.gen.d.ts +300 -0
- package/dist/spec/query-planner/types.gen.js +3 -0
- package/dist/spec/query-planner/types.gen.js.map +1 -0
- package/dist/spec/query-planner/zod.gen.d.ts +325 -0
- package/dist/spec/query-planner/zod.gen.js +137 -0
- package/dist/spec/query-planner/zod.gen.js.map +1 -0
- package/package.json +99 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type Server } from 'node:http';
|
|
2
|
+
import { type SignInError, type SignInRequest, type Tokens } from '../auth/signIn.js';
|
|
3
|
+
import type { AuthCallOptions } from '../auth/transport.js';
|
|
4
|
+
import { type PastedRedirect } from './headless.js';
|
|
5
|
+
export interface LoopbackSignInOptions extends Omit<SignInRequest, 'redirectUri'>, AuthCallOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Shows the person where to sign in: opens their browser, or prints the URL. Called once, when
|
|
8
|
+
* the port is open. The SDK opens nothing itself and writes nothing to the terminal.
|
|
9
|
+
*/
|
|
10
|
+
readonly open: (url: string) => void | Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Reads the address the person pastes back when their browser can't reach this machine's port (a
|
|
13
|
+
* remote session), for this same sign-in. Called once, just after `open`; prompting is the app's.
|
|
14
|
+
* Whichever comes first is taken, the port's redirect or the paste, and a paste is checked as
|
|
15
|
+
* `parsePastedRedirect` checks one. `signal` fires once a paste can no longer be taken (the port's
|
|
16
|
+
* redirect came first, or the sign-in ended): stop reading then. A rejection is `paste_failed`.
|
|
17
|
+
*/
|
|
18
|
+
readonly readPasted?: (signal: AbortSignal) => Promise<string>;
|
|
19
|
+
/** The pages the browser shows after the redirect; neutral ones when left out (HTML). */
|
|
20
|
+
readonly page?: {
|
|
21
|
+
readonly signedIn: string;
|
|
22
|
+
readonly failed: string;
|
|
23
|
+
};
|
|
24
|
+
/** How long to wait for the redirect, on the port or pasted: 5 minutes when left out. */
|
|
25
|
+
readonly timeoutMs?: number;
|
|
26
|
+
}
|
|
27
|
+
export type LoopbackError = SignInError
|
|
28
|
+
/** The pasted address isn't a URL, or isn't this sign-in's redirect. Nothing was sent. */
|
|
29
|
+
| Extract<PastedRedirect, {
|
|
30
|
+
readonly ok: false;
|
|
31
|
+
}>['error']
|
|
32
|
+
/** The port couldn't be opened. */
|
|
33
|
+
| {
|
|
34
|
+
readonly kind: 'listen_failed';
|
|
35
|
+
readonly cause: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** `open` threw, so nobody could have signed in. */
|
|
38
|
+
| {
|
|
39
|
+
readonly kind: 'open_failed';
|
|
40
|
+
readonly cause: unknown;
|
|
41
|
+
}
|
|
42
|
+
/** `readPasted` rejected before a redirect was taken. */
|
|
43
|
+
| {
|
|
44
|
+
readonly kind: 'paste_failed';
|
|
45
|
+
readonly cause: unknown;
|
|
46
|
+
};
|
|
47
|
+
export type LoopbackResult = {
|
|
48
|
+
readonly ok: true;
|
|
49
|
+
readonly data: Tokens;
|
|
50
|
+
} | {
|
|
51
|
+
readonly ok: false;
|
|
52
|
+
readonly error: LoopbackError;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Signs the person in through their browser, with the redirect `http://127.0.0.1:<port>/callback`
|
|
56
|
+
* on a port of the system's choosing, bound to 127.0.0.1 only. The redirect, on the port or pasted
|
|
57
|
+
* (`readPasted`), is checked as `finishSignIn` checks one (its state first), and its code
|
|
58
|
+
* exchanged. The first redirect decides, if it comes within `timeoutMs`, and only its code is ever
|
|
59
|
+
* exchanged; the port is closed on every path: signed in, refused, `timeout`, `aborted`,
|
|
60
|
+
* `open_failed` or `paste_failed`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function signInWithLoopback(options: LoopbackSignInOptions): Promise<LoopbackResult>;
|
|
63
|
+
type Listening = {
|
|
64
|
+
readonly ok: true;
|
|
65
|
+
readonly server: Server;
|
|
66
|
+
readonly port: number;
|
|
67
|
+
readonly close: () => Promise<void>;
|
|
68
|
+
} | {
|
|
69
|
+
readonly ok: false;
|
|
70
|
+
readonly cause: unknown;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A server on 127.0.0.1 only (never every address: the code it receives would be reachable from
|
|
74
|
+
* the network), on a port of the system's choosing. `close` ends every connection with it.
|
|
75
|
+
*/
|
|
76
|
+
export declare function listenOnLoopback(): Promise<Listening>;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { finishSignIn, startSignIn } from '../auth/signIn.js';
|
|
3
|
+
import { parsePastedRedirect } from './headless.js';
|
|
4
|
+
const WAIT_MS = 300_000;
|
|
5
|
+
const PAGE = (heading, text) => `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>${heading}</title></head>` +
|
|
6
|
+
`<body style="font-family:system-ui,sans-serif;max-width:32rem;margin:4rem auto;padding:0 1rem">` +
|
|
7
|
+
`<h1>${heading}</h1><p>${text}</p>` +
|
|
8
|
+
// The code is good once, and is then exchanged; still, it leaves the address bar.
|
|
9
|
+
`<script>try{history.replaceState(null,'',location.pathname)}catch(e){}</script></body></html>`;
|
|
10
|
+
const PAGES = { signedIn: PAGE('Signed in', 'You can close this tab.'), failed: PAGE('Sign-in failed', 'Return to the app for details.') };
|
|
11
|
+
const asError = (error) => (error instanceof Error ? error : new Error(String(error)));
|
|
12
|
+
/**
|
|
13
|
+
* Signs the person in through their browser, with the redirect `http://127.0.0.1:<port>/callback`
|
|
14
|
+
* on a port of the system's choosing, bound to 127.0.0.1 only. The redirect, on the port or pasted
|
|
15
|
+
* (`readPasted`), is checked as `finishSignIn` checks one (its state first), and its code
|
|
16
|
+
* exchanged. The first redirect decides, if it comes within `timeoutMs`, and only its code is ever
|
|
17
|
+
* exchanged; the port is closed on every path: signed in, refused, `timeout`, `aborted`,
|
|
18
|
+
* `open_failed` or `paste_failed`.
|
|
19
|
+
*/
|
|
20
|
+
export async function signInWithLoopback(options) {
|
|
21
|
+
const { signal, readPasted } = options;
|
|
22
|
+
// A function, so each look reads the signal as it is now, past the awaits between them.
|
|
23
|
+
const aborted = () => signal?.aborted === true;
|
|
24
|
+
if (aborted())
|
|
25
|
+
return { ok: false, error: { kind: 'aborted' } };
|
|
26
|
+
const pages = options.page ?? PAGES;
|
|
27
|
+
const listening = await listenOnLoopback();
|
|
28
|
+
if (!listening.ok)
|
|
29
|
+
return { ok: false, error: { kind: 'listen_failed', cause: listening.cause } };
|
|
30
|
+
const { server, close } = listening;
|
|
31
|
+
const redirectUri = `http://127.0.0.1:${String(listening.port)}/callback`;
|
|
32
|
+
// The reader's signal: it fires once a paste can no longer be taken.
|
|
33
|
+
const reading = new AbortController();
|
|
34
|
+
let timer;
|
|
35
|
+
let onAbort;
|
|
36
|
+
try {
|
|
37
|
+
const { url, pending } = await startSignIn({ server: options.server, clientId: options.clientId, scopes: options.scopes, redirectUri });
|
|
38
|
+
// An abort while the port opened, or the URL was made, fired no event this could still hear.
|
|
39
|
+
if (aborted())
|
|
40
|
+
return { ok: false, error: { kind: 'aborted' } };
|
|
41
|
+
return await new Promise((resolve, reject) => {
|
|
42
|
+
/*
|
|
43
|
+
* One phase, so the sign-in ends once and one code is exchanged (D446). `listening`: no
|
|
44
|
+
* redirect yet; the timeout, a failing opener or reader, or a refused paste ends the wait.
|
|
45
|
+
* `exchanging`: one redirect was taken, and only its exchange or an abort decides now; the
|
|
46
|
+
* port answers anything else with the failure page, and a paste is dropped. `done`: settled.
|
|
47
|
+
*/
|
|
48
|
+
let phase = 'listening';
|
|
49
|
+
const settle = (result) => {
|
|
50
|
+
phase = 'done';
|
|
51
|
+
resolve(result);
|
|
52
|
+
};
|
|
53
|
+
const fail = (error) => {
|
|
54
|
+
phase = 'done';
|
|
55
|
+
reject(asError(error));
|
|
56
|
+
};
|
|
57
|
+
const endWait = (error) => {
|
|
58
|
+
if (phase === 'listening')
|
|
59
|
+
settle({ ok: false, error });
|
|
60
|
+
};
|
|
61
|
+
const exchanged = (result) => {
|
|
62
|
+
if (phase === 'exchanging')
|
|
63
|
+
settle(result);
|
|
64
|
+
};
|
|
65
|
+
// Takes the redirect: the one exchange of this sign-in.
|
|
66
|
+
const exchange = (callbackUrl) => {
|
|
67
|
+
phase = 'exchanging';
|
|
68
|
+
// The redirect came in time: the exchange has its own deadline (`finishSignIn`).
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
reading.abort();
|
|
71
|
+
return finishSignIn(callbackUrl, pending, { signal, fetch: options.fetch });
|
|
72
|
+
};
|
|
73
|
+
timer = setTimeout(() => {
|
|
74
|
+
endWait({ kind: 'timeout' });
|
|
75
|
+
}, options.timeoutMs ?? WAIT_MS);
|
|
76
|
+
onAbort = () => {
|
|
77
|
+
if (phase !== 'done')
|
|
78
|
+
settle({ ok: false, error: { kind: 'aborted' } });
|
|
79
|
+
};
|
|
80
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
81
|
+
server.on('request', (request, response) => {
|
|
82
|
+
// A request target no URL can be made of (`//[`) is no redirect, and must not throw here,
|
|
83
|
+
// where nothing would catch it.
|
|
84
|
+
const target = request.url ?? '/';
|
|
85
|
+
const callbackUrl = URL.canParse(target, redirectUri) ? new URL(target, redirectUri) : null;
|
|
86
|
+
if (callbackUrl?.pathname !== '/callback' || phase !== 'listening') {
|
|
87
|
+
void send(response, callbackUrl === null ? 400 : 404, pages.failed);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// The page is sent before the sign-in settles, so closing the port can't cut it short.
|
|
91
|
+
exchange(callbackUrl).then(async (result) => {
|
|
92
|
+
await send(response, result.ok ? 200 : 400, result.ok ? pages.signedIn : pages.failed);
|
|
93
|
+
exchanged(result);
|
|
94
|
+
}, async (error) => {
|
|
95
|
+
await send(response, 500, pages.failed);
|
|
96
|
+
fail(error);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
// Neither is awaited: an `open` or a reader that never settles (one waiting on a browser
|
|
100
|
+
// process, or on a person) must not hold back the redirect, the timeout or an abort.
|
|
101
|
+
// `open` is called here, so one that throws at once has ended the wait before the reader
|
|
102
|
+
// would be called: no prompt for a sign-in that already failed.
|
|
103
|
+
let opening = undefined;
|
|
104
|
+
try {
|
|
105
|
+
opening = options.open(url);
|
|
106
|
+
}
|
|
107
|
+
catch (cause) {
|
|
108
|
+
endWait({ kind: 'open_failed', cause });
|
|
109
|
+
}
|
|
110
|
+
Promise.resolve(opening).then(undefined, (cause) => {
|
|
111
|
+
endWait({ kind: 'open_failed', cause });
|
|
112
|
+
});
|
|
113
|
+
if (readPasted !== undefined) {
|
|
114
|
+
Promise.resolve()
|
|
115
|
+
.then(() => (phase === 'listening' ? readPasted(reading.signal) : undefined))
|
|
116
|
+
.then((text) => {
|
|
117
|
+
if (phase !== 'listening')
|
|
118
|
+
return;
|
|
119
|
+
const pasted = parsePastedRedirect(typeof text === 'string' ? text : '', pending);
|
|
120
|
+
if (pasted.ok)
|
|
121
|
+
exchange(pasted.callbackUrl).then(exchanged, fail);
|
|
122
|
+
else
|
|
123
|
+
endWait(pasted.error);
|
|
124
|
+
}, (cause) => {
|
|
125
|
+
endWait({ kind: 'paste_failed', cause });
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
clearTimeout(timer);
|
|
132
|
+
if (onAbort !== undefined)
|
|
133
|
+
signal?.removeEventListener('abort', onAbort);
|
|
134
|
+
reading.abort();
|
|
135
|
+
await close();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A server on 127.0.0.1 only (never every address: the code it receives would be reachable from
|
|
140
|
+
* the network), on a port of the system's choosing. `close` ends every connection with it.
|
|
141
|
+
*/
|
|
142
|
+
export async function listenOnLoopback() {
|
|
143
|
+
const sockets = new Set();
|
|
144
|
+
const server = createServer();
|
|
145
|
+
server.on('connection', (socket) => {
|
|
146
|
+
sockets.add(socket);
|
|
147
|
+
socket.on('close', () => sockets.delete(socket));
|
|
148
|
+
});
|
|
149
|
+
const close = () => new Promise((resolve) => {
|
|
150
|
+
for (const socket of sockets)
|
|
151
|
+
socket.destroy();
|
|
152
|
+
server.close(() => {
|
|
153
|
+
resolve();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
const port = await new Promise((resolve) => {
|
|
157
|
+
server.once('error', (cause) => {
|
|
158
|
+
resolve({ cause });
|
|
159
|
+
});
|
|
160
|
+
server.listen(0, '127.0.0.1', () => {
|
|
161
|
+
const address = server.address();
|
|
162
|
+
resolve(typeof address === 'object' && address !== null ? address.port : { cause: new Error('the server has no port') });
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
if (typeof port === 'number')
|
|
166
|
+
return { ok: true, server, port, close };
|
|
167
|
+
await close();
|
|
168
|
+
return { ok: false, cause: port.cause };
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The page, sent whole: settles once it has left, so closing the port can't cut it short, or at
|
|
172
|
+
* once when the browser has already gone, which no event would then say.
|
|
173
|
+
*/
|
|
174
|
+
function send(response, status, html) {
|
|
175
|
+
if (response.destroyed || response.writableEnded)
|
|
176
|
+
return Promise.resolve();
|
|
177
|
+
response.writeHead(status, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store', connection: 'close' });
|
|
178
|
+
return new Promise((resolve) => {
|
|
179
|
+
response.once('close', resolve);
|
|
180
|
+
response.end(html, resolve);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=loopback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopback.js","sourceRoot":"","sources":["../../src/node/loopback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAA;AAEhG,OAAO,EAAE,YAAY,EAAE,WAAW,EAAwE,MAAM,mBAAmB,CAAA;AAEnI,OAAO,EAAE,mBAAmB,EAAuB,MAAM,eAAe,CAAA;AAyCxE,MAAM,OAAO,GAAG,OAAO,CAAA;AAEvB,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,IAAY,EAAU,EAAE,CACrD,qEAAqE,OAAO,iBAAiB;IAC7F,iGAAiG;IACjG,OAAO,OAAO,WAAW,IAAI,MAAM;IACnC,kFAAkF;IAClF,+FAA+F,CAAA;AACjG,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,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O,EAAE,CAAC,CAAA;IAC5H,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC/B,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { TokenAsk } from '../core/fetch.js';
|
|
2
|
+
import type { ApiError } from '../core/result.js';
|
|
3
|
+
import type { AuthServer } from '../auth/discovery.js';
|
|
4
|
+
import type { Tokens } from '../auth/signIn.js';
|
|
5
|
+
import { type AuthCallOptions } from '../auth/transport.js';
|
|
6
|
+
/** What the app's store holds: `finishSignIn`'s tokens fit. */
|
|
7
|
+
export type SessionTokens = Pick<Tokens, 'accessToken' | 'refreshToken' | 'expiresAt'>;
|
|
8
|
+
/**
|
|
9
|
+
* New tokens from a refresh, for the app to save before anything uses them, or the end of the
|
|
10
|
+
* session. `replaces` is the store's key when the refresh began (D472): its refresh token, or its
|
|
11
|
+
* access token when it has none or an empty one, as `refreshToken || accessToken`. Write only while
|
|
12
|
+
* the store's key is still `replaces` (compare and set, or delete), so a refresh of an old session
|
|
13
|
+
* never overwrites a newer sign-in that another process saved meanwhile.
|
|
14
|
+
*/
|
|
15
|
+
export type TokenUpdate =
|
|
16
|
+
/** A new refresh token came: save both. The one sent is spent. */
|
|
17
|
+
{
|
|
18
|
+
readonly kind: 'rotated';
|
|
19
|
+
readonly accessToken: string;
|
|
20
|
+
readonly refreshToken: string;
|
|
21
|
+
readonly expiresAt?: number;
|
|
22
|
+
readonly replaces: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* This refresh crossed another one, perhaps another process's, and only the access token is
|
|
26
|
+
* new. Keep the refresh token that is stored now: the other refresh may already have saved its
|
|
27
|
+
* new one, and writing back the one this refresh sent would end the session.
|
|
28
|
+
*/
|
|
29
|
+
| {
|
|
30
|
+
readonly kind: 'access-only';
|
|
31
|
+
readonly accessToken: string;
|
|
32
|
+
readonly expiresAt?: number;
|
|
33
|
+
readonly replaces: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The server ended the session (`invalid_grant`): delete the stored tokens, only while the
|
|
37
|
+
* store's key is still `replaces`, so a newer sign-in is kept.
|
|
38
|
+
*/
|
|
39
|
+
| {
|
|
40
|
+
readonly kind: 'cleared';
|
|
41
|
+
readonly replaces: string;
|
|
42
|
+
};
|
|
43
|
+
export interface SessionOptions extends Pick<AuthCallOptions, 'fetch'> {
|
|
44
|
+
/** The server, as `discover` gave it. */
|
|
45
|
+
readonly server: AuthServer;
|
|
46
|
+
/** The app's own OAuth client ID (D421). */
|
|
47
|
+
readonly clientId: string;
|
|
48
|
+
/**
|
|
49
|
+
* The app's client secret, as a confidential client (#123): sent only in the Authorization header
|
|
50
|
+
* of the refresh and the revocation, to `server`'s own endpoints, and their failures then keep
|
|
51
|
+
* no server text (`finishSignIn`'s rule). Left out, the session is a public client's. Never log it.
|
|
52
|
+
*/
|
|
53
|
+
readonly clientSecret?: string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The tokens as the store holds them now, or null when nobody is signed in. Read again before
|
|
56
|
+
* every refresh, so the refresh token sent is the current one, even after another process
|
|
57
|
+
* rotated it, and again just before a refresh's answer is saved.
|
|
58
|
+
*
|
|
59
|
+
* The store's contract (D457): this returns only what `onTokens` has durably saved. Write first,
|
|
60
|
+
* make visible second, so no reader, in this process or another, ever sees tokens whose save
|
|
61
|
+
* may still fail. For example:
|
|
62
|
+
* - the system keychain, whose write is one step that is visible once it has succeeded;
|
|
63
|
+
* - a file, written in full to a temporary name in the same folder, flushed to disk (fsync),
|
|
64
|
+
* renamed over the old one, and the folder flushed too (fsync on the directory, where the
|
|
65
|
+
* platform has one): a reader sees it whole or not at all, and a power cut can't bring back
|
|
66
|
+
* the old file with its spent token.
|
|
67
|
+
*/
|
|
68
|
+
readonly tokens: () => SessionTokens | null | Promise<SessionTokens | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Saves a refresh's tokens, or clears them once the server has ended the session, only while the
|
|
71
|
+
* store's key (`refreshToken || accessToken`) is still `update.replaces`. The session reads the
|
|
72
|
+
* store again just before, and lets the answer go when the store has moved on (a newer sign-in,
|
|
73
|
+
* or a sign-out); comparing and setting on `replaces` closes the moment between that read and
|
|
74
|
+
* this write, and a store that refuses then throws. A refresh's answer is used only once this has
|
|
75
|
+
* settled. When a save fails, the session keeps a rotation's refresh token in memory, the only
|
|
76
|
+
* live one, for its next refresh and for `revoke()` (D456).
|
|
77
|
+
*/
|
|
78
|
+
readonly onTokens: (update: TokenUpdate) => void | Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Runs `work` while holding off every other process's refresh, for a store several Node
|
|
81
|
+
* processes share: `fileLock(path)` from this entry, or the app's own lock on its store. With
|
|
82
|
+
* `fileLock`, keep `tokens` and `onTokens` asynchronous: a holder whose thread is blocked for 10 s
|
|
83
|
+
* loses the lock. A refresh runs inside it (the reads, the request and the save), and so does a
|
|
84
|
+
* revocation.
|
|
85
|
+
* `signal` fires at the refresh's deadline: a lock still held then ends the refresh on time, as
|
|
86
|
+
* `unavailable`, and `work` never sends anything, even if the lock runs it late. A lock that
|
|
87
|
+
* ignores `signal` still holds off the others for as long as it waits.
|
|
88
|
+
*
|
|
89
|
+
* The lock's promise must settle only once `work` has settled, as Web Locks does with its
|
|
90
|
+
* signal: a lock that lets go while `work` still runs (a mutex with a timeout) lets another
|
|
91
|
+
* process in beside a pending save. The session itself waits for `work` before its next turn.
|
|
92
|
+
*
|
|
93
|
+
* Without one, there must be one session per store, shared by everything that uses it: two
|
|
94
|
+
* sessions on one store, in one process (a backend making one per request) or in two, refresh
|
|
95
|
+
* as two processes do. A refresh whose answer takes longer than pulse-auth's 10 s grace can then
|
|
96
|
+
* cross another's refresh of the same token, which pulse-auth reads as reuse, and the session
|
|
97
|
+
* ends.
|
|
98
|
+
*/
|
|
99
|
+
readonly lock?: <T>(work: () => Promise<T>, signal: AbortSignal) => Promise<T>;
|
|
100
|
+
}
|
|
101
|
+
/** Why a session has no token to give. */
|
|
102
|
+
export type SessionFailure =
|
|
103
|
+
/**
|
|
104
|
+
* Nobody is signed in: no tokens, no refresh token, or the server ended the session
|
|
105
|
+
* (`invalid_grant`), after which the stored tokens are cleared (`onTokens`, `cleared`).
|
|
106
|
+
*/
|
|
107
|
+
{
|
|
108
|
+
readonly kind: 'signed-out';
|
|
109
|
+
}
|
|
110
|
+
/** No token within 15 s, or no answer at all: offline, or the server is down. A refresh goes on, and its answer is still saved. */
|
|
111
|
+
| {
|
|
112
|
+
readonly kind: 'unavailable';
|
|
113
|
+
}
|
|
114
|
+
/** The app's store failed: reading the tokens, saving a refresh's, or taking its lock. */
|
|
115
|
+
| {
|
|
116
|
+
readonly kind: 'store_failed';
|
|
117
|
+
readonly step: 'read' | 'save' | 'lock';
|
|
118
|
+
readonly cause: unknown;
|
|
119
|
+
}
|
|
120
|
+
/** The refresh failed any other way: the server refused the client, or answered outside the contract. */
|
|
121
|
+
| {
|
|
122
|
+
readonly kind: 'refresh_failed';
|
|
123
|
+
readonly error: ApiError;
|
|
124
|
+
};
|
|
125
|
+
/** Thrown by `session.token()`; the default transport turns it into `no_token`, with this as its `cause`. */
|
|
126
|
+
export declare class SessionError extends Error {
|
|
127
|
+
readonly failure: SessionFailure;
|
|
128
|
+
constructor(failure: SessionFailure);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* How a revocation came out (RFC 7009). pulse-auth answers a revocation 200 whatever it was sent,
|
|
132
|
+
* so that answer proves nothing: `revoked` rests on the issuer taking the session's access token
|
|
133
|
+
* just before and refusing it just after (D461, D464). Either way, what the app clears locally is
|
|
134
|
+
* its own call.
|
|
135
|
+
*/
|
|
136
|
+
export type RevokeResult = {
|
|
137
|
+
readonly kind: 'revoked';
|
|
138
|
+
} | {
|
|
139
|
+
readonly kind: 'unconfirmed';
|
|
140
|
+
/**
|
|
141
|
+
* Why it isn't known to be over:
|
|
142
|
+
* - the revocation's own failure (an `ApiError`, `aborted` and `timeout` included);
|
|
143
|
+
* - `still_live`: the issuer still takes the access token after its revocation;
|
|
144
|
+
* - `check_failed`: the revocation went, but the check before or after it couldn't be made,
|
|
145
|
+
* or the issuer didn't take the access token before it (`error` says how);
|
|
146
|
+
* - `unconfirmable`: no access token known to have 30 s left to check with, so the refresh
|
|
147
|
+
* token went (or a last access token), and nothing can tell whether it ended the session;
|
|
148
|
+
* - `maybe_spent`: as `unconfirmable`, and the refresh token's last refresh got no answer, so
|
|
149
|
+
* the server may have rotated it, and it may end nothing;
|
|
150
|
+
* - `no_endpoint`, `no_tokens` (nothing to send), or the store failing.
|
|
151
|
+
*/
|
|
152
|
+
readonly reason: ApiError | {
|
|
153
|
+
readonly kind: 'still_live';
|
|
154
|
+
} | {
|
|
155
|
+
readonly kind: 'check_failed';
|
|
156
|
+
readonly error: ApiError;
|
|
157
|
+
} | {
|
|
158
|
+
readonly kind: 'unconfirmable';
|
|
159
|
+
} | {
|
|
160
|
+
readonly kind: 'maybe_spent';
|
|
161
|
+
} | {
|
|
162
|
+
readonly kind: 'no_endpoint';
|
|
163
|
+
} | {
|
|
164
|
+
readonly kind: 'no_tokens';
|
|
165
|
+
} | Extract<SessionFailure, {
|
|
166
|
+
readonly kind: 'store_failed';
|
|
167
|
+
}>;
|
|
168
|
+
};
|
|
169
|
+
export interface Session {
|
|
170
|
+
/**
|
|
171
|
+
* The token function for `createFlipstream` (or `fetchTransport`): the access token while it has
|
|
172
|
+
* more than a minute left, or else a refreshed one. Callers arriving while a refresh runs share
|
|
173
|
+
* it. After a 401 (`rejected`), the token is refreshed, unless another refresh already replaced
|
|
174
|
+
* it. Rejects with a `SessionError`.
|
|
175
|
+
*/
|
|
176
|
+
token(ask?: TokenAsk): Promise<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Ends the session at the server (RFC 7009), with the tokens read once no refresh is spending
|
|
179
|
+
* them, inside the app's `lock` when there is one, all within 10 s, with nothing sent after. An
|
|
180
|
+
* access token known to have at least 30 s left is checked at the issuer, revoked (pulse-auth
|
|
181
|
+
* ends the whole session by it, whatever became of the refresh token) and checked again: only
|
|
182
|
+
* taken before and refused after is `revoked`. Without such a token, or when the check before
|
|
183
|
+
* fails, the live refresh token goes (the store's, or a rotation's whose save failed, D456), and
|
|
184
|
+
* the result is `unconfirmed`.
|
|
185
|
+
*
|
|
186
|
+
* It doesn't touch the store: after it, whatever the result, the app clears its own (D473). A
|
|
187
|
+
* clear with no `replaces` can be undone by a refresh's slow save that lands afterwards; #134
|
|
188
|
+
* would have the session do the clear instead.
|
|
189
|
+
*/
|
|
190
|
+
revoke(options?: Pick<AuthCallOptions, 'signal'>): Promise<RevokeResult>;
|
|
191
|
+
}
|
|
192
|
+
export declare function createSession(options: SessionOptions): Session;
|