@flipstream/sdk 0.14.0 → 0.16.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 (225) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +95 -1
  3. package/dist/api/datasets.js +8 -8
  4. package/dist/api/datasets.js.map +1 -1
  5. package/dist/api/log.js +6 -10
  6. package/dist/api/log.js.map +1 -1
  7. package/dist/api/pathArgument.d.ts +7 -0
  8. package/dist/api/pathArgument.js +12 -0
  9. package/dist/api/pathArgument.js.map +1 -0
  10. package/dist/auth/transport.d.ts +6 -2
  11. package/dist/auth/transport.js +5 -3
  12. package/dist/auth/transport.js.map +1 -1
  13. package/dist/core/call.d.ts +4 -0
  14. package/dist/core/call.js +7 -1
  15. package/dist/core/call.js.map +1 -1
  16. package/dist/core/fetch.d.ts +20 -1
  17. package/dist/core/fetch.js +50 -3
  18. package/dist/core/fetch.js.map +1 -1
  19. package/dist/core/hosts.d.ts +11 -0
  20. package/dist/core/hosts.js +13 -0
  21. package/dist/core/hosts.js.map +1 -0
  22. package/dist/core/identify.d.ts +6 -2
  23. package/dist/core/identify.js +16 -12
  24. package/dist/core/identify.js.map +1 -1
  25. package/dist/core/result.d.ts +1 -1
  26. package/dist/core/shared.d.ts +2 -0
  27. package/dist/core/shared.js +1 -0
  28. package/dist/core/shared.js.map +1 -1
  29. package/dist/core/signal.d.ts +7 -0
  30. package/dist/core/signal.js +9 -0
  31. package/dist/core/signal.js.map +1 -1
  32. package/dist/first-party/asPerson.d.ts +13 -0
  33. package/dist/first-party/asPerson.js +144 -0
  34. package/dist/first-party/asPerson.js.map +1 -0
  35. package/dist/first-party/attempts.d.ts +71 -0
  36. package/dist/first-party/attempts.js +132 -0
  37. package/dist/first-party/attempts.js.map +1 -0
  38. package/dist/first-party/authProxyMark.d.ts +10 -0
  39. package/dist/first-party/authProxyMark.js +11 -0
  40. package/dist/first-party/authProxyMark.js.map +1 -0
  41. package/dist/first-party/browser.d.ts +55 -0
  42. package/dist/first-party/browser.js +137 -0
  43. package/dist/first-party/browser.js.map +1 -0
  44. package/dist/first-party/browserSession.d.ts +95 -0
  45. package/dist/first-party/browserSession.js +242 -0
  46. package/dist/first-party/browserSession.js.map +1 -0
  47. package/dist/first-party/calls/consent.d.ts +89 -0
  48. package/dist/first-party/calls/consent.js +174 -0
  49. package/dist/first-party/calls/consent.js.map +1 -0
  50. package/dist/first-party/calls/device.d.ts +97 -0
  51. package/dist/first-party/calls/device.js +133 -0
  52. package/dist/first-party/calls/device.js.map +1 -0
  53. package/dist/first-party/calls/invitation.d.ts +244 -0
  54. package/dist/first-party/calls/invitation.js +258 -0
  55. package/dist/first-party/calls/invitation.js.map +1 -0
  56. package/dist/first-party/calls/logIn.d.ts +61 -0
  57. package/dist/first-party/calls/logIn.js +48 -0
  58. package/dist/first-party/calls/logIn.js.map +1 -0
  59. package/dist/first-party/calls/reset.d.ts +61 -0
  60. package/dist/first-party/calls/reset.js +163 -0
  61. package/dist/first-party/calls/reset.js.map +1 -0
  62. package/dist/first-party/calls/signUp.d.ts +21 -0
  63. package/dist/first-party/calls/signUp.js +72 -0
  64. package/dist/first-party/calls/signUp.js.map +1 -0
  65. package/dist/first-party/calls/twoStepSetup.d.ts +78 -0
  66. package/dist/first-party/calls/twoStepSetup.js +168 -0
  67. package/dist/first-party/calls/twoStepSetup.js.map +1 -0
  68. package/dist/first-party/claims.d.ts +88 -0
  69. package/dist/first-party/claims.js +181 -0
  70. package/dist/first-party/claims.js.map +1 -0
  71. package/dist/first-party/enrollment.d.ts +10 -0
  72. package/dist/first-party/enrollment.js +44 -0
  73. package/dist/first-party/enrollment.js.map +1 -0
  74. package/dist/first-party/entry.d.ts +573 -0
  75. package/dist/first-party/entry.js +582 -0
  76. package/dist/first-party/entry.js.map +1 -0
  77. package/dist/first-party/hooks.d.ts +81 -0
  78. package/dist/first-party/hooks.js +19 -0
  79. package/dist/first-party/hooks.js.map +1 -0
  80. package/dist/first-party/http.d.ts +191 -0
  81. package/dist/first-party/http.js +364 -0
  82. package/dist/first-party/http.js.map +1 -0
  83. package/dist/first-party/index.d.ts +14 -0
  84. package/dist/first-party/index.js +3 -0
  85. package/dist/first-party/index.js.map +1 -0
  86. package/dist/first-party/landed.d.ts +32 -0
  87. package/dist/first-party/landed.js +50 -0
  88. package/dist/first-party/landed.js.map +1 -0
  89. package/dist/first-party/landedProof.d.ts +12 -0
  90. package/dist/first-party/landedProof.js +20 -0
  91. package/dist/first-party/landedProof.js.map +1 -0
  92. package/dist/first-party/linkToken.d.ts +15 -0
  93. package/dist/first-party/linkToken.js +28 -0
  94. package/dist/first-party/linkToken.js.map +1 -0
  95. package/dist/first-party/links.d.ts +100 -0
  96. package/dist/first-party/links.js +84 -0
  97. package/dist/first-party/links.js.map +1 -0
  98. package/dist/first-party/locks.d.ts +36 -0
  99. package/dist/first-party/locks.js +64 -0
  100. package/dist/first-party/locks.js.map +1 -0
  101. package/dist/first-party/personTransport.d.ts +38 -0
  102. package/dist/first-party/personTransport.js +177 -0
  103. package/dist/first-party/personTransport.js.map +1 -0
  104. package/dist/first-party/proxy/app.d.ts +32 -0
  105. package/dist/first-party/proxy/app.js +94 -0
  106. package/dist/first-party/proxy/app.js.map +1 -0
  107. package/dist/first-party/proxy/bound.d.ts +5 -0
  108. package/dist/first-party/proxy/bound.js +13 -0
  109. package/dist/first-party/proxy/bound.js.map +1 -0
  110. package/dist/first-party/proxy/cases.d.ts +71 -0
  111. package/dist/first-party/proxy/cases.js +411 -0
  112. package/dist/first-party/proxy/cases.js.map +1 -0
  113. package/dist/first-party/proxy/decide.d.ts +31 -0
  114. package/dist/first-party/proxy/decide.js +139 -0
  115. package/dist/first-party/proxy/decide.js.map +1 -0
  116. package/dist/first-party/proxy/freeze.d.ts +2 -0
  117. package/dist/first-party/proxy/freeze.js +10 -0
  118. package/dist/first-party/proxy/freeze.js.map +1 -0
  119. package/dist/first-party/proxy/handler.d.ts +23 -0
  120. package/dist/first-party/proxy/handler.js +190 -0
  121. package/dist/first-party/proxy/handler.js.map +1 -0
  122. package/dist/first-party/proxy/headers.d.ts +7 -0
  123. package/dist/first-party/proxy/headers.js +20 -0
  124. package/dist/first-party/proxy/headers.js.map +1 -0
  125. package/dist/first-party/proxy/hop.d.ts +9 -0
  126. package/dist/first-party/proxy/hop.js +37 -0
  127. package/dist/first-party/proxy/hop.js.map +1 -0
  128. package/dist/first-party/proxy/host.d.ts +5 -0
  129. package/dist/first-party/proxy/host.js +11 -0
  130. package/dist/first-party/proxy/host.js.map +1 -0
  131. package/dist/first-party/proxy/index.d.ts +7 -0
  132. package/dist/first-party/proxy/index.js +6 -0
  133. package/dist/first-party/proxy/index.js.map +1 -0
  134. package/dist/first-party/proxy/pass-back.d.ts +26 -0
  135. package/dist/first-party/proxy/pass-back.js +47 -0
  136. package/dist/first-party/proxy/pass-back.js.map +1 -0
  137. package/dist/first-party/proxy/paths.d.ts +15 -0
  138. package/dist/first-party/proxy/paths.js +34 -0
  139. package/dist/first-party/proxy/paths.js.map +1 -0
  140. package/dist/first-party/proxy/shown.d.ts +5 -0
  141. package/dist/first-party/proxy/shown.js +16 -0
  142. package/dist/first-party/proxy/shown.js.map +1 -0
  143. package/dist/first-party/proxy/stand-in.d.ts +49 -0
  144. package/dist/first-party/proxy/stand-in.js +341 -0
  145. package/dist/first-party/proxy/stand-in.js.map +1 -0
  146. package/dist/first-party/report.d.ts +56 -0
  147. package/dist/first-party/report.js +38 -0
  148. package/dist/first-party/report.js.map +1 -0
  149. package/dist/first-party/result.d.ts +150 -0
  150. package/dist/first-party/result.js +40 -0
  151. package/dist/first-party/result.js.map +1 -0
  152. package/dist/first-party/session/cell.d.ts +201 -0
  153. package/dist/first-party/session/cell.js +103 -0
  154. package/dist/first-party/session/cell.js.map +1 -0
  155. package/dist/first-party/session/closed.d.ts +11 -0
  156. package/dist/first-party/session/closed.js +15 -0
  157. package/dist/first-party/session/closed.js.map +1 -0
  158. package/dist/first-party/session/index.d.ts +3 -0
  159. package/dist/first-party/session/index.js +3 -0
  160. package/dist/first-party/session/index.js.map +1 -0
  161. package/dist/first-party/session/logout.d.ts +102 -0
  162. package/dist/first-party/session/logout.js +526 -0
  163. package/dist/first-party/session/logout.js.map +1 -0
  164. package/dist/first-party/session/owed.d.ts +105 -0
  165. package/dist/first-party/session/owed.js +128 -0
  166. package/dist/first-party/session/owed.js.map +1 -0
  167. package/dist/first-party/session/refresh.d.ts +19 -0
  168. package/dist/first-party/session/refresh.js +236 -0
  169. package/dist/first-party/session/refresh.js.map +1 -0
  170. package/dist/first-party/session/results.d.ts +38 -0
  171. package/dist/first-party/session/results.js +74 -0
  172. package/dist/first-party/session/results.js.map +1 -0
  173. package/dist/first-party/session/session.d.ts +2 -0
  174. package/dist/first-party/session/session.js +376 -0
  175. package/dist/first-party/session/session.js.map +1 -0
  176. package/dist/first-party/session/shared.d.ts +34 -0
  177. package/dist/first-party/session/shared.js +145 -0
  178. package/dist/first-party/session/shared.js.map +1 -0
  179. package/dist/first-party/session/sharedSignal.d.ts +27 -0
  180. package/dist/first-party/session/sharedSignal.js +55 -0
  181. package/dist/first-party/session/sharedSignal.js.map +1 -0
  182. package/dist/first-party/session/signIn.d.ts +48 -0
  183. package/dist/first-party/session/signIn.js +340 -0
  184. package/dist/first-party/session/signIn.js.map +1 -0
  185. package/dist/first-party/session/signInThrough.d.ts +6 -0
  186. package/dist/first-party/session/signInThrough.js +144 -0
  187. package/dist/first-party/session/signInThrough.js.map +1 -0
  188. package/dist/first-party/session/sync.d.ts +17 -0
  189. package/dist/first-party/session/sync.js +174 -0
  190. package/dist/first-party/session/sync.js.map +1 -0
  191. package/dist/first-party/session/tokens.d.ts +18 -0
  192. package/dist/first-party/session/tokens.js +64 -0
  193. package/dist/first-party/session/tokens.js.map +1 -0
  194. package/dist/first-party/session/types.d.ts +270 -0
  195. package/dist/first-party/session/types.js +3 -0
  196. package/dist/first-party/session/types.js.map +1 -0
  197. package/dist/first-party/sessionWire.d.ts +31 -0
  198. package/dist/first-party/sessionWire.js +91 -0
  199. package/dist/first-party/sessionWire.js.map +1 -0
  200. package/dist/first-party/signInHooks.d.ts +85 -0
  201. package/dist/first-party/signInHooks.js +2 -0
  202. package/dist/first-party/signInHooks.js.map +1 -0
  203. package/dist/first-party/state.d.ts +71 -0
  204. package/dist/first-party/state.js +55 -0
  205. package/dist/first-party/state.js.map +1 -0
  206. package/dist/first-party/strip.d.ts +1 -0
  207. package/dist/first-party/strip.js +8 -0
  208. package/dist/first-party/strip.js.map +1 -0
  209. package/dist/first-party/twoStepLock.d.ts +26 -0
  210. package/dist/first-party/twoStepLock.js +58 -0
  211. package/dist/first-party/twoStepLock.js.map +1 -0
  212. package/dist/first-party/twoStepSession.d.ts +21 -0
  213. package/dist/first-party/twoStepSession.js +31 -0
  214. package/dist/first-party/twoStepSession.js.map +1 -0
  215. package/dist/first-party/wire.d.ts +63 -0
  216. package/dist/first-party/wire.js +5 -0
  217. package/dist/first-party/wire.js.map +1 -0
  218. package/dist/flipstream.d.ts +80 -19
  219. package/dist/flipstream.js +121 -36
  220. package/dist/flipstream.js.map +1 -1
  221. package/dist/node/session.js +3 -1
  222. package/dist/node/session.js.map +1 -1
  223. package/dist/version.gen.js +1 -1
  224. package/docs/first-party.md +300 -0
  225. package/package.json +34 -5
@@ -0,0 +1,573 @@
1
+ import type { TwoStepSetup, TwoStepStatus } from './calls/twoStepSetup.js';
2
+ import type { Flipstream, Hosts } from '../flipstream.js';
3
+ import { type BrowserSession as Internal } from './browserSession.js';
4
+ import { type AskingConsent, type ConsentRequest, type ConsentStop } from './calls/consent.js';
5
+ import { type LogInRequest, type LogInStop } from './calls/logIn.js';
6
+ import { type OpenedReset } from './calls/reset.js';
7
+ import { type AcceptInvitation, type Invitation, type OpenedInvitation } from './calls/invitation.js';
8
+ import { type SignInSetup, type SignInStep } from './hooks.js';
9
+ import { type LandedTokens } from './landed.js';
10
+ import { type SignupAttemptDeps } from './links.js';
11
+ import { type SessionReport } from './report.js';
12
+ import { type AsPerson, type CallOptions, type Refused, type Result, type Sent, type ThroughProxy } from './result.js';
13
+ import type { AuthSession } from './session/index.js';
14
+ import { type DeviceAnswerStop, type DeviceRequest, type DeviceStop } from './calls/device.js';
15
+ import type { Wire } from './wire.js';
16
+ /**
17
+ * What is known about the person in this browser, one meaning per kind.
18
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
19
+ */
20
+ export type SessionState =
21
+ /**
22
+ * The first answer isn't in yet: the refresh cookie decides.
23
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
24
+ */
25
+ {
26
+ readonly kind: 'restoring';
27
+ } | {
28
+ readonly kind: 'signed_out';
29
+ } | {
30
+ readonly kind: 'signed_in';
31
+ readonly user_id: string;
32
+ readonly email: string;
33
+ /**
34
+ * Rises each time who is signed in, or what their token says they are (organization, roles), changes, and with each new sign-in.
35
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
36
+ */
37
+ readonly revision: number;
38
+ }
39
+ /**
40
+ * pulse-auth can't be reached now.
41
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
42
+ */
43
+ | {
44
+ readonly kind: 'unavailable';
45
+ readonly retry_in_ms: number;
46
+ }
47
+ /**
48
+ * pulse-auth answered outside its contract, or the app's own proxy refused: reported.
49
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
50
+ */
51
+ | {
52
+ readonly kind: 'broken';
53
+ readonly status: number;
54
+ }
55
+ /**
56
+ * This browser lacks what the session needs (Web Locks, localStorage): nobody can sign in.
57
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
58
+ */
59
+ | {
60
+ readonly kind: 'unsupported';
61
+ };
62
+ /**
63
+ * Not a result: read from the address and this browser's attempt, with nothing sent.
64
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
65
+ */
66
+ export type OpenedLink = {
67
+ readonly kind: 'ready';
68
+ readonly email: string;
69
+ readonly purpose: 'sign_in' | 'sign_up';
70
+ /**
71
+ * Where the person was going, as given to `requestLink` or `requestSignUp`.
72
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
73
+ */
74
+ readonly next: string | null;
75
+ }
76
+ /**
77
+ * This browser already used this link, or asked for it over 10 minutes ago.
78
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
79
+ */
80
+ | {
81
+ readonly kind: 'spent';
82
+ readonly email: string;
83
+ readonly purpose: 'sign_in' | 'sign_up';
84
+ readonly next: string | null;
85
+ }
86
+ /**
87
+ * Asked for in another browser, or not asked for at all.
88
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
89
+ */
90
+ | {
91
+ readonly kind: 'other_browser';
92
+ }
93
+ /**
94
+ * The token's address, the address shown and the attempt's differ.
95
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
96
+ */
97
+ | {
98
+ readonly kind: 'invalid';
99
+ }
100
+ /**
101
+ * No link's token on this page: off the landing, or a reload after the token was taken.
102
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
103
+ */
104
+ | {
105
+ readonly kind: 'no_token';
106
+ }
107
+ /**
108
+ * An invitation's login link: send the person to the invitation page.
109
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
110
+ */
111
+ | {
112
+ readonly kind: 'invitation';
113
+ };
114
+ /**
115
+ * A link `redeem` takes: only one `openedLink()` gave.
116
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
117
+ */
118
+ export type ReadyLink = Extract<OpenedLink, {
119
+ readonly kind: 'ready';
120
+ }>;
121
+ /**
122
+ * A link this browser asked for that no longer works: `requestLinkAgain` sends a new one to its address.
123
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
124
+ */
125
+ export type SpentLink = Extract<OpenedLink, {
126
+ readonly kind: 'spent';
127
+ }>;
128
+ /**
129
+ * Where a redeem stops, short of a sign-in step.
130
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#redeem
131
+ */
132
+ export type RedeemStop = ThroughProxy
133
+ /**
134
+ * The link is used up: pulse-auth refused it (expired, or used elsewhere), or its code step ran out or locked.
135
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#redeem
136
+ */
137
+ | {
138
+ readonly kind: 'dead_link';
139
+ } | {
140
+ readonly kind: 'no_account';
141
+ } | {
142
+ readonly kind: 'inactive';
143
+ }
144
+ /**
145
+ * A sign-in or sign-out overtook this press.
146
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#redeem
147
+ */
148
+ | {
149
+ readonly kind: 'superseded';
150
+ };
151
+ /**
152
+ * A code's own refusals.
153
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#verifytwostep
154
+ */
155
+ export type TwoStepStop = {
156
+ readonly kind: 'wrong_code';
157
+ }
158
+ /**
159
+ * Too many wrong codes.
160
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#verifytwostep
161
+ */
162
+ | {
163
+ readonly kind: 'locked';
164
+ readonly until: number;
165
+ };
166
+ /**
167
+ * What a code's check can stop at.
168
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#verifytwostep
169
+ */
170
+ export type TwoStepVerifyStop = Exclude<ThroughProxy, {
171
+ readonly kind: 'aborted';
172
+ }> | Refused | TwoStepStop
173
+ /**
174
+ * The code was not sent, so press again.
175
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#verifytwostep
176
+ */
177
+ | {
178
+ readonly kind: 'not_sent';
179
+ }
180
+ /**
181
+ * The challenge ran out, or none is pending (a reload): start the sign-in again.
182
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#verifytwostep
183
+ */
184
+ | {
185
+ readonly kind: 'expired';
186
+ } | {
187
+ readonly kind: 'no_account';
188
+ } | {
189
+ readonly kind: 'inactive';
190
+ }
191
+ /**
192
+ * Issued setup codes are returned only for a signed-out browser or the same confirmed user.
193
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#verifytwostep
194
+ */
195
+ | {
196
+ readonly kind: 'superseded';
197
+ readonly backup_codes: readonly string[] | null;
198
+ };
199
+ /**
200
+ * What pulse-auth said about a sign-out (SDK-D1904).
201
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#signout
202
+ */
203
+ export type SignOutTold =
204
+ /**
205
+ * pulse-auth ended the session: told by this tab, or by another tab first.
206
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#signout
207
+ */
208
+ {
209
+ readonly kind: 'confirmed';
210
+ }
211
+ /**
212
+ * Not confirmed: the sign-out stays pending and is sent again when the browser next reaches pulse-auth.
213
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#signout
214
+ */
215
+ | {
216
+ readonly kind: 'unconfirmed';
217
+ readonly reason: 'unavailable' | 'refused' | 'invalid';
218
+ }
219
+ /**
220
+ * The record moved on since this sign-out: a sign-in, in any tab, or rarely a renewal by a tab that hadn't heard of it.
221
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#signout
222
+ */
223
+ | {
224
+ readonly kind: 'superseded';
225
+ }
226
+ /**
227
+ * This browser lacks what the session needs: nobody was signed in, nothing was sent.
228
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#signout
229
+ */
230
+ | {
231
+ readonly kind: 'unsupported';
232
+ };
233
+ /**
234
+ * `createBrowserSession`'s options, each checked when the session is made.
235
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
236
+ */
237
+ export interface BrowserSessionOptions {
238
+ /**
239
+ * Which app this is: `{ name, version }`, each 1 to 64 of RFC 9110's token characters, as the main entry's `createFlipstream` takes it.
240
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
241
+ */
242
+ readonly app: {
243
+ readonly name: string;
244
+ readonly version: string;
245
+ };
246
+ /**
247
+ * The same-origin path the app's own server forwards to pulse-auth, `/auth` by default.
248
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
249
+ */
250
+ readonly authPath?: string;
251
+ /**
252
+ * Where a mailed login link lands: a plain path of this page's origin, such as `/login-link`.
253
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
254
+ */
255
+ readonly landing: string;
256
+ /**
257
+ * Where an invitation's link lands.
258
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
259
+ */
260
+ readonly invitationLanding?: string;
261
+ /**
262
+ * Where a reset link lands.
263
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
264
+ */
265
+ readonly resetLanding?: string;
266
+ /**
267
+ * Every host the main client can use is checked here, including the console for hand-offs.
268
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
269
+ */
270
+ readonly hosts?: Hosts;
271
+ /**
272
+ * What the app's operator should know: an answer outside the contract, a browser fault, a bug.
273
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
274
+ */
275
+ readonly onReport?: (report: SessionReport) => void;
276
+ }
277
+ /**
278
+ * The session and the calls a person signs in and out with.
279
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
280
+ */
281
+ export interface BrowserSession {
282
+ /**
283
+ * Reads the authorisation request from this page's current address, including after close().
284
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#consentrequest
285
+ */
286
+ readonly consentRequest: () => ConsentRequest;
287
+ /**
288
+ * Approves the request this session showed.
289
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#approveconsent-denyconsent
290
+ */
291
+ readonly approveConsent: (request: AskingConsent, options?: CallOptions) => Promise<Result<{
292
+ readonly redirect_to: string;
293
+ }, ConsentStop>>;
294
+ /**
295
+ * Denies the request this session showed and returns the checked callback carrying the refusal.
296
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#approveconsent-denyconsent
297
+ */
298
+ readonly denyConsent: (request: AskingConsent, options?: CallOptions) => Promise<Result<{
299
+ readonly redirect_to: string;
300
+ }, ConsentStop>>;
301
+ /**
302
+ * Reads the signed-in person's two-step settings and remaining backup-code count.
303
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#twostepstatus
304
+ */
305
+ readonly twoStepStatus: (options?: CallOptions) => Promise<Result<TwoStepStatus, AsPerson>>;
306
+ /**
307
+ * Starts authenticator enrollment for the signed-in person on the Security page.
308
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#starttwostepsetup
309
+ */
310
+ readonly startTwoStepSetup: (options?: CallOptions) => Promise<Result<TwoStepSetup, AsPerson | {
311
+ readonly kind: 'already_on';
312
+ }>>;
313
+ /**
314
+ * Starts enrollment for the exact setup returned by this session's logIn or redeem.
315
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#startsignintwostepsetup
316
+ */
317
+ readonly startSignInTwoStepSetup: (setup: SignInSetup, options?: CallOptions) => Promise<Result<TwoStepSetup, Sent | {
318
+ readonly kind: 'expired';
319
+ } | {
320
+ readonly kind: 'superseded';
321
+ }>>;
322
+ /**
323
+ * The first code turns two-step on and gives ten backup codes once.
324
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#confirmtwostepsetup
325
+ */
326
+ readonly confirmTwoStepSetup: (entry: {
327
+ readonly code: string;
328
+ }, options?: CallOptions) => Promise<Result<{
329
+ readonly backup_codes: readonly string[];
330
+ }, AsPerson | Refused | TwoStepStop | {
331
+ readonly kind: 'not_started';
332
+ }>>;
333
+ /**
334
+ * A current code replaces the old set.
335
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#newbackupcodes
336
+ */
337
+ readonly newBackupCodes: (entry: {
338
+ readonly code: string;
339
+ }, options?: CallOptions) => Promise<Result<{
340
+ readonly backup_codes: readonly string[];
341
+ }, AsPerson | Refused | TwoStepStop | {
342
+ readonly kind: 'not_on';
343
+ }>>;
344
+ /**
345
+ * Turns off two-step for the signed-in person with a current code, when the deployment permits it.
346
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#turnofftwostep
347
+ */
348
+ readonly turnOffTwoStep: (entry: {
349
+ readonly code: string;
350
+ }, options?: CallOptions) => Promise<Result<{
351
+ readonly kind: 'off';
352
+ }, AsPerson | Refused | TwoStepStop | {
353
+ readonly kind: 'not_on';
354
+ } | {
355
+ readonly kind: 'required';
356
+ }>>;
357
+ /**
358
+ * The main SDK as the person this page shows.
359
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#flipstream
360
+ */
361
+ readonly flipstream: Flipstream;
362
+ /**
363
+ * Asks pulse-admin to email a sign-up link that opens here with the `next` given.
364
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#requestsignup
365
+ */
366
+ readonly requestSignUp: (request: {
367
+ readonly email: string;
368
+ readonly first_name: string;
369
+ readonly last_name: string;
370
+ readonly organization: string;
371
+ readonly accepted: {
372
+ readonly terms_version: string;
373
+ readonly privacy_version: string;
374
+ };
375
+ readonly next: string | null;
376
+ }, options?: CallOptions) => Promise<Result<{
377
+ readonly email: string;
378
+ }, Sent | Refused |
379
+ /**
380
+ * The browser could not store this attempt.
381
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#requestsignup
382
+ */
383
+ {
384
+ readonly kind: 'unsupported';
385
+ }>>;
386
+ /**
387
+ * Asks for a reset link; known and unknown addresses get the same answer.
388
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#requestpasswordreset
389
+ */
390
+ readonly requestPasswordReset: (request: {
391
+ readonly email: string;
392
+ }, options?: CallOptions) => Promise<Result<{
393
+ readonly email: string;
394
+ }, Sent | Refused>>;
395
+ /**
396
+ * Reads the reset link on this page, including after close().
397
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedreset
398
+ */
399
+ readonly openedReset: () => OpenedReset;
400
+ /**
401
+ * Sets the link owner's password as typed and ends their sessions.
402
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#setpassword
403
+ */
404
+ readonly setPassword: (
405
+ /**
406
+ * The types allow other ready links here.
407
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#setpassword
408
+ */
409
+ reset: Extract<OpenedReset, {
410
+ readonly kind: 'ready';
411
+ }>, entry: {
412
+ readonly password: string;
413
+ }, options?: CallOptions) => Promise<Result<{
414
+ readonly kind: 'password_set';
415
+ }, Sent | Refused
416
+ /**
417
+ * Expired, or used before.
418
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#setpassword
419
+ */
420
+ | {
421
+ readonly kind: 'dead_link';
422
+ }
423
+ /**
424
+ * pulse-auth wants at least 8 characters.
425
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#setpassword
426
+ */
427
+ | {
428
+ readonly kind: 'password_too_short';
429
+ } | {
430
+ readonly kind: 'inactive';
431
+ }>>;
432
+ /**
433
+ * Signs in with an address and a password (sdk#467): `signed_in`, or a two-step code wanted.
434
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#login
435
+ */
436
+ readonly logIn: (request: LogInRequest, options?: CallOptions) => Promise<Result<SignInStep, LogInStop>>;
437
+ /**
438
+ * Whether the page was opened on `invitationLanding` with an invitation's token (sdk#472).
439
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedinvitation
440
+ */
441
+ readonly openedInvitation: () => OpenedInvitation;
442
+ /**
443
+ * What the invitation is for: `personal` (it names its recipient) or `shared`.
444
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#previewinvitation
445
+ */
446
+ readonly previewInvitation: (
447
+ /**
448
+ * The types allow other ready proofs here.
449
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#previewinvitation
450
+ */
451
+ opened: Extract<OpenedInvitation, {
452
+ readonly kind: 'ready';
453
+ }>, options?: CallOptions) => Promise<Result<Invitation, Sent | {
454
+ readonly kind: 'dead_link';
455
+ }>>;
456
+ /**
457
+ * Accepting makes the account and signs the person in, as `logIn` does: `signed_in` with `continue_to`, or a two-step code or set-up wanted.
458
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#acceptinvitation
459
+ */
460
+ readonly acceptInvitation: AcceptInvitation;
461
+ /**
462
+ * Looks up a device's code as typed (sdk#471): the request to show the person, or `unknown_code` (unknown, expired or already used; pulse-auth says the same for all three) or `already_denied`.
463
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#lookupdevice
464
+ */
465
+ readonly lookUpDevice: (request: {
466
+ readonly user_code: string;
467
+ }, options?: CallOptions) => Promise<Result<DeviceRequest, Sent | Refused | DeviceStop>>;
468
+ /**
469
+ * Approves the request `lookUpDevice()` answered on this session, as the signed-in person, only on a press.
470
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#approvedevice-denydevice
471
+ */
472
+ readonly approveDevice: (device: DeviceRequest, options?: CallOptions) => Promise<Result<{
473
+ readonly kind: 'approved';
474
+ }, AsPerson | DeviceAnswerStop>>;
475
+ /**
476
+ * Denies the request `lookUpDevice()` answered on this session, as `approveDevice` approves it.
477
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#approvedevice-denydevice
478
+ */
479
+ readonly denyDevice: (device: DeviceRequest, options?: CallOptions) => Promise<Result<{
480
+ readonly kind: 'denied';
481
+ }, AsPerson | DeviceAnswerStop>>;
482
+ /**
483
+ * The session's state, the same object until it changes.
484
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
485
+ */
486
+ readonly current: () => SessionState;
487
+ /**
488
+ * `listener` runs on every change of `current()`.
489
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#current-subscribe
490
+ */
491
+ readonly subscribe: (listener: () => void) => () => void;
492
+ /**
493
+ * Restores the session from the refresh cookie, once, after subscribing.
494
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#start
495
+ */
496
+ readonly start: () => void;
497
+ /**
498
+ * Ends this session object: its listeners, timers and channel, for tests and hot reloading.
499
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#close
500
+ */
501
+ readonly close: () => void;
502
+ /**
503
+ * Stores this browser's attempt, then asks for a login link.
504
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#requestlink
505
+ */
506
+ readonly requestLink: (request: {
507
+ readonly email: string;
508
+ readonly next: string | null;
509
+ }, options?: CallOptions) => Promise<Result<{
510
+ readonly email: string;
511
+ }, ThroughProxy | Refused>>;
512
+ /**
513
+ * The login link this page was opened with, checked against this browser's attempt.
514
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#openedlink
515
+ */
516
+ readonly openedLink: () => OpenedLink;
517
+ /**
518
+ * Signs in with a ready link, checking it again first.
519
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#redeem
520
+ */
521
+ readonly redeem: (link: ReadyLink, options?: CallOptions) => Promise<Result<SignInStep, RedeemStop>>;
522
+ /**
523
+ * A new login link to the address of a link this browser asked for, with its `next`.
524
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#requestlinkagain
525
+ */
526
+ readonly requestLinkAgain: (link: ReadyLink | SpentLink, options?: CallOptions) => Promise<Result<{
527
+ readonly email: string;
528
+ }, ThroughProxy>>;
529
+ /**
530
+ * Sends the person's two-step or backup code and finishes the sign-in.
531
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#verifytwostep
532
+ */
533
+ readonly verifyTwoStep: (entry: {
534
+ readonly code: string;
535
+ }, options?: CallOptions) => Promise<Result<{
536
+ readonly kind: 'signed_in';
537
+ readonly backup_codes: readonly string[] | null;
538
+ }, TwoStepVerifyStop>>;
539
+ /**
540
+ * Signs out here and in every tab, only on a press.
541
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#signout
542
+ */
543
+ readonly signOut: () => {
544
+ readonly told: Promise<SignOutTold>;
545
+ };
546
+ }
547
+ /** The page's link parameters and its path, read when `openedLink()` is called; null outside a page. */
548
+ export type Address = () => {
549
+ readonly path: string;
550
+ readonly attempt: unknown;
551
+ readonly email: unknown;
552
+ readonly invite: unknown;
553
+ } | null;
554
+ /** What the entry wraps: the session's parts, made by `createBrowserSession` or a test. */
555
+ export interface EntryParts {
556
+ readonly browser: Internal;
557
+ readonly session: AuthSession;
558
+ readonly landed: LandedTokens;
559
+ readonly wire: Wire;
560
+ readonly flipstream: () => Flipstream;
561
+ readonly linkDeps: SignupAttemptDeps;
562
+ readonly report: (report: SessionReport) => void;
563
+ readonly landing: string;
564
+ readonly address: Address;
565
+ readonly href: () => string;
566
+ }
567
+ /** The session's wrapping, for `createBrowserSession` and the tests. */
568
+ export declare function entryOver(parts: EntryParts): BrowserSession;
569
+ /**
570
+ * The browser session, for a page on the app's own origin.
571
+ * @see https://github.com/flipstream-io/sdk/blob/main/sdks/typescript/docs/first-party.md#createbrowsersession
572
+ */
573
+ export declare function createBrowserSession(options: BrowserSessionOptions): BrowserSession;