@dbsc-toolkit/better-auth 0.1.0

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/schema.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Better Auth schema extension for dbsc-toolkit.
3
+ *
4
+ * Defines two tables:
5
+ * dbscSession — tracks binding state (tier, lastRefreshAt) per session
6
+ * dbscBoundKey — stores the JWK for native (TPM) and bound (polyfill) keys
7
+ *
8
+ * Challenges are stored in Better Auth's built-in `verification` table
9
+ * so we get atomic consumeVerificationValue for free.
10
+ */
11
+ export const dbscSchema = {
12
+ dbscSession: {
13
+ fields: {
14
+ userId: {
15
+ type: "string",
16
+ required: true,
17
+ references: { model: "user", field: "id" },
18
+ },
19
+ tier: {
20
+ type: "string",
21
+ required: true,
22
+ // "dbsc" | "bound" | "none"
23
+ },
24
+ createdAt: {
25
+ type: "number",
26
+ required: true,
27
+ },
28
+ expiresAt: {
29
+ type: "number",
30
+ required: true,
31
+ },
32
+ lastRefreshAt: {
33
+ type: "number",
34
+ required: true,
35
+ },
36
+ },
37
+ },
38
+ dbscBoundKey: {
39
+ fields: {
40
+ sessionId: {
41
+ type: "string",
42
+ required: true,
43
+ references: { model: "dbscSession", field: "id" },
44
+ },
45
+ kind: {
46
+ type: "string",
47
+ required: true,
48
+ // "native" | "bound"
49
+ },
50
+ jwk: {
51
+ type: "string",
52
+ required: true,
53
+ // JSON-serialized JWK — stored as text, never logged
54
+ },
55
+ createdAt: {
56
+ type: "number",
57
+ required: true,
58
+ },
59
+ algorithm: {
60
+ type: "string",
61
+ required: true,
62
+ // "ES256" | "RS256"
63
+ },
64
+ },
65
+ },
66
+ };
67
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,WAAW,EAAE;QACX,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;gBACd,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE;aAC3C;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;gBACd,4BAA4B;aAC7B;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;aACf;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;aACf;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;aACf;SACF;KACF;IACD,YAAY,EAAE;QACZ,MAAM,EAAE;YACN,SAAS,EAAE;gBACT,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;gBACd,UAAU,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE;aAClD;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;gBACd,qBAAqB;aACtB;YACD,GAAG,EAAE;gBACH,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;gBACd,qDAAqD;aACtD;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;aACf;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAiB;gBACvB,QAAQ,EAAE,IAAI;gBACd,oBAAoB;aACrB;SACF;KACF;CACO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@dbsc-toolkit/better-auth",
3
+ "version": "0.1.0",
4
+ "description": "DBSC (Device Bound Session Credentials) plugin for Better Auth, powered by dbsc-toolkit.",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./express": {
15
+ "import": "./dist/express.js",
16
+ "types": "./dist/express.d.ts"
17
+ },
18
+ "./client": {
19
+ "import": "./dist/client.js",
20
+ "types": "./dist/client.d.ts"
21
+ },
22
+ "./internal": {
23
+ "import": "./dist/internal.js",
24
+ "types": "./dist/internal.d.ts"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "peerDependencies": {
33
+ "better-auth": ">=1.0.0",
34
+ "dbsc-toolkit": ">=2.9.0",
35
+ "express": ">=5.0.0"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "express": {
39
+ "optional": true
40
+ }
41
+ },
42
+ "devDependencies": {
43
+ "@types/express": "^5.0.6",
44
+ "better-auth": "^1.2.0",
45
+ "express": "^5.2.1",
46
+ "rimraf": "^6.0.0",
47
+ "typescript": "^6.0.0",
48
+ "dbsc-toolkit": "2.9.8"
49
+ },
50
+ "keywords": [
51
+ "dbsc",
52
+ "device-bound-session-credentials",
53
+ "better-auth",
54
+ "session",
55
+ "security",
56
+ "tpm",
57
+ "cookies"
58
+ ],
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "https://github.com/SulimanAbdulrazzaq/dbsc-toolkit.git",
62
+ "directory": "packages/better-auth"
63
+ },
64
+ "homepage": "https://github.com/SulimanAbdulrazzaq/dbsc-toolkit/tree/main/packages/better-auth#readme",
65
+ "publishConfig": {
66
+ "access": "public"
67
+ },
68
+ "scripts": {
69
+ "build": "tsc",
70
+ "dev": "tsc --watch",
71
+ "clean": "rimraf dist"
72
+ }
73
+ }