@flipstream/sdk 0.8.0 → 0.9.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 +32 -0
- package/README.md +161 -54
- package/dist/auth/discovery.js +1 -1
- package/dist/auth/discovery.js.map +1 -1
- package/dist/auth/signIn.js +7 -2
- package/dist/auth/signIn.js.map +1 -1
- package/dist/core/fetch.d.ts +5 -0
- package/dist/core/fetch.js +3 -0
- package/dist/core/fetch.js.map +1 -1
- package/dist/core/identify.d.ts +63 -0
- package/dist/core/identify.js +122 -0
- package/dist/core/identify.js.map +1 -0
- package/dist/core/names.d.ts +61 -0
- package/dist/core/names.js +73 -0
- package/dist/core/names.js.map +1 -0
- package/dist/core/read.js +8 -2
- package/dist/core/read.js.map +1 -1
- package/dist/core/result.d.ts +26 -3
- package/dist/core/result.js +22 -3
- package/dist/core/result.js.map +1 -1
- package/dist/core/transport.d.ts +6 -2
- package/dist/flipstream.d.ts +47 -3
- package/dist/flipstream.js +46 -5
- package/dist/flipstream.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node/clientSecret.js +1 -1
- package/dist/node/clientSecret.js.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/keychainChild.js +10 -6
- package/dist/node/keychainChild.js.map +1 -1
- package/dist/node/keychainStore.d.ts +6 -3
- package/dist/node/keychainStore.js +6 -3
- package/dist/node/keychainStore.js.map +1 -1
- package/dist/node/session.d.ts +79 -29
- package/dist/node/session.js +52 -38
- package/dist/node/session.js.map +1 -1
- package/dist/node/store.d.ts +11 -1
- package/dist/node/store.js +14 -1
- package/dist/node/store.js.map +1 -1
- package/dist/query/query.d.ts +15 -10
- package/dist/query/query.js +21 -11
- package/dist/query/query.js.map +1 -1
- package/dist/version.gen.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The package entry point (D421): createFlipstream and its calls, the results they give (D412),
|
|
2
2
|
// and the core types a console needs to pass its own transport.
|
|
3
3
|
export { createFlipstream } from './flipstream.js';
|
|
4
|
-
//
|
|
4
|
+
// flipstream.query's field check, for an app to run before anything else it does (#183).
|
|
5
5
|
export { refusedQueryFields } from './query/query.js';
|
|
6
6
|
export { isPlannerCode } from './query/errors.js';
|
|
7
7
|
export { ApiFailure, orThrow } from './core/result.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,gEAAgE;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,gEAAgE;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,yFAAyF;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAwBtD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,kGAAkG;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -16,7 +16,7 @@ export async function finishSignIn(callbackUrl, pending, options) {
|
|
|
16
16
|
throw new TypeError("finishSignIn: clientId is required: the app's own OAuth client ID");
|
|
17
17
|
checkSecret('finishSignIn', clientSecret);
|
|
18
18
|
if (!isPendingSignIn(pending) || !startedHere(pending, server, clientId))
|
|
19
|
-
return { ok: false, error: { kind: 'refused' } };
|
|
19
|
+
return { ok: false, error: { kind: 'refused', reason: 'pending' } };
|
|
20
20
|
if (clientSecret === undefined)
|
|
21
21
|
return exchangeCode(callbackUrl, pending, callOptions);
|
|
22
22
|
const result = await exchangeCode(callbackUrl, pending, callOptions, basicAuthorization(clientId, clientSecret));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientSecret.js","sourceRoot":"","sources":["../../src/node/clientSecret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,YAAY,EAAE,eAAe,EAA2D,MAAM,mBAAmB,CAAA;AAkC1H;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,WAAyB,EAAE,OAAsB,EAAE,OAA4B;IAChH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAA;IAClE,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,mEAAmE,CAAC,CAAA;IAC7I,WAAW,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IACzC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"clientSecret.js","sourceRoot":"","sources":["../../src/node/clientSecret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,YAAY,EAAE,eAAe,EAA2D,MAAM,mBAAmB,CAAA;AAkC1H;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,WAAyB,EAAE,OAAsB,EAAE,OAA4B;IAChH,MAAM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AAK,MAAM,CAAC,aAAa;QAC9C,OAAO,CAAC,gBAAgB,KAAK,MAAM,CAAC,gBAAgB,CACrD,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,QAAgB,EAAE,YAAoB;IAChE,OAAO,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;AAC3G,CAAC;AAED,uEAAuE;AACvE,MAAM,WAAW,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export { keychainStore } from './keychainStore.js';
|
|
|
12
12
|
export type { KeychainStoreOptions } from './keychainStore.js';
|
|
13
13
|
export { KeychainError } from './keychainError.js';
|
|
14
14
|
export type { KeychainFailure } from './keychainError.js';
|
|
15
|
+
export { StoreMovedOnError } from './store.js';
|
|
15
16
|
export type { TokenStore } from './store.js';
|
package/dist/node/index.js
CHANGED
|
@@ -11,4 +11,5 @@ export { finishSignIn } from './clientSecret.js';
|
|
|
11
11
|
export { fileStore } from './fileStore.js';
|
|
12
12
|
export { keychainStore } from './keychainStore.js';
|
|
13
13
|
export { KeychainError } from './keychainError.js';
|
|
14
|
+
export { StoreMovedOnError } from './store.js';
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,kGAAkG;AAClG,kGAAkG;AAClG,+DAA+D;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,yFAAyF;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,kGAAkG;AAClG,kGAAkG;AAClG,+DAA+D;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,yFAAyF;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
* and the parent may have gone any time after (#157 item 15). Before each step, it also checks
|
|
17
17
|
* that its parent is still the app that sent the request. So a save the app started is made even
|
|
18
18
|
* if the app has ended, and a refresh's new tokens aren't lost.
|
|
19
|
-
* - **A terminal Ctrl-C is ignored** (#169)
|
|
20
|
-
*
|
|
21
|
-
* the heartbeat. Other signals
|
|
19
|
+
* - **A terminal Ctrl-C is ignored** (#169), from before this process's own imports load (#157
|
|
20
|
+
* item 14). It reaches this process too, as one of the app's process group. The app decides
|
|
21
|
+
* whether to stop, and if it does, this process follows through the heartbeat. Other signals
|
|
22
|
+
* still end it.
|
|
22
23
|
* - **Each answer is one line on file descriptor 3,** a pipe of its own, with the request's id, in
|
|
23
24
|
* one synchronous write: whatever else prints to standard output (a preload in NODE_OPTIONS, say)
|
|
24
25
|
* can't garble it.
|
|
@@ -31,7 +32,12 @@
|
|
|
31
32
|
*/
|
|
32
33
|
import { writeSync } from 'node:fs';
|
|
33
34
|
import { createInterface } from 'node:readline';
|
|
34
|
-
|
|
35
|
+
// A terminal Ctrl-C: the app decides whether to stop, and this process follows it (below). This
|
|
36
|
+
// is set up first, before zod loads (#157 item 14): a Ctrl-C while this process is still loading
|
|
37
|
+
// would end it, and lose a save its app had already sent. Node's own start-up, and any preload in
|
|
38
|
+
// NODE_OPTIONS, come before even this, and stay outside it.
|
|
39
|
+
process.on('SIGINT', () => undefined);
|
|
40
|
+
const { z } = await import('zod');
|
|
35
41
|
/** The tokens to save are the `set` step's `secret`. */
|
|
36
42
|
const zRequest = z.discriminatedUnion('op', [
|
|
37
43
|
z.strictObject({ id: z.number().int(), msLeft: z.number().int().positive(), afterParentMs: z.number().int().nonnegative(), parent: z.number().int().positive(), op: z.literal('get'), service: z.string(), account: z.string() }),
|
|
@@ -42,8 +48,6 @@ const zRequest = z.discriminatedUnion('op', [
|
|
|
42
48
|
const die = () => {
|
|
43
49
|
process.kill(process.pid, 'SIGKILL');
|
|
44
50
|
};
|
|
45
|
-
// A terminal Ctrl-C: the app decides whether to stop, and this process follows it (above).
|
|
46
|
-
process.on('SIGINT', () => undefined);
|
|
47
51
|
// For each request not yet answered, in the order they came, by this process's monotonic clock:
|
|
48
52
|
// - `until`: when it is cut off if the parent goes. A save or a delete keeps its own time left. A
|
|
49
53
|
// read, whose answer nobody would take, and a line that is no request get none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychainChild.js","sourceRoot":"","sources":["../../src/node/keychainChild.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"keychainChild.js","sourceRoot":"","sources":["../../src/node/keychainChild.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAG/C,gGAAgG;AAChG,iGAAiG;AACjG,kGAAkG;AAClG,4DAA4D;AAC5D,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AACrC,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAA;AAEjC,wDAAwD;AACxD,MAAM,QAAQ,GAAG,CAAC,CAAC,kBAAkB,CAAC,IAAI,EAAE;IAC1C,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IACjO,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE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IAAI,CAAC,KAAK,IAAI,EAAE;QAC1B,4FAA4F;QAC5F,4FAA4F;QAC5F,8FAA8F;QAC9F,mFAAmF;QACnF,IAAI,SAAS,IAAI,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,UAAU,EAAE,CAAA;QAC3E,IAAI,SAAS,IAAI,IAAI;YAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAA;;YAC9E,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,2CAA2C,EAAE,CAAC,CAAA;QACzF,UAAU,CAAC,KAAK,EAAE,CAAA;QAClB,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,GAAG,EAAE,CAAA;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -19,15 +19,18 @@ export interface KeychainStoreOptions {
|
|
|
19
19
|
* succeeded, or not at all.
|
|
20
20
|
*
|
|
21
21
|
* - **Every failure of the keychain or its helper is a `KeychainError`,** whose `failure.kind` says
|
|
22
|
-
* why: the cause of a session's `store_failed`. The store's own
|
|
23
|
-
* token (a `TypeError`, before any step)
|
|
22
|
+
* why: the cause of a session's `store_failed`. The store's own three are not: tokens with no
|
|
23
|
+
* access token (a `TypeError`, before any step), an item holding something other than tokens, and
|
|
24
|
+
* an update the item no longer holds the tokens for (a `StoreMovedOnError`, which a sign-out reads
|
|
25
|
+
* as `kept`, and a refresh reports as `store_failed`, step `save`).
|
|
24
26
|
* - **It needs `@napi-rs/keyring`** (`npm install @napi-rs/keyring`), which nothing else in the
|
|
25
27
|
* SDK uses. Without it, every step fails as `missing`, and says so.
|
|
26
28
|
* - **Linux without a Secret Service** (a server, a container) fails as `unavailable`: use
|
|
27
29
|
* `fileStore` there.
|
|
28
30
|
* - **Its steps run in one helper process,** one at a time: started by the first step and kept
|
|
29
31
|
* warm while the app runs, for every keychain store of the process. A step past its `timeoutMs`
|
|
30
|
-
* (30 s) kills it, and the next step starts another. It ignores a terminal Ctrl-C
|
|
32
|
+
* (30 s) kills it, and the next step starts another. It ignores a terminal Ctrl-C from before
|
|
33
|
+
* its own code loads, though not during Node's start-up or a preload in `NODE_OPTIONS`. A step whose
|
|
31
34
|
* helper died before it answered runs once more on a fresh one, within its `timeoutMs`. It never
|
|
32
35
|
* keeps the app running. When the app ends, it ends too: at once when idle or on a read, or once
|
|
33
36
|
* the save or delete it's on is done, within that step's `timeoutMs` and 1 s at most, so a
|
|
@@ -49,15 +49,18 @@ const AFTER_PARENT_MS = TIMINGS.oldWatchMs - TIMINGS.touchMs - 1_000;
|
|
|
49
49
|
* succeeded, or not at all.
|
|
50
50
|
*
|
|
51
51
|
* - **Every failure of the keychain or its helper is a `KeychainError`,** whose `failure.kind` says
|
|
52
|
-
* why: the cause of a session's `store_failed`. The store's own
|
|
53
|
-
* token (a `TypeError`, before any step)
|
|
52
|
+
* why: the cause of a session's `store_failed`. The store's own three are not: tokens with no
|
|
53
|
+
* access token (a `TypeError`, before any step), an item holding something other than tokens, and
|
|
54
|
+
* an update the item no longer holds the tokens for (a `StoreMovedOnError`, which a sign-out reads
|
|
55
|
+
* as `kept`, and a refresh reports as `store_failed`, step `save`).
|
|
54
56
|
* - **It needs `@napi-rs/keyring`** (`npm install @napi-rs/keyring`), which nothing else in the
|
|
55
57
|
* SDK uses. Without it, every step fails as `missing`, and says so.
|
|
56
58
|
* - **Linux without a Secret Service** (a server, a container) fails as `unavailable`: use
|
|
57
59
|
* `fileStore` there.
|
|
58
60
|
* - **Its steps run in one helper process,** one at a time: started by the first step and kept
|
|
59
61
|
* warm while the app runs, for every keychain store of the process. A step past its `timeoutMs`
|
|
60
|
-
* (30 s) kills it, and the next step starts another. It ignores a terminal Ctrl-C
|
|
62
|
+
* (30 s) kills it, and the next step starts another. It ignores a terminal Ctrl-C from before
|
|
63
|
+
* its own code loads, though not during Node's start-up or a preload in `NODE_OPTIONS`. A step whose
|
|
61
64
|
* helper died before it answered runs once more on a fresh one, within its `timeoutMs`. It never
|
|
62
65
|
* keeps the app running. When the app ends, it ends too: at once when idle or on a read, or once
|
|
63
66
|
* the save or delete it's on is done, within that step's `timeoutMs` and 1 s at most, so a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychainStore.js","sourceRoot":"","sources":["../../src/node/keychainStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAmB,MAAM,YAAY,CAAA;AAgB5D;;;;;;GAMG;AACH;;;;GAIG;AACH,SAAS,WAAW;IAClB,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AACD,MAAM,UAAU,GAAG,MAAM,CAAA;AACzB,2FAA2F;AAC3F,MAAM,cAAc,GAAG,aAAa,CAAA;AACpC;;;;GAIG;AACH,MAAM,WAAW,GAAG,KAAK,CAAA;AACzB;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,OAAO,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K,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IACxC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACjD,CAAC"}
|
package/dist/node/session.d.ts
CHANGED
|
@@ -76,8 +76,9 @@ export type SessionOptions = Pick<AuthCallOptions, 'fetch' | 'allowLocalhostHttp
|
|
|
76
76
|
* 2,147,483,647, the timers' own limit, or a TypeError at creation. Give a store that can wait on
|
|
77
77
|
* a person, such as a keychain asking for access, as long as that person may take: the CLI's
|
|
78
78
|
* 120 s when interactive, say. Only this wait changes. A refresh still waits at most 60 s for its
|
|
79
|
-
* lock and its answer, then its re-read and save are waited out, as before; a sign-out
|
|
80
|
-
* its 10 s; and D487's 60 s bounds on a sign-out's lock and store calls stay as
|
|
79
|
+
* lock and its answer, then its re-read and save are waited out, as before; a sign-out sends
|
|
80
|
+
* nothing after its 10 s; and D487's 60 s bounds on a sign-out's lock and store calls stay as
|
|
81
|
+
* they are.
|
|
81
82
|
*/
|
|
82
83
|
readonly waitMs?: number | undefined;
|
|
83
84
|
/**
|
|
@@ -100,9 +101,15 @@ export type SessionOptions = Pick<AuthCallOptions, 'fetch' | 'allowLocalhostHttp
|
|
|
100
101
|
* (`refreshToken || accessToken`) is still `update.replaces`. The session reads the
|
|
101
102
|
* store again just before, and lets the answer go when the store has moved on (a newer sign-in,
|
|
102
103
|
* or a sign-out); comparing and setting on `replaces` closes the moment between that read and
|
|
103
|
-
* this write, and a store that refuses then throws
|
|
104
|
+
* this write, and a store that refuses then throws a `StoreMovedOnError`: a sign-out reads it as
|
|
105
|
+
* the store keeping what it now holds (`kept`), and any other throw as the store failing
|
|
106
|
+
* (`failed`, D534). A refresh's answer is used only once this has
|
|
104
107
|
* settled. When a save fails, the session keeps a rotation's refresh token in memory, the only
|
|
105
108
|
* live one, for its next refresh and for `revoke()` (D456).
|
|
109
|
+
*
|
|
110
|
+
* Never call the session from this, or from `tokens`: both run inside the session's own turn. A
|
|
111
|
+
* `revoke()` there waits for that turn for ever, answering only at its `signal`, and a `token()`
|
|
112
|
+
* answers only at its `waitMs`.
|
|
106
113
|
*/
|
|
107
114
|
readonly onTokens: (update: TokenUpdate) => void | Promise<void>;
|
|
108
115
|
/**
|
|
@@ -159,12 +166,14 @@ export declare class SessionError extends Error {
|
|
|
159
166
|
constructor(failure: SessionFailure);
|
|
160
167
|
}
|
|
161
168
|
/**
|
|
162
|
-
* How a
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
169
|
+
* How a sign-out came out: at the server (`kind`), and in the store (`cleared`, D526), with where
|
|
170
|
+
* the store failed when it did (`failure`, D549).
|
|
171
|
+
*
|
|
172
|
+
* The server's half (RFC 7009): pulse-auth answers a revocation 200 whatever it was sent, so that
|
|
173
|
+
* answer proves nothing: `revoked` rests on the issuer taking the session's access token just before
|
|
174
|
+
* and refusing it just after (D461, D464).
|
|
166
175
|
*/
|
|
167
|
-
export type RevokeResult = {
|
|
176
|
+
export type RevokeResult = ({
|
|
168
177
|
readonly kind: 'revoked';
|
|
169
178
|
} | {
|
|
170
179
|
readonly kind: 'unconfirmed';
|
|
@@ -196,7 +205,43 @@ export type RevokeResult = {
|
|
|
196
205
|
} | Extract<SessionFailure, {
|
|
197
206
|
readonly kind: 'store_failed';
|
|
198
207
|
}>;
|
|
199
|
-
}
|
|
208
|
+
}) & ({
|
|
209
|
+
/**
|
|
210
|
+
* What became of the session in the store, whatever `kind` says:
|
|
211
|
+
* - `cleared`: `onTokens` cleared it (`cleared`);
|
|
212
|
+
* - `kept`: nothing of this session's to clear: nothing was stored, or the store moved on
|
|
213
|
+
* after the turn read it, to a newer sign-in, which is kept, or to another sign-out's
|
|
214
|
+
* clear. The session's own read finds it, or the store says so by refusing the clear with
|
|
215
|
+
* a `StoreMovedOnError` (D534);
|
|
216
|
+
* - `failed` (the other arm): the store failed, and `failure` says where and how (D549);
|
|
217
|
+
* - `cut`: a 60 s bound ran out (D487), on the lock or on a store call. A store call cut off
|
|
218
|
+
* may still finish on its own;
|
|
219
|
+
* - `pending`: the caller's `signal` answered first, so the store may still hold the tokens.
|
|
220
|
+
* The clear goes on, and `settled()` waits for it. With a signal that had fired before the
|
|
221
|
+
* call, nothing runs: no turn, no lock, no clear (D532).
|
|
222
|
+
*
|
|
223
|
+
* After any but `cleared` and `kept`, the tokens may still be stored: until the next refresh
|
|
224
|
+
* meets `invalid_grant`, or, for a store holding only an access token, until that token
|
|
225
|
+
* expires.
|
|
226
|
+
*/
|
|
227
|
+
readonly cleared: 'cleared' | 'kept' | 'cut' | 'pending';
|
|
228
|
+
} | {
|
|
229
|
+
/** The store failed, so the tokens may still be stored: `failure` says where and how (D549). */
|
|
230
|
+
readonly cleared: 'failed';
|
|
231
|
+
/**
|
|
232
|
+
* Where the store failed, and what it threw: `read`, the tokens' read (the turn's, or the
|
|
233
|
+
* clear's own check); `lock`, the app's lock, before the turn began; `clear`, `onTokens`'s
|
|
234
|
+
* clear, with any throw but a `StoreMovedOnError`. Nothing more is asked of the store.
|
|
235
|
+
* `cause` is what the store threw, unchanged, except that a clear or a lock rejecting with
|
|
236
|
+
* something other than an `Error` gives an `Error` carrying its text (#235). For
|
|
237
|
+
* `keychainStore`, `cause` is a `KeychainError`, whose `failure.kind` and message say why,
|
|
238
|
+
* never with a token in them.
|
|
239
|
+
*/
|
|
240
|
+
readonly failure: {
|
|
241
|
+
readonly step: 'read' | 'lock' | 'clear';
|
|
242
|
+
readonly cause: unknown;
|
|
243
|
+
};
|
|
244
|
+
});
|
|
200
245
|
export interface Session {
|
|
201
246
|
/**
|
|
202
247
|
* The token function for `createFlipstream` (or `fetchTransport`): the access token while it has
|
|
@@ -206,43 +251,48 @@ export interface Session {
|
|
|
206
251
|
*/
|
|
207
252
|
token(ask?: TokenAsk): Promise<string>;
|
|
208
253
|
/**
|
|
209
|
-
* Ends the session at the server (RFC 7009),
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* the
|
|
254
|
+
* Ends the session at the server (RFC 7009), then clears it from the store, and answers once both
|
|
255
|
+
* are done (D526): `kind` for the server, `cleared` for the store. The revocation uses the tokens
|
|
256
|
+
* read once no refresh is spending them, inside the app's `lock` when there is one, and is sent
|
|
257
|
+
* within 10 s, with nothing sent after. An access token known to have at least 30 s left is
|
|
258
|
+
* checked at the issuer, revoked (pulse-auth ends the whole session by it, whatever became of the
|
|
259
|
+
* refresh token) and checked again: only taken before and refused after is `revoked`. Without
|
|
260
|
+
* such a token, or when the check before fails, the live refresh token goes (the store's, or a
|
|
261
|
+
* rotation's whose save failed, D456), and the result is `unconfirmed`.
|
|
216
262
|
*
|
|
217
263
|
* A sign-out ends the session the store holds when its turn comes (#134), a newer sign-in from
|
|
218
264
|
* another terminal included: signing out means this person is signed out on this machine (D484).
|
|
219
265
|
* Its turn is queued at the call, and in one hold of the app's lock it revokes that session, then
|
|
220
266
|
* clears it from the store through `onTokens` (`cleared`), once, however the revocation went: in
|
|
221
267
|
* time or too late to send anything, aborted by the caller (D478), failed, or with any result. A
|
|
222
|
-
* sign-in saved after the turn read the store is kept.
|
|
223
|
-
* 10 s.
|
|
268
|
+
* sign-in saved after the turn read the store is kept (`kept`).
|
|
224
269
|
*
|
|
225
270
|
* A refresh token the session holds only in memory, because saving it failed (D456), goes too once
|
|
226
271
|
* the store has moved on from the token it replaced: as a refresh token, after the stored session,
|
|
227
272
|
* in the same 10 s. One sign-out sends it, whatever the result, and the session then lets it go
|
|
228
273
|
* (D500). Its send failing is the result when the stored session's went as well as it can.
|
|
229
274
|
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
275
|
+
* The answer waits for the clear, so it can come well after the 10 s. This reverses #140's "a
|
|
276
|
+
* stalled clear holds the queue, not the caller" for the caller of `revoke()` (D526). It waits
|
|
277
|
+
* for the queue ahead of the turn for as long as that takes: a refresh's re-read and save are
|
|
278
|
+
* waited out, and so is a lock that ignores its signal (rev197's O2.F1). Once the turn reaches the
|
|
279
|
+
* lock, it waits at most 60 s for it, and at most 60 s for each of its three store calls (D487),
|
|
280
|
+
* so up to about four minutes. Past a bound, the turn gives up, touching nothing more, and
|
|
281
|
+
* answers with `cleared: 'cut'`, and later turns run. A lock held longer than its 60 s by another
|
|
282
|
+
* process leaves the store as it was, and so does a store call that hasn't answered within its
|
|
283
|
+
* 60 s, unless it finishes later on its own. `signal` is the way out: it answers at once, with the
|
|
284
|
+
* revocation's result once that is known, or `aborted`, and `cleared: 'pending'`, while the clear
|
|
285
|
+
* goes on. A signal that had fired before the call runs nothing at all, and answers `aborted` and
|
|
286
|
+
* `pending` too (D532).
|
|
238
287
|
*/
|
|
239
288
|
revoke(options?: Pick<AuthCallOptions, 'signal'>): Promise<RevokeResult>;
|
|
240
289
|
/**
|
|
241
290
|
* Resolves once nothing is in flight in this session: no refresh, no save, no sign-out, and no
|
|
242
291
|
* `token()` still reading the store before it queues a refresh (#170, D516). Await it before the
|
|
243
|
-
* process exits, on Ctrl-C or after `unavailable`: `token()` answers at its `waitMs`
|
|
244
|
-
* `revoke()` at its
|
|
245
|
-
* pulse-auth has rotated, losing the new token. Work that starts while it
|
|
292
|
+
* process exits, on Ctrl-C or after `unavailable`: `token()` answers at its `waitMs` while its
|
|
293
|
+
* refresh goes on, and `revoke()` at its `signal` while its clear goes on, and an exit then can
|
|
294
|
+
* cut a refresh after pulse-auth has rotated, losing the new token. Work that starts while it
|
|
295
|
+
* waits is waited for too.
|
|
246
296
|
*
|
|
247
297
|
* It never rejects, and it starts no work. It waits at most as long as the session's own limits
|
|
248
298
|
* (D521): a refresh's 60 s for its lock and its request (D445), and a sign-out's 60 s for the lock
|
package/dist/node/session.js
CHANGED
|
@@ -4,6 +4,7 @@ import { discover } from '../auth/discovery.js';
|
|
|
4
4
|
import { tokenCall } from '../auth/tokenEndpoint.js';
|
|
5
5
|
import { authTransport, endpointProblem, isSignInUrl } from '../auth/transport.js';
|
|
6
6
|
import { clientAuthorization, vouched } from './clientSecret.js';
|
|
7
|
+
import { StoreMovedOnError } from './store.js';
|
|
7
8
|
/** Thrown by `session.token()`; the default transport turns it into `no_token`, with this as its `cause`. */
|
|
8
9
|
export class SessionError extends Error {
|
|
9
10
|
failure;
|
|
@@ -38,6 +39,7 @@ const zStored = z.object({
|
|
|
38
39
|
refreshToken: z.string().optional(),
|
|
39
40
|
expiresAt: z.number().optional(),
|
|
40
41
|
});
|
|
42
|
+
const failedAt = (step, cause) => ({ cleared: 'failed', failure: { step, cause } });
|
|
41
43
|
const SIGNED_OUT = { kind: 'signed-out' };
|
|
42
44
|
const UNAVAILABLE = { kind: 'unavailable' };
|
|
43
45
|
export function createSession(options) {
|
|
@@ -87,7 +89,7 @@ export function createSession(options) {
|
|
|
87
89
|
if (known !== undefined)
|
|
88
90
|
return { ok: true, data: known };
|
|
89
91
|
if (issuer === undefined)
|
|
90
|
-
return { ok: false, error: { kind: 'refused' } };
|
|
92
|
+
return { ok: false, error: { kind: 'refused', reason: 'destination' } };
|
|
91
93
|
// By the clock too, as every send: a store that blocked the thread past the deadline returns
|
|
92
94
|
// before its timer has run (S1.F1).
|
|
93
95
|
const ended = limit.ended();
|
|
@@ -316,24 +318,23 @@ export function createSession(options) {
|
|
|
316
318
|
/**
|
|
317
319
|
* A sign-out's turn (#134): the revocation, then the store's clear, in one hold of the app's lock,
|
|
318
320
|
* so nothing can rotate the session in between. The turn's one read of the store serves both:
|
|
319
|
-
* the revocation waits for it only within its 10 s, the clear for
|
|
320
|
-
* revocation's result goes to `answer` as soon as it's known
|
|
321
|
-
* revocation did: in time or too late to send
|
|
322
|
-
* result.
|
|
321
|
+
* the revocation waits for it only within its 10 s, the clear for at most its 60 s. The
|
|
322
|
+
* revocation's result goes to `answer` as soon as it's known, for a caller whose signal fires
|
|
323
|
+
* during the clear. The clear runs whatever the revocation did: in time or too late to send
|
|
324
|
+
* anything, aborted (D478), failed, or with any result.
|
|
323
325
|
*/
|
|
324
326
|
async function signOut(limit, answer) {
|
|
325
327
|
const reading = waitedAtMost(read());
|
|
326
328
|
// Whatever the revocation half does, throwing included, the clear below still runs (rev140's
|
|
327
329
|
// P3.2): a throw is the revocation's own failure, outside the contract.
|
|
328
|
-
const
|
|
330
|
+
const revocation = await revokeWith(reading, limit).catch((cause) => ({ kind: 'unconfirmed', reason: { kind: 'invalid', issues: `the revocation failed: ${cause instanceof Error ? cause.message : String(cause)}` } }));
|
|
329
331
|
// One sign-out sends the rotations set aside, whatever its result, and lets them go (D500).
|
|
330
332
|
setAside = [];
|
|
331
|
-
answer(
|
|
333
|
+
answer(revocation);
|
|
332
334
|
// The session the turn read, while the store still holds it: a sign-in saved since is kept.
|
|
333
335
|
const now = await reading;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
return result;
|
|
336
|
+
const cleared = isAborted(now) ? { cleared: 'cut' } : !now.ok ? failedAt('read', now.failure.cause) : await clearIfStill(keyOf(now.tokens));
|
|
337
|
+
return { ...revocation, ...cleared };
|
|
337
338
|
}
|
|
338
339
|
/** A store call, given up on after 60 s (D487): the turn then touches nothing more. */
|
|
339
340
|
function waitedAtMost(call) {
|
|
@@ -426,19 +427,27 @@ export function createSession(options) {
|
|
|
426
427
|
}
|
|
427
428
|
/**
|
|
428
429
|
* Clears the store, as C2 does after `invalid_grant`: read again, and `cleared` only while the
|
|
429
|
-
* store's key is still `key`, so a sign-in another process saved meanwhile is kept.
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
430
|
+
* store's key is still `key`, so a sign-in another process saved meanwhile is kept. Each store
|
|
431
|
+
* call is waited for at most 60 s (D487), and the caller waits with them (D526). A clear that
|
|
432
|
+
* fails or is cut leaves the tokens, and says so; the next refresh of an ended session clears
|
|
433
|
+
* them (C2).
|
|
433
434
|
*/
|
|
434
435
|
async function clearIfStill(key) {
|
|
435
436
|
if (key === undefined)
|
|
436
|
-
return;
|
|
437
|
+
return { cleared: 'kept' };
|
|
437
438
|
const now = await waitedAtMost(read());
|
|
438
|
-
if (isAborted(now)
|
|
439
|
-
return;
|
|
439
|
+
if (isAborted(now))
|
|
440
|
+
return { cleared: 'cut' };
|
|
441
|
+
if (!now.ok)
|
|
442
|
+
return failedAt('read', now.failure.cause);
|
|
443
|
+
if (keyOf(now.tokens) !== key)
|
|
444
|
+
return { cleared: 'kept' };
|
|
440
445
|
unsaved = null;
|
|
441
|
-
|
|
446
|
+
return waitedAtMost(Promise.resolve().then(() => options.onTokens({ kind: 'cleared', replaces: key }))).then((done) => ({ cleared: isAborted(done) ? 'cut' : 'cleared' }),
|
|
447
|
+
// A store that compares and sets refuses a clear once it no longer holds `key`: a sign-in
|
|
448
|
+
// saved since the read above, or another process's clear, is kept. Only its marker says so;
|
|
449
|
+
// any other throw is the store failing, with nothing more asked of it (D534).
|
|
450
|
+
(error) => (error instanceof StoreMovedOnError ? { cleared: 'kept' } : failedAt('clear', error)));
|
|
442
451
|
}
|
|
443
452
|
function revocation(endpoint, token, hint, limit) {
|
|
444
453
|
// Nothing is sent once the turn's 10 s are up, not even with no time left (S6.F1).
|
|
@@ -535,33 +544,34 @@ export function createSession(options) {
|
|
|
535
544
|
// A sign-out asked with a signal that has already fired does nothing at all.
|
|
536
545
|
if (limit.signal.aborted) {
|
|
537
546
|
limit.dispose();
|
|
538
|
-
return Promise.resolve(limit.unconfirmed());
|
|
547
|
+
return Promise.resolve({ ...limit.unconfirmed(), cleared: 'pending' });
|
|
539
548
|
}
|
|
540
549
|
let answer = noop;
|
|
541
550
|
const answered = new Promise((resolve) => (answer = resolve));
|
|
542
551
|
// Queued now, before anything is awaited, so neither an abort nor a stalled read can keep the
|
|
543
|
-
// turn from coming, and a refresh asked after the sign-out comes after it (K1).
|
|
544
|
-
|
|
552
|
+
// turn from coming, and a refresh asked after the sign-out comes after it (K1). A turn that
|
|
553
|
+
// gives up on the lock at its 60 s touches nothing (D487).
|
|
554
|
+
const { turn, run } = enqueueSignOut(() => signOut(limit, answer), () => ({ ...limit.unconfirmed(), cleared: 'cut' }));
|
|
555
|
+
// The whole sign-out, once its turn is over, the clear included (D526), so a token() just
|
|
556
|
+
// after finds the store cleared. A lock that fails after the work began leaves the work's own
|
|
557
|
+
// result standing (rev140's P3.1).
|
|
558
|
+
const whole = turn
|
|
559
|
+
.then((first) => run.begun ?? first, (cause) => run.begun ?? { kind: 'unconfirmed', reason: { kind: 'store_failed', step: 'lock', cause }, ...failedAt('lock', cause) })
|
|
560
|
+
// A turn whose own work failed: the caller still gets an answer (K6, rev140's round-3 P3.5).
|
|
561
|
+
// Every store call in it is caught, so only the SDK's own code can get here; the clear is
|
|
562
|
+
// the step it leaves unknown.
|
|
563
|
+
.catch((failed) => ({ kind: 'unconfirmed', reason: { kind: 'invalid', issues: `the sign-out failed: ${failed instanceof Error ? failed.message : String(failed)}` }, ...failedAt('clear', failed) }));
|
|
545
564
|
return new Promise((resolve) => {
|
|
546
|
-
|
|
547
|
-
//
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
// At the 10 s, a turn that hasn't begun is `timeout` (or `aborted`); one that has begun
|
|
553
|
-
// answers soon, every step of it being bound to the same 10 s. A lock that fails after the
|
|
554
|
-
// work began leaves the work's own result standing (rev140's P3.1).
|
|
555
|
-
void orAborted(turn, limit.signal).then((first) => {
|
|
556
|
-
if (isAborted(first) && run.begun === undefined)
|
|
557
|
-
resolve(limit.unconfirmed());
|
|
558
|
-
}, (cause) => {
|
|
565
|
+
void whole.then(resolve);
|
|
566
|
+
// The caller's signal answers at once, the clear still to come: `aborted` for a turn that
|
|
567
|
+
// hasn't begun, or else the revocation's result, which comes soon, every step of it being
|
|
568
|
+
// bound to the same signal. Through the limit's own listener, so a call holds one on the
|
|
569
|
+
// caller's signal, as before it could wait minutes (rev197's O2.T1).
|
|
570
|
+
void limit.callerAborted.then(() => {
|
|
559
571
|
if (run.begun === undefined)
|
|
560
|
-
resolve({
|
|
561
|
-
// A turn whose own work failed, without an answer: the caller still gets one (K6), not
|
|
562
|
-
// a wait for an answer that won't come (rev140's round-3 P3.5).
|
|
572
|
+
resolve({ ...limit.unconfirmed(), cleared: 'pending' });
|
|
563
573
|
else
|
|
564
|
-
void
|
|
574
|
+
void answered.then((revocation) => resolve({ ...revocation, cleared: 'pending' }));
|
|
565
575
|
});
|
|
566
576
|
}).finally(limit.dispose);
|
|
567
577
|
},
|
|
@@ -598,9 +608,12 @@ function createLimit(ms, caller) {
|
|
|
598
608
|
const timer = setTimeout(() => {
|
|
599
609
|
stop.abort();
|
|
600
610
|
}, ms);
|
|
611
|
+
let callerAbort = noop;
|
|
612
|
+
const callerAborted = new Promise((resolve) => (callerAbort = resolve));
|
|
601
613
|
const onAbort = () => {
|
|
602
614
|
reason = 'aborted';
|
|
603
615
|
stop.abort();
|
|
616
|
+
callerAbort();
|
|
604
617
|
};
|
|
605
618
|
if (caller?.aborted === true)
|
|
606
619
|
onAbort();
|
|
@@ -614,6 +627,7 @@ function createLimit(ms, caller) {
|
|
|
614
627
|
// The clock as well as the timer: a store that blocks the thread past the deadline returns
|
|
615
628
|
// before the timer has had a chance to run (S7.F1).
|
|
616
629
|
ended: () => (stop.signal.aborted || Date.now() >= end ? { kind: reason } : null),
|
|
630
|
+
callerAborted,
|
|
617
631
|
dispose: () => {
|
|
618
632
|
clearTimeout(timer);
|
|
619
633
|
caller?.removeEventListener('abort', onAbort);
|