@squiz/resource-browser 2.2.2-rc.0 → 2.4.0-rc.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/.eslintrc CHANGED
@@ -11,8 +11,8 @@
11
11
  "import/resolver": {
12
12
  "typescript": {
13
13
  "alwaysTryTypes": true,
14
- },
15
- },
14
+ }
15
+ }
16
16
  },
17
17
  "ignorePatterns": ["**/lib/"],
18
18
  "overrides": [
@@ -21,19 +21,20 @@
21
21
  "rules": {
22
22
  "no-var": 0,
23
23
  "import/no-extraneous-dependencies": 0,
24
- },
24
+ }
25
25
  },
26
26
  {
27
27
  "files": ["*.config.ts", "*.config.js", "build.js"],
28
28
  "rules": {
29
29
  "import/no-extraneous-dependencies": 0,
30
- },
30
+ }
31
31
  },
32
32
  {
33
33
  "files": ["*.stories.ts", "*.stories.tsx"],
34
34
  "rules": {
35
35
  "import/no-extraneous-dependencies": 0,
36
- },
37
- },
38
- ],
36
+ "no-console": "off"
37
+ }
38
+ }
39
+ ]
39
40
  }
package/CHANGELOG.md CHANGED
@@ -3,7 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [2.2.2-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.2.1-rc.0...@squiz/resource-browser@2.2.2-rc.0) (2024-06-10)
6
+ # [2.4.0-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.3.0-rc.0...@squiz/resource-browser@2.4.0-rc.0) (2024-06-13)
7
+
8
+ ### Features
9
+
10
+ - **PRODAM-161:** updated versions ([8ed02b5](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/8ed02b5aa5b818c27a0d23d98cbbee468e4e559e))
11
+
12
+ # [2.3.0-rc.0](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.2.1...@squiz/resource-browser@2.3.0-rc.0) (2024-06-13)
13
+
14
+ ### Features
15
+
16
+ - **PRODAM-161:** lint ([7bc6f21](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/7bc6f2112a0364efb6c7e6e56c1fcfac61dc1086))
17
+ - **PRODAM-161:** linting ([afef928](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/afef928ac5a3fd05693f44995c144548e44b4392))
18
+ - **PRODAM-161:** route resource fetch tru internal api ([3073a7a](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/commit/3073a7a34b8700f63f3b60070c489a7476c62122))
19
+
20
+ ## [2.2.1](https://gitlab.squiz.net/dxp/dxp-shared-ui/resource-browser/compare/@squiz/resource-browser@2.2.1-rc.0...@squiz/resource-browser@2.2.1) (2024-06-11)
7
21
 
8
22
  **Note:** Version bump only for package @squiz/resource-browser
9
23
 
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAuth = void 0;
4
+ /* eslint-disable no-console */
4
5
  const react_1 = require("react");
5
6
  const authUtils_1 = require("../utils/authUtils");
6
7
  const useAuth = (authConfig) => {
@@ -13,10 +14,11 @@ const useAuth = (authConfig) => {
13
14
  return newToken;
14
15
  }, [authConfig]);
15
16
  const handleLogin = (0, react_1.useCallback)(() => {
16
- if (!authConfig?.redirectUrl && !authConfig?.authUrl && !authConfig?.redirectUrl && !authConfig?.scope) {
17
+ if (!authConfig?.redirectUrl && !authConfig?.authUrl && !authConfig?.scope) {
18
+ console.error('Auth config is misconfigured');
17
19
  return;
18
20
  }
19
- const encodedRedirectUrl = encodeURIComponent(authConfig?.redirectUrl || '');
21
+ const encodedRedirectUrl = encodeURIComponent(authConfig.redirectUrl);
20
22
  const loginUrl = `${authConfig?.authUrl}?client_id=${authConfig?.clientId}&scope=${authConfig?.scope}&redirect_uri=${encodedRedirectUrl}&response_type=code&state=state`;
21
23
  const popup = window.open(loginUrl, 'Login', 'width=600,height=600');
22
24
  if (!popup) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/resource-browser",
3
- "version": "2.2.2-rc.0",
3
+ "version": "2.4.0-rc.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "private": false,
@@ -24,8 +24,8 @@
24
24
  "@react-types/overlays": "^3.8.7",
25
25
  "@react-types/shared": "^3.23.1",
26
26
  "@squiz/dx-json-schema-lib": "^1.67.0",
27
- "@squiz/generic-browser-lib": "^1.66.0",
28
- "@squiz/resource-browser-ui-lib": "^0.8.3-rc.0",
27
+ "@squiz/generic-browser-lib": "1.67.2",
28
+ "@squiz/resource-browser-ui-lib": "^0.10.0-rc.0",
29
29
  "clsx": "^2.1.0",
30
30
  "expiry-map": "^2.0.0",
31
31
  "p-memoize": "^4.0.4",
@@ -87,5 +87,5 @@
87
87
  "volta": {
88
88
  "node": "18.18.0"
89
89
  },
90
- "gitHead": "5d66e140b42ee6c9794ca079b1049289ca4f74f8"
90
+ "gitHead": "68102123c494f931e7b6e9d0f7548e9b95244466"
91
91
  }
@@ -32,6 +32,22 @@ describe('useAuth', () => {
32
32
  });
33
33
  });
34
34
 
35
+ it('should do nothing if missing crucial props', async () => {
36
+ const authConfigMissingProps = {
37
+ clientId: 'example-client-id',
38
+ // Missing redirectUrl, authUrl, and scope
39
+ };
40
+ // @ts-ignore
41
+ const { result } = renderHook(() => useAuth(authConfigMissingProps));
42
+
43
+ result.current.login();
44
+
45
+ await waitFor(() => {
46
+ expect(result.current.authToken).toBe(undefined);
47
+ expect(result.current.isAuthenticated).toBe(false);
48
+ });
49
+ });
50
+
35
51
  it('should log error and return when popup fails to open', async () => {
36
52
  const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
37
53
  jest.spyOn(window, 'open').mockImplementation(() => null);
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-console */
1
2
  import { useState, useCallback, useEffect } from 'react';
2
3
  import { AuthenticationConfiguration } from '../types';
3
4
  import { getCookieValue, refreshAccessToken as refreshTokenUtil } from '../utils/authUtils';
@@ -14,10 +15,11 @@ export const useAuth = (authConfig: AuthenticationConfiguration | undefined) =>
14
15
  }, [authConfig]);
15
16
 
16
17
  const handleLogin = useCallback((): void => {
17
- if (!authConfig?.redirectUrl && !authConfig?.authUrl && !authConfig?.redirectUrl && !authConfig?.scope) {
18
+ if (!authConfig?.redirectUrl && !authConfig?.authUrl && !authConfig?.scope) {
19
+ console.error('Auth config is misconfigured');
18
20
  return;
19
21
  }
20
- const encodedRedirectUrl = encodeURIComponent(authConfig?.redirectUrl || '');
22
+ const encodedRedirectUrl = encodeURIComponent(authConfig.redirectUrl);
21
23
  const loginUrl = `${authConfig?.authUrl}?client_id=${authConfig?.clientId}&scope=${authConfig?.scope}&redirect_uri=${encodedRedirectUrl}&response_type=code&state=state`;
22
24
  const popup = window.open(loginUrl, 'Login', 'width=600,height=600');
23
25