@atls/react-identity-links 0.0.3 → 0.0.6
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 +25 -0
- package/dist/identity-link.component.d.ts +3 -0
- package/dist/identity-link.component.js +2 -4
- package/dist/identity-link.component.test.d.ts +1 -0
- package/dist/identity-link.component.test.js +0 -22
- package/dist/identity-url.interfaces.d.ts +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -2
- package/dist/use-browser-effect.hook.d.ts +3 -0
- package/dist/use-identity-url.hook.d.ts +10 -0
- package/package.json +6 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
## 0.0.6 (2025-01-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* **react:** lint and typecheck errors ([a090051](https://github.com/atls/reactjs/commit/a090051d1007e171df8066e85f15fcf8fd44c4ed))
|
|
10
|
+
* upgrade react, types fixes ([34feb02](https://github.com/atls/reactjs/commit/34feb027a2e2d7e5741509fd1ff846755d217b97))
|
|
11
|
+
* upgrade yarn, typescript, set resolutions ([b235334](https://github.com/atls/reactjs/commit/b23533417af6fb323187ef281b83d8dc5e7bd9dd))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
* add emotion as deps, bump @types/react ([1ce29b3](https://github.com/atls/reactjs/commit/1ce29b384640d9be0550d9c6f4dc07083821137a))
|
|
17
|
+
* **common:** bump yarn ([#143](https://github.com/atls/reactjs/issues/143)) ([8239f82](https://github.com/atls/reactjs/commit/8239f82f1c85d872a99613d3693babc761703b05))
|
|
18
|
+
* domain based identity links ([8263449](https://github.com/atls/reactjs/commit/826344977b1a86190a47b8d8fc6eecdb432da6a8))
|
|
19
|
+
* **identity-links:** init, also refactor react-user ([3fe1388](https://github.com/atls/reactjs/commit/3fe138854f57f7b50ce14df6c5dd9ab6f0d90dc2))
|
|
20
|
+
* react bump ([#144](https://github.com/atls/reactjs/issues/144)) ([9770fa1](https://github.com/atls/reactjs/commit/9770fa10451b647ed48e226270da68228714d174))
|
|
21
|
+
* root domain based identity links ([61508e4](https://github.com/atls/reactjs/commit/61508e41910a041d604999c01b74469bd1ea128c))
|
|
22
|
+
* update kratos browser flows to client 0.8.2 ([52f9c0f](https://github.com/atls/reactjs/commit/52f9c0fa129cd7d4567ab826c754483a6ddd6817))
|
|
23
|
+
* upgraded ([71a06f6](https://github.com/atls/reactjs/commit/71a06f6f498c928ed33b79f93af5d398a32af487))
|
|
24
|
+
|
|
25
|
+
|
|
@@ -4,12 +4,10 @@ exports.IdentityLink = void 0;
|
|
|
4
4
|
const use_identity_url_hook_1 = require("./use-identity-url.hook");
|
|
5
5
|
const IdentityLink = ({ children, type, returnTo }) => {
|
|
6
6
|
const url = (0, use_identity_url_hook_1.useIdentityUrl)({ type, returnTo });
|
|
7
|
-
if (!children || !url)
|
|
7
|
+
if (!children || !url)
|
|
8
8
|
return null;
|
|
9
|
-
|
|
10
|
-
if (typeof children !== 'function') {
|
|
9
|
+
if (typeof children !== 'function')
|
|
11
10
|
throw new Error('IdentityLink - children must be a function.');
|
|
12
|
-
}
|
|
13
11
|
return children(url);
|
|
14
12
|
};
|
|
15
13
|
exports.IdentityLink = IdentityLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,24 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
7
|
-
const react_1 = require("@testing-library/react");
|
|
8
|
-
const react_2 = __importDefault(require("react"));
|
|
9
|
-
const identity_link_component_1 = require("./identity-link.component");
|
|
10
|
-
describe('identity-link.component', () => {
|
|
11
|
-
const originalLocation = window.location;
|
|
12
|
-
const mockWindowLocation = (newLocation) => {
|
|
13
|
-
delete window.location;
|
|
14
|
-
window.location = newLocation;
|
|
15
|
-
};
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
mockWindowLocation(originalLocation);
|
|
18
|
-
});
|
|
19
|
-
it('without params', async () => {
|
|
20
|
-
mockWindowLocation(new URL('https://identity.monstrs.dev'));
|
|
21
|
-
const { getByText } = (0, react_1.render)(react_2.default.createElement(identity_link_component_1.IdentityLink, { returnTo: true }, (url) => react_2.default.createElement("a", { href: url }, "Login")));
|
|
22
|
-
expect(getByText('Login')).toHaveAttribute('href', 'https://accounts.monstrs.dev/auth/login?return_to=https://identity.monstrs.dev/');
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
export type IdentityUrlType = 'login' | 'logout' | 'recovery' | 'registration' | 'settings' | 'verification';
|
|
3
|
+
export interface UseIdentityUrlReturnToProps {
|
|
4
|
+
subdomain?: string;
|
|
5
|
+
pathname?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UseIdentityUrlProps {
|
|
8
|
+
type?: IdentityUrlType;
|
|
9
|
+
returnTo?: UseIdentityUrlReturnToProps | false | true;
|
|
10
|
+
}
|
|
11
|
+
export interface IdentityLinkProps extends UseIdentityUrlProps {
|
|
12
|
+
children?: (value: string) => JSX.Element;
|
|
13
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./identity-link.component"), exports);
|
|
14
|
-
__exportStar(require("./identity-url.interfaces"), exports);
|
|
15
18
|
__exportStar(require("./use-identity-url.hook"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UseIdentityUrlProps } from './identity-url.interfaces';
|
|
2
|
+
export declare const identityUrlTypes: {
|
|
3
|
+
login: string;
|
|
4
|
+
registration: string;
|
|
5
|
+
verification: string;
|
|
6
|
+
recovery: string;
|
|
7
|
+
logout: string;
|
|
8
|
+
settings: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const useIdentityUrl: ({ type, returnTo }?: UseIdentityUrlProps) => string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atls/react-identity-links",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"@testing-library/jest-dom": "^5.16.2",
|
|
19
19
|
"@testing-library/react": "^12.1.3",
|
|
20
20
|
"@testing-library/react-hooks": "^7.0.2",
|
|
21
|
-
"@types/react": "
|
|
22
|
-
"@types/react-dom": "^
|
|
21
|
+
"@types/react": "18.3.6",
|
|
22
|
+
"@types/react-dom": "^18.2.7",
|
|
23
23
|
"@types/testing-library__jest-dom": "^5.14.1",
|
|
24
|
-
"
|
|
25
|
-
"react
|
|
24
|
+
"@types/tldjs": "2.3.4",
|
|
25
|
+
"react": "^18.2.0",
|
|
26
|
+
"react-dom": "^18.2.0"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"react": "^17.0.1"
|