@nanodb-orm/plugin-auth 0.0.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/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +458 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Easy-Deploy-Dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# @nanodb-orm/plugin-auth
|
|
2
|
+
|
|
3
|
+
Auth plugin for `nanodb-orm`.
|
|
4
|
+
|
|
5
|
+
This plugin is ORM-level and lightweight, and follows `nanodb-orm` plugin conventions:
|
|
6
|
+
- `user` / `account` / `session` / `verification` table conventions (configurable)
|
|
7
|
+
- email normalization and `emailVerified` defaulting
|
|
8
|
+
- credential password hashing and verification
|
|
9
|
+
- session `expiresIn` + `updateAge` refresh model
|
|
10
|
+
- verification token hashing by default
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @nanodb-orm/plugin-auth
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { createDatabase } from 'nanodb-orm';
|
|
22
|
+
import { authPlugin, withAuth } from '@nanodb-orm/plugin-auth';
|
|
23
|
+
|
|
24
|
+
const db = await createDatabase({
|
|
25
|
+
tables,
|
|
26
|
+
plugins: [authPlugin()],
|
|
27
|
+
preview: { deterministicPluginOrdering: true },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const authDb = withAuth(db);
|
|
31
|
+
const hash = authDb.auth.hashPassword('my-strong-password');
|
|
32
|
+
const ok = authDb.auth.verifyPassword('my-strong-password', hash);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Options
|
|
36
|
+
|
|
37
|
+
Default policy used by `authPlugin()`:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
{
|
|
41
|
+
session: {
|
|
42
|
+
expiresIn: 60 * 60 * 24 * 7,
|
|
43
|
+
updateAge: 60 * 60 * 24,
|
|
44
|
+
},
|
|
45
|
+
emailAndPassword: {
|
|
46
|
+
minPasswordLength: 8,
|
|
47
|
+
maxPasswordLength: 128,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
You can override any of these values:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
authPlugin({
|
|
56
|
+
tables: {
|
|
57
|
+
users: ['user'],
|
|
58
|
+
accounts: ['account'],
|
|
59
|
+
sessions: ['session'],
|
|
60
|
+
verifications: ['verification'],
|
|
61
|
+
},
|
|
62
|
+
fields: {
|
|
63
|
+
userEmail: 'email',
|
|
64
|
+
userEmailVerified: 'emailVerified',
|
|
65
|
+
|
|
66
|
+
accountPassword: 'password',
|
|
67
|
+
accountProviderId: 'providerId',
|
|
68
|
+
accountAccountId: 'accountId',
|
|
69
|
+
accountUserId: 'userId',
|
|
70
|
+
|
|
71
|
+
sessionToken: 'token',
|
|
72
|
+
sessionUserId: 'userId',
|
|
73
|
+
sessionExpiresAt: 'expiresAt',
|
|
74
|
+
sessionCreatedAt: 'createdAt',
|
|
75
|
+
sessionUpdatedAt: 'updatedAt',
|
|
76
|
+
|
|
77
|
+
verificationIdentifier: 'identifier',
|
|
78
|
+
verificationValue: 'value',
|
|
79
|
+
verificationExpiresAt: 'expiresAt',
|
|
80
|
+
verificationCreatedAt: 'createdAt',
|
|
81
|
+
verificationUpdatedAt: 'updatedAt',
|
|
82
|
+
},
|
|
83
|
+
emailAndPassword: {
|
|
84
|
+
enabled: true,
|
|
85
|
+
minPasswordLength: 8,
|
|
86
|
+
maxPasswordLength: 128,
|
|
87
|
+
requireEmailVerification: false,
|
|
88
|
+
},
|
|
89
|
+
session: {
|
|
90
|
+
expiresIn: 60 * 60 * 24 * 7,
|
|
91
|
+
updateAge: 60 * 60 * 24,
|
|
92
|
+
disableSessionRefresh: false,
|
|
93
|
+
tokenBytes: 32,
|
|
94
|
+
},
|
|
95
|
+
verification: {
|
|
96
|
+
expiresIn: 60 * 60,
|
|
97
|
+
hashToken: true,
|
|
98
|
+
},
|
|
99
|
+
allowedProviders: ['credential', 'google', 'github'],
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Notes
|
|
104
|
+
|
|
105
|
+
- Plugin name is `auth`, and the installed API is on `db.auth`.
|
|
106
|
+
- Exports: `authPlugin` and `withAuth`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { NanoPlugin } from 'nanodb-orm';
|
|
2
|
+
export declare const DEFAULT_AUTH_PLUGIN_OPTIONS: {
|
|
3
|
+
readonly session: {
|
|
4
|
+
readonly expiresIn: number;
|
|
5
|
+
readonly updateAge: number;
|
|
6
|
+
};
|
|
7
|
+
readonly emailAndPassword: {
|
|
8
|
+
readonly minPasswordLength: 8;
|
|
9
|
+
readonly maxPasswordLength: 128;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export interface AuthTableOptions {
|
|
13
|
+
users?: string | string[];
|
|
14
|
+
accounts?: string | string[];
|
|
15
|
+
sessions?: string | string[];
|
|
16
|
+
verifications?: string | string[];
|
|
17
|
+
}
|
|
18
|
+
export interface AuthFieldOptions {
|
|
19
|
+
userEmail?: string;
|
|
20
|
+
userEmailVerified?: string;
|
|
21
|
+
accountPassword?: string;
|
|
22
|
+
accountProviderId?: string;
|
|
23
|
+
accountAccountId?: string;
|
|
24
|
+
accountUserId?: string;
|
|
25
|
+
sessionToken?: string;
|
|
26
|
+
sessionUserId?: string;
|
|
27
|
+
sessionExpiresAt?: string;
|
|
28
|
+
sessionCreatedAt?: string;
|
|
29
|
+
sessionUpdatedAt?: string;
|
|
30
|
+
verificationIdentifier?: string;
|
|
31
|
+
verificationValue?: string;
|
|
32
|
+
verificationExpiresAt?: string;
|
|
33
|
+
verificationCreatedAt?: string;
|
|
34
|
+
verificationUpdatedAt?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AuthScryptOptions {
|
|
37
|
+
N?: number;
|
|
38
|
+
r?: number;
|
|
39
|
+
p?: number;
|
|
40
|
+
keyLength?: number;
|
|
41
|
+
saltBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface AuthPasswordOptions {
|
|
44
|
+
hash?: (password: string) => string;
|
|
45
|
+
verify?: (params: {
|
|
46
|
+
password: string;
|
|
47
|
+
hash: string;
|
|
48
|
+
}) => boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface AuthEmailAndPasswordOptions {
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
minPasswordLength?: number;
|
|
53
|
+
maxPasswordLength?: number;
|
|
54
|
+
requireEmailVerification?: boolean;
|
|
55
|
+
password?: AuthPasswordOptions;
|
|
56
|
+
}
|
|
57
|
+
export interface AuthSessionOptions {
|
|
58
|
+
expiresIn?: number;
|
|
59
|
+
updateAge?: number;
|
|
60
|
+
disableSessionRefresh?: boolean;
|
|
61
|
+
tokenBytes?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface AuthVerificationOptions {
|
|
64
|
+
expiresIn?: number;
|
|
65
|
+
hashToken?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface AuthPluginOptions {
|
|
68
|
+
tables?: AuthTableOptions;
|
|
69
|
+
fields?: AuthFieldOptions;
|
|
70
|
+
scrypt?: AuthScryptOptions;
|
|
71
|
+
allowedProviders?: string[];
|
|
72
|
+
emailAndPassword?: AuthEmailAndPasswordOptions;
|
|
73
|
+
session?: AuthSessionOptions;
|
|
74
|
+
verification?: AuthVerificationOptions;
|
|
75
|
+
}
|
|
76
|
+
export interface AuthPluginApi {
|
|
77
|
+
normalizeEmail: (email: string) => string;
|
|
78
|
+
hashPassword: (password: string) => string;
|
|
79
|
+
verifyPassword: (password: string, encodedHash: string) => boolean;
|
|
80
|
+
createSessionToken: () => string;
|
|
81
|
+
createSessionRecord: (userId: string, seed?: Record<string, unknown>) => Record<string, unknown>;
|
|
82
|
+
shouldRefreshSession: (updatedAt: string | number | Date) => boolean;
|
|
83
|
+
refreshSessionRecord: (seed?: Record<string, unknown>) => Record<string, unknown>;
|
|
84
|
+
isSessionExpired: (expiresAt: string | number | Date) => boolean;
|
|
85
|
+
hashVerificationValue: (value: string) => string;
|
|
86
|
+
createVerificationRecord: (identifier: string, value: string, seed?: Record<string, unknown>) => Record<string, unknown>;
|
|
87
|
+
verifyStoredVerificationValue: (value: string, storedValue: string) => boolean;
|
|
88
|
+
validateProvider: (provider: string) => boolean;
|
|
89
|
+
}
|
|
90
|
+
export type AuthEnabled<T> = T & {
|
|
91
|
+
auth: AuthPluginApi;
|
|
92
|
+
};
|
|
93
|
+
export declare function authPlugin(options?: AuthPluginOptions): NanoPlugin;
|
|
94
|
+
export declare function withAuth<T>(db: T): AuthEnabled<T>;
|
|
95
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA+C7C,eAAO,MAAM,2BAA2B;;;;;;;;;CAS9B,CAAC;AAkFX,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,CAAC,EA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BAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CACjD;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAkbzD,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CAmDtE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEjD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_AUTH_PLUGIN_OPTIONS = void 0;
|
|
4
|
+
exports.authPlugin = authPlugin;
|
|
5
|
+
exports.withAuth = withAuth;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const HASH_VERSION = 'n2';
|
|
8
|
+
const CREDENTIAL_PROVIDER_ID = 'credential';
|
|
9
|
+
const DEFAULT_TABLES = {
|
|
10
|
+
users: ['user', 'users'],
|
|
11
|
+
accounts: ['account', 'accounts'],
|
|
12
|
+
sessions: ['session', 'sessions'],
|
|
13
|
+
verifications: ['verification', 'verifications', 'verificationToken'],
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_FIELDS = {
|
|
16
|
+
userEmail: 'email',
|
|
17
|
+
userEmailVerified: 'emailVerified',
|
|
18
|
+
accountPassword: 'password',
|
|
19
|
+
accountProviderId: 'providerId',
|
|
20
|
+
accountAccountId: 'accountId',
|
|
21
|
+
accountUserId: 'userId',
|
|
22
|
+
sessionToken: 'token',
|
|
23
|
+
sessionUserId: 'userId',
|
|
24
|
+
sessionExpiresAt: 'expiresAt',
|
|
25
|
+
sessionCreatedAt: 'createdAt',
|
|
26
|
+
sessionUpdatedAt: 'updatedAt',
|
|
27
|
+
verificationIdentifier: 'identifier',
|
|
28
|
+
verificationValue: 'value',
|
|
29
|
+
verificationExpiresAt: 'expiresAt',
|
|
30
|
+
verificationCreatedAt: 'createdAt',
|
|
31
|
+
verificationUpdatedAt: 'updatedAt',
|
|
32
|
+
};
|
|
33
|
+
const DEFAULT_SCRYPT = {
|
|
34
|
+
N: 16384,
|
|
35
|
+
r: 8,
|
|
36
|
+
p: 1,
|
|
37
|
+
keyLength: 64,
|
|
38
|
+
saltBytes: 16,
|
|
39
|
+
};
|
|
40
|
+
const DEFAULT_SESSION_EXPIRES_IN_SECONDS = 60 * 60 * 24 * 7;
|
|
41
|
+
const DEFAULT_SESSION_UPDATE_AGE_SECONDS = 60 * 60 * 24;
|
|
42
|
+
const DEFAULT_VERIFICATION_EXPIRES_IN_SECONDS = 60 * 60;
|
|
43
|
+
const DEFAULT_TOKEN_BYTES = 32;
|
|
44
|
+
exports.DEFAULT_AUTH_PLUGIN_OPTIONS = {
|
|
45
|
+
session: {
|
|
46
|
+
expiresIn: DEFAULT_SESSION_EXPIRES_IN_SECONDS,
|
|
47
|
+
updateAge: DEFAULT_SESSION_UPDATE_AGE_SECONDS,
|
|
48
|
+
},
|
|
49
|
+
emailAndPassword: {
|
|
50
|
+
minPasswordLength: 8,
|
|
51
|
+
maxPasswordLength: 128,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
function toSet(value, fallback) {
|
|
55
|
+
const source = value === undefined ? fallback : (Array.isArray(value) ? value : [value]);
|
|
56
|
+
return new Set(source.map((item) => item.trim().toLowerCase()).filter(Boolean));
|
|
57
|
+
}
|
|
58
|
+
function toPositiveInteger(value, fallback) {
|
|
59
|
+
if (value === undefined)
|
|
60
|
+
return fallback;
|
|
61
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
62
|
+
throw new Error(`auth plugin requires a positive integer, got: ${String(value)}`);
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
function isRecord(value) {
|
|
67
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
68
|
+
}
|
|
69
|
+
function normalizeTableName(name) {
|
|
70
|
+
return name.trim().toLowerCase();
|
|
71
|
+
}
|
|
72
|
+
function nowIso() {
|
|
73
|
+
return new Date().toISOString();
|
|
74
|
+
}
|
|
75
|
+
function addSeconds(seconds) {
|
|
76
|
+
return new Date(Date.now() + seconds * 1000).toISOString();
|
|
77
|
+
}
|
|
78
|
+
function normalizeEmailValue(email) {
|
|
79
|
+
return email.trim().toLowerCase();
|
|
80
|
+
}
|
|
81
|
+
function parseTimestamp(value) {
|
|
82
|
+
if (value instanceof Date)
|
|
83
|
+
return value.getTime();
|
|
84
|
+
if (typeof value === 'number')
|
|
85
|
+
return value;
|
|
86
|
+
return new Date(value).getTime();
|
|
87
|
+
}
|
|
88
|
+
function maxmemFor(settings) {
|
|
89
|
+
return 128 * settings.N * settings.r * 2;
|
|
90
|
+
}
|
|
91
|
+
function hashPasswordValue(password, settings) {
|
|
92
|
+
const salt = (0, node_crypto_1.randomBytes)(settings.saltBytes);
|
|
93
|
+
const derived = (0, node_crypto_1.scryptSync)(password, salt, settings.keyLength, {
|
|
94
|
+
N: settings.N,
|
|
95
|
+
r: settings.r,
|
|
96
|
+
p: settings.p,
|
|
97
|
+
maxmem: maxmemFor(settings),
|
|
98
|
+
});
|
|
99
|
+
return [
|
|
100
|
+
HASH_VERSION,
|
|
101
|
+
String(settings.N),
|
|
102
|
+
String(settings.r),
|
|
103
|
+
String(settings.p),
|
|
104
|
+
String(settings.keyLength),
|
|
105
|
+
salt.toString('base64url'),
|
|
106
|
+
Buffer.from(derived).toString('base64url'),
|
|
107
|
+
].join('$');
|
|
108
|
+
}
|
|
109
|
+
function parseHash(encodedHash) {
|
|
110
|
+
const parts = encodedHash.split('$');
|
|
111
|
+
if (parts.length !== 7)
|
|
112
|
+
return null;
|
|
113
|
+
if (parts[0] !== HASH_VERSION)
|
|
114
|
+
return null;
|
|
115
|
+
const N = Number(parts[1]);
|
|
116
|
+
const r = Number(parts[2]);
|
|
117
|
+
const p = Number(parts[3]);
|
|
118
|
+
const keyLength = Number(parts[4]);
|
|
119
|
+
if (![N, r, p, keyLength].every((value) => Number.isInteger(value) && value > 0)) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const saltPart = parts[5];
|
|
123
|
+
const digestPart = parts[6];
|
|
124
|
+
if (saltPart === undefined || digestPart === undefined) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const salt = Buffer.from(saltPart, 'base64url');
|
|
129
|
+
const digest = Buffer.from(digestPart, 'base64url');
|
|
130
|
+
if (salt.length === 0 || digest.length === 0)
|
|
131
|
+
return null;
|
|
132
|
+
return { N, r, p, keyLength, salt, digest };
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function verifyPasswordValue(password, encodedHash) {
|
|
139
|
+
const parsed = parseHash(encodedHash);
|
|
140
|
+
if (!parsed)
|
|
141
|
+
return false;
|
|
142
|
+
const derived = (0, node_crypto_1.scryptSync)(password, parsed.salt, parsed.keyLength, {
|
|
143
|
+
N: parsed.N,
|
|
144
|
+
r: parsed.r,
|
|
145
|
+
p: parsed.p,
|
|
146
|
+
maxmem: maxmemFor(parsed),
|
|
147
|
+
});
|
|
148
|
+
const digest = Buffer.from(derived);
|
|
149
|
+
if (digest.length !== parsed.digest.length) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
return (0, node_crypto_1.timingSafeEqual)(digest, parsed.digest);
|
|
153
|
+
}
|
|
154
|
+
function hashVerificationValue(value) {
|
|
155
|
+
return (0, node_crypto_1.createHash)('sha256').update(value).digest('hex');
|
|
156
|
+
}
|
|
157
|
+
function createSessionToken(bytes) {
|
|
158
|
+
return (0, node_crypto_1.randomBytes)(bytes).toString('base64url');
|
|
159
|
+
}
|
|
160
|
+
function normalizeProvider(value) {
|
|
161
|
+
return value.trim().toLowerCase();
|
|
162
|
+
}
|
|
163
|
+
function resolveOptions(options) {
|
|
164
|
+
const fields = {
|
|
165
|
+
userEmail: options.fields?.userEmail ?? DEFAULT_FIELDS.userEmail,
|
|
166
|
+
userEmailVerified: options.fields?.userEmailVerified ?? DEFAULT_FIELDS.userEmailVerified,
|
|
167
|
+
accountPassword: options.fields?.accountPassword ?? DEFAULT_FIELDS.accountPassword,
|
|
168
|
+
accountProviderId: options.fields?.accountProviderId ?? DEFAULT_FIELDS.accountProviderId,
|
|
169
|
+
accountAccountId: options.fields?.accountAccountId ?? DEFAULT_FIELDS.accountAccountId,
|
|
170
|
+
accountUserId: options.fields?.accountUserId ?? DEFAULT_FIELDS.accountUserId,
|
|
171
|
+
sessionToken: options.fields?.sessionToken ?? DEFAULT_FIELDS.sessionToken,
|
|
172
|
+
sessionUserId: options.fields?.sessionUserId ?? DEFAULT_FIELDS.sessionUserId,
|
|
173
|
+
sessionExpiresAt: options.fields?.sessionExpiresAt ?? DEFAULT_FIELDS.sessionExpiresAt,
|
|
174
|
+
sessionCreatedAt: options.fields?.sessionCreatedAt ?? DEFAULT_FIELDS.sessionCreatedAt,
|
|
175
|
+
sessionUpdatedAt: options.fields?.sessionUpdatedAt ?? DEFAULT_FIELDS.sessionUpdatedAt,
|
|
176
|
+
verificationIdentifier: options.fields?.verificationIdentifier ?? DEFAULT_FIELDS.verificationIdentifier,
|
|
177
|
+
verificationValue: options.fields?.verificationValue ?? DEFAULT_FIELDS.verificationValue,
|
|
178
|
+
verificationExpiresAt: options.fields?.verificationExpiresAt ?? DEFAULT_FIELDS.verificationExpiresAt,
|
|
179
|
+
verificationCreatedAt: options.fields?.verificationCreatedAt ?? DEFAULT_FIELDS.verificationCreatedAt,
|
|
180
|
+
verificationUpdatedAt: options.fields?.verificationUpdatedAt ?? DEFAULT_FIELDS.verificationUpdatedAt,
|
|
181
|
+
};
|
|
182
|
+
const scrypt = {
|
|
183
|
+
N: toPositiveInteger(options.scrypt?.N, DEFAULT_SCRYPT.N),
|
|
184
|
+
r: toPositiveInteger(options.scrypt?.r, DEFAULT_SCRYPT.r),
|
|
185
|
+
p: toPositiveInteger(options.scrypt?.p, DEFAULT_SCRYPT.p),
|
|
186
|
+
keyLength: toPositiveInteger(options.scrypt?.keyLength, DEFAULT_SCRYPT.keyLength),
|
|
187
|
+
saltBytes: toPositiveInteger(options.scrypt?.saltBytes, DEFAULT_SCRYPT.saltBytes),
|
|
188
|
+
};
|
|
189
|
+
const minPasswordLength = toPositiveInteger(options.emailAndPassword?.minPasswordLength, exports.DEFAULT_AUTH_PLUGIN_OPTIONS.emailAndPassword.minPasswordLength);
|
|
190
|
+
const maxPasswordLength = toPositiveInteger(options.emailAndPassword?.maxPasswordLength, exports.DEFAULT_AUTH_PLUGIN_OPTIONS.emailAndPassword.maxPasswordLength);
|
|
191
|
+
if (maxPasswordLength < minPasswordLength) {
|
|
192
|
+
throw new Error('auth plugin requires maxPasswordLength >= minPasswordLength');
|
|
193
|
+
}
|
|
194
|
+
const passwordAdapter = {
|
|
195
|
+
hash: options.emailAndPassword?.password?.hash ?? ((password) => hashPasswordValue(password, scrypt)),
|
|
196
|
+
verify: options.emailAndPassword?.password?.verify ?? ((params) => verifyPasswordValue(params.password, params.hash)),
|
|
197
|
+
};
|
|
198
|
+
const allowedProviders = options.allowedProviders?.length
|
|
199
|
+
? new Set(options.allowedProviders.map(normalizeProvider).filter(Boolean))
|
|
200
|
+
: undefined;
|
|
201
|
+
const resolved = {
|
|
202
|
+
tables: {
|
|
203
|
+
users: toSet(options.tables?.users, DEFAULT_TABLES.users),
|
|
204
|
+
accounts: toSet(options.tables?.accounts, DEFAULT_TABLES.accounts),
|
|
205
|
+
sessions: toSet(options.tables?.sessions, DEFAULT_TABLES.sessions),
|
|
206
|
+
verifications: toSet(options.tables?.verifications, DEFAULT_TABLES.verifications),
|
|
207
|
+
},
|
|
208
|
+
fields,
|
|
209
|
+
emailAndPassword: {
|
|
210
|
+
enabled: options.emailAndPassword?.enabled ?? true,
|
|
211
|
+
minPasswordLength,
|
|
212
|
+
maxPasswordLength,
|
|
213
|
+
requireEmailVerification: options.emailAndPassword?.requireEmailVerification ?? false,
|
|
214
|
+
password: passwordAdapter,
|
|
215
|
+
},
|
|
216
|
+
session: {
|
|
217
|
+
expiresIn: toPositiveInteger(options.session?.expiresIn, exports.DEFAULT_AUTH_PLUGIN_OPTIONS.session.expiresIn),
|
|
218
|
+
updateAge: toPositiveInteger(options.session?.updateAge, exports.DEFAULT_AUTH_PLUGIN_OPTIONS.session.updateAge),
|
|
219
|
+
disableSessionRefresh: options.session?.disableSessionRefresh ?? false,
|
|
220
|
+
tokenBytes: toPositiveInteger(options.session?.tokenBytes, DEFAULT_TOKEN_BYTES),
|
|
221
|
+
},
|
|
222
|
+
verification: {
|
|
223
|
+
expiresIn: toPositiveInteger(options.verification?.expiresIn, DEFAULT_VERIFICATION_EXPIRES_IN_SECONDS),
|
|
224
|
+
hashToken: options.verification?.hashToken ?? true,
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
if (allowedProviders) {
|
|
228
|
+
resolved.allowedProviders = allowedProviders;
|
|
229
|
+
}
|
|
230
|
+
return resolved;
|
|
231
|
+
}
|
|
232
|
+
function shouldMatch(table, targets) {
|
|
233
|
+
return targets.has(normalizeTableName(table));
|
|
234
|
+
}
|
|
235
|
+
function ensurePasswordSecurity(password, config) {
|
|
236
|
+
if (password.length < config.emailAndPassword.minPasswordLength) {
|
|
237
|
+
throw new Error(`auth plugin requires password length >= ${config.emailAndPassword.minPasswordLength}`);
|
|
238
|
+
}
|
|
239
|
+
if (password.length > config.emailAndPassword.maxPasswordLength) {
|
|
240
|
+
throw new Error(`auth plugin requires password length <= ${config.emailAndPassword.maxPasswordLength}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function applyUserRules(row, config, isInsert) {
|
|
244
|
+
const next = { ...row };
|
|
245
|
+
const emailValue = next[config.fields.userEmail];
|
|
246
|
+
if (typeof emailValue === 'string') {
|
|
247
|
+
next[config.fields.userEmail] = normalizeEmailValue(emailValue);
|
|
248
|
+
}
|
|
249
|
+
if (isInsert && next[config.fields.userEmailVerified] === undefined) {
|
|
250
|
+
next[config.fields.userEmailVerified] = false;
|
|
251
|
+
}
|
|
252
|
+
return next;
|
|
253
|
+
}
|
|
254
|
+
function applyProviderRules(row, config) {
|
|
255
|
+
if (!config.allowedProviders)
|
|
256
|
+
return;
|
|
257
|
+
const providerValue = row[config.fields.accountProviderId];
|
|
258
|
+
if (providerValue === undefined || providerValue === null)
|
|
259
|
+
return;
|
|
260
|
+
if (typeof providerValue !== 'string' || providerValue.trim().length === 0) {
|
|
261
|
+
throw new Error(`auth plugin expected a string provider in "${config.fields.accountProviderId}"`);
|
|
262
|
+
}
|
|
263
|
+
if (!config.allowedProviders.has(normalizeProvider(providerValue))) {
|
|
264
|
+
throw new Error(`auth plugin rejected provider "${providerValue}"`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function applyAccountRules(row, config) {
|
|
268
|
+
const next = { ...row };
|
|
269
|
+
if (!config.emailAndPassword.enabled) {
|
|
270
|
+
applyProviderRules(next, config);
|
|
271
|
+
return next;
|
|
272
|
+
}
|
|
273
|
+
const passwordValue = next[config.fields.accountPassword];
|
|
274
|
+
const hasPassword = typeof passwordValue === 'string' && passwordValue.length > 0;
|
|
275
|
+
if (hasPassword) {
|
|
276
|
+
ensurePasswordSecurity(passwordValue, config);
|
|
277
|
+
next[config.fields.accountPassword] = config.emailAndPassword.password.hash(passwordValue);
|
|
278
|
+
if (next[config.fields.accountProviderId] === undefined) {
|
|
279
|
+
next[config.fields.accountProviderId] = CREDENTIAL_PROVIDER_ID;
|
|
280
|
+
}
|
|
281
|
+
const provider = next[config.fields.accountProviderId];
|
|
282
|
+
if (next[config.fields.accountAccountId] === undefined &&
|
|
283
|
+
provider === CREDENTIAL_PROVIDER_ID &&
|
|
284
|
+
next[config.fields.accountUserId] !== undefined) {
|
|
285
|
+
next[config.fields.accountAccountId] = String(next[config.fields.accountUserId]);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
applyProviderRules(next, config);
|
|
289
|
+
return next;
|
|
290
|
+
}
|
|
291
|
+
function refreshSessionFields(target, config) {
|
|
292
|
+
target[config.fields.sessionExpiresAt] = addSeconds(config.session.expiresIn);
|
|
293
|
+
target[config.fields.sessionUpdatedAt] = nowIso();
|
|
294
|
+
}
|
|
295
|
+
function applySessionInsertRules(row, config) {
|
|
296
|
+
const next = { ...row };
|
|
297
|
+
if (next[config.fields.sessionToken] === undefined || next[config.fields.sessionToken] === null) {
|
|
298
|
+
next[config.fields.sessionToken] = createSessionToken(config.session.tokenBytes);
|
|
299
|
+
}
|
|
300
|
+
if (next[config.fields.sessionExpiresAt] === undefined || next[config.fields.sessionExpiresAt] === null) {
|
|
301
|
+
next[config.fields.sessionExpiresAt] = addSeconds(config.session.expiresIn);
|
|
302
|
+
}
|
|
303
|
+
if (next[config.fields.sessionCreatedAt] === undefined) {
|
|
304
|
+
next[config.fields.sessionCreatedAt] = nowIso();
|
|
305
|
+
}
|
|
306
|
+
if (next[config.fields.sessionUpdatedAt] === undefined) {
|
|
307
|
+
next[config.fields.sessionUpdatedAt] = nowIso();
|
|
308
|
+
}
|
|
309
|
+
return next;
|
|
310
|
+
}
|
|
311
|
+
function shouldRefreshSession(updatedAt, config) {
|
|
312
|
+
if (config.session.disableSessionRefresh)
|
|
313
|
+
return false;
|
|
314
|
+
const ts = parseTimestamp(updatedAt);
|
|
315
|
+
if (!Number.isFinite(ts))
|
|
316
|
+
return true;
|
|
317
|
+
return Date.now() - ts >= config.session.updateAge * 1000;
|
|
318
|
+
}
|
|
319
|
+
function applySessionUpdateRules(row, config) {
|
|
320
|
+
const next = { ...row };
|
|
321
|
+
if (config.session.disableSessionRefresh)
|
|
322
|
+
return next;
|
|
323
|
+
const updatedAt = next[config.fields.sessionUpdatedAt];
|
|
324
|
+
if (updatedAt === undefined || updatedAt === null) {
|
|
325
|
+
refreshSessionFields(next, config);
|
|
326
|
+
return next;
|
|
327
|
+
}
|
|
328
|
+
if (updatedAt instanceof Date ||
|
|
329
|
+
typeof updatedAt === 'string' ||
|
|
330
|
+
typeof updatedAt === 'number') {
|
|
331
|
+
if (shouldRefreshSession(updatedAt, config)) {
|
|
332
|
+
refreshSessionFields(next, config);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
refreshSessionFields(next, config);
|
|
337
|
+
}
|
|
338
|
+
return next;
|
|
339
|
+
}
|
|
340
|
+
function applyVerificationRules(row, config) {
|
|
341
|
+
const next = { ...row };
|
|
342
|
+
if (next[config.fields.verificationExpiresAt] === undefined) {
|
|
343
|
+
next[config.fields.verificationExpiresAt] = addSeconds(config.verification.expiresIn);
|
|
344
|
+
}
|
|
345
|
+
if (next[config.fields.verificationCreatedAt] === undefined) {
|
|
346
|
+
next[config.fields.verificationCreatedAt] = nowIso();
|
|
347
|
+
}
|
|
348
|
+
if (next[config.fields.verificationUpdatedAt] === undefined) {
|
|
349
|
+
next[config.fields.verificationUpdatedAt] = nowIso();
|
|
350
|
+
}
|
|
351
|
+
const value = next[config.fields.verificationValue];
|
|
352
|
+
if (config.verification.hashToken && typeof value === 'string' && value.length > 0) {
|
|
353
|
+
next[config.fields.verificationValue] = hashVerificationValue(value);
|
|
354
|
+
}
|
|
355
|
+
return next;
|
|
356
|
+
}
|
|
357
|
+
function buildApi(config) {
|
|
358
|
+
return {
|
|
359
|
+
normalizeEmail: normalizeEmailValue,
|
|
360
|
+
hashPassword: (password) => {
|
|
361
|
+
ensurePasswordSecurity(password, config);
|
|
362
|
+
return config.emailAndPassword.password.hash(password);
|
|
363
|
+
},
|
|
364
|
+
verifyPassword: (password, encodedHash) => (config.emailAndPassword.password.verify({ password, hash: encodedHash })),
|
|
365
|
+
createSessionToken: () => createSessionToken(config.session.tokenBytes),
|
|
366
|
+
createSessionRecord: (userId, seed = {}) => {
|
|
367
|
+
const next = {
|
|
368
|
+
...seed,
|
|
369
|
+
[config.fields.sessionUserId]: userId,
|
|
370
|
+
};
|
|
371
|
+
return applySessionInsertRules(next, config);
|
|
372
|
+
},
|
|
373
|
+
shouldRefreshSession: (updatedAt) => shouldRefreshSession(updatedAt, config),
|
|
374
|
+
refreshSessionRecord: (seed = {}) => {
|
|
375
|
+
const next = { ...seed };
|
|
376
|
+
refreshSessionFields(next, config);
|
|
377
|
+
return next;
|
|
378
|
+
},
|
|
379
|
+
isSessionExpired: (expiresAt) => {
|
|
380
|
+
const ts = parseTimestamp(expiresAt);
|
|
381
|
+
return Number.isFinite(ts) ? Date.now() >= ts : true;
|
|
382
|
+
},
|
|
383
|
+
hashVerificationValue,
|
|
384
|
+
createVerificationRecord: (identifier, value, seed = {}) => {
|
|
385
|
+
const next = {
|
|
386
|
+
...seed,
|
|
387
|
+
[config.fields.verificationIdentifier]: identifier,
|
|
388
|
+
[config.fields.verificationValue]: value,
|
|
389
|
+
};
|
|
390
|
+
return applyVerificationRules(next, config);
|
|
391
|
+
},
|
|
392
|
+
verifyStoredVerificationValue: (value, storedValue) => {
|
|
393
|
+
if (!config.verification.hashToken) {
|
|
394
|
+
return value === storedValue;
|
|
395
|
+
}
|
|
396
|
+
return hashVerificationValue(value) === storedValue;
|
|
397
|
+
},
|
|
398
|
+
validateProvider: (provider) => {
|
|
399
|
+
if (!config.allowedProviders)
|
|
400
|
+
return true;
|
|
401
|
+
return config.allowedProviders.has(normalizeProvider(provider));
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function authPlugin(options = {}) {
|
|
406
|
+
const config = resolveOptions(options);
|
|
407
|
+
const api = buildApi(config);
|
|
408
|
+
return {
|
|
409
|
+
name: 'auth',
|
|
410
|
+
mutates: ['beforeInsert', 'beforeUpdate'],
|
|
411
|
+
install: (db) => {
|
|
412
|
+
if (!isRecord(db))
|
|
413
|
+
return db;
|
|
414
|
+
return {
|
|
415
|
+
...db,
|
|
416
|
+
auth: api,
|
|
417
|
+
};
|
|
418
|
+
},
|
|
419
|
+
beforeInsert: (table, data) => {
|
|
420
|
+
if (!isRecord(data))
|
|
421
|
+
return data;
|
|
422
|
+
if (shouldMatch(table, config.tables.users)) {
|
|
423
|
+
return applyUserRules(data, config, true);
|
|
424
|
+
}
|
|
425
|
+
if (shouldMatch(table, config.tables.accounts)) {
|
|
426
|
+
return applyAccountRules(data, config);
|
|
427
|
+
}
|
|
428
|
+
if (shouldMatch(table, config.tables.sessions)) {
|
|
429
|
+
return applySessionInsertRules(data, config);
|
|
430
|
+
}
|
|
431
|
+
if (shouldMatch(table, config.tables.verifications)) {
|
|
432
|
+
return applyVerificationRules(data, config);
|
|
433
|
+
}
|
|
434
|
+
return data;
|
|
435
|
+
},
|
|
436
|
+
beforeUpdate: (table, data) => {
|
|
437
|
+
if (!isRecord(data))
|
|
438
|
+
return data;
|
|
439
|
+
if (shouldMatch(table, config.tables.users)) {
|
|
440
|
+
return applyUserRules(data, config, false);
|
|
441
|
+
}
|
|
442
|
+
if (shouldMatch(table, config.tables.accounts)) {
|
|
443
|
+
return applyAccountRules(data, config);
|
|
444
|
+
}
|
|
445
|
+
if (shouldMatch(table, config.tables.sessions)) {
|
|
446
|
+
return applySessionUpdateRules(data, config);
|
|
447
|
+
}
|
|
448
|
+
if (shouldMatch(table, config.tables.verifications)) {
|
|
449
|
+
return applyVerificationRules(data, config);
|
|
450
|
+
}
|
|
451
|
+
return data;
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function withAuth(db) {
|
|
456
|
+
return db;
|
|
457
|
+
}
|
|
458
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA2pBA,gCAmDC;AAED,4BAEC;AAltBD,6CAAmF;AAGnF,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAE5C,MAAM,cAAc,GAAG;IACrB,KA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AAC;AACJ,CAAC;AAED,SAAgB,QAAQ,CAAI,EAAK;IAC/B,OAAO,EAAoB,CAAC;AAC9B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nanodb-orm/plugin-auth",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Auth plugin for nanodb-orm (user/account/session/verification helpers)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/**/*",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"clean": "rm -rf dist",
|
|
21
|
+
"pack:dry-run": "npm pack --dry-run"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"nanodb-orm": ">=0.0.9"
|
|
25
|
+
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"nanodb-orm": {
|
|
28
|
+
"optional": true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/Easy-Deploy-Dev/nanodb-orm.git"
|
|
38
|
+
}
|
|
39
|
+
}
|