@foir/sdk 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +84 -1
- package/README.md +9 -9
- package/dist/app/client.d.ts +90 -84
- package/dist/app/contract/proto/apps/v1/apps_pb.d.ts +14 -13
- package/dist/app/dispatch.d.ts +5 -5
- package/dist/app/errors.d.ts +11 -11
- package/dist/app/index.d.ts +4 -4
- package/dist/app/naming.d.ts +1 -1
- package/dist/app/ticket.d.ts +2 -2
- package/dist/app/vocabulary.generated.d.ts +2 -2
- package/dist/app-contract.js +3 -3
- package/dist/app.js +92 -90
- package/dist/auth/access.d.ts +19 -19
- package/dist/auth/auth.d.ts +216 -114
- package/dist/auth/hosted.d.ts +14 -14
- package/dist/auth/index.d.ts +7 -7
- package/dist/auth/operations.d.ts +128 -32
- package/dist/auth/ops.d.ts +39 -21
- package/dist/auth/session-client.d.ts +3 -3
- package/dist/auth-session.js +3 -3
- package/dist/auth.js +234 -135
- package/dist/client.js +4 -4
- package/dist/data/builtins.d.ts +26 -26
- package/dist/data/client.d.ts +2 -2
- package/dist/data/decimal.d.ts +1 -1
- package/dist/data/index.d.ts +1 -1
- package/dist/data/manifest.d.ts +1 -1
- package/dist/data/schema.d.ts +1 -1
- package/dist/data/transport.d.ts +10 -10
- package/dist/data/ws-transport.d.ts +1 -1
- package/dist/data.js +6 -6
- package/dist/graphql/content-client.d.ts +13 -13
- package/dist/live/drift.d.ts +1 -1
- package/dist/media/screen-capture.d.ts +1 -1
- package/dist/next/index.d.ts +2 -2
- package/dist/next/session.d.ts +10 -10
- package/dist/next.js +77 -56
- package/dist/placement/index.d.ts +13 -13
- package/dist/placement.js +9 -6
- package/dist/push.js +61 -40
- package/dist/react/FoirFeedback.d.ts +2 -2
- package/dist/react/FoirProvider.d.ts +23 -23
- package/dist/react/SignIn.d.ts +4 -4
- package/dist/react/UserButton.d.ts +1 -1
- package/dist/react/feedback-notes.d.ts +4 -4
- package/dist/react/index.d.ts +3 -3
- package/dist/react.js +119 -95
- package/dist/realtime/index.d.ts +1 -1
- package/dist/server/callback-client.d.ts +4 -4
- package/dist/server/events-client.d.ts +16 -16
- package/dist/server/operation-types.d.ts +8 -8
- package/dist/server/require-scoped-token.d.ts +3 -3
- package/dist/server/types.d.ts +1 -1
- package/dist/server/verify-scoped-token.d.ts +3 -3
- package/dist/server.js +16 -13
- package/dist/transport/foir-http.d.ts +13 -13
- package/dist/types/index.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { AuthProviderPublic, FoirAccess,
|
|
2
|
+
import type { AuthProviderPublic, FoirAccess, FoirUser, FoirSessionConfig, SessionAdapter } from '../auth';
|
|
3
3
|
import type { ProviderCallbackInput, ProviderLoginInput } from '../auth';
|
|
4
4
|
import type { FoirEnv } from '../graphql/foir-request';
|
|
5
5
|
/** Where the session hydration stands. */
|
|
6
6
|
export type FoirStatus = 'loading' | 'authenticated' | 'unauthenticated';
|
|
7
7
|
/**
|
|
8
|
-
* Where reading the signed-in
|
|
8
|
+
* Where reading the signed-in user's access stands. `idle` until something
|
|
9
9
|
* asks for it; `unavailable` when the platform could not be asked.
|
|
10
10
|
*/
|
|
11
11
|
export type FoirAccessStatus = 'idle' | 'loading' | 'ready' | 'unavailable';
|
|
12
12
|
/** The full context value. Read it through the hooks below, not directly. */
|
|
13
13
|
export interface FoirContextValue {
|
|
14
14
|
status: FoirStatus;
|
|
15
|
-
|
|
16
|
-
/** The signed-in
|
|
15
|
+
user: FoirUser | null;
|
|
16
|
+
/** The signed-in user's access, once read. See {@link useFoirAccess}. */
|
|
17
17
|
access: FoirAccess | null;
|
|
18
18
|
accessStatus: FoirAccessStatus;
|
|
19
|
-
/** Ask the platform for the signed-in
|
|
19
|
+
/** Ask the platform for the signed-in user's access, again if it was read before. */
|
|
20
20
|
loadAccess(): Promise<void>;
|
|
21
21
|
/** The same, unless a read is already under way: then that one is awaited. */
|
|
22
22
|
ensureAccess(): Promise<void>;
|
|
@@ -27,22 +27,22 @@ export interface FoirContextValue {
|
|
|
27
27
|
signIn(vars: {
|
|
28
28
|
email: string;
|
|
29
29
|
password: string;
|
|
30
|
-
}): Promise<
|
|
30
|
+
}): Promise<FoirUser>;
|
|
31
31
|
register(vars: {
|
|
32
32
|
email: string;
|
|
33
33
|
password: string;
|
|
34
|
-
}): Promise<
|
|
34
|
+
}): Promise<FoirUser>;
|
|
35
35
|
requestOtp(email: string): Promise<boolean>;
|
|
36
36
|
signInWithOtp(vars: {
|
|
37
37
|
email: string;
|
|
38
38
|
otp: string;
|
|
39
|
-
}): Promise<
|
|
39
|
+
}): Promise<FoirUser>;
|
|
40
40
|
/** Start a provider (OAuth/OIDC) login. Redirect providers navigate away. */
|
|
41
41
|
signInWithProvider(providerKey: string, opts?: Omit<ProviderLoginInput, 'providerKey'>): Promise<void>;
|
|
42
42
|
/** Complete a provider login from your callback route (code + state). */
|
|
43
43
|
completeProviderLogin(input: Omit<ProviderCallbackInput, 'providerKey'> & {
|
|
44
44
|
providerKey: string;
|
|
45
|
-
}): Promise<
|
|
45
|
+
}): Promise<FoirUser>;
|
|
46
46
|
signOut(): Promise<void>;
|
|
47
47
|
/** Rotate the access token; returns false (and signs out) if it can't. */
|
|
48
48
|
refresh(): Promise<boolean>;
|
|
@@ -78,8 +78,8 @@ export interface FoirProviderProps {
|
|
|
78
78
|
children: ReactNode;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Provides Foir
|
|
82
|
-
* then exposes the current
|
|
81
|
+
* Provides Foir user auth to a React tree. Hydrates the session on mount,
|
|
82
|
+
* then exposes the current user and sign-in/out actions through
|
|
83
83
|
* {@link useFoirSession}, {@link useFoirUser}, and {@link useFoirAuth}.
|
|
84
84
|
*
|
|
85
85
|
* Two session models:
|
|
@@ -93,14 +93,14 @@ export declare function FoirProvider({ env, adapter, hostedSession, children, }:
|
|
|
93
93
|
/** The current session state. */
|
|
94
94
|
export interface FoirSession {
|
|
95
95
|
status: FoirStatus;
|
|
96
|
-
|
|
96
|
+
user: FoirUser | null;
|
|
97
97
|
isLoading: boolean;
|
|
98
98
|
isAuthenticated: boolean;
|
|
99
99
|
}
|
|
100
|
-
/** Read the current session status and
|
|
100
|
+
/** Read the current session status and user. */
|
|
101
101
|
export declare function useFoirSession(): FoirSession;
|
|
102
|
-
/** The signed-in
|
|
103
|
-
export declare function useFoirUser():
|
|
102
|
+
/** The signed-in user (`{ id, email }`), or null. */
|
|
103
|
+
export declare function useFoirUser(): FoirUser | null;
|
|
104
104
|
/** What {@link useFoirAccess} returns. */
|
|
105
105
|
export interface FoirAccessState {
|
|
106
106
|
/**
|
|
@@ -110,17 +110,17 @@ export interface FoirAccessState {
|
|
|
110
110
|
*/
|
|
111
111
|
status: 'loading' | 'ready' | 'unavailable';
|
|
112
112
|
isLoading: boolean;
|
|
113
|
-
/** The signed-in
|
|
113
|
+
/** The signed-in user's access, or null: signed out, loading or unavailable. */
|
|
114
114
|
access: FoirAccess | null;
|
|
115
|
-
/** Whether the
|
|
115
|
+
/** Whether the user holds the role with this key. False until known. */
|
|
116
116
|
hasRole(key: string): boolean;
|
|
117
|
-
/** Whether the
|
|
117
|
+
/** Whether the user's scopes cover this one. False until known. */
|
|
118
118
|
hasScope(scope: string): boolean;
|
|
119
119
|
/** Ask the platform again, for a role given or taken away since. */
|
|
120
120
|
reload(): Promise<void>;
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* The roles the signed-in
|
|
123
|
+
* The roles the signed-in user holds and the scopes they resolve to, as the
|
|
124
124
|
* platform resolved them. Read on first use, again when the session refreshes,
|
|
125
125
|
* and whenever `reload` is called.
|
|
126
126
|
*
|
|
@@ -133,20 +133,20 @@ export declare function useFoirAuth(): {
|
|
|
133
133
|
signIn: (vars: {
|
|
134
134
|
email: string;
|
|
135
135
|
password: string;
|
|
136
|
-
}) => Promise<
|
|
136
|
+
}) => Promise<FoirUser>;
|
|
137
137
|
register: (vars: {
|
|
138
138
|
email: string;
|
|
139
139
|
password: string;
|
|
140
|
-
}) => Promise<
|
|
140
|
+
}) => Promise<FoirUser>;
|
|
141
141
|
requestOtp: (email: string) => Promise<boolean>;
|
|
142
142
|
signInWithOtp: (vars: {
|
|
143
143
|
email: string;
|
|
144
144
|
otp: string;
|
|
145
|
-
}) => Promise<
|
|
145
|
+
}) => Promise<FoirUser>;
|
|
146
146
|
signInWithProvider: (providerKey: string, opts?: Omit<ProviderLoginInput, "providerKey">) => Promise<void>;
|
|
147
147
|
completeProviderLogin: (input: Omit<ProviderCallbackInput, "providerKey"> & {
|
|
148
148
|
providerKey: string;
|
|
149
|
-
}) => Promise<
|
|
149
|
+
}) => Promise<FoirUser>;
|
|
150
150
|
signOut: () => Promise<void>;
|
|
151
151
|
refresh: () => Promise<boolean>;
|
|
152
152
|
getToken: () => Promise<string | null>;
|
package/dist/react/SignIn.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FoirUser } from '../auth';
|
|
2
2
|
export interface SignInProps {
|
|
3
3
|
/** `password` (default) or `otp` (email one-time code). Ignored when `hostedUrl` is set. */
|
|
4
4
|
method?: 'password' | 'otp';
|
|
@@ -8,12 +8,12 @@ export interface SignInProps {
|
|
|
8
8
|
oauth?: boolean;
|
|
9
9
|
/** Navigate here after a successful sign-in. */
|
|
10
10
|
afterSignInUrl?: string;
|
|
11
|
-
/** Called with the
|
|
12
|
-
onSignIn?(
|
|
11
|
+
/** Called with the user on a successful sign-in (before any redirect). */
|
|
12
|
+
onSignIn?(user: FoirUser): void;
|
|
13
13
|
className?: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* A drop-in
|
|
16
|
+
* A drop-in user sign-in. Renders an email/password (or OTP) form and,
|
|
17
17
|
* unless disabled, OAuth provider buttons. Set `hostedUrl` to instead render a
|
|
18
18
|
* button that redirects to a hosted login page. All state is handled through
|
|
19
19
|
* {@link FoirProvider}; on success it calls `onSignIn` and optionally navigates
|
|
@@ -6,7 +6,7 @@ export interface UserButtonProps {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* A minimal signed-in affordance: the
|
|
9
|
+
* A minimal signed-in affordance: the user's email plus a sign-out button.
|
|
10
10
|
* Renders nothing when signed out. Style it via `className` (the default is an
|
|
11
11
|
* unopinionated inline layout).
|
|
12
12
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* shape (see `data/selection.ts`) — so every response here has to be read rather
|
|
8
8
|
* than cast, and reading is the part worth testing on its own.
|
|
9
9
|
*/
|
|
10
|
-
import type {
|
|
10
|
+
import type { FoirUserNote, FoirNoteConfig, FoirSubject } from '../data';
|
|
11
11
|
import type { FoirScreenCapture } from '../media/screen-capture';
|
|
12
12
|
/**
|
|
13
13
|
* The client the widget needs, and no more of it.
|
|
@@ -44,9 +44,9 @@ export interface FoirFeedbackClient {
|
|
|
44
44
|
* widget can name.
|
|
45
45
|
*
|
|
46
46
|
* The distinction earns its place because the three have different audiences.
|
|
47
|
-
* `signIn` is the visitor's to fix. `scope` is the
|
|
47
|
+
* `signIn` is the visitor's to fix. `scope` is the PROJECT's: a role that does
|
|
48
48
|
* not grant `notes:create` produces `missing required scope: notes:create`, which
|
|
49
|
-
* reads like a bad API key and is not one; the key is fine and the
|
|
49
|
+
* reads like a bad API key and is not one; the key is fine and the user's
|
|
50
50
|
* role is short a capability. `other` is everything the widget will not pretend
|
|
51
51
|
* to understand.
|
|
52
52
|
*/
|
|
@@ -98,4 +98,4 @@ export interface FoirFeedbackSubmission {
|
|
|
98
98
|
* worse than one that did not arrive: they have no way to tell, and the thing
|
|
99
99
|
* they wrote ("as you can see in the screenshot") stops making sense.
|
|
100
100
|
*/
|
|
101
|
-
export declare function submitFeedbackNote(client: FoirFeedbackClient, submission: FoirFeedbackSubmission): Promise<
|
|
101
|
+
export declare function submitFeedbackNote(client: FoirFeedbackClient, submission: FoirFeedbackSubmission): Promise<FoirUserNote>;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@foir/sdk/react` — drop-in React components for Foir
|
|
2
|
+
* `@foir/sdk/react` — drop-in React components for Foir users.
|
|
3
3
|
*
|
|
4
4
|
* Wrap your app in `<FoirProvider>`, then read the session with
|
|
5
|
-
* `useFoirSession` / `useFoirUser`, ask what the
|
|
5
|
+
* `useFoirSession` / `useFoirUser`, ask what the user may see with
|
|
6
6
|
* `useFoirAccess`, and drive it with `useFoirAuth` — or drop in
|
|
7
7
|
* the `<SignIn>`, `<OAuthButtons>`, and `<UserButton>` components. Built entirely
|
|
8
8
|
* on `@foir/sdk/auth`; `react` is the only peer dependency.
|
|
@@ -22,5 +22,5 @@ export type { UserButtonProps } from './UserButton';
|
|
|
22
22
|
export { FoirFeedback } from './FoirFeedback';
|
|
23
23
|
export type { FoirFeedbackProps, FoirFeedbackClient } from './FoirFeedback';
|
|
24
24
|
export { createLocalStorageAdapter } from './localStorageAdapter';
|
|
25
|
-
export type { FoirAccess,
|
|
25
|
+
export type { FoirAccess, FoirUser, SessionAdapter, AuthProviderPublic } from '../auth';
|
|
26
26
|
export type { FoirEnv } from '../graphql/foir-request';
|