@rapidraptor/auth-server 0.2.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/config.d.ts +33 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +44 -0
- package/dist/config.js.map +1 -0
- package/dist/firebase/admin.d.ts +18 -0
- package/dist/firebase/admin.d.ts.map +1 -0
- package/dist/firebase/admin.js +96 -0
- package/dist/firebase/admin.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/authMiddleware.d.ts +9 -0
- package/dist/middleware/authMiddleware.d.ts.map +1 -0
- package/dist/middleware/authMiddleware.js +241 -0
- package/dist/middleware/authMiddleware.js.map +1 -0
- package/dist/middleware/authMiddleware.test.d.ts +2 -0
- package/dist/middleware/authMiddleware.test.d.ts.map +1 -0
- package/dist/middleware/authMiddleware.test.js +691 -0
- package/dist/middleware/authMiddleware.test.js.map +1 -0
- package/dist/middleware/logoutHandler.d.ts +9 -0
- package/dist/middleware/logoutHandler.d.ts.map +1 -0
- package/dist/middleware/logoutHandler.js +54 -0
- package/dist/middleware/logoutHandler.js.map +1 -0
- package/dist/middleware/logoutHandler.test.d.ts +2 -0
- package/dist/middleware/logoutHandler.test.d.ts.map +1 -0
- package/dist/middleware/logoutHandler.test.js +103 -0
- package/dist/middleware/logoutHandler.test.js.map +1 -0
- package/dist/session/firestoreSync.d.ts +37 -0
- package/dist/session/firestoreSync.d.ts.map +1 -0
- package/dist/session/firestoreSync.js +88 -0
- package/dist/session/firestoreSync.js.map +1 -0
- package/dist/session/firestoreSync.test.d.ts +2 -0
- package/dist/session/firestoreSync.test.d.ts.map +1 -0
- package/dist/session/firestoreSync.test.js +142 -0
- package/dist/session/firestoreSync.test.js.map +1 -0
- package/dist/session/sessionCache.d.ts +37 -0
- package/dist/session/sessionCache.d.ts.map +1 -0
- package/dist/session/sessionCache.js +63 -0
- package/dist/session/sessionCache.js.map +1 -0
- package/dist/session/sessionCache.test.d.ts +2 -0
- package/dist/session/sessionCache.test.d.ts.map +1 -0
- package/dist/session/sessionCache.test.js +117 -0
- package/dist/session/sessionCache.test.js.map +1 -0
- package/dist/session/sessionService.d.ts +97 -0
- package/dist/session/sessionService.d.ts.map +1 -0
- package/dist/session/sessionService.js +311 -0
- package/dist/session/sessionService.js.map +1 -0
- package/dist/session/sessionService.test.d.ts +2 -0
- package/dist/session/sessionService.test.d.ts.map +1 -0
- package/dist/session/sessionService.test.js +426 -0
- package/dist/session/sessionService.test.js.map +1 -0
- package/dist/session/types.d.ts +7 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +2 -0
- package/dist/session/types.js.map +1 -0
- package/dist/tokenVerifier/errors.d.ts +23 -0
- package/dist/tokenVerifier/errors.d.ts.map +1 -0
- package/dist/tokenVerifier/errors.js +34 -0
- package/dist/tokenVerifier/errors.js.map +1 -0
- package/dist/tokenVerifier/joseTokenVerifier.d.ts +24 -0
- package/dist/tokenVerifier/joseTokenVerifier.d.ts.map +1 -0
- package/dist/tokenVerifier/joseTokenVerifier.js +157 -0
- package/dist/tokenVerifier/joseTokenVerifier.js.map +1 -0
- package/dist/tokenVerifier/types.d.ts +41 -0
- package/dist/tokenVerifier/types.d.ts.map +1 -0
- package/dist/tokenVerifier/types.js +2 -0
- package/dist/tokenVerifier/types.js.map +1 -0
- package/dist/types/middleware.d.ts +33 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/middleware.js +2 -0
- package/dist/types/middleware.js.map +1 -0
- package/dist/types/session.d.ts +7 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +2 -0
- package/dist/types/session.js.map +1 -0
- package/package.json +36 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Firestore } from 'firebase-admin/firestore';
|
|
2
|
+
import { SessionService } from './session/sessionService.js';
|
|
3
|
+
import type { SessionServiceConfig } from '@rapidraptor/auth-shared';
|
|
4
|
+
/**
|
|
5
|
+
* Create a configured SessionService instance
|
|
6
|
+
* This helper function makes it easy to set up session management with environment-specific configuration
|
|
7
|
+
*
|
|
8
|
+
* @param firestore - Firestore instance
|
|
9
|
+
* @param config - Optional configuration to override defaults
|
|
10
|
+
* @returns Configured SessionService instance
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Use defaults
|
|
14
|
+
* const sessionService = createSessionService(firestore);
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Override for development environment
|
|
18
|
+
* const sessionService = createSessionService(firestore, {
|
|
19
|
+
* inactivityTimeoutMs: 1 * 60 * 60 * 1000, // 1 hour for dev
|
|
20
|
+
* firestoreWriteThrottleMs: 1 * 60 * 1000, // 1 minute for dev
|
|
21
|
+
* firestoreCollectionName: 'dev_user_sessions'
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Override for production environment
|
|
26
|
+
* const sessionService = createSessionService(firestore, {
|
|
27
|
+
* inactivityTimeoutMs: 24 * 60 * 60 * 1000, // 24 hours
|
|
28
|
+
* firestoreWriteThrottleMs: 5 * 60 * 1000, // 5 minutes
|
|
29
|
+
* firestoreCollectionName: 'user_sessions'
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSessionService(firestore: Firestore, config?: Partial<SessionServiceConfig>): SessionService;
|
|
33
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACrC,cAAc,CAmBhB"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SessionCache } from './session/sessionCache.js';
|
|
2
|
+
import { FirestoreSync } from './session/firestoreSync.js';
|
|
3
|
+
import { SessionService } from './session/sessionService.js';
|
|
4
|
+
import { DEFAULTS } from '@rapidraptor/auth-shared';
|
|
5
|
+
/**
|
|
6
|
+
* Create a configured SessionService instance
|
|
7
|
+
* This helper function makes it easy to set up session management with environment-specific configuration
|
|
8
|
+
*
|
|
9
|
+
* @param firestore - Firestore instance
|
|
10
|
+
* @param config - Optional configuration to override defaults
|
|
11
|
+
* @returns Configured SessionService instance
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Use defaults
|
|
15
|
+
* const sessionService = createSessionService(firestore);
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Override for development environment
|
|
19
|
+
* const sessionService = createSessionService(firestore, {
|
|
20
|
+
* inactivityTimeoutMs: 1 * 60 * 60 * 1000, // 1 hour for dev
|
|
21
|
+
* firestoreWriteThrottleMs: 1 * 60 * 1000, // 1 minute for dev
|
|
22
|
+
* firestoreCollectionName: 'dev_user_sessions'
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Override for production environment
|
|
27
|
+
* const sessionService = createSessionService(firestore, {
|
|
28
|
+
* inactivityTimeoutMs: 24 * 60 * 60 * 1000, // 24 hours
|
|
29
|
+
* firestoreWriteThrottleMs: 5 * 60 * 1000, // 5 minutes
|
|
30
|
+
* firestoreCollectionName: 'user_sessions'
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
33
|
+
export function createSessionService(firestore, config) {
|
|
34
|
+
const inactivityTimeout = config?.inactivityTimeoutMs ?? DEFAULTS.INACTIVITY_TIMEOUT_MS;
|
|
35
|
+
const throttleMs = config?.firestoreWriteThrottleMs ?? DEFAULTS.FIRESTORE_WRITE_THROTTLE_MS;
|
|
36
|
+
const usersCollectionName = config?.firestoreCollectionName ?? DEFAULTS.FIRESTORE_SESSIONS_COLLECTION_NAME;
|
|
37
|
+
const logoutsCollectionName = config?.firestoreLogoutsCollectionName ?? DEFAULTS.FIRESTORE_LOGOUTS_COLLECTION_NAME;
|
|
38
|
+
const logoutTtlMs = config?.logoutTtlMs ?? DEFAULTS.LOGOUT_TTL_MS;
|
|
39
|
+
const cache = new SessionCache(inactivityTimeout);
|
|
40
|
+
const firestoreSync = new FirestoreSync(firestore, throttleMs, usersCollectionName);
|
|
41
|
+
const sessionService = new SessionService(cache, firestoreSync, firestore, inactivityTimeout, usersCollectionName, logoutsCollectionName, logoutTtlMs);
|
|
42
|
+
return sessionService;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAoB,EACpB,MAAsC;IAEtC,MAAM,iBAAiB,GAAO,MAAM,EAAE,mBAAmB,IAAI,QAAQ,CAAC,qBAAqB,CAAC;IAC5F,MAAM,UAAU,GAAc,MAAM,EAAE,wBAAwB,IAAI,QAAQ,CAAC,2BAA2B,CAAC;IACvG,MAAM,mBAAmB,GAAK,MAAM,EAAE,uBAAuB,IAAI,QAAQ,CAAC,kCAAkC,CAAC;IAC7G,MAAM,qBAAqB,GAAG,MAAM,EAAE,8BAA8B,IAAI,QAAQ,CAAC,iCAAiC,CAAC;IACnH,MAAM,WAAW,GAAa,MAAM,EAAE,WAAW,IAAI,QAAQ,CAAC,aAAa,CAAC;IAC5E,MAAM,KAAK,GAAmB,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAClE,MAAM,aAAa,GAAW,IAAI,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAAC;IAC5F,MAAM,cAAc,GAAU,IAAI,cAAc,CAC9C,KAAK,EACL,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,CACZ,CAAC;IAEF,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type App } from 'firebase-admin/app';
|
|
2
|
+
import { type Firestore } from 'firebase-admin/firestore';
|
|
3
|
+
/**
|
|
4
|
+
* Initialize Firebase Admin SDK
|
|
5
|
+
* Can be called multiple times safely (idempotent)
|
|
6
|
+
*/
|
|
7
|
+
export declare function initializeFirebaseAdmin(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Get Firestore instance
|
|
10
|
+
* Throws if Firebase Admin is not initialized
|
|
11
|
+
*/
|
|
12
|
+
export declare function getFirestoreInstance(): Firestore;
|
|
13
|
+
/**
|
|
14
|
+
* Get Firebase App instance
|
|
15
|
+
* Throws if Firebase Admin is not initialized
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAppInstance(): App;
|
|
18
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/firebase/admin.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAqDxE;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAwC7D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,SAAS,CAOhD;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,GAAG,CAOpC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { initializeApp, cert, getApps } from 'firebase-admin/app';
|
|
3
|
+
import { getFirestore } from 'firebase-admin/firestore';
|
|
4
|
+
let firestoreInstance = null;
|
|
5
|
+
let appInstance = null;
|
|
6
|
+
/**
|
|
7
|
+
* Get credentials from environment variables
|
|
8
|
+
*/
|
|
9
|
+
function getCredentialsFromEnv() {
|
|
10
|
+
const projectId = process.env.FIREBASE_PROJECT_ID;
|
|
11
|
+
const privateKey = process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, '\n');
|
|
12
|
+
const clientEmail = process.env.FIREBASE_CLIENT_EMAIL;
|
|
13
|
+
if (!projectId || !privateKey || !clientEmail) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return { projectId, privateKey, clientEmail };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get credentials from service account file
|
|
20
|
+
*/
|
|
21
|
+
function getCredentialsFromFile() {
|
|
22
|
+
const serviceAccountPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
23
|
+
if (!serviceAccountPath) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
// Read and parse the JSON file explicitly (safer than require)
|
|
28
|
+
const fileContents = readFileSync(serviceAccountPath, 'utf-8');
|
|
29
|
+
const serviceAccount = JSON.parse(fileContents);
|
|
30
|
+
return {
|
|
31
|
+
projectId: serviceAccount.project_id,
|
|
32
|
+
privateKey: serviceAccount.private_key,
|
|
33
|
+
clientEmail: serviceAccount.client_email,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error('Failed to load service account file:', error);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Initialize Firebase Admin SDK
|
|
43
|
+
* Can be called multiple times safely (idempotent)
|
|
44
|
+
*/
|
|
45
|
+
export async function initializeFirebaseAdmin() {
|
|
46
|
+
// Check if already initialized
|
|
47
|
+
if (getApps().length > 0) {
|
|
48
|
+
firestoreInstance = getFirestore();
|
|
49
|
+
appInstance = getApps()[0];
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Try to get credentials from environment or file
|
|
53
|
+
// Environment variables take precedence over file-based credentials
|
|
54
|
+
const envCredentials = getCredentialsFromEnv();
|
|
55
|
+
const fileCredentials = getCredentialsFromFile();
|
|
56
|
+
// Warn if both are set (they might conflict)
|
|
57
|
+
if (envCredentials && fileCredentials) {
|
|
58
|
+
console.warn('Both environment variables and service account file are set. Environment variables will be used.');
|
|
59
|
+
}
|
|
60
|
+
const credentials = envCredentials || fileCredentials;
|
|
61
|
+
if (!credentials) {
|
|
62
|
+
throw new Error('Firebase Admin credentials not found. Set FIREBASE_PROJECT_ID, FIREBASE_PRIVATE_KEY, and FIREBASE_CLIENT_EMAIL environment variables, or set GOOGLE_APPLICATION_CREDENTIALS to point to a service account file.');
|
|
63
|
+
}
|
|
64
|
+
// Initialize Firebase Admin
|
|
65
|
+
appInstance = initializeApp({
|
|
66
|
+
credential: cert({
|
|
67
|
+
projectId: credentials.projectId,
|
|
68
|
+
privateKey: credentials.privateKey,
|
|
69
|
+
clientEmail: credentials.clientEmail,
|
|
70
|
+
}),
|
|
71
|
+
projectId: credentials.projectId,
|
|
72
|
+
});
|
|
73
|
+
// Get Firestore instance
|
|
74
|
+
firestoreInstance = getFirestore(appInstance);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get Firestore instance
|
|
78
|
+
* Throws if Firebase Admin is not initialized
|
|
79
|
+
*/
|
|
80
|
+
export function getFirestoreInstance() {
|
|
81
|
+
if (!firestoreInstance) {
|
|
82
|
+
throw new Error('Firebase Admin not initialized. Call initializeFirebaseAdmin() first.');
|
|
83
|
+
}
|
|
84
|
+
return firestoreInstance;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get Firebase App instance
|
|
88
|
+
* Throws if Firebase Admin is not initialized
|
|
89
|
+
*/
|
|
90
|
+
export function getAppInstance() {
|
|
91
|
+
if (!appInstance) {
|
|
92
|
+
throw new Error('Firebase Admin not initialized. Call initializeFirebaseAdmin() first.');
|
|
93
|
+
}
|
|
94
|
+
return appInstance;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=admin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/firebase/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAY,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAkB,MAAM,0BAA0B,CAAC;AAExE,IAAI,iBAAiB,GAAqB,IAAI,CAAC;AAC/C,IAAI,WAAW,GAAe,IAAI,CAAC;AAWnC;;GAEG;AACH,SAAS,qBAAqB;IAC5B,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3E,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAEtD,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AAChD,CAAC;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AC;IACJ,CAAC;IAED,4BAA4B;IAC5B,WAAW,GAAG,aAAa,CAAC;QAC1B,UAAU,EAAE,IAAI,CAAC;YACf,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,UAAU,EAAE,WAAW,CAAC,UAAU;YAClC,WAAW,EAAE,WAAW,CAAC,WAAW;SACrC,CAAC;QACF,SAAS,EAAE,WAAW,CAAC,SAAS;KACjC,CAAC,CAAC;IAEH,yBAAyB;IACzB,iBAAiB,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { initializeFirebaseAdmin, getFirestoreInstance, getAppInstance } from './firebase/admin.js';
|
|
2
|
+
export { SessionCache } from './session/sessionCache.js';
|
|
3
|
+
export { FirestoreSync } from './session/firestoreSync.js';
|
|
4
|
+
export { SessionService, TokenRevokedError } from './session/sessionService.js';
|
|
5
|
+
export { createSessionService } from './config.js';
|
|
6
|
+
export { createAuthMiddleware } from './middleware/authMiddleware.js';
|
|
7
|
+
export { createLogoutHandler } from './middleware/logoutHandler.js';
|
|
8
|
+
export type { UserTokenVerifier, UserTokenVerificationError, Logger } from './types/middleware.js';
|
|
9
|
+
export { JoseTokenVerifier } from './tokenVerifier/joseTokenVerifier.js';
|
|
10
|
+
export type { TokenVerifierConfig } from './tokenVerifier/types.js';
|
|
11
|
+
export { TokenVerificationError, TokenVerificationFailedError, TokenVerifierConfigurationError, } from './tokenVerifier/errors.js';
|
|
12
|
+
export type { SessionInfo, ErrorResponse, ErrorCode, SessionServiceConfig, FirestoreSessionDocument, FirestoreLogoutDocument, } from '@rapidraptor/auth-shared';
|
|
13
|
+
export { SessionValidationStatus } from '@rapidraptor/auth-shared';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGpG,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,YAAY,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Firebase Admin
|
|
2
|
+
export { initializeFirebaseAdmin, getFirestoreInstance, getAppInstance } from './firebase/admin.js';
|
|
3
|
+
// Session Management
|
|
4
|
+
export { SessionCache } from './session/sessionCache.js';
|
|
5
|
+
export { FirestoreSync } from './session/firestoreSync.js';
|
|
6
|
+
export { SessionService, TokenRevokedError } from './session/sessionService.js';
|
|
7
|
+
export { createSessionService } from './config.js';
|
|
8
|
+
// Middleware
|
|
9
|
+
export { createAuthMiddleware } from './middleware/authMiddleware.js';
|
|
10
|
+
export { createLogoutHandler } from './middleware/logoutHandler.js';
|
|
11
|
+
// Token Verifier (Default Implementation)
|
|
12
|
+
export { JoseTokenVerifier } from './tokenVerifier/joseTokenVerifier.js';
|
|
13
|
+
export { TokenVerificationError, TokenVerificationFailedError, TokenVerifierConfigurationError, } from './tokenVerifier/errors.js';
|
|
14
|
+
export { SessionValidationStatus } from '@rapidraptor/auth-shared';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEpG,qBAAqB;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,aAAa;AACb,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,0CAA0C;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AAWnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RequestHandler } from 'express';
|
|
2
|
+
import { SessionService } from '../session/sessionService.js';
|
|
3
|
+
import type { UserTokenVerifier, Logger } from '../types/middleware.js';
|
|
4
|
+
/**
|
|
5
|
+
* Create authentication middleware with session validation
|
|
6
|
+
* Wraps existing JWT verifier and adds session management
|
|
7
|
+
*/
|
|
8
|
+
export declare function createAuthMiddleware(userTokenVerifier: UserTokenVerifier, sessionService: SessionService, logger?: Logger): RequestHandler;
|
|
9
|
+
//# sourceMappingURL=authMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authMiddleware.d.ts","sourceRoot":"","sources":["../../src/middleware/authMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAM/E,OAAO,EAAE,cAAc,EAAqB,MAAM,8BAA8B,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAA8B,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA0CpG;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,MAAM,CAAC,EAAE,MAAM,GACd,cAAc,CAiNhB"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { decodeJwt } from 'jose';
|
|
2
|
+
import { ERROR_CODES, SessionValidationStatus } from '@rapidraptor/auth-shared';
|
|
3
|
+
import { TokenRevokedError } from '../session/sessionService.js';
|
|
4
|
+
/**
|
|
5
|
+
* Type guard for errors with code property (e.g., Firestore errors)
|
|
6
|
+
*/
|
|
7
|
+
function isErrorWithCode(error) {
|
|
8
|
+
return (typeof error === 'object' &&
|
|
9
|
+
error !== null &&
|
|
10
|
+
'code' in error &&
|
|
11
|
+
typeof error.code === 'string');
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Handle token revocation error response
|
|
15
|
+
*/
|
|
16
|
+
function handleTokenRevoked(res, requestLogger, userId, tokenIssuedAt, correlationId) {
|
|
17
|
+
requestLogger?.warn?.('Token revoked (issued before logout)', {
|
|
18
|
+
event: 'token_revoked',
|
|
19
|
+
userId,
|
|
20
|
+
tokenIssuedAt: tokenIssuedAt.toISOString(),
|
|
21
|
+
correlationId,
|
|
22
|
+
});
|
|
23
|
+
res.status(401).json({
|
|
24
|
+
error: {
|
|
25
|
+
code: ERROR_CODES.SESSION_EXPIRED,
|
|
26
|
+
message: 'This token was issued before logout. Please log in again.',
|
|
27
|
+
requiresLogout: true,
|
|
28
|
+
sessionExpired: true,
|
|
29
|
+
timestamp: new Date().toISOString(),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create authentication middleware with session validation
|
|
35
|
+
* Wraps existing JWT verifier and adds session management
|
|
36
|
+
*/
|
|
37
|
+
export function createAuthMiddleware(userTokenVerifier, sessionService, logger) {
|
|
38
|
+
return async (req, res, next) => {
|
|
39
|
+
// Type-safe access with Express type extensions
|
|
40
|
+
const requestLogger = req.logger || logger;
|
|
41
|
+
try {
|
|
42
|
+
// Phase 1: JWT verification (existing logic)
|
|
43
|
+
const authHeader = req.headers.authorization;
|
|
44
|
+
if (!authHeader?.startsWith('Bearer ')) {
|
|
45
|
+
res.status(401).json({
|
|
46
|
+
error: {
|
|
47
|
+
code: ERROR_CODES.AUTH_FAILED,
|
|
48
|
+
message: 'Authorization header required',
|
|
49
|
+
requiresLogout: false,
|
|
50
|
+
sessionExpired: false,
|
|
51
|
+
timestamp: new Date().toISOString(),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const token = authHeader.split(' ')[1];
|
|
57
|
+
let user;
|
|
58
|
+
let tokenIssuedAt;
|
|
59
|
+
// Decode JWT to extract iat (issued at) timestamp
|
|
60
|
+
// This is needed to check if token was issued before logout
|
|
61
|
+
try {
|
|
62
|
+
const decoded = decodeJwt(token);
|
|
63
|
+
// iat is in seconds, convert to milliseconds for Date
|
|
64
|
+
tokenIssuedAt = new Date((decoded.iat || 0) * 1000);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
// If we can't decode, assume token is invalid
|
|
68
|
+
requestLogger?.warn?.('Failed to decode JWT', {
|
|
69
|
+
event: 'jwt_decode_failed',
|
|
70
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
71
|
+
correlationId: req.correlationId,
|
|
72
|
+
});
|
|
73
|
+
res.status(401).json({
|
|
74
|
+
error: {
|
|
75
|
+
code: ERROR_CODES.AUTH_FAILED,
|
|
76
|
+
message: 'Invalid token format',
|
|
77
|
+
requiresLogout: false,
|
|
78
|
+
sessionExpired: false,
|
|
79
|
+
timestamp: new Date().toISOString(),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
// Type-safe access with Express type extensions
|
|
86
|
+
const correlationId = req.correlationId;
|
|
87
|
+
user = await userTokenVerifier.verify(token, correlationId);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Handle JWT verification errors
|
|
91
|
+
const isExpired = error.isExpired === true;
|
|
92
|
+
requestLogger?.warn?.('JWT verification failed', {
|
|
93
|
+
event: 'jwt_verification_failed',
|
|
94
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
95
|
+
isExpired,
|
|
96
|
+
correlationId: req.correlationId,
|
|
97
|
+
});
|
|
98
|
+
res.status(401).json({
|
|
99
|
+
error: {
|
|
100
|
+
code: isExpired ? ERROR_CODES.TOKEN_EXPIRED : ERROR_CODES.AUTH_FAILED,
|
|
101
|
+
message: error instanceof Error ? error.message : 'Authentication failed',
|
|
102
|
+
requiresLogout: isExpired,
|
|
103
|
+
sessionExpired: false,
|
|
104
|
+
timestamp: new Date().toISOString(),
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
// Phase 2: Session validation (new)
|
|
110
|
+
let validationStatus;
|
|
111
|
+
try {
|
|
112
|
+
validationStatus = await sessionService.validateSession(user.sub);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// Handle Firestore unavailability with proper type checking
|
|
116
|
+
if (isErrorWithCode(error) && (error.code === 'unavailable' || error.code === 'deadline-exceeded')) {
|
|
117
|
+
requestLogger?.error?.('Firestore unavailable for session validation', {
|
|
118
|
+
event: 'firestore_unavailable',
|
|
119
|
+
error: error.message || 'Unknown error',
|
|
120
|
+
userId: user.sub,
|
|
121
|
+
correlationId: req.correlationId,
|
|
122
|
+
});
|
|
123
|
+
res.status(503).json({
|
|
124
|
+
error: {
|
|
125
|
+
code: ERROR_CODES.SERVICE_UNAVAILABLE,
|
|
126
|
+
message: 'User sessions could not be validated',
|
|
127
|
+
requiresLogout: false,
|
|
128
|
+
sessionExpired: false,
|
|
129
|
+
timestamp: new Date().toISOString(),
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// Re-throw other errors
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
if (validationStatus === SessionValidationStatus.VALID) {
|
|
138
|
+
// Session is valid - update activity (async, don't wait)
|
|
139
|
+
sessionService.updateLastActivity(user.sub).catch((err) => {
|
|
140
|
+
requestLogger?.error?.('Failed to update activity', {
|
|
141
|
+
event: 'activity_update_failed',
|
|
142
|
+
error: err instanceof Error ? err.message : 'Unknown error',
|
|
143
|
+
userId: user.sub,
|
|
144
|
+
correlationId: req.correlationId,
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
// Continue to attach user and proceed
|
|
148
|
+
}
|
|
149
|
+
else if (validationStatus === SessionValidationStatus.EXPIRED) {
|
|
150
|
+
// Session expired - reject the request
|
|
151
|
+
requestLogger?.warn?.('Session expired', {
|
|
152
|
+
event: 'session_expired',
|
|
153
|
+
userId: user.sub,
|
|
154
|
+
correlationId: req.correlationId,
|
|
155
|
+
});
|
|
156
|
+
res.status(401).json({
|
|
157
|
+
error: {
|
|
158
|
+
code: ERROR_CODES.SESSION_EXPIRED,
|
|
159
|
+
message: 'Session has expired due to inactivity',
|
|
160
|
+
requiresLogout: true,
|
|
161
|
+
sessionExpired: true,
|
|
162
|
+
timestamp: new Date().toISOString(),
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
else if (validationStatus === SessionValidationStatus.NOT_FOUND) {
|
|
168
|
+
// Session doesn't exist - ensureSession will check token revocation and create session if needed
|
|
169
|
+
try {
|
|
170
|
+
await sessionService.ensureSession(user.sub, tokenIssuedAt);
|
|
171
|
+
requestLogger?.info?.('Session created', {
|
|
172
|
+
event: 'session_created',
|
|
173
|
+
userId: user.sub,
|
|
174
|
+
correlationId: req.correlationId,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
// Handle TokenRevokedError from ensureSession
|
|
179
|
+
if (error instanceof TokenRevokedError) {
|
|
180
|
+
handleTokenRevoked(res, requestLogger, user.sub, tokenIssuedAt, req.correlationId);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
// Handle Firestore unavailability (from validateSession or createSession)
|
|
184
|
+
if (isErrorWithCode(error) && (error.code === 'unavailable' || error.code === 'deadline-exceeded')) {
|
|
185
|
+
requestLogger?.error?.('Firestore unavailable for session creation', {
|
|
186
|
+
event: 'firestore_unavailable',
|
|
187
|
+
error: error.message || 'Unknown error',
|
|
188
|
+
userId: user.sub,
|
|
189
|
+
correlationId: req.correlationId,
|
|
190
|
+
});
|
|
191
|
+
res.status(503).json({
|
|
192
|
+
error: {
|
|
193
|
+
code: ERROR_CODES.SERVICE_UNAVAILABLE,
|
|
194
|
+
message: 'User sessions could not be created',
|
|
195
|
+
requiresLogout: false,
|
|
196
|
+
sessionExpired: false,
|
|
197
|
+
timestamp: new Date().toISOString(),
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
// Re-throw other errors
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (validationStatus === SessionValidationStatus.DATA_INTEGRITY_ERROR) {
|
|
207
|
+
// Data integrity issue - reject request
|
|
208
|
+
requestLogger?.error?.('Session data integrity error', {
|
|
209
|
+
event: 'session_data_integrity_error',
|
|
210
|
+
userId: user.sub,
|
|
211
|
+
correlationId: req.correlationId,
|
|
212
|
+
});
|
|
213
|
+
res.status(500).json({
|
|
214
|
+
error: {
|
|
215
|
+
code: ERROR_CODES.INTERNAL_ERROR,
|
|
216
|
+
message: 'Session data integrity error',
|
|
217
|
+
requiresLogout: true,
|
|
218
|
+
sessionExpired: false,
|
|
219
|
+
timestamp: new Date().toISOString(),
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
// Attach user to request - now type-safe
|
|
225
|
+
req.user = user;
|
|
226
|
+
next();
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
requestLogger?.error?.('Authentication middleware error', {
|
|
230
|
+
event: 'auth_middleware_error',
|
|
231
|
+
error: {
|
|
232
|
+
name: error instanceof Error ? error.name : 'Unknown',
|
|
233
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
234
|
+
},
|
|
235
|
+
correlationId: req.correlationId,
|
|
236
|
+
});
|
|
237
|
+
next(error);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=authMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authMiddleware.js","sourceRoot":"","sources":["../../src/middleware/authMiddleware.ts"],"names":[],"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G,IAAI,CAAC;YAChB,IAAI,EAAE,CAAC;QACT,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,aAAa,EAAE,KAAK,EAAE,CAAC,iCAAiC,EAAE;gBACxD,KAAK,EAAE,uBAAuB;gBAC9B,KAAK,EAAE;oBACL,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;oBACrD,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;iBAClE;gBACD,aAAa,EAAE,GAAG,CAAC,aAAa;aACjC,CAAC,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authMiddleware.test.d.ts","sourceRoot":"","sources":["../../src/middleware/authMiddleware.test.ts"],"names":[],"mappings":""}
|