@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +84 -1
  2. package/README.md +9 -9
  3. package/dist/app/client.d.ts +90 -84
  4. package/dist/app/contract/proto/apps/v1/apps_pb.d.ts +14 -13
  5. package/dist/app/dispatch.d.ts +5 -5
  6. package/dist/app/errors.d.ts +11 -11
  7. package/dist/app/index.d.ts +4 -4
  8. package/dist/app/naming.d.ts +1 -1
  9. package/dist/app/ticket.d.ts +2 -2
  10. package/dist/app/vocabulary.generated.d.ts +2 -2
  11. package/dist/app-contract.js +3 -3
  12. package/dist/app.js +92 -90
  13. package/dist/auth/access.d.ts +19 -19
  14. package/dist/auth/auth.d.ts +216 -114
  15. package/dist/auth/hosted.d.ts +14 -14
  16. package/dist/auth/index.d.ts +7 -7
  17. package/dist/auth/operations.d.ts +128 -32
  18. package/dist/auth/ops.d.ts +39 -21
  19. package/dist/auth/session-client.d.ts +3 -3
  20. package/dist/auth-session.js +3 -3
  21. package/dist/auth.js +234 -135
  22. package/dist/client.js +4 -4
  23. package/dist/data/builtins.d.ts +26 -26
  24. package/dist/data/client.d.ts +2 -2
  25. package/dist/data/decimal.d.ts +1 -1
  26. package/dist/data/index.d.ts +1 -1
  27. package/dist/data/manifest.d.ts +1 -1
  28. package/dist/data/schema.d.ts +1 -1
  29. package/dist/data/transport.d.ts +10 -10
  30. package/dist/data/ws-transport.d.ts +1 -1
  31. package/dist/data.js +6 -6
  32. package/dist/graphql/content-client.d.ts +13 -13
  33. package/dist/live/drift.d.ts +1 -1
  34. package/dist/media/screen-capture.d.ts +1 -1
  35. package/dist/next/index.d.ts +2 -2
  36. package/dist/next/session.d.ts +10 -10
  37. package/dist/next.js +77 -56
  38. package/dist/placement/index.d.ts +13 -13
  39. package/dist/placement.js +9 -6
  40. package/dist/push.js +61 -40
  41. package/dist/react/FoirFeedback.d.ts +2 -2
  42. package/dist/react/FoirProvider.d.ts +23 -23
  43. package/dist/react/SignIn.d.ts +4 -4
  44. package/dist/react/UserButton.d.ts +1 -1
  45. package/dist/react/feedback-notes.d.ts +4 -4
  46. package/dist/react/index.d.ts +3 -3
  47. package/dist/react.js +119 -95
  48. package/dist/realtime/index.d.ts +1 -1
  49. package/dist/server/callback-client.d.ts +4 -4
  50. package/dist/server/events-client.d.ts +16 -16
  51. package/dist/server/operation-types.d.ts +8 -8
  52. package/dist/server/require-scoped-token.d.ts +3 -3
  53. package/dist/server/types.d.ts +1 -1
  54. package/dist/server/verify-scoped-token.d.ts +3 -3
  55. package/dist/server.js +16 -13
  56. package/dist/transport/foir-http.d.ts +13 -13
  57. package/dist/types/index.d.ts +2 -2
  58. package/package.json +3 -3
@@ -1,22 +1,22 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { AuthProviderPublic, FoirAccess, FoirCustomer, FoirSessionConfig, SessionAdapter } from '../auth';
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 customer's access stands. `idle` until something
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
- customer: FoirCustomer | null;
16
- /** The signed-in customer's access, once read. See {@link useFoirAccess}. */
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 customer's access, again if it was read before. */
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<FoirCustomer>;
30
+ }): Promise<FoirUser>;
31
31
  register(vars: {
32
32
  email: string;
33
33
  password: string;
34
- }): Promise<FoirCustomer>;
34
+ }): Promise<FoirUser>;
35
35
  requestOtp(email: string): Promise<boolean>;
36
36
  signInWithOtp(vars: {
37
37
  email: string;
38
38
  otp: string;
39
- }): Promise<FoirCustomer>;
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<FoirCustomer>;
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 customer auth to a React tree. Hydrates the session on mount,
82
- * then exposes the current customer and sign-in/out actions through
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
- customer: FoirCustomer | null;
96
+ user: FoirUser | null;
97
97
  isLoading: boolean;
98
98
  isAuthenticated: boolean;
99
99
  }
100
- /** Read the current session status and customer. */
100
+ /** Read the current session status and user. */
101
101
  export declare function useFoirSession(): FoirSession;
102
- /** The signed-in customer (`{ id, email }`), or null. */
103
- export declare function useFoirUser(): FoirCustomer | null;
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 customer's access, or null: signed out, loading or unavailable. */
113
+ /** The signed-in user's access, or null: signed out, loading or unavailable. */
114
114
  access: FoirAccess | null;
115
- /** Whether the customer holds the role with this key. False until known. */
115
+ /** Whether the user holds the role with this key. False until known. */
116
116
  hasRole(key: string): boolean;
117
- /** Whether the customer's scopes cover this one. False until known. */
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 customer holds and the scopes they resolve to, as the
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<FoirCustomer>;
136
+ }) => Promise<FoirUser>;
137
137
  register: (vars: {
138
138
  email: string;
139
139
  password: string;
140
- }) => Promise<FoirCustomer>;
140
+ }) => Promise<FoirUser>;
141
141
  requestOtp: (email: string) => Promise<boolean>;
142
142
  signInWithOtp: (vars: {
143
143
  email: string;
144
144
  otp: string;
145
- }) => Promise<FoirCustomer>;
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<FoirCustomer>;
149
+ }) => Promise<FoirUser>;
150
150
  signOut: () => Promise<void>;
151
151
  refresh: () => Promise<boolean>;
152
152
  getToken: () => Promise<string | null>;
@@ -1,4 +1,4 @@
1
- import type { FoirCustomer } from '../auth';
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 customer on a successful sign-in (before any redirect). */
12
- onSignIn?(customer: FoirCustomer): void;
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 customer sign-in. Renders an email/password (or OTP) form and,
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 customer's email plus a sign-out button.
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 { FoirCustomerNote, FoirNoteConfig, FoirSubject } from '../data';
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 OPERATOR's — a role that does
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 customer's
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<FoirCustomerNote>;
101
+ export declare function submitFeedbackNote(client: FoirFeedbackClient, submission: FoirFeedbackSubmission): Promise<FoirUserNote>;
@@ -1,8 +1,8 @@
1
1
  /**
2
- * `@foir/sdk/react` — drop-in React components for Foir customers.
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 customer may see with
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, FoirCustomer, SessionAdapter, AuthProviderPublic } from '../auth';
25
+ export type { FoirAccess, FoirUser, SessionAdapter, AuthProviderPublic } from '../auth';
26
26
  export type { FoirEnv } from '../graphql/foir-request';