@oxy.so/services 14.15.1 → 14.15.2

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 (67) hide show
  1. package/lib/commonjs/index.js.map +1 -1
  2. package/lib/commonjs/ui/components/signIn/OxySignInPanel.js +27 -2
  3. package/lib/commonjs/ui/components/signIn/OxySignInPanel.js.map +1 -1
  4. package/lib/commonjs/ui/components/signIn/OxySignUpPanel.js +3 -1
  5. package/lib/commonjs/ui/components/signIn/OxySignUpPanel.js.map +1 -1
  6. package/lib/commonjs/ui/components/signIn/ReauthStep.js +21 -0
  7. package/lib/commonjs/ui/components/signIn/ReauthStep.js.map +1 -1
  8. package/lib/commonjs/ui/context/OxyContext.js +18 -5
  9. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  10. package/lib/commonjs/ui/session/deviceCredentialTracker.js +4 -2
  11. package/lib/commonjs/ui/session/deviceCredentialTracker.js.map +1 -1
  12. package/lib/commonjs/ui/session/setupSignIn.js +6 -0
  13. package/lib/commonjs/ui/session/setupSignIn.js.map +1 -0
  14. package/lib/module/index.js +0 -1
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/module/ui/components/signIn/OxySignInPanel.js +27 -2
  17. package/lib/module/ui/components/signIn/OxySignInPanel.js.map +1 -1
  18. package/lib/module/ui/components/signIn/OxySignUpPanel.js +3 -1
  19. package/lib/module/ui/components/signIn/OxySignUpPanel.js.map +1 -1
  20. package/lib/module/ui/components/signIn/ReauthStep.js +22 -1
  21. package/lib/module/ui/components/signIn/ReauthStep.js.map +1 -1
  22. package/lib/module/ui/context/OxyContext.js +18 -5
  23. package/lib/module/ui/context/OxyContext.js.map +1 -1
  24. package/lib/module/ui/session/deviceCredentialTracker.js +4 -2
  25. package/lib/module/ui/session/deviceCredentialTracker.js.map +1 -1
  26. package/lib/module/ui/session/setupSignIn.js +4 -0
  27. package/lib/module/ui/session/setupSignIn.js.map +1 -0
  28. package/lib/typescript/commonjs/index.d.ts +1 -0
  29. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/ui/components/signIn/ReauthStep.d.ts +2 -1
  32. package/lib/typescript/commonjs/ui/components/signIn/ReauthStep.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts +10 -3
  35. package/lib/typescript/commonjs/ui/context/oxyContextTypes.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/ui/icons/Ionicons.d.ts +1 -1
  37. package/lib/typescript/commonjs/ui/session/deviceCredentialTracker.d.ts +3 -12
  38. package/lib/typescript/commonjs/ui/session/deviceCredentialTracker.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/ui/session/setupSignIn.d.ts +38 -0
  40. package/lib/typescript/commonjs/ui/session/setupSignIn.d.ts.map +1 -0
  41. package/lib/typescript/commonjs/ui/types/navigation.d.ts +7 -3
  42. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  43. package/lib/typescript/module/index.d.ts +1 -0
  44. package/lib/typescript/module/index.d.ts.map +1 -1
  45. package/lib/typescript/module/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
  46. package/lib/typescript/module/ui/components/signIn/ReauthStep.d.ts +2 -1
  47. package/lib/typescript/module/ui/components/signIn/ReauthStep.d.ts.map +1 -1
  48. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  49. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts +10 -3
  50. package/lib/typescript/module/ui/context/oxyContextTypes.d.ts.map +1 -1
  51. package/lib/typescript/module/ui/icons/Ionicons.d.ts +1 -1
  52. package/lib/typescript/module/ui/session/deviceCredentialTracker.d.ts +3 -12
  53. package/lib/typescript/module/ui/session/deviceCredentialTracker.d.ts.map +1 -1
  54. package/lib/typescript/module/ui/session/setupSignIn.d.ts +38 -0
  55. package/lib/typescript/module/ui/session/setupSignIn.d.ts.map +1 -0
  56. package/lib/typescript/module/ui/types/navigation.d.ts +7 -3
  57. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  58. package/package.json +1 -1
  59. package/src/index.ts +5 -0
  60. package/src/ui/components/signIn/OxySignInPanel.tsx +22 -2
  61. package/src/ui/components/signIn/OxySignUpPanel.tsx +1 -1
  62. package/src/ui/components/signIn/ReauthStep.tsx +26 -1
  63. package/src/ui/context/OxyContext.tsx +26 -5
  64. package/src/ui/context/oxyContextTypes.ts +11 -3
  65. package/src/ui/session/deviceCredentialTracker.ts +10 -5
  66. package/src/ui/session/setupSignIn.ts +41 -0
  67. package/src/ui/types/navigation.ts +7 -3
@@ -166,7 +166,7 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
166
166
  languages: [currentLanguage],
167
167
  ...(campaignAttribution ? { campaignAttribution } : {}),
168
168
  });
169
- await handleWebSession(session);
169
+ await handleWebSession(session, { method: 'signup' });
170
170
  writeSignInFlow(flowOwner, SIGN_UP_FLOW_KEY, undefined);
171
171
  } catch (reason) {
172
172
  if (errorCode(reason) === SIGN_IN_ERROR_CODES.usernameTaken) {
@@ -38,7 +38,8 @@ export interface ReauthStepProps {
38
38
  allowPassword?: boolean;
39
39
  /**
40
40
  * The account has an email, and this change accepts a code sent to it.
41
- * Without it the proof is the password alone.
41
+ * Without it the proof is the password alone; with neither, the change is
42
+ * not offered (there is no proof the account could give).
42
43
  */
43
44
  allowEmail?: boolean;
44
45
  /** The account has an authenticator: its code is required too. */
@@ -137,6 +138,30 @@ export const ReauthStep: React.FC<ReauthStepProps> = ({
137
138
 
138
139
  const needsCode = mode === 'email' && !verificationId;
139
140
 
141
+ // No proof this account can give: no email to send a code to, and no password
142
+ // this change accepts. Offering either anyway sends a code nowhere or asks for
143
+ // a password that does not exist, so the change is not offered at all; the
144
+ // account needs an email first (the API refuses both, `reauth.service`).
145
+ if (!allowPassword && !allowEmail) {
146
+ return (
147
+ <OxyAuthScreen>
148
+ <OxyAuthScreenHeader title={title} />
149
+ <AccountFlowNote>{t('signInSecurity.email.noneDescription')}</AccountFlowNote>
150
+ {secondary ? (
151
+ <Button
152
+ appearance="plain"
153
+ tone="neutral"
154
+ size="lg"
155
+ onPress={secondary.onPress}
156
+ testID="reauth-cancel"
157
+ >
158
+ {secondary.label}
159
+ </Button>
160
+ ) : null}
161
+ </OxyAuthScreen>
162
+ );
163
+ }
164
+
140
165
  return (
141
166
  <OxyAuthScreen>
142
167
  <OxyAuthScreenHeader title={title} description={description} />
@@ -120,6 +120,7 @@ import {
120
120
  useBackgroundSessionSync,
121
121
  type IdentitySessionBinding,
122
122
  } from '../session';
123
+ import type { SetupSignInContext } from '../session/setupSignIn';
123
124
  import type { OxyContextState, OxyRuntimeProviderProps, CommitInput } from './oxyContextTypes';
124
125
  import { DEFAULT_SESSION_VALIDITY_MS } from './oxyContextHelpers';
125
126
  import { useFollow } from '../hooks/useFollow';
@@ -847,7 +848,15 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
847
848
  // Used by the QR device flow (`handleWebSession`), password sign-in, 2FA
848
849
  // completion, and the cold boot.
849
850
  const commitSession = useCallback(
850
- async (input: CommitInput, options: { activate: boolean; oauth?: boolean }): Promise<void> => {
851
+ async (
852
+ input: CommitInput,
853
+ options: {
854
+ activate: boolean;
855
+ oauth?: boolean;
856
+ /** How the sign-in happened, for a platform's setup store only. */
857
+ setup?: SetupSignInContext;
858
+ },
859
+ ): Promise<void> => {
851
860
  const isolatedOAuth = options.oauth === true && !input.deviceId && !input.deviceSecret;
852
861
  if (isolatedOAuth || hasIsolatedOAuthSession(runtime)) {
853
862
  sessionClient.resetLocalState();
@@ -881,7 +890,13 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
881
890
  ...(input.accessToken ? { accessToken: input.accessToken } : {}),
882
891
  ...(input.expiresAt ? { expiresAt: input.expiresAt } : {}),
883
892
  };
884
- await authStore.save(next);
893
+ // A platform's setup store (`authStateStore`) is also told how the
894
+ // sign-in happened; the platform's own stores never are.
895
+ if (options.setup && !usesSharedDeviceCredential && authStoreRef.current) {
896
+ await authStoreRef.current.save(next, options.setup);
897
+ } else {
898
+ await authStore.save(next);
899
+ }
885
900
  sessionClientHost.setDeviceCredential({
886
901
  deviceId: input.deviceId,
887
902
  deviceSecret: input.deviceSecret,
@@ -962,6 +977,7 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
962
977
  logger,
963
978
  clientId,
964
979
  identity,
980
+ usesSharedDeviceCredential,
965
981
  ],
966
982
  );
967
983
  const commitSessionRef = useRef(commitSession);
@@ -970,7 +986,10 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
970
986
  // Public `handleWebSession`: commit a session from the QR device flow. It is a
971
987
  // deliberate sign-in on THIS device, so it activates the account.
972
988
  const handleWebSession = useCallback(
973
- async (session: SessionLoginResponse | LoginSessionResult): Promise<void> => {
989
+ async (
990
+ session: SessionLoginResponse | LoginSessionResult,
991
+ setup?: SetupSignInContext,
992
+ ): Promise<void> => {
974
993
  if (!session?.user || !session?.sessionId || !session.accessToken) {
975
994
  throw new Error('Session response did not include a usable session');
976
995
  }
@@ -984,7 +1003,7 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
984
1003
  userId: session.user.id,
985
1004
  user: session.user,
986
1005
  },
987
- { activate: true },
1006
+ { activate: true, ...(setup ? { setup } : {}) },
988
1007
  );
989
1008
  },
990
1009
  [commitSession],
@@ -1103,7 +1122,9 @@ export const OxyRuntimeProvider: React.FC<OxyRuntimeProviderProps> = ({
1103
1122
  oxyServices,
1104
1123
  sessionClient,
1105
1124
  clientId,
1106
- commitSession: (session) => handleWebSessionRef.current(session),
1125
+ // The controller's sign-ins are approvals from a device the person holds
1126
+ // (the QR, the Commons identity): passwordless.
1127
+ commitSession: (session) => handleWebSessionRef.current(session, { method: 'qr' }),
1107
1128
  onSignedIn: () => {
1108
1129
  // Close the dialog: pop the morphed frame back to its host surface, or
1109
1130
  // dismiss the detached surface (whose settle flips `accountDialogOpen`).
@@ -17,11 +17,11 @@ import type {
17
17
  import type {
18
18
  AccountDialogController,
19
19
  AccountDialogView,
20
- AuthStateStore,
21
20
  SessionClient,
22
21
  SessionMode,
23
22
  } from '@oxy.so/core/session';
24
23
  import type { UseFollowHook } from '../hooks/useFollow.types';
24
+ import type { PlatformSetupAuthStateStore, SetupSignInContext } from '../session/setupSignIn';
25
25
  import type { useLanguageManagement } from '../hooks/useLanguageManagement';
26
26
  import type { RouteName } from '../navigation/routes';
27
27
  import type { StartWebOAuthSignInOptions } from '../oauth/browserAuthTransport';
@@ -118,7 +118,15 @@ export interface OxyContextState {
118
118
  * code exchange, an email code or link, a password, a sign-up — as the
119
119
  * active one.
120
120
  */
121
- handleWebSession: (session: SessionLoginResponse | LoginSessionResult) => Promise<void>;
121
+ handleWebSession: (
122
+ session: SessionLoginResponse | LoginSessionResult,
123
+ /**
124
+ * How the sign-in happened, handed to a platform's setup store
125
+ * (`authStateStore`) with the credential, and to no other store
126
+ * (`SetupSignInContext`).
127
+ */
128
+ setup?: SetupSignInContext,
129
+ ) => Promise<void>;
122
130
 
123
131
  /**
124
132
  * Run a WEB third-party OAuth sign-in (authorization code + PKCE) end to end
@@ -259,7 +267,7 @@ export interface OxyRuntimeProviderProps {
259
267
  /** Storage instance owned by the public provider; internal composition seam. */
260
268
  platformStorage?: StorageInterface | null;
261
269
  /** See `OxyProviderProps.authStateStore`. Read once, at mount. */
262
- authStateStore?: AuthStateStore;
270
+ authStateStore?: PlatformSetupAuthStateStore;
263
271
  /** See `OxyProviderProps.accountQueries`. Read once, at mount. */
264
272
  accountQueries?: AccountQueriesConfig;
265
273
  }
@@ -7,14 +7,15 @@
7
7
  * every load, save and clear passes through, so the press can read it at once.
8
8
  * The cold boot loads the store on mount, long before anyone presses sign-in.
9
9
  */
10
- import type { AuthStateStore, AuthStateWriteGuard, PersistedAuthState } from '@oxy.so/core/session';
10
+ import type { AuthStateWriteGuard, PersistedAuthState } from '@oxy.so/core/session';
11
+ import type { PlatformSetupAuthStateStore, SetupSignInContext } from './setupSignIn';
11
12
 
12
13
  export interface HeldDeviceCredential {
13
14
  deviceId: string;
14
15
  deviceSecret: string;
15
16
  }
16
17
 
17
- export interface CredentialTrackingAuthStateStore extends AuthStateStore {
18
+ export interface CredentialTrackingAuthStateStore extends PlatformSetupAuthStateStore {
18
19
  /**
19
20
  * The credential last seen through this store; `undefined` until the store has
20
21
  * been read at least once (unknown — the caller should not guess).
@@ -30,7 +31,9 @@ function credentialOf(
30
31
  : null;
31
32
  }
32
33
 
33
- export function trackDeviceCredential(store: AuthStateStore): CredentialTrackingAuthStateStore {
34
+ export function trackDeviceCredential(
35
+ store: PlatformSetupAuthStateStore,
36
+ ): CredentialTrackingAuthStateStore {
34
37
  let held: HeldDeviceCredential | null | undefined;
35
38
  return {
36
39
  ...store,
@@ -39,9 +42,11 @@ export function trackDeviceCredential(store: AuthStateStore): CredentialTracking
39
42
  held = credentialOf(state);
40
43
  return state;
41
44
  },
42
- save: async (state) => {
45
+ // The setup context (how the sign-in happened) goes to the wrapped store
46
+ // only when the caller passed one, so a plain store sees its usual call.
47
+ save: async (state: PersistedAuthState, context?: SetupSignInContext) => {
43
48
  held = credentialOf(state);
44
- return store.save(state);
49
+ return context ? store.save(state, context) : store.save(state);
45
50
  },
46
51
  ...(store.saveIfCurrent
47
52
  ? {
@@ -0,0 +1,41 @@
1
+ /**
2
+ * What a platform's setup client is told about each sign-in it commits.
3
+ *
4
+ * A platform that runs the SDK's own sign-in at its setup (OxyOS's login
5
+ * screen) gives the provider its own store (`OxyProviderProps.authStateStore`),
6
+ * and `save()` receives the credential the moment a sign-in commits. The
7
+ * platform also needs to know HOW the person signed in, because its own setup
8
+ * differs:
9
+ *
10
+ * - `'qr'`: approved from a device the person already holds (the QR a phone
11
+ * scans, or the Commons identity): passwordless, so the platform asks no
12
+ * password; its service redeems the approval for its own credential
13
+ * (`POST /session/device/platform`, ADR 0058 R6);
14
+ * - `'password'`: the account's password, which the person just typed and the
15
+ * platform may reuse once (OxyOS keeps it as its offline verifier) instead of
16
+ * asking for it again; it is in `password`, with or without a second factor;
17
+ * - `'emailCode'`: the code or the link sent by email;
18
+ * - `'signup'`: a new account.
19
+ *
20
+ * Passed as `save()`'s second argument, and ONLY to a store the app provided:
21
+ * the platform's default stores never receive it. The SDK never keeps the
22
+ * password beyond handing it over, never persists it and never logs it.
23
+ */
24
+
25
+ import type { AuthStateStore, PersistedAuthState } from '@oxy.so/core/session';
26
+
27
+ export type SetupSignInMethod = 'qr' | 'password' | 'emailCode' | 'signup';
28
+
29
+ export interface SetupSignInContext {
30
+ method: SetupSignInMethod;
31
+ /** The password just typed; present only when `method` is `'password'`. */
32
+ password?: string;
33
+ }
34
+
35
+ /**
36
+ * A platform's setup store: an {@link AuthStateStore} whose `save()` may also
37
+ * read how the sign-in happened. Every `AuthStateStore` is one.
38
+ */
39
+ export interface PlatformSetupAuthStateStore extends Omit<AuthStateStore, 'save'> {
40
+ save(state: PersistedAuthState, context?: SetupSignInContext): Promise<boolean>;
41
+ }
@@ -4,7 +4,8 @@ import type { AccountQueriesConfig } from '../hooks/accountQueryPersistence';
4
4
  import type { RouteName } from '../navigation/routes';
5
5
  import type { User } from '@oxy.so/core';
6
6
  import type { ClientSession } from '@oxy.so/core';
7
- import type { AuthStateStore, SessionMode } from '@oxy.so/core/session';
7
+ import type { SessionMode } from '@oxy.so/core/session';
8
+ import type { PlatformSetupAuthStateStore } from '../session/setupSignIn';
8
9
  import type { WebAuthMode } from '../oauth/types';
9
10
  import type { ProductAnalytics } from '../analytics/productAnalytics';
10
11
 
@@ -200,13 +201,16 @@ export interface OxyProviderProps {
200
201
  * off) and no background credential (`backgroundSession` is ignored). The
201
202
  * email-code, password and authenticator sign-ins and the "add a password"
202
203
  * flow (ADR 0030) run as usual; `save()` receives the credential the moment
203
- * a sign-in commits, so the platform can take it over.
204
+ * a sign-in commits, so the platform can take it over, and, as its second
205
+ * argument, how the sign-in happened (`SetupSignInContext`: the QR's
206
+ * approval, a password with the password just typed, an email code, a
207
+ * sign-up). Only this store ever receives that context.
204
208
  *
205
209
  * Ordinary apps never pass it. Never combined with a session host: when a
206
210
  * platform has registered one (`@oxy.so/core/host`), the host wins and this
207
211
  * is ignored. Read once, at mount.
208
212
  */
209
- authStateStore?: AuthStateStore;
213
+ authStateStore?: PlatformSetupAuthStateStore;
210
214
  }
211
215
 
212
216
  export interface OxyLanguageConfig {