@flipstream/sdk 0.14.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 +76 -0
- package/README.md +95 -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 +4 -0
- package/dist/core/call.js +7 -1
- 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 +6 -2
- package/dist/core/identify.js +16 -12
- package/dist/core/identify.js.map +1 -1
- package/dist/core/result.d.ts +1 -1
- package/dist/core/shared.d.ts +2 -0
- package/dist/core/shared.js +1 -0
- 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 +51 -9
- package/dist/flipstream.js +58 -22
- package/dist/flipstream.js.map +1 -1
- package/dist/node/session.js +3 -1
- package/dist/node/session.js.map +1 -1
- package/dist/version.gen.js +1 -1
- package/docs/first-party.md +278 -0
- package/package.json +34 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/first-party/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,kBAAkB,IAAI,oBAAoB,EAAE,wBAAwB,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAEhI,OAAO,EAAE,eAAe,EAAoB,MAAM,aAAa,CAAA;AAE/D;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAA;AAEhC,6FAA6F;AAC7F,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAA;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AACtC;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,MAAM,CAAA;AAkB7B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC;IAC/C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChD,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAClC,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,uBAAuB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/C,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,qFAAqF;IACrF,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACjD,CA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,CAAC,IAAY;IAC7B,IAAI,CAAC;QACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { TwoStepSetup, TwoStepStatus } from './calls/twoStepSetup.js';
|
|
2
|
+
export { createBrowserSession } from './entry.js';
|
|
3
|
+
export type { BrowserSession, BrowserSessionOptions, OpenedLink, ReadyLink, RedeemStop, SessionState, SignOutTold, SpentLink, TwoStepStop, TwoStepVerifyStop, } from './entry.js';
|
|
4
|
+
export type { ServiceName } from '../core/transport.js';
|
|
5
|
+
export type { Flipstream, Hosts } from '../flipstream.js';
|
|
6
|
+
export type { SignInSetup, SignInStep } from './hooks.js';
|
|
7
|
+
export type { SessionReport } from './report.js';
|
|
8
|
+
export type { AsPerson, CallOptions, Ok, Refused, Result, Sent, Stopped, ThroughProxy } from './result.js';
|
|
9
|
+
export { SessionClosedError } from './session/closed.js';
|
|
10
|
+
export type { AskingConsent, ConsentRequest, ConsentStop } from './calls/consent.js';
|
|
11
|
+
export type { OpenedReset } from './calls/reset.js';
|
|
12
|
+
export type { LogInRequest, LogInStop } from './calls/logIn.js';
|
|
13
|
+
export type { DeviceAnswerStop, DeviceRequest, DeviceStop } from './calls/device.js';
|
|
14
|
+
export type { AcceptEntry, AcceptInvitation, AcceptStop, Accepted, Invitation, InvitationShown, OpenedInvitation, PersonalAcceptEntry, PersonalInvitation, SharedAcceptEntry, SharedInvitation, } from './calls/invitation.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/first-party/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAkBjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Landed } from './linkToken.js';
|
|
2
|
+
/**
|
|
3
|
+
* The paths a site's links land on. An invitation's or a reset's absent: this site has no such
|
|
4
|
+
* landing, and no token is ever taken as one (the lead, 3 Dec, ask 5aa08a).
|
|
5
|
+
*/
|
|
6
|
+
export interface Landings {
|
|
7
|
+
/** A login link's (`continue_url`'s path). */
|
|
8
|
+
readonly landing: string;
|
|
9
|
+
/** An invitation's. pulse-auth builds its links on `/invite`. */
|
|
10
|
+
readonly invitationLanding?: string | undefined;
|
|
11
|
+
/** A reset link's. pulse-auth builds its links on `/reset-password`. */
|
|
12
|
+
readonly resetLanding?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** The tokens a family other than the login link's reads. */
|
|
15
|
+
export type LandedFor = 'invitation' | 'reset';
|
|
16
|
+
export interface LandedTokens {
|
|
17
|
+
/** The login link's token, for the session's own link check and redeem; null otherwise. */
|
|
18
|
+
readonly linkToken: string | null;
|
|
19
|
+
/** That family's token while it is held; null when there was none, or once forgotten. */
|
|
20
|
+
readonly token: (family: LandedFor) => string | null;
|
|
21
|
+
/** The family is done with it, spent or dead: from now on `token` gives null. */
|
|
22
|
+
readonly forget: (family: LandedFor) => void;
|
|
23
|
+
}
|
|
24
|
+
/** Sorts the landed token by its path, once; the families then read and forget theirs. */
|
|
25
|
+
export declare function sortLanded(landed: Landed | null, landings: Landings): LandedTokens;
|
|
26
|
+
/**
|
|
27
|
+
* The landings, checked when the session is made, each like `landing` (`checkLanding`): a plain
|
|
28
|
+
* path of the page's own origin, or a RangeError naming the option; not a string, a TypeError. No
|
|
29
|
+
* two the same, or a token would belong to two families: a RangeError. The error names the
|
|
30
|
+
* option, never a token. An absent invitation or reset landing is no landing, so it is no clash.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkLandings(landings: Landings): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { checkLanding, PLAIN_PATH_RULE } from './attempts.js';
|
|
2
|
+
/** Sorts the landed token by its path, once; the families then read and forget theirs. */
|
|
3
|
+
export function sortLanded(landed, landings) {
|
|
4
|
+
const on = (path) => path !== undefined && landed !== null && landed.path === path ? landed.token : null;
|
|
5
|
+
const held = {
|
|
6
|
+
invitation: on(landings.invitationLanding),
|
|
7
|
+
reset: on(landings.resetLanding),
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
linkToken: on(landings.landing),
|
|
11
|
+
token: (family) => held[family],
|
|
12
|
+
forget: (family) => {
|
|
13
|
+
held[family] = null;
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The landings, checked when the session is made, each like `landing` (`checkLanding`): a plain
|
|
19
|
+
* path of the page's own origin, or a RangeError naming the option; not a string, a TypeError. No
|
|
20
|
+
* two the same, or a token would belong to two families: a RangeError. The error names the
|
|
21
|
+
* option, never a token. An absent invitation or reset landing is no landing, so it is no clash.
|
|
22
|
+
*/
|
|
23
|
+
export function checkLandings(landings) {
|
|
24
|
+
const named = [
|
|
25
|
+
['landing', landings.landing],
|
|
26
|
+
['invitationLanding', landings.invitationLanding],
|
|
27
|
+
['resetLanding', landings.resetLanding],
|
|
28
|
+
];
|
|
29
|
+
const given = named.filter(([name, path]) => name === 'landing' || path !== undefined);
|
|
30
|
+
for (const [name, path] of given) {
|
|
31
|
+
if (typeof path !== 'string') {
|
|
32
|
+
throw new TypeError(`createBrowserSession: ${name} must be a path on the page’s own origin, starting with /`);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
checkLanding(path);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw new RangeError(`createBrowserSession: ${name} must be ${PLAIN_PATH_RULE}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const seen = new Map();
|
|
42
|
+
for (const [name, path] of given) {
|
|
43
|
+
const first = seen.get(path);
|
|
44
|
+
if (first !== undefined) {
|
|
45
|
+
throw new RangeError(`createBrowserSession: ${first} and ${name} are the same path; a token would belong to both`);
|
|
46
|
+
}
|
|
47
|
+
seen.set(path, name);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=landed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"landed.js","sourceRoot":"","sources":["../../src/first-party/landed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAmC7D,0FAA0F;AAC1F,MAAM,UAAU,UAAU,CAAC,MAAqB,EAAE,QAAkB;IAClE,MAAM,EAAE,GAAG,CAAC,IAAwB,EAAiB,EAAE,CACrD,IAAI,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;IACrF,MAAM,IAAI,GAAqC;QAC7C,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAC1C,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;KACjC,CAAA;IACD,OAAO;QACL,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/B,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACjB,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;QACrB,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,MAAM,KAAK,GAA4C;QACrD,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC;QAC7B,CAAC,mBAAmB,EAAE,QAAQ,CAAC,iBAAiB,CAAC;QACjD,CAAC,cAAc,EAAE,QAAQ,CAAC,YAAY,CAAC;KACxC,CAAA;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS,CAAC,CAAA;IACtF,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,IAAI,SAAS,CAAC,yBAAyB,IAAI,2DAA2D,CAAC,CAAA;QAC/G,CAAC;QACD,IAAI,CAAC;YACH,YAAY,CAAC,IAAI,CAAC,CAAA;QACpB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,UAAU,CAAC,yBAAyB,IAAI,YAAY,eAAe,EAAE,CAAC,CAAA;QAClF,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAmB,CAAA;IACvC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,UAAU,CAAC,yBAAyB,KAAK,QAAQ,IAAI,kDAAkD,CAAC,CAAA;QACpH,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A page has at most one landed token per family. Its proof holds no credential and
|
|
2
|
+
* remains recognizable after the token has been forgotten. */
|
|
3
|
+
export declare function landedProof(readToken: () => string | null, wrongProofMessage: string): {
|
|
4
|
+
opened: () => Readonly<{
|
|
5
|
+
readonly kind: "no_token";
|
|
6
|
+
}> | Readonly<{
|
|
7
|
+
readonly kind: "ready";
|
|
8
|
+
}>;
|
|
9
|
+
assertIssued(proof: Readonly<{
|
|
10
|
+
readonly kind: "ready";
|
|
11
|
+
}>): void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A page has at most one landed token per family. Its proof holds no credential and
|
|
2
|
+
* remains recognizable after the token has been forgotten. */
|
|
3
|
+
export function landedProof(readToken, wrongProofMessage) {
|
|
4
|
+
const absent = Object.freeze({ kind: 'no_token' });
|
|
5
|
+
const ready = Object.freeze({ kind: 'ready' });
|
|
6
|
+
const issued = new WeakSet();
|
|
7
|
+
return {
|
|
8
|
+
opened: () => {
|
|
9
|
+
if (readToken() === null)
|
|
10
|
+
return absent;
|
|
11
|
+
issued.add(ready);
|
|
12
|
+
return ready;
|
|
13
|
+
},
|
|
14
|
+
assertIssued(proof) {
|
|
15
|
+
if (!issued.has(proof))
|
|
16
|
+
throw new TypeError(wrongProofMessage);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=landedProof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"landedProof.js","sourceRoot":"","sources":["../../src/first-party/landedProof.ts"],"names":[],"mappings":"AAAA;8DAC8D;AAC9D,MAAM,UAAU,WAAW,CAAC,SAA8B,EAAE,iBAAyB;IACnF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAW,CAAC,CAAA;IAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAW,CAAC,CAAA;IACvD,MAAM,MAAM,GAAG,IAAI,OAAO,EAAgB,CAAA;IAC1C,OAAO;QACL,MAAM,EAAE,GAAG,EAAE;YACX,IAAI,SAAS,EAAE,KAAK,IAAI;gBAAE,OAAO,MAAM,CAAA;YACvC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YACjB,OAAO,KAAK,CAAA;QACd,CAAC;QACD,YAAY,CAAC,KAAmB;YAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,SAAS,CAAC,iBAAiB,CAAC,CAAA;QAChE,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The token and the path it landed on: a login link's, an invitation's and a reset's all come as
|
|
3
|
+
* `?token=`, and only the path says which (#465).
|
|
4
|
+
*/
|
|
5
|
+
export interface Landed {
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly token: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Takes a link's token out of `href` and keeps it here, with the path it landed on: the address
|
|
11
|
+
* without it, for `history.replaceState`, or null when there was none to take. Every other
|
|
12
|
+
* parameter stays.
|
|
13
|
+
*/
|
|
14
|
+
export declare function strip(href: string): string | null;
|
|
15
|
+
/** The token and its path, handed out once: a second call gets null. */
|
|
16
|
+
export declare function take(): Landed | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* A link's token, between src/boot.ts and the page that reads it: in memory only, never in
|
|
3
|
+
* the address bar, history, storage or a report (docs/architecture.md 2.2). No imports and
|
|
4
|
+
* no side effects, so boot.ts can import it before anything else runs. ES modules are
|
|
5
|
+
* evaluated once, so main.tsx reads the same variable boot.ts wrote.
|
|
6
|
+
*/
|
|
7
|
+
let landed = null;
|
|
8
|
+
/**
|
|
9
|
+
* Takes a link's token out of `href` and keeps it here, with the path it landed on: the address
|
|
10
|
+
* without it, for `history.replaceState`, or null when there was none to take. Every other
|
|
11
|
+
* parameter stays.
|
|
12
|
+
*/
|
|
13
|
+
export function strip(href) {
|
|
14
|
+
const url = new URL(href);
|
|
15
|
+
if (!url.searchParams.has('token'))
|
|
16
|
+
return null;
|
|
17
|
+
const value = url.searchParams.get('token') ?? '';
|
|
18
|
+
if (value !== '')
|
|
19
|
+
landed = { path: url.pathname, token: value };
|
|
20
|
+
url.searchParams.delete('token');
|
|
21
|
+
return url.toString();
|
|
22
|
+
}
|
|
23
|
+
/** The token and its path, handed out once: a second call gets null. */
|
|
24
|
+
export function take() {
|
|
25
|
+
const taken = landed;
|
|
26
|
+
landed = null;
|
|
27
|
+
return taken;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=linkToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkToken.js","sourceRoot":"","sources":["../../src/first-party/linkToken.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,IAAI,MAAM,GAAkB,IAAI,CAAA;AAEhC;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAA;IACzB,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;IACjD,IAAI,KAAK,KAAK,EAAE;QAAE,MAAM,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IAC/D,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAChC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;AACvB,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,IAAI;IAClB,MAAM,KAAK,GAAG,MAAM,CAAA;IACpB,MAAM,GAAG,IAAI,CAAA;IACb,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type Attempt } from './attempts.js';
|
|
2
|
+
import type { StorageLike } from './browser.js';
|
|
3
|
+
import type { AuthHttp } from './http.js';
|
|
4
|
+
export interface LinkDeps {
|
|
5
|
+
readonly http: AuthHttp;
|
|
6
|
+
/** Null in a browser that can't sign in (no localStorage). */
|
|
7
|
+
readonly storage: StorageLike | null;
|
|
8
|
+
/** The page's own origin: never user input. */
|
|
9
|
+
readonly origin: string;
|
|
10
|
+
/** The path on it a mailed link lands on: the console's is `/login/confirm`. */
|
|
11
|
+
readonly landing: string;
|
|
12
|
+
readonly now: () => number;
|
|
13
|
+
readonly random: (bytes: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A login link's request, as the entry needs it to say why (#465): `proxy-refused` apart from
|
|
17
|
+
* pulse-auth's own answers, and the status of an answer outside the contract, to report.
|
|
18
|
+
*/
|
|
19
|
+
export type LoginLinkRequest = {
|
|
20
|
+
readonly kind: 'sent';
|
|
21
|
+
readonly email: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'unavailable';
|
|
24
|
+
}
|
|
25
|
+
/** No storage, or it refused the attempt: a link sent now could never be redeemed. */
|
|
26
|
+
| {
|
|
27
|
+
readonly kind: 'unsupported';
|
|
28
|
+
}
|
|
29
|
+
/** The app's own server refused it (the proxy's own refusal mark). No mail went out. */
|
|
30
|
+
| {
|
|
31
|
+
readonly kind: 'proxy-refused';
|
|
32
|
+
}
|
|
33
|
+
/** An answer outside pulse-auth's contract, with its status. */
|
|
34
|
+
| {
|
|
35
|
+
readonly kind: 'broken';
|
|
36
|
+
readonly status: number;
|
|
37
|
+
};
|
|
38
|
+
/** Asks for a login link for `email`, coming back to `next` (validated later, by `safeNext`). */
|
|
39
|
+
export declare function requestLink(deps: LinkDeps, email: string, next: string | null, signal?: AbortSignal): Promise<LoginLinkRequest>;
|
|
40
|
+
export type SignupAttemptDeps = Pick<LinkDeps, 'storage' | 'origin' | 'landing' | 'now' | 'random'>;
|
|
41
|
+
/** Stores the sign-up attempt the mailed link will be checked against. */
|
|
42
|
+
export declare function storeSignupAttempt(deps: SignupAttemptDeps, email: string): {
|
|
43
|
+
email: string;
|
|
44
|
+
continue_url: string;
|
|
45
|
+
discard: () => void;
|
|
46
|
+
} | null;
|
|
47
|
+
/** What an opened link is, before anyone clicks (§2.2, "Open the link"). */
|
|
48
|
+
export type LinkCheck =
|
|
49
|
+
/** All three addresses agree and this browser asked for it: offer "Continue as". */
|
|
50
|
+
{
|
|
51
|
+
readonly kind: 'ready';
|
|
52
|
+
readonly email: string;
|
|
53
|
+
readonly token: string;
|
|
54
|
+
readonly attemptId: string;
|
|
55
|
+
readonly attempt: Attempt;
|
|
56
|
+
}
|
|
57
|
+
/** The token's address, the address shown and the attempt's differ: no button. */
|
|
58
|
+
| {
|
|
59
|
+
readonly kind: 'invalid';
|
|
60
|
+
}
|
|
61
|
+
/** This browser holds no such attempt: open it where it was asked for, or sign in here. */
|
|
62
|
+
| {
|
|
63
|
+
readonly kind: 'other-browser';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* This browser asked, over 10 minutes ago, or its link was used here: dead either way.
|
|
67
|
+
* The attempt says which address this browser typed, the only one a new link may go to.
|
|
68
|
+
*/
|
|
69
|
+
| {
|
|
70
|
+
readonly kind: 'spent';
|
|
71
|
+
readonly attempt: Attempt;
|
|
72
|
+
}
|
|
73
|
+
/** The page was opened without its token (a reload, after boot took it). */
|
|
74
|
+
| {
|
|
75
|
+
readonly kind: 'no-token';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* An invitation (`invite` in the link, as pulse-fe's invitations carry it). The invitee
|
|
79
|
+
* never asked for a link, so no attempt could bind it, and anyone can add `invite` to a
|
|
80
|
+
* link: it is held, never redeemed, until invitations have their own token (24l).
|
|
81
|
+
*/
|
|
82
|
+
| {
|
|
83
|
+
readonly kind: 'invitation';
|
|
84
|
+
};
|
|
85
|
+
/** An opened link as the console sees it: `LinkCheck` without the link's token (A2). */
|
|
86
|
+
export type OpenedLink = Exclude<LinkCheck, {
|
|
87
|
+
readonly kind: 'ready';
|
|
88
|
+
}> | Omit<Extract<LinkCheck, {
|
|
89
|
+
readonly kind: 'ready';
|
|
90
|
+
}>, 'token'>;
|
|
91
|
+
/**
|
|
92
|
+
* Checks an opened link. The attempt is required, not a warning: comparing addresses only
|
|
93
|
+
* catches a swapped address, not an attacker who mails a victim their own link (§2.2).
|
|
94
|
+
*/
|
|
95
|
+
export declare function checkLink(storage: StorageLike | null, link: {
|
|
96
|
+
readonly token: string | null;
|
|
97
|
+
readonly attempt: unknown;
|
|
98
|
+
readonly email: unknown;
|
|
99
|
+
readonly invite?: unknown;
|
|
100
|
+
}, now: number): LinkCheck;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { continueUrl, createAttempt, findAttempt, removeAttempt, } from './attempts.js';
|
|
2
|
+
import { linkTokenEmail, normalizeEmail } from './claims.js';
|
|
3
|
+
/** Asks for a login link for `email`, coming back to `next` (validated later, by `safeNext`). */
|
|
4
|
+
export async function requestLink(deps, email, next, signal) {
|
|
5
|
+
const { storage } = deps;
|
|
6
|
+
if (storage === null)
|
|
7
|
+
return { kind: 'unsupported' };
|
|
8
|
+
const address = normalizeEmail(email);
|
|
9
|
+
const attemptId = createAttempt(storage, { email: address, next, at: deps.now(), purpose: 'log-in', used: false }, deps.random);
|
|
10
|
+
// The browser refused to store the attempt: a link sent now could never be redeemed.
|
|
11
|
+
if (attemptId === null)
|
|
12
|
+
return { kind: 'unsupported' };
|
|
13
|
+
const answer = await deps.http.requestLink(address, continueUrl(deps.origin, deps.landing, attemptId, address), signal);
|
|
14
|
+
if (answer.kind === 'sent')
|
|
15
|
+
return { kind: 'sent', email: address };
|
|
16
|
+
// Unreachable, a 5xx, or a 2xx without "ok": the mail may still have gone out, so its
|
|
17
|
+
// attempt stays (its link works for 10 minutes). Only an answer that proves no mail
|
|
18
|
+
// went out removes it.
|
|
19
|
+
switch (answer.kind) {
|
|
20
|
+
case 'unavailable':
|
|
21
|
+
return { kind: 'unavailable' };
|
|
22
|
+
case 'unsettled':
|
|
23
|
+
return { kind: 'broken', status: answer.httpStatus };
|
|
24
|
+
case 'proxy-refused':
|
|
25
|
+
removeAttempt(storage, attemptId);
|
|
26
|
+
return { kind: 'proxy-refused' };
|
|
27
|
+
case 'broken':
|
|
28
|
+
removeAttempt(storage, attemptId);
|
|
29
|
+
return { kind: 'broken', status: answer.httpStatus };
|
|
30
|
+
default: {
|
|
31
|
+
const exhaustive = answer;
|
|
32
|
+
return exhaustive;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Stores the sign-up attempt the mailed link will be checked against. */
|
|
37
|
+
export function storeSignupAttempt(deps, email) {
|
|
38
|
+
const { storage } = deps;
|
|
39
|
+
if (storage === null)
|
|
40
|
+
return null;
|
|
41
|
+
const address = normalizeEmail(email);
|
|
42
|
+
const attemptId = createAttempt(storage, { email: address, next: null, at: deps.now(), purpose: 'sign-up', used: false }, deps.random);
|
|
43
|
+
// The browser refused to store the attempt: a link sent now could never be redeemed.
|
|
44
|
+
if (attemptId === null)
|
|
45
|
+
return null;
|
|
46
|
+
return {
|
|
47
|
+
email: address,
|
|
48
|
+
continue_url: continueUrl(deps.origin, deps.landing, attemptId, address),
|
|
49
|
+
discard: () => removeAttempt(storage, attemptId),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Checks an opened link. The attempt is required, not a warning: comparing addresses only
|
|
54
|
+
* catches a swapped address, not an attacker who mails a victim their own link (§2.2).
|
|
55
|
+
*/
|
|
56
|
+
export function checkLink(storage, link, now) {
|
|
57
|
+
// Absent either way: `URLSearchParams.get` answers null for a parameter that isn't there (#464's
|
|
58
|
+
// round 2, finding 2).
|
|
59
|
+
if (link.invite !== undefined && link.invite !== null)
|
|
60
|
+
return { kind: 'invitation' };
|
|
61
|
+
if (link.token === null)
|
|
62
|
+
return { kind: 'no-token' };
|
|
63
|
+
if (storage === null || typeof link.attempt !== 'string')
|
|
64
|
+
return { kind: 'other-browser' };
|
|
65
|
+
const found = findAttempt(storage, link.attempt, now);
|
|
66
|
+
if (found.kind === 'missing')
|
|
67
|
+
return { kind: 'other-browser' };
|
|
68
|
+
if (found.kind === 'spent')
|
|
69
|
+
return { kind: 'spent', attempt: found.attempt };
|
|
70
|
+
// A mail client that decodes once too often turns `+` into a space (pulse-fe's repair).
|
|
71
|
+
const shown = typeof link.email === 'string' ? normalizeEmail(link.email.replace(/ /g, '+')) : '';
|
|
72
|
+
const sub = linkTokenEmail(link.token);
|
|
73
|
+
if (shown === '' || sub !== shown || found.attempt.email !== shown) {
|
|
74
|
+
return { kind: 'invalid' };
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
kind: 'ready',
|
|
78
|
+
email: shown,
|
|
79
|
+
token: link.token,
|
|
80
|
+
attemptId: link.attempt,
|
|
81
|
+
attempt: found.attempt,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/first-party/links.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,GAEd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAmC5D,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAc,EACd,KAAa,EACb,IAAmB,EACnB,MAAoB;IAEpB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IACxB,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAA;IACpD,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;IACrC,MAAM,SAAS,GAAG,aAAa,CAC7B,OAAO,EACP,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,E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AE,IAAI,EAAE,eAAe,EAAE,CAAA;IAC9D,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;IAC5E,wFAAwF;IACxF,MAAM,KAAK,GACT,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACrF,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtC,IAAI,KAAK,KAAK,EAAE,IAAI,GAAG,KAAK,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;QACnE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAC5B,CAAC;IACD,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,IAAI,CAAC,OAAO;QACvB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { LockManagerLike } from './browser.js';
|
|
2
|
+
/**
|
|
3
|
+
* Held across tabs by every request whose answer sets or clears the refresh cookie:
|
|
4
|
+
* refresh, redeem, two-step verify and logout. The browser keeps whichever Set-Cookie lands
|
|
5
|
+
* last, and pulse-auth revokes a session whose spent cookie comes back after its 10 s grace,
|
|
6
|
+
* so these requests go one at a time (docs/architecture.md 2.3).
|
|
7
|
+
*/
|
|
8
|
+
export declare const COOKIE_LOCK = "flipstream-auth-cookie";
|
|
9
|
+
/**
|
|
10
|
+
* Held only for a read-modify-write of the shared state in localStorage, never across a
|
|
11
|
+
* network call, so no two tabs compute the same generation. The order is always cookie lock,
|
|
12
|
+
* then state lock, so the two can't deadlock.
|
|
13
|
+
*/
|
|
14
|
+
export declare const STATE_LOCK = "flipstream-auth-state";
|
|
15
|
+
/**
|
|
16
|
+
* How long a tab waits for a lock. After that it gives up instead of going ahead alone: the
|
|
17
|
+
* other tab may already have rotated the cookie. Running out means `unavailable`, never a
|
|
18
|
+
* request without the lock.
|
|
19
|
+
*/
|
|
20
|
+
export declare const LOCK_WAIT_MS = 10000;
|
|
21
|
+
export type Locked<T> = {
|
|
22
|
+
readonly ran: true;
|
|
23
|
+
readonly value: T;
|
|
24
|
+
} | {
|
|
25
|
+
readonly ran: false;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Runs `run` while holding the lock `name` across tabs, or not at all: `{ ran: false }` when
|
|
29
|
+
* the wait ran out or the lock manager refused (reported). The wait is bounded with an
|
|
30
|
+
* AbortController (AbortSignal.timeout is missing in Safari 15.4, which has Web Locks).
|
|
31
|
+
*
|
|
32
|
+
* `signal`, a caller's own (#465): aborted before the turn comes, the wait ends at once and
|
|
33
|
+
* nothing runs, with no report; the caller reads `signal.aborted` after `{ ran: false }`. Once
|
|
34
|
+
* the turn has come it no longer matters: a run holding the lock finishes.
|
|
35
|
+
*/
|
|
36
|
+
export declare function withLock<T>(locks: LockManagerLike, name: string, run: () => Promise<T>, report: (error: unknown) => void, signal?: AbortSignal): Promise<Locked<T>>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Held across tabs by every request whose answer sets or clears the refresh cookie:
|
|
3
|
+
* refresh, redeem, two-step verify and logout. The browser keeps whichever Set-Cookie lands
|
|
4
|
+
* last, and pulse-auth revokes a session whose spent cookie comes back after its 10 s grace,
|
|
5
|
+
* so these requests go one at a time (docs/architecture.md 2.3).
|
|
6
|
+
*/
|
|
7
|
+
export const COOKIE_LOCK = 'flipstream-auth-cookie';
|
|
8
|
+
/**
|
|
9
|
+
* Held only for a read-modify-write of the shared state in localStorage, never across a
|
|
10
|
+
* network call, so no two tabs compute the same generation. The order is always cookie lock,
|
|
11
|
+
* then state lock, so the two can't deadlock.
|
|
12
|
+
*/
|
|
13
|
+
export const STATE_LOCK = 'flipstream-auth-state';
|
|
14
|
+
/**
|
|
15
|
+
* How long a tab waits for a lock. After that it gives up instead of going ahead alone: the
|
|
16
|
+
* other tab may already have rotated the cookie. Running out means `unavailable`, never a
|
|
17
|
+
* request without the lock.
|
|
18
|
+
*/
|
|
19
|
+
export const LOCK_WAIT_MS = 10_000;
|
|
20
|
+
/**
|
|
21
|
+
* Runs `run` while holding the lock `name` across tabs, or not at all: `{ ran: false }` when
|
|
22
|
+
* the wait ran out or the lock manager refused (reported). The wait is bounded with an
|
|
23
|
+
* AbortController (AbortSignal.timeout is missing in Safari 15.4, which has Web Locks).
|
|
24
|
+
*
|
|
25
|
+
* `signal`, a caller's own (#465): aborted before the turn comes, the wait ends at once and
|
|
26
|
+
* nothing runs, with no report; the caller reads `signal.aborted` after `{ ran: false }`. Once
|
|
27
|
+
* the turn has come it no longer matters: a run holding the lock finishes.
|
|
28
|
+
*/
|
|
29
|
+
export async function withLock(locks, name, run, report, signal) {
|
|
30
|
+
if (signal?.aborted === true)
|
|
31
|
+
return { ran: false };
|
|
32
|
+
const waitLimit = new AbortController();
|
|
33
|
+
const timer = setTimeout(() => {
|
|
34
|
+
waitLimit.abort();
|
|
35
|
+
}, LOCK_WAIT_MS);
|
|
36
|
+
const givenUp = () => {
|
|
37
|
+
waitLimit.abort();
|
|
38
|
+
};
|
|
39
|
+
signal?.addEventListener('abort', givenUp, { once: true });
|
|
40
|
+
// An object, not a `let`: the lock manager sets it in a callback the compiler can't follow.
|
|
41
|
+
const turn = { ran: false };
|
|
42
|
+
try {
|
|
43
|
+
const value = await locks.request(name, { signal: waitLimit.signal }, () => {
|
|
44
|
+
turn.ran = true;
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
signal?.removeEventListener('abort', givenUp);
|
|
47
|
+
return run();
|
|
48
|
+
});
|
|
49
|
+
return { ran: true, value };
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
// An error from `run` itself is the caller's to handle.
|
|
53
|
+
if (turn.ran)
|
|
54
|
+
throw error;
|
|
55
|
+
if (!waitLimit.signal.aborted)
|
|
56
|
+
report(error);
|
|
57
|
+
return { ran: false };
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
signal?.removeEventListener('abort', givenUp);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=locks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locks.js","sourceRoot":"","sources":["../../src/first-party/locks.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAA;AAEnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,uBAAuB,CAAA;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA;AAKlC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,KAAsB,EACtB,IAAY,EACZ,GAAqB,EACrB,MAAgC,EAChC,MAAoB;IAEpB,IAAI,MAAM,EAAE,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;IACnD,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAA;IACvC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,SAAS,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC,EAAE,YAAY,CAAC,CAAA;IAChB,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,SAAS,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC,CAAA;IACD,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,4FAA4F;IAC5F,MAAM,IAAI,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;IAC3B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE;YACzE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;YACf,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC7C,OAAO,GAAG,EAAE,CAAA;QACd,CAAC,CAAC,CAAA;QACF,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IAC7B,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,wDAAwD;QACxD,IAAI,IAAI,CAAC,GAAG;YAAE,MAAM,KAAK,CAAA;QACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO;YAAE,MAAM,CAAC,KAAK,CAAC,CAAA;QAC5C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;IACvB,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACnB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ApiRequest, TransportResult } from '../core/transport.js';
|
|
2
|
+
import type { DeployedHosts, Hosts } from '../flipstream.js';
|
|
3
|
+
import type { AuthSession } from './session/types.js';
|
|
4
|
+
type Credentials = Pick<AuthSession, 'current' | 'getAccessToken' | 'refreshAfterUnauthorized' | 'isCurrent' | 'isClosed'>;
|
|
5
|
+
export interface PersonDestination {
|
|
6
|
+
readonly hosts: Hosts & DeployedHosts;
|
|
7
|
+
readonly origin: string;
|
|
8
|
+
readonly authPath: string;
|
|
9
|
+
readonly fetch: typeof fetch;
|
|
10
|
+
readonly allowLocalhostHttp?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const CLOSED: {
|
|
13
|
+
readonly kind: "cancelled";
|
|
14
|
+
readonly reason: "session-closed";
|
|
15
|
+
};
|
|
16
|
+
declare const ABORTED: {
|
|
17
|
+
readonly kind: "aborted";
|
|
18
|
+
};
|
|
19
|
+
/** The caller can stop waiting for credentials or a shared renewal without aborting that renewal. */
|
|
20
|
+
export declare function untilAborted<T>(signal: AbortSignal, work: () => Promise<T>): Promise<T | typeof ABORTED>;
|
|
21
|
+
/** A page's own proxy never receives a bearer, including when a service shares the page's origin. */
|
|
22
|
+
export declare function allowsProxyFreePath(url: URL, proxy: URL): boolean;
|
|
23
|
+
interface ResponseChecks {
|
|
24
|
+
readonly beforeRenewal?: () => void;
|
|
25
|
+
readonly canDeliver?: (() => boolean) | undefined;
|
|
26
|
+
readonly isUnauthorized?: ((response: Response) => Promise<boolean>) | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** A client keeps its pin; each family call has a sender of its own. */
|
|
29
|
+
export declare function personSender(session: Credentials, deps: PersonDestination): (revision?: number, onRedirect?: (answer: {
|
|
30
|
+
path: string;
|
|
31
|
+
status: number;
|
|
32
|
+
}) => void) => {
|
|
33
|
+
readonly send: (call: ApiRequest, fetch?: typeof globalThis.fetch, checks?: ResponseChecks) => Promise<TransportResult | typeof CLOSED>;
|
|
34
|
+
readonly current: () => boolean;
|
|
35
|
+
readonly pinAtPress: () => void;
|
|
36
|
+
readonly matchesDisplay: (shown: number | undefined) => boolean;
|
|
37
|
+
};
|
|
38
|
+
export {};
|