@flipstream/sdk 0.7.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +211 -65
  3. package/dist/auth/discovery.js +1 -1
  4. package/dist/auth/discovery.js.map +1 -1
  5. package/dist/auth/signIn.js +7 -2
  6. package/dist/auth/signIn.js.map +1 -1
  7. package/dist/core/fetch.d.ts +5 -0
  8. package/dist/core/fetch.js +3 -0
  9. package/dist/core/fetch.js.map +1 -1
  10. package/dist/core/identify.d.ts +63 -0
  11. package/dist/core/identify.js +122 -0
  12. package/dist/core/identify.js.map +1 -0
  13. package/dist/core/names.d.ts +61 -0
  14. package/dist/core/names.js +73 -0
  15. package/dist/core/names.js.map +1 -0
  16. package/dist/core/read.js +8 -2
  17. package/dist/core/read.js.map +1 -1
  18. package/dist/core/result.d.ts +26 -3
  19. package/dist/core/result.js +22 -3
  20. package/dist/core/result.js.map +1 -1
  21. package/dist/core/transport.d.ts +6 -2
  22. package/dist/flipstream.d.ts +47 -3
  23. package/dist/flipstream.js +46 -5
  24. package/dist/flipstream.js.map +1 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/node/clientSecret.js +1 -1
  29. package/dist/node/clientSecret.js.map +1 -1
  30. package/dist/node/index.d.ts +3 -0
  31. package/dist/node/index.js +2 -0
  32. package/dist/node/index.js.map +1 -1
  33. package/dist/node/keychainChild.js +78 -18
  34. package/dist/node/keychainChild.js.map +1 -1
  35. package/dist/node/keychainError.d.ts +53 -0
  36. package/dist/node/keychainError.js +48 -0
  37. package/dist/node/keychainError.js.map +1 -0
  38. package/dist/node/keychainStore.d.ts +19 -9
  39. package/dist/node/keychainStore.js +61 -27
  40. package/dist/node/keychainStore.js.map +1 -1
  41. package/dist/node/session.d.ts +88 -28
  42. package/dist/node/session.js +60 -40
  43. package/dist/node/session.js.map +1 -1
  44. package/dist/node/store.d.ts +11 -1
  45. package/dist/node/store.js +14 -1
  46. package/dist/node/store.js.map +1 -1
  47. package/dist/query/query.d.ts +15 -10
  48. package/dist/query/query.js +21 -11
  49. package/dist/query/query.js.map +1 -1
  50. package/dist/version.gen.js +1 -1
  51. package/package.json +1 -1
@@ -1,37 +1,78 @@
1
1
  import { call } from './core/call.js';
2
2
  import { fetchTransport, tokenlessTransport } from './core/fetch.js';
3
+ import { callerSender, identityOf, isConversationId, nodeVersion, sdkSender, traceFor, traceparent, valueHolds } from './core/identify.js';
3
4
  import { catalogGet, catalogList, consoleWarn } from './query/catalog.js';
4
5
  import { healthCheck } from './query/health.js';
5
6
  import { queryRun, unsentFields } from './query/query.js';
6
7
  const DEFAULT_HOSTS = { query: 'https://query.flipstream.io' };
8
+ const refused = (reason) => ({ ok: false, error: { kind: 'refused', reason } });
7
9
  /** The SDK, for one caller (D421): the console with its transport, or anyone with a token function. */
8
10
  export function createFlipstream(options) {
11
+ // First, so a client that can't say who it is throws before anything else is set up.
12
+ const identity = identityOf(options);
13
+ const node = nodeVersion();
14
+ // The values the caller gave, keyed by the Request that carries them, so the token function's
15
+ // transport can refuse one whose values hold the access token: only the transport has the token.
16
+ const carried = new WeakMap();
17
+ const holdsToken = (request, token) => (carried.get(request) ?? []).some((value) => valueHolds(value, token));
9
18
  const hosts = { ...DEFAULT_HOSTS, ...options.hosts };
10
19
  const transport = options.transport !== undefined
11
20
  ? options.transport
12
- : fetchTransport({ token: options.token, fetch: options.fetch, hosts, allowLocalhostHttp: options.allowLocalhostHttp });
21
+ : fetchTransport({ token: options.token, fetch: options.fetch, hosts, allowLocalhostHttp: options.allowLocalhostHttp, holdsToken });
13
22
  const base = (hosts.query ?? DEFAULT_HOSTS.query).replace(/\/+$/, '');
14
23
  const warn = options.onWarning ?? consoleWarn;
15
24
  // For health alone (#111), whichever way the SDK was made: only the query host, so the call that
16
25
  // works signed out can go nowhere else.
17
26
  const signedOut = tokenlessTransport({ fetch: options.fetch, hosts: { query: base }, allowLocalhostHttp: options.allowLocalhostHttp });
18
- const send = (spec, { signal, deadlineMs } = {}, via = transport) => call(via, deadlineMs === undefined ? spec : { ...spec, deadlineMs }, signal);
27
+ /**
28
+ * `spec` with what its requests say about who sent them, in Node: one trace for the call, and a
29
+ * parent-id for each request, retries and a 401's resend included.
30
+ */
31
+ const identified = (spec, sender, trace) => ({
32
+ ...spec,
33
+ makeRequest: () => {
34
+ const built = spec.makeRequest();
35
+ const headers = new Headers(built.headers);
36
+ headers.set('user-agent', sender.userAgent);
37
+ headers.set('traceparent', traceparent(trace));
38
+ if (sender.baggage !== undefined)
39
+ headers.set('baggage', sender.baggage);
40
+ const request = new Request(built, { headers });
41
+ carried.set(request, sender.values);
42
+ return request;
43
+ },
44
+ });
45
+ /** One call. `signedIn` is false for health alone, which says only who the SDK is (D535). */
46
+ const send = (spec, callOptions = {}, signedIn = true) => {
47
+ // One flag picks both the transport and what the request says: only the signed-in transport
48
+ // checks the caller's values against the token, so a signed-out call can never carry them.
49
+ const via = signedIn ? transport : signedOut;
50
+ const { signal, deadlineMs } = callOptions;
51
+ // Refused before anything is sent, like a field the call doesn't send: the token function isn't asked.
52
+ if (callOptions.conversationId !== undefined && !isConversationId(callOptions.conversationId))
53
+ return Promise.resolve(refused('conversation-id'));
54
+ const timed = deadlineMs === undefined ? spec : { ...spec, deadlineMs };
55
+ if (node === undefined)
56
+ return call(via, timed, signal);
57
+ const sender = signedIn ? callerSender(identity, callOptions.conversationId ?? identity.conversationId, node) : sdkSender(node);
58
+ return call(via, identified(timed, sender, traceFor(callOptions.traceparent)), signal);
59
+ };
19
60
  return {
20
61
  catalog: {
21
62
  list: (callOptions) => send(catalogList(base, warn), callOptions),
22
63
  get(request, callOptions) {
23
64
  const spec = catalogGet(base, request.source, warn);
24
65
  // Refused before anything is sent: the token function isn't asked, and nothing is spent.
25
- return spec === null ? Promise.resolve({ ok: false, error: { kind: 'refused' } }) : send(spec, callOptions);
66
+ return spec === null ? Promise.resolve(refused('path')) : send(spec, callOptions);
26
67
  },
27
68
  },
28
69
  // Async, so a request that isn't an object rejects, as D436's do, rather than throwing here.
29
70
  async query(request, callOptions) {
30
71
  const fields = unsentFields(request);
31
72
  // Refused before anything is sent, like catalog.get's: the token function isn't asked.
32
- return fields === null ? send(queryRun(base, request), callOptions) : { ok: false, error: { kind: 'refused', fields } };
73
+ return fields === null ? send(queryRun(base, request), callOptions) : { ok: false, error: { kind: 'refused', reason: 'fields', fields } };
33
74
  },
34
- health: (callOptions) => send(healthCheck(base), callOptions, signedOut),
75
+ health: (callOptions) => send(healthCheck(base), callOptions, false),
35
76
  };
36
77
  }
37
78
  //# sourceMappingURL=flipstream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flipstream.js","sourceRoot":"","sources":["../src/flipstream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAA;AAGnF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAa,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAqB,MAAM,kBAAkB,CAAA;AA0D5E,MAAM,aAAa,GAAG,EAAE,KAAK,EAAE,6BAA6B,EAAW,CAAA;AAEvE,uGAAuG;AACvG,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACzD,MAAM,KAAK,GAAU,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAA;IAC3D,MAAM,SAAS,GACb,OAAO,CAAC,SAAS,KAAK,SAAS;QAC7B,CAAC,CAAC,OAAO,CAAC,SAAS;QACnB,CAAC,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC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,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAA;QAC3I,CAAC;QACD,MAAM,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC;KACrE,CAAA;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { createFlipstream } from './flipstream.js';
2
- export type { CallOptions, Flipstream, FlipstreamOptions, Hosts, TokenFunction } from './flipstream.js';
2
+ export type { CallOptions, Flipstream, FlipstreamOptions, Hosts, Identification, TokenFunction } from './flipstream.js';
3
3
  export { refusedQueryFields } from './query/query.js';
4
4
  export type { QueryRequest } from './query/query.js';
5
5
  export type { Health } from './query/health.js';
6
6
  export { isPlannerCode } from './query/errors.js';
7
7
  export { ApiFailure, orThrow } from './core/result.js';
8
- export type { Answered, ApiError, ApiResult, ErrorCode, Said, StatusKind } from './core/result.js';
8
+ export type { Answered, ApiError, ApiResult, ErrorCode, RefusedReason, Said, StatusKind } from './core/result.js';
9
9
  export type { ApiRequest, CancelReason, ServiceName, Transport, TransportResult } from './core/transport.js';
10
10
  export type { TokenAsk } from './core/fetch.js';
11
11
  export type { Catalog, CatalogSource, CurrencyFormat, CustomDimensions, DateFormat, Dimension, ErrorBody, Format, Metric, NumberFormat, PercentageFormat, PlannerErrorCode, QueryResponse, Row, SortSpec, Source, StringFormat, UnknownFormat, } from './spec/query-planner/types.gen.js';
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
- // fs.query's field check, for an app to run before anything else it does (#183).
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,iFAAiF;AACjF,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"}
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;IAC1H,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO,YAAY,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IACtF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,kBAAkB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;IAChH,OAAO,MAAM,CAA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O,CAAC,QAAQ,KAAK,QAAQ;QAC7B,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAChC,OAAO,CAAC,aAAa,KAAK,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"}
@@ -10,4 +10,7 @@ export type { ServerSignInOptions } from './clientSecret.js';
10
10
  export { fileStore } from './fileStore.js';
11
11
  export { keychainStore } from './keychainStore.js';
12
12
  export type { KeychainStoreOptions } from './keychainStore.js';
13
+ export { KeychainError } from './keychainError.js';
14
+ export type { KeychainFailure } from './keychainError.js';
15
+ export { StoreMovedOnError } from './store.js';
13
16
  export type { TokenStore } from './store.js';
@@ -10,4 +10,6 @@ export { fileLock } from './fileLock.js';
10
10
  export { finishSignIn } from './clientSecret.js';
11
11
  export { fileStore } from './fileStore.js';
12
12
  export { keychainStore } from './keychainStore.js';
13
+ export { KeychainError } from './keychainError.js';
14
+ export { StoreMovedOnError } from './store.js';
13
15
  //# sourceMappingURL=index.js.map
@@ -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"}
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"}
@@ -8,8 +8,18 @@
8
8
  * - **Each request is one line on standard input,** with its id: the tokens never become an
9
9
  * argument or a variable of this process, which other users can read.
10
10
  * - **Standard input stays open as the parent's heartbeat.** When it closes, the parent is gone (it
11
- * exited, threw, or was killed), and this process kills itself, rather than being left behind,
12
- * warm or on a call that never returns.
11
+ * exited, threw, or was killed), and this process ends, rather than being left behind, warm or on
12
+ * a call that never returns: at once when idle or on a read, or once it has answered the save or
13
+ * delete it's on. That step is cut off when its own time left (`msLeft`, in each request) runs
14
+ * out, and `afterParentMs` (1 s) after the parent went at the latest. For this process's first
15
+ * request, that 1 s counts from this process's own start: the request was written as it started,
16
+ * and the parent may have gone any time after (#157 item 15). Before each step, it also checks
17
+ * that its parent is still the app that sent the request. So a save the app started is made even
18
+ * if the app has ended, and a refresh's new tokens aren't lost.
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.
13
23
  * - **Each answer is one line on file descriptor 3,** a pipe of its own, with the request's id, in
14
24
  * one synchronous write: whatever else prints to standard output (a preload in NODE_OPTIONS, say)
15
25
  * can't garble it.
@@ -22,24 +32,62 @@
22
32
  */
23
33
  import { writeSync } from 'node:fs';
24
34
  import { createInterface } from 'node:readline';
25
- import { z } from 'zod';
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');
26
41
  /** The tokens to save are the `set` step's `secret`. */
27
42
  const zRequest = z.discriminatedUnion('op', [
28
- z.strictObject({ id: z.number().int(), op: z.literal('get'), service: z.string(), account: z.string() }),
29
- z.strictObject({ id: z.number().int(), op: z.literal('delete'), service: z.string(), account: z.string() }),
30
- z.strictObject({ id: z.number().int(), op: z.literal('set'), service: z.string(), account: z.string(), secret: z.string() }),
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() }),
44
+ z.strictObject({ id: z.number().int(), msLeft: z.number().int().positive(), afterParentMs: z.number().int().nonnegative(), parent: z.number().int().positive(), op: z.literal('delete'), service: z.string(), account: z.string() }),
45
+ z.strictObject({ id: z.number().int(), msLeft: z.number().int().positive(), afterParentMs: z.number().int().nonnegative(), parent: z.number().int().positive(), op: z.literal('set'), service: z.string(), account: z.string(), secret: z.string() }),
31
46
  ]);
32
47
  // SIGKILL, never process.exit: a call stuck in the kernel would hold up an exit too.
33
- const dieWithParent = () => {
48
+ const die = () => {
34
49
  process.kill(process.pid, 'SIGKILL');
35
50
  };
36
- // Installed first, for the whole life of the process: a parent that dies right after writing the
37
- // request must still take this process with it.
38
- process.stdin.on('end', dieWithParent);
39
- process.stdin.on('close', dieWithParent);
51
+ // For each request not yet answered, in the order they came, by this process's monotonic clock:
52
+ // - `until`: when it is cut off if the parent goes. A save or a delete keeps its own time left. A
53
+ // read, whose answer nobody would take, and a line that is no request get none;
54
+ // - `first`: whether it is this process's first request. The parent wrote that one as it started
55
+ // this process, before anything here could read, so the parent may have gone any time from about
56
+ // 0 on this clock, which starts with the process. A slow start (a loaded machine, a heavy preload)
57
+ // must not stretch the 1 s past the soonest the parent's lock can pass on. A later request was
58
+ // written while this process was reading, so the parent's end shows here at once.
59
+ const unanswered = [];
60
+ let requests = 0;
61
+ // And how long a step may go on once the parent has gone, at most, as the parent last said
62
+ // (`afterParentMs`, under the soonest the parent's lock may pass to another process).
63
+ let afterParentMs = 0;
64
+ let parentGone = false;
65
+ // Installed first, for the whole life of the process: a parent that dies right after writing a
66
+ // request still takes this process with it, once that request is answered or cut off.
67
+ const parentLeft = () => {
68
+ if (parentGone)
69
+ return;
70
+ parentGone = true;
71
+ const now = performance.now();
72
+ // Each step's cut: its own time left, or `afterParentMs` from when its parent may have gone.
73
+ const cut = Math.max(...unanswered.map((step) => Math.min(step.until, (step.first ? 0 : now) + afterParentMs)));
74
+ // At once when it has passed, so a step can't start meanwhile.
75
+ if (unanswered.length === 0 || cut <= now)
76
+ die();
77
+ else
78
+ setTimeout(die, cut - now);
79
+ };
80
+ process.stdin.on('end', parentLeft);
81
+ process.stdin.on('close', parentLeft);
40
82
  const ANSWER_FD = 3;
41
83
  const emit = (answer) => {
42
- writeSync(ANSWER_FD, `${JSON.stringify(answer)}\n`);
84
+ try {
85
+ writeSync(ANSWER_FD, `${JSON.stringify(answer)}\n`);
86
+ }
87
+ catch {
88
+ // Nobody reads the answers any more (EPIPE): the parent is gone.
89
+ die();
90
+ }
43
91
  };
44
92
  /** The request in one line, or the id of a line that is no request (null when it has none). */
45
93
  function requestOf(line) {
@@ -121,16 +169,28 @@ async function step(request) {
121
169
  }
122
170
  }
123
171
  const messageOf = (error) => (error instanceof Error ? error.message : String(error));
124
- // One request at a time, in order: each waits for the one before it to be answered.
172
+ // One request at a time, in order: each waits for the one before it to be answered. Each is counted
173
+ // as it comes, before its turn: the parent may be gone by then.
125
174
  let tail = Promise.resolve();
126
175
  createInterface({ input: process.stdin, crlfDelay: Infinity }).on('line', (line) => {
176
+ const read = requestOf(line);
177
+ unanswered.push({ until: 'request' in read && read.request.op !== 'get' ? performance.now() + read.request.msLeft : 0, first: requests++ === 0 });
178
+ if ('request' in read)
179
+ afterParentMs = read.request.afterParentMs;
127
180
  tail = tail.then(async () => {
128
- const read = requestOf(line);
129
- if (!('request' in read)) {
181
+ // A parent gone before this step's turn, perhaps while this process was still starting: the
182
+ // end of standard input that came with the request is seen only after a quick step has run,
183
+ // so ask the system who the parent is now. An orphan's parent is no longer the app (#157 item
184
+ // 15). On Windows, which doesn't reparent, only the end of standard input says so.
185
+ if ('request' in read && process.ppid !== read.request.parent)
186
+ parentLeft();
187
+ if ('request' in read)
188
+ emit({ id: read.request.id, ...(await step(read.request)) });
189
+ else
130
190
  emit({ id: read.id, ok: false, error: 'the keychain step got no readable request' });
131
- return;
132
- }
133
- emit({ id: read.request.id, ...(await step(read.request)) });
191
+ unanswered.shift();
192
+ if (parentGone && unanswered.length === 0)
193
+ die();
134
194
  });
135
195
  });
136
196
  //# sourceMappingURL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,KAAK,EAAE,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAA;IACjJ,IAAI,SAAS,IAAI,IAAI;QAAE,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAA;IACjE,IAAI,GAAG,IAAI,CAAC,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"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Why a `keychainStore` step failed, in `KeychainError.failure`. Switch on `kind`:
3
+ * - `unavailable`: there's no keychain here, as on Linux with no Secret Service or no D-Bus
4
+ * session (most servers and containers). The only kind after which a file may stand in for the
5
+ * keychain, if the app or the person chooses it.
6
+ * - `locked`: the keychain is locked and can't ask to be unlocked, as on a Mac over SSH after a
7
+ * reboot, before anyone has logged in at the screen.
8
+ * - `refused`: any other refusal by the keychain, in its own words in the message.
9
+ * - `timeout`: the step took longer than its `timeoutMs`, so its helper was ended: a keychain
10
+ * prompt nobody answered, say.
11
+ * - `helper`: the helper process failed. It couldn't start, or it ended or answered something else
12
+ * before it answered. `exit` says how it ended, when it did.
13
+ * - `missing`: the optional package `@napi-rs/keyring` isn't installed.
14
+ * - `too-long`: the tokens are over the 2,560 bytes every platform can keep, so nothing was saved.
15
+ *
16
+ * `unavailable` and `locked` are read from the keychain library's words, which carry no code. Only
17
+ * words known for each match. Anything else is `refused`, never `unavailable`, so that a broken
18
+ * keychain can't send the tokens to a file.
19
+ */
20
+ export type KeychainFailure = {
21
+ readonly kind: 'unavailable';
22
+ } | {
23
+ readonly kind: 'locked';
24
+ } | {
25
+ readonly kind: 'refused';
26
+ } | {
27
+ readonly kind: 'timeout';
28
+ readonly timeoutMs: number;
29
+ } | {
30
+ readonly kind: 'helper';
31
+ readonly exit: {
32
+ readonly code: number | null;
33
+ readonly signal: string | null;
34
+ } | null;
35
+ } | {
36
+ readonly kind: 'missing';
37
+ } | {
38
+ readonly kind: 'too-long';
39
+ readonly bytes: number;
40
+ };
41
+ /**
42
+ * What `keychainStore`'s `tokens`, `save` and `clear` reject with when the keychain or its helper
43
+ * fails, and so the `cause` of a session's `store_failed` on that store. The store's own checks
44
+ * fail as they do for every store: tokens with no access token, or an item holding something
45
+ * other than tokens. The message says what happened, never with a token in it.
46
+ */
47
+ export declare class KeychainError extends Error {
48
+ /** Why the step failed: switch on `failure.kind`. */
49
+ readonly failure: KeychainFailure;
50
+ constructor(message: string, failure: KeychainFailure, options?: ErrorOptions);
51
+ }
52
+ /** The kind of a refusal, from the keychain library's words. */
53
+ export declare function refusalKind(said: string): 'unavailable' | 'locked' | 'refused';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * What `keychainStore`'s `tokens`, `save` and `clear` reject with when the keychain or its helper
3
+ * fails, and so the `cause` of a session's `store_failed` on that store. The store's own checks
4
+ * fail as they do for every store: tokens with no access token, or an item holding something
5
+ * other than tokens. The message says what happened, never with a token in it.
6
+ */
7
+ export class KeychainError extends Error {
8
+ /** Why the step failed: switch on `failure.kind`. */
9
+ failure;
10
+ constructor(message, failure, options) {
11
+ super(message, options);
12
+ this.name = 'KeychainError';
13
+ this.failure = failure;
14
+ }
15
+ }
16
+ /*
17
+ * @napi-rs/keyring 2.1.0's words for each kind. It passes keyring-core 1.0's errors on as text,
18
+ * "Platform failure: …" or "Couldn't access platform storage: …", around the platform's own words.
19
+ * Each pattern says where its words come from: a run in a container, the library's source, or a
20
+ * guess still to be checked live.
21
+ */
22
+ const UNAVAILABLE = [
23
+ // Run (Debian in Docker, a D-Bus session but no Secret Service): the item's constructor throws it.
24
+ /^Platform failure: DBus error: The name org\.freedesktop\.secrets was not provided by any \.service files/,
25
+ // Run (Debian in Docker, no D-Bus session at all).
26
+ /^Platform failure: DBus error: .*DBUS_SESSION_BUS_ADDRESS/,
27
+ // Source: dbus-secret-service's Error::Unavailable. Not run.
28
+ /^Platform failure: No DBus session or Secret Service provider found/,
29
+ // Guessed: macOS's errSecNotAvailable (-25291), which the library calls NoStorageAccess, in
30
+ // macOS's English words. Not run.
31
+ /^Couldn't access platform storage: No keychain is available/,
32
+ ];
33
+ const LOCKED = [
34
+ // Source: dbus-secret-service's Error::Locked, which the library calls NoStorageAccess. Not run.
35
+ /^Couldn't access platform storage: Secret Service: object locked/,
36
+ // Guessed: macOS's errSecInteractionNotAllowed (-25308), a locked keychain with no screen to ask
37
+ // on, in macOS's English words. Michel's live check shows the real words.
38
+ /^Platform failure: User interaction is not allowed/,
39
+ ];
40
+ /** The kind of a refusal, from the keychain library's words. */
41
+ export function refusalKind(said) {
42
+ if (UNAVAILABLE.some((words) => words.test(said)))
43
+ return 'unavailable';
44
+ if (LOCKED.some((words) => words.test(said)))
45
+ return 'locked';
46
+ return 'refused';
47
+ }
48
+ //# sourceMappingURL=keychainError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keychainError.js","sourceRoot":"","sources":["../../src/node/keychainError.ts"],"names":[],"mappings":"AA4BA;;;;;GAKG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,qDAAqD;IAC5C,OAAO,CAAiB;IAEjC,YAAY,OAAe,EAAE,OAAwB,EAAE,OAAsB;QAC3E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,WAAW,GAAsB;IACrC,mGAAmG;IACnG,2GAA2G;IAC3G,mDAAmD;IACnD,2DAA2D;IAC3D,6DAA6D;IAC7D,qEAAqE;IACrE,4FAA4F;IAC5F,kCAAkC;IAClC,6DAA6D;CAC9D,CAAA;AAED,MAAM,MAAM,GAAsB;IAChC,iGAAiG;IACjG,kEAAkE;IAClE,iGAAiG;IACjG,0EAA0E;IAC1E,oDAAoD;CACrD,CAAA;AAED,gEAAgE;AAChE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,aAAa,CAAA;IACvE,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC7D,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -5,10 +5,10 @@ export interface KeychainStoreOptions {
5
5
  /** The item's account, such as the issuer the tokens are for. */
6
6
  readonly account: string;
7
7
  /**
8
- * How long one step may take before it is ended, as `store_failed`: 30 s unless you say. A
8
+ * How long one step may take before it is ended, as a `timeout`: 30 s unless you say. A
9
9
  * keychain prompt that a person must answer may need longer. Through `session.token()`, a read
10
- * longer than the caller's 15 s wait is `unavailable`: a longer limit helps the app's own
11
- * `tokens`, `save` and `clear`, and a refresh, which goes on after the caller's wait.
10
+ * is also held to the caller's wait, `createSession`'s `waitMs` (15 s by default), past which it
11
+ * is `unavailable`: give that as long too. This limit is each step's own, whatever the caller's.
12
12
  */
13
13
  readonly timeoutMs?: number;
14
14
  }
@@ -18,17 +18,27 @@ export interface KeychainStoreOptions {
18
18
  * KWallet). One item (`service`, `account`) holds them; a save is one write, seen whole once it has
19
19
  * succeeded, or not at all.
20
20
  *
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 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`).
21
26
  * - **It needs `@napi-rs/keyring`** (`npm install @napi-rs/keyring`), which nothing else in the
22
- * SDK uses. Without it, every step fails as `store_failed`, and says so.
23
- * - **Linux without a Secret Service** (a server, a container) fails as `store_failed`: use
27
+ * SDK uses. Without it, every step fails as `missing`, and says so.
28
+ * - **Linux without a Secret Service** (a server, a container) fails as `unavailable`: use
24
29
  * `fileStore` there.
25
30
  * - **Its steps run in one helper process,** one at a time: started by the first step and kept
26
31
  * warm while the app runs, for every keychain store of the process. A step past its `timeoutMs`
27
- * (30 s) kills it, and the next step starts another. A step whose helper died before it answered
28
- * (a terminal Ctrl-C reaches the helper too) runs once more on a fresh one, within its `timeoutMs`.
29
- * It never keeps the app running, and it ends with the app. It is `process.execPath`, so it needs a Node that runs a script: not an Electron
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
34
+ * helper died before it answered runs once more on a fresh one, within its `timeoutMs`. It never
35
+ * keeps the app running. When the app ends, it ends too: at once when idle or on a read, or once
36
+ * the save or delete it's on is done, within that step's `timeoutMs` and 1 s at most, so a
37
+ * refresh's save isn't lost to a Ctrl-C. 1 s is less than the soonest `fileLock` lets another
38
+ * process take the app's lock. For a helper's first step, the 1 s counts from the helper's own
39
+ * start, so a slow start can't stretch it, and that step may be cut sooner. It is `process.execPath`, so it needs a Node that runs a script: not an Electron
30
40
  * app (without `ELECTRON_RUN_AS_NODE`), a Node single-executable application, or a compiled Bun
31
41
  * binary.
32
- * - **Tokens over 2,560 bytes** fail the save, with nothing written.
42
+ * - **Tokens over 2,560 bytes** fail the save as `too-long`, with nothing written.
33
43
  */
34
44
  export declare function keychainStore(options: KeychainStoreOptions): TokenStore;