@nebulr-group/bridge-auth-core 0.4.0-beta.2 → 0.4.0-beta.5
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/backend/index.d.ts +12 -0
- package/dist/backend/index.d.ts.map +1 -0
- package/dist/backend/index.js +12 -0
- package/dist/backend/index.js.map +1 -0
- package/dist/backend/jwks-service.d.ts +86 -0
- package/dist/backend/jwks-service.d.ts.map +1 -0
- package/dist/backend/jwks-service.js +143 -0
- package/dist/backend/jwks-service.js.map +1 -0
- package/dist/backend/types.d.ts +119 -0
- package/dist/backend/types.d.ts.map +1 -0
- package/dist/backend/types.js +37 -0
- package/dist/backend/types.js.map +1 -0
- package/dist/usage/index.d.ts +1 -1
- package/dist/usage/index.d.ts.map +1 -1
- package/dist/usage/index.js +1 -1
- package/dist/usage/index.js.map +1 -1
- package/dist/usage/storage/index.d.ts +0 -1
- package/dist/usage/storage/index.d.ts.map +1 -1
- package/dist/usage/storage/index.js +44 -9
- package/dist/usage/storage/index.js.map +1 -1
- package/dist/usage/storage/node-fs-storage.d.ts.map +1 -1
- package/dist/usage/storage/node-fs-storage.js +22 -7
- package/dist/usage/storage/node-fs-storage.js.map +1 -1
- package/package.json +13 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nebulr-group/bridge-auth-core/backend
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic, Node-only auth surface for server-side Bridge plugins.
|
|
5
|
+
* No NestJS, no browser/storage APIs. Safe to import from any Node backend.
|
|
6
|
+
*/
|
|
7
|
+
export { JwksService, TokenVerificationError } from './jwks-service.js';
|
|
8
|
+
export type { JwksServiceConfig, JwksLogger } from './jwks-service.js';
|
|
9
|
+
export type { JwtClaims, BridgeUser, ApiTokenClaims } from './types.js';
|
|
10
|
+
export { transformJwtToBridgeUser } from './types.js';
|
|
11
|
+
export { decodeJwtPayload, getTokenExpiry, isTokenExpired, getTenantId, getTenantUserId, } from '../token-utils.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGvE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAGtD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nebulr-group/bridge-auth-core/backend
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic, Node-only auth surface for server-side Bridge plugins.
|
|
5
|
+
* No NestJS, no browser/storage APIs. Safe to import from any Node backend.
|
|
6
|
+
*/
|
|
7
|
+
// JWKS-based verification (plain class, not a DI provider)
|
|
8
|
+
export { JwksService, TokenVerificationError } from './jwks-service.js';
|
|
9
|
+
export { transformJwtToBridgeUser } from './types.js';
|
|
10
|
+
// Token utilities (reused from the shared token-utils — no duplication)
|
|
11
|
+
export { decodeJwtPayload, getTokenExpiry, isTokenExpired, getTenantId, getTenantUserId, } from '../token-utils.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2DAA2D;AAC3D,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD,wEAAwE;AACxE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { JwtClaims, ApiTokenClaims } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Optional logger. Defaults to a no-op so the service is silent unless a
|
|
4
|
+
* consumer wires one in (e.g. NestJS forwards `BridgeConfigService.log`).
|
|
5
|
+
*/
|
|
6
|
+
export type JwksLogger = (message: string, ...args: unknown[]) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Construction config for the framework-agnostic JwksService.
|
|
9
|
+
*
|
|
10
|
+
* Everything the verification logic needs is injected — there is no hardcoded
|
|
11
|
+
* URL, issuer, audience, or TTL. Framework wrappers (NestJS, etc.) construct
|
|
12
|
+
* this from their own config service.
|
|
13
|
+
*/
|
|
14
|
+
export interface JwksServiceConfig {
|
|
15
|
+
/** JWKS endpoint for user-token verification. */
|
|
16
|
+
jwksUrl: string;
|
|
17
|
+
/** JWKS endpoint for API-token verification (cached independently). */
|
|
18
|
+
apiTokenJwksUrl: string;
|
|
19
|
+
/** Expected `iss` for user tokens. */
|
|
20
|
+
issuer: string;
|
|
21
|
+
/** Expected `aud` for user tokens (typically the appId). */
|
|
22
|
+
audience: string;
|
|
23
|
+
/** How long a remote JWKS client is reused before it is re-created. @default 3600000 (1h) */
|
|
24
|
+
cacheTtlMs?: number;
|
|
25
|
+
/** Optional debug logger. @default no-op */
|
|
26
|
+
log?: JwksLogger;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown on token verification failure.
|
|
30
|
+
*
|
|
31
|
+
* `code` is a stable, framework-agnostic discriminator:
|
|
32
|
+
* `TOKEN_EXPIRED` | `TOKEN_INVALID` | `JWKS_NO_MATCH` | `CLAIM_VALIDATION_FAILED`
|
|
33
|
+
* | `APP_MISMATCH` | `UNKNOWN_ERROR`.
|
|
34
|
+
*/
|
|
35
|
+
export declare class TokenVerificationError extends Error {
|
|
36
|
+
readonly code: string;
|
|
37
|
+
constructor(message: string, code: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Framework-agnostic, Node-only JWKS-based JWT verification.
|
|
41
|
+
*
|
|
42
|
+
* Covers BOTH the user-token path (issuer/audience validated) and the
|
|
43
|
+
* API-token path (type + appId validated). The two JWKS clients are cached
|
|
44
|
+
* independently with the same TTL behavior.
|
|
45
|
+
*
|
|
46
|
+
* This is a plain class — NOT a DI provider. Framework plugins wrap it.
|
|
47
|
+
*/
|
|
48
|
+
export declare class JwksService {
|
|
49
|
+
private readonly config;
|
|
50
|
+
private jwks;
|
|
51
|
+
private jwksInitTime;
|
|
52
|
+
private apiTokenJwks;
|
|
53
|
+
private apiTokenJwksInitTime;
|
|
54
|
+
private readonly cacheTtlMs;
|
|
55
|
+
private readonly log;
|
|
56
|
+
constructor(config: JwksServiceConfig);
|
|
57
|
+
/**
|
|
58
|
+
* Initialize or refresh the user-token JWKS client.
|
|
59
|
+
*/
|
|
60
|
+
private ensureJwks;
|
|
61
|
+
/**
|
|
62
|
+
* Initialize or refresh the API-token JWKS client (cached independently).
|
|
63
|
+
*/
|
|
64
|
+
private ensureApiTokenJwks;
|
|
65
|
+
/**
|
|
66
|
+
* Verify a user JWT and return its claims.
|
|
67
|
+
*
|
|
68
|
+
* @throws {TokenVerificationError} if the token is invalid or expired.
|
|
69
|
+
*/
|
|
70
|
+
verifyToken(token: string): Promise<JwtClaims>;
|
|
71
|
+
/**
|
|
72
|
+
* Verify a Bridge API token JWT and return its claims.
|
|
73
|
+
*
|
|
74
|
+
* Uses a separate JWKS client (cached independently from the user-token
|
|
75
|
+
* client). Validates `type === 'api'` and `appId === expectedAppId`.
|
|
76
|
+
*
|
|
77
|
+
* @throws {TokenVerificationError} if the token is invalid, expired, the
|
|
78
|
+
* wrong type, or issued for a different app.
|
|
79
|
+
*/
|
|
80
|
+
verifyApiToken(token: string, expectedAppId: string): Promise<ApiTokenClaims>;
|
|
81
|
+
/**
|
|
82
|
+
* Map a jose verification error to a stable TokenVerificationError.
|
|
83
|
+
*/
|
|
84
|
+
private mapVerificationError;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=jwks-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwks-service.d.ts","sourceRoot":"","sources":["../../src/backend/jwks-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,eAAe,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aAG7B,IAAI,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;CAK/B;AAID;;;;;;;;GAQG;AACH,qBAAa,WAAW;IAUV,OAAO,CAAC,QAAQ,CAAC,MAAM;IATnC,OAAO,CAAC,IAAI,CAAsD;IAClE,OAAO,CAAC,YAAY,CAAK;IAEzB,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,oBAAoB,CAAK;IAEjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;gBAEJ,MAAM,EAAE,iBAAiB;IAKtD;;OAEG;IACH,OAAO,CAAC,UAAU;IAYlB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;;;OAIG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAqBpD;;;;;;;;OAQG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BnF;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAqB7B"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createRemoteJWKSet, jwtVerify, errors as joseErrors } from 'jose';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown on token verification failure.
|
|
4
|
+
*
|
|
5
|
+
* `code` is a stable, framework-agnostic discriminator:
|
|
6
|
+
* `TOKEN_EXPIRED` | `TOKEN_INVALID` | `JWKS_NO_MATCH` | `CLAIM_VALIDATION_FAILED`
|
|
7
|
+
* | `APP_MISMATCH` | `UNKNOWN_ERROR`.
|
|
8
|
+
*/
|
|
9
|
+
export class TokenVerificationError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
constructor(message, code) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.name = 'TokenVerificationError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const DEFAULT_CACHE_TTL_MS = 60 * 60 * 1000; // 1 hour
|
|
18
|
+
/**
|
|
19
|
+
* Framework-agnostic, Node-only JWKS-based JWT verification.
|
|
20
|
+
*
|
|
21
|
+
* Covers BOTH the user-token path (issuer/audience validated) and the
|
|
22
|
+
* API-token path (type + appId validated). The two JWKS clients are cached
|
|
23
|
+
* independently with the same TTL behavior.
|
|
24
|
+
*
|
|
25
|
+
* This is a plain class — NOT a DI provider. Framework plugins wrap it.
|
|
26
|
+
*/
|
|
27
|
+
export class JwksService {
|
|
28
|
+
config;
|
|
29
|
+
jwks = null;
|
|
30
|
+
jwksInitTime = 0;
|
|
31
|
+
apiTokenJwks = null;
|
|
32
|
+
apiTokenJwksInitTime = 0;
|
|
33
|
+
cacheTtlMs;
|
|
34
|
+
log;
|
|
35
|
+
constructor(config) {
|
|
36
|
+
this.config = config;
|
|
37
|
+
this.cacheTtlMs = config.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
38
|
+
this.log = config.log ?? (() => { });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Initialize or refresh the user-token JWKS client.
|
|
42
|
+
*/
|
|
43
|
+
ensureJwks() {
|
|
44
|
+
const now = Date.now();
|
|
45
|
+
if (!this.jwks || now - this.jwksInitTime > this.cacheTtlMs) {
|
|
46
|
+
this.log('Initializing JWKS client', { url: this.config.jwksUrl });
|
|
47
|
+
this.jwks = createRemoteJWKSet(new URL(this.config.jwksUrl));
|
|
48
|
+
this.jwksInitTime = now;
|
|
49
|
+
}
|
|
50
|
+
return this.jwks;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Initialize or refresh the API-token JWKS client (cached independently).
|
|
54
|
+
*/
|
|
55
|
+
ensureApiTokenJwks() {
|
|
56
|
+
const now = Date.now();
|
|
57
|
+
if (!this.apiTokenJwks || now - this.apiTokenJwksInitTime > this.cacheTtlMs) {
|
|
58
|
+
this.log('Initializing API token JWKS client', { url: this.config.apiTokenJwksUrl });
|
|
59
|
+
this.apiTokenJwks = createRemoteJWKSet(new URL(this.config.apiTokenJwksUrl));
|
|
60
|
+
this.apiTokenJwksInitTime = now;
|
|
61
|
+
}
|
|
62
|
+
return this.apiTokenJwks;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Verify a user JWT and return its claims.
|
|
66
|
+
*
|
|
67
|
+
* @throws {TokenVerificationError} if the token is invalid or expired.
|
|
68
|
+
*/
|
|
69
|
+
async verifyToken(token) {
|
|
70
|
+
const jwks = this.ensureJwks();
|
|
71
|
+
try {
|
|
72
|
+
const { payload } = await jwtVerify(token, jwks, {
|
|
73
|
+
issuer: this.config.issuer,
|
|
74
|
+
audience: this.config.audience,
|
|
75
|
+
});
|
|
76
|
+
this.log('Token verified successfully', {
|
|
77
|
+
sub: payload.sub,
|
|
78
|
+
iss: payload.iss,
|
|
79
|
+
aud: payload.aud,
|
|
80
|
+
});
|
|
81
|
+
return payload;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
throw this.mapVerificationError(error, 'Token');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Verify a Bridge API token JWT and return its claims.
|
|
89
|
+
*
|
|
90
|
+
* Uses a separate JWKS client (cached independently from the user-token
|
|
91
|
+
* client). Validates `type === 'api'` and `appId === expectedAppId`.
|
|
92
|
+
*
|
|
93
|
+
* @throws {TokenVerificationError} if the token is invalid, expired, the
|
|
94
|
+
* wrong type, or issued for a different app.
|
|
95
|
+
*/
|
|
96
|
+
async verifyApiToken(token, expectedAppId) {
|
|
97
|
+
const jwks = this.ensureApiTokenJwks();
|
|
98
|
+
try {
|
|
99
|
+
const { payload } = await jwtVerify(token, jwks);
|
|
100
|
+
if (payload['type'] !== 'api') {
|
|
101
|
+
throw new TokenVerificationError('Wrong token type', 'TOKEN_INVALID');
|
|
102
|
+
}
|
|
103
|
+
if (payload['appId'] !== expectedAppId) {
|
|
104
|
+
throw new TokenVerificationError('Token issued for a different app', 'APP_MISMATCH');
|
|
105
|
+
}
|
|
106
|
+
this.log('API token verified successfully', {
|
|
107
|
+
sub: payload.sub,
|
|
108
|
+
appId: payload['appId'],
|
|
109
|
+
});
|
|
110
|
+
return payload;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (error instanceof TokenVerificationError) {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
throw this.mapVerificationError(error, 'API token');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Map a jose verification error to a stable TokenVerificationError.
|
|
121
|
+
*/
|
|
122
|
+
mapVerificationError(error, label) {
|
|
123
|
+
if (error instanceof joseErrors.JWTExpired) {
|
|
124
|
+
this.log(`${label} verification failed: Token expired`);
|
|
125
|
+
return new TokenVerificationError('Token expired', 'TOKEN_EXPIRED');
|
|
126
|
+
}
|
|
127
|
+
if (error instanceof joseErrors.JWTInvalid) {
|
|
128
|
+
this.log(`${label} verification failed: Invalid token`);
|
|
129
|
+
return new TokenVerificationError('Invalid token', 'TOKEN_INVALID');
|
|
130
|
+
}
|
|
131
|
+
if (error instanceof joseErrors.JWKSNoMatchingKey) {
|
|
132
|
+
this.log(`${label} verification failed: No matching key in JWKS`);
|
|
133
|
+
return new TokenVerificationError('Invalid token signature', 'JWKS_NO_MATCH');
|
|
134
|
+
}
|
|
135
|
+
if (error instanceof joseErrors.JWTClaimValidationFailed) {
|
|
136
|
+
this.log(`${label} verification failed: Claim validation failed`, error.message);
|
|
137
|
+
return new TokenVerificationError('Token claim validation failed', 'CLAIM_VALIDATION_FAILED');
|
|
138
|
+
}
|
|
139
|
+
this.log(`${label} verification failed: Unknown error`, error);
|
|
140
|
+
return new TokenVerificationError('Token verification failed', 'UNKNOWN_ERROR');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=jwks-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwks-service.js","sourceRoot":"","sources":["../../src/backend/jwks-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,MAAM,CAAC;AA+B3E;;;;;;GAMG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAG7B;IAFlB,YACE,OAAe,EACC,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;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,yBAAyB,EAAE,eAAe,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,KAAK,YAAY,UAAU,CAAC,wBAAwB,EAAE,CAAC;YACzD,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,+CAA+C,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;YAC5F,OAAO,IAAI,sBAAsB,CAAC,+BAA+B,EAAE,yBAAyB,CAAC,CAAC;QAChG,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC/D,OAAO,IAAI,sBAAsB,CAAC,2BAA2B,EAAE,eAAe,CAAC,CAAC;IAClF,CAAC;CACF"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend (Node-only) auth types.
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic. No NestJS, no browser/storage APIs. These are the shapes
|
|
5
|
+
* shared by every server-side Bridge plugin (bridge-nestjs today; others later)
|
|
6
|
+
* for JWT verification and user extraction.
|
|
7
|
+
*
|
|
8
|
+
* NOTE on `JwtClaims` vs `IDToken` (in ../types.ts): `IDToken` is the strict
|
|
9
|
+
* OIDC id_token payload used by the browser SDK to build a `Profile`. `JwtClaims`
|
|
10
|
+
* here is the permissive *access-token* claim set the server verifies via JWKS —
|
|
11
|
+
* it carries short-form tenant/app claims (`tid`/`aid`), `privileges`, `role`,
|
|
12
|
+
* and the registered JWT claims (`iss`/`aud`/`exp`/...). They intentionally stay
|
|
13
|
+
* separate: different tokens, different consumers.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Raw JWT claims from a Bridge access/ID token (the verified payload).
|
|
17
|
+
*/
|
|
18
|
+
export interface JwtClaims {
|
|
19
|
+
/** Subject (user ID) */
|
|
20
|
+
sub: string;
|
|
21
|
+
/** Preferred username */
|
|
22
|
+
preferred_username?: string;
|
|
23
|
+
/** Email address */
|
|
24
|
+
email?: string;
|
|
25
|
+
/** Email verified flag */
|
|
26
|
+
email_verified?: boolean;
|
|
27
|
+
/** Full name */
|
|
28
|
+
name?: string;
|
|
29
|
+
/** Given name */
|
|
30
|
+
given_name?: string;
|
|
31
|
+
/** Family name */
|
|
32
|
+
family_name?: string;
|
|
33
|
+
/** Locale */
|
|
34
|
+
locale?: string;
|
|
35
|
+
/** User onboarded flag */
|
|
36
|
+
onboarded?: boolean;
|
|
37
|
+
/** Multi-tenant flag */
|
|
38
|
+
multi_tenant?: boolean;
|
|
39
|
+
/** Tenant ID (long form) */
|
|
40
|
+
tenant_id?: string;
|
|
41
|
+
/** Tenant ID (short form) */
|
|
42
|
+
tid?: string;
|
|
43
|
+
/** App ID (short form) */
|
|
44
|
+
aid?: string;
|
|
45
|
+
/** Scope */
|
|
46
|
+
scope?: string;
|
|
47
|
+
/** Tenant name */
|
|
48
|
+
tenant_name?: string;
|
|
49
|
+
/** Tenant locale */
|
|
50
|
+
tenant_locale?: string;
|
|
51
|
+
/** Tenant logo URL */
|
|
52
|
+
tenant_logo?: string;
|
|
53
|
+
/** Tenant onboarded flag */
|
|
54
|
+
tenant_onboarded?: boolean;
|
|
55
|
+
/** User's role */
|
|
56
|
+
role?: string;
|
|
57
|
+
/** User privilege strings (custom claim) */
|
|
58
|
+
privileges?: string[];
|
|
59
|
+
/** Token issuer */
|
|
60
|
+
iss?: string;
|
|
61
|
+
/** Token audience */
|
|
62
|
+
aud?: string | string[];
|
|
63
|
+
/** Expiration time */
|
|
64
|
+
exp?: number;
|
|
65
|
+
/** Not before time */
|
|
66
|
+
nbf?: number;
|
|
67
|
+
/** Issued at time */
|
|
68
|
+
iat?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Authenticated user extracted from a verified JWT access token.
|
|
72
|
+
*/
|
|
73
|
+
export interface BridgeUser {
|
|
74
|
+
/** User ID (sub claim) */
|
|
75
|
+
id: string;
|
|
76
|
+
/** User's email address */
|
|
77
|
+
email: string;
|
|
78
|
+
/** Whether email is verified */
|
|
79
|
+
emailVerified: boolean;
|
|
80
|
+
/** Username (preferred_username claim) */
|
|
81
|
+
username: string;
|
|
82
|
+
/** Full display name */
|
|
83
|
+
fullName: string;
|
|
84
|
+
/** Given/first name */
|
|
85
|
+
givenName?: string;
|
|
86
|
+
/** Family/last name */
|
|
87
|
+
familyName?: string;
|
|
88
|
+
/** User's locale preference */
|
|
89
|
+
locale?: string;
|
|
90
|
+
/** Whether user has completed onboarding */
|
|
91
|
+
onboarded?: boolean;
|
|
92
|
+
/** Tenant/workspace ID the user is authenticated for */
|
|
93
|
+
tenantId: string;
|
|
94
|
+
/** App ID from the token (aid claim) */
|
|
95
|
+
appId?: string;
|
|
96
|
+
/** OAuth scopes granted to the token */
|
|
97
|
+
scope?: string;
|
|
98
|
+
/** User's role within the tenant */
|
|
99
|
+
role?: string;
|
|
100
|
+
/** Whether user has multi-tenant access */
|
|
101
|
+
multiTenantAccess?: boolean;
|
|
102
|
+
/** Privilege strings from the JWT `privileges` claim (e.g. ['AUTHENTICATED', 'USER_READ']) */
|
|
103
|
+
privileges?: string[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Claims present in a Bridge API token JWT (the `x-api-key` machine credential).
|
|
107
|
+
*/
|
|
108
|
+
export interface ApiTokenClaims extends JwtClaims {
|
|
109
|
+
sub: string;
|
|
110
|
+
appId: string;
|
|
111
|
+
tenantId: string | null;
|
|
112
|
+
type: 'api';
|
|
113
|
+
privileges: string[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Transform raw JWT claims into a BridgeUser.
|
|
117
|
+
*/
|
|
118
|
+
export declare function transformJwtToBridgeUser(claims: JwtClaims): BridgeUser;
|
|
119
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,MAAM,WAAW,S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4
|
+
* Framework-agnostic. No NestJS, no browser/storage APIs. These are the shapes
|
|
5
|
+
* shared by every server-side Bridge plugin (bridge-nestjs today; others later)
|
|
6
|
+
* for JWT verification and user extraction.
|
|
7
|
+
*
|
|
8
|
+
* NOTE on `JwtClaims` vs `IDToken` (in ../types.ts): `IDToken` is the strict
|
|
9
|
+
* OIDC id_token payload used by the browser SDK to build a `Profile`. `JwtClaims`
|
|
10
|
+
* here is the permissive *access-token* claim set the server verifies via JWKS —
|
|
11
|
+
* it carries short-form tenant/app claims (`tid`/`aid`), `privileges`, `role`,
|
|
12
|
+
* and the registered JWT claims (`iss`/`aud`/`exp`/...). They intentionally stay
|
|
13
|
+
* separate: different tokens, different consumers.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Transform raw JWT claims into a BridgeUser.
|
|
17
|
+
*/
|
|
18
|
+
export function transformJwtToBridgeUser(claims) {
|
|
19
|
+
return {
|
|
20
|
+
id: claims.sub,
|
|
21
|
+
email: claims.email || '',
|
|
22
|
+
emailVerified: claims.email_verified || false,
|
|
23
|
+
username: claims.preferred_username || claims.email || '',
|
|
24
|
+
fullName: claims.name || '',
|
|
25
|
+
givenName: claims.given_name,
|
|
26
|
+
familyName: claims.family_name,
|
|
27
|
+
locale: claims.locale,
|
|
28
|
+
onboarded: claims.onboarded,
|
|
29
|
+
tenantId: claims.tid || claims.tenant_id || '',
|
|
30
|
+
appId: claims.aid,
|
|
31
|
+
scope: claims.scope,
|
|
32
|
+
role: claims.role,
|
|
33
|
+
multiTenantAccess: claims.multi_tenant,
|
|
34
|
+
privileges: claims.privileges,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/backend/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAyGH;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAiB;IACxD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,GAAG;QACd,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;QACzB,aAAa,EAAE,MAAM,CAAC,cAAc,IAAI,KAAK;QAC7C,QAAQ,EAAE,MAAM,CAAC,kBAAkB,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE;QACzD,QAAQ,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;QAC3B,SAAS,EAAE,MAAM,CAAC,UAAU;QAC5B,UAAU,EAAE,MAAM,CAAC,WAAW;QAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,SAAS,IAAI,EAAE;QAC9C,KAAK,EAAE,MAAM,CAAC,GAAG;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,iBAAiB,EAAE,MAAM,CAAC,YAAY;QACtC,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC;AACJ,CAAC"}
|
package/dist/usage/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { UsageReporter, type UsageReporterOptions, type QueueStatus } from './usage-reporter.js';
|
|
2
|
-
export { createDurableStorage, type DurableStorage, type DurableStorageOptions, type QueuedEvent, IndexedDBStorage,
|
|
2
|
+
export { createDurableStorage, type DurableStorage, type DurableStorageOptions, type QueuedEvent, IndexedDBStorage, InMemoryStorage, DEFAULT_MAX_SIZE, isBrowserEnv, isNodeEnv, } from './storage/index.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/usage/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/usage/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,MAAM,oBAAoB,CAAC"}
|
package/dist/usage/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Billing 2.0 — public exports for the usage subsystem.
|
|
2
2
|
export { UsageReporter } from './usage-reporter.js';
|
|
3
|
-
export { createDurableStorage, IndexedDBStorage,
|
|
3
|
+
export { createDurableStorage, IndexedDBStorage, InMemoryStorage, DEFAULT_MAX_SIZE, isBrowserEnv, isNodeEnv, } from './storage/index.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/usage/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/usage/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,aAAa,EAA+C,MAAM,qBAAqB,CAAC;AACjG,OAAO,EACL,oBAAoB,EAIpB,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/usage/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,aAAa,EAA+C,MAAM,qBAAqB,CAAC;AACjG,OAAO,EACL,oBAAoB,EAIpB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type DurableStorage, type DurableStorageOptions } from './durable-storage.js';
|
|
2
2
|
export { type DurableStorage, type DurableStorageOptions, type QueuedEvent, DEFAULT_MAX_SIZE, isBrowserEnv, isNodeEnv, } from './durable-storage.js';
|
|
3
3
|
export { IndexedDBStorage } from './indexeddb-storage.js';
|
|
4
|
-
export { NodeFsStorage } from './node-fs-storage.js';
|
|
5
4
|
export { InMemoryStorage } from './noop-storage.js';
|
|
6
5
|
export declare function createDurableStorage(opts?: DurableStorageOptions): DurableStorage;
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/usage/storage/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/usage/storage/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAE3B,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsCpD,wBAAgB,oBAAoB,CAAC,IAAI,GAAE,qBAA0B,GAAG,cAAc,CAIrF"}
|
|
@@ -2,27 +2,62 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Auto-selects the correct backend for the current runtime:
|
|
4
4
|
// - browser → IndexedDBStorage
|
|
5
|
-
// - Node → NodeFsStorage
|
|
5
|
+
// - Node → NodeFsStorage (loaded lazily — see edge-safety note)
|
|
6
6
|
// - else → InMemoryStorage (SSR / edge fallback)
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
8
|
+
// Edge-safety (TBP — Node-builtin edge-runtime fix): node-fs-storage.js loads
|
|
9
|
+
// the Node fs/path/os builtins. Bundlers targeting the browser or an edge
|
|
10
|
+
// runtime (Next.js middleware, Vite) choke on those builtins as soon as the
|
|
11
|
+
// module is STATICALLY reachable from the package root — even when the builtin
|
|
12
|
+
// import inside it is itself dynamic. We therefore never import NodeFsStorage
|
|
13
|
+
// statically here: the Node branch returns a thin lazy proxy
|
|
14
|
+
// (LazyNodeFsStorage) that imports the real impl on first method call. In a
|
|
15
|
+
// real Node process this is transparent (all DurableStorage methods are async
|
|
16
|
+
// already); in a browser/edge bundle the Node module simply never enters the
|
|
17
|
+
// static graph. IndexedDBStorage is safe to import statically — it only touches
|
|
18
|
+
// the indexedDB global inside method bodies, no Node builtins.
|
|
13
19
|
import { isBrowserEnv, isNodeEnv, } from './durable-storage.js';
|
|
14
20
|
import { IndexedDBStorage } from './indexeddb-storage.js';
|
|
15
|
-
import { NodeFsStorage } from './node-fs-storage.js';
|
|
16
21
|
import { InMemoryStorage } from './noop-storage.js';
|
|
17
22
|
export { DEFAULT_MAX_SIZE, isBrowserEnv, isNodeEnv, } from './durable-storage.js';
|
|
18
23
|
export { IndexedDBStorage } from './indexeddb-storage.js';
|
|
19
|
-
export { NodeFsStorage } from './node-fs-storage.js';
|
|
20
24
|
export { InMemoryStorage } from './noop-storage.js';
|
|
25
|
+
/**
|
|
26
|
+
* Lazy Node filesystem storage. Defers loading node-fs-storage.js (and thus
|
|
27
|
+
* its Node-builtin imports) until the first storage operation, so the concrete
|
|
28
|
+
* Node impl is reachable only via a dynamic import and never via the static
|
|
29
|
+
* module graph. Keeps `createDurableStorage()` synchronous (it's called from
|
|
30
|
+
* the `UsageReporter` constructor) while all real I/O stays async.
|
|
31
|
+
*/
|
|
32
|
+
class LazyNodeFsStorage {
|
|
33
|
+
real;
|
|
34
|
+
constructor(opts) {
|
|
35
|
+
this.real = import('./node-fs-storage.js').then((m) => new m.NodeFsStorage(opts));
|
|
36
|
+
}
|
|
37
|
+
async enqueue(event) {
|
|
38
|
+
return (await this.real).enqueue(event);
|
|
39
|
+
}
|
|
40
|
+
async peek(limit) {
|
|
41
|
+
return (await this.real).peek(limit);
|
|
42
|
+
}
|
|
43
|
+
async remove(keys) {
|
|
44
|
+
return (await this.real).remove(keys);
|
|
45
|
+
}
|
|
46
|
+
async markRetry(key, error) {
|
|
47
|
+
return (await this.real).markRetry(key, error);
|
|
48
|
+
}
|
|
49
|
+
async size() {
|
|
50
|
+
return (await this.real).size();
|
|
51
|
+
}
|
|
52
|
+
async close() {
|
|
53
|
+
return (await this.real).close?.();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
21
56
|
export function createDurableStorage(opts = {}) {
|
|
22
57
|
if (isBrowserEnv())
|
|
23
58
|
return new IndexedDBStorage(opts);
|
|
24
59
|
if (isNodeEnv())
|
|
25
|
-
return new
|
|
60
|
+
return new LazyNodeFsStorage(opts);
|
|
26
61
|
return new InMemoryStorage(opts);
|
|
27
62
|
}
|
|
28
63
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/usage/storage/index.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,4DAA4D;AAC5D,iCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/usage/storage/index.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,EAAE;AACF,4DAA4D;AAC5D,iCAAiC;AACjC,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,4EAA4E;AAC5E,+EAA+E;AAC/E,8EAA8E;AAC9E,6DAA6D;AAC7D,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAChF,+DAA+D;A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I,EAAE,CAAC;IAClC,CAAC;IACD,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IACrC,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,OAA8B,EAAE;IACnE,IAAI,YAAY,EAAE;QAAE,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,SAAS,EAAE;QAAE,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACpD,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-fs-storage.d.ts","sourceRoot":"","sources":["../../../src/usage/storage/node-fs-storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-fs-storage.d.ts","sourceRoot":"","sources":["../../../src/usage/storage/node-fs-storage.ts"],"names":[],"mappings":"AAwBA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAoB9B,qBAAa,aAAc,YAAW,cAAc;IAClD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAC,CAAkB;IACrC,OAAO,CAAC,UAAU,CAAuC;IACzD,OAAO,CAAC,GAAG,CAAC,CAAoB;IAChC,OAAO,CAAC,KAAK,CAAC,CAAsB;IACpC,OAAO,CAAC,GAAG,CAAC,CAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAS;gBAE1B,IAAI,GAAE,qBAA0B;IAUtC,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1C,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAM3C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAYrC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBpD,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAK7B,SAAS,CAAC,IAAI,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAMrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,OAAO,CAAC,UAAU;YAOJ,QAAQ;YA8BR,qBAAqB;YAcrB,MAAM;IAOpB,OAAO,CAAC,GAAG;IAKX,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,GAAG;IAKX,OAAO,CAAC,IAAI;CAab"}
|
|
@@ -14,11 +14,26 @@
|
|
|
14
14
|
// serializes all writes. We do NOT attempt multi-process locking — bridge
|
|
15
15
|
// SDK consumers run a single process per app instance.
|
|
16
16
|
//
|
|
17
|
-
//
|
|
18
|
-
// `
|
|
19
|
-
//
|
|
20
|
-
// into
|
|
17
|
+
// Edge/browser-bundle isolation: this file loads the Node fs/path/os builtins
|
|
18
|
+
// through `loadNodeBuiltin` (a runtime-computed specifier with per-bundler
|
|
19
|
+
// ignore hints) so that even when an edge/browser bundler pulls this module
|
|
20
|
+
// into its graph it never tries to bundle or parse the Node-builtin imports —
|
|
21
|
+
// they stay native runtime imports that only ever resolve in a real Node
|
|
22
|
+
// process. (A plain dynamic import of a literal node-scheme specifier is NOT
|
|
23
|
+
// enough: webpack's edge target still parses the chunk and rejects it.)
|
|
21
24
|
import { DEFAULT_MAX_SIZE, isNodeEnv, } from './durable-storage.js';
|
|
25
|
+
// Bundler-invisible Node-builtin loader. A literal dynamic import of a
|
|
26
|
+
// node-scheme specifier trips edge/browser bundlers (Next.js middleware
|
|
27
|
+
// webpack: UnhandledSchemeError; Turbopack: middleware panic; Vite/esbuild:
|
|
28
|
+
// unresolved scheme) whenever this module is reachable in their graph — even
|
|
29
|
+
// though NodeFsStorage only ever runs in a real Node process. Routing through a
|
|
30
|
+
// runtime-computed specifier plus per-bundler ignore hints keeps these as
|
|
31
|
+
// native runtime imports the bundler never bundles or parses, while Node
|
|
32
|
+
// resolves them normally.
|
|
33
|
+
function loadNodeBuiltin(specifier) {
|
|
34
|
+
return import(
|
|
35
|
+
/* webpackIgnore: true */ /* turbopackIgnore: true */ /* @vite-ignore */ specifier);
|
|
36
|
+
}
|
|
22
37
|
export class NodeFsStorage {
|
|
23
38
|
maxSize;
|
|
24
39
|
dirPromise;
|
|
@@ -150,17 +165,17 @@ export class NodeFsStorage {
|
|
|
150
165
|
}
|
|
151
166
|
_fs() {
|
|
152
167
|
if (!this.fsP)
|
|
153
|
-
this.fsP =
|
|
168
|
+
this.fsP = loadNodeBuiltin('node:fs/promises');
|
|
154
169
|
return this.fsP;
|
|
155
170
|
}
|
|
156
171
|
_path() {
|
|
157
172
|
if (!this.pathP)
|
|
158
|
-
this.pathP =
|
|
173
|
+
this.pathP = loadNodeBuiltin('node:path');
|
|
159
174
|
return this.pathP;
|
|
160
175
|
}
|
|
161
176
|
_os() {
|
|
162
177
|
if (!this.osP)
|
|
163
|
-
this.osP =
|
|
178
|
+
this.osP = loadNodeBuiltin('node:os');
|
|
164
179
|
return this.osP;
|
|
165
180
|
}
|
|
166
181
|
_dir() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-fs-storage.js","sourceRoot":"","sources":["../../../src/usage/storage/node-fs-storage.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,2EAA2E;AAC3E,iDAAiD;AACjD,EAAE;AACF,uBAAuB;AACvB,yDAAyD;AACzD,4EAA4E;AAC5E,yEAAyE;AACzE,6EAA6E;AAC7E,sCAAsC;AACtC,mEAAmE;AACnE,6EAA6E;AAC7E,8EAA8E;AAC9E,2DAA2D;AAC3D,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"file":"node-f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I,CAAC,KAAK,EAAE,CAAC;gBAChC,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;gBAClF,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBACzC,OAAO,GAAG,CAAC;YACb,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulr-group/bridge-auth-core",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.5",
|
|
4
4
|
"description": "Framework-agnostic auth core for Bridge platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./backend": {
|
|
15
|
+
"types": "./dist/backend/index.d.ts",
|
|
16
|
+
"import": "./dist/backend/index.js",
|
|
17
|
+
"default": "./dist/backend/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
"*": {
|
|
22
|
+
"backend": [
|
|
23
|
+
"./dist/backend/index.d.ts"
|
|
24
|
+
]
|
|
13
25
|
}
|
|
14
26
|
},
|
|
15
27
|
"files": [
|