@oxy.so/services 14.0.1 → 14.1.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/lib/commonjs/ui/components/accountSettings/AccountSettings.js +5 -5
- package/lib/commonjs/ui/components/accountSettings/AccountSettings.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxyAuthenticatorPanel.js +2 -1
- package/lib/commonjs/ui/components/signIn/OxyAuthenticatorPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxyDeleteAccountPanel.js +9 -3
- package/lib/commonjs/ui/components/signIn/OxyDeleteAccountPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxyEmailPanel.js +2 -1
- package/lib/commonjs/ui/components/signIn/OxyEmailPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxyLinkCommonsPanel.js +2 -1
- package/lib/commonjs/ui/components/signIn/OxyLinkCommonsPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxyPasswordPanel.js +8 -1
- package/lib/commonjs/ui/components/signIn/OxyPasswordPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxySignInPanel.js +6 -3
- package/lib/commonjs/ui/components/signIn/OxySignInPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/OxySignUpPanel.js +39 -10
- package/lib/commonjs/ui/components/signIn/OxySignUpPanel.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/ReauthStep.js +7 -1
- package/lib/commonjs/ui/components/signIn/ReauthStep.js.map +1 -1
- package/lib/commonjs/ui/components/signIn/accountFlowParts.js +16 -86
- package/lib/commonjs/ui/components/signIn/accountFlowParts.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/mutationFactory.js +5 -4
- package/lib/commonjs/ui/hooks/mutations/mutationFactory.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +31 -7
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useServicesMutations.js +22 -5
- package/lib/commonjs/ui/hooks/mutations/useServicesMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/useUsernameAvailability.js +8 -3
- package/lib/commonjs/ui/hooks/useUsernameAvailability.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountMembersScreen.js +25 -21
- package/lib/commonjs/ui/screens/AccountMembersScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/CreateAccountScreen.js +15 -19
- package/lib/commonjs/ui/screens/CreateAccountScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/DomainsScreen.js +25 -11
- package/lib/commonjs/ui/screens/DomainsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +10 -5
- package/lib/commonjs/ui/screens/EditProfileFieldScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +27 -7
- package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/apiErrorMessage.js +117 -0
- package/lib/commonjs/ui/utils/apiErrorMessage.js.map +1 -0
- package/lib/commonjs/ui/utils/usernamePolicy.js +75 -0
- package/lib/commonjs/ui/utils/usernamePolicy.js.map +1 -0
- package/lib/module/ui/components/accountSettings/AccountSettings.js +5 -5
- package/lib/module/ui/components/accountSettings/AccountSettings.js.map +1 -1
- package/lib/module/ui/components/signIn/OxyAuthenticatorPanel.js +3 -2
- package/lib/module/ui/components/signIn/OxyAuthenticatorPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/OxyDeleteAccountPanel.js +9 -3
- package/lib/module/ui/components/signIn/OxyDeleteAccountPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/OxyEmailPanel.js +3 -2
- package/lib/module/ui/components/signIn/OxyEmailPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/OxyLinkCommonsPanel.js +3 -2
- package/lib/module/ui/components/signIn/OxyLinkCommonsPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/OxyPasswordPanel.js +8 -1
- package/lib/module/ui/components/signIn/OxyPasswordPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/OxySignInPanel.js +7 -4
- package/lib/module/ui/components/signIn/OxySignInPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/OxySignUpPanel.js +38 -9
- package/lib/module/ui/components/signIn/OxySignUpPanel.js.map +1 -1
- package/lib/module/ui/components/signIn/ReauthStep.js +9 -3
- package/lib/module/ui/components/signIn/ReauthStep.js.map +1 -1
- package/lib/module/ui/components/signIn/accountFlowParts.js +15 -82
- package/lib/module/ui/components/signIn/accountFlowParts.js.map +1 -1
- package/lib/module/ui/hooks/mutations/mutationFactory.js +5 -4
- package/lib/module/ui/hooks/mutations/mutationFactory.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +31 -7
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useServicesMutations.js +22 -5
- package/lib/module/ui/hooks/mutations/useServicesMutations.js.map +1 -1
- package/lib/module/ui/hooks/useUsernameAvailability.js +8 -3
- package/lib/module/ui/hooks/useUsernameAvailability.js.map +1 -1
- package/lib/module/ui/screens/AccountMembersScreen.js +25 -21
- package/lib/module/ui/screens/AccountMembersScreen.js.map +1 -1
- package/lib/module/ui/screens/CreateAccountScreen.js +16 -20
- package/lib/module/ui/screens/CreateAccountScreen.js.map +1 -1
- package/lib/module/ui/screens/DomainsScreen.js +26 -10
- package/lib/module/ui/screens/DomainsScreen.js.map +1 -1
- package/lib/module/ui/screens/EditProfileFieldScreen.js +11 -6
- package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
- package/lib/module/ui/screens/WelcomeNewUserScreen.js +29 -9
- package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
- package/lib/module/ui/utils/apiErrorMessage.js +107 -0
- package/lib/module/ui/utils/apiErrorMessage.js.map +1 -0
- package/lib/module/ui/utils/usernamePolicy.js +70 -0
- package/lib/module/ui/utils/usernamePolicy.js.map +1 -0
- package/lib/typescript/commonjs/ui/components/accountSettings/AccountSettings.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/OxyDeleteAccountPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/OxyLinkCommonsPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/OxyPasswordPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/OxySignUpPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/ReauthStep.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/signIn/accountFlowParts.d.ts +7 -16
- package/lib/typescript/commonjs/ui/components/signIn/accountFlowParts.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts +4 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useUsernameAvailability.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountMembersScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/CreateAccountScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/DomainsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/apiErrorMessage.d.ts +30 -0
- package/lib/typescript/commonjs/ui/utils/apiErrorMessage.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/usernamePolicy.d.ts +33 -0
- package/lib/typescript/commonjs/ui/utils/usernamePolicy.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/accountSettings/AccountSettings.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/OxyDeleteAccountPanel.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/OxyLinkCommonsPanel.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/OxyPasswordPanel.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/OxySignInPanel.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/OxySignUpPanel.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/ReauthStep.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/signIn/accountFlowParts.d.ts +7 -16
- package/lib/typescript/module/ui/components/signIn/accountFlowParts.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts +4 -1
- package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useUsernameAvailability.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountMembersScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/CreateAccountScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/DomainsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/apiErrorMessage.d.ts +30 -0
- package/lib/typescript/module/ui/utils/apiErrorMessage.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/usernamePolicy.d.ts +33 -0
- package/lib/typescript/module/ui/utils/usernamePolicy.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/ui/components/accountSettings/AccountSettings.tsx +5 -7
- package/src/ui/components/signIn/OxyAuthenticatorPanel.tsx +2 -2
- package/src/ui/components/signIn/OxyDeleteAccountPanel.tsx +7 -3
- package/src/ui/components/signIn/OxyEmailPanel.tsx +2 -2
- package/src/ui/components/signIn/OxyLinkCommonsPanel.tsx +3 -7
- package/src/ui/components/signIn/OxyPasswordPanel.tsx +6 -1
- package/src/ui/components/signIn/OxySignInPanel.tsx +13 -6
- package/src/ui/components/signIn/OxySignUpPanel.tsx +38 -11
- package/src/ui/components/signIn/ReauthStep.tsx +9 -3
- package/src/ui/components/signIn/accountFlowParts.tsx +16 -87
- package/src/ui/hooks/mutations/mutationFactory.ts +9 -10
- package/src/ui/hooks/mutations/useAccountMutations.ts +20 -9
- package/src/ui/hooks/mutations/useServicesMutations.ts +12 -5
- package/src/ui/hooks/useUsernameAvailability.ts +6 -3
- package/src/ui/screens/AccountMembersScreen.tsx +29 -27
- package/src/ui/screens/CreateAccountScreen.tsx +20 -40
- package/src/ui/screens/DomainsScreen.tsx +22 -11
- package/src/ui/screens/EditProfileFieldScreen.tsx +10 -8
- package/src/ui/screens/WelcomeNewUserScreen.tsx +36 -14
- package/src/ui/utils/apiErrorMessage.ts +111 -0
- package/src/ui/utils/usernamePolicy.ts +81 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiErrorMessage.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/apiErrorMessage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAkB,CAAC;AAElD,yEAAyE;AACzE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG5D;AAED,6CAA6C;AAC7C,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAK9D;AAED,0CAA0C;AAC1C,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIxD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAqDxF;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMvD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The username policy, in the words of the person typing.
|
|
3
|
+
*
|
|
4
|
+
* Every field that takes a username (signing up, editing yours, creating an
|
|
5
|
+
* account you manage) asks the ONE policy in `@oxy.so/contracts/client` and
|
|
6
|
+
* says WHICH rule the candidate broke, localized. The policy's own messages are
|
|
7
|
+
* English and catch-all; shown raw, or not checked at all, a name like
|
|
8
|
+
* `hash saah` reached the server, was refused with a 400, and the person read
|
|
9
|
+
* "Something went wrong".
|
|
10
|
+
*/
|
|
11
|
+
import type { AccountKind } from '@oxy.so/core';
|
|
12
|
+
import type { Translate } from '../hooks/useI18n.js';
|
|
13
|
+
export type UsernameDraftResult = {
|
|
14
|
+
ok: true;
|
|
15
|
+
username: string;
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Hold a typed username to the policy for `kind` (`bot` handles end in `bot`).
|
|
22
|
+
* On success `username` is the trimmed handle to send; on failure `error` is
|
|
23
|
+
* the localized reason, specific to the rule that failed.
|
|
24
|
+
*/
|
|
25
|
+
export declare function checkUsernameDraft(value: string, t: Translate, kind?: AccountKind | null): UsernameDraftResult;
|
|
26
|
+
/**
|
|
27
|
+
* The server's refusal of `username` (a 400 naming the `username` field, whose
|
|
28
|
+
* message is the policy's), in the same words as {@link checkUsernameDraft};
|
|
29
|
+
* `null` when `reason` is something else. The backstop for a rule this client
|
|
30
|
+
* does not know yet: the person still reads which rule, in their language.
|
|
31
|
+
*/
|
|
32
|
+
export declare function describeUsernameRefusal(reason: unknown, username: string, t: Translate): string | null;
|
|
33
|
+
//# sourceMappingURL=usernamePolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usernamePolicy.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/usernamePolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAShD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAkB,CAAC;AAElD,MAAM,MAAM,mBAAmB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,CAAC,EAAE,SAAS,EACZ,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,GACxB,mBAAmB,CAMrB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,MAAM,EAChB,CAAC,EAAE,SAAS,GACX,MAAM,GAAG,IAAI,CASf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/services",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.1.1",
|
|
4
4
|
"description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -176,16 +176,16 @@
|
|
|
176
176
|
"delete-dts.js": "find ./lib/commonjs -name '*.d.js*' -delete && find ./lib/module -name '*.d.js*' -delete"
|
|
177
177
|
},
|
|
178
178
|
"dependencies": {
|
|
179
|
-
"@oxy.so/contracts": "^6.
|
|
179
|
+
"@oxy.so/contracts": "^6.5.0",
|
|
180
180
|
"color": "^5.0.3",
|
|
181
|
-
"@peable.to/sdk": "0.
|
|
181
|
+
"@peable.to/sdk": "0.8.0"
|
|
182
182
|
},
|
|
183
183
|
"devDependencies": {
|
|
184
184
|
"@commitlint/cli": "^21.2.1",
|
|
185
185
|
"@commitlint/config-conventional": "^21.2.0",
|
|
186
186
|
"@expo/app-integrity": "~58.0.2",
|
|
187
187
|
"@expo/vector-icons": "^15.0.3",
|
|
188
|
-
"@oxy.so/core": "7.
|
|
188
|
+
"@oxy.so/core": "7.13.0",
|
|
189
189
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
190
190
|
"@react-native-community/netinfo": "^12.0.1",
|
|
191
191
|
"@react-native/babel-preset": "^0.88.0",
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
"@types/jest": "^30.0.0",
|
|
200
200
|
"@types/node": "^20.19.43",
|
|
201
201
|
"@types/react": "*",
|
|
202
|
-
"@oxy.so/bloom": "16.
|
|
202
|
+
"@oxy.so/bloom": "16.6.0",
|
|
203
203
|
"copyfiles": "^2.4.1",
|
|
204
204
|
"expo-clipboard": "~58.0.4",
|
|
205
205
|
"expo-constants": "~58.0.13",
|
|
@@ -235,13 +235,13 @@
|
|
|
235
235
|
"expo-video": "~58.0.12"
|
|
236
236
|
},
|
|
237
237
|
"//@oxy.so/bloom": "Bloom 11.1.0 adds the shared grouped sections, usage card, subscription plans, frame appearance and overlay navigation APIs used by this SDK. First-party Bloom peers remain open above this tested minimum.",
|
|
238
|
-
"//@oxy.so/core": "Core 7.9.1 fences ordinary authenticated HTTP requests across session changes during auth preflight, which organization claim and creation require; 7.9.0 supplies `deviceComparisonCode`, the short code `OxyDeviceSignIn` prints; 7.8.0 supplies the device sign-in request's `approvalUrl` and the `signin.device.*` strings `OxyDeviceSignIn` shows; 7.7.0 supplies the bounded native asset file adapter and phase progress installed by OxyProvider; 7.6.0 forwards guest locale and first-touch campaign metadata through signup; 7.3.0 supplies `users.lookupMany`, with which the account members screen fails (and retries) a profile read whose chunk failed instead of caching those members as handle-less; 7.2.0 supplies `assets.cachedUrl`, with which `useFileDownloadUrl` answers an already-resolved URL in its first render; 6.16.0 supplies `requireServerVerdict` and `onHolderRejected`, with which the cold boot checks a session it painted from the cache; 6.13.0 supplies the `accounts.settings.*` strings (picture, categories) the account settings speak in every language; 6.12.0 supplies `fileManagement.contentLost` and the `lost` file status a lost file is listed with; 6.11.0 supplies the `follow.errors.*` strings the follow error codes are worded with; 6.4.0 the `follow.*` strings the follow buttons read for every verb and language; 6.1.0 the `oxy.auth.email.{startChange,change,remove}` and `oxy.auth.password.remove` the sign-in & security panels call. Keep one Core instance per app; raise this floor with the root catalogue when new runtime APIs are required.",
|
|
238
|
+
"//@oxy.so/core": "Core 7.13.0 supplies the `usernamePolicy.*`, `actionErrors.*` and `signin.errors.{network,invalidInput,server}` strings every username field and failure toast is worded with; 7.9.1 fences ordinary authenticated HTTP requests across session changes during auth preflight, which organization claim and creation require; 7.9.0 supplies `deviceComparisonCode`, the short code `OxyDeviceSignIn` prints; 7.8.0 supplies the device sign-in request's `approvalUrl` and the `signin.device.*` strings `OxyDeviceSignIn` shows; 7.7.0 supplies the bounded native asset file adapter and phase progress installed by OxyProvider; 7.6.0 forwards guest locale and first-touch campaign metadata through signup; 7.3.0 supplies `users.lookupMany`, with which the account members screen fails (and retries) a profile read whose chunk failed instead of caching those members as handle-less; 7.2.0 supplies `assets.cachedUrl`, with which `useFileDownloadUrl` answers an already-resolved URL in its first render; 6.16.0 supplies `requireServerVerdict` and `onHolderRejected`, with which the cold boot checks a session it painted from the cache; 6.13.0 supplies the `accounts.settings.*` strings (picture, categories) the account settings speak in every language; 6.12.0 supplies `fileManagement.contentLost` and the `lost` file status a lost file is listed with; 6.11.0 supplies the `follow.errors.*` strings the follow error codes are worded with; 6.4.0 the `follow.*` strings the follow buttons read for every verb and language; 6.1.0 the `oxy.auth.email.{startChange,change,remove}` and `oxy.auth.password.remove` the sign-in & security panels call. Keep one Core instance per app; raise this floor with the root catalogue when new runtime APIs are required.",
|
|
239
239
|
"//react-native": "React Native 0.81 to 0.88, React 19.1+ and Expo SDK 54 to 58. The floors are the Expo SDK 54 stack (react-native 0.81.6, react 19.1.4, react-native-web 0.21.4, expo 54.0.38 and the module versions its bundledNativeModules.json pins), which compat/expo-54 installs as an external consumer and checks on every CI run (`bun check.mjs`): every peer here admits that stack, services' published src typechecks against its types, and <OxyProvider> mounts and settles its cold boot on iOS (React Native 0.81), web (react-native-web 0.21) and react-native-macos 0.81 with the native modules macOS lacks absent. Astro, Oxy's browser, runs react-native-macos 0.81 (0.83 is its latest release), which is why the floor is not 0.85. The SDK 56 floors these replaced were the versions current when the ranges were first written, not measurements.",
|
|
240
240
|
"peerDependencies": {
|
|
241
241
|
"@expo/app-integrity": ">=0.1.10 <59.0.0",
|
|
242
242
|
"@expo/vector-icons": "^15.0.3",
|
|
243
243
|
"@oxy.so/bloom": ">=11.1.0",
|
|
244
|
-
"@oxy.so/core": "^7.
|
|
244
|
+
"@oxy.so/core": "^7.13.0",
|
|
245
245
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
|
246
246
|
"@react-native-community/netinfo": ">=11.4.1 <13.0.0",
|
|
247
247
|
"@tanstack/query-async-storage-persister": "^5.101",
|
|
@@ -35,13 +35,11 @@ import type { BaseScreenProps } from '../../types/navigation';
|
|
|
35
35
|
import { OrganizationSettings } from '../organizations/OrganizationSettings';
|
|
36
36
|
import { SettingsIcon } from '../SettingsIcon';
|
|
37
37
|
import { AccountCategoriesSection, accountCategoriesEqual } from './AccountCategoriesSection';
|
|
38
|
+
import { describeApiError } from '../../utils/apiErrorMessage';
|
|
38
39
|
|
|
39
40
|
const BIO_MAX = 160;
|
|
40
41
|
const AVATAR_SIZE = 64;
|
|
41
42
|
|
|
42
|
-
const errorMessage = (error: unknown, fallback: string): string =>
|
|
43
|
-
error instanceof Error && error.message ? error.message : fallback;
|
|
44
|
-
|
|
45
43
|
/**
|
|
46
44
|
* How archiving the account behaves, for an app whose ending of an account
|
|
47
45
|
* means more than Oxy's archive.
|
|
@@ -185,7 +183,7 @@ export const AccountSettings: React.FC<AccountSettingsProps> = ({
|
|
|
185
183
|
toast.success(t('accounts.settings.toasts.saved'));
|
|
186
184
|
},
|
|
187
185
|
onError: (error) => {
|
|
188
|
-
toast.error(
|
|
186
|
+
toast.error(describeApiError(error, t, t('accounts.settings.toasts.saveFailed')));
|
|
189
187
|
},
|
|
190
188
|
});
|
|
191
189
|
|
|
@@ -211,7 +209,7 @@ export const AccountSettings: React.FC<AccountSettingsProps> = ({
|
|
|
211
209
|
else onClose?.();
|
|
212
210
|
},
|
|
213
211
|
onError: (error) => {
|
|
214
|
-
toast.error(
|
|
212
|
+
toast.error(describeApiError(error, t, t('accounts.settings.toasts.archiveFailed')));
|
|
215
213
|
},
|
|
216
214
|
});
|
|
217
215
|
|
|
@@ -229,7 +227,7 @@ export const AccountSettings: React.FC<AccountSettingsProps> = ({
|
|
|
229
227
|
destructive: true,
|
|
230
228
|
});
|
|
231
229
|
} catch (error) {
|
|
232
|
-
toast.error(
|
|
230
|
+
toast.error(describeApiError(error, t, t('accounts.settings.toasts.archiveFailed')));
|
|
233
231
|
return;
|
|
234
232
|
}
|
|
235
233
|
if (confirmed) archiveMutation.mutate(node);
|
|
@@ -287,7 +285,7 @@ export const AccountSettings: React.FC<AccountSettingsProps> = ({
|
|
|
287
285
|
});
|
|
288
286
|
if (avatar !== undefined) updateMutation.mutate({ avatar });
|
|
289
287
|
} catch (error) {
|
|
290
|
-
toast.error(
|
|
288
|
+
toast.error(describeApiError(error, t, t('accounts.settings.toasts.saveFailed')));
|
|
291
289
|
}
|
|
292
290
|
}, [account?.avatar, oxyServices, storedName, t, updateMutation]);
|
|
293
291
|
|
|
@@ -35,9 +35,9 @@ import {
|
|
|
35
35
|
AccountFlowErrorLine,
|
|
36
36
|
AccountFlowNote,
|
|
37
37
|
AccountFlowProgress,
|
|
38
|
-
describeSignInError,
|
|
39
38
|
} from './accountFlowParts';
|
|
40
39
|
import { accountSecurityFallback, useAccountSecurityState } from './accountSecurityState';
|
|
40
|
+
import { describeApiError } from '../../utils/apiErrorMessage';
|
|
41
41
|
|
|
42
42
|
/** High-contrast, un-themed on purpose: scan reliability. */
|
|
43
43
|
const QR_PLATE_BG = '#FFFFFF';
|
|
@@ -95,7 +95,7 @@ export const OxyAuthenticatorPanel: React.FC<OxyAuthenticatorPanelProps> = ({ on
|
|
|
95
95
|
setCode('');
|
|
96
96
|
setStep({ name: 'enroll', enrollment });
|
|
97
97
|
})
|
|
98
|
-
.catch((reason: unknown) => setError(
|
|
98
|
+
.catch((reason: unknown) => setError(describeApiError(reason, t)))
|
|
99
99
|
.finally(() => setPending(false));
|
|
100
100
|
};
|
|
101
101
|
|
|
@@ -77,9 +77,13 @@ export const OxyDeleteAccountPanel: React.FC<OxyDeleteAccountPanelProps> = ({
|
|
|
77
77
|
totpEnabled={totpEnabled}
|
|
78
78
|
submitLabel={t('deleteAccount.keyless.action')}
|
|
79
79
|
destructive
|
|
80
|
-
validate={() =>
|
|
81
|
-
confirmText.trim()
|
|
82
|
-
|
|
80
|
+
validate={() => {
|
|
81
|
+
const typed = confirmText.trim();
|
|
82
|
+
if (typed === username) return null;
|
|
83
|
+
return typed
|
|
84
|
+
? t('deleteAccount.confirmMismatch', { username })
|
|
85
|
+
: t('deleteAccount.confirmLabel', { username });
|
|
86
|
+
}}
|
|
83
87
|
onSubmit={async (proof) => {
|
|
84
88
|
// The last word before it is gone: the proof is ready, and nothing has
|
|
85
89
|
// been sent yet. Cancelling keeps the screen as it is, code and all.
|
|
@@ -30,9 +30,9 @@ import {
|
|
|
30
30
|
AccountFlowField,
|
|
31
31
|
AccountFlowNote,
|
|
32
32
|
AccountFlowNotice,
|
|
33
|
-
describeSignInError,
|
|
34
33
|
} from './accountFlowParts';
|
|
35
34
|
import { accountSecurityFallback, useAccountSecurityState } from './accountSecurityState';
|
|
35
|
+
import { describeApiError } from '../../utils/apiErrorMessage';
|
|
36
36
|
|
|
37
37
|
type Step =
|
|
38
38
|
| { name: 'status' }
|
|
@@ -91,7 +91,7 @@ export const OxyEmailPanel: React.FC<OxyEmailPanelProps> = ({ onDone }) => {
|
|
|
91
91
|
setCode('');
|
|
92
92
|
setStep({ name: 'confirm', email, verificationId: started.verificationId });
|
|
93
93
|
})
|
|
94
|
-
.catch((reason: unknown) => setError(
|
|
94
|
+
.catch((reason: unknown) => setError(describeApiError(reason, t)))
|
|
95
95
|
.finally(() => setPending(false));
|
|
96
96
|
};
|
|
97
97
|
|
|
@@ -26,13 +26,9 @@ import { loadIdentityCrypto } from '../../utils/identityCrypto';
|
|
|
26
26
|
import { useI18n } from '../../hooks/useI18n';
|
|
27
27
|
import { OxyAuthScreen, OxyAuthScreenHeader } from './OxyAuthScreen';
|
|
28
28
|
import { ReauthStep } from './ReauthStep';
|
|
29
|
-
import {
|
|
30
|
-
AccountFlowAction,
|
|
31
|
-
AccountFlowErrorLine,
|
|
32
|
-
AccountFlowNote,
|
|
33
|
-
describeSignInError,
|
|
34
|
-
} from './accountFlowParts';
|
|
29
|
+
import { AccountFlowAction, AccountFlowErrorLine, AccountFlowNote } from './accountFlowParts';
|
|
35
30
|
import { accountSecurityFallback, useAccountSecurityState } from './accountSecurityState';
|
|
31
|
+
import { describeApiError } from '../../utils/apiErrorMessage';
|
|
36
32
|
|
|
37
33
|
/** How often the page asks whether Commons has signed. */
|
|
38
34
|
export const IDENTITY_LINK_POLL_MS = 2000;
|
|
@@ -71,7 +67,7 @@ export const OxyLinkCommonsPanel: React.FC<OxyLinkCommonsPanelProps> = ({ onLink
|
|
|
71
67
|
.create()
|
|
72
68
|
.then((link) => setStep({ name: 'qr', link }))
|
|
73
69
|
.catch((reason: unknown) => {
|
|
74
|
-
setError(
|
|
70
|
+
setError(describeApiError(reason, t));
|
|
75
71
|
setStep({ name: 'expired' });
|
|
76
72
|
});
|
|
77
73
|
}, [oxyServices, t]);
|
|
@@ -92,9 +92,12 @@ export const OxyPasswordPanel: React.FC<OxyPasswordPanelProps> = ({ onDone, onCa
|
|
|
92
92
|
totpEnabled={totpEnabled}
|
|
93
93
|
submitLabel={t('signInSecurity.password.save')}
|
|
94
94
|
validate={() => {
|
|
95
|
-
if (password.length < PASSWORD_MIN_LENGTH
|
|
95
|
+
if (password.length < PASSWORD_MIN_LENGTH) {
|
|
96
96
|
return t('signInSecurity.password.tooShort', { min: PASSWORD_MIN_LENGTH });
|
|
97
97
|
}
|
|
98
|
+
if (password.length > PASSWORD_MAX_LENGTH) {
|
|
99
|
+
return t('signInSecurity.password.tooLong', { max: PASSWORD_MAX_LENGTH });
|
|
100
|
+
}
|
|
98
101
|
return password === repeat ? null : t('signInSecurity.password.mismatch');
|
|
99
102
|
}}
|
|
100
103
|
onSubmit={async (reauth) => {
|
|
@@ -117,6 +120,7 @@ export const OxyPasswordPanel: React.FC<OxyPasswordPanelProps> = ({ onDone, onCa
|
|
|
117
120
|
error={null}
|
|
118
121
|
autoComplete="new-password"
|
|
119
122
|
secureTextEntry
|
|
123
|
+
maxLength={PASSWORD_MAX_LENGTH}
|
|
120
124
|
testID="password-new"
|
|
121
125
|
/>
|
|
122
126
|
<AccountFlowField
|
|
@@ -127,6 +131,7 @@ export const OxyPasswordPanel: React.FC<OxyPasswordPanelProps> = ({ onDone, onCa
|
|
|
127
131
|
error={null}
|
|
128
132
|
autoComplete="new-password"
|
|
129
133
|
secureTextEntry
|
|
134
|
+
maxLength={PASSWORD_MAX_LENGTH}
|
|
130
135
|
autoFocus={false}
|
|
131
136
|
testID="password-repeat"
|
|
132
137
|
/>
|
|
@@ -44,7 +44,9 @@ import type {
|
|
|
44
44
|
import {
|
|
45
45
|
EMAIL_CODE_LENGTH,
|
|
46
46
|
EMAIL_SIGNIN_LONG_CODE_LENGTH,
|
|
47
|
+
PASSWORD_MAX_LENGTH,
|
|
47
48
|
SIGN_IN_ERROR_CODES,
|
|
49
|
+
SIGN_IN_IDENTIFIER_MAX_LENGTH,
|
|
48
50
|
TOTP_DIGITS,
|
|
49
51
|
isEmailSignInChooseAccount,
|
|
50
52
|
isSecondFactorRequired,
|
|
@@ -69,14 +71,17 @@ import {
|
|
|
69
71
|
AccountFlowField,
|
|
70
72
|
AccountFlowNotice,
|
|
71
73
|
BACKUP_CODE_LENGTH,
|
|
72
|
-
|
|
73
|
-
errorCode,
|
|
74
|
+
isCompleteSecondFactorCode,
|
|
74
75
|
isCompleteSignInCode,
|
|
75
|
-
isRateLimited,
|
|
76
|
-
retryAfterSeconds,
|
|
77
76
|
} from './accountFlowParts';
|
|
78
77
|
import { readSignInFlow, writeSignInFlow } from './signInFlowStore';
|
|
79
78
|
import { resolveSignInMethods } from './signInMethods';
|
|
79
|
+
import {
|
|
80
|
+
describeApiError,
|
|
81
|
+
errorCode,
|
|
82
|
+
isRateLimited,
|
|
83
|
+
retryAfterSeconds,
|
|
84
|
+
} from '../../utils/apiErrorMessage';
|
|
80
85
|
|
|
81
86
|
/** Bloom `AuthCard`'s split card width, which the account dialog grows to for it. */
|
|
82
87
|
const SPLIT_WIDTH = 880;
|
|
@@ -232,7 +237,7 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
232
237
|
const fail = useCallback(
|
|
233
238
|
(reason: unknown) => {
|
|
234
239
|
if (isRateLimited(reason)) setRateLimitSeconds(retryAfterSeconds(reason));
|
|
235
|
-
else setError(
|
|
240
|
+
else setError(describeApiError(reason, t));
|
|
236
241
|
},
|
|
237
242
|
[t],
|
|
238
243
|
);
|
|
@@ -381,7 +386,7 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
381
386
|
const submitSecondFactor = (typed: string) => {
|
|
382
387
|
if (step.name !== 'second-factor' || blocked) return;
|
|
383
388
|
const value = typed.trim();
|
|
384
|
-
if (!value) {
|
|
389
|
+
if (!isCompleteSecondFactorCode(value, useBackupCode)) {
|
|
385
390
|
setError(t('signin.errors.secondFactorInvalid'));
|
|
386
391
|
return;
|
|
387
392
|
}
|
|
@@ -657,6 +662,7 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
657
662
|
disabled={blocked}
|
|
658
663
|
autoComplete="current-password"
|
|
659
664
|
secureTextEntry
|
|
665
|
+
maxLength={PASSWORD_MAX_LENGTH}
|
|
660
666
|
testID="signin-password"
|
|
661
667
|
/>
|
|
662
668
|
{rateLimitNotice}
|
|
@@ -822,6 +828,7 @@ export const OxySignInPanel: React.FC<OxySignInPanelProps> = ({
|
|
|
822
828
|
placeholder={t('signin.identifier.placeholder')}
|
|
823
829
|
autoComplete="username"
|
|
824
830
|
keyboardType="email-address"
|
|
831
|
+
maxLength={SIGN_IN_IDENTIFIER_MAX_LENGTH}
|
|
825
832
|
autoFocus={Platform.OS === 'web'}
|
|
826
833
|
testID="signin-identifier"
|
|
827
834
|
/>
|
|
@@ -16,12 +16,19 @@ import { useEffect, useState } from 'react';
|
|
|
16
16
|
import { Linking, Platform } from 'react-native';
|
|
17
17
|
import { toast } from '@oxy.so/bloom/toast';
|
|
18
18
|
import type { EmailVerificationConfirmResponse } from '@oxy.so/contracts';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
SIGN_IN_ERROR_CODES,
|
|
21
|
+
USERNAME_MAX_LENGTH,
|
|
22
|
+
checkContract,
|
|
23
|
+
emailAddressCheck,
|
|
24
|
+
stripDisallowedUsernameCharacters,
|
|
25
|
+
} from '@oxy.so/contracts/client';
|
|
20
26
|
import { useOxy } from '../../context/oxyRuntimeContext';
|
|
21
27
|
import { useAccountDialogSnapshot } from '../../hooks/accountDialogSnapshot';
|
|
22
28
|
import { useI18n } from '../../hooks/useI18n';
|
|
23
29
|
import { getCommonsAcquisitionUrl } from '../../utils/commonsStoreLinks';
|
|
24
30
|
import { isWebBrowser } from '../../utils/isWebBrowser';
|
|
31
|
+
import { checkUsernameDraft, describeUsernameRefusal } from '../../utils/usernamePolicy';
|
|
25
32
|
import { SubtleLink } from '../authChooser/primitives';
|
|
26
33
|
import { OxyAuthScreen, OxyAuthScreenHeader, OxyAuthTerms } from './OxyAuthScreen';
|
|
27
34
|
import { readSignInFlow, writeSignInFlow } from './signInFlowStore';
|
|
@@ -31,10 +38,8 @@ import {
|
|
|
31
38
|
AccountFlowNote,
|
|
32
39
|
AccountFlowProgress,
|
|
33
40
|
EmailCodeStep,
|
|
34
|
-
describeSignInError,
|
|
35
|
-
errorCode,
|
|
36
|
-
isTicketExpired,
|
|
37
41
|
} from './accountFlowParts';
|
|
42
|
+
import { describeApiError, errorCode, isTicketExpired } from '../../utils/apiErrorMessage';
|
|
38
43
|
|
|
39
44
|
/** Commons' own identity-creation deep link. */
|
|
40
45
|
const COMMONS_CREATE_IDENTITY_URL = 'oxycommons://create-identity';
|
|
@@ -101,18 +106,23 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
101
106
|
setError(
|
|
102
107
|
reason instanceof UsernameTakenError
|
|
103
108
|
? t('signup.username.taken')
|
|
104
|
-
:
|
|
109
|
+
: describeApiError(reason, t),
|
|
105
110
|
);
|
|
106
111
|
})
|
|
107
112
|
.finally(() => setPending(false));
|
|
108
113
|
};
|
|
109
114
|
|
|
115
|
+
// The policy is checked here, before the server is asked: the availability
|
|
116
|
+
// check refuses a malformed name with a 400, and that reads as a failure of
|
|
117
|
+
// ours rather than a rule the person can follow.
|
|
110
118
|
const submitUsername = () => {
|
|
111
|
-
const
|
|
112
|
-
if (!
|
|
113
|
-
setError(
|
|
119
|
+
const draft = checkUsernameDraft(username, t);
|
|
120
|
+
if (!draft.ok) {
|
|
121
|
+
setError(draft.error);
|
|
114
122
|
return;
|
|
115
123
|
}
|
|
124
|
+
const handle = draft.username;
|
|
125
|
+
setUsername(handle);
|
|
116
126
|
run(async () => {
|
|
117
127
|
const { available } = await oxyServices.auth.checkUsername(handle);
|
|
118
128
|
if (!available) throw new UsernameTakenError();
|
|
@@ -140,9 +150,16 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
140
150
|
|
|
141
151
|
// The code step reports this promise's failure in place.
|
|
142
152
|
const createAccount = async ({ ticket }: EmailVerificationConfirmResponse): Promise<void> => {
|
|
153
|
+
// A flow restored from before this check existed may carry any name.
|
|
154
|
+
const draft = checkUsernameDraft(username, t);
|
|
155
|
+
if (!draft.ok) {
|
|
156
|
+
setStep({ name: 'username' });
|
|
157
|
+
setError(draft.error);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
143
160
|
try {
|
|
144
161
|
const session = await oxyServices.auth.signUp({
|
|
145
|
-
username: username
|
|
162
|
+
username: draft.username,
|
|
146
163
|
email,
|
|
147
164
|
emailTicket: ticket,
|
|
148
165
|
languages: [currentLanguage],
|
|
@@ -156,9 +173,17 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
156
173
|
setError(t('signup.username.taken'));
|
|
157
174
|
return;
|
|
158
175
|
}
|
|
176
|
+
// The server refused the name by a rule this client does not know yet:
|
|
177
|
+
// the name is what to change, so that is the step to return to.
|
|
178
|
+
const refused = describeUsernameRefusal(reason, draft.username, t);
|
|
179
|
+
if (refused) {
|
|
180
|
+
setStep({ name: 'username' });
|
|
181
|
+
setError(refused);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
159
184
|
if (isTicketExpired(reason)) {
|
|
160
185
|
setStep({ name: 'email' });
|
|
161
|
-
setError(
|
|
186
|
+
setError(describeApiError(reason, t));
|
|
162
187
|
return;
|
|
163
188
|
}
|
|
164
189
|
throw reason;
|
|
@@ -241,13 +266,15 @@ export const OxySignUpPanel: React.FC<OxySignUpPanelProps> = ({
|
|
|
241
266
|
label={t('signup.username.label')}
|
|
242
267
|
value={username}
|
|
243
268
|
onChange={(value) => {
|
|
244
|
-
setUsername(value);
|
|
269
|
+
setUsername(stripDisallowedUsernameCharacters(value));
|
|
245
270
|
if (error) setError(null);
|
|
246
271
|
}}
|
|
247
272
|
onSubmit={submitUsername}
|
|
248
273
|
error={error}
|
|
249
274
|
disabled={pending}
|
|
250
275
|
placeholder={t('signup.username.placeholder')}
|
|
276
|
+
hint={t('usernamePolicy.hint')}
|
|
277
|
+
maxLength={USERNAME_MAX_LENGTH}
|
|
251
278
|
autoComplete="username"
|
|
252
279
|
testID="signup-username"
|
|
253
280
|
/>
|
|
@@ -12,7 +12,7 @@ import { useState } from 'react';
|
|
|
12
12
|
import { View } from 'react-native';
|
|
13
13
|
import { Button } from '@oxy.so/bloom/button';
|
|
14
14
|
import type { ReauthAction, ReauthProof } from '@oxy.so/contracts';
|
|
15
|
-
import { EMAIL_CODE_LENGTH, TOTP_DIGITS } from '@oxy.so/contracts/client';
|
|
15
|
+
import { EMAIL_CODE_LENGTH, PASSWORD_MAX_LENGTH, TOTP_DIGITS } from '@oxy.so/contracts/client';
|
|
16
16
|
import { useOxy } from '../../context/oxyRuntimeContext';
|
|
17
17
|
import { useI18n } from '../../hooks/useI18n';
|
|
18
18
|
import { SubtleLink } from '../authChooser/primitives';
|
|
@@ -25,8 +25,9 @@ import {
|
|
|
25
25
|
AccountFlowNote,
|
|
26
26
|
AccountFlowNotice,
|
|
27
27
|
BACKUP_CODE_LENGTH,
|
|
28
|
-
|
|
28
|
+
isCompleteSecondFactorCode,
|
|
29
29
|
} from './accountFlowParts';
|
|
30
|
+
import { describeApiError } from '../../utils/apiErrorMessage';
|
|
30
31
|
|
|
31
32
|
export interface ReauthStepProps {
|
|
32
33
|
title: string;
|
|
@@ -86,7 +87,7 @@ export const ReauthStep: React.FC<ReauthStepProps> = ({
|
|
|
86
87
|
setError(null);
|
|
87
88
|
setPending(true);
|
|
88
89
|
work()
|
|
89
|
-
.catch((reason: unknown) => setError(
|
|
90
|
+
.catch((reason: unknown) => setError(describeApiError(reason, t)))
|
|
90
91
|
.finally(() => setPending(false));
|
|
91
92
|
};
|
|
92
93
|
|
|
@@ -112,6 +113,10 @@ export const ReauthStep: React.FC<ReauthStepProps> = ({
|
|
|
112
113
|
setError(t('reauth.errors.totpRequired'));
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
116
|
+
if (totp && !isCompleteSecondFactorCode(totp, useBackupCode)) {
|
|
117
|
+
setError(t('signin.errors.secondFactorInvalid'));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
115
120
|
let proof: ReauthProof;
|
|
116
121
|
if (mode === 'password') {
|
|
117
122
|
if (!password) {
|
|
@@ -146,6 +151,7 @@ export const ReauthStep: React.FC<ReauthStepProps> = ({
|
|
|
146
151
|
disabled={pending}
|
|
147
152
|
autoComplete="current-password"
|
|
148
153
|
secureTextEntry
|
|
154
|
+
maxLength={PASSWORD_MAX_LENGTH}
|
|
149
155
|
autoFocus={false}
|
|
150
156
|
testID="reauth-password"
|
|
151
157
|
/>
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
EMAIL_SIGNIN_LONG_CODE_LENGTH,
|
|
26
26
|
EMAIL_VERIFICATION_ERROR_CODES,
|
|
27
27
|
SIGN_IN_ERROR_CODES,
|
|
28
|
+
TOTP_DIGITS,
|
|
28
29
|
normalizeEmailSignInCode,
|
|
29
30
|
} from '@oxy.so/contracts/client';
|
|
30
31
|
import { useOxy } from '../../context/oxyRuntimeContext';
|
|
@@ -32,91 +33,7 @@ import { useI18n } from '../../hooks/useI18n';
|
|
|
32
33
|
import type { Translate } from '../authChooser/types';
|
|
33
34
|
import { SubtleLink } from '../authChooser/primitives';
|
|
34
35
|
import { OxyAuthScreen, OxyAuthScreenHeader } from './OxyAuthScreen';
|
|
35
|
-
|
|
36
|
-
/** How long a screen waits after a 429 that names no wait of its own. */
|
|
37
|
-
export const RATE_LIMIT_SECONDS = 60;
|
|
38
|
-
|
|
39
|
-
/** The API error code a thrown SDK error carries (`error.code`), if any. */
|
|
40
|
-
export function errorCode(error: unknown): string | undefined {
|
|
41
|
-
const code = (error as { code?: unknown } | null)?.code;
|
|
42
|
-
return typeof code === 'string' ? code : undefined;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** An HTTP status off a thrown SDK error. */
|
|
46
|
-
function errorStatus(error: unknown): number | undefined {
|
|
47
|
-
return (
|
|
48
|
-
(error as { status?: number } | undefined)?.status ??
|
|
49
|
-
(error as { response?: { status?: number } } | undefined)?.response?.status
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** A 429: too many attempts or emails. */
|
|
54
|
-
export function isRateLimited(error: unknown): boolean {
|
|
55
|
-
return errorStatus(error) === 429;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** How long to wait after a 429, from the API's `retryAfterSeconds` when it sent one. */
|
|
59
|
-
export function retryAfterSeconds(error: unknown): number {
|
|
60
|
-
const seconds = (error as { details?: { retryAfterSeconds?: unknown } } | undefined)?.details
|
|
61
|
-
?.retryAfterSeconds;
|
|
62
|
-
return typeof seconds === 'number' && seconds > 0 ? Math.ceil(seconds) : RATE_LIMIT_SECONDS;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* A failure of a sign-in or account screen, in the person's language. Never
|
|
67
|
-
* says whether an account exists: every "no" is the same sentence.
|
|
68
|
-
*/
|
|
69
|
-
export function describeSignInError(error: unknown, t: Translate): string {
|
|
70
|
-
switch (errorCode(error)) {
|
|
71
|
-
case SIGN_IN_ERROR_CODES.invalidCredentials:
|
|
72
|
-
return t('signin.errors.invalidCredentials');
|
|
73
|
-
case SIGN_IN_ERROR_CODES.requestInvalid:
|
|
74
|
-
case SIGN_IN_ERROR_CODES.linkInvalid:
|
|
75
|
-
return t('signin.errors.requestExpired');
|
|
76
|
-
case SIGN_IN_ERROR_CODES.secondFactorInvalid:
|
|
77
|
-
case SIGN_IN_ERROR_CODES.totpCodeInvalid:
|
|
78
|
-
return t('signin.errors.secondFactorInvalid');
|
|
79
|
-
case SIGN_IN_ERROR_CODES.reauthInvalid:
|
|
80
|
-
case SIGN_IN_ERROR_CODES.reauthRequired:
|
|
81
|
-
return t('reauth.errors.invalid');
|
|
82
|
-
case SIGN_IN_ERROR_CODES.totpRequired:
|
|
83
|
-
return t('reauth.errors.totpRequired');
|
|
84
|
-
case SIGN_IN_ERROR_CODES.originNotAllowed:
|
|
85
|
-
return t('signin.errors.originNotAllowed');
|
|
86
|
-
case SIGN_IN_ERROR_CODES.usernameTaken:
|
|
87
|
-
return t('signup.username.taken');
|
|
88
|
-
case SIGN_IN_ERROR_CODES.emailAccountsFull:
|
|
89
|
-
return t('signin.errors.emailAccountsFull');
|
|
90
|
-
case SIGN_IN_ERROR_CODES.lastSignInMethod:
|
|
91
|
-
return t('signInSecurity.errors.lastSignInMethod');
|
|
92
|
-
case SIGN_IN_ERROR_CODES.passwordRequired:
|
|
93
|
-
return t('signInSecurity.errors.passwordRequired');
|
|
94
|
-
case SIGN_IN_ERROR_CODES.emailUnchanged:
|
|
95
|
-
return t('signInSecurity.errors.emailUnchanged');
|
|
96
|
-
case EMAIL_VERIFICATION_ERROR_CODES.codeInvalid:
|
|
97
|
-
return t('emailCode.errors.codeInvalid');
|
|
98
|
-
case EMAIL_VERIFICATION_ERROR_CODES.tooManyAttempts:
|
|
99
|
-
return t('emailCode.errors.tooManyAttempts');
|
|
100
|
-
case EMAIL_VERIFICATION_ERROR_CODES.ticketInvalid:
|
|
101
|
-
case EMAIL_VERIFICATION_ERROR_CODES.ticketRequired:
|
|
102
|
-
return t('emailCode.errors.expired');
|
|
103
|
-
case EMAIL_VERIFICATION_ERROR_CODES.unavailable:
|
|
104
|
-
return t('emailCode.errors.unavailable');
|
|
105
|
-
default:
|
|
106
|
-
if (isRateLimited(error))
|
|
107
|
-
return t('signin.errors.rateLimited', { seconds: retryAfterSeconds(error) });
|
|
108
|
-
return t('signin.errors.generic');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** Whether the confirmation this flow holds is gone and it must start again. */
|
|
113
|
-
export function isTicketExpired(error: unknown): boolean {
|
|
114
|
-
const code = errorCode(error);
|
|
115
|
-
return (
|
|
116
|
-
code === EMAIL_VERIFICATION_ERROR_CODES.ticketInvalid ||
|
|
117
|
-
code === EMAIL_VERIFICATION_ERROR_CODES.ticketRequired
|
|
118
|
-
);
|
|
119
|
-
}
|
|
36
|
+
import { describeApiError } from '../../utils/apiErrorMessage';
|
|
120
37
|
|
|
121
38
|
const SIX_DIGITS = new RegExp(`^\\d{${EMAIL_CODE_LENGTH}}$`);
|
|
122
39
|
const LONG_CODE = new RegExp(
|
|
@@ -136,6 +53,15 @@ export function isCompleteSignInCode(typed: string): boolean {
|
|
|
136
53
|
/** Characters in a backup code (`xxxxx-xxxxx`, its dash not counted). */
|
|
137
54
|
export const BACKUP_CODE_LENGTH = 10;
|
|
138
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Every box of the second-factor field is filled: six digits, or a backup code's
|
|
58
|
+
* ten characters. A partial code is never sent — the server would refuse it as
|
|
59
|
+
* a malformed request, which reads as "Something went wrong".
|
|
60
|
+
*/
|
|
61
|
+
export function isCompleteSecondFactorCode(typed: string, backup: boolean): boolean {
|
|
62
|
+
return typed.trim().length === (backup ? BACKUP_CODE_LENGTH : TOTP_DIGITS);
|
|
63
|
+
}
|
|
64
|
+
|
|
139
65
|
/**
|
|
140
66
|
* One labelled input, the way the sign-in screen draws its fields. A
|
|
141
67
|
* `secureTextEntry` field is always revealable: Bloom's eye button shows and
|
|
@@ -154,6 +80,7 @@ export const AccountFlowField: React.FC<{
|
|
|
154
80
|
secureTextEntry?: boolean;
|
|
155
81
|
autoFocus?: boolean;
|
|
156
82
|
hint?: string;
|
|
83
|
+
maxLength?: number;
|
|
157
84
|
testID: string;
|
|
158
85
|
}> = ({
|
|
159
86
|
label,
|
|
@@ -168,6 +95,7 @@ export const AccountFlowField: React.FC<{
|
|
|
168
95
|
secureTextEntry,
|
|
169
96
|
autoFocus = true,
|
|
170
97
|
hint,
|
|
98
|
+
maxLength,
|
|
171
99
|
testID,
|
|
172
100
|
}) => (
|
|
173
101
|
<View style={styles.field}>
|
|
@@ -186,6 +114,7 @@ export const AccountFlowField: React.FC<{
|
|
|
186
114
|
autoCapitalize="none"
|
|
187
115
|
autoCorrect={false}
|
|
188
116
|
autoFocus={autoFocus}
|
|
117
|
+
maxLength={maxLength}
|
|
189
118
|
returnKeyType="go"
|
|
190
119
|
onSubmitEditing={onSubmit}
|
|
191
120
|
aria-required
|
|
@@ -376,7 +305,7 @@ export const EmailCodeStep: React.FC<EmailCodeStepProps> = ({
|
|
|
376
305
|
oxyServices.auth.email
|
|
377
306
|
.confirmVerification(verificationId, digits)
|
|
378
307
|
.then(onConfirmed)
|
|
379
|
-
.catch((reason: unknown) => setError(
|
|
308
|
+
.catch((reason: unknown) => setError(describeApiError(reason, t)))
|
|
380
309
|
.finally(() => setPending(false));
|
|
381
310
|
};
|
|
382
311
|
|
|
@@ -386,7 +315,7 @@ export const EmailCodeStep: React.FC<EmailCodeStepProps> = ({
|
|
|
386
315
|
setCode('');
|
|
387
316
|
onResend()
|
|
388
317
|
.then(() => setNotice(t('emailCode.resent')))
|
|
389
|
-
.catch((reason: unknown) => setError(
|
|
318
|
+
.catch((reason: unknown) => setError(describeApiError(reason, t)));
|
|
390
319
|
};
|
|
391
320
|
|
|
392
321
|
return (
|