magiclinkcore 0.0.1 → 0.0.2
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/dist/index.d.ts +9 -2
- package/dist/index.js +8 -2
- package/package.json +36 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export interface MagicLink {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
issuedAt: number;
|
|
5
|
+
expiresAt: number;
|
|
6
|
+
redirectTo?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function createMagicLink(link: MagicLink): Readonly<MagicLink>;
|
|
9
|
+
export declare function isMagicLinkValid(link: MagicLink, now?: number): boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export function createMagicLink(link) {
|
|
2
|
+
if (!/^\S+@\S+\.\S+$/.test(link.email) || link.expiresAt <= link.issuedAt)
|
|
3
|
+
throw new TypeError("Invalid magic link.");
|
|
4
|
+
return Object.freeze({ ...link });
|
|
5
|
+
}
|
|
6
|
+
export function isMagicLinkValid(link, now = Date.now()) {
|
|
7
|
+
return now < link.expiresAt;
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magiclinkcore",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Small, framework-neutral primitives for magic-link authentication.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
10
19
|
"sideEffects": false,
|
|
11
|
-
"scripts": {
|
|
12
|
-
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc --project tsconfig.json",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"auth",
|
|
26
|
+
"authentication",
|
|
27
|
+
"magic-link",
|
|
28
|
+
"passwordless"
|
|
29
|
+
],
|
|
13
30
|
"homepage": "https://signway.dev/",
|
|
14
31
|
"author": "Mosanic <dev@mosanic.io>",
|
|
15
32
|
"license": "MIT",
|
|
16
|
-
"engines": {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/mosanic/mosa-platform.git",
|
|
45
|
+
"directory": "packages/magiclinkcore"
|
|
46
|
+
}
|
|
20
47
|
}
|