@foir/sdk 0.30.0 → 0.31.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/dist/push.js CHANGED
@@ -1069,7 +1069,7 @@ async function fetchFoirManifest(config, options = {}) {
1069
1069
 
1070
1070
  // src/auth/ops.ts
1071
1071
  var AUTH_OPS = {
1072
- // Pre-credential reads a login screen renders itself from.
1072
+ // Pre-credential reads a sign-in screen renders itself from.
1073
1073
  authConfig: "authConfig",
1074
1074
  authProviders: "authProviders",
1075
1075
  defaultAuthProvider: "defaultAuthProvider",
@@ -1081,17 +1081,15 @@ var AUTH_OPS = {
1081
1081
  // they hold. `./access` reads it.
1082
1082
  whoami: "whoami",
1083
1083
  // Methods.
1084
- login: "login",
1084
+ signIn: "signIn",
1085
1085
  register: "register",
1086
1086
  requestOTP: "requestOTP",
1087
- loginWithOTP: "loginWithOTP",
1088
1087
  // Session lifecycle.
1089
1088
  refreshToken: "refreshToken",
1090
- logout: "logout",
1089
+ signOut: "signOut",
1091
1090
  joinWaitlist: "joinWaitlist",
1092
1091
  // Password management and account lifecycle.
1093
1092
  requestPasswordReset: "requestPasswordReset",
1094
- resetPassword: "resetPassword",
1095
1093
  updatePassword: "updatePassword",
1096
1094
  deleteMyAccount: "deleteMyAccount",
1097
1095
  // Ending their own membership where the request stands.
@@ -1105,10 +1103,10 @@ var AUTH_OPS = {
1105
1103
  mySessions: "mySessions",
1106
1104
  endMySession: "endMySession",
1107
1105
  signOutEverywhere: "signOutEverywhere",
1108
- // Their email addresses: one added is kept once the code it was sent proves it.
1106
+ // Their email addresses: one added is kept once the code it was sent comes
1107
+ // back on the step addMyAddress answers, on its own route (proveMyAddress).
1109
1108
  myAddresses: "myAddresses",
1110
1109
  addMyAddress: "addMyAddress",
1111
- proveMyAddress: "proveMyAddress",
1112
1110
  makeMyAddressPrimary: "makeMyAddressPrimary",
1113
1111
  removeMyAddress: "removeMyAddress",
1114
1112
  // A copy of their own data.
@@ -1119,10 +1117,8 @@ var AUTH_OPS = {
1119
1117
  disconnectSignInMethod: "disconnectSignInMethod",
1120
1118
  // Their second factors. A change needs one proven first, by a step-up.
1121
1119
  myFactors: "myFactors",
1122
- beginStepUp: "beginStepUp",
1123
- completeStepUp: "completeStepUp",
1120
+ stepUp: "stepUp",
1124
1121
  beginFactorEnrollment: "beginFactorEnrollment",
1125
- completeFactorEnrollment: "completeFactorEnrollment",
1126
1122
  removeFactor: "removeFactor",
1127
1123
  renameFactor: "renameFactor",
1128
1124
  makeRecoveryCodes: "makeRecoveryCodes",
@@ -1136,13 +1132,7 @@ var AUTH_OPS = {
1136
1132
  // Founding one. Present in a manifest only when the project opted in.
1137
1133
  registerOrganization: "registerOrganization",
1138
1134
  // External identity providers.
1139
- loginWithProvider: "loginWithProvider",
1140
- providerCallback: "providerCallback",
1141
- providerVerifyOTP: "providerVerifyOTP",
1142
- // A provider sign-in that names an address somebody already holds, waiting
1143
- // for the code sent to it.
1144
- confirmProviderLink: "confirmProviderLink",
1145
- resendProviderLinkCode: "resendProviderLinkCode"
1135
+ signInWithProvider: "signInWithProvider"
1146
1136
  };
1147
1137
  function authClientConfig(env, options) {
1148
1138
  const apiKey = resolveFoirApiKey(env);
@@ -1207,7 +1197,7 @@ var TOKEN_KEY = "foir:token";
1207
1197
  var REFRESH_KEY = "foir:refreshToken";
1208
1198
  var USER_ID_KEY = "foir:userId";
1209
1199
  var EMAIL_KEY = "foir:email";
1210
- async function refreshTokens(env, refreshToken) {
1200
+ async function rotateTokens(env, refreshToken) {
1211
1201
  return authOp(env, AUTH_OPS.refreshToken, { refreshToken });
1212
1202
  }
1213
1203
  async function saveSession(adapter, result) {
@@ -1239,7 +1229,7 @@ async function refreshSession(adapter, env) {
1239
1229
  const refreshToken = await adapter.get(REFRESH_KEY) ?? null;
1240
1230
  if (!refreshToken) return null;
1241
1231
  try {
1242
- const result = await refreshTokens(env, refreshToken);
1232
+ const result = await rotateTokens(env, refreshToken);
1243
1233
  await saveSession(adapter, result);
1244
1234
  return { token: result.token, refreshToken: result.refreshToken };
1245
1235
  } catch {
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { AuthProviderPublic, FoirAccess, FoirUser, FoirSessionConfig, HostedLoginOptions, SessionAdapter } from '../auth';
3
- import type { ProviderCallbackInput, ProviderLoginInput } from '../auth';
2
+ import type { AuthProviderPublic, FoirAccess, FoirUser, FoirSessionConfig, HostedSignInOptions, SessionAdapter } from '../auth';
3
+ import type { ProviderCallbackInput, ProviderSignInInput } 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';
@@ -32,21 +32,25 @@ export interface FoirContextValue {
32
32
  * Start a sign-up: the address is mailed a code, and `signInWithOtp` with it
33
33
  * finishes the account and signs them in.
34
34
  */
35
- register(vars: {
35
+ signUp(vars: {
36
36
  email: string;
37
37
  password: string;
38
38
  }): Promise<void>;
39
+ /** Email the address a code to sign in with; `signInWithOtp` brings it back. */
39
40
  requestOtp(email: string): Promise<boolean>;
41
+ /**
42
+ * Bring back the code the address was last sent by `requestOtp` or
43
+ * `signUp`, to the step that sent it, and sign them in.
44
+ */
40
45
  signInWithOtp(vars: {
41
46
  email: string;
42
47
  otp: string;
43
48
  }): Promise<FoirUser>;
44
- /** Start a provider (OAuth/OIDC) login. Redirect providers navigate away. */
45
- signInWithProvider(providerKey: string, opts?: Omit<ProviderLoginInput, 'providerKey'>): Promise<void>;
46
- /** Complete a provider login from your callback route (code + state). */
47
- completeProviderLogin(input: Omit<ProviderCallbackInput, 'providerKey'> & {
48
- providerKey: string;
49
- }): Promise<FoirUser>;
49
+ /** Start a provider (OAuth/OIDC) sign-in. Redirect providers navigate away. */
50
+ signInWithProvider(providerKey: string, opts?: Omit<ProviderSignInInput, 'providerKey'>): Promise<void>;
51
+ /** Finish a provider sign-in on your callback route (code + state). */
52
+ finishProviderSignIn(input: ProviderCallbackInput): Promise<FoirUser>;
53
+ /** End the session on the platform and here. */
50
54
  signOut(): Promise<void>;
51
55
  /** Rotate the access token; returns false (and signs out) if it can't. */
52
56
  refresh(): Promise<boolean>;
@@ -60,7 +64,7 @@ export interface FoirContextValue {
60
64
  * where you call {@link FoirContextValue.signIn} instead. `options.org` names
61
65
  * the organization the sign-in is for.
62
66
  */
63
- hostedSignInUrl: ((returnTo?: string, options?: HostedLoginOptions) => string) | null;
67
+ hostedSignInUrl: ((returnTo?: string, options?: HostedSignInOptions) => string) | null;
64
68
  }
65
69
  export interface FoirProviderProps {
66
70
  /** API config: `{ PLATFORM_API_URL, PLATFORM_API_KEY }` (a publishable key). */
@@ -139,7 +143,7 @@ export declare function useFoirAuth(): {
139
143
  email: string;
140
144
  password: string;
141
145
  }) => Promise<FoirUser>;
142
- register: (vars: {
146
+ signUp: (vars: {
143
147
  email: string;
144
148
  password: string;
145
149
  }) => Promise<void>;
@@ -148,13 +152,11 @@ export declare function useFoirAuth(): {
148
152
  email: string;
149
153
  otp: string;
150
154
  }) => Promise<FoirUser>;
151
- signInWithProvider: (providerKey: string, opts?: Omit<ProviderLoginInput, "providerKey">) => Promise<void>;
152
- completeProviderLogin: (input: Omit<ProviderCallbackInput, "providerKey"> & {
153
- providerKey: string;
154
- }) => Promise<FoirUser>;
155
+ signInWithProvider: (providerKey: string, opts?: Omit<ProviderSignInInput, "providerKey">) => Promise<void>;
156
+ finishProviderSignIn: (input: ProviderCallbackInput) => Promise<FoirUser>;
155
157
  signOut: () => Promise<void>;
156
158
  refresh: () => Promise<boolean>;
157
159
  getToken: () => Promise<string | null>;
158
160
  getProviders: () => Promise<AuthProviderPublic[]>;
159
- hostedSignInUrl: ((returnTo?: string, options?: HostedLoginOptions) => string) | null;
161
+ hostedSignInUrl: ((returnTo?: string, options?: HostedSignInOptions) => string) | null;
160
162
  };
@@ -54,8 +54,7 @@ interface FoirGeneratedFeedbackClient {
54
54
  * optional. Screenshot capture is the only thing that reaches it.
55
55
  */
56
56
  readonly files?: {
57
- createFileUpload(args?: Record<string, unknown>): Promise<unknown>;
58
- confirmFileUpload(args?: Record<string, unknown>): Promise<unknown>;
57
+ uploadFile(args?: Record<string, unknown>): Promise<unknown>;
59
58
  };
60
59
  };
61
60
  }