auth-vir 1.3.0 → 1.3.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/auth.d.ts +1 -1
- package/dist/cookie.d.ts +2 -2
- package/dist/cookie.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{user-jwt.d.ts → jwt/user-jwt.d.ts} +2 -2
- package/dist/{user-jwt.js → jwt/user-jwt.js} +2 -2
- package/package.json +10 -10
- package/src/auth.ts +1 -1
- package/src/cookie.ts +2 -2
- package/src/index.ts +3 -3
- package/src/{user-jwt.ts → jwt/user-jwt.ts} +3 -3
- /package/dist/{jwt-keys.d.ts → jwt/jwt-keys.d.ts} +0 -0
- /package/dist/{jwt-keys.js → jwt/jwt-keys.js} +0 -0
- /package/dist/{jwt-keys.script.d.ts → jwt/jwt-keys.script.d.ts} +0 -0
- /package/dist/{jwt-keys.script.js → jwt/jwt-keys.script.js} +0 -0
- /package/dist/{jwt.d.ts → jwt/jwt.d.ts} +0 -0
- /package/dist/{jwt.js → jwt/jwt.js} +0 -0
- /package/src/{jwt-keys.script.ts → jwt/jwt-keys.script.ts} +0 -0
- /package/src/{jwt-keys.ts → jwt/jwt-keys.ts} +0 -0
- /package/src/{jwt.ts → jwt/jwt.ts} +0 -0
package/dist/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clearAuthCookie, type CookieParams } from './cookie.js';
|
|
2
|
-
import { type ParseJwtParams } from './jwt.js';
|
|
2
|
+
import { type ParseJwtParams } from './jwt/jwt.js';
|
|
3
3
|
/**
|
|
4
4
|
* All possible headers container types supported by {@link extractUserIdFromRequestHeaders}.
|
|
5
5
|
*
|
package/dist/cookie.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
2
|
import { type AnyDuration } from 'date-vir';
|
|
3
3
|
import { type Primitive } from 'type-fest';
|
|
4
|
-
import { type CreateJwtParams, type ParseJwtParams } from './jwt.js';
|
|
5
|
-
import { type UserJwtData } from './user-jwt.js';
|
|
4
|
+
import { type CreateJwtParams, type ParseJwtParams } from './jwt/jwt.js';
|
|
5
|
+
import { type UserJwtData } from './jwt/user-jwt.js';
|
|
6
6
|
/**
|
|
7
7
|
* Parameters for {@link generateAuthCookie}.
|
|
8
8
|
*
|
package/dist/cookie.js
CHANGED
|
@@ -2,7 +2,7 @@ import { check } from '@augment-vir/assert';
|
|
|
2
2
|
import { safeMatch } from '@augment-vir/common';
|
|
3
3
|
import { convertDuration } from 'date-vir';
|
|
4
4
|
import { parseUrl } from 'url-vir';
|
|
5
|
-
import { createUserJwt, parseUserJwt } from './user-jwt.js';
|
|
5
|
+
import { createUserJwt, parseUserJwt } from './jwt/user-jwt.js';
|
|
6
6
|
/**
|
|
7
7
|
* Generate a secure cookie that stores the user JWT data. Used in host (backend) code.
|
|
8
8
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './auth.js';
|
|
|
2
2
|
export * from './cookie.js';
|
|
3
3
|
export * from './csrf-token.js';
|
|
4
4
|
export * from './hash.js';
|
|
5
|
-
export * from './jwt-keys.js';
|
|
6
|
-
export * from './jwt.js';
|
|
5
|
+
export * from './jwt/jwt-keys.js';
|
|
6
|
+
export * from './jwt/jwt.js';
|
|
7
|
+
export * from './jwt/user-jwt.js';
|
|
7
8
|
export * from './mock-local-storage.js';
|
|
8
|
-
export * from './user-jwt.js';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from './auth.js';
|
|
|
2
2
|
export * from './cookie.js';
|
|
3
3
|
export * from './csrf-token.js';
|
|
4
4
|
export * from './hash.js';
|
|
5
|
-
export * from './jwt-keys.js';
|
|
6
|
-
export * from './jwt.js';
|
|
5
|
+
export * from './jwt/jwt-keys.js';
|
|
6
|
+
export * from './jwt/jwt.js';
|
|
7
|
+
export * from './jwt/user-jwt.js';
|
|
7
8
|
export * from './mock-local-storage.js';
|
|
8
|
-
export * from './user-jwt.js';
|
|
@@ -4,7 +4,7 @@ import { type CreateJwtParams, type ParseJwtParams } from './jwt.js';
|
|
|
4
4
|
*
|
|
5
5
|
* @category Internal
|
|
6
6
|
*/
|
|
7
|
-
export declare const userJwtDataShape: import("object-shape-tester").
|
|
7
|
+
export declare const userJwtDataShape: import("object-shape-tester").Shape<{
|
|
8
8
|
/** The id from your database of the user you're authenticating. */
|
|
9
9
|
userId: string;
|
|
10
10
|
/**
|
|
@@ -13,7 +13,7 @@ export declare const userJwtDataShape: import("object-shape-tester").ShapeDefini
|
|
|
13
13
|
* Consider using {@link generateCsrfToken} to generate this.
|
|
14
14
|
*/
|
|
15
15
|
csrfToken: string;
|
|
16
|
-
}
|
|
16
|
+
}>;
|
|
17
17
|
/**
|
|
18
18
|
* Data required for user JWTs.
|
|
19
19
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { checkValidShape, defineShape } from 'object-shape-tester';
|
|
2
2
|
import { createJwt, parseJwt } from './jwt.js';
|
|
3
3
|
/**
|
|
4
4
|
* Shape definition and source of truth for {@link UserJwtData}.
|
|
@@ -34,7 +34,7 @@ export async function createUserJwt(data, params) {
|
|
|
34
34
|
*/
|
|
35
35
|
export async function parseUserJwt(encryptedJwt, params) {
|
|
36
36
|
const parsed = await parseJwt(encryptedJwt, params);
|
|
37
|
-
if (!
|
|
37
|
+
if (!checkValidShape(parsed, userJwtDataShape)) {
|
|
38
38
|
throw new TypeError('Verified jwt has wrong data.');
|
|
39
39
|
}
|
|
40
40
|
return parsed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "auth-vir",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Auth made easy and secure via JWT cookies, CSRF tokens, and password hashing helpers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"test:update": "npm test update"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@augment-vir/assert": "^31.
|
|
44
|
-
"@augment-vir/common": "^31.
|
|
45
|
-
"date-vir": "^
|
|
43
|
+
"@augment-vir/assert": "^31.40.0",
|
|
44
|
+
"@augment-vir/common": "^31.40.0",
|
|
45
|
+
"date-vir": "^8.0.0",
|
|
46
46
|
"hash-wasm": "^4.12.0",
|
|
47
|
-
"jose": "^6.0
|
|
48
|
-
"object-shape-tester": "^
|
|
49
|
-
"type-fest": "^
|
|
50
|
-
"url-vir": "^2.1.
|
|
47
|
+
"jose": "^6.1.0",
|
|
48
|
+
"object-shape-tester": "^6.9.2",
|
|
49
|
+
"type-fest": "^5.1.0",
|
|
50
|
+
"url-vir": "^2.1.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@augment-vir/test": "^31.
|
|
53
|
+
"@augment-vir/test": "^31.40.0",
|
|
54
54
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
55
55
|
"@web/test-runner": "^0.20.2",
|
|
56
56
|
"@web/test-runner-commands": "^0.9.0",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
59
59
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
60
60
|
"markdown-code-example-inserter": "^3.0.3",
|
|
61
|
-
"typedoc": "^0.28.
|
|
61
|
+
"typedoc": "^0.28.14"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22"
|
package/src/auth.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
generateAuthCookie,
|
|
6
6
|
} from './cookie.js';
|
|
7
7
|
import {csrfTokenHeaderName, generateCsrfToken} from './csrf-token.js';
|
|
8
|
-
import {type ParseJwtParams} from './jwt.js';
|
|
8
|
+
import {type ParseJwtParams} from './jwt/jwt.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* All possible headers container types supported by {@link extractUserIdFromRequestHeaders}.
|
package/src/cookie.ts
CHANGED
|
@@ -3,8 +3,8 @@ import {safeMatch, type PartialWithUndefined} from '@augment-vir/common';
|
|
|
3
3
|
import {convertDuration, type AnyDuration} from 'date-vir';
|
|
4
4
|
import {type Primitive} from 'type-fest';
|
|
5
5
|
import {parseUrl} from 'url-vir';
|
|
6
|
-
import {type CreateJwtParams, type ParseJwtParams} from './jwt.js';
|
|
7
|
-
import {createUserJwt, parseUserJwt, type UserJwtData} from './user-jwt.js';
|
|
6
|
+
import {type CreateJwtParams, type ParseJwtParams} from './jwt/jwt.js';
|
|
7
|
+
import {createUserJwt, parseUserJwt, type UserJwtData} from './jwt/user-jwt.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Parameters for {@link generateAuthCookie}.
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './auth.js';
|
|
|
2
2
|
export * from './cookie.js';
|
|
3
3
|
export * from './csrf-token.js';
|
|
4
4
|
export * from './hash.js';
|
|
5
|
-
export * from './jwt-keys.js';
|
|
6
|
-
export * from './jwt.js';
|
|
5
|
+
export * from './jwt/jwt-keys.js';
|
|
6
|
+
export * from './jwt/jwt.js';
|
|
7
|
+
export * from './jwt/user-jwt.js';
|
|
7
8
|
export * from './mock-local-storage.js';
|
|
8
|
-
export * from './user-jwt.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {type generateCsrfToken} from '
|
|
1
|
+
import {checkValidShape, defineShape} from 'object-shape-tester';
|
|
2
|
+
import {type generateCsrfToken} from '../csrf-token.js';
|
|
3
3
|
import {createJwt, type CreateJwtParams, parseJwt, type ParseJwtParams} from './jwt.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -52,7 +52,7 @@ export async function parseUserJwt(
|
|
|
52
52
|
): Promise<UserJwtData | undefined> {
|
|
53
53
|
const parsed = await parseJwt(encryptedJwt, params);
|
|
54
54
|
|
|
55
|
-
if (!
|
|
55
|
+
if (!checkValidShape(parsed, userJwtDataShape)) {
|
|
56
56
|
throw new TypeError('Verified jwt has wrong data.');
|
|
57
57
|
}
|
|
58
58
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|