@flipstream/sdk 0.13.0 → 0.15.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 +120 -0
- package/README.md +143 -21
- package/dist/api/backend.d.ts +7 -0
- package/dist/api/backend.js +7 -0
- 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 +3 -3
- 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 -24
- package/dist/api/wallet.js.map +1 -1
- package/dist/api/workspaces.d.ts +7 -2
- package/dist/api/workspaces.js +14 -8
- package/dist/api/workspaces.js.map +1 -1
- package/dist/auth/discovery.js +4 -5
- package/dist/auth/discovery.js.map +1 -1
- package/dist/auth/transport.d.ts +6 -2
- package/dist/auth/transport.js +5 -3
- package/dist/auth/transport.js.map +1 -1
- package/dist/core/call.d.ts +9 -4
- package/dist/core/call.js +12 -8
- package/dist/core/call.js.map +1 -1
- package/dist/core/fetch.d.ts +20 -1
- package/dist/core/fetch.js +50 -3
- package/dist/core/fetch.js.map +1 -1
- package/dist/core/hosts.d.ts +11 -0
- package/dist/core/hosts.js +13 -0
- package/dist/core/hosts.js.map +1 -0
- package/dist/core/identify.d.ts +12 -2
- package/dist/core/identify.js +31 -19
- 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 -9
- package/dist/core/invalid.js +36 -23
- 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 +4 -10
- package/dist/core/read.js +1 -11
- package/dist/core/read.js.map +1 -1
- package/dist/core/result.d.ts +14 -10
- package/dist/core/result.js +1 -0
- package/dist/core/result.js.map +1 -1
- package/dist/core/shared.d.ts +15 -9
- package/dist/core/shared.js +8 -6
- package/dist/core/shared.js.map +1 -1
- package/dist/core/signal.d.ts +7 -0
- package/dist/core/signal.js +9 -0
- package/dist/core/signal.js.map +1 -1
- package/dist/first-party/asPerson.d.ts +13 -0
- package/dist/first-party/asPerson.js +144 -0
- package/dist/first-party/asPerson.js.map +1 -0
- package/dist/first-party/attempts.d.ts +71 -0
- package/dist/first-party/attempts.js +132 -0
- package/dist/first-party/attempts.js.map +1 -0
- package/dist/first-party/authProxyMark.d.ts +7 -0
- package/dist/first-party/authProxyMark.js +8 -0
- package/dist/first-party/authProxyMark.js.map +1 -0
- package/dist/first-party/browser.d.ts +55 -0
- package/dist/first-party/browser.js +137 -0
- package/dist/first-party/browser.js.map +1 -0
- package/dist/first-party/browserSession.d.ts +95 -0
- package/dist/first-party/browserSession.js +242 -0
- package/dist/first-party/browserSession.js.map +1 -0
- package/dist/first-party/calls/consent.d.ts +77 -0
- package/dist/first-party/calls/consent.js +174 -0
- package/dist/first-party/calls/consent.js.map +1 -0
- package/dist/first-party/calls/device.d.ts +75 -0
- package/dist/first-party/calls/device.js +133 -0
- package/dist/first-party/calls/device.js.map +1 -0
- package/dist/first-party/calls/invitation.d.ts +198 -0
- package/dist/first-party/calls/invitation.js +240 -0
- package/dist/first-party/calls/invitation.js.map +1 -0
- package/dist/first-party/calls/logIn.d.ts +41 -0
- package/dist/first-party/calls/logIn.js +48 -0
- package/dist/first-party/calls/logIn.js.map +1 -0
- package/dist/first-party/calls/reset.d.ts +58 -0
- package/dist/first-party/calls/reset.js +163 -0
- package/dist/first-party/calls/reset.js.map +1 -0
- package/dist/first-party/calls/signUp.d.ts +21 -0
- package/dist/first-party/calls/signUp.js +72 -0
- package/dist/first-party/calls/signUp.js.map +1 -0
- package/dist/first-party/calls/twoStepSetup.d.ts +55 -0
- package/dist/first-party/calls/twoStepSetup.js +168 -0
- package/dist/first-party/calls/twoStepSetup.js.map +1 -0
- package/dist/first-party/claims.d.ts +88 -0
- package/dist/first-party/claims.js +181 -0
- package/dist/first-party/claims.js.map +1 -0
- package/dist/first-party/enrollment.d.ts +10 -0
- package/dist/first-party/enrollment.js +44 -0
- package/dist/first-party/enrollment.js.map +1 -0
- package/dist/first-party/entry.d.ts +549 -0
- package/dist/first-party/entry.js +580 -0
- package/dist/first-party/entry.js.map +1 -0
- package/dist/first-party/hooks.d.ts +66 -0
- package/dist/first-party/hooks.js +19 -0
- package/dist/first-party/hooks.js.map +1 -0
- package/dist/first-party/http.d.ts +191 -0
- package/dist/first-party/http.js +364 -0
- package/dist/first-party/http.js.map +1 -0
- package/dist/first-party/index.d.ts +14 -0
- package/dist/first-party/index.js +3 -0
- package/dist/first-party/index.js.map +1 -0
- package/dist/first-party/landed.d.ts +32 -0
- package/dist/first-party/landed.js +50 -0
- package/dist/first-party/landed.js.map +1 -0
- package/dist/first-party/landedProof.d.ts +12 -0
- package/dist/first-party/landedProof.js +20 -0
- package/dist/first-party/landedProof.js.map +1 -0
- package/dist/first-party/linkToken.d.ts +16 -0
- package/dist/first-party/linkToken.js +29 -0
- package/dist/first-party/linkToken.js.map +1 -0
- package/dist/first-party/links.d.ts +100 -0
- package/dist/first-party/links.js +84 -0
- package/dist/first-party/links.js.map +1 -0
- package/dist/first-party/locks.d.ts +36 -0
- package/dist/first-party/locks.js +64 -0
- package/dist/first-party/locks.js.map +1 -0
- package/dist/first-party/personTransport.d.ts +38 -0
- package/dist/first-party/personTransport.js +177 -0
- package/dist/first-party/personTransport.js.map +1 -0
- package/dist/first-party/proxy/app.d.ts +25 -0
- package/dist/first-party/proxy/app.js +94 -0
- package/dist/first-party/proxy/app.js.map +1 -0
- package/dist/first-party/proxy/bound.d.ts +5 -0
- package/dist/first-party/proxy/bound.js +13 -0
- package/dist/first-party/proxy/bound.js.map +1 -0
- package/dist/first-party/proxy/cases.d.ts +54 -0
- package/dist/first-party/proxy/cases.js +412 -0
- package/dist/first-party/proxy/cases.js.map +1 -0
- package/dist/first-party/proxy/decide.d.ts +29 -0
- package/dist/first-party/proxy/decide.js +140 -0
- package/dist/first-party/proxy/decide.js.map +1 -0
- package/dist/first-party/proxy/freeze.d.ts +2 -0
- package/dist/first-party/proxy/freeze.js +10 -0
- package/dist/first-party/proxy/freeze.js.map +1 -0
- package/dist/first-party/proxy/handler.d.ts +23 -0
- package/dist/first-party/proxy/handler.js +190 -0
- package/dist/first-party/proxy/handler.js.map +1 -0
- package/dist/first-party/proxy/headers.d.ts +8 -0
- package/dist/first-party/proxy/headers.js +20 -0
- package/dist/first-party/proxy/headers.js.map +1 -0
- package/dist/first-party/proxy/hop.d.ts +9 -0
- package/dist/first-party/proxy/hop.js +37 -0
- package/dist/first-party/proxy/hop.js.map +1 -0
- package/dist/first-party/proxy/host.d.ts +5 -0
- package/dist/first-party/proxy/host.js +11 -0
- package/dist/first-party/proxy/host.js.map +1 -0
- package/dist/first-party/proxy/index.d.ts +7 -0
- package/dist/first-party/proxy/index.js +6 -0
- package/dist/first-party/proxy/index.js.map +1 -0
- package/dist/first-party/proxy/pass-back.d.ts +21 -0
- package/dist/first-party/proxy/pass-back.js +51 -0
- package/dist/first-party/proxy/pass-back.js.map +1 -0
- package/dist/first-party/proxy/paths.d.ts +17 -0
- package/dist/first-party/proxy/paths.js +36 -0
- package/dist/first-party/proxy/paths.js.map +1 -0
- package/dist/first-party/proxy/shown.d.ts +5 -0
- package/dist/first-party/proxy/shown.js +16 -0
- package/dist/first-party/proxy/shown.js.map +1 -0
- package/dist/first-party/proxy/stand-in.d.ts +47 -0
- package/dist/first-party/proxy/stand-in.js +318 -0
- package/dist/first-party/proxy/stand-in.js.map +1 -0
- package/dist/first-party/report.d.ts +47 -0
- package/dist/first-party/report.js +38 -0
- package/dist/first-party/report.js.map +1 -0
- package/dist/first-party/result.d.ts +82 -0
- package/dist/first-party/result.js +40 -0
- package/dist/first-party/result.js.map +1 -0
- package/dist/first-party/session/cell.d.ts +177 -0
- package/dist/first-party/session/cell.js +89 -0
- package/dist/first-party/session/cell.js.map +1 -0
- package/dist/first-party/session/closed.d.ts +8 -0
- package/dist/first-party/session/closed.js +12 -0
- package/dist/first-party/session/closed.js.map +1 -0
- package/dist/first-party/session/index.d.ts +3 -0
- package/dist/first-party/session/index.js +3 -0
- package/dist/first-party/session/index.js.map +1 -0
- package/dist/first-party/session/logout.d.ts +82 -0
- package/dist/first-party/session/logout.js +328 -0
- package/dist/first-party/session/logout.js.map +1 -0
- package/dist/first-party/session/owed.d.ts +30 -0
- package/dist/first-party/session/owed.js +27 -0
- package/dist/first-party/session/owed.js.map +1 -0
- package/dist/first-party/session/refresh.d.ts +19 -0
- package/dist/first-party/session/refresh.js +229 -0
- package/dist/first-party/session/refresh.js.map +1 -0
- package/dist/first-party/session/results.d.ts +38 -0
- package/dist/first-party/session/results.js +74 -0
- package/dist/first-party/session/results.js.map +1 -0
- package/dist/first-party/session/session.d.ts +2 -0
- package/dist/first-party/session/session.js +379 -0
- package/dist/first-party/session/session.js.map +1 -0
- package/dist/first-party/session/shared.d.ts +34 -0
- package/dist/first-party/session/shared.js +104 -0
- package/dist/first-party/session/shared.js.map +1 -0
- package/dist/first-party/session/sharedSignal.d.ts +27 -0
- package/dist/first-party/session/sharedSignal.js +55 -0
- package/dist/first-party/session/sharedSignal.js.map +1 -0
- package/dist/first-party/session/signIn.d.ts +43 -0
- package/dist/first-party/session/signIn.js +294 -0
- package/dist/first-party/session/signIn.js.map +1 -0
- package/dist/first-party/session/signInThrough.d.ts +5 -0
- package/dist/first-party/session/signInThrough.js +95 -0
- package/dist/first-party/session/signInThrough.js.map +1 -0
- package/dist/first-party/session/sync.d.ts +17 -0
- package/dist/first-party/session/sync.js +143 -0
- package/dist/first-party/session/sync.js.map +1 -0
- package/dist/first-party/session/tokens.d.ts +18 -0
- package/dist/first-party/session/tokens.js +64 -0
- package/dist/first-party/session/tokens.js.map +1 -0
- package/dist/first-party/session/types.d.ts +270 -0
- package/dist/first-party/session/types.js +3 -0
- package/dist/first-party/session/types.js.map +1 -0
- package/dist/first-party/sessionWire.d.ts +31 -0
- package/dist/first-party/sessionWire.js +91 -0
- package/dist/first-party/sessionWire.js.map +1 -0
- package/dist/first-party/signInHooks.d.ts +57 -0
- package/dist/first-party/signInHooks.js +2 -0
- package/dist/first-party/signInHooks.js.map +1 -0
- package/dist/first-party/state.d.ts +51 -0
- package/dist/first-party/state.js +52 -0
- package/dist/first-party/state.js.map +1 -0
- package/dist/first-party/strip.d.ts +1 -0
- package/dist/first-party/strip.js +8 -0
- package/dist/first-party/strip.js.map +1 -0
- package/dist/first-party/twoStepLock.d.ts +26 -0
- package/dist/first-party/twoStepLock.js +58 -0
- package/dist/first-party/twoStepLock.js.map +1 -0
- package/dist/first-party/twoStepSession.d.ts +21 -0
- package/dist/first-party/twoStepSession.js +31 -0
- package/dist/first-party/twoStepSession.js.map +1 -0
- package/dist/first-party/wire.d.ts +63 -0
- package/dist/first-party/wire.js +5 -0
- package/dist/first-party/wire.js.map +1 -0
- package/dist/flipstream.d.ts +132 -36
- package/dist/flipstream.js +94 -47
- 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/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/session.js +9 -8
- 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 +53 -4
- package/docs/first-party.md +278 -0
- package/docs/node-sign-in.md +8 -4
- package/package.json +34 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Which session is current in this browser, shared by its tabs: the authority. The
|
|
4
|
+
* BroadcastChannel only makes changes quick (docs/architecture.md 2.3). It never holds a
|
|
5
|
+
* token.
|
|
6
|
+
*/
|
|
7
|
+
export const STATE_KEY = 'flipstream-auth:state';
|
|
8
|
+
/** No record at all: a new browser, or Local Storage cleared. Never "signed out" by itself: the cookie decides (§2.3). */
|
|
9
|
+
export const NO_RECORD = {
|
|
10
|
+
generation: 0,
|
|
11
|
+
signedIn: false,
|
|
12
|
+
serial: 0,
|
|
13
|
+
logoutPending: null,
|
|
14
|
+
principal: null,
|
|
15
|
+
person: null,
|
|
16
|
+
};
|
|
17
|
+
const Generation = z.int().min(0);
|
|
18
|
+
const StateSchema = z.object({
|
|
19
|
+
generation: Generation,
|
|
20
|
+
signedIn: z.boolean(),
|
|
21
|
+
serial: Generation,
|
|
22
|
+
logoutPending: z.object({ generation: Generation }).nullable(),
|
|
23
|
+
// A record from before the fingerprint has none: nothing to compare, nothing assumed.
|
|
24
|
+
principal: z.string().nullable().default(null),
|
|
25
|
+
person: z.string().nullable().default(null),
|
|
26
|
+
});
|
|
27
|
+
/** The record in storage, or NO_RECORD when there is none or it can't be read. */
|
|
28
|
+
export function readState(storage) {
|
|
29
|
+
const raw = storage.getItem(STATE_KEY);
|
|
30
|
+
if (raw === null)
|
|
31
|
+
return NO_RECORD;
|
|
32
|
+
let json;
|
|
33
|
+
try {
|
|
34
|
+
json = JSON.parse(raw);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return NO_RECORD;
|
|
38
|
+
}
|
|
39
|
+
const parsed = StateSchema.safeParse(json);
|
|
40
|
+
return parsed.success ? parsed.data : NO_RECORD;
|
|
41
|
+
}
|
|
42
|
+
/** Whether the browser took the write. */
|
|
43
|
+
export function writeState(storage, state) {
|
|
44
|
+
return storage.setItem(STATE_KEY, JSON.stringify(state));
|
|
45
|
+
}
|
|
46
|
+
/** The newer of two states: the higher generation, then the higher serial. */
|
|
47
|
+
export function newer(a, b) {
|
|
48
|
+
if (a.generation !== b.generation)
|
|
49
|
+
return a.generation > b.generation ? a : b;
|
|
50
|
+
return a.serial >= b.serial ? a : b;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/first-party/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,uBAAuB,CAAA;AAqChD,0HAA0H;AAC1H,MAAM,CAAC,MAAM,SAAS,GAAc;IAClC,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,aAAa,EAAE,IAAI;IACnB,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,IAAI;CACb,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAEjC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,UAAU,EAAE,UAAU;IACtB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;IACrB,MAAM,EAAE,UAAU;IAClB,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC9D,sFAAsF;IACtF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC9C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;CAC5C,CAAC,CAAA;AAEF,kFAAkF;AAClF,MAAM,UAAU,SAAS,CAAC,OAAoB;IAC5C,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACtC,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IAClC,IAAI,IAAa,CAAA;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACjD,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,KAAgB;IAC/D,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,KAAK,CAAC,CAAY,EAAE,CAAY;IAC9C,IAAI,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAAE,OAAO,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7E,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { strip } from './linkToken.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @flipstream/sdk/first-party/link-token (#465): what the app's boot module calls, before anything
|
|
2
|
+
// else is evaluated: `const cleaned = strip(location.href)`, then
|
|
3
|
+
// `if (cleaned !== null) history.replaceState(history.state, '', cleaned)`, which keeps the entry's
|
|
4
|
+
// state. The boot module holds only that, and the app's entry module imports it first.
|
|
5
|
+
// The same module the session reads (linkToken.ts), so the token it keeps is the one the session
|
|
6
|
+
// takes. Nothing else: no session, no network.
|
|
7
|
+
export { strip } from './linkToken.js';
|
|
8
|
+
//# sourceMappingURL=strip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../../src/first-party/strip.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,kEAAkE;AAClE,oGAAoG;AACpG,uFAAuF;AACvF,iGAAiG;AACjG,+CAA+C;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StorageLike } from './browser.js';
|
|
2
|
+
/** The address the code screen's link was asked for, from this browser's attempt. */
|
|
3
|
+
export declare function attemptEmail(storage: StorageLike, attemptId: string, now: number): string | null;
|
|
4
|
+
/** The kept end for `email` while it is still ahead of `now`: null when there is none ahead. */
|
|
5
|
+
export declare function keptLockEnd(storage: StorageLike, email: string, now: number): number | null;
|
|
6
|
+
/**
|
|
7
|
+
* Keeps `end` for `email`, and drops the ends already past. A write the browser refuses keeps
|
|
8
|
+
* nothing: the next lock then counts its own five minutes, as it did before.
|
|
9
|
+
*/
|
|
10
|
+
export declare function keepLockEnd(storage: StorageLike, email: string, end: number, now: number): void;
|
|
11
|
+
/**
|
|
12
|
+
* Drops the kept end for `email`: pulse-auth counted a code as wrong, or took one, so its lock
|
|
13
|
+
* is over, and a later lock is a new one with its own five minutes. The kept end is only the
|
|
14
|
+
* latest the old lock could end, up to five minutes past the real end.
|
|
15
|
+
*/
|
|
16
|
+
export declare function forgetLockEnd(storage: StorageLike, email: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* How long pulse-auth refuses codes after the fifth wrong one in a row (`mfa.py`, LOCKOUT).
|
|
19
|
+
* Its answer says neither when the lock began nor when it ends, and the fifth wrong code is
|
|
20
|
+
* still answered as a wrong code: counted from the answer that says "locked", the end is
|
|
21
|
+
* the latest it can be. Up to the whole minute, as people read it: the minute shown is never
|
|
22
|
+
* before the lock ends.
|
|
23
|
+
*/
|
|
24
|
+
export declare const TWO_STEP_LOCKOUT_MS: number;
|
|
25
|
+
export declare const MINUTE_MS = 60000;
|
|
26
|
+
export declare function firstLockEnd(answeredAt: number): number;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { findAttempt } from './attempts.js';
|
|
2
|
+
import { normalizeEmail } from './claims.js';
|
|
3
|
+
/*
|
|
4
|
+
* The end of a two-step lock this browser was told about, per address (Michel, 17 Oct).
|
|
5
|
+
* pulse-auth's lock isn't moved by a code tried during it (`mfa.py`: `_check_lock` refuses
|
|
6
|
+
* before anything is counted), so an end still ahead stays the end, and a new link must not
|
|
7
|
+
* start the five minutes over. An address and a time only: never a token or a code.
|
|
8
|
+
*/
|
|
9
|
+
const PREFIX = 'flipstream-auth:two-step-lock:';
|
|
10
|
+
const END = /^\d{13}$/;
|
|
11
|
+
/** The address the code screen's link was asked for, from this browser's attempt. */
|
|
12
|
+
export function attemptEmail(storage, attemptId, now) {
|
|
13
|
+
const lookup = findAttempt(storage, attemptId, now);
|
|
14
|
+
return lookup.kind === 'missing' ? null : normalizeEmail(lookup.attempt.email);
|
|
15
|
+
}
|
|
16
|
+
/** The kept end for `email` while it is still ahead of `now`: null when there is none ahead. */
|
|
17
|
+
export function keptLockEnd(storage, email, now) {
|
|
18
|
+
const end = endOf(storage.getItem(PREFIX + email));
|
|
19
|
+
return end !== null && end > now ? end : null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Keeps `end` for `email`, and drops the ends already past. A write the browser refuses keeps
|
|
23
|
+
* nothing: the next lock then counts its own five minutes, as it did before.
|
|
24
|
+
*/
|
|
25
|
+
export function keepLockEnd(storage, email, end, now) {
|
|
26
|
+
for (const key of storage.keys()) {
|
|
27
|
+
if (!key.startsWith(PREFIX))
|
|
28
|
+
continue;
|
|
29
|
+
const kept = endOf(storage.getItem(key));
|
|
30
|
+
if (kept === null || kept <= now)
|
|
31
|
+
storage.removeItem(key);
|
|
32
|
+
}
|
|
33
|
+
storage.setItem(PREFIX + email, String(end));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Drops the kept end for `email`: pulse-auth counted a code as wrong, or took one, so its lock
|
|
37
|
+
* is over, and a later lock is a new one with its own five minutes. The kept end is only the
|
|
38
|
+
* latest the old lock could end, up to five minutes past the real end.
|
|
39
|
+
*/
|
|
40
|
+
export function forgetLockEnd(storage, email) {
|
|
41
|
+
storage.removeItem(PREFIX + email);
|
|
42
|
+
}
|
|
43
|
+
function endOf(value) {
|
|
44
|
+
return value !== null && END.test(value) ? Number(value) : null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* How long pulse-auth refuses codes after the fifth wrong one in a row (`mfa.py`, LOCKOUT).
|
|
48
|
+
* Its answer says neither when the lock began nor when it ends, and the fifth wrong code is
|
|
49
|
+
* still answered as a wrong code: counted from the answer that says "locked", the end is
|
|
50
|
+
* the latest it can be. Up to the whole minute, as people read it: the minute shown is never
|
|
51
|
+
* before the lock ends.
|
|
52
|
+
*/
|
|
53
|
+
export const TWO_STEP_LOCKOUT_MS = 5 * 60_000;
|
|
54
|
+
export const MINUTE_MS = 60_000;
|
|
55
|
+
export function firstLockEnd(answeredAt) {
|
|
56
|
+
return Math.ceil((answeredAt + TWO_STEP_LOCKOUT_MS) / MINUTE_MS) * MINUTE_MS;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=twoStepLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twoStepLock.js","sourceRoot":"","sources":["../../src/first-party/twoStepLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;GAKG;AAEH,MAAM,MAAM,GAAG,gCAAgC,CAAA;AAC/C,MAAM,GAAG,GAAG,UAAU,CAAA;AAEtB,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAC1B,OAAoB,EACpB,SAAiB,EACjB,GAAW;IAEX,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,CAAA;IACnD,OAAO,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAChF,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,WAAW,CACzB,OAAoB,EACpB,KAAa,EACb,GAAW;IAEX,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAA;IAClD,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,OAAoB,EACpB,KAAa,EACb,GAAW,EACX,GAAW;IAEX,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,SAAQ;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;QACxC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG;YAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAAoB,EAAE,KAAa;IAC/D,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,KAAK,CAAC,KAAoB;IACjC,OAAO,KAAK,KAAK,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,MAAM,CAAA;AAC7C,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAA;AAE/B,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,GAAG,mBAAmB,CAAC,GAAG,SAAS,CAAC,GAAG,SAAS,CAAA;AAC9E,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StorageLike } from './browser.js';
|
|
2
|
+
import type { AuthSession } from './session/types.js';
|
|
3
|
+
import type { Wire } from './wire.js';
|
|
4
|
+
type Session = Pick<AuthSession, 'current' | 'isCurrent' | 'signInSetupChallenge' | 'canDeliverCodes'>;
|
|
5
|
+
export declare function setupHooks(session: Session, storage: StorageLike | null): {
|
|
6
|
+
setupRevision(): number | null;
|
|
7
|
+
signInSetupChallenge: (setup: import("./hooks.js").SignInSetup) => {
|
|
8
|
+
readonly kind: "pending";
|
|
9
|
+
readonly challenge: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: "expired" | "superseded";
|
|
12
|
+
};
|
|
13
|
+
codeRecipient(): () => boolean;
|
|
14
|
+
addressLock(): {
|
|
15
|
+
keptLockEnd: (now: number) => number | null;
|
|
16
|
+
keepLockEnd: (end: number, now: number) => void;
|
|
17
|
+
forgetLockEnd: () => void;
|
|
18
|
+
} | null;
|
|
19
|
+
};
|
|
20
|
+
export declare function twoStepForSession(wire: Wire, session: Session, storage: StorageLike | null): import("./calls/twoStepSetup.js").TwoStepSetupCalls;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createTwoStepSetupCalls } from './calls/twoStepSetup.js';
|
|
2
|
+
import { normalizeEmail } from './claims.js';
|
|
3
|
+
import { keptLockEnd, keepLockEnd, forgetLockEnd } from './twoStepLock.js';
|
|
4
|
+
export function setupHooks(session, storage) {
|
|
5
|
+
return {
|
|
6
|
+
setupRevision() {
|
|
7
|
+
const current = session.current();
|
|
8
|
+
return current.status === 'signed-in' && session.isCurrent(current.revision) ? current.revision : null;
|
|
9
|
+
},
|
|
10
|
+
signInSetupChallenge: session.signInSetupChallenge,
|
|
11
|
+
codeRecipient() {
|
|
12
|
+
const pressed = session.current();
|
|
13
|
+
return () => pressed.status === 'signed-in' && session.canDeliverCodes(pressed.principal.userId);
|
|
14
|
+
},
|
|
15
|
+
addressLock() {
|
|
16
|
+
const current = session.current();
|
|
17
|
+
if (storage === null || current.status !== 'signed-in' || !session.isCurrent(current.revision))
|
|
18
|
+
return null;
|
|
19
|
+
const email = normalizeEmail(current.principal.email);
|
|
20
|
+
return {
|
|
21
|
+
keptLockEnd: (now) => keptLockEnd(storage, email, now),
|
|
22
|
+
keepLockEnd: (end, now) => keepLockEnd(storage, email, end, now),
|
|
23
|
+
forgetLockEnd: () => forgetLockEnd(storage, email),
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function twoStepForSession(wire, session, storage) {
|
|
29
|
+
return createTwoStepSetupCalls(wire, setupHooks(session, storage));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=twoStepSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twoStepSession.js","sourceRoot":"","sources":["../../src/first-party/twoStepSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAK1E,MAAM,UAAU,UAAU,CAAC,OAAgB,EAAE,OAA2B;IACtE,OAAO;QACL,aAAa;YACX,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;YACjC,OAAO,OAAO,CAAC,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;QACxG,CAAC;QACD,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,aAAa;YACX,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;YACjC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAClG,CAAC;QACD,WAAW;YACT,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;YACjC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAA;YAC3G,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;YACrD,OAAO;gBACL,WAAW,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;gBAC9D,WAAW,EAAE,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC;gBAChF,aAAa,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;aACnD,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAU,EAAE,OAAgB,EAAE,OAA2B;IACzF,OAAO,uBAAuB,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CallOptions } from './result.js';
|
|
2
|
+
export interface WireRequest {
|
|
3
|
+
readonly method: 'GET' | 'POST';
|
|
4
|
+
/** The server's own path, starting with '/': '/oauth/device/verify'. Never a full URL. */
|
|
5
|
+
readonly path: string;
|
|
6
|
+
/** Query pairs. The wire encodes them. */
|
|
7
|
+
readonly query?: Readonly<Record<string, string>>;
|
|
8
|
+
/** Sent as JSON. A POST without one sends `{}`, as the session's own calls do. */
|
|
9
|
+
readonly body?: Readonly<Record<string, unknown>>;
|
|
10
|
+
}
|
|
11
|
+
/** A server answered. `body`: the parsed JSON, or `undefined` when the answer isn't JSON. */
|
|
12
|
+
export interface WireAnswer {
|
|
13
|
+
readonly kind: 'answer';
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly body: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** No answer to read. */
|
|
18
|
+
export type WireStop =
|
|
19
|
+
/** Nothing came back in time: offline, a failed connection, the call's own time limit. */
|
|
20
|
+
{
|
|
21
|
+
readonly kind: 'unavailable';
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'aborted';
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Every request the wire sends says `Accept: application/json`, and a body goes as
|
|
27
|
+
* `Content-Type: application/json`. So a family never sets a header.
|
|
28
|
+
*
|
|
29
|
+
* There is no way through the app's /auth proxy here (the lead, 2 Dec, on #465): every path it forwards
|
|
30
|
+
* sets or reads the session's cookie and answers a token the session must adopt, so a family
|
|
31
|
+
* goes through it only by the session's `signInThrough` (part 3), never raw.
|
|
32
|
+
*/
|
|
33
|
+
export interface Wire {
|
|
34
|
+
/** Straight to a host, with no cookie and no token (`credentials: 'omit'`). */
|
|
35
|
+
readonly open: (host: 'auth' | 'admin', request: WireRequest, options: CallOptions | undefined) => Promise<WireAnswer | WireStop>;
|
|
36
|
+
/**
|
|
37
|
+
* Straight to pulse-auth as the signed-in person. Nobody signed in: `signed_out`, with nothing
|
|
38
|
+
* sent. A 401 renews the token once and sends again; refused again: `signed_out`.
|
|
39
|
+
*/
|
|
40
|
+
readonly asPerson: (request: WireRequest, options: CallOptions | undefined,
|
|
41
|
+
/** Enrollment observes its dispatch. Calls issuing backup codes keep the sent answer across a caller abort. */
|
|
42
|
+
dispatch?: {
|
|
43
|
+
readonly onSend: () => void;
|
|
44
|
+
/** An anonymous approval can be a checked 200. Renew it once like a 401. */
|
|
45
|
+
readonly isUnauthorized?: (answer: WireAnswer) => boolean;
|
|
46
|
+
} | 'keep_sent_answer',
|
|
47
|
+
/** For successful keep_sent_answer responses only, including after the body has been read. */
|
|
48
|
+
canDeliver?: () => boolean) => Promise<WireAnswer | WireStop | {
|
|
49
|
+
readonly kind: 'signed_out';
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* An answer outside the contract: the path and the status, never a body. The family calls this
|
|
53
|
+
* once per call. `open` does not report a redirect (SDK-D1962).
|
|
54
|
+
*/
|
|
55
|
+
readonly report: (answer: {
|
|
56
|
+
readonly path: string;
|
|
57
|
+
readonly status: number;
|
|
58
|
+
}) => void;
|
|
59
|
+
/** The clock, epoch ms. A family never reads `Date`: the lint refuses it. */
|
|
60
|
+
readonly now: () => number;
|
|
61
|
+
}
|
|
62
|
+
/** A 5xx, or a 429. A family asks this only after its own rules for that status. */
|
|
63
|
+
export declare function isUnavailable(answer: WireAnswer): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/first-party/wire.ts"],"names":[],"mappings":"AAoEA,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC9C,OAAO,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,IAAI,GAAG,CAAA;AACtD,CAAC"}
|
package/dist/flipstream.d.ts
CHANGED
|
@@ -6,9 +6,12 @@ import { type Member } from './api/members.js';
|
|
|
6
6
|
import type { Page, PageRequest } from './api/page.js';
|
|
7
7
|
import { type Balance, type Ledger } from './api/wallet.js';
|
|
8
8
|
import { type Workspace } from './api/workspaces.js';
|
|
9
|
+
import { type SharedReads } from './core/shared.js';
|
|
9
10
|
import { type TokenAsk } from './core/fetch.js';
|
|
11
|
+
import { DEFAULT_HOSTS } from './core/hosts.js';
|
|
12
|
+
import { type Trace } from './core/identify.js';
|
|
10
13
|
import type { ApiResult } from './core/result.js';
|
|
11
|
-
import type { ServiceName, Transport } from './core/transport.js';
|
|
14
|
+
import type { ApiRequest, ServiceName, Transport } from './core/transport.js';
|
|
12
15
|
import { type Health } from './query/health.js';
|
|
13
16
|
import { type QueryRequest } from './query/query.js';
|
|
14
17
|
import type { Catalog, CatalogSource, QueryResponse } from './spec/query-planner/types.gen.js';
|
|
@@ -127,6 +130,27 @@ declare global {
|
|
|
127
130
|
readonly asyncDispose: unique symbol;
|
|
128
131
|
}
|
|
129
132
|
}
|
|
133
|
+
/** How a scope is made (#409, D579): `flipstream.scope(options)` and `withScope(run, options)`. */
|
|
134
|
+
export interface ScopeOptions {
|
|
135
|
+
/**
|
|
136
|
+
* The caller's own W3C trace context, for the scope's shared reads, as a call's `traceparent` is
|
|
137
|
+
* for its own requests: each shared read goes out under its trace-id and flags, with a parent-id of
|
|
138
|
+
* its own for each attempt. So one piece of work, such as a CLI command, is one trace.
|
|
139
|
+
* - **A call names the request that answered it** as its `trace_id` (#376): a shared read's whose
|
|
140
|
+
* failure is its answer, else its own requests', else the first shared read it asked for. So a
|
|
141
|
+
* call answered by shared reads alone, such as `me()`, names the scope's trace-id, even when it
|
|
142
|
+
* was given a `traceparent` of its own.
|
|
143
|
+
* - **Only where the SDK sends a trace:** Node's requests to the admin host, your organisation's
|
|
144
|
+
* and a workspace's own reads. The sign-in server, where your person is read, never gets one
|
|
145
|
+
* (#192), and from a browser the admin host gets none yet (#380), so there the option changes
|
|
146
|
+
* nothing.
|
|
147
|
+
* - **One that isn't a valid version-00 traceparent,** a value that isn't a string included, is
|
|
148
|
+
* dropped, as a call's is, and the shared reads keep traces of their own.
|
|
149
|
+
* - It never reaches a call's own requests, and a call's own `traceparent` never reaches a shared
|
|
150
|
+
* read.
|
|
151
|
+
*/
|
|
152
|
+
readonly traceparent?: string;
|
|
153
|
+
}
|
|
130
154
|
/**
|
|
131
155
|
* One piece of work's shared reads (#376, D573): a route's load in the console, a command in the
|
|
132
156
|
* CLI. Made by `flipstream.scope()`, taken by each call as `{ scope }`, and ended by `close()`, or
|
|
@@ -153,6 +177,13 @@ export interface Flipstream {
|
|
|
153
177
|
readonly source: string;
|
|
154
178
|
}, options?: CallOptions): Promise<ApiResult<CatalogSource>>;
|
|
155
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* A query's answer. Every row, and its totals, are keyed by the dimensions and metrics asked for,
|
|
182
|
+
* and only those: any other key makes the answer `invalid`, so it never reaches you as data. The
|
|
183
|
+
* error names at most five of the keys, each shaped like a field name, and counts the rest, never
|
|
184
|
+
* a value (#237). A query that asks for no dimension and no metric is `refused`, with `reason`
|
|
185
|
+
* `nothing_asked`, and nothing is sent: no answer to it could pass that check.
|
|
186
|
+
*/
|
|
156
187
|
query(request: QueryRequest, options?: CallOptions): Promise<ApiResult<QueryResponse>>;
|
|
157
188
|
/**
|
|
158
189
|
* Whether the planner answers, signed out: `GET /health` with no token. It goes through neither
|
|
@@ -190,7 +221,8 @@ export interface Flipstream {
|
|
|
190
221
|
* first, for its id, and a call under one workspace reads you beside it, all under one deadline
|
|
191
222
|
* (the call's, or 30 s); the first failure is the answer. A workspace of another organisation is
|
|
192
223
|
* `invalid`, never dropped or shown. A call under one workspace answers `not_found` for one you
|
|
193
|
-
* don't open, as for one nobody has
|
|
224
|
+
* don't open, as for one nobody has, and so does one for a workspace whose own read pulse-admin
|
|
225
|
+
* refuses (D578): see "The workspaces you open" in docs/admin.md (#372).
|
|
194
226
|
*/
|
|
195
227
|
readonly workspaces: {
|
|
196
228
|
/**
|
|
@@ -208,7 +240,8 @@ export interface Flipstream {
|
|
|
208
240
|
/**
|
|
209
241
|
* One workspace, by its id. An id that can't stay one path segment is `refused` (`path`), with
|
|
210
242
|
* nothing sent. Your organisation and you are read first, so one you don't open is `not_found`,
|
|
211
|
-
* exactly as one nobody has, with nothing under it read.
|
|
243
|
+
* exactly as one nobody has, with nothing under it read. One whose own read pulse-admin refuses,
|
|
244
|
+
* its own 403 (`FORBIDDEN_EXCEPTION`), is `not_found` too, as one nobody has (D578).
|
|
212
245
|
*/
|
|
213
246
|
get(request: {
|
|
214
247
|
readonly workspace_id: string;
|
|
@@ -231,8 +264,8 @@ export interface Flipstream {
|
|
|
231
264
|
/**
|
|
232
265
|
* A rename is a person's, in the console (D542): it answers `needs_person`, with why and, where
|
|
233
266
|
* the console can be named, the workspace's settings page. It never writes, and the name isn't
|
|
234
|
-
* sent: the person types it there. A workspace that isn't yours,
|
|
235
|
-
* `not_found`, never handed off.
|
|
267
|
+
* sent: the person types it there. A workspace that isn't yours, that you don't open, or whose
|
|
268
|
+
* read pulse-admin refuses (D578), is `not_found`, never handed off.
|
|
236
269
|
*/
|
|
237
270
|
rename(request: {
|
|
238
271
|
readonly workspace_id: string;
|
|
@@ -249,8 +282,9 @@ export interface Flipstream {
|
|
|
249
282
|
/**
|
|
250
283
|
* The logbook (#218, #295), on the admin host: a workspace's notes on time ranges, and one
|
|
251
284
|
* member's entries across your organisation's workspaces. A call under one workspace answers
|
|
252
|
-
* `not_found` for one you don't open, as for one nobody has
|
|
253
|
-
* docs/admin.md
|
|
285
|
+
* `not_found` for one you don't open, as for one nobody has, and so does one for a workspace or an
|
|
286
|
+
* entry whose own read pulse-admin refuses (D578): see "The workspaces you open" in docs/admin.md
|
|
287
|
+
* (#372).
|
|
254
288
|
*/
|
|
255
289
|
readonly log: {
|
|
256
290
|
/**
|
|
@@ -264,7 +298,8 @@ export interface Flipstream {
|
|
|
264
298
|
* or removed in between, and entries written at the same moment have no fixed order among
|
|
265
299
|
* themselves. A changed `total` shows that something was added or removed; an unchanged one
|
|
266
300
|
* doesn't prove nothing was. Your organisation and you are read first, then the workspace
|
|
267
|
-
* beside the list (#249, #372), under one deadline: one nobody has,
|
|
301
|
+
* beside the list (#249, #372), under one deadline: one nobody has, one you don't open, or one
|
|
302
|
+
* whose read pulse-admin refuses (D578), is
|
|
268
303
|
* `not_found`, and another organisation's is `invalid`, never an empty page. An entry of
|
|
269
304
|
* another workspace or organisation makes the answer `invalid`, never dropped. A limit or
|
|
270
305
|
* offset that isn't a whole number in range rejects, with nothing sent, as every list's does.
|
|
@@ -281,7 +316,8 @@ export interface Flipstream {
|
|
|
281
316
|
* One entry, by its id, read beside your organisation and you (#249, #372); `not_found` when
|
|
282
317
|
* there's none, or it's in a workspace you don't open, and `invalid` when the answer is another
|
|
283
318
|
* entry, or another organisation's. A failure of the entry's own read is the backend's, as it
|
|
284
|
-
* answered
|
|
319
|
+
* answered, but pulse-admin's own refusal (its 403, `FORBIDDEN_EXCEPTION`): that says the entry
|
|
320
|
+
* exists, so it's `not_found`, as one nobody has (D578).
|
|
285
321
|
*/
|
|
286
322
|
get(request: {
|
|
287
323
|
readonly log_id: string;
|
|
@@ -291,8 +327,9 @@ export interface Flipstream {
|
|
|
291
327
|
* `refused` (`fields`, naming them), and a description that isn't a non-blank string, a time
|
|
292
328
|
* not written as `2026-10-05T00:00:00Z` (a fraction may follow the seconds, and an offset such
|
|
293
329
|
* as `+02:00`, or none, may take the place of the `Z`), or a start after the end rejects with a
|
|
294
|
-
* TypeError. Your organisation and you are read first, then the workspace: one nobody has,
|
|
295
|
-
*
|
|
330
|
+
* TypeError. Your organisation and you are read first, then the workspace: one nobody has, one
|
|
331
|
+
* you don't open, or one whose read pulse-admin refuses (D578), is `not_found`, and another
|
|
332
|
+
* organisation's `invalid`, with nothing
|
|
296
333
|
* written. Times go as UTC instants; one with no offset is
|
|
297
334
|
* read as UTC. Who may write is the backend's rule, not the SDK's: Owners, Admins and Editors
|
|
298
335
|
* add; an Editor changes or removes only their own entries, and Owners and Admins any. Until the
|
|
@@ -330,9 +367,11 @@ export interface Flipstream {
|
|
|
330
367
|
* dataset of another organisation is
|
|
331
368
|
* `invalid`, never dropped or shown. The backend's answers embed each dataset's sign-in, so a
|
|
332
369
|
* body that isn't its JSON is never kept: a failure of the dataset's own read or write has no
|
|
333
|
-
* `text` (#279). The organisation's and the workspace's reads keep theirs
|
|
334
|
-
*
|
|
335
|
-
*
|
|
370
|
+
* `text` (#279). The organisation's and the workspace's reads keep theirs, but pulse-admin's own
|
|
371
|
+
* refusal of the workspace's read, which is `not_found`. A call under one workspace answers
|
|
372
|
+
* `not_found` for one you don't open, as for one nobody has, and so does one for a workspace or a
|
|
373
|
+
* dataset whose own read pulse-admin refuses (D578): see "The workspaces you open" in
|
|
374
|
+
* docs/admin.md (#372).
|
|
336
375
|
*/
|
|
337
376
|
readonly datasets: {
|
|
338
377
|
/**
|
|
@@ -342,8 +381,9 @@ export interface Flipstream {
|
|
|
342
381
|
* can overlap or skip a dataset when datasets are added, removed or renamed in between, or when
|
|
343
382
|
* two share a name. A changed `total` shows some of that; an unchanged one doesn't prove none
|
|
344
383
|
* happened. For a complete, stable list, read it in one page, of up to 1,000. A dataset of
|
|
345
|
-
* another workspace makes the answer `invalid`, never dropped. A workspace nobody has,
|
|
346
|
-
*
|
|
384
|
+
* another workspace makes the answer `invalid`, never dropped. A workspace nobody has, one you
|
|
385
|
+
* don't open, or one whose read pulse-admin refuses (D578), is `not_found`, and another
|
|
386
|
+
* organisation's is `invalid`, never an empty page.
|
|
347
387
|
*
|
|
348
388
|
* `{ organization: true }` instead of a workspace (#342): your organisation's datasets, in every
|
|
349
389
|
* workspace you open, paged and ordered as a workspace's are. Exactly one of `workspace_id` and
|
|
@@ -363,7 +403,8 @@ export interface Flipstream {
|
|
|
363
403
|
* workspace and organisation are read, so one `list` would refuse for anything else can't lose
|
|
364
404
|
* the count, while one of another workspace or organisation, or a page whose count is smaller
|
|
365
405
|
* than it or above 0 with no dataset on it, is `invalid`. The workspace is read beside it, by
|
|
366
|
-
* `list`'s rules for it: a workspace nobody has,
|
|
406
|
+
* `list`'s rules for it: a workspace nobody has, one you don't open, or one whose read
|
|
407
|
+
* pulse-admin refuses (D578), is `not_found`, and
|
|
367
408
|
* another organisation's `invalid`, never a count of 0. The organisation's failure, then yours,
|
|
368
409
|
* then the workspace's, then the count's, is the answer. A `workspace_id` that isn't a string
|
|
369
410
|
* rejects with a TypeError, with nothing sent. A count across your organisation isn't here yet.
|
|
@@ -376,7 +417,9 @@ export interface Flipstream {
|
|
|
376
417
|
/**
|
|
377
418
|
* One dataset, by its id, read beside your organisation and you; `not_found` when there's none,
|
|
378
419
|
* or it's in a workspace you don't open, and `invalid` when the answer is another dataset. A
|
|
379
|
-
* failure of the dataset's own read is the backend's, as it answered
|
|
420
|
+
* failure of the dataset's own read is the backend's, as it answered, but pulse-admin's own
|
|
421
|
+
* refusal (its 403, `FORBIDDEN_EXCEPTION`): that says the dataset exists, so it's `not_found`,
|
|
422
|
+
* as one nobody has (D578).
|
|
380
423
|
*/
|
|
381
424
|
get(request: {
|
|
382
425
|
readonly dataset_id: string;
|
|
@@ -386,7 +429,8 @@ export interface Flipstream {
|
|
|
386
429
|
* sends the same write and answers the same. Before anything is sent, a key other than
|
|
387
430
|
* `dataset_id` is `refused` (`fields`, naming them), and an id that isn't a string rejects with
|
|
388
431
|
* a TypeError. The dataset is read first, fresh, beside your organisation and you: one nobody
|
|
389
|
-
* has,
|
|
432
|
+
* has, one in a workspace you don't open, or one whose read pulse-admin refuses (D578), is
|
|
433
|
+
* `not_found`, and another organisation's
|
|
390
434
|
* `invalid`, with nothing written. Then `active` alone is sent, so a rename made meanwhile
|
|
391
435
|
* stays. The dataset is read fresh again after the write, and the answer is that read: one
|
|
392
436
|
* whose `active` isn't the one asked for is `invalid`, since the write may not have been
|
|
@@ -407,7 +451,8 @@ export interface Flipstream {
|
|
|
407
451
|
/**
|
|
408
452
|
* Deleting a dataset is a person's to do, in the console (D542, D546): it removes the dataset's
|
|
409
453
|
* data for good, and the console can't delete one yet. Never a write: it reads the dataset (one
|
|
410
|
-
* nobody has,
|
|
454
|
+
* nobody has, one in a workspace you don't open, or one whose read pulse-admin refuses (D578), is
|
|
455
|
+
* `not_found`, and another organisation's
|
|
411
456
|
* `invalid`), then answers `needs_person` with `why`, and the dataset's page as `url`, with
|
|
412
457
|
* what it shows as `sees`, where a console can be named.
|
|
413
458
|
*/
|
|
@@ -507,6 +552,16 @@ export interface Flipstream {
|
|
|
507
552
|
get(request: {
|
|
508
553
|
readonly member_id: string;
|
|
509
554
|
}, options?: CallOptions): Promise<ApiResult<Member>>;
|
|
555
|
+
/**
|
|
556
|
+
* Removing someone from your organisation is a person's to do, in the console (D542): it can't
|
|
557
|
+
* be undone. Never a write: it reads the person by `get`'s rules (one there's no such person
|
|
558
|
+
* for you, such as an API key, is `not_found`, a read pulse-auth refuses is `forbidden`, and
|
|
559
|
+
* another organisation's is `invalid`), then answers `needs_person` with `why`, and the
|
|
560
|
+
* person's page as `url`, with what it shows as `sees`, where a console can be named.
|
|
561
|
+
*/
|
|
562
|
+
remove(request: {
|
|
563
|
+
readonly member_id: string;
|
|
564
|
+
}, options?: CallOptions): Promise<ApiResult<never>>;
|
|
510
565
|
};
|
|
511
566
|
/**
|
|
512
567
|
* A scope for one piece of work, such as a page's load or a command (#376, D573): every call that
|
|
@@ -516,9 +571,11 @@ export interface Flipstream {
|
|
|
516
571
|
* - They're read from the backend at the first call that needs them, and every later call reuses
|
|
517
572
|
* that read, still on its way or answered. Nothing is taken on your word.
|
|
518
573
|
* - A shared read is the starting call's own read, its deadline and retries, under a trace of its
|
|
519
|
-
* own,
|
|
520
|
-
*
|
|
521
|
-
*
|
|
574
|
+
* own, or the scope's `traceparent`'s trace when it's given one (`ScopeOptions`, #409), and every
|
|
575
|
+
* call it answers names that trace. A call's own `traceparent` never reaches it. Each call keeps
|
|
576
|
+
* its own `deadlineMs` and signal: they end that call's wait, never the read, and a call still
|
|
577
|
+
* waiting when the read times out at its starter's deadline reads again. A read no call waits on
|
|
578
|
+
* any more is ended.
|
|
522
579
|
* - A definitive failure (`forbidden`, `not_found`, `conflict`, `refused`, `rejected` but a 408 or
|
|
523
580
|
* 425, and `invalid` but a 2xx whose body isn't JSON or a status outside the contract) is every
|
|
524
581
|
* later call's answer too, as its own copy, with no new read. A transient one is the answer of
|
|
@@ -529,27 +586,64 @@ export interface Flipstream {
|
|
|
529
586
|
* - Close it when the work is done (`close()`, or `await using`). It keeps each answer until then:
|
|
530
587
|
* it's one piece of work, never a session. Nothing is kept past it.
|
|
531
588
|
*/
|
|
532
|
-
scope(): Scope;
|
|
589
|
+
scope(options?: ScopeOptions): Scope;
|
|
533
590
|
/**
|
|
534
|
-
* `scope()` for the length of `run`: `run` gets the client with every call in the scope, and
|
|
535
|
-
* scope is closed when `run` settles, so it can't be left open. `run`'s answer is
|
|
536
|
-
* and so is its rejection.
|
|
591
|
+
* `scope(options)` for the length of `run`: `run` gets the client with every call in the scope, and
|
|
592
|
+
* the scope is closed when `run` settles, so it can't be left open. `run`'s answer is
|
|
593
|
+
* `withScope`'s, and so is its rejection.
|
|
537
594
|
*/
|
|
538
|
-
withScope<T>(run: (flipstream: ScopedFlipstream) => Promise<T
|
|
595
|
+
withScope<T>(run: (flipstream: ScopedFlipstream) => Promise<T>, options?: ScopeOptions): Promise<T>;
|
|
539
596
|
}
|
|
540
597
|
/** The client inside `withScope`: every call in its scope, and no scope of its own (#376). */
|
|
541
598
|
export type ScopedFlipstream = Omit<Flipstream, 'scope' | 'withScope'>;
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
599
|
+
export { DEFAULT_HOSTS };
|
|
600
|
+
/**
|
|
601
|
+
* One SDK call's trace (#251): every request the call makes carries it, each with its own parent-id,
|
|
602
|
+
* and `sent` turns true once one of them goes out, so the call's result can name it.
|
|
603
|
+
*/
|
|
604
|
+
interface CallTrace {
|
|
605
|
+
readonly trace: Trace;
|
|
606
|
+
sent: boolean;
|
|
607
|
+
/** True once the call has answered: a request built after that is never looked for. */
|
|
608
|
+
ended: boolean;
|
|
609
|
+
/** The traceparent each of its requests carried, so they're forgotten when the call ends. */
|
|
610
|
+
readonly traceparents: string[];
|
|
611
|
+
/** The shared reads that answered it in a scope (#376), each under its own trace, in the order it asked. */
|
|
612
|
+
readonly shared: CallTrace[];
|
|
613
|
+
}
|
|
549
614
|
/** The hosts a client takes as Flipstream's own deployment, whatever it was configured with. */
|
|
550
615
|
export type DeployedHosts = {
|
|
551
616
|
readonly [Service in keyof typeof DEFAULT_HOSTS]: string;
|
|
552
617
|
};
|
|
618
|
+
/**
|
|
619
|
+
* A scope this client made (#376): its shared reads, and the trace each one goes out under
|
|
620
|
+
* (`readTrace`): the scope's, when it was given a valid traceparent (#409, D579), else one of its
|
|
621
|
+
* own, never a call's, since it serves several (#377's code review, 3).
|
|
622
|
+
*/
|
|
623
|
+
interface ScopeState {
|
|
624
|
+
readonly owner: (() => boolean) | undefined;
|
|
625
|
+
readonly shared: SharedReads<CallTrace>;
|
|
626
|
+
readonly readTrace: () => CallTrace;
|
|
627
|
+
}
|
|
628
|
+
/** What the browser session contributes to a main client made for its displayed person. */
|
|
629
|
+
export interface PersonClientSession {
|
|
630
|
+
/** Freezes the client and method groups handed to a withScope callback. */
|
|
631
|
+
readonly freezeScoped: (client: ScopedFlipstream) => ScopedFlipstream;
|
|
632
|
+
/** All scopes created by clients of this session, so an older scope can be recognised. */
|
|
633
|
+
readonly scopes: WeakMap<Scope, ScopeState>;
|
|
634
|
+
/** The answer boundary checks that this client still represents the displayed person. */
|
|
635
|
+
readonly current: () => boolean;
|
|
636
|
+
/** Admission pins the displayed person and rejects a closed session in the call's name. */
|
|
637
|
+
readonly admit: (call: string) => void;
|
|
638
|
+
/** A health call already admitted uses this to avoid a new send after close. */
|
|
639
|
+
readonly isClosed: () => boolean;
|
|
640
|
+
/** The page's network edge, traced for bearer and tokenless requests alike. */
|
|
641
|
+
readonly fetch: typeof fetch;
|
|
642
|
+
/** The session reports a manual redirect on a tokenless health request. */
|
|
643
|
+
readonly healthResponse: (status: number) => void;
|
|
644
|
+
/** Health accepts loopback HTTP when the session's configured service hosts do. */
|
|
645
|
+
readonly allowLocalhostHttp?: boolean | undefined;
|
|
646
|
+
}
|
|
553
647
|
/** The SDK, for one caller (D421): the console with its transport, or anyone with a token function. */
|
|
554
648
|
export declare function createFlipstream(options: FlipstreamOptions): Flipstream;
|
|
555
649
|
/**
|
|
@@ -558,4 +652,6 @@ export declare function createFlipstream(options: FlipstreamOptions): Flipstream
|
|
|
558
652
|
* cases (scripts/surface.mjs) use it so a local server can stand in for a deployed host, as
|
|
559
653
|
* `createFileLock` takes a test's timings (#378's code review, 1).
|
|
560
654
|
*/
|
|
561
|
-
export declare function createFlipstreamFor(options: FlipstreamOptions
|
|
655
|
+
export declare function createFlipstreamFor(options: FlipstreamOptions & {
|
|
656
|
+
readonly transport?: (request: ApiRequest, fetch?: typeof globalThis.fetch) => ReturnType<Transport>;
|
|
657
|
+
}, deployed: DeployedHosts, person?: PersonClientSession): Flipstream;
|