@drmhse/authos-node 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.
@@ -0,0 +1,98 @@
1
+ import { JwtClaims } from '@drmhse/sso-sdk';
2
+
3
+ /**
4
+ * Configuration options for the AuthOS Node.js adapter
5
+ */
6
+ interface AuthOSNodeOptions {
7
+ /**
8
+ * Base URL of the AuthOS API service
9
+ */
10
+ baseURL: string;
11
+ /**
12
+ * Cache TTL for JWKS in milliseconds. Default: 1 hour (3600000ms)
13
+ */
14
+ jwksCacheTTL?: number;
15
+ }
16
+ /**
17
+ * JSON Web Key structure
18
+ */
19
+ interface JWK {
20
+ kty: string;
21
+ kid: string;
22
+ use?: string;
23
+ alg?: string;
24
+ n?: string;
25
+ e?: string;
26
+ }
27
+ /**
28
+ * JSON Web Key Set structure
29
+ */
30
+ interface JWKS {
31
+ keys: JWK[];
32
+ }
33
+ /**
34
+ * Verified token result
35
+ */
36
+ interface VerifiedToken {
37
+ /**
38
+ * The decoded JWT claims
39
+ */
40
+ claims: JwtClaims;
41
+ /**
42
+ * The raw token string
43
+ */
44
+ token: string;
45
+ }
46
+ /**
47
+ * Express request with auth context attached
48
+ */
49
+ interface AuthenticatedRequest {
50
+ auth: VerifiedToken;
51
+ }
52
+ /**
53
+ * Token verification options
54
+ */
55
+ interface VerifyTokenOptions {
56
+ /**
57
+ * Required audience (aud) claim
58
+ */
59
+ audience?: string;
60
+ /**
61
+ * Required issuer (iss) claim
62
+ */
63
+ issuer?: string;
64
+ /**
65
+ * Clock tolerance in seconds for exp/iat validation. Default: 0
66
+ */
67
+ clockTolerance?: number;
68
+ }
69
+ /**
70
+ * Webhook verification options
71
+ */
72
+ interface WebhookVerifyOptions {
73
+ /**
74
+ * Tolerance window in milliseconds for timestamp validation. Default: 5 minutes (300000ms)
75
+ */
76
+ tolerance?: number;
77
+ }
78
+ /**
79
+ * Express middleware options for requireAuth
80
+ */
81
+ interface RequireAuthOptions extends VerifyTokenOptions {
82
+ /**
83
+ * Custom function to extract token from request.
84
+ * Default: extracts from Authorization: Bearer header
85
+ */
86
+ getToken?: (req: unknown) => string | null;
87
+ }
88
+ /**
89
+ * Express middleware options for requirePermission
90
+ */
91
+ interface RequirePermissionOptions {
92
+ /**
93
+ * Custom 403 error message
94
+ */
95
+ message?: string;
96
+ }
97
+
98
+ export type { AuthOSNodeOptions as A, JWK as J, RequireAuthOptions as R, VerifyTokenOptions as V, WebhookVerifyOptions as W, VerifiedToken as a, JWKS as b, AuthenticatedRequest as c, RequirePermissionOptions as d };
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@drmhse/authos-node",
3
+ "version": "0.1.0",
4
+ "description": "Node.js server adapter for AuthOS authentication - Express middleware and token verification",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "./express": {
20
+ "import": {
21
+ "types": "./dist/express.d.mts",
22
+ "default": "./dist/express.mjs"
23
+ },
24
+ "require": {
25
+ "types": "./dist/express.d.ts",
26
+ "default": "./dist/express.js"
27
+ }
28
+ }
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsup",
35
+ "dev": "tsup --watch",
36
+ "typecheck": "tsc --noEmit",
37
+ "lint": "eslint src --ext .ts",
38
+ "prepublishOnly": "npm run build"
39
+ },
40
+ "keywords": [
41
+ "authos",
42
+ "auth",
43
+ "authentication",
44
+ "node",
45
+ "express",
46
+ "middleware",
47
+ "jwt",
48
+ "jwks"
49
+ ],
50
+ "author": "DRM HSE <info@drmhse.com>",
51
+ "license": "MIT",
52
+ "peerDependencies": {
53
+ "express": ">=4.0.0"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "express": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "dependencies": {
61
+ "@drmhse/sso-sdk": "^0.3.3"
62
+ },
63
+ "devDependencies": {
64
+ "@types/express": "^5.0.0",
65
+ "@types/node": "^22.10.2",
66
+ "express": "^4.21.2",
67
+ "tsup": "^8.3.5",
68
+ "typescript": "^5.7.2"
69
+ },
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "https://github.com/drmhse/sso.git",
73
+ "directory": "packages/authos-node"
74
+ },
75
+ "publishConfig": {
76
+ "access": "public"
77
+ },
78
+ "engines": {
79
+ "node": ">=18.0.0"
80
+ }
81
+ }