sessioncore 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 +13 -2
- package/package.json +35 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export interface Session {
|
|
2
|
+
id: string;
|
|
3
|
+
principalId: string;
|
|
4
|
+
issuedAt: number;
|
|
5
|
+
expiresAt: number;
|
|
6
|
+
methods: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function createSession(session: Session): Readonly<Session>;
|
|
9
|
+
export declare function isSessionActive(session: Session, now?: number): boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export function createSession(session) {
|
|
2
|
+
if (!session.id ||
|
|
3
|
+
!session.principalId ||
|
|
4
|
+
session.expiresAt <= session.issuedAt)
|
|
5
|
+
throw new TypeError("Invalid session.");
|
|
6
|
+
return Object.freeze({
|
|
7
|
+
...session,
|
|
8
|
+
methods: Object.freeze([...session.methods]),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function isSessionActive(session, now = Date.now()) {
|
|
12
|
+
return session.issuedAt <= now && now < session.expiresAt;
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sessioncore",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Framework-neutral session primitives for identity systems.",
|
|
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
|
+
"identity",
|
|
26
|
+
"session",
|
|
27
|
+
"auth"
|
|
28
|
+
],
|
|
13
29
|
"homepage": "https://signway.dev/",
|
|
14
30
|
"author": "Mosanic <dev@mosanic.io>",
|
|
15
31
|
"license": "MIT",
|
|
16
|
-
"engines": {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^5.9.3"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/mosanic/mosa-platform.git",
|
|
44
|
+
"directory": "packages/sessioncore"
|
|
45
|
+
}
|
|
20
46
|
}
|