@shipfox/client-auth 12.0.0 → 12.0.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/pages/form-utils.d.ts.map +1 -1
- package/dist/pages/form-utils.js +12 -0
- package/dist/pages/form-utils.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/pages/form-utils.test.ts +10 -0
- package/src/pages/form-utils.ts +14 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/client-auth",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "12.0.
|
|
4
|
+
"version": "12.0.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@swc/helpers": "^0.5.17",
|
|
37
37
|
"@tanstack/react-form": "^1.32.0",
|
|
38
|
-
"@shipfox/api-auth-dto": "10.
|
|
39
|
-
"@shipfox/api-workspaces-dto": "10.
|
|
38
|
+
"@shipfox/api-auth-dto": "10.2.0",
|
|
39
|
+
"@shipfox/api-workspaces-dto": "10.2.0",
|
|
40
40
|
"@shipfox/client-api": "6.0.1",
|
|
41
|
-
"@shipfox/client-invitations": "12.0.
|
|
42
|
-
"@shipfox/client-shell": "12.0.
|
|
41
|
+
"@shipfox/client-invitations": "12.0.1",
|
|
42
|
+
"@shipfox/client-shell": "12.0.1",
|
|
43
43
|
"@shipfox/client-ui": "6.0.2",
|
|
44
44
|
"@shipfox/react-ui": "0.3.7"
|
|
45
45
|
},
|
|
@@ -26,6 +26,16 @@ describe('authErrorMessage', () => {
|
|
|
26
26
|
expect(result).toBe('Try later');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
test('renders the configured signup denial message from safe error details', () => {
|
|
30
|
+
const error = new ApiError({
|
|
31
|
+
code: 'signup-not-allowed',
|
|
32
|
+
message: 'Forbidden',
|
|
33
|
+
status: 403,
|
|
34
|
+
details: {code: 'signup-not-allowed', details: {message: 'Ask your administrator to join.'}},
|
|
35
|
+
});
|
|
36
|
+
const result = authErrorMessage(error);
|
|
37
|
+
expect(result).toBe('Ask your administrator to join.');
|
|
38
|
+
});
|
|
29
39
|
test('uses generic copy for unknown errors', () => {
|
|
30
40
|
const result = authErrorMessage(new Error('boom'));
|
|
31
41
|
|
package/src/pages/form-utils.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import {ApiError} from '@shipfox/client-api';
|
|
2
2
|
|
|
3
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
4
|
+
return typeof value === 'object' && value !== null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function signupNotAllowedMessage(error: ApiError): string | undefined {
|
|
8
|
+
if (error.code !== 'signup-not-allowed') return undefined;
|
|
9
|
+
if (!isRecord(error.details)) return undefined;
|
|
10
|
+
const details = error.details.details;
|
|
11
|
+
if (!isRecord(details)) return undefined;
|
|
12
|
+
return typeof details.message === 'string' ? details.message : undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
export function authErrorMessage(error: unknown): string {
|
|
4
16
|
if (!(error instanceof ApiError)) return 'Something went wrong. Try again.';
|
|
5
17
|
|
|
@@ -25,5 +37,7 @@ export function authErrorMessage(error: unknown): string {
|
|
|
25
37
|
return 'We could not reach the API. Check your connection and try again.';
|
|
26
38
|
}
|
|
27
39
|
|
|
40
|
+
const signupMessage = signupNotAllowedMessage(error);
|
|
41
|
+
if (signupMessage) return signupMessage;
|
|
28
42
|
return error.message || 'Something went wrong. Try again.';
|
|
29
43
|
}
|