najm-auth 1.1.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/dist/index.d.ts +1466 -0
- package/dist/index.js +3201 -0
- package/dist/schema/mysql.d.ts +1297 -0
- package/dist/schema/mysql.js +72 -0
- package/dist/schema/pg.d.ts +1300 -0
- package/dist/schema/pg.js +78 -0
- package/dist/schema/sqlite.d.ts +1439 -0
- package/dist/schema/sqlite.js +65 -0
- package/package.json +90 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/schema/sqlite.ts
|
|
5
|
+
import { sqliteTable, text, integer, uniqueIndex } from "drizzle-orm/sqlite-core";
|
|
6
|
+
import { sql } from "drizzle-orm";
|
|
7
|
+
import { nanoid } from "nanoid";
|
|
8
|
+
var baseFields = /* @__PURE__ */ __name((idLength = 5) => ({
|
|
9
|
+
id: text("id").primaryKey().$defaultFn(() => nanoid(idLength)),
|
|
10
|
+
createdAt: text("created_at").$defaultFn(() => (/* @__PURE__ */ new Date()).toISOString()),
|
|
11
|
+
updatedAt: text("updated_at").$defaultFn(() => (/* @__PURE__ */ new Date()).toISOString()).$onUpdate(() => sql`(datetime('now'))`)
|
|
12
|
+
}), "baseFields");
|
|
13
|
+
var rolesTable = sqliteTable("roles", {
|
|
14
|
+
...baseFields(5),
|
|
15
|
+
name: text("name").notNull(),
|
|
16
|
+
description: text("description")
|
|
17
|
+
});
|
|
18
|
+
var usersTable = sqliteTable("users", {
|
|
19
|
+
...baseFields(8),
|
|
20
|
+
email: text("email").notNull().unique(),
|
|
21
|
+
emailVerified: integer("email_verified", { mode: "boolean" }).default(false),
|
|
22
|
+
password: text("password").notNull(),
|
|
23
|
+
image: text("image").default("noavatar.png"),
|
|
24
|
+
status: text("status").$type().default("pending"),
|
|
25
|
+
roleId: text("role_id").references(() => rolesTable.id),
|
|
26
|
+
lastLogin: text("last_login")
|
|
27
|
+
});
|
|
28
|
+
var permissionsTable = sqliteTable("permissions", {
|
|
29
|
+
...baseFields(5),
|
|
30
|
+
name: text("name").notNull().unique(),
|
|
31
|
+
description: text("description"),
|
|
32
|
+
resource: text("resource").notNull(),
|
|
33
|
+
action: text("action").notNull()
|
|
34
|
+
});
|
|
35
|
+
var tokensTable = sqliteTable("tokens", {
|
|
36
|
+
...baseFields(10),
|
|
37
|
+
userId: text("user_id").references(() => usersTable.id, { onDelete: "cascade" }).unique().notNull(),
|
|
38
|
+
token: text("token").notNull(),
|
|
39
|
+
type: text("type").$type().default("refresh"),
|
|
40
|
+
status: text("status").$type().default("active"),
|
|
41
|
+
expiresAt: text("expires_at").notNull()
|
|
42
|
+
});
|
|
43
|
+
var rolePermissionsTable = sqliteTable("role_permissions", {
|
|
44
|
+
...baseFields(10),
|
|
45
|
+
roleId: text("role_id").notNull().references(() => rolesTable.id, { onDelete: "cascade" }),
|
|
46
|
+
permissionId: text("permission_id").notNull().references(() => permissionsTable.id, { onDelete: "cascade" })
|
|
47
|
+
}, (table) => ({
|
|
48
|
+
uniq: uniqueIndex("role_permission_unique").on(table.roleId, table.permissionId)
|
|
49
|
+
}));
|
|
50
|
+
var authSchema = {
|
|
51
|
+
users: usersTable,
|
|
52
|
+
tokens: tokensTable,
|
|
53
|
+
roles: rolesTable,
|
|
54
|
+
permissions: permissionsTable,
|
|
55
|
+
rolePermissions: rolePermissionsTable
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
authSchema,
|
|
59
|
+
baseFields,
|
|
60
|
+
permissionsTable,
|
|
61
|
+
rolePermissionsTable,
|
|
62
|
+
rolesTable,
|
|
63
|
+
tokensTable,
|
|
64
|
+
usersTable
|
|
65
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "najm-auth",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Authentication and authorization library for najm framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"bun": "./src/index.ts",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./pg": {
|
|
19
|
+
"bun": "./src/schema/pg.ts",
|
|
20
|
+
"types": "./dist/schema/pg.d.ts",
|
|
21
|
+
"import": "./dist/schema/pg.js",
|
|
22
|
+
"default": "./dist/schema/pg.js"
|
|
23
|
+
},
|
|
24
|
+
"./sqlite": {
|
|
25
|
+
"bun": "./src/schema/sqlite.ts",
|
|
26
|
+
"types": "./dist/schema/sqlite.d.ts",
|
|
27
|
+
"import": "./dist/schema/sqlite.js",
|
|
28
|
+
"default": "./dist/schema/sqlite.js"
|
|
29
|
+
},
|
|
30
|
+
"./mysql": {
|
|
31
|
+
"bun": "./src/schema/mysql.ts",
|
|
32
|
+
"types": "./dist/schema/mysql.d.ts",
|
|
33
|
+
"import": "./dist/schema/mysql.js",
|
|
34
|
+
"default": "./dist/schema/mysql.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"test": "bun test",
|
|
40
|
+
"test:watch": "bun test --watch",
|
|
41
|
+
"start": "bun --watch src/main.ts",
|
|
42
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"authentication",
|
|
46
|
+
"authorization",
|
|
47
|
+
"jwt",
|
|
48
|
+
"oauth",
|
|
49
|
+
"session",
|
|
50
|
+
"decorators",
|
|
51
|
+
"typescript"
|
|
52
|
+
],
|
|
53
|
+
"author": "",
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/bcryptjs": "^3.0.0",
|
|
57
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
58
|
+
"@types/node": "^25.0.2",
|
|
59
|
+
"drizzle-kit": "^0.31.8",
|
|
60
|
+
"drizzle-orm": "^0.45.1",
|
|
61
|
+
"tsup": "^8.5.1",
|
|
62
|
+
"typescript": "^5.9.3"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"najm-cookies": "^1.1.1",
|
|
66
|
+
"najm-core": "^1.1.1",
|
|
67
|
+
"najm-database": "^1.1.1",
|
|
68
|
+
"najm-guard": "^1.1.1",
|
|
69
|
+
"najm-i18n": "^1.1.1",
|
|
70
|
+
"najm-cache": "^1.1.1",
|
|
71
|
+
"najm-email": "^1.1.1",
|
|
72
|
+
"najm-rate": "^1.1.1",
|
|
73
|
+
"najm-validation": "^1.1.1",
|
|
74
|
+
"bcryptjs": "^3.0.3",
|
|
75
|
+
"hono": "^4.0.0",
|
|
76
|
+
"jsonwebtoken": "^9.0.3",
|
|
77
|
+
"jwt-decode": "^4.0.0",
|
|
78
|
+
"lodash.isempty": "^4.4.0",
|
|
79
|
+
"nanoid": "^5.1.6",
|
|
80
|
+
"pino": "^10.1.0",
|
|
81
|
+
"postgres": "^3.4.7",
|
|
82
|
+
"reflect-metadata": "^0.2.2",
|
|
83
|
+
"timestring": "^7.0.0",
|
|
84
|
+
"zod": "^4.2.1"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"drizzle-orm": "^0.45.1",
|
|
88
|
+
"hono": "^4.0.0"
|
|
89
|
+
}
|
|
90
|
+
}
|