@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.
Files changed (218) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +95 -1
  3. package/dist/auth/transport.d.ts +6 -2
  4. package/dist/auth/transport.js +5 -3
  5. package/dist/auth/transport.js.map +1 -1
  6. package/dist/core/call.d.ts +4 -0
  7. package/dist/core/call.js +7 -1
  8. package/dist/core/call.js.map +1 -1
  9. package/dist/core/fetch.d.ts +20 -1
  10. package/dist/core/fetch.js +50 -3
  11. package/dist/core/fetch.js.map +1 -1
  12. package/dist/core/hosts.d.ts +11 -0
  13. package/dist/core/hosts.js +13 -0
  14. package/dist/core/hosts.js.map +1 -0
  15. package/dist/core/identify.d.ts +6 -2
  16. package/dist/core/identify.js +16 -12
  17. package/dist/core/identify.js.map +1 -1
  18. package/dist/core/result.d.ts +1 -1
  19. package/dist/core/shared.d.ts +2 -0
  20. package/dist/core/shared.js +1 -0
  21. package/dist/core/shared.js.map +1 -1
  22. package/dist/core/signal.d.ts +7 -0
  23. package/dist/core/signal.js +9 -0
  24. package/dist/core/signal.js.map +1 -1
  25. package/dist/first-party/asPerson.d.ts +13 -0
  26. package/dist/first-party/asPerson.js +144 -0
  27. package/dist/first-party/asPerson.js.map +1 -0
  28. package/dist/first-party/attempts.d.ts +71 -0
  29. package/dist/first-party/attempts.js +132 -0
  30. package/dist/first-party/attempts.js.map +1 -0
  31. package/dist/first-party/authProxyMark.d.ts +7 -0
  32. package/dist/first-party/authProxyMark.js +8 -0
  33. package/dist/first-party/authProxyMark.js.map +1 -0
  34. package/dist/first-party/browser.d.ts +55 -0
  35. package/dist/first-party/browser.js +137 -0
  36. package/dist/first-party/browser.js.map +1 -0
  37. package/dist/first-party/browserSession.d.ts +95 -0
  38. package/dist/first-party/browserSession.js +242 -0
  39. package/dist/first-party/browserSession.js.map +1 -0
  40. package/dist/first-party/calls/consent.d.ts +77 -0
  41. package/dist/first-party/calls/consent.js +174 -0
  42. package/dist/first-party/calls/consent.js.map +1 -0
  43. package/dist/first-party/calls/device.d.ts +75 -0
  44. package/dist/first-party/calls/device.js +133 -0
  45. package/dist/first-party/calls/device.js.map +1 -0
  46. package/dist/first-party/calls/invitation.d.ts +198 -0
  47. package/dist/first-party/calls/invitation.js +240 -0
  48. package/dist/first-party/calls/invitation.js.map +1 -0
  49. package/dist/first-party/calls/logIn.d.ts +41 -0
  50. package/dist/first-party/calls/logIn.js +48 -0
  51. package/dist/first-party/calls/logIn.js.map +1 -0
  52. package/dist/first-party/calls/reset.d.ts +58 -0
  53. package/dist/first-party/calls/reset.js +163 -0
  54. package/dist/first-party/calls/reset.js.map +1 -0
  55. package/dist/first-party/calls/signUp.d.ts +21 -0
  56. package/dist/first-party/calls/signUp.js +72 -0
  57. package/dist/first-party/calls/signUp.js.map +1 -0
  58. package/dist/first-party/calls/twoStepSetup.d.ts +55 -0
  59. package/dist/first-party/calls/twoStepSetup.js +168 -0
  60. package/dist/first-party/calls/twoStepSetup.js.map +1 -0
  61. package/dist/first-party/claims.d.ts +88 -0
  62. package/dist/first-party/claims.js +181 -0
  63. package/dist/first-party/claims.js.map +1 -0
  64. package/dist/first-party/enrollment.d.ts +10 -0
  65. package/dist/first-party/enrollment.js +44 -0
  66. package/dist/first-party/enrollment.js.map +1 -0
  67. package/dist/first-party/entry.d.ts +549 -0
  68. package/dist/first-party/entry.js +580 -0
  69. package/dist/first-party/entry.js.map +1 -0
  70. package/dist/first-party/hooks.d.ts +66 -0
  71. package/dist/first-party/hooks.js +19 -0
  72. package/dist/first-party/hooks.js.map +1 -0
  73. package/dist/first-party/http.d.ts +191 -0
  74. package/dist/first-party/http.js +364 -0
  75. package/dist/first-party/http.js.map +1 -0
  76. package/dist/first-party/index.d.ts +14 -0
  77. package/dist/first-party/index.js +3 -0
  78. package/dist/first-party/index.js.map +1 -0
  79. package/dist/first-party/landed.d.ts +32 -0
  80. package/dist/first-party/landed.js +50 -0
  81. package/dist/first-party/landed.js.map +1 -0
  82. package/dist/first-party/landedProof.d.ts +12 -0
  83. package/dist/first-party/landedProof.js +20 -0
  84. package/dist/first-party/landedProof.js.map +1 -0
  85. package/dist/first-party/linkToken.d.ts +16 -0
  86. package/dist/first-party/linkToken.js +29 -0
  87. package/dist/first-party/linkToken.js.map +1 -0
  88. package/dist/first-party/links.d.ts +100 -0
  89. package/dist/first-party/links.js +84 -0
  90. package/dist/first-party/links.js.map +1 -0
  91. package/dist/first-party/locks.d.ts +36 -0
  92. package/dist/first-party/locks.js +64 -0
  93. package/dist/first-party/locks.js.map +1 -0
  94. package/dist/first-party/personTransport.d.ts +38 -0
  95. package/dist/first-party/personTransport.js +177 -0
  96. package/dist/first-party/personTransport.js.map +1 -0
  97. package/dist/first-party/proxy/app.d.ts +25 -0
  98. package/dist/first-party/proxy/app.js +94 -0
  99. package/dist/first-party/proxy/app.js.map +1 -0
  100. package/dist/first-party/proxy/bound.d.ts +5 -0
  101. package/dist/first-party/proxy/bound.js +13 -0
  102. package/dist/first-party/proxy/bound.js.map +1 -0
  103. package/dist/first-party/proxy/cases.d.ts +54 -0
  104. package/dist/first-party/proxy/cases.js +412 -0
  105. package/dist/first-party/proxy/cases.js.map +1 -0
  106. package/dist/first-party/proxy/decide.d.ts +29 -0
  107. package/dist/first-party/proxy/decide.js +140 -0
  108. package/dist/first-party/proxy/decide.js.map +1 -0
  109. package/dist/first-party/proxy/freeze.d.ts +2 -0
  110. package/dist/first-party/proxy/freeze.js +10 -0
  111. package/dist/first-party/proxy/freeze.js.map +1 -0
  112. package/dist/first-party/proxy/handler.d.ts +23 -0
  113. package/dist/first-party/proxy/handler.js +190 -0
  114. package/dist/first-party/proxy/handler.js.map +1 -0
  115. package/dist/first-party/proxy/headers.d.ts +8 -0
  116. package/dist/first-party/proxy/headers.js +20 -0
  117. package/dist/first-party/proxy/headers.js.map +1 -0
  118. package/dist/first-party/proxy/hop.d.ts +9 -0
  119. package/dist/first-party/proxy/hop.js +37 -0
  120. package/dist/first-party/proxy/hop.js.map +1 -0
  121. package/dist/first-party/proxy/host.d.ts +5 -0
  122. package/dist/first-party/proxy/host.js +11 -0
  123. package/dist/first-party/proxy/host.js.map +1 -0
  124. package/dist/first-party/proxy/index.d.ts +7 -0
  125. package/dist/first-party/proxy/index.js +6 -0
  126. package/dist/first-party/proxy/index.js.map +1 -0
  127. package/dist/first-party/proxy/pass-back.d.ts +21 -0
  128. package/dist/first-party/proxy/pass-back.js +51 -0
  129. package/dist/first-party/proxy/pass-back.js.map +1 -0
  130. package/dist/first-party/proxy/paths.d.ts +17 -0
  131. package/dist/first-party/proxy/paths.js +36 -0
  132. package/dist/first-party/proxy/paths.js.map +1 -0
  133. package/dist/first-party/proxy/shown.d.ts +5 -0
  134. package/dist/first-party/proxy/shown.js +16 -0
  135. package/dist/first-party/proxy/shown.js.map +1 -0
  136. package/dist/first-party/proxy/stand-in.d.ts +47 -0
  137. package/dist/first-party/proxy/stand-in.js +318 -0
  138. package/dist/first-party/proxy/stand-in.js.map +1 -0
  139. package/dist/first-party/report.d.ts +47 -0
  140. package/dist/first-party/report.js +38 -0
  141. package/dist/first-party/report.js.map +1 -0
  142. package/dist/first-party/result.d.ts +82 -0
  143. package/dist/first-party/result.js +40 -0
  144. package/dist/first-party/result.js.map +1 -0
  145. package/dist/first-party/session/cell.d.ts +177 -0
  146. package/dist/first-party/session/cell.js +89 -0
  147. package/dist/first-party/session/cell.js.map +1 -0
  148. package/dist/first-party/session/closed.d.ts +8 -0
  149. package/dist/first-party/session/closed.js +12 -0
  150. package/dist/first-party/session/closed.js.map +1 -0
  151. package/dist/first-party/session/index.d.ts +3 -0
  152. package/dist/first-party/session/index.js +3 -0
  153. package/dist/first-party/session/index.js.map +1 -0
  154. package/dist/first-party/session/logout.d.ts +82 -0
  155. package/dist/first-party/session/logout.js +328 -0
  156. package/dist/first-party/session/logout.js.map +1 -0
  157. package/dist/first-party/session/owed.d.ts +30 -0
  158. package/dist/first-party/session/owed.js +27 -0
  159. package/dist/first-party/session/owed.js.map +1 -0
  160. package/dist/first-party/session/refresh.d.ts +19 -0
  161. package/dist/first-party/session/refresh.js +229 -0
  162. package/dist/first-party/session/refresh.js.map +1 -0
  163. package/dist/first-party/session/results.d.ts +38 -0
  164. package/dist/first-party/session/results.js +74 -0
  165. package/dist/first-party/session/results.js.map +1 -0
  166. package/dist/first-party/session/session.d.ts +2 -0
  167. package/dist/first-party/session/session.js +379 -0
  168. package/dist/first-party/session/session.js.map +1 -0
  169. package/dist/first-party/session/shared.d.ts +34 -0
  170. package/dist/first-party/session/shared.js +104 -0
  171. package/dist/first-party/session/shared.js.map +1 -0
  172. package/dist/first-party/session/sharedSignal.d.ts +27 -0
  173. package/dist/first-party/session/sharedSignal.js +55 -0
  174. package/dist/first-party/session/sharedSignal.js.map +1 -0
  175. package/dist/first-party/session/signIn.d.ts +43 -0
  176. package/dist/first-party/session/signIn.js +294 -0
  177. package/dist/first-party/session/signIn.js.map +1 -0
  178. package/dist/first-party/session/signInThrough.d.ts +5 -0
  179. package/dist/first-party/session/signInThrough.js +95 -0
  180. package/dist/first-party/session/signInThrough.js.map +1 -0
  181. package/dist/first-party/session/sync.d.ts +17 -0
  182. package/dist/first-party/session/sync.js +143 -0
  183. package/dist/first-party/session/sync.js.map +1 -0
  184. package/dist/first-party/session/tokens.d.ts +18 -0
  185. package/dist/first-party/session/tokens.js +64 -0
  186. package/dist/first-party/session/tokens.js.map +1 -0
  187. package/dist/first-party/session/types.d.ts +270 -0
  188. package/dist/first-party/session/types.js +3 -0
  189. package/dist/first-party/session/types.js.map +1 -0
  190. package/dist/first-party/sessionWire.d.ts +31 -0
  191. package/dist/first-party/sessionWire.js +91 -0
  192. package/dist/first-party/sessionWire.js.map +1 -0
  193. package/dist/first-party/signInHooks.d.ts +57 -0
  194. package/dist/first-party/signInHooks.js +2 -0
  195. package/dist/first-party/signInHooks.js.map +1 -0
  196. package/dist/first-party/state.d.ts +51 -0
  197. package/dist/first-party/state.js +52 -0
  198. package/dist/first-party/state.js.map +1 -0
  199. package/dist/first-party/strip.d.ts +1 -0
  200. package/dist/first-party/strip.js +8 -0
  201. package/dist/first-party/strip.js.map +1 -0
  202. package/dist/first-party/twoStepLock.d.ts +26 -0
  203. package/dist/first-party/twoStepLock.js +58 -0
  204. package/dist/first-party/twoStepLock.js.map +1 -0
  205. package/dist/first-party/twoStepSession.d.ts +21 -0
  206. package/dist/first-party/twoStepSession.js +31 -0
  207. package/dist/first-party/twoStepSession.js.map +1 -0
  208. package/dist/first-party/wire.d.ts +63 -0
  209. package/dist/first-party/wire.js +5 -0
  210. package/dist/first-party/wire.js.map +1 -0
  211. package/dist/flipstream.d.ts +51 -9
  212. package/dist/flipstream.js +58 -22
  213. package/dist/flipstream.js.map +1 -1
  214. package/dist/node/session.js +3 -1
  215. package/dist/node/session.js.map +1 -1
  216. package/dist/version.gen.js +1 -1
  217. package/docs/first-party.md +278 -0
  218. package/package.json +34 -5
@@ -32,6 +32,8 @@ export interface SharedResult<T, O> {
32
32
  }
33
33
  /** A scope's shared reads. */
34
34
  export interface SharedReads<O> {
35
+ /** Drops every shared read when the person changed before the caller received its answer. */
36
+ dropAll(): void;
35
37
  /** True until the scope closes; then every call reads its own, as outside a scope. */
36
38
  readonly isOpen: () => boolean;
37
39
  /** `spec`'s answer for `waiter`, from the one read the scope makes of it, started with `start` when none is kept. */
@@ -135,6 +135,7 @@ export function sharedReads() {
135
135
  entry.answer.then((read) => finish({ read }), (rejected) => finish({ rejected }));
136
136
  });
137
137
  return {
138
+ dropAll,
138
139
  isOpen: () => open,
139
140
  async read(spec, rule, waiter, start) {
140
141
  const key = `${spec.endpoint} ${rule.key}`;
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/core/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;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5
5
  */
6
6
  export declare function hasSignalShape(value: unknown): boolean;
7
+ /**
8
+ * A signal that is no AbortSignal (the controller, say) is a programming error: a TypeError naming
9
+ * the call, before anything is sent.
10
+ */
11
+ export declare function checkSignal(name: string, options: {
12
+ readonly signal?: unknown;
13
+ } | undefined): void;
7
14
  /**
8
15
  * Stops `listener` hearing `signal`'s abort, where the signal can. One with no removeEventListener
9
16
  * (a minimal polyfill's) keeps it: never a throw, which would come only once the work it listened
@@ -13,6 +13,15 @@ export function hasSignalShape(value) {
13
13
  return false;
14
14
  return 'aborted' in value && typeof Reflect.get(value, 'addEventListener') === 'function';
15
15
  }
16
+ /**
17
+ * A signal that is no AbortSignal (the controller, say) is a programming error: a TypeError naming
18
+ * the call, before anything is sent.
19
+ */
20
+ export function checkSignal(name, options) {
21
+ const signal = options?.signal;
22
+ if (signal !== undefined && !hasSignalShape(signal))
23
+ throw new TypeError(name + '() takes signal as an AbortSignal');
24
+ }
16
25
  /**
17
26
  * Stops `listener` hearing `signal`'s abort, where the signal can. One with no removeEventListener
18
27
  * (a minimal polyfill's) keeps it: never a throw, which would come only once the work it listened
@@ -1 +1 @@
1
- {"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/core/signal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7D,OAAO,SAAS,IAAI,KAAK,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,UAAU,CAAA;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAA+B,EAAE,QAAoB;IACjF,IAAI,OAAO,MAAM,EAAE,mBAAmB,KAAK,UAAU;QAAE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACtG,CAAC"}
1
+ {"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/core/signal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7D,OAAO,SAAS,IAAI,KAAK,IAAI,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,UAAU,CAAA;AAC3F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,OAAkD;IAC1F,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAA;IAC9B,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,IAAI,GAAG,mCAAmC,CAAC,CAAA;AACtH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAA+B,EAAE,QAAoB;IACjF,IAAI,OAAO,MAAM,EAAE,mBAAmB,KAAK,UAAU;QAAE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACtG,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Flipstream, type Identification } from '../flipstream.js';
2
+ import { type PersonDestination } from './personTransport.js';
3
+ import { type WireDeps } from './sessionWire.js';
4
+ import type { AuthSession } from './session/types.js';
5
+ import type { Wire } from './wire.js';
6
+ type Dependencies = WireDeps & PersonDestination & Pick<Identification, 'app'>;
7
+ type Session = Pick<AuthSession, 'current' | 'getAccessToken' | 'isCurrent' | 'refreshAfterUnauthorized' | 'isClosed'>;
8
+ /** The public session exposes the main client. The transport and the family wire are internal. */
9
+ export declare function createPersonAccess(session: Session, deps: Dependencies): {
10
+ readonly wire: Wire;
11
+ readonly flipstream: Flipstream;
12
+ };
13
+ export {};
@@ -0,0 +1,144 @@
1
+ import { stopListening } from '../core/signal.js';
2
+ import { createFlipstreamFor, DEFAULT_HOSTS } from '../flipstream.js';
3
+ import { SessionClosedError } from './session/closed.js';
4
+ import { frozen } from './result.js';
5
+ import { refusedRedirect } from './http.js';
6
+ import { personSender, untilAborted } from './personTransport.js';
7
+ import { checkPath, createSessionWire, OPEN_DEADLINE_MS, parsed } from './sessionWire.js';
8
+ async function readAnswer(response) {
9
+ try {
10
+ return { kind: 'answer', status: response.status, body: parsed(await response.text()) };
11
+ }
12
+ catch {
13
+ return { kind: 'unavailable' };
14
+ }
15
+ }
16
+ /** The public session exposes the main client. The transport and the family wire are internal. */
17
+ export function createPersonAccess(session, deps) {
18
+ const newSender = personSender(session, deps);
19
+ const asPerson = async (request, options, dispatch, canDeliver) => {
20
+ checkPath(request.path);
21
+ const signal = options?.signal;
22
+ if (signal?.aborted === true)
23
+ return { kind: 'aborted' };
24
+ const sender = newSender();
25
+ const url = new URL(deps.hosts.auth.replace(/\/+$/, '') + request.path);
26
+ for (const [key, value] of Object.entries(request.query ?? {}))
27
+ url.searchParams.set(key, value);
28
+ const init = request.method === 'POST'
29
+ ? { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(request.body ?? {}) }
30
+ : { method: 'GET', headers: { Accept: 'application/json' } };
31
+ const cut = new AbortController();
32
+ let byCaller = false;
33
+ const recipient = dispatch === 'keep_sent_answer' ? canDeliver : undefined;
34
+ const predicate = typeof dispatch === 'object' ? dispatch.isUnauthorized : undefined;
35
+ let inspected;
36
+ const isUnauthorized = predicate && (async (response) => {
37
+ const answer = await readAnswer(response);
38
+ if (answer.kind === 'answer' && predicate(answer))
39
+ return true;
40
+ inspected = answer; // Hand back the body already read, including a failed read.
41
+ return false;
42
+ });
43
+ let keepSent = false;
44
+ const abort = () => {
45
+ if (keepSent)
46
+ return;
47
+ byCaller = true;
48
+ cut.abort();
49
+ };
50
+ // A 401 issued no codes. The caller can stop waiting for the renewal or prevent its replay.
51
+ const beforeRenewal = () => {
52
+ if (dispatch !== 'keep_sent_answer')
53
+ return;
54
+ keepSent = false;
55
+ if (signal?.aborted)
56
+ abort();
57
+ };
58
+ const send = (input, init) => {
59
+ if (dispatch === 'keep_sent_answer')
60
+ keepSent = true;
61
+ else
62
+ dispatch?.onSend();
63
+ return deps.fetch(input, init);
64
+ };
65
+ const timer = setTimeout(() => cut.abort(), OPEN_DEADLINE_MS);
66
+ signal?.addEventListener('abort', abort, { once: true });
67
+ try {
68
+ const answer = await untilAborted(cut.signal, async () => {
69
+ const sent = await sender.send({
70
+ service: 'auth', endpoint: request.path, effect: request.method === 'GET' ? 'read' : 'write',
71
+ makeRequest: () => new Request(url, init), signal: cut.signal,
72
+ }, send, { beforeRenewal, canDeliver: recipient, isUnauthorized });
73
+ switch (sent.kind) {
74
+ case 'aborted':
75
+ case 'unavailable': return sent;
76
+ case 'cancelled': return sent.reason === 'session-closed' ? { kind: 'unavailable' } : { kind: 'signed_out' };
77
+ case 'no_token': return { kind: 'signed_out' };
78
+ case 'refused':
79
+ if (sent.reason === 'identification')
80
+ throw new TypeError('a bearer wire identification header cannot contain the access token');
81
+ throw new TypeError('a bearer wire request must go directly to its configured auth host');
82
+ case 'response': {
83
+ if (sent.response.status === 401) {
84
+ void sent.response.body?.cancel().catch(() => undefined);
85
+ return { kind: 'signed_out' };
86
+ }
87
+ return inspected ?? readAnswer(sent.response);
88
+ }
89
+ }
90
+ });
91
+ if (answer.kind === 'aborted')
92
+ return byCaller ? { kind: 'aborted' } : { kind: 'unavailable' };
93
+ const eligible = recipient && answer.kind === 'answer' && answer.status >= 200 && answer.status < 300
94
+ ? recipient() : sender.current();
95
+ return eligible ? answer : { kind: 'signed_out' };
96
+ }
97
+ finally {
98
+ clearTimeout(timer);
99
+ stopListening(signal, abort);
100
+ }
101
+ };
102
+ const scopes = new WeakMap();
103
+ function newClient(revision) {
104
+ const sender = newSender(revision, deps.report);
105
+ const transport = async (call, fetch = deps.fetch) => {
106
+ const sent = await sender.send(call, fetch);
107
+ // Transport exposes its established cancellation vocabulary. The wire reads the private reason.
108
+ if (sent.kind === 'cancelled')
109
+ return { kind: 'cancelled', reason: sent.reason === 'session-closed' ? 'aborted' : sent.reason };
110
+ return sent;
111
+ };
112
+ const flipstream = createFlipstreamFor({ app: deps.app, hosts: deps.hosts, transport }, DEFAULT_HOSTS, {
113
+ scopes,
114
+ freezeScoped: frozen,
115
+ current: sender.current,
116
+ isClosed: session.isClosed,
117
+ admit: call => {
118
+ if (session.isClosed())
119
+ throw new SessionClosedError(call);
120
+ sender.pinAtPress();
121
+ },
122
+ fetch: deps.fetch,
123
+ healthResponse: status => {
124
+ if (refusedRedirect(status))
125
+ deps.report({ path: new URL(deps.hosts.query + '/health').pathname, status });
126
+ },
127
+ allowLocalhostHttp: deps.allowLocalhostHttp,
128
+ });
129
+ return { matchesDisplay: sender.matchesDisplay, flipstream: frozen(flipstream) };
130
+ }
131
+ let client;
132
+ function currentClient() {
133
+ const shown = session.current();
134
+ const revision = shown.status === 'signed-in' ? shown.revision : undefined;
135
+ if (!client?.matchesDisplay(revision))
136
+ client = newClient(revision);
137
+ return client;
138
+ }
139
+ return {
140
+ wire: { ...createSessionWire(deps), asPerson },
141
+ get flipstream() { return currentClient().flipstream; },
142
+ };
143
+ }
144
+ //# sourceMappingURL=asPerson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asPerson.js","sourceRoot":"","sources":["../../src/first-party/asPerson.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAkE,MAAM,kBAAkB,CAAA;AACrI,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,E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;gBAC1D,MAAM,CAAC,UAAU,EAAE,CAAA;YACrB,CAAC;YACD,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,cAAc,EAAE,MAAM,CAAC,EAAE;gBACvB,IAAI,eAAe,CAAC,MAAM,CAAC;oBAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;YAC5G,CAAC;YACD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CACF,CAAA;QACD,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAA;IAClF,CAAC;IAED,IAAI,MAAgD,CAAA;IACpD,SAAS,aAAa;QACpB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;QAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;QAC1E,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC;YAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;QACnE,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO;QACL,IAAI,EAAE,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE;QAC9C,IAAI,UAAU,KAAK,OAAO,aAAa,EAAE,CAAC,UAAU,CAAA,CAAC,CAAC;KACvD,CAAA;AACH,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type { StorageLike } from './browser.js';
2
+ /** A login link lives 10 minutes at pulse-auth: an attempt redeems for as long. */
3
+ export declare const ATTEMPT_TTL_MS: number;
4
+ /**
5
+ * How long an attempt is kept: a day, only so a link opened late, or again after it was
6
+ * used, says "doesn't work any more" here, not "asked for in another browser" (24m, 1).
7
+ * Two times on this browser's clock are compared, never the token's own expiry.
8
+ */
9
+ export declare const ATTEMPT_KEEP_MS: number;
10
+ export interface Attempt {
11
+ /** Normalised, as it was sent: the address typed in this browser. */
12
+ readonly email: string;
13
+ /** The page to go to afterwards, as asked; read only through `safeNext`. */
14
+ readonly next: string | null;
15
+ /** When it was made, on this browser's clock. */
16
+ readonly at: number;
17
+ /** Which form asked: a sign-up link opens as "Finish signing up" (24k). */
18
+ readonly purpose: 'log-in' | 'sign-up';
19
+ /** Its link signed someone in here: opened again, it doesn't work any more. */
20
+ readonly used: boolean;
21
+ }
22
+ export type AttemptLookup = {
23
+ readonly kind: 'found';
24
+ readonly attempt: Attempt;
25
+ }
26
+ /** This browser asked, but over 10 minutes ago, or its link was used: dead either way. */
27
+ | {
28
+ readonly kind: 'spent';
29
+ readonly attempt: Attempt;
30
+ }
31
+ /** Not asked for in this browser in the last day (or the id isn't one we make). */
32
+ | {
33
+ readonly kind: 'missing';
34
+ };
35
+ /**
36
+ * Stores a new attempt under its own key and returns its id, or null when the browser
37
+ * refused the write: then no link may be asked for, as it could never be redeemed. One key
38
+ * per attempt: no shared map two tabs could each read and write back, so no attempt erases
39
+ * another. Expired ones are pruned on every write.
40
+ */
41
+ export declare function createAttempt(storage: StorageLike, attempt: Attempt, random: (bytes: Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer>): string | null;
42
+ export declare function findAttempt(storage: StorageLike, id: string, now: number): AttemptLookup;
43
+ /** A link that didn't go out: its attempt goes. */
44
+ export declare function removeAttempt(storage: StorageLike, id: string): void;
45
+ /**
46
+ * Its link signed someone in: the attempt is kept, marked used, so the link opened again
47
+ * says it doesn't work any more. Removed instead when the browser refuses the write.
48
+ */
49
+ export declare function spendAttempt(storage: StorageLike, id: string): void;
50
+ /**
51
+ * What `checkLanding` asks of a path, in the words its RangeErrors use: the landings', `authPath`'s
52
+ * and its own. Never a value: a landing names where a login token goes.
53
+ */
54
+ export declare const PLAIN_PATH_RULE = "a plain path on the page\u2019s own origin, as the browser writes it: starting with /, no query, no fragment, no . or .. segment, percent-encoded";
55
+ /**
56
+ * A landing is a plain path on the page's own origin (#464's review): one `/` first, never `//`
57
+ * or `/\` (which URL reads as another host), and no query or fragment, since pulse-auth appends
58
+ * the token to the query and a fragment would leave it out of the part `strip()` reads. And it is
59
+ * its own pathname: one the URL parser rewrites (`/vérifier`, `/log in`, `/a/../b`, `/a/./b`)
60
+ * would never equal the path the link lands on, so every link would read `no_token` (#475's
61
+ * round 1, finding 8). Anything else is a RangeError, since the link it builds carries a login
62
+ * token.
63
+ */
64
+ export declare function checkLanding(landing: string): void;
65
+ /**
66
+ * Where the mailed link lands: `<origin><landing>?attempt=<id>&email=<email>`, to which
67
+ * pulse-auth appends `token`. Built with URL and searchParams, never by joining strings: a
68
+ * `+` in an address must arrive as `%2B`, not as a space. The origin is the page's own, and
69
+ * `landing` a plain path on it (the console's is `/login/confirm`, see `checkLanding`).
70
+ */
71
+ export declare function continueUrl(origin: string, landing: string, attemptId: string, email: string): string;
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod';
2
+ /*
3
+ * A login attempt (A5, docs/architecture.md 2.2): asking for a link stores which address
4
+ * this browser asked for, and where to go afterwards. A link is redeemed only in the browser
5
+ * that holds its attempt, which closes login CSRF: an attacker can mail a victim their own
6
+ * link, but can't put their attempt in the victim's browser. `next` stays here and is never
7
+ * mailed.
8
+ */
9
+ const PREFIX = 'flipstream-auth:attempt:';
10
+ /** A login link lives 10 minutes at pulse-auth: an attempt redeems for as long. */
11
+ export const ATTEMPT_TTL_MS = 10 * 60_000;
12
+ /**
13
+ * How long an attempt is kept: a day, only so a link opened late, or again after it was
14
+ * used, says "doesn't work any more" here, not "asked for in another browser" (24m, 1).
15
+ * Two times on this browser's clock are compared, never the token's own expiry.
16
+ */
17
+ export const ATTEMPT_KEEP_MS = 24 * 3_600_000;
18
+ /** 128 random bits, as 32 lower-case hex digits. */
19
+ const ATTEMPT_ID = /^[0-9a-f]{32}$/;
20
+ const AttemptSchema = z.object({
21
+ email: z.string(),
22
+ next: z.string().nullable(),
23
+ at: z.number(),
24
+ purpose: z.enum(['log-in', 'sign-up']).default('log-in'),
25
+ used: z.boolean().default(false),
26
+ });
27
+ /**
28
+ * Stores a new attempt under its own key and returns its id, or null when the browser
29
+ * refused the write: then no link may be asked for, as it could never be redeemed. One key
30
+ * per attempt: no shared map two tabs could each read and write back, so no attempt erases
31
+ * another. Expired ones are pruned on every write.
32
+ */
33
+ export function createAttempt(storage, attempt, random) {
34
+ pruneAttempts(storage, attempt.at);
35
+ const id = Array.from(random(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, '0')).join('');
36
+ return storage.setItem(PREFIX + id, JSON.stringify(attempt)) ? id : null;
37
+ }
38
+ export function findAttempt(storage, id, now) {
39
+ if (!ATTEMPT_ID.test(id))
40
+ return { kind: 'missing' };
41
+ const attempt = parseAttempt(storage.getItem(PREFIX + id));
42
+ if (attempt === null || forgotten(attempt, now))
43
+ return { kind: 'missing' };
44
+ if (attempt.used || expired(attempt, now))
45
+ return { kind: 'spent', attempt };
46
+ return { kind: 'found', attempt };
47
+ }
48
+ /** A link that didn't go out: its attempt goes. */
49
+ export function removeAttempt(storage, id) {
50
+ if (ATTEMPT_ID.test(id))
51
+ storage.removeItem(PREFIX + id);
52
+ }
53
+ /**
54
+ * Its link signed someone in: the attempt is kept, marked used, so the link opened again
55
+ * says it doesn't work any more. Removed instead when the browser refuses the write.
56
+ */
57
+ export function spendAttempt(storage, id) {
58
+ if (!ATTEMPT_ID.test(id))
59
+ return;
60
+ const attempt = parseAttempt(storage.getItem(PREFIX + id));
61
+ if (attempt === null)
62
+ return;
63
+ if (!storage.setItem(PREFIX + id, JSON.stringify({ ...attempt, used: true }))) {
64
+ storage.removeItem(PREFIX + id);
65
+ }
66
+ }
67
+ function pruneAttempts(storage, now) {
68
+ for (const key of storage.keys()) {
69
+ if (!key.startsWith(PREFIX))
70
+ continue;
71
+ const attempt = parseAttempt(storage.getItem(key));
72
+ if (attempt === null || forgotten(attempt, now))
73
+ storage.removeItem(key);
74
+ }
75
+ }
76
+ /** Past its 10 minutes. A clock that went back counts too: an attempt from the future proves nothing. */
77
+ function expired(attempt, now) {
78
+ return now - attempt.at >= ATTEMPT_TTL_MS || attempt.at > now;
79
+ }
80
+ /** Past the day it is kept for. */
81
+ function forgotten(attempt, now) {
82
+ return now - attempt.at >= ATTEMPT_KEEP_MS;
83
+ }
84
+ function parseAttempt(raw) {
85
+ if (raw === null)
86
+ return null;
87
+ let json;
88
+ try {
89
+ json = JSON.parse(raw);
90
+ }
91
+ catch {
92
+ return null;
93
+ }
94
+ const parsed = AttemptSchema.safeParse(json);
95
+ return parsed.success ? parsed.data : null;
96
+ }
97
+ /**
98
+ * What `checkLanding` asks of a path, in the words its RangeErrors use: the landings', `authPath`'s
99
+ * and its own. Never a value: a landing names where a login token goes.
100
+ */
101
+ export const PLAIN_PATH_RULE = 'a plain path on the page’s own origin, as the browser writes it: starting with /, no query, no fragment, no . or .. segment, percent-encoded';
102
+ /**
103
+ * A landing is a plain path on the page's own origin (#464's review): one `/` first, never `//`
104
+ * or `/\` (which URL reads as another host), and no query or fragment, since pulse-auth appends
105
+ * the token to the query and a fragment would leave it out of the part `strip()` reads. And it is
106
+ * its own pathname: one the URL parser rewrites (`/vérifier`, `/log in`, `/a/../b`, `/a/./b`)
107
+ * would never equal the path the link lands on, so every link would read `no_token` (#475's
108
+ * round 1, finding 8). Anything else is a RangeError, since the link it builds carries a login
109
+ * token.
110
+ */
111
+ export function checkLanding(landing) {
112
+ if (!/^\/(?![/\\])[^?#\\\t\n\r]*$/.test(landing) || new URL(landing, 'https://x.invalid').pathname !== landing) {
113
+ throw new RangeError(`A link lands on ${PLAIN_PATH_RULE}.`);
114
+ }
115
+ }
116
+ /**
117
+ * Where the mailed link lands: `<origin><landing>?attempt=<id>&email=<email>`, to which
118
+ * pulse-auth appends `token`. Built with URL and searchParams, never by joining strings: a
119
+ * `+` in an address must arrive as `%2B`, not as a space. The origin is the page's own, and
120
+ * `landing` a plain path on it (the console's is `/login/confirm`, see `checkLanding`).
121
+ */
122
+ export function continueUrl(origin, landing, attemptId, email) {
123
+ checkLanding(landing);
124
+ const url = new URL(landing, origin);
125
+ if (url.origin !== new URL(origin).origin) {
126
+ throw new RangeError('A link lands on a path of the page’s own origin.');
127
+ }
128
+ url.searchParams.set('attempt', attemptId);
129
+ url.searchParams.set('email', email);
130
+ return url.toString();
131
+ }
132
+ //# sourceMappingURL=attempts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attempts.js","sourceRoot":"","sources":["../../src/first-party/attempts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;GAMG;AAEH,MAAM,MAAM,GAAG,0BAA0B,CAAA;AAEzC,mFAAmF;AACnF,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,MAAM,CAAA;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,SAAS,CAAA;AAE7C,oDAAoD;AACpD,MAAM,UAAU,GAAG,gBAAgB,CAAA;AAenC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACxD,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACjC,CAAC,CAAA;AASF;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAoB,EACpB,OAAgB,EAChB,MAAmE;IAEnE,aAA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GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACpC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;AACvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The mark on a refusal of the proxy's own, so the session never reads it as pulse-auth's.
3
+ * One module, imported by the session and by the proxy. It imports nothing.
4
+ */
5
+ export declare const AUTH_PROXY_REFUSAL: "X-Auth-Proxy";
6
+ /** The only value of {@link AUTH_PROXY_REFUSAL} the session treats as the proxy's own refusal. */
7
+ export declare const AUTH_PROXY_REFUSAL_VALUE: "refused";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The mark on a refusal of the proxy's own, so the session never reads it as pulse-auth's.
3
+ * One module, imported by the session and by the proxy. It imports nothing.
4
+ */
5
+ export const AUTH_PROXY_REFUSAL = 'X-Auth-Proxy';
6
+ /** The only value of {@link AUTH_PROXY_REFUSAL} the session treats as the proxy's own refusal. */
7
+ export const AUTH_PROXY_REFUSAL_VALUE = 'refused';
8
+ //# sourceMappingURL=authProxyMark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authProxyMark.js","sourceRoot":"","sources":["../../src/first-party/authProxyMark.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAuB,CAAA;AAEzD,kGAAkG;AAClG,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAkB,CAAA"}
@@ -0,0 +1,55 @@
1
+ /** The slice of `navigator.locks` the session uses. */
2
+ export interface LockManagerLike {
3
+ request<T>(name: string, options: {
4
+ readonly signal: AbortSignal;
5
+ }, callback: () => Promise<T>): Promise<T>;
6
+ }
7
+ /** The slice of `localStorage` the session uses. It never throws (private mode, quota). */
8
+ export interface StorageLike {
9
+ getItem(key: string): string | null;
10
+ /** Whether the browser took the write: a full quota or blocked site data refuse it. */
11
+ setItem(key: string, value: string): boolean;
12
+ removeItem(key: string): void;
13
+ /** Every key, for pruning expired attempts. */
14
+ keys(): readonly string[];
15
+ }
16
+ /** The slice of a `BroadcastChannel` the session uses. */
17
+ export interface ChannelLike {
18
+ postMessage(message: unknown): void;
19
+ addEventListener(type: 'message', listener: (event: {
20
+ readonly data: unknown;
21
+ }) => void): void;
22
+ removeEventListener(type: 'message', listener: (event: {
23
+ readonly data: unknown;
24
+ }) => void): void;
25
+ close(): void;
26
+ }
27
+ /**
28
+ * Where a page subscriber's exception goes. A page has `reportError`, which is also what a
29
+ * listener that throws does there. Outside a page there is none, so the same exception is
30
+ * thrown again from a fresh microtask, as Node does for a listener (SDK-D1915). Either way
31
+ * it stays out of the session's own report.
32
+ */
33
+ export declare function subscriberErrorReporter(host: {
34
+ reportError?: (cause: unknown) => void;
35
+ queueMicrotask: (task: () => void) => void;
36
+ }): (cause: unknown) => void;
37
+ /**
38
+ * localStorage behind StorageLike, or null when this browser won't let the page use it
39
+ * (blocked site data, or none at all): such a browser can't sign in (§2.3).
40
+ */
41
+ export declare function browserStorage(): StorageLike | null;
42
+ /**
43
+ * This tab's sessionStorage behind StorageLike, or null without it: where a staff member's
44
+ * choice of customer is kept, per tab (§2.7). A blocked getter is null, as localStorage is.
45
+ */
46
+ export declare function browserTabStorage(): StorageLike | null;
47
+ /** `navigator.locks`, or null where there are no Web Locks (Safari before 15.4). */
48
+ export declare function browserLocks(): LockManagerLike | null;
49
+ /**
50
+ * The tabs' channel, or null when this browser has no BroadcastChannel or refuses to open
51
+ * one. Firefox throws SecurityError from the constructor when storage is denied. That is
52
+ * no channel, the same as a missing BroadcastChannel: the shared state still works, and
53
+ * creating the session does not throw (SDK-D1940).
54
+ */
55
+ export declare function browserChannel(name: string): ChannelLike | null;