trustline 0.0.1 → 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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -0
  3. package/dist/adapters/mysql/index.cjs +199 -0
  4. package/dist/adapters/mysql/index.cjs.map +1 -0
  5. package/dist/adapters/mysql/index.d.cts +6 -0
  6. package/dist/adapters/mysql/index.d.ts +6 -0
  7. package/dist/adapters/mysql/index.js +21 -0
  8. package/dist/adapters/mysql/index.js.map +1 -0
  9. package/dist/adapters/postgres/index.cjs +199 -0
  10. package/dist/adapters/postgres/index.cjs.map +1 -0
  11. package/dist/adapters/postgres/index.d.cts +6 -0
  12. package/dist/adapters/postgres/index.d.ts +6 -0
  13. package/dist/adapters/postgres/index.js +21 -0
  14. package/dist/adapters/postgres/index.js.map +1 -0
  15. package/dist/adapters/sqlite/index.cjs +216 -0
  16. package/dist/adapters/sqlite/index.cjs.map +1 -0
  17. package/dist/adapters/sqlite/index.d.cts +6 -0
  18. package/dist/adapters/sqlite/index.d.ts +6 -0
  19. package/dist/adapters/sqlite/index.js +28 -0
  20. package/dist/adapters/sqlite/index.js.map +1 -0
  21. package/dist/chunk-CTPFKR4O.js +157 -0
  22. package/dist/chunk-CTPFKR4O.js.map +1 -0
  23. package/dist/chunk-GF3NKEEK.js +18 -0
  24. package/dist/chunk-GF3NKEEK.js.map +1 -0
  25. package/dist/client/index.cjs +141 -0
  26. package/dist/client/index.cjs.map +1 -0
  27. package/dist/client/index.d.cts +18 -0
  28. package/dist/client/index.d.ts +18 -0
  29. package/dist/client/index.js +104 -0
  30. package/dist/client/index.js.map +1 -0
  31. package/dist/frameworks/express/index.cjs +121 -0
  32. package/dist/frameworks/express/index.cjs.map +1 -0
  33. package/dist/frameworks/express/index.d.cts +18 -0
  34. package/dist/frameworks/express/index.d.ts +18 -0
  35. package/dist/frameworks/express/index.js +83 -0
  36. package/dist/frameworks/express/index.js.map +1 -0
  37. package/dist/frameworks/fastify/index.cjs +158 -0
  38. package/dist/frameworks/fastify/index.cjs.map +1 -0
  39. package/dist/frameworks/fastify/index.d.cts +25 -0
  40. package/dist/frameworks/fastify/index.d.ts +25 -0
  41. package/dist/frameworks/fastify/index.js +120 -0
  42. package/dist/frameworks/fastify/index.js.map +1 -0
  43. package/dist/frameworks/hono/index.cjs +117 -0
  44. package/dist/frameworks/hono/index.cjs.map +1 -0
  45. package/dist/frameworks/hono/index.d.cts +17 -0
  46. package/dist/frameworks/hono/index.d.ts +17 -0
  47. package/dist/frameworks/hono/index.js +79 -0
  48. package/dist/frameworks/hono/index.js.map +1 -0
  49. package/dist/index-Dc4GFume.d.ts +34 -0
  50. package/dist/index-DqkKZOlH.d.cts +34 -0
  51. package/dist/index.cjs +571 -0
  52. package/dist/index.cjs.map +1 -0
  53. package/dist/index.d.cts +14 -0
  54. package/dist/index.d.ts +14 -0
  55. package/dist/index.js +537 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/interface-BzT_DC3u.d.cts +38 -0
  58. package/dist/interface-BzT_DC3u.d.ts +38 -0
  59. package/dist/token-BtfYGd9K.d.cts +33 -0
  60. package/dist/token-BtfYGd9K.d.ts +33 -0
  61. package/package.json +125 -3
  62. package/index.js +0 -1
@@ -0,0 +1,33 @@
1
+ import { JWTVerifyGetKey, JWTPayload } from 'jose';
2
+
3
+ interface JwksCacheOptions {
4
+ ttlMs?: number;
5
+ }
6
+ declare class JwksCache {
7
+ private readonly ttlMs;
8
+ private readonly entries;
9
+ private readonly inflight;
10
+ constructor(options?: JwksCacheOptions);
11
+ get(url: string, forceRefresh?: boolean): Promise<JWTVerifyGetKey>;
12
+ clear(url?: string): void;
13
+ private fetchAndCache;
14
+ }
15
+
16
+ interface GuardOptions {
17
+ issuer: string;
18
+ jwksUrl?: string;
19
+ audience?: string | string[];
20
+ scopes?: string[];
21
+ env?: string;
22
+ clockTolerance?: number;
23
+ jwksCache?: JwksCache;
24
+ }
25
+ interface ServiceIdentity {
26
+ clientId: string;
27
+ name: string | null;
28
+ scopes: string[];
29
+ env: string | null;
30
+ raw: JWTPayload & Record<string, unknown>;
31
+ }
32
+
33
+ export type { GuardOptions as G, ServiceIdentity as S };
@@ -0,0 +1,33 @@
1
+ import { JWTVerifyGetKey, JWTPayload } from 'jose';
2
+
3
+ interface JwksCacheOptions {
4
+ ttlMs?: number;
5
+ }
6
+ declare class JwksCache {
7
+ private readonly ttlMs;
8
+ private readonly entries;
9
+ private readonly inflight;
10
+ constructor(options?: JwksCacheOptions);
11
+ get(url: string, forceRefresh?: boolean): Promise<JWTVerifyGetKey>;
12
+ clear(url?: string): void;
13
+ private fetchAndCache;
14
+ }
15
+
16
+ interface GuardOptions {
17
+ issuer: string;
18
+ jwksUrl?: string;
19
+ audience?: string | string[];
20
+ scopes?: string[];
21
+ env?: string;
22
+ clockTolerance?: number;
23
+ jwksCache?: JwksCache;
24
+ }
25
+ interface ServiceIdentity {
26
+ clientId: string;
27
+ name: string | null;
28
+ scopes: string[];
29
+ env: string | null;
30
+ raw: JWTPayload & Record<string, unknown>;
31
+ }
32
+
33
+ export type { GuardOptions as G, ServiceIdentity as S };
package/package.json CHANGED
@@ -1,11 +1,133 @@
1
1
  {
2
2
  "name": "trustline",
3
- "version": "0.0.1",
4
- "description": "Service identity and authorization for Node.js",
5
- "main": "index.js",
3
+ "version": "0.1.0",
4
+ "description": "Service identity and authorization for modern JavaScript runtimes",
6
5
  "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "publishConfig": {
14
+ "access": "public",
15
+ "provenance": true
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ },
23
+ "./adapters/mysql": {
24
+ "types": "./dist/adapters/mysql/index.d.ts",
25
+ "import": "./dist/adapters/mysql/index.js",
26
+ "require": "./dist/adapters/mysql/index.cjs"
27
+ },
28
+ "./adapters/postgres": {
29
+ "types": "./dist/adapters/postgres/index.d.ts",
30
+ "import": "./dist/adapters/postgres/index.js",
31
+ "require": "./dist/adapters/postgres/index.cjs"
32
+ },
33
+ "./adapters/sqlite": {
34
+ "types": "./dist/adapters/sqlite/index.d.ts",
35
+ "import": "./dist/adapters/sqlite/index.js",
36
+ "require": "./dist/adapters/sqlite/index.cjs"
37
+ },
38
+ "./client": {
39
+ "types": "./dist/client/index.d.ts",
40
+ "import": "./dist/client/index.js",
41
+ "require": "./dist/client/index.cjs"
42
+ },
43
+ "./frameworks/express": {
44
+ "types": "./dist/frameworks/express/index.d.ts",
45
+ "import": "./dist/frameworks/express/index.js",
46
+ "require": "./dist/frameworks/express/index.cjs"
47
+ },
48
+ "./frameworks/fastify": {
49
+ "types": "./dist/frameworks/fastify/index.d.ts",
50
+ "import": "./dist/frameworks/fastify/index.js",
51
+ "require": "./dist/frameworks/fastify/index.cjs"
52
+ },
53
+ "./frameworks/hono": {
54
+ "types": "./dist/frameworks/hono/index.d.ts",
55
+ "import": "./dist/frameworks/hono/index.js",
56
+ "require": "./dist/frameworks/hono/index.cjs"
57
+ }
58
+ },
59
+ "sideEffects": false,
60
+ "scripts": {
61
+ "build": "tsup",
62
+ "check": "biome check .",
63
+ "changeset": "changeset",
64
+ "format": "biome check --write .",
65
+ "lint": "biome lint .",
66
+ "release": "bun run release:check && changeset publish",
67
+ "release:check": "bun run build && bun run test && bun run typecheck",
68
+ "release:version": "changeset version",
69
+ "test": "bunx vitest run",
70
+ "typecheck": "tsc --noEmit"
71
+ },
7
72
  "repository": {
8
73
  "type": "git",
9
74
  "url": "https://github.com/barddoo/trustline"
75
+ },
76
+ "peerDependencies": {
77
+ "better-sqlite3": "^12.8.0",
78
+ "express": "^4.21.0 || ^5.0.0",
79
+ "fastify": "^5.0.0",
80
+ "hono": "^4.0.0",
81
+ "kysely": "^0.28.14",
82
+ "mysql2": "^3.20.0",
83
+ "pg": "^8.20.0"
84
+ },
85
+ "peerDependenciesMeta": {
86
+ "better-sqlite3": {
87
+ "optional": true
88
+ },
89
+ "express": {
90
+ "optional": true
91
+ },
92
+ "fastify": {
93
+ "optional": true
94
+ },
95
+ "hono": {
96
+ "optional": true
97
+ },
98
+ "kysely": {
99
+ "optional": true
100
+ },
101
+ "mysql2": {
102
+ "optional": true
103
+ },
104
+ "pg": {
105
+ "optional": true
106
+ }
107
+ },
108
+ "dependencies": {
109
+ "bcryptjs": "^3.0.3",
110
+ "jose": "^6.1.0",
111
+ "uuid": "^13.0.0"
112
+ },
113
+ "devDependencies": {
114
+ "@biomejs/biome": "^2.4.9",
115
+ "@changesets/cli": "^2.30.0",
116
+ "@types/better-sqlite3": "^7.6.13",
117
+ "@types/express": "^5.0.1",
118
+ "@types/node": "^24",
119
+ "@types/pg": "^8.20.0",
120
+ "@types/supertest": "^6.0.3",
121
+ "better-sqlite3": "^12.8.0",
122
+ "express": "^5",
123
+ "fastify": "^5",
124
+ "hono": "^4",
125
+ "kysely": "^0.28.14",
126
+ "mysql2": "^3.20.0",
127
+ "pg": "^8.20.0",
128
+ "supertest": "^7.1.4",
129
+ "tsup": "^8.5.0",
130
+ "typescript": "^6",
131
+ "vitest": "^4.1.1"
10
132
  }
11
133
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- // coming soon