@flipstream/sdk 0.12.0 → 0.14.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 +65 -0
- package/README.md +128 -30
- package/dist/api/backend.d.ts +18 -3
- package/dist/api/backend.js +33 -6
- package/dist/api/backend.js.map +1 -1
- package/dist/api/credentials.js +4 -4
- package/dist/api/credentials.js.map +1 -1
- package/dist/api/datasets.js +30 -50
- package/dist/api/datasets.js.map +1 -1
- package/dist/api/handoff.d.ts +1 -1
- package/dist/api/handoff.js +7 -0
- package/dist/api/handoff.js.map +1 -1
- package/dist/api/log.d.ts +4 -4
- package/dist/api/log.js +23 -42
- package/dist/api/log.js.map +1 -1
- package/dist/api/me.d.ts +5 -3
- package/dist/api/me.js +5 -4
- package/dist/api/me.js.map +1 -1
- package/dist/api/members.d.ts +40 -17
- package/dist/api/members.js +66 -29
- package/dist/api/members.js.map +1 -1
- package/dist/api/ownRecord.d.ts +46 -0
- package/dist/api/ownRecord.js +57 -0
- package/dist/api/ownRecord.js.map +1 -0
- package/dist/api/refusal.d.ts +14 -0
- package/dist/api/refusal.js +23 -0
- package/dist/api/refusal.js.map +1 -0
- package/dist/api/wallet.d.ts +2 -1
- package/dist/api/wallet.js +18 -21
- package/dist/api/wallet.js.map +1 -1
- package/dist/api/workspaces.d.ts +14 -9
- package/dist/api/workspaces.js +21 -15
- package/dist/api/workspaces.js.map +1 -1
- package/dist/auth/discovery.js +3 -1
- package/dist/auth/discovery.js.map +1 -1
- package/dist/core/call.d.ts +12 -2
- package/dist/core/call.js +5 -2
- package/dist/core/call.js.map +1 -1
- package/dist/core/identify.d.ts +65 -14
- package/dist/core/identify.js +69 -27
- package/dist/core/identify.js.map +1 -1
- package/dist/core/inPlaceOf.d.ts +6 -0
- package/dist/core/inPlaceOf.js +17 -0
- package/dist/core/inPlaceOf.js.map +1 -0
- package/dist/core/invalid.d.ts +32 -6
- package/dist/core/invalid.js +36 -17
- package/dist/core/invalid.js.map +1 -1
- package/dist/core/notFound.d.ts +2 -2
- package/dist/core/notFound.js.map +1 -1
- package/dist/core/read.d.ts +6 -3
- package/dist/core/read.js +5 -6
- package/dist/core/read.js.map +1 -1
- package/dist/core/result.d.ts +16 -8
- package/dist/core/result.js +1 -0
- package/dist/core/result.js.map +1 -1
- package/dist/core/shared.d.ts +43 -0
- package/dist/core/shared.js +178 -0
- package/dist/core/shared.js.map +1 -0
- package/dist/core/signal.d.ts +12 -0
- package/dist/core/signal.js +25 -0
- package/dist/core/signal.js.map +1 -0
- package/dist/flipstream.d.ts +160 -22
- package/dist/flipstream.js +207 -81
- package/dist/flipstream.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/node/clientSecret.js +2 -1
- package/dist/node/clientSecret.js.map +1 -1
- package/dist/node/keychainChild.js +60 -25
- package/dist/node/keychainChild.js.map +1 -1
- package/dist/node/keychainError.d.ts +4 -1
- package/dist/node/keychainError.js.map +1 -1
- package/dist/node/keychainStore.js +42 -8
- package/dist/node/keychainStore.js.map +1 -1
- package/dist/node/loopback.d.ts +5 -2
- package/dist/node/loopback.js +28 -3
- package/dist/node/loopback.js.map +1 -1
- package/dist/node/session.js +11 -5
- package/dist/node/session.js.map +1 -1
- package/dist/query/query.d.ts +52 -8
- package/dist/query/query.js +133 -19
- package/dist/query/query.js.map +1 -1
- package/dist/version.gen.js +1 -1
- package/docs/admin.md +108 -4
- package/docs/node-sign-in.md +11 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/api/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../src/api/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K,UAAU,gBAAgB,CAAC,IAAa,EAAE,IAAU,EAAE,WAAmB,EAAE,MAAwB;IAC7G,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAA;IACjF,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,GAAG,CAAA;IACvB,OAAO,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AACvG,CAAC"}
|
package/dist/auth/discovery.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { call } from '../core/call.js';
|
|
3
|
+
import { invalidIn } from '../core/invalid.js';
|
|
3
4
|
import { authTransport, endpointProblem, isSignInUrl } from './transport.js';
|
|
4
5
|
/**
|
|
5
6
|
* What a `server` given in place of discovery lacks, as `server.<field>` with what it must be, or
|
|
@@ -56,8 +57,9 @@ export async function discover(issuer, options = {}) {
|
|
|
56
57
|
return read;
|
|
57
58
|
const doc = read.data;
|
|
58
59
|
const problem = problemWith(doc, issuer);
|
|
60
|
+
// Any server the app names, with the status its answer came with, as every check has (invalid.ts).
|
|
59
61
|
if (problem !== null)
|
|
60
|
-
return
|
|
62
|
+
return invalidIn(read, problem);
|
|
61
63
|
return {
|
|
62
64
|
ok: true,
|
|
63
65
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/auth/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/auth/discovery.ts"],"names":[],"mappings":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O,OAAO,CAAA;IACpC,IAAI,GAAG,CAAC,gCAAgC,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI;QAAE,OAAO,oCAAoC,CAAA;IAChH,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/core/call.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import type { HeardResult } from './invalid.js';
|
|
3
|
+
import type { SharedRule } from './shared.js';
|
|
3
4
|
import { type RetryRule } from './retry.js';
|
|
4
5
|
import type { ApiRequest, Transport } from './transport.js';
|
|
5
6
|
/** One endpoint's call: what it sends, and the rules it is sent under, declared next to its schema. */
|
|
@@ -14,6 +15,12 @@ export interface CallSpec<T> extends Omit<ApiRequest, 'signal'> {
|
|
|
14
15
|
* alone (#278 round 1). Left out, the text is kept, as for every other call.
|
|
15
16
|
*/
|
|
16
17
|
readonly keepsNoText?: true;
|
|
18
|
+
/**
|
|
19
|
+
* Inside one scope (`flipstream.scope()`, #376), one read serves every call that asks for it, by
|
|
20
|
+
* its key: your organisation's, your person's and a workspace's own. Left out, every call reads
|
|
21
|
+
* its own.
|
|
22
|
+
*/
|
|
23
|
+
readonly shared?: SharedRule;
|
|
17
24
|
}
|
|
18
25
|
/**
|
|
19
26
|
* One call: attempts under its rule, every attempt, wait and read under one signal that joins the
|
|
@@ -22,5 +29,8 @@ export interface CallSpec<T> extends Omit<ApiRequest, 'signal'> {
|
|
|
22
29
|
* `callEnd` is the SDK call's own end, for a read (#349): it ends the request as the caller's abort
|
|
23
30
|
* does, `aborted`, and one already ended sends nothing. It's the SDK's own signal, kept apart from
|
|
24
31
|
* the caller's, so a caller's signal gets one listener a request, as before, and never one more.
|
|
32
|
+
* Its answer is read from the attempt that ends it, so a check of it after takes that attempt's
|
|
33
|
+
* status (invalid.ts, #385). It's handed on as readJson read it, a `Heard` answer (#394), never
|
|
34
|
+
* rebuilt.
|
|
25
35
|
*/
|
|
26
|
-
export declare function call<T>(transport: Transport, spec: CallSpec<T>, signal?: AbortSignal, callEnd?: AbortSignal): Promise<
|
|
36
|
+
export declare function call<T>(transport: Transport, spec: CallSpec<T>, signal?: AbortSignal, callEnd?: AbortSignal): Promise<HeardResult<T>>;
|
package/dist/core/call.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readJson } from './read.js';
|
|
|
2
2
|
import { deadlineIn, MAX_TIMER_MS } from './deadline.js';
|
|
3
3
|
import { classifyStatus } from './result.js';
|
|
4
4
|
import { decide, parseRetryAfterMs } from './retry.js';
|
|
5
|
+
import { stopListening } from './signal.js';
|
|
5
6
|
/**
|
|
6
7
|
* One call: attempts under its rule, every attempt, wait and read under one signal that joins the
|
|
7
8
|
* caller's with the deadline. Whichever fires first decides the answer, `timeout` or `aborted`
|
|
@@ -9,6 +10,9 @@ import { decide, parseRetryAfterMs } from './retry.js';
|
|
|
9
10
|
* `callEnd` is the SDK call's own end, for a read (#349): it ends the request as the caller's abort
|
|
10
11
|
* does, `aborted`, and one already ended sends nothing. It's the SDK's own signal, kept apart from
|
|
11
12
|
* the caller's, so a caller's signal gets one listener a request, as before, and never one more.
|
|
13
|
+
* Its answer is read from the attempt that ends it, so a check of it after takes that attempt's
|
|
14
|
+
* status (invalid.ts, #385). It's handed on as readJson read it, a `Heard` answer (#394), never
|
|
15
|
+
* rebuilt.
|
|
12
16
|
*/
|
|
13
17
|
export async function call(transport, spec, signal, callEnd) {
|
|
14
18
|
if (signal?.aborted === true || callEnd?.aborted === true)
|
|
@@ -74,8 +78,7 @@ export async function call(transport, spec, signal, callEnd) {
|
|
|
74
78
|
finally {
|
|
75
79
|
clearTimeout(timer);
|
|
76
80
|
// A minimal polyfill signal may have no removeEventListener; it keeps its one listener.
|
|
77
|
-
|
|
78
|
-
signal.removeEventListener('abort', onAbort);
|
|
81
|
+
stopListening(signal, onAbort);
|
|
79
82
|
callEnd?.removeEventListener('abort', onEnd);
|
|
80
83
|
}
|
|
81
84
|
}
|
package/dist/core/call.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/core/call.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/core/call.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,cAAc,EAAgC,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAgC,MAAM,YAAY,CAAA;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AA4B3C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAI,SAAoB,EAAE,IAAiB,EAAE,MAAoB,EAAE,OAAqB;IAChH,IAAI,MAAM,EAAE,OAAO,KAAK,IAAI,IAAI,OAAO,EAAE,OAAO,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IAC7F,mGAAmG;IACnG,gGAAgG;IAChG,kGAAkG;IAClG,iGAAiG;IACjG,kGAAkG;IAClG,gGAAgG;IAChG,2FAA2F;IAC3F,gBAAgB;IAChB,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,GAAG,YAAY;QAAE,OAAO,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IACjG,6FAA6F;IAC7F,gGAAgG;IAChG,mBAAmB;IACnB,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC5C,8FAA8F;IAC9F,yFAAyF;IACzF,MAAM,IAAI,GAAG,IAAI,eAAe,EAAE,CAAA;IAClC,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,GAA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AI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAA;AAEnF,qHAAqH;AACrH,SAAS,KAAK,CAAC,EAAU,EAAE,MAAmB;IAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,wFAAwF;QACxF,uFAAuF;QACvF,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,OAAO,EAAE,CAAA;QACpC,MAAM,IAAI,GAAG,GAAS,EAAE;YACtB,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;YACzC,OAAO,EAAE,CAAA;QACX,CAAC,CAAA;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAClC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,KAAe,EAAU,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA"}
|
package/dist/core/identify.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ServiceName } from './transport.js';
|
|
1
2
|
/** An app's or an agent's name and version, as a product token: `name/version`. */
|
|
2
3
|
export interface Product {
|
|
3
4
|
readonly name: string;
|
|
@@ -21,6 +22,12 @@ export interface Trace {
|
|
|
21
22
|
readonly traceId: string;
|
|
22
23
|
readonly flags: string;
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* A caller's own `traceparent`'s trace: its trace-id and flags, when it's a valid version-00 one.
|
|
27
|
+
* Undefined for anything else, a value that isn't a string included, which W3C Trace Context says
|
|
28
|
+
* to drop.
|
|
29
|
+
*/
|
|
30
|
+
export declare function callerTrace(callerTraceparent: unknown): Trace | undefined;
|
|
24
31
|
/**
|
|
25
32
|
* The trace a call goes out under. A caller's own `traceparent` is carried on when it is one;
|
|
26
33
|
* otherwise, as W3C Trace Context says of one that can't be parsed, the call starts its own. A new
|
|
@@ -30,24 +37,29 @@ export interface Trace {
|
|
|
30
37
|
export declare function traceFor(callerTraceparent: unknown): Trace;
|
|
31
38
|
/** The traceparent of one attempt: the call's trace, with a parent-id of its own. */
|
|
32
39
|
export declare function traceparent(trace: Trace): string;
|
|
33
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* What a request says about who sent it: the header that names the products, `User-Agent` in Node
|
|
42
|
+
* and `Flipstream-Client` in a browser, its value, the baggage, and the caller's values in them.
|
|
43
|
+
*/
|
|
34
44
|
export interface Sender {
|
|
35
|
-
readonly
|
|
45
|
+
readonly header: 'user-agent' | 'flipstream-client';
|
|
46
|
+
readonly products: string;
|
|
36
47
|
readonly baggage: string | undefined;
|
|
37
48
|
/** Each of which must never hold the access token. */
|
|
38
49
|
readonly values: readonly string[];
|
|
39
50
|
}
|
|
40
51
|
/**
|
|
41
|
-
* A signed-in call's:
|
|
42
|
-
* `
|
|
43
|
-
* agent or a conversation: no empty
|
|
52
|
+
* A signed-in call's: `<app>/<version> flipstream-sdk/<version>`, with ` node/<version>` in Node, as
|
|
53
|
+
* `User-Agent` there and as `Flipstream-Client` in a browser; and `baggage` with OpenTelemetry's
|
|
54
|
+
* GenAI names, each value percent-encoded, only when there is an agent or a conversation: no empty
|
|
55
|
+
* header.
|
|
44
56
|
*/
|
|
45
|
-
export declare function callerSender(identity: Identity, conversationId: string | undefined,
|
|
57
|
+
export declare function callerSender(identity: Identity, conversationId: string | undefined, runtime: Identifying): Sender;
|
|
46
58
|
/**
|
|
47
|
-
* Health's, signed out (D535): `
|
|
48
|
-
* for no token, so nothing could check a caller's value there, and a probe gains little from one.
|
|
59
|
+
* Health's, signed out (D535): `flipstream-sdk/<version>`, with ` node/<version>` in Node, alone. It
|
|
60
|
+
* asks for no token, so nothing could check a caller's value there, and a probe gains little from one.
|
|
49
61
|
*/
|
|
50
|
-
export declare function sdkSender(
|
|
62
|
+
export declare function sdkSender(runtime: Identifying): Sender;
|
|
51
63
|
/**
|
|
52
64
|
* Whether a caller's `value` holds the access token (#199): contains it, for a token of real
|
|
53
65
|
* length; equals it, for a shorter one, which as a substring turns up in ordinary values ('abc' in
|
|
@@ -55,9 +67,48 @@ export declare function sdkSender(nodeVersion: string): Sender;
|
|
|
55
67
|
*/
|
|
56
68
|
export declare function valueHolds(value: string, token: string): boolean;
|
|
57
69
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
* Where the SDK runs, for what its requests say about who sent them (#192, #196): Node, a browser
|
|
71
|
+
* (a page, with its CORS), or another runtime, which sends none of it.
|
|
72
|
+
*/
|
|
73
|
+
export type Runtime = {
|
|
74
|
+
readonly kind: 'node';
|
|
75
|
+
readonly version: string;
|
|
76
|
+
} | {
|
|
77
|
+
readonly kind: 'browser';
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: 'other';
|
|
80
|
+
};
|
|
81
|
+
/** A runtime whose requests say who sent them. */
|
|
82
|
+
export type Identifying = Exclude<Runtime, {
|
|
83
|
+
readonly kind: 'other';
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Node, or a runtime that says it is Node's (Bun, Deno with Node's compatibility), with no
|
|
87
|
+
* `window`: its version. Otherwise a browser, when a page's `document` is defined (a page,
|
|
88
|
+
* Electron's renderer, a jsdom test): there a cross-origin request's custom headers are
|
|
89
|
+
* preflighted, so they go only where CORS allows them (#196). Anything else (Deno 1.x, which has a
|
|
90
|
+
* `window` but no `document`, a Worker, an edge function, React Native, a bundler's stand-in
|
|
91
|
+
* `process` with no versions) is `other`, and sends none, as before #196 (#378's code review, 3).
|
|
92
|
+
*/
|
|
93
|
+
export declare function runtimeOf(): Runtime;
|
|
94
|
+
/**
|
|
95
|
+
* Which hosts a request says who sent it to, in Node and in a browser: the whole policy, in one
|
|
96
|
+
* table (#378's code review, 7). Switching a host on for a browser is its line here, and its row in
|
|
97
|
+
* test/query/identify-browser.test.mjs, once its CORS allows `Flipstream-Client`, `traceparent` and
|
|
98
|
+
* `baggage`: a browser refuses every call to a host whose CORS doesn't, and the SDK can't tell that
|
|
99
|
+
* refusal from a network failure (`unavailable`).
|
|
100
|
+
* - query: in a browser too, since query-planner#41 (6100c0e, deployed 18 Nov 2026).
|
|
101
|
+
* - admin and wallet: Node only, until pulse-admin's and pulse-wallet's CORS allows them (Douwe's).
|
|
102
|
+
* - api: the public gateway, which the SDK doesn't call yet.
|
|
103
|
+
* - auth: never, where sign-in sends none (#192).
|
|
104
|
+
*/
|
|
105
|
+
export declare const IDENTIFIED: Readonly<Record<ServiceName, {
|
|
106
|
+
readonly node: boolean;
|
|
107
|
+
readonly browser: boolean;
|
|
108
|
+
}>>;
|
|
109
|
+
/**
|
|
110
|
+
* Whether a request to `service` says who sent it, by `IDENTIFIED`. In a browser, only at its
|
|
111
|
+
* deployed origin (`atDeployedOrigin`): a custom host (a proxy, staging, a local planner) gets none,
|
|
112
|
+
* as before #196, since nothing says its CORS allows them (#378's code review, 1).
|
|
62
113
|
*/
|
|
63
|
-
export declare function
|
|
114
|
+
export declare function identifies(runtime: Identifying, service: ServiceName, atDeployedOrigin: boolean): boolean;
|
package/dist/core/identify.js
CHANGED
|
@@ -40,6 +40,20 @@ export function identityOf(options) {
|
|
|
40
40
|
throw invalid('conversationId', CONVERSATION_RULE);
|
|
41
41
|
return { app, agent, conversationId };
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* A caller's own `traceparent`'s trace: its trace-id and flags, when it's a valid version-00 one.
|
|
45
|
+
* Undefined for anything else, a value that isn't a string included, which W3C Trace Context says
|
|
46
|
+
* to drop.
|
|
47
|
+
*/
|
|
48
|
+
export function callerTrace(callerTraceparent) {
|
|
49
|
+
const match = typeof callerTraceparent === 'string' ? TRACEPARENT.exec(callerTraceparent) : null;
|
|
50
|
+
if (match === null)
|
|
51
|
+
return undefined;
|
|
52
|
+
const [, traceId, parentId, flags] = match;
|
|
53
|
+
if (traceId === undefined || parentId === undefined || flags === undefined || traceId === ZERO_TRACE_ID || parentId === ZERO_PARENT_ID)
|
|
54
|
+
return undefined;
|
|
55
|
+
return { traceId, flags };
|
|
56
|
+
}
|
|
43
57
|
/**
|
|
44
58
|
* The trace a call goes out under. A caller's own `traceparent` is carried on when it is one;
|
|
45
59
|
* otherwise, as W3C Trace Context says of one that can't be parsed, the call starts its own. A new
|
|
@@ -47,13 +61,7 @@ export function identityOf(options) {
|
|
|
47
61
|
* needs every request (D527).
|
|
48
62
|
*/
|
|
49
63
|
export function traceFor(callerTraceparent) {
|
|
50
|
-
|
|
51
|
-
if (match !== null) {
|
|
52
|
-
const [, traceId, parentId, flags] = match;
|
|
53
|
-
if (traceId !== undefined && parentId !== undefined && flags !== undefined && traceId !== ZERO_TRACE_ID && parentId !== ZERO_PARENT_ID)
|
|
54
|
-
return { traceId, flags };
|
|
55
|
-
}
|
|
56
|
-
return { traceId: randomHex(16, ZERO_TRACE_ID), flags: '01' };
|
|
64
|
+
return callerTrace(callerTraceparent) ?? { traceId: randomHex(16, ZERO_TRACE_ID), flags: '01' };
|
|
57
65
|
}
|
|
58
66
|
/** The traceparent of one attempt: the call's trace, with a parent-id of its own. */
|
|
59
67
|
export function traceparent(trace) {
|
|
@@ -68,29 +76,34 @@ function randomHex(bytes, zero) {
|
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
/**
|
|
71
|
-
* A signed-in call's:
|
|
72
|
-
* `
|
|
73
|
-
* agent or a conversation: no empty
|
|
79
|
+
* A signed-in call's: `<app>/<version> flipstream-sdk/<version>`, with ` node/<version>` in Node, as
|
|
80
|
+
* `User-Agent` there and as `Flipstream-Client` in a browser; and `baggage` with OpenTelemetry's
|
|
81
|
+
* GenAI names, each value percent-encoded, only when there is an agent or a conversation: no empty
|
|
82
|
+
* header.
|
|
74
83
|
*/
|
|
75
|
-
export function callerSender(identity, conversationId,
|
|
84
|
+
export function callerSender(identity, conversationId, runtime) {
|
|
76
85
|
const { app, agent } = identity;
|
|
77
86
|
const members = [];
|
|
78
87
|
if (agent !== undefined)
|
|
79
88
|
members.push(`gen_ai.agent.name=${encodeURIComponent(agent.name)}`, `gen_ai.agent.version=${encodeURIComponent(agent.version)}`);
|
|
80
89
|
if (conversationId !== undefined)
|
|
81
90
|
members.push(`gen_ai.conversation.id=${encodeURIComponent(conversationId)}`);
|
|
91
|
+
const sdk = sdkSender(runtime);
|
|
82
92
|
return {
|
|
83
|
-
|
|
93
|
+
header: sdk.header,
|
|
94
|
+
products: `${app.name}/${app.version} ${sdk.products}`,
|
|
84
95
|
baggage: members.length > 0 ? members.join(',') : undefined,
|
|
85
96
|
values: [app.name, app.version, ...(agent === undefined ? [] : [agent.name, agent.version]), ...(conversationId === undefined ? [] : [conversationId])],
|
|
86
97
|
};
|
|
87
98
|
}
|
|
88
99
|
/**
|
|
89
|
-
* Health's, signed out (D535): `
|
|
90
|
-
* for no token, so nothing could check a caller's value there, and a probe gains little from one.
|
|
100
|
+
* Health's, signed out (D535): `flipstream-sdk/<version>`, with ` node/<version>` in Node, alone. It
|
|
101
|
+
* asks for no token, so nothing could check a caller's value there, and a probe gains little from one.
|
|
91
102
|
*/
|
|
92
|
-
export function sdkSender(
|
|
93
|
-
return
|
|
103
|
+
export function sdkSender(runtime) {
|
|
104
|
+
return runtime.kind === 'node'
|
|
105
|
+
? { header: 'user-agent', products: `flipstream-sdk/${version} node/${runtime.version}`, baggage: undefined, values: [] }
|
|
106
|
+
: { header: 'flipstream-client', products: `flipstream-sdk/${version}`, baggage: undefined, values: [] };
|
|
94
107
|
}
|
|
95
108
|
/**
|
|
96
109
|
* The shortest token looked for inside a value. A real access token, a JWT, runs to hundreds of
|
|
@@ -106,17 +119,46 @@ export function valueHolds(value, token) {
|
|
|
106
119
|
return token.length >= TOKEN_SEARCHED_FROM ? value.includes(token) : value === token;
|
|
107
120
|
}
|
|
108
121
|
/**
|
|
109
|
-
* Node
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
122
|
+
* Node, or a runtime that says it is Node's (Bun, Deno with Node's compatibility), with no
|
|
123
|
+
* `window`: its version. Otherwise a browser, when a page's `document` is defined (a page,
|
|
124
|
+
* Electron's renderer, a jsdom test): there a cross-origin request's custom headers are
|
|
125
|
+
* preflighted, so they go only where CORS allows them (#196). Anything else (Deno 1.x, which has a
|
|
126
|
+
* `window` but no `document`, a Worker, an edge function, React Native, a bundler's stand-in
|
|
127
|
+
* `process` with no versions) is `other`, and sends none, as before #196 (#378's code review, 3).
|
|
113
128
|
*/
|
|
114
|
-
export function
|
|
115
|
-
if (typeof window
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
export function runtimeOf() {
|
|
130
|
+
if (typeof window === 'undefined' && typeof process !== 'undefined') {
|
|
131
|
+
const versions = process.versions;
|
|
132
|
+
const node = isRecord(versions) ? versions['node'] : undefined;
|
|
133
|
+
if (typeof node === 'string' && PRODUCT_TOKEN.test(node))
|
|
134
|
+
return { kind: 'node', version: node };
|
|
135
|
+
}
|
|
136
|
+
return typeof document !== 'undefined' ? { kind: 'browser' } : { kind: 'other' };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Which hosts a request says who sent it to, in Node and in a browser: the whole policy, in one
|
|
140
|
+
* table (#378's code review, 7). Switching a host on for a browser is its line here, and its row in
|
|
141
|
+
* test/query/identify-browser.test.mjs, once its CORS allows `Flipstream-Client`, `traceparent` and
|
|
142
|
+
* `baggage`: a browser refuses every call to a host whose CORS doesn't, and the SDK can't tell that
|
|
143
|
+
* refusal from a network failure (`unavailable`).
|
|
144
|
+
* - query: in a browser too, since query-planner#41 (6100c0e, deployed 18 Nov 2026).
|
|
145
|
+
* - admin and wallet: Node only, until pulse-admin's and pulse-wallet's CORS allows them (Douwe's).
|
|
146
|
+
* - api: the public gateway, which the SDK doesn't call yet.
|
|
147
|
+
* - auth: never, where sign-in sends none (#192).
|
|
148
|
+
*/
|
|
149
|
+
export const IDENTIFIED = {
|
|
150
|
+
query: { node: true, browser: true },
|
|
151
|
+
admin: { node: true, browser: false },
|
|
152
|
+
wallet: { node: true, browser: false },
|
|
153
|
+
api: { node: true, browser: false },
|
|
154
|
+
auth: { node: false, browser: false },
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Whether a request to `service` says who sent it, by `IDENTIFIED`. In a browser, only at its
|
|
158
|
+
* deployed origin (`atDeployedOrigin`): a custom host (a proxy, staging, a local planner) gets none,
|
|
159
|
+
* as before #196, since nothing says its CORS allows them (#378's code review, 1).
|
|
160
|
+
*/
|
|
161
|
+
export function identifies(runtime, service, atDeployedOrigin) {
|
|
162
|
+
return runtime.kind === 'node' ? IDENTIFIED[service].node : IDENTIFIED[service].browser && atDeployedOrigin;
|
|
121
163
|
}
|
|
122
164
|
//# sourceMappingURL=identify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identify.js","sourceRoot":"","sources":["../../src/core/identify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"identify.js","sourceRoot":"","sources":["../../src/core/identify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAyB3C,sGAAsG;AACtG,MAAM,aAAa,GAAG,qCAAqC,CAAA;AAC3D,MAAM,eAAe,GAAG,0BAA0B,CAAA;AAClD,qEAAqE;AACrE,MAAM,WAAW,GAAG,kDAAkD,CAAA;AACtE,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AACpC,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAErC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAAC,OAAO,KAAK,KAA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js';
|
|
2
|
+
import type { ApiError } from './result.js';
|
|
3
|
+
/** `replacement`, answered in place of `failed`, and remembered as standing for it. */
|
|
4
|
+
export declare function inPlaceOf(failed: Failed, replacement: Failed): Failed;
|
|
5
|
+
/** The failure `error` was answered in place of, or `error` itself when it wasn't. */
|
|
6
|
+
export declare function standsFor(error: ApiError): ApiError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A failure the SDK answers in place of another (#410's code review, 1): D578's `not_found` for a
|
|
3
|
+
* record the backend refused. The call still names the request the refusal came from, as it does
|
|
4
|
+
* for the backend's own 404, so in a scope, where that request may be a shared read, the trace can't
|
|
5
|
+
* tell the two apart, and Logs still leads to the refusal.
|
|
6
|
+
*/
|
|
7
|
+
const replaced = new WeakMap();
|
|
8
|
+
/** `replacement`, answered in place of `failed`, and remembered as standing for it. */
|
|
9
|
+
export function inPlaceOf(failed, replacement) {
|
|
10
|
+
replaced.set(replacement.error, failed.error);
|
|
11
|
+
return replacement;
|
|
12
|
+
}
|
|
13
|
+
/** The failure `error` was answered in place of, or `error` itself when it wasn't. */
|
|
14
|
+
export function standsFor(error) {
|
|
15
|
+
return replaced.get(error) ?? error;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=inPlaceOf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inPlaceOf.js","sourceRoot":"","sources":["../../src/core/inPlaceOf.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAsB,CAAA;AAElD,uFAAuF;AACvF,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,WAAmB;IAC3D,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;IAC7C,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,SAAS,CAAC,KAAe;IACvC,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAA;AACrC,CAAC"}
|
package/dist/core/invalid.d.ts
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import type { ApiResult } from './result.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
type Answer<T> = Extract<ApiResult<T>, {
|
|
4
|
+
readonly ok: true;
|
|
5
|
+
}>;
|
|
6
|
+
/** A result's failure, as the public `ApiResult` describes it. */
|
|
7
|
+
export type Failed = Extract<ApiResult<never>, {
|
|
8
|
+
readonly ok: false;
|
|
9
|
+
}>;
|
|
10
|
+
declare class HeardMark {
|
|
11
|
+
private heardMark;
|
|
12
|
+
}
|
|
13
|
+
/** An answer readParsed read from a 2xx, its status remembered: the one kind a check takes (#394). */
|
|
14
|
+
export type Heard<T> = Answer<T> & HeardMark;
|
|
15
|
+
/** A read's result as readParsed hands it on, and every layer after it: a `Heard` answer, or a failure. */
|
|
16
|
+
export type HeardResult<T> = Heard<T> | Failed;
|
|
17
|
+
/** The fault readParsed answers if it couldn't remember an answer it read. */
|
|
18
|
+
export declare const UNHEARD = "the answer couldn't be remembered with its status, so it isn't handed on";
|
|
19
|
+
/**
|
|
20
|
+
* `value`, a 2xx's JSON, read by `schema`: the data, as a `Heard` answer with the response's
|
|
21
|
+
* `status` remembered for a check of it after, or `invalid` with that `status`. readJson's own last
|
|
22
|
+
* step, and the one a scope's shared read takes for each call (#377's code review, 10), so both give
|
|
23
|
+
* one shape, status and issue text. Zod's issues name paths and expected types, never the body's
|
|
24
|
+
* values. The one place an answer becomes `Heard` (#398's code review, 3).
|
|
25
|
+
*/
|
|
26
|
+
export declare function readParsed<T>(value: unknown, schema: z.ZodType<T>, status: number | undefined): HeardResult<T>;
|
|
27
|
+
/** The status `answer` came with, as readParsed remembered it; none when its read heard none. */
|
|
28
|
+
export declare function statusOf(answer: Heard<unknown>): number | undefined;
|
|
29
|
+
/** `invalid`, found by a check of `answer` after its read, with the status `answer` came with (#385). */
|
|
30
|
+
export declare function invalidIn(answer: Heard<unknown>, issues: string): Failed;
|
|
31
|
+
/** `invalid` with `status`, a status the failure came with, or with none when it's undefined. */
|
|
32
|
+
export declare function invalidWith(issues: string, status: number | undefined): Failed;
|
|
33
|
+
export {};
|
package/dist/core/invalid.js
CHANGED
|
@@ -1,22 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// The status each answer came with, keyed by the answer itself, weakly, so it lives as long as the
|
|
3
|
+
// answer does. Only readParsed sets it, so only an answer as read is in it, with its status, or with
|
|
4
|
+
// none when its read heard none.
|
|
5
|
+
const answeredWith = new WeakMap();
|
|
6
|
+
/** Whether readParsed remembered `answer`: the one check that makes an answer `Heard` (#394). */
|
|
7
|
+
const isHeard = (answer) => answeredWith.has(answer);
|
|
8
|
+
/** The fault readParsed answers if it couldn't remember an answer it read. */
|
|
9
|
+
export const UNHEARD = "the answer couldn't be remembered with its status, so it isn't handed on";
|
|
10
|
+
/**
|
|
11
|
+
* `value`, a 2xx's JSON, read by `schema`: the data, as a `Heard` answer with the response's
|
|
12
|
+
* `status` remembered for a check of it after, or `invalid` with that `status`. readJson's own last
|
|
13
|
+
* step, and the one a scope's shared read takes for each call (#377's code review, 10), so both give
|
|
14
|
+
* one shape, status and issue text. Zod's issues name paths and expected types, never the body's
|
|
15
|
+
* values. The one place an answer becomes `Heard` (#398's code review, 3).
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
export function readParsed(value, schema, status) {
|
|
18
|
+
const parsed = schema.safeParse(value);
|
|
19
|
+
if (!parsed.success)
|
|
20
|
+
return invalidWith(z.prettifyError(parsed.error), status);
|
|
21
|
+
const answer = { ok: true, data: parsed.data };
|
|
22
|
+
answeredWith.set(answer, status);
|
|
23
|
+
// The predicate reads what was just remembered, so it holds. Were it ever not to, the read answers
|
|
24
|
+
// invalid, naming why, as the session answers its own code's failure (session.ts's revoke, K6,
|
|
25
|
+
// rev140's round 3, P3.5): a result that fails closed, never a throw out of every read, and never
|
|
26
|
+
// an answer handed on that a check would find no status in (#398's code review, 6).
|
|
27
|
+
return isHeard(answer) ? answer : invalidWith(UNHEARD, status);
|
|
28
|
+
}
|
|
29
|
+
/** The status `answer` came with, as readParsed remembered it; none when its read heard none. */
|
|
30
|
+
export function statusOf(answer) {
|
|
31
|
+
return answeredWith.get(answer);
|
|
32
|
+
}
|
|
33
|
+
/** `invalid`, found by a check of `answer` after its read, with the status `answer` came with (#385). */
|
|
34
|
+
export function invalidIn(answer, issues) {
|
|
35
|
+
return invalidWith(issues, statusOf(answer));
|
|
36
|
+
}
|
|
37
|
+
/** `invalid` with `status`, a status the failure came with, or with none when it's undefined. */
|
|
15
38
|
export function invalidWith(issues, status) {
|
|
16
39
|
return { ok: false, error: status === undefined ? { kind: 'invalid', issues } : { kind: 'invalid', issues, status } };
|
|
17
40
|
}
|
|
18
|
-
/** `invalid`, found by a check of an answer whose route answers 200 by its backend's own code. */
|
|
19
|
-
export const invalidAnswer = (issues) => invalidWith(issues, 200);
|
|
20
|
-
/** `invalid`, found by a check of an answer whose route's success status isn't known: a create's. */
|
|
21
|
-
export const invalidStatusUnknown = (issues) => invalidWith(issues, undefined);
|
|
22
41
|
//# sourceMappingURL=invalid.js.map
|
package/dist/core/invalid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalid.js","sourceRoot":"","sources":["../../src/core/invalid.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invalid.js","sourceRoot":"","sources":["../../src/core/invalid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA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MAA0B;IACpE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAA;AACvH,CAAC"}
|
package/dist/core/notFound.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Failed } from './invalid.js';
|
|
2
2
|
/**
|
|
3
3
|
* `not_found` exactly as a service answers it for a record nobody has, its own `code` and `message`
|
|
4
4
|
* included, so an answer the SDK makes for a record you can't see says no more than that (D571,
|
|
5
5
|
* #372). A fresh object on each call: a caller that changes one answer never changes another's
|
|
6
6
|
* (#373's code review, 8).
|
|
7
7
|
*/
|
|
8
|
-
export declare const notFound: (code: string, message: string) =>
|
|
8
|
+
export declare const notFound: (code: string, message: string) => Failed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../src/core/notFound.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,OAAe,
|
|
1
|
+
{"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../src/core/notFound.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,OAAe,EAAU,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA"}
|