@newskit-render/auth 0.20.0 → 0.22.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/CHANGELOG.md +41 -0
- package/README.md +0 -2
- package/dist/__tests__/CookieView.js +15 -10
- package/dist/client/CookieView.js +8 -3
- package/dist/client/PageWithAuth.js +5 -3
- package/dist/client/SessionProvider.js +6 -4
- package/dist/client/index.js +16 -11
- package/dist/providers/index.js +10 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
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
|
+
## [0.22.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/auth@0.22.0...@newskit-render/auth@0.22.1) (2021-11-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @newskit-render/auth
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.22.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/auth@0.21.1...@newskit-render/auth@0.22.0) (2021-11-22)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **PPDSR-0:** fix broken dependecy ([#521](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/521)) ([2690dd3](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/2690dd3bc6cf61a88740a0ff935adf461be02416))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [0.21.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/auth@0.21.0...@newskit-render/auth@0.21.1) (2021-11-15)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **PPDSR-541:** change packages to get published ([#506](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/506)) ([4de773b](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/4de773b8e22663a2822f64255f347c32384532c0))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [0.21.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/auth@0.20.0...@newskit-render/auth@0.21.0) (2021-11-10)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* **PPDSR-496:** add next link wrapper component ([#500](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/500)) ([a8ca436](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/a8ca436f6f8061d58e857eb83d7d3ee9cfb449a6))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
# [0.20.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/auth@0.19.1...@newskit-render/auth@0.20.0) (2021-11-10)
|
|
7
48
|
|
|
8
49
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var preact_1 = require("preact");
|
|
7
|
+
var react_dom_1 = require("react-dom");
|
|
8
|
+
var CookieView_1 = __importDefault(require("../client/CookieView"));
|
|
4
9
|
describe('CookieView', function () {
|
|
5
10
|
var container;
|
|
6
11
|
beforeEach(function () {
|
|
@@ -8,13 +13,13 @@ describe('CookieView', function () {
|
|
|
8
13
|
document.body.appendChild(container);
|
|
9
14
|
});
|
|
10
15
|
afterEach(function () {
|
|
11
|
-
unmountComponentAtNode(container);
|
|
16
|
+
(0, react_dom_1.unmountComponentAtNode)(container);
|
|
12
17
|
container.remove();
|
|
13
18
|
container = { textContent: '' };
|
|
14
19
|
});
|
|
15
20
|
test('Not visible, no cookie set', function () {
|
|
16
|
-
render(h(
|
|
17
|
-
h("div", null, "Not visible")), container);
|
|
21
|
+
(0, react_dom_1.render)((0, preact_1.h)(CookieView_1.default, null,
|
|
22
|
+
(0, preact_1.h)("div", null, "Not visible")), container);
|
|
18
23
|
expect(container.textContent).toBe('');
|
|
19
24
|
});
|
|
20
25
|
test('Not visible, cookie set set to false', function () {
|
|
@@ -22,8 +27,8 @@ describe('CookieView', function () {
|
|
|
22
27
|
writable: true,
|
|
23
28
|
value: 'nextAuthShowLogOut=false',
|
|
24
29
|
});
|
|
25
|
-
render(h(
|
|
26
|
-
h("div", null, "visible")), container);
|
|
30
|
+
(0, react_dom_1.render)((0, preact_1.h)(CookieView_1.default, null,
|
|
31
|
+
(0, preact_1.h)("div", null, "visible")), container);
|
|
27
32
|
expect(container.textContent).toBe('');
|
|
28
33
|
});
|
|
29
34
|
test('Visible, cookie set set to true', function () {
|
|
@@ -31,8 +36,8 @@ describe('CookieView', function () {
|
|
|
31
36
|
writable: true,
|
|
32
37
|
value: 'nextAuthShowLogOut=true',
|
|
33
38
|
});
|
|
34
|
-
render(h(
|
|
35
|
-
h("div", null, "visible")), container);
|
|
39
|
+
(0, react_dom_1.render)((0, preact_1.h)(CookieView_1.default, null,
|
|
40
|
+
(0, preact_1.h)("div", null, "visible")), container);
|
|
36
41
|
expect(container.textContent).toBe('visible');
|
|
37
42
|
});
|
|
38
43
|
});
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var cookie_1 = __importDefault(require("cookie"));
|
|
2
7
|
var CookieView = function (_a) {
|
|
3
8
|
var _b = _a.cookieName, cookieName = _b === void 0 ? 'nextAuthShowLogOut' : _b, children = _a.children;
|
|
4
9
|
return typeof document !== 'undefined'
|
|
5
|
-
?
|
|
10
|
+
? cookie_1.default.parse(document.cookie)[cookieName] === 'true'
|
|
6
11
|
? children
|
|
7
12
|
: null
|
|
8
13
|
: null;
|
|
9
14
|
};
|
|
10
|
-
|
|
15
|
+
exports.default = CookieView;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var client_1 = require("next-auth/client");
|
|
2
4
|
var PageWithAuth = function (_a) {
|
|
3
5
|
var children = _a.children, isLoading = _a.isLoading, onDenied = _a.onDenied;
|
|
4
|
-
var _b = useSession(), session = _b[0], loading = _b[1];
|
|
6
|
+
var _b = (0, client_1.useSession)(), session = _b[0], loading = _b[1];
|
|
5
7
|
if (typeof window !== 'undefined' && loading)
|
|
6
8
|
return isLoading;
|
|
7
9
|
if (!session) {
|
|
@@ -11,4 +13,4 @@ var PageWithAuth = function (_a) {
|
|
|
11
13
|
return children;
|
|
12
14
|
}
|
|
13
15
|
};
|
|
14
|
-
|
|
16
|
+
exports.default = PageWithAuth;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var react_1 = require("react");
|
|
4
|
+
var client_1 = require("next-auth/client");
|
|
3
5
|
var SessionProvider = function (_a) {
|
|
4
6
|
var pageProps = _a.pageProps, children = _a.children;
|
|
5
7
|
if (pageProps && pageProps.session !== undefined) {
|
|
6
|
-
return createElement(Provider, { session: pageProps.session }, children);
|
|
8
|
+
return (0, react_1.createElement)(client_1.Provider, { session: pageProps.session }, children);
|
|
7
9
|
}
|
|
8
10
|
return children;
|
|
9
11
|
};
|
|
10
|
-
|
|
12
|
+
exports.default = SessionProvider;
|
package/dist/client/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var PageWithAuth_1 = __importDefault(require("./PageWithAuth"));
|
|
7
|
+
var SessionProvider_1 = __importDefault(require("./SessionProvider"));
|
|
8
|
+
var CookieView_1 = __importDefault(require("./CookieView"));
|
|
9
|
+
var client_1 = require("next-auth/client");
|
|
10
|
+
exports.default = {
|
|
11
|
+
PageWithAuth: PageWithAuth_1.default,
|
|
12
|
+
getSession: client_1.getSession,
|
|
13
|
+
SessionProvider: SessionProvider_1.default,
|
|
14
|
+
signIn: client_1.signIn,
|
|
15
|
+
signOut: client_1.signOut,
|
|
16
|
+
CookieView: CookieView_1.default,
|
|
12
17
|
};
|
package/dist/providers/index.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var next_auth_1 = __importDefault(require("next-auth"));
|
|
7
|
+
var providers_1 = __importDefault(require("next-auth/providers"));
|
|
3
8
|
var createAuthRoute = function (req, res, providerOptions) {
|
|
4
9
|
var OKTA_CLIENT_ID = providerOptions.OKTA_CLIENT_ID, OKTA_CLIENT_SECRET = providerOptions.OKTA_CLIENT_SECRET, OKTA_DOMAIN = providerOptions.OKTA_DOMAIN;
|
|
5
10
|
var options = {
|
|
6
11
|
providers: [
|
|
7
|
-
|
|
12
|
+
providers_1.default.Okta({
|
|
8
13
|
clientId: OKTA_CLIENT_ID,
|
|
9
14
|
clientSecret: OKTA_CLIENT_SECRET,
|
|
10
15
|
domain: OKTA_DOMAIN,
|
|
11
16
|
}),
|
|
12
17
|
],
|
|
13
18
|
};
|
|
14
|
-
return
|
|
19
|
+
return (0, next_auth_1.default)(req, res, options);
|
|
15
20
|
};
|
|
16
|
-
|
|
21
|
+
exports.default = createAuthRoute;
|