@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 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/first-party/session/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAoB,MAAM,WAAW,CAAA;AAG5E,OAAO,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAA;AAevD,MAAM,UAAU,UAAU,CACxB,IAAiB,EACjB,IAAiB,EACjB,EAAE,MAAM,EAAe,EACvB,EAAE,IAAI,EAAE,OAAO,EAAU,EACzB,EAAE,OAAO,EAAE,OAAO,EAAa,EAC/B,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAU,EAC/C,EAAE,UAAU,EAAU;IAEtB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAEvB,MAAM,SAAS,GAAG,CAAC,IAAa,EAAQ,EAAE;QACxC,uFAAuF;QACvF,qFAAqF;QACrF,4CAA4C;QAC5C,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAM;QAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAM;QAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,OAAO,CAAC,IAAI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A;YACnC,OAAM;QACR,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;YAChF,MAAM,OAAO,EAAE,CAAA;YACf,OAAM;QACR,CAAC;QACD,oFAAoF;QACpF,gFAAgF;QAChF,8EAA8E;QAC9E,IACE,IAAI,CAAC,IAAI,KAAK,IAAI;YAClB,KAAK,CAAC,QAAQ;YACd,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM;YAC/B,KAAK,CAAC,SAAS,KAAK,IAAI;YACxB,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAChD,CAAC;YACD,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAA;IAED;;;;;;OAMG;IACH,MAAM,YAAY,GAAG,GAAkB,EAAE;QACvC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QACtB,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;IAED,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AccessToken } from '../claims.js';
|
|
2
|
+
import { type RefreshOutcome, type SessionCell } from './cell.js';
|
|
3
|
+
import type { SharedState } from './shared.js';
|
|
4
|
+
import { type Session, type SessionDeps } from './types.js';
|
|
5
|
+
/** The token this tab holds: taking one, dropping it, and refreshing it before it expires. */
|
|
6
|
+
export interface Tokens {
|
|
7
|
+
readonly publish: (next: Session) => void;
|
|
8
|
+
/** Holds `access` as the token of `generation`, and tells listeners (and, from here, the other tabs). */
|
|
9
|
+
readonly hold: (access: AccessToken, generation: number, serial: number, from: 'here' | 'another-tab') => void;
|
|
10
|
+
/** Drops the token: nobody is signed in here now, or nobody can tell. */
|
|
11
|
+
readonly release: (next: Session) => void;
|
|
12
|
+
readonly nextBackoff: () => number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The held token's part of the session. Its timer refreshes the token through `refresh`,
|
|
16
|
+
* which is the refresher's: the session hands it in, since a refresh holds its answer here.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createTokens(deps: SessionDeps, cell: SessionCell, { broadcast }: SharedState, refresh: (stale: string | null) => Promise<RefreshOutcome>): Tokens;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BACKOFF_MS, MIN_REFRESH_DELAY_MS, } from './cell.js';
|
|
2
|
+
import { REFRESH_MARGIN_MS } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The held token's part of the session. Its timer refreshes the token through `refresh`,
|
|
5
|
+
* which is the refresher's: the session hands it in, since a refresh holds its answer here.
|
|
6
|
+
*/
|
|
7
|
+
export function createTokens(deps, cell, { broadcast }, refresh) {
|
|
8
|
+
const { now } = deps;
|
|
9
|
+
const publish = (next) => {
|
|
10
|
+
cell.status = next;
|
|
11
|
+
for (const listener of cell.listeners)
|
|
12
|
+
listener();
|
|
13
|
+
};
|
|
14
|
+
const hold = (access, generation, serial, from) => {
|
|
15
|
+
// Any generation change is a new session, even for the same person: work begun under
|
|
16
|
+
// the old one must not carry on (§2.3).
|
|
17
|
+
if (access.principalKey !== cell.principalKey ||
|
|
18
|
+
cell.held?.generation !== generation) {
|
|
19
|
+
cell.revision += 1;
|
|
20
|
+
}
|
|
21
|
+
cell.principalKey = access.principalKey;
|
|
22
|
+
const held = { access, generation, serial, expiresAt: now() + access.lifetimeMs };
|
|
23
|
+
cell.held = held;
|
|
24
|
+
cell.backoffStep = 0;
|
|
25
|
+
clearTimeout(cell.restoreTimer);
|
|
26
|
+
scheduleRefresh(Math.max(held.expiresAt - REFRESH_MARGIN_MS - now(), MIN_REFRESH_DELAY_MS));
|
|
27
|
+
if (from === 'here') {
|
|
28
|
+
broadcast({ type: 'token', generation, serial, accessToken: access.token });
|
|
29
|
+
}
|
|
30
|
+
publish({ status: 'signed-in', principal: access.principal, revision: cell.revision });
|
|
31
|
+
};
|
|
32
|
+
const release = (next) => {
|
|
33
|
+
cell.held = null;
|
|
34
|
+
clearTimeout(cell.refreshTimer);
|
|
35
|
+
if (cell.principalKey !== null) {
|
|
36
|
+
cell.principalKey = null;
|
|
37
|
+
cell.revision += 1;
|
|
38
|
+
}
|
|
39
|
+
publish(next);
|
|
40
|
+
};
|
|
41
|
+
const scheduleRefresh = (delay) => {
|
|
42
|
+
clearTimeout(cell.refreshTimer);
|
|
43
|
+
if (cell.closed)
|
|
44
|
+
return;
|
|
45
|
+
cell.refreshTimer = setTimeout(() => {
|
|
46
|
+
const token = cell.held?.access.token ?? null;
|
|
47
|
+
if (token === null)
|
|
48
|
+
return;
|
|
49
|
+
void refresh(token).then((outcome) => {
|
|
50
|
+
// Pulse-auth couldn't be reached: the token may still be good for a while. Try
|
|
51
|
+
// again, backing off, without telling anyone it is signed out.
|
|
52
|
+
if (outcome === 'unavailable' && cell.held !== null)
|
|
53
|
+
scheduleRefresh(nextBackoff());
|
|
54
|
+
});
|
|
55
|
+
}, delay);
|
|
56
|
+
};
|
|
57
|
+
const nextBackoff = () => {
|
|
58
|
+
const delay = BACKOFF_MS[Math.min(cell.backoffStep, BACKOFF_MS.length - 1)] ?? 30_000;
|
|
59
|
+
cell.backoffStep += 1;
|
|
60
|
+
return delay;
|
|
61
|
+
};
|
|
62
|
+
return { publish, hold, release, nextBackoff };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/first-party/session/tokens.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,oBAAoB,GAGrB,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,iBAAiB,EAAkC,MAAM,YAAY,CA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WAAW,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAA;QACrF,IAAI,CAAC,WAAW,IAAI,CAAC,CAAA;QACrB,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import type { SignInSetup } from '../hooks.js';
|
|
2
|
+
import type { SignInHooks } from '../signInHooks.js';
|
|
3
|
+
import type { ChannelLike, LockManagerLike, StorageLike } from '../browser.js';
|
|
4
|
+
import type { Principal } from '../claims.js';
|
|
5
|
+
import type { AuthHttp } from '../http.js';
|
|
6
|
+
import type { SessionReport } from '../report.js';
|
|
7
|
+
import type { OwedSlot } from './owed.js';
|
|
8
|
+
/** What the console knows about the session, one meaning per case (§2.6). */
|
|
9
|
+
export type Session = {
|
|
10
|
+
readonly status: 'restoring';
|
|
11
|
+
} | {
|
|
12
|
+
readonly status: 'unavailable';
|
|
13
|
+
readonly retryInMs: number;
|
|
14
|
+
}
|
|
15
|
+
/** pulse-auth answered outside its contract, or our own proxy refused: reported. */
|
|
16
|
+
| {
|
|
17
|
+
readonly status: 'broken';
|
|
18
|
+
readonly httpStatus: number;
|
|
19
|
+
}
|
|
20
|
+
/** No Web Locks or localStorage: tabs can't agree, so sign-in is refused. */
|
|
21
|
+
| {
|
|
22
|
+
readonly status: 'unsupported';
|
|
23
|
+
} | {
|
|
24
|
+
readonly status: 'signed-out';
|
|
25
|
+
} | {
|
|
26
|
+
readonly status: 'signed-in';
|
|
27
|
+
readonly principal: Principal;
|
|
28
|
+
/** Moves whenever who is signed in, or what they may do, changes. */
|
|
29
|
+
readonly revision: number;
|
|
30
|
+
};
|
|
31
|
+
/** A redeemed login link (§2.2): a union, so each case gets its own screen. */
|
|
32
|
+
export type RedeemResult = {
|
|
33
|
+
readonly kind: 'signed-in';
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'two-step';
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'two-step-setup';
|
|
38
|
+
readonly setup: SignInSetup;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'dead-link';
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'no-account';
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: 'inactive';
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: 'proxy-refused';
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'unavailable';
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'unsupported';
|
|
51
|
+
}
|
|
52
|
+
/** A sign-out happened while this was in flight: the sign-out wins. */
|
|
53
|
+
| {
|
|
54
|
+
readonly kind: 'superseded';
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: 'unknown';
|
|
57
|
+
readonly status: number;
|
|
58
|
+
};
|
|
59
|
+
/** The private reader is called only as the entry hands the verify result to the page. */
|
|
60
|
+
export interface SupersededVerify {
|
|
61
|
+
readonly kind: 'superseded';
|
|
62
|
+
readonly codesAtDelivery?: () => readonly string[] | null;
|
|
63
|
+
}
|
|
64
|
+
/** A two-step code, checked (A4): the same rules as a redeem. */
|
|
65
|
+
export type TwoStepResult =
|
|
66
|
+
/** `backupCodes`: the ten codes, once, when this sign-in also set two-step up; otherwise null. */
|
|
67
|
+
{
|
|
68
|
+
readonly kind: 'signed-in';
|
|
69
|
+
readonly backupCodes: readonly string[] | null;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: 'wrong-code';
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Too many wrong codes: none is taken for `minutes`, so not before `until` (epoch ms), the
|
|
75
|
+
* latest the lock can end.
|
|
76
|
+
*/
|
|
77
|
+
| {
|
|
78
|
+
readonly kind: 'locked';
|
|
79
|
+
readonly minutes: number;
|
|
80
|
+
readonly until: number;
|
|
81
|
+
} | {
|
|
82
|
+
readonly kind: 'expired';
|
|
83
|
+
} | {
|
|
84
|
+
readonly kind: 'no-account';
|
|
85
|
+
} | {
|
|
86
|
+
readonly kind: 'inactive';
|
|
87
|
+
} | {
|
|
88
|
+
readonly kind: 'proxy-refused';
|
|
89
|
+
} | {
|
|
90
|
+
readonly kind: 'unavailable';
|
|
91
|
+
} | {
|
|
92
|
+
readonly kind: 'unsupported';
|
|
93
|
+
} | SupersededVerify | {
|
|
94
|
+
readonly kind: 'unknown';
|
|
95
|
+
readonly status: number;
|
|
96
|
+
};
|
|
97
|
+
/** The token to send now, or why there is none. */
|
|
98
|
+
export type TokenFor = {
|
|
99
|
+
readonly kind: 'token';
|
|
100
|
+
readonly token: string;
|
|
101
|
+
readonly revision: number;
|
|
102
|
+
} | {
|
|
103
|
+
readonly kind: 'signed-out';
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: 'unavailable';
|
|
106
|
+
};
|
|
107
|
+
/** What became of a sign-out's first try to tell pulse-auth (#465, SDK-D1904). */
|
|
108
|
+
export type Told =
|
|
109
|
+
/** pulse-auth confirmed it: to this tab, or to another tab first (the flag gone, same generation). */
|
|
110
|
+
{
|
|
111
|
+
readonly kind: 'confirmed';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Not confirmed: it stays pending and is sent again, backing off. `unavailable`: no answer
|
|
115
|
+
* (offline, a 5xx or 429, the cookie lock not had in time); `refused`: a 401 or 403, which
|
|
116
|
+
* proves nothing about the cookie; `invalid`: an answer outside the contract, the proxy's
|
|
117
|
+
* refusal included, reported.
|
|
118
|
+
*/
|
|
119
|
+
| {
|
|
120
|
+
readonly kind: 'unconfirmed';
|
|
121
|
+
readonly reason: 'unavailable' | 'refused' | 'invalid';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The record moved on since this sign-out (its serial, which a sign-out never moves): a sign-in,
|
|
125
|
+
* in any tab, or rarely a renewal by a tab that hadn't heard of it. That tab's cookie replaced
|
|
126
|
+
* the old one; it sent this logout first when it knew it was owed, and this call isn't told
|
|
127
|
+
* whether pulse-auth confirmed it. Nothing is pending for this sign-out; a sign-out made since
|
|
128
|
+
* is owed and sent on its own. Read `current()` (SDK-D1933, SDK-D2022).
|
|
129
|
+
*/
|
|
130
|
+
| {
|
|
131
|
+
readonly kind: 'superseded';
|
|
132
|
+
}
|
|
133
|
+
/** No locks or storage: nobody could sign in here, so nothing was sent and nothing is pending. */
|
|
134
|
+
| {
|
|
135
|
+
readonly kind: 'unsupported';
|
|
136
|
+
};
|
|
137
|
+
/** A sign-out that is done here; `told` settles what pulse-auth said to the first try. */
|
|
138
|
+
export interface SignedOut {
|
|
139
|
+
readonly told: Promise<Told>;
|
|
140
|
+
}
|
|
141
|
+
/** After a 401: send again with a new token, or not at all. */
|
|
142
|
+
export type AfterUnauthorized = 'retry' | 'signed-out' | 'unavailable';
|
|
143
|
+
export interface SessionDeps {
|
|
144
|
+
readonly http: AuthHttp;
|
|
145
|
+
/** `navigator.locks`; null makes the browser unsupported. */
|
|
146
|
+
readonly locks: LockManagerLike | null;
|
|
147
|
+
/** `localStorage`; null makes the browser unsupported. */
|
|
148
|
+
readonly storage: StorageLike | null;
|
|
149
|
+
readonly channel: ChannelLike | null;
|
|
150
|
+
/** What the app's operator should know (report.ts): never a body, a token or a message's content. */
|
|
151
|
+
readonly report: (report: SessionReport) => void;
|
|
152
|
+
/**
|
|
153
|
+
* A subscriber's exception. It is the page's own bug, so it goes where the page's uncaught
|
|
154
|
+
* errors go, and never into `report` (SDK-D1910, SDK-D1915).
|
|
155
|
+
*/
|
|
156
|
+
readonly reportError: (cause: unknown) => void;
|
|
157
|
+
readonly now: () => number;
|
|
158
|
+
/**
|
|
159
|
+
* The page's slot for a logout a closed session owed, which storage never took (owed.ts,
|
|
160
|
+
* sdk#483). Null where nothing can sign in (no locks or storage): never read or written there.
|
|
161
|
+
*/
|
|
162
|
+
readonly owed: OwedSlot | null;
|
|
163
|
+
}
|
|
164
|
+
/** Refresh this long before the access token expires (pulse-auth issues 1-hour tokens). */
|
|
165
|
+
export declare const REFRESH_MARGIN_MS = 60000;
|
|
166
|
+
/**
|
|
167
|
+
* The session as the rest of the console sees it (`Auth.session`): its state and the
|
|
168
|
+
* actions a page takes. No credential: the token, the refreshes and the raw redeem stay in
|
|
169
|
+
* `AuthSession`, inside packages/platform/auth (A2).
|
|
170
|
+
*/
|
|
171
|
+
export interface SessionView {
|
|
172
|
+
/** What is known now. The same object until something changes (useSyncExternalStore). */
|
|
173
|
+
current(): Session;
|
|
174
|
+
subscribe(listener: () => void): () => void;
|
|
175
|
+
/** Resolves once the first answer is in: anything but `restoring`. */
|
|
176
|
+
ready(): Promise<Session>;
|
|
177
|
+
/** On page load: the access token is gone, the refresh cookie decides. */
|
|
178
|
+
start(): void;
|
|
179
|
+
/** Try again, after `broken` or `unavailable`. */
|
|
180
|
+
retry(): void;
|
|
181
|
+
/** Whether a two-step code is being waited for, and until when: never the challenge. */
|
|
182
|
+
twoStepPending(): {
|
|
183
|
+
readonly expiresAt: number;
|
|
184
|
+
} | null;
|
|
185
|
+
/**
|
|
186
|
+
* With no code waited for: whether a sign-out or sign-in elsewhere ended the last challenge
|
|
187
|
+
* (true), or its five minutes or a lock did (false).
|
|
188
|
+
*/
|
|
189
|
+
twoStepEndedByTab(): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* `signal`, the caller's own: aborted while this waits for the cookie lock, nothing is sent
|
|
192
|
+
* (`unavailable`, and the caller reads its signal); once sent, the code is settled here.
|
|
193
|
+
* `onSend`: called right before the code goes out; from then on the call answers what
|
|
194
|
+
* pulse-auth said, whatever the signal does (SDK-D1931).
|
|
195
|
+
*/
|
|
196
|
+
verifyTwoStep(code: string, signal?: AbortSignal, onSend?: () => void): Promise<TwoStepResult>;
|
|
197
|
+
/**
|
|
198
|
+
* Local first: resolves once this browser is signed out, every tab of it. pulse-auth is
|
|
199
|
+
* told after, under the cookie lock; `told` settles once it was asked (a logout it never
|
|
200
|
+
* confirmed stays pending and is sent again).
|
|
201
|
+
*/
|
|
202
|
+
signOut(): Promise<SignedOut>;
|
|
203
|
+
/** Checks the shared state again: a tab coming back, a token asked for. */
|
|
204
|
+
sync(): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Another tab wrote the shared state (the `storage` event for its key, or for every key): ends
|
|
207
|
+
* this tab's paid mark, then checks the shared state again (sdk#506).
|
|
208
|
+
*/
|
|
209
|
+
stateWritten(): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Ends this tab's session object: its timers stop and are never set again, it stops hearing the
|
|
212
|
+
* other tabs, closes its channel and tells its subscribers nothing more. What it holds stays
|
|
213
|
+
* readable (`current()`, `twoStepPending()`). A request already sent settles with its real
|
|
214
|
+
* outcome and still writes the shared state the other tabs read; a sign-in already sent that then
|
|
215
|
+
* loses (a sign-out won, or its 2xx can't be read) is still revoked with a `/logout` (SDK-D1941).
|
|
216
|
+
* Nothing new is sent (SDK-D1930): a call still waiting for the cookie lock answers
|
|
217
|
+
* `unavailable`, and a sign-out's try that hadn't gone out is `unconfirmed`, its pending logout
|
|
218
|
+
* left recorded. A call made after it sends nothing and throws, or rejects, with a
|
|
219
|
+
* `SessionClosedError`: a closed session is not used again. Safe to call twice. The shared state
|
|
220
|
+
* and the cookie are untouched: this is no sign-out.
|
|
221
|
+
*
|
|
222
|
+
* A logout owed only in this object's memory (one storage refused to record, a sign-in's revoke
|
|
223
|
+
* included) is not lost with it: it is left for the next session in this page that looks, which
|
|
224
|
+
* sends it before it restores. It is lost when it was never written down: the page closed while
|
|
225
|
+
* storage still refused, another tab that never heard of it restored the cookie first, or storage
|
|
226
|
+
* came back too shortly before to have taken it (a logout on the back-off is written at its next
|
|
227
|
+
* try, one kept without a timer at the next `sync()`; the `close()` row in `docs/first-party.md`).
|
|
228
|
+
*
|
|
229
|
+
* A `ready()` already waiting gets the answer of the restore under way; with none under
|
|
230
|
+
* way it rejects with a `SessionClosedError`. An `unavailable` it gets after the close isn't
|
|
231
|
+
* tried again.
|
|
232
|
+
*/
|
|
233
|
+
close(): void;
|
|
234
|
+
}
|
|
235
|
+
/** The whole session, its credentials included: packages/platform/auth's own code only (A2). */
|
|
236
|
+
export interface AuthSession extends SessionView, SignInHooks {
|
|
237
|
+
/** Whether `close()` was called: what else sends on this session's behalf (the wire) reads it. */
|
|
238
|
+
isClosed(): boolean;
|
|
239
|
+
getAccessToken(): Promise<TokenFor>;
|
|
240
|
+
/** After a 401 on a request sent with `sent`. */
|
|
241
|
+
refreshAfterUnauthorized(sent: string): Promise<AfterUnauthorized>;
|
|
242
|
+
/** After a 403: the role comes from the token's claims, so ask for fresh ones, once a minute at most. */
|
|
243
|
+
refreshAfterForbidden(): Promise<void>;
|
|
244
|
+
/** `signal`: as for `verifyTwoStep`. */
|
|
245
|
+
redeem(linkToken: string, attemptId: string, signal?: AbortSignal): Promise<RedeemResult>;
|
|
246
|
+
/**
|
|
247
|
+
* Reads the current setup challenge while it is live. Clears it on expiry or marks it
|
|
248
|
+
* superseded on a generation change. Returns null for a plain verify or an ended challenge.
|
|
249
|
+
*/
|
|
250
|
+
setupChallenge(): {
|
|
251
|
+
readonly challenge: string;
|
|
252
|
+
readonly expiresAt: number;
|
|
253
|
+
} | null;
|
|
254
|
+
/** Checks the original sign-in setup from this session before its secret can be requested or delivered. */
|
|
255
|
+
signInSetupChallenge(setup: SignInSetup): {
|
|
256
|
+
readonly kind: 'pending';
|
|
257
|
+
readonly challenge: string;
|
|
258
|
+
} | {
|
|
259
|
+
readonly kind: 'expired' | 'superseded';
|
|
260
|
+
};
|
|
261
|
+
/** After a password reset, ask pulse-auth whether the current browser session still stands. */
|
|
262
|
+
readonly askPulseAuthAgain: () => Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* Whether `revision` is still who is signed in, by the shared state too: a sign-out or a
|
|
265
|
+
* changed principal another tab committed counts even before its message arrives.
|
|
266
|
+
*/
|
|
267
|
+
isCurrent(revision: number): boolean;
|
|
268
|
+
/** Whether issued codes may reach the caller in the shared browser now. */
|
|
269
|
+
canDeliverCodes(userId: string): boolean;
|
|
270
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/first-party/session/types.ts"],"names":[],"mappings":"AA0HA,2FAA2F;AAC3F,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Wire } from './wire.js';
|
|
2
|
+
/** A call straight to a host gives up after this long, as the main entry's calls do (30 s). */
|
|
3
|
+
export declare const OPEN_DEADLINE_MS = 30000;
|
|
4
|
+
export interface WireDeps {
|
|
5
|
+
/** The page's fetch: the one network edge. */
|
|
6
|
+
readonly fetch: typeof fetch;
|
|
7
|
+
/** The hosts' base URLs, checked when the session was made, with no trailing slash. */
|
|
8
|
+
readonly hosts: {
|
|
9
|
+
readonly auth: string;
|
|
10
|
+
readonly admin: string;
|
|
11
|
+
};
|
|
12
|
+
/** An answer outside a family's contract: the path and the status, never a body or a query. */
|
|
13
|
+
readonly report: (answer: {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly status: number;
|
|
16
|
+
}) => void;
|
|
17
|
+
readonly now: () => number;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the session was closed: then `open` sends nothing and answers `unavailable`, as the
|
|
20
|
+
* session's own calls send nothing new after `close()` (SDK-D1930). A family's call made after
|
|
21
|
+
* the close rejecting comes with the first family's attachment (SDK-D1938).
|
|
22
|
+
*/
|
|
23
|
+
readonly closed: () => boolean;
|
|
24
|
+
}
|
|
25
|
+
/** The shared clock, reporter and open sender used to compose a session's family wire. */
|
|
26
|
+
export type SessionWire = Pick<Wire, 'open' | 'report' | 'now'>;
|
|
27
|
+
/** A path a family sends to, on its host: '/oauth/device/verify'. Anything else is a programming error. */
|
|
28
|
+
export declare function checkPath(path: string): void;
|
|
29
|
+
/** The JSON a body holds, or undefined when there is none, or it isn't JSON. */
|
|
30
|
+
export declare function parsed(text: string): unknown;
|
|
31
|
+
export declare function createSessionWire(deps: WireDeps): SessionWire;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { refusedRedirect } from './http.js';
|
|
2
|
+
/*
|
|
3
|
+
* The wire (wire.ts) on a browser session (#465): how a family's request reaches a server. `open`
|
|
4
|
+
* goes straight to pulse-auth or pulse-admin without a cookie or token. createPersonAccess adds
|
|
5
|
+
* the signed-in sender. The family uses the wire's clock and reports a redirect through the
|
|
6
|
+
* wire's reporter. The open sender returns the redirect status without following it (SDK-D1962).
|
|
7
|
+
*/
|
|
8
|
+
/** A call straight to a host gives up after this long, as the main entry's calls do (30 s). */
|
|
9
|
+
export const OPEN_DEADLINE_MS = 30_000;
|
|
10
|
+
/** A path a family sends to, on its host: '/oauth/device/verify'. Anything else is a programming error. */
|
|
11
|
+
export function checkPath(path) {
|
|
12
|
+
if (!/^\/(?!\/)[^?#]*$/.test(path)) {
|
|
13
|
+
throw new TypeError('a wire request’s path starts with one /, and has no query or fragment');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** The JSON a body holds, or undefined when there is none, or it isn't JSON. */
|
|
17
|
+
export function parsed(text) {
|
|
18
|
+
if (text === '')
|
|
19
|
+
return undefined;
|
|
20
|
+
try {
|
|
21
|
+
const value = JSON.parse(text);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createSessionWire(deps) {
|
|
29
|
+
const open = async (host, request, options) => {
|
|
30
|
+
checkPath(request.path);
|
|
31
|
+
const caller = options?.signal;
|
|
32
|
+
// A function, so the compiler doesn't keep the answer it gave before the await.
|
|
33
|
+
const abortedByCaller = () => caller?.aborted === true;
|
|
34
|
+
if (abortedByCaller())
|
|
35
|
+
return { kind: 'aborted' };
|
|
36
|
+
if (deps.closed())
|
|
37
|
+
return { kind: 'unavailable' };
|
|
38
|
+
const url = new URL(`${deps.hosts[host]}${request.path}`);
|
|
39
|
+
for (const [name, value] of Object.entries(request.query ?? {}))
|
|
40
|
+
url.searchParams.set(name, value);
|
|
41
|
+
const giveUp = new AbortController();
|
|
42
|
+
const timer = setTimeout(() => {
|
|
43
|
+
giveUp.abort();
|
|
44
|
+
}, OPEN_DEADLINE_MS);
|
|
45
|
+
const cut = () => {
|
|
46
|
+
giveUp.abort();
|
|
47
|
+
};
|
|
48
|
+
caller?.addEventListener('abort', cut, { once: true });
|
|
49
|
+
try {
|
|
50
|
+
const response = await deps.fetch(url, {
|
|
51
|
+
method: request.method,
|
|
52
|
+
credentials: 'omit',
|
|
53
|
+
// A redirect is a misconfigured host, not an outage (SDK-D1953): never followed,
|
|
54
|
+
// because a 307 would send the body again.
|
|
55
|
+
redirect: 'manual',
|
|
56
|
+
signal: giveUp.signal,
|
|
57
|
+
headers: request.method === 'POST'
|
|
58
|
+
? { Accept: 'application/json', 'Content-Type': 'application/json' }
|
|
59
|
+
: { Accept: 'application/json' },
|
|
60
|
+
...(request.method === 'POST' ? { body: JSON.stringify(request.body ?? {}) } : {}),
|
|
61
|
+
});
|
|
62
|
+
// Nothing to parse, and Node's 3xx may carry a body, so it is cancelled at once.
|
|
63
|
+
// This call goes to another origin. The page sees the redirect only when the browser
|
|
64
|
+
// lets it see the answer; otherwise fetch rejects and the call is unavailable.
|
|
65
|
+
// The family reports a status outside its table. The wire does not (SDK-D1962).
|
|
66
|
+
if (refusedRedirect(response.status)) {
|
|
67
|
+
await response.body?.cancel().catch(() => undefined);
|
|
68
|
+
return { kind: 'answer', status: response.status, body: undefined };
|
|
69
|
+
}
|
|
70
|
+
const text = await response.text();
|
|
71
|
+
return { kind: 'answer', status: response.status, body: parsed(text) };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// fetch rejects only when no answer came, or its body broke off: offline, the deadline,
|
|
75
|
+
// or the caller's own signal.
|
|
76
|
+
return abortedByCaller() ? { kind: 'aborted' } : { kind: 'unavailable' };
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
clearTimeout(timer);
|
|
80
|
+
caller?.removeEventListener('abort', cut);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
open,
|
|
85
|
+
report: (answer) => {
|
|
86
|
+
deps.report({ path: answer.path, status: answer.status });
|
|
87
|
+
},
|
|
88
|
+
now: deps.now,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=sessionWire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionWire.js","sourceRoot":"","sources":["../../src/first-party/sessionWire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAI3C;;;;;GAKG;AAEH,+FAA+F;AAC/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAqBtC,2GAA2G;AAC3G,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,SAAS,CAAC,uEAAuE,CAAC,CAAA;IAC9F,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,SAAS,CAAA;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,OAAO,KAAK,CAAA;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAc;IAC9C,MAAM,IAAI,GAAG,KAAK,EAChB,IAAsB,EACtB,OAAoB,EACpB,OAAgC,EACA,EAAE;QAClC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACvB,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAA;QAC9B,gFAAgF;QAChF,M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ACjB,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;QAC3D,CAAC;QACD,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SignInStep } from './hooks.js';
|
|
2
|
+
import type { CallOptions, ThroughProxy } from './result.js';
|
|
3
|
+
import type { WireAnswer, WireRequest } from './wire.js';
|
|
4
|
+
/**
|
|
5
|
+
* sdk#467 (password sign-in): a call that answers a TokenResponse, run as a redeem runs. logIn is
|
|
6
|
+
* its first user; the invitation's accept (sdk#472) the second.
|
|
7
|
+
*/
|
|
8
|
+
export interface SignInHooks {
|
|
9
|
+
/**
|
|
10
|
+
* Through the proxy, pinned to the press, inside the cookie lock (a pending logout sent
|
|
11
|
+
* first), the other tabs told. `superseded` when a sign-in or sign-out, in any tab, came after
|
|
12
|
+
* the press (read `current()`): before the send, nothing is sent; after it, only for an answer
|
|
13
|
+
* that would have signed in (that session is revoked) or opened a challenge (dropped). Once sent, a refusal, no answer or the proxy's
|
|
14
|
+
* is answered as it is (SDK-D1946). Sent once however often it is asked while one is under way.
|
|
15
|
+
* The session reads every 2xx: a token signs in, a challenge is kept (its two-step lock under
|
|
16
|
+
* `email`) while a caller is left to answer it, and dropped once every caller has left
|
|
17
|
+
* (SDK-D1975), a 2xx it can't use is `invalid` and its logout recorded. `extra`: the fields of
|
|
18
|
+
* that 200 the session lets out for this step, by a list it owns: for `accept` exactly
|
|
19
|
+
* `continue_link`, for `log-in` nothing; and `{}` with any two-step step. Never a token, a
|
|
20
|
+
* challenge or a backup code, and never a field pulse-auth adds later (SDK-D1907, 3 Dec). The
|
|
21
|
+
* family reads every answer that is not a 2xx (`refused`), with its own rules. A route that is
|
|
22
|
+
* not the step's own POST rejects with a `TypeError` after the closed check, before anything
|
|
23
|
+
* else, nothing sent (SDK-D1929).
|
|
24
|
+
* `onRefused`: called once per request with an answer that is not a 2xx, on the request's own
|
|
25
|
+
* result, whatever its callers did; where the family reports one outside its contract (one
|
|
26
|
+
* request, one report: SDK-D1949, SDK-D1976). Only the press that started the request is asked.
|
|
27
|
+
* `onSettled`: called once per request, after `onRefused`, with the request's own result,
|
|
28
|
+
* whatever its callers did (one that left after the send was told `aborted`, and a joined caller
|
|
29
|
+
* shares the request), and before any caller is answered. `received`: pulse-auth answered this
|
|
30
|
+
* request a 2xx (not an HTML page, which is the app's own), whatever the session made of it (`step`, `superseded` because the session it
|
|
31
|
+
* made was revoked, `invalid` because it couldn't be read, `unavailable` because every caller
|
|
32
|
+
* left before a challenge was taken). false: no 2xx (a refusal, no answer, the proxy's, or a
|
|
33
|
+
* stop before the send). A request whose result rejects calls neither hook: that is a fault in
|
|
34
|
+
* this session, possibly after pulse-auth answered. The invitation's token is then kept, and a
|
|
35
|
+
* retry answers `dead_link` if it was used. Where a family keeps what lives as long as the request (sdk#472:
|
|
36
|
+
* the invitation's token).
|
|
37
|
+
*/
|
|
38
|
+
readonly signInThrough: (request: WireRequest, how: {
|
|
39
|
+
readonly step: 'log-in' | 'accept';
|
|
40
|
+
readonly email: string | null;
|
|
41
|
+
readonly onRefused: (answer: WireAnswer) => void;
|
|
42
|
+
readonly onSettled: (answer: SignInThroughAnswer, heard: {
|
|
43
|
+
readonly received: boolean;
|
|
44
|
+
}) => void;
|
|
45
|
+
}, options: CallOptions | undefined) => Promise<SignInThroughAnswer>;
|
|
46
|
+
}
|
|
47
|
+
/** What `signInThrough` answers a caller, and tells `onSettled` of the request. */
|
|
48
|
+
export type SignInThroughAnswer = {
|
|
49
|
+
readonly kind: 'step';
|
|
50
|
+
readonly step: SignInStep;
|
|
51
|
+
readonly extra: Readonly<Record<string, unknown>>;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: 'refused';
|
|
54
|
+
readonly answer: WireAnswer;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: 'superseded';
|
|
57
|
+
} | ThroughProxy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signInHooks.js","sourceRoot":"","sources":["../../src/first-party/signInHooks.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { StorageLike } from './browser.js';
|
|
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 declare const STATE_KEY = "flipstream-auth:state";
|
|
8
|
+
export interface AuthState {
|
|
9
|
+
/**
|
|
10
|
+
* Moves on every sign-in and sign-out, and on a refresh that returns another person (sdk#535),
|
|
11
|
+
* never on a refresh of the same person. A generation begun under a record with no person, and
|
|
12
|
+
* renewed by a tab that knew nobody, can name another person by the end: so code delivery
|
|
13
|
+
* compares the person, not only the generation (PR 551 S1).
|
|
14
|
+
*/
|
|
15
|
+
readonly generation: number;
|
|
16
|
+
readonly signedIn: boolean;
|
|
17
|
+
/** Moves every time a refresh or sign-in adopts a token, so a late token never rolls a tab back. */
|
|
18
|
+
readonly serial: number;
|
|
19
|
+
/**
|
|
20
|
+
* A sign-out pulse-auth hasn't confirmed, for the generation the sign-out made. Inside
|
|
21
|
+
* this record, so one write changes both: no tab can read a signed-out generation
|
|
22
|
+
* without its pending logout.
|
|
23
|
+
*/
|
|
24
|
+
readonly logoutPending: {
|
|
25
|
+
readonly generation: number;
|
|
26
|
+
} | null;
|
|
27
|
+
/**
|
|
28
|
+
* A fingerprint of the principal the latest adopted token carries (claims.ts, never the
|
|
29
|
+
* claims themselves), null when signed out. A tab that missed a token message finds out
|
|
30
|
+
* from here that who is signed in, or what they may do, changed, and refreshes; the same
|
|
31
|
+
* principal at a newer serial needs nothing, so tabs never refresh each other in turn.
|
|
32
|
+
*/
|
|
33
|
+
readonly principal: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* A fingerprint of the person alone (the `uid` claim, claims.ts), null when signed out. A
|
|
36
|
+
* refresh compares it: another person starts a new generation, a changed role doesn't. On a
|
|
37
|
+
* signed-in record without one (written before it was kept, or by a console), the refresh
|
|
38
|
+
* compares the token its tab holds at that generation instead. With neither, nothing is known:
|
|
39
|
+
* it keeps the generation, as before, and writes the person from then on (sdk#535, SDK-D2023 as
|
|
40
|
+
* amended in PR 551).
|
|
41
|
+
*/
|
|
42
|
+
readonly person: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** No record at all: a new browser, or Local Storage cleared. Never "signed out" by itself: the cookie decides (§2.3). */
|
|
45
|
+
export declare const NO_RECORD: AuthState;
|
|
46
|
+
/** The record in storage, or NO_RECORD when there is none or it can't be read. */
|
|
47
|
+
export declare function readState(storage: StorageLike): AuthState;
|
|
48
|
+
/** Whether the browser took the write. */
|
|
49
|
+
export declare function writeState(storage: StorageLike, state: AuthState): boolean;
|
|
50
|
+
/** The newer of two states: the higher generation, then the higher serial. */
|
|
51
|
+
export declare function newer(a: AuthState, b: AuthState): AuthState;
|