@kurdel/auth 0.1.0-beta.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 +253 -0
- package/lib/domain/auth-context.d.ts +8 -0
- package/lib/domain/auth-context.js +2 -0
- package/lib/domain/auth-context.js.map +1 -0
- package/lib/domain/auth-event-sink-provider.d.ts +7 -0
- package/lib/domain/auth-event-sink-provider.js +2 -0
- package/lib/domain/auth-event-sink-provider.js.map +1 -0
- package/lib/domain/auth-event.d.ts +30 -0
- package/lib/domain/auth-event.js +5 -0
- package/lib/domain/auth-event.js.map +1 -0
- package/lib/domain/auth-strategy-provider.d.ts +9 -0
- package/lib/domain/auth-strategy-provider.js +2 -0
- package/lib/domain/auth-strategy-provider.js.map +1 -0
- package/lib/domain/auth-strategy.d.ts +17 -0
- package/lib/domain/auth-strategy.js +2 -0
- package/lib/domain/auth-strategy.js.map +1 -0
- package/lib/domain/authorization-policy-provider.d.ts +9 -0
- package/lib/domain/authorization-policy-provider.js +2 -0
- package/lib/domain/authorization-policy-provider.js.map +1 -0
- package/lib/domain/authorization-policy.d.ts +6 -0
- package/lib/domain/authorization-policy.js +2 -0
- package/lib/domain/authorization-policy.js.map +1 -0
- package/lib/domain/index.d.ts +7 -0
- package/lib/domain/index.js +8 -0
- package/lib/domain/index.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/infra/in-memory/in-memory-api-key-repository.d.ts +7 -0
- package/lib/infra/in-memory/in-memory-api-key-repository.js +10 -0
- package/lib/infra/in-memory/in-memory-api-key-repository.js.map +1 -0
- package/lib/infra/in-memory/in-memory-auth-user-repository.d.ts +8 -0
- package/lib/infra/in-memory/in-memory-auth-user-repository.js +10 -0
- package/lib/infra/in-memory/in-memory-auth-user-repository.js.map +1 -0
- package/lib/infra/in-memory/in-memory-jwt-repository.d.ts +7 -0
- package/lib/infra/in-memory/in-memory-jwt-repository.js +8 -0
- package/lib/infra/in-memory/in-memory-jwt-repository.js.map +1 -0
- package/lib/infra/in-memory/index.d.ts +3 -0
- package/lib/infra/in-memory/index.js +4 -0
- package/lib/infra/in-memory/index.js.map +1 -0
- package/lib/infra/index.d.ts +1 -0
- package/lib/infra/index.js +2 -0
- package/lib/infra/index.js.map +1 -0
- package/lib/repositories/api-key/api-key-repository.d.ts +30 -0
- package/lib/repositories/api-key/api-key-repository.js +2 -0
- package/lib/repositories/api-key/api-key-repository.js.map +1 -0
- package/lib/repositories/api-key/api-key-usage-recorder.d.ts +4 -0
- package/lib/repositories/api-key/api-key-usage-recorder.js +2 -0
- package/lib/repositories/api-key/api-key-usage-recorder.js.map +1 -0
- package/lib/repositories/api-key/index.d.ts +2 -0
- package/lib/repositories/api-key/index.js +3 -0
- package/lib/repositories/api-key/index.js.map +1 -0
- package/lib/repositories/index.d.ts +3 -0
- package/lib/repositories/index.js +4 -0
- package/lib/repositories/index.js.map +1 -0
- package/lib/repositories/jwt/index.d.ts +1 -0
- package/lib/repositories/jwt/index.js +2 -0
- package/lib/repositories/jwt/index.js.map +1 -0
- package/lib/repositories/jwt/jwt-repository.d.ts +3 -0
- package/lib/repositories/jwt/jwt-repository.js +2 -0
- package/lib/repositories/jwt/jwt-repository.js.map +1 -0
- package/lib/repositories/user/auth-user-repository.d.ts +11 -0
- package/lib/repositories/user/auth-user-repository.js +2 -0
- package/lib/repositories/user/auth-user-repository.js.map +1 -0
- package/lib/repositories/user/index.d.ts +1 -0
- package/lib/repositories/user/index.js +2 -0
- package/lib/repositories/user/index.js.map +1 -0
- package/lib/runtime/auth-module.d.ts +64 -0
- package/lib/runtime/auth-module.js +83 -0
- package/lib/runtime/auth-module.js.map +1 -0
- package/lib/runtime/auth-strategy-registry.d.ts +25 -0
- package/lib/runtime/auth-strategy-registry.js +33 -0
- package/lib/runtime/auth-strategy-registry.js.map +1 -0
- package/lib/runtime/authorization-policy-registry.d.ts +8 -0
- package/lib/runtime/authorization-policy-registry.js +16 -0
- package/lib/runtime/authorization-policy-registry.js.map +1 -0
- package/lib/runtime/create-auth-middleware.d.ts +5 -0
- package/lib/runtime/create-auth-middleware.js +89 -0
- package/lib/runtime/create-auth-middleware.js.map +1 -0
- package/lib/runtime/index.d.ts +4 -0
- package/lib/runtime/index.js +5 -0
- package/lib/runtime/index.js.map +1 -0
- package/lib/strategies/api-key/api-key-strategy.d.ts +22 -0
- package/lib/strategies/api-key/api-key-strategy.js +36 -0
- package/lib/strategies/api-key/api-key-strategy.js.map +1 -0
- package/lib/strategies/api-key/index.d.ts +1 -0
- package/lib/strategies/api-key/index.js +2 -0
- package/lib/strategies/api-key/index.js.map +1 -0
- package/lib/strategies/index.d.ts +2 -0
- package/lib/strategies/index.js +3 -0
- package/lib/strategies/index.js.map +1 -0
- package/lib/strategies/jwt/index.d.ts +2 -0
- package/lib/strategies/jwt/index.js +3 -0
- package/lib/strategies/jwt/index.js.map +1 -0
- package/lib/strategies/jwt/jwt-service.d.ts +50 -0
- package/lib/strategies/jwt/jwt-service.js +87 -0
- package/lib/strategies/jwt/jwt-service.js.map +1 -0
- package/lib/strategies/jwt/jwt-strategy.d.ts +27 -0
- package/lib/strategies/jwt/jwt-strategy.js +45 -0
- package/lib/strategies/jwt/jwt-strategy.js.map +1 -0
- package/lib/tokens.d.ts +11 -0
- package/lib/tokens.js +13 -0
- package/lib/tokens.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* ## JwtService
|
|
4
|
+
*
|
|
5
|
+
* Lightweight JWT (HS256) implementation with zero dependencies.
|
|
6
|
+
* Provides signing, decoding and verification.
|
|
7
|
+
*/
|
|
8
|
+
export class JwtService {
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
this.opts = opts;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Signs a new JWT token with the configured HS256 secret.
|
|
14
|
+
*/
|
|
15
|
+
sign(payload) {
|
|
16
|
+
const header = { alg: 'HS256', typ: 'JWT' };
|
|
17
|
+
const iat = Math.floor(Date.now() / 1000);
|
|
18
|
+
const exp = this.opts.expiresIn ? iat + this.opts.expiresIn : undefined;
|
|
19
|
+
const fullPayload = {
|
|
20
|
+
...payload,
|
|
21
|
+
iat,
|
|
22
|
+
exp,
|
|
23
|
+
iss: this.opts.issuer,
|
|
24
|
+
aud: this.opts.audience,
|
|
25
|
+
};
|
|
26
|
+
const encodedHeader = this.b64(JSON.stringify(header));
|
|
27
|
+
const encodedPayload = this.b64(JSON.stringify(fullPayload));
|
|
28
|
+
const signature = this.signSegment(`${encodedHeader}.${encodedPayload}`);
|
|
29
|
+
return `${encodedHeader}.${encodedPayload}.${signature}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Decodes the payload **without validating the signature**.
|
|
33
|
+
* Useful for debugging or optional preview.
|
|
34
|
+
*/
|
|
35
|
+
decode(token) {
|
|
36
|
+
const parts = token.split('.');
|
|
37
|
+
if (parts.length !== 3)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(Buffer.from(parts[1], 'base64url').toString());
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Verifies signature + exp/nbf/iss/aud constraints.
|
|
48
|
+
* Returns the decoded payload or throws an Error.
|
|
49
|
+
*/
|
|
50
|
+
verify(token) {
|
|
51
|
+
const parts = token.split('.');
|
|
52
|
+
if (parts.length !== 3) {
|
|
53
|
+
throw new Error('Invalid token format');
|
|
54
|
+
}
|
|
55
|
+
const [headerB64, payloadB64, signature] = parts;
|
|
56
|
+
const computedSign = this.signSegment(`${headerB64}.${payloadB64}`);
|
|
57
|
+
if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(computedSign))) {
|
|
58
|
+
throw new Error('Invalid token signature');
|
|
59
|
+
}
|
|
60
|
+
const payload = JSON.parse(Buffer.from(payloadB64, 'base64url').toString());
|
|
61
|
+
const now = Math.floor(Date.now() / 1000);
|
|
62
|
+
if (payload.exp && now >= payload.exp) {
|
|
63
|
+
throw new Error('Token expired');
|
|
64
|
+
}
|
|
65
|
+
if (payload.nbf && now < payload.nbf) {
|
|
66
|
+
throw new Error('Token not yet valid');
|
|
67
|
+
}
|
|
68
|
+
if (this.opts.issuer && payload.iss !== this.opts.issuer) {
|
|
69
|
+
throw new Error('Invalid issuer');
|
|
70
|
+
}
|
|
71
|
+
if (this.opts.audience && payload.aud !== this.opts.audience) {
|
|
72
|
+
throw new Error('Invalid audience');
|
|
73
|
+
}
|
|
74
|
+
return payload;
|
|
75
|
+
}
|
|
76
|
+
// ─────────────────────────────────────────────
|
|
77
|
+
b64(str) {
|
|
78
|
+
return Buffer.from(str).toString('base64url');
|
|
79
|
+
}
|
|
80
|
+
signSegment(data) {
|
|
81
|
+
return crypto
|
|
82
|
+
.createHmac('sha256', this.opts.secret)
|
|
83
|
+
.update(data)
|
|
84
|
+
.digest('base64url');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=jwt-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-service.js","sourceRoot":"","sources":["../../../src/strategies/jwt/jwt-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAqCjC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACrB,YAA6B,IAAuB;QAAvB,SAAI,GAAJ,IAAI,CAAmB;IAAG,CAAC;IAExD;;OAEG;IACH,IAAI,CAAC,OAAwC;QAC3C,MAAM,MAAM,GAAc,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAEvD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1C,M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AAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,gDAAgD;IAExC,GAAG,CAAC,GAAW;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAEO,WAAW,CAAC,IAAY;QAC9B,OAAO,MAAM;aACV,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;aACtC,MAAM,CAAC,IAAI,CAAC;aACZ,MAAM,CAAC,WAAW,CAAC,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HttpRequest } from '@kurdel/common';
|
|
2
|
+
import type { AuthenticationResult, AuthStrategy } from '../../domain/index.js';
|
|
3
|
+
import type { AuthUserRepository } from '../../repositories/index.js';
|
|
4
|
+
import type { JwtService } from '../../strategies/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* ## JwtStrategyOptions
|
|
7
|
+
*
|
|
8
|
+
* Configures how the strategy extracts and validates JWT tokens.
|
|
9
|
+
*/
|
|
10
|
+
export interface JwtStrategyOptions {
|
|
11
|
+
header?: string;
|
|
12
|
+
prefix?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ## JwtStrategy
|
|
16
|
+
*
|
|
17
|
+
* Authentication strategy that validates a JWT token from
|
|
18
|
+
* the HttpRequest and returns an AuthUser.
|
|
19
|
+
*/
|
|
20
|
+
export declare class JwtStrategy implements AuthStrategy {
|
|
21
|
+
private readonly service;
|
|
22
|
+
private readonly users;
|
|
23
|
+
private readonly header;
|
|
24
|
+
private readonly prefix;
|
|
25
|
+
constructor(service: JwtService, users: AuthUserRepository, opts?: JwtStrategyOptions);
|
|
26
|
+
authenticate(req: HttpRequest): Promise<AuthenticationResult | null>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ## JwtStrategy
|
|
3
|
+
*
|
|
4
|
+
* Authentication strategy that validates a JWT token from
|
|
5
|
+
* the HttpRequest and returns an AuthUser.
|
|
6
|
+
*/
|
|
7
|
+
export class JwtStrategy {
|
|
8
|
+
constructor(service, users, opts = {}) {
|
|
9
|
+
this.service = service;
|
|
10
|
+
this.users = users;
|
|
11
|
+
this.header = (opts.header ?? 'authorization').toLowerCase();
|
|
12
|
+
this.prefix = (opts.prefix ?? 'Bearer').toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
async authenticate(req) {
|
|
15
|
+
const raw = req.headers?.[this.header];
|
|
16
|
+
if (!raw)
|
|
17
|
+
return null;
|
|
18
|
+
const str = Array.isArray(raw) ? raw[0] : raw;
|
|
19
|
+
const value = typeof str === 'string' ? str.trim() : '';
|
|
20
|
+
if (!value.toLowerCase().startsWith(this.prefix.toLowerCase())) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const token = value.slice(this.prefix.length).trim();
|
|
24
|
+
try {
|
|
25
|
+
const payload = this.service.verify(token);
|
|
26
|
+
if (!payload.sub)
|
|
27
|
+
return null;
|
|
28
|
+
const user = await this.users.findById(payload.sub);
|
|
29
|
+
if (!user)
|
|
30
|
+
return null;
|
|
31
|
+
return {
|
|
32
|
+
user,
|
|
33
|
+
credential: {
|
|
34
|
+
type: 'jwt',
|
|
35
|
+
...(typeof payload.jti === 'string' ? { id: payload.jti } : {}),
|
|
36
|
+
},
|
|
37
|
+
claims: payload,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=jwt-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-strategy.js","sourceRoot":"","sources":["../../../src/strategies/jwt/jwt-strategy.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,OAAO,WAA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C,OAAO,CAAC,GAAG,CAAC,CAAC;YACpD,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YAEvB,OAAO;gBACL,IAAI;gBACJ,UAAU,EAAE;oBACV,IAAI,EAAE,KAAK;oBACX,GAAG,CAAC,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAChE;gBACD,MAAM,EAAE,OAAO;aAChB,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/lib/tokens.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const AUTH_TOKENS: {
|
|
2
|
+
StrategyRegistry: symbol;
|
|
3
|
+
PolicyRegistry: symbol;
|
|
4
|
+
EventSink: symbol;
|
|
5
|
+
UserRepository: symbol;
|
|
6
|
+
/** @deprecated Use UserRepository. */
|
|
7
|
+
JwtRepository: symbol;
|
|
8
|
+
ApiKeyRepository: symbol;
|
|
9
|
+
ApiKeyUsageRecorder: symbol;
|
|
10
|
+
JwtService: symbol;
|
|
11
|
+
};
|
package/lib/tokens.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const UserRepository = Symbol('AuthUserRepository');
|
|
2
|
+
export const AUTH_TOKENS = {
|
|
3
|
+
StrategyRegistry: Symbol('AuthStrategyRegistry'),
|
|
4
|
+
PolicyRegistry: Symbol('AuthorizationPolicyRegistry'),
|
|
5
|
+
EventSink: Symbol('AuthEventSink'),
|
|
6
|
+
UserRepository,
|
|
7
|
+
/** @deprecated Use UserRepository. */
|
|
8
|
+
JwtRepository: UserRepository,
|
|
9
|
+
ApiKeyRepository: Symbol('ApiKeyRepository'),
|
|
10
|
+
ApiKeyUsageRecorder: Symbol('ApiKeyUsageRecorder'),
|
|
11
|
+
JwtService: Symbol('JwtService'),
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,gBAAgB,EAAE,MAAM,CAAC,sBAAsB,CAAC;IAChD,cAAc,EAAE,MAAM,CAAC,6BAA6B,CAAC;IACrD,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC;IAClC,cAAc;IACd,sCAAsC;IACtC,aAAa,EAAE,cAAc;IAC7B,gBAAgB,EAAE,MAAM,CAAC,kBAAkB,CAAC;IAC5C,mBAAmB,EAAE,MAAM,CAAC,qBAAqB,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC;CACjC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kurdel/auth",
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
|
+
"description": "Authentication and authorization primitives for Kurdel applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./lib/index.js",
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"lib"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prepack": "npm run build",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"coverage": "vitest run --coverage",
|
|
19
|
+
"clean": "rimraf lib ../../.cache/tsconfig.auth.build.tsbuildinfo",
|
|
20
|
+
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
21
|
+
"build:force": "npm run clean && tsc -p tsconfig.build.json --force && tsc-alias -p tsconfig.build.json"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"kurdel",
|
|
25
|
+
"authentication",
|
|
26
|
+
"authorization",
|
|
27
|
+
"framework"
|
|
28
|
+
],
|
|
29
|
+
"author": "Andrii Sorokin",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/ignorantic/kurdel.git",
|
|
37
|
+
"directory": "packages/auth"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/ignorantic/kurdel/tree/main/packages/auth#readme",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/ignorantic/kurdel/issues"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"tag": "beta"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"rimraf": "^6.0.1",
|
|
49
|
+
"tsc-alias": "^1.8.16"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@kurdel/common": "0.1.0-beta.1",
|
|
53
|
+
"@kurdel/core": "0.1.0-beta.1",
|
|
54
|
+
"@kurdel/ioc": "0.1.0-beta.1"
|
|
55
|
+
}
|
|
56
|
+
}
|