@flipstream/sdk 0.18.0 → 0.19.1
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 +29 -0
- package/README.md +19 -4
- package/dist/api/backend.d.ts +6 -0
- package/dist/api/backend.js +9 -0
- package/dist/api/backend.js.map +1 -1
- package/dist/api/handoff.d.ts +4 -3
- package/dist/api/handoff.js +4 -2
- package/dist/api/handoff.js.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/members.d.ts +14 -0
- package/dist/api/members.js +48 -4
- package/dist/api/members.js.map +1 -1
- package/dist/api/profile.d.ts +20 -0
- package/dist/api/profile.js +95 -0
- package/dist/api/profile.js.map +1 -1
- package/dist/core/result.d.ts +8 -2
- package/dist/core/result.js +3 -0
- package/dist/core/result.js.map +1 -1
- package/dist/core/signal.d.ts +14 -8
- package/dist/core/signal.js +7 -5
- package/dist/core/signal.js.map +1 -1
- package/dist/first-party/calls/consent.js +0 -2
- package/dist/first-party/calls/consent.js.map +1 -1
- package/dist/first-party/calls/device.js +0 -3
- package/dist/first-party/calls/device.js.map +1 -1
- package/dist/first-party/calls/invitation.d.ts +1 -1
- package/dist/first-party/calls/invitation.js.map +1 -1
- package/dist/first-party/calls/reset.js +1 -3
- package/dist/first-party/calls/reset.js.map +1 -1
- package/dist/first-party/calls/signUp.js +0 -3
- package/dist/first-party/calls/signUp.js.map +1 -1
- package/dist/first-party/entry.js +53 -43
- package/dist/first-party/entry.js.map +1 -1
- package/dist/first-party/http.js +2 -1
- package/dist/first-party/http.js.map +1 -1
- package/dist/first-party/locks.js +3 -2
- package/dist/first-party/locks.js.map +1 -1
- package/dist/first-party/sessionWire.js +2 -1
- package/dist/first-party/sessionWire.js.map +1 -1
- package/dist/flipstream.d.ts +23 -5
- package/dist/flipstream.js +49 -4
- package/dist/flipstream.js.map +1 -1
- package/dist/version.gen.js +1 -1
- package/docs/admin.md +30 -3
- package/docs/first-party.md +1 -1
- package/package.json +1 -1
package/docs/admin.md
CHANGED
|
@@ -23,7 +23,7 @@ section's basics, and its most common example, are in the package's README under
|
|
|
23
23
|
- Every role reads the same access, a viewer limited to some workspaces and Flipstream's own
|
|
24
24
|
staff included.
|
|
25
25
|
- **`user`** is
|
|
26
|
-
`{ id, email, first_name, last_name, role, roles, unknown_roles, active, workspace_ids, created_on, created_by_id }`:
|
|
26
|
+
`{ id, email, first_name, last_name, role, roles, unknown_roles, active, workspace_ids, created_on, created_by_id, photo }`:
|
|
27
27
|
a `Member`, as `flipstream.members` answers each person (see "Your organisation's members").
|
|
28
28
|
- `me()` reads the token's own person and doesn't apply `members`' people-only rule. An API key's
|
|
29
29
|
token isn't tested with it yet: service accounts come with pulse-admin#93. Every call under one
|
|
@@ -58,13 +58,35 @@ section's basics, and its most common example, are in the package's README under
|
|
|
58
58
|
- `profile.privacy()` reads on every client. The answer is `{ version, accepted_on }`, and
|
|
59
59
|
`version` is null when none is accepted. `accepted_on` is that entry's date as a UTC instant
|
|
60
60
|
with `Z` and milliseconds, or null when `version` is null, or when it is missing or not a
|
|
61
|
-
date and time. It reads `GET /users/{id}/profile?refresh=true`. A later
|
|
61
|
+
date and time. A date alone, such as `2025-01-01`, reads as null. It reads `GET /users/{id}/profile?refresh=true`. A later
|
|
62
62
|
`accepted: false` is not read as a withdrawal. Meta that is not a JSON object is `invalid`.
|
|
63
63
|
A 404 stays `not_found`.
|
|
64
64
|
- `profile.setName({ first_name, last_name })` and `profile.acceptPrivacy({ version })` write
|
|
65
65
|
only on the client the first-party session makes (`session.flipstream`). On every other client
|
|
66
66
|
they answer `needs_person`, with `why`, and send nothing. No `url` is named: the page's address
|
|
67
67
|
needs your organisation's short name, and that would be a read.
|
|
68
|
+
- `profile.setPhoto(file)` writes only on that same client. `file` is a `File` or `Blob`. A
|
|
69
|
+
zero-byte file is `refused` (`empty`, `fields: ['file']`) before the type is considered. A
|
|
70
|
+
type other than png, jpeg, gif or webp is `refused` (`type`); `image/jpg` and a blank type
|
|
71
|
+
are that. Over 5 MiB is `refused` (`too_large`); exactly 5 MiB is sent. Those three read
|
|
72
|
+
`size` and `type` once, before the bytes and before any request. The bytes are read next,
|
|
73
|
+
still before any request (#598, SDK-D2071). A read that throws, or that is not an
|
|
74
|
+
ArrayBuffer, is `refused` (`unreadable`). A byte length of 0 is `empty`, and one over 5 MiB
|
|
75
|
+
is `too_large`, even when `size` said otherwise. On the first-party session's client, anything
|
|
76
|
+
that is not a file rejects with a `TypeError` and sends nothing. On every other client,
|
|
77
|
+
`needs_person` comes first. The post is `POST /users/{sub}/upload-file` with
|
|
78
|
+
`{ data, file_type: 'image' }`, `data` a data URL, and there is no user GET first. The file
|
|
79
|
+
is read inside the call's one deadline, with userinfo and the upload, 30 s by default. For a
|
|
80
|
+
large photo on a slow connection pass `deadlineMs` (for example 120000). A `timeout` leaves
|
|
81
|
+
the outcome unknown: it may come before anything was sent, or after the upload went out, when
|
|
82
|
+
the photo may be saved and the old one deleted. Either way the next `me()` shows what the
|
|
83
|
+
server holds.
|
|
84
|
+
`ok` is `{ link }`, the https link by `photo`'s rule. Another
|
|
85
|
+
user, or no usable link, is `invalid`. A 5xx is `unavailable`. A 413 stays `rejected` with
|
|
86
|
+
status 413. Every answer except `needs_person` and `refused` drops that scope's shared reads.
|
|
87
|
+
The server deletes the previous photo after the upload, so another tab, or another person
|
|
88
|
+
page, still showing the old link shows a broken image until its next read of `me()` or
|
|
89
|
+
`members`.
|
|
68
90
|
- A blank name, or a blank version, is `refused` (`empty`), naming the fields, and nothing is
|
|
69
91
|
sent. `setName` answers only `saved`. The name write reads `GET /users/{sub}?refresh=true`
|
|
70
92
|
fresh, not the scope's shared read, and sets `email`, `first_name` and `last_name`, with that
|
|
@@ -85,7 +107,7 @@ section's basics, and its most common example, are in the package's README under
|
|
|
85
107
|
## Your organisation's members
|
|
86
108
|
|
|
87
109
|
- **A member** is
|
|
88
|
-
`{ id, email, first_name, last_name, role, roles, unknown_roles, active, workspace_ids, created_on, created_by_id }`,
|
|
110
|
+
`{ id, email, first_name, last_name, role, roles, unknown_roles, active, workspace_ids, created_on, created_by_id, photo }`,
|
|
89
111
|
and nothing else, with `role`, `roles`, `unknown_roles` and `workspace_ids` by `me()`'s rules (see
|
|
90
112
|
"Who you are"): the highest role they hold, or `null` for none and for Flipstream's own staff,
|
|
91
113
|
then every role of ours they hold, highest first, and a count of the rest. A role this version
|
|
@@ -95,6 +117,11 @@ section's basics, and its most common example, are in the package's README under
|
|
|
95
117
|
or when they accepted if accepting did. It's `null` when the service holds none, or one that
|
|
96
118
|
isn't a time: unlike a dataset's, it never fails the answer.
|
|
97
119
|
- `created_by_id` is the person who made their account, `null` when the service holds none.
|
|
120
|
+
- `photo` is the https link of their profile photo, never the storage id. It is `null` when they
|
|
121
|
+
have none, when the link does not start with `https://`, or when it does not parse as a URL
|
|
122
|
+
(`https:`, `https:foo`, `https://` with no host, `http:` and `javascript:` included). It never
|
|
123
|
+
fails the person. `me().user`, `members.list` and
|
|
124
|
+
`members.get` all carry it.
|
|
98
125
|
- `flipstream.members.get({ member_id: created_by_id })` names the maker. When it doesn't answer
|
|
99
126
|
ok (see below), show the maker as unknown, for example for Flipstream's staff or an account
|
|
100
127
|
made by another organisation. The SDK doesn't guess which: a `not_found` may also be someone
|
package/docs/first-party.md
CHANGED
|
@@ -59,7 +59,7 @@ document.querySelector('#sign-in')?.addEventListener('click', () => {
|
|
|
59
59
|
| --- | --- |
|
|
60
60
|
| <a id="current-subscribe"></a>`current()`, `subscribe(listener)` | The session's state (`restoring`, `signed_out`, `signed_in`, `unavailable`, `broken`, `unsupported`), the same object until it changes, for `useSyncExternalStore`. `signed_in` carries `revision`, which rises by one when who is signed in, or what their token says, changes (every claim but `iat`, `nbf`, `exp`, `jti` and `sid`: the person, the organization, the roles, or a claim pulse-auth adds later); with each new generation, that is a new sign-in or a refresh that answers another person; and once when the tab stops being signed in (signed out, `broken`, or `restoring` after a sign-in it missed). A renewal that says the same leaves it. It counts within one tab, from 0 at each page load, so two tabs' revisions aren't comparable. `restoring` ends within 60 s of `start()`, ordinarily 15. `unavailable` carries `retry_in_ms`. `unavailable`: pulse-auth cannot be reached now. The session asks pulse-auth again by itself after that wait, and stays `unavailable` while it asks. `retry_in_ms` counts from when the state was published; the ask itself can take up to 15 s, and the tab stays `unavailable` until it answers. Its answer moves the tab on, or to `unavailable` again with the next wait. A tab shows `restoring` again only when the browser comes back online, which asks at once without waiting out `retry_in_ms`, or, when it is signed in, when another tab signed in and this one missed the message. The call that published finishes; a listener's throw goes to the page's `error` event through `reportError`, and on a host without one (a server render, Node) it is thrown again from a microtask, which Node raises as an uncaughtException, as its own `EventTarget` does. A try whose answer came for a state another tab moved is asked again, at most three more times. `current()` is frozen. `subscribe` returns the unsubscribe. Until the first answer, the refresh cookie decides. Without Web Locks or localStorage nobody can sign in. `broken`: pulse-auth answered outside its contract, or the app's own proxy refused, and it is reported. `broken`'s `status` is the answer's, and a redirect in a browser reads 0. |
|
|
61
61
|
| <a id="flipstream"></a>`flipstream` | The main SDK as the signed-in person. Read the getter for each piece of work, for example `await session.flipstream.me()`. A call uses the person displayed when it is made. With nobody shown, a bearer call answers at once. A kept client or scope answers `cancelled` after the person or rights change. After `close()` the getter stays readable, and a call on the client rejects with `SessionClosedError`. |
|
|
62
|
-
| <a id="requestlink"></a>`requestLink({ email, next }, { signal })` | Mails a login link. Empty text is `refused`, with nothing sent. `next` is a string or `null`. Anything else, left out included, is a `TypeError`, with nothing stored or sent. An absolute URL or a `//` URL is stored as given. The app checks it against its routes. `next` comes back on the opened link and never travels in the mail. "Send again" is the same call. `aborted`: the mail may still have gone out. Every sending call answers `{ ok: true, data }` or `{ ok: false, error }` and rejects only on a programming error. The last argument is the caller's own signal. The entry sets each call's own time limit. `unavailable` means trying again later may work, and `invalid` was reported, so trying again won't help. `unavailable` is offline, a 5xx, or a 429 the call has no rule for. `invalid` is an answer outside the contract. The call stores this browser's attempt, then asks. An answer is frozen, all the way down. `refused` names the empty fields. `proxy_refused` is the app's own server refusing, a deployment fault, and `unsupported` is a browser without locks or storage. Once the caller's signal aborts, the call answers `aborted`, unless its own row says an abort is ignored once it is sent. `error.kind` says why a call stopped short. A call through the app's own proxy runs inside the session's cookie lock. |
|
|
62
|
+
| <a id="requestlink"></a>`requestLink({ email, next }, { signal })` | Mails a login link. Empty text is `refused`, with nothing sent. `next` is a string or `null`. Anything else, left out included, is a `TypeError`, with nothing stored or sent. An absolute URL or a `//` URL is stored as given. The app checks it against its routes. `next` comes back on the opened link and never travels in the mail. "Send again" is the same call. `aborted`: the mail may still have gone out. Every sending call answers `{ ok: true, data }` or `{ ok: false, error }` and rejects only on a programming error. The last argument is the caller's own signal. Every session call that takes `{ signal }` refuses a signal that is no AbortSignal with `name() takes signal as an AbortSignal`, before anything is stored or sent. The entry sets each call's own time limit. `unavailable` means trying again later may work, and `invalid` was reported, so trying again won't help. `unavailable` is offline, a 5xx, or a 429 the call has no rule for. `invalid` is an answer outside the contract. The call stores this browser's attempt, then asks. An answer is frozen, all the way down. `refused` names the empty fields. `proxy_refused` is the app's own server refusing, a deployment fault, and `unsupported` is a browser without locks or storage. Once the caller's signal aborts, the call answers `aborted`, unless its own row says an abort is ignored once it is sent. `error.kind` says why a call stopped short. A call through the app's own proxy runs inside the session's cookie lock. |
|
|
63
63
|
| <a id="openedlink"></a>`openedLink()` | On the landing: whether a link's token was there, and for whom (`ready`, `spent`, `other_browser`, `invalid`, `no_token`, `invitation`). It only reads: nothing is sent and nothing stored, so it is safe in a render and when called twice (React's StrictMode renders twice). Each call gives a new, frozen object, equal in content while nothing has changed. `redeem` and `requestLinkAgain` take any object it gave, and refuse a copy, or one made by hand, with a `TypeError`. The app checks `next` against its routes. `next` is where the person was going. `spent` means this browser already used the link or asked over 10 minutes ago. `other_browser` means it was asked for somewhere else, or not at all. `invalid`: the token's address, the address shown and the attempt's differ. `no_token`: off the landing, or a reload after the token was taken. `invitation` means send the person to the invitation page. |
|
|
64
64
|
| <a id="redeem"></a>`redeem(link, { signal })` | Signs in with the `ready` link `openedLink()` gave: `signed_in`, or a two-step code wanted. Call it only on a press, never as the page loads: a prerender, a speculative load or a restored tab runs the page's script without one, and the link works once. If redeem answers `superseded`, read `current()`. If the press was overtaken before the link was sent, pressing it again sends it, unless the sign-in that overtook it used this link: then `current()` is `signed_in` and the link reads `spent`. If it was sent and the sign-in was lost, every later press in this page keeps `superseded`. Ask for a new link. `requestLinkAgain` takes the same link after `dead_link`. It takes only the object `openedLink()` gave. `aborted`: the sign-in may still complete, and `current()` tells. `dead_link`: the link is used up, because pulse-auth refused it (expired, or used elsewhere), or its code step ran out or locked. |
|
|
65
65
|
| <a id="requestlinkagain"></a>`requestLinkAgain(link, { signal })` | A new link for the same address and next page. Always a plain login link, also after a sign-up, because the account exists by then. It sends a new link to the address of a link this browser asked for, with its `next`. |
|