@venizia/ignis 0.4.7-5 → 0.4.7-7
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/esm/common/environments.d.ts +1 -1
- package/dist/esm/common/environments.d.ts.map +1 -1
- package/dist/esm/common/environments.js +1 -1
- package/dist/esm/common/environments.js.map +1 -1
- package/dist/esm/common/index.d.ts +0 -1
- package/dist/esm/common/index.d.ts.map +1 -1
- package/dist/esm/common/index.js +0 -1
- package/dist/esm/common/index.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +3 -4
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +2 -2
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.js +1 -1
- package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.js.map +1 -1
- package/dist/presets/app/files/.configs/builders/Dockerfile +1 -1
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +9 -85
- package/dist/esm/common/constants.d.ts +0 -10
- package/dist/esm/common/constants.d.ts.map +0 -1
- package/dist/esm/common/constants.js +0 -11
- package/dist/esm/common/constants.js.map +0 -1
- package/dist/esm/connectors/meilisearch/index.d.ts +0 -3
- package/dist/esm/connectors/meilisearch/index.d.ts.map +0 -1
- package/dist/esm/connectors/meilisearch/index.js +0 -3
- package/dist/esm/connectors/meilisearch/index.js.map +0 -1
- package/dist/esm/connectors/postgres/drivers/node-postgres.d.ts +0 -3
- package/dist/esm/connectors/postgres/drivers/node-postgres.d.ts.map +0 -1
- package/dist/esm/connectors/postgres/drivers/node-postgres.js +0 -3
- package/dist/esm/connectors/postgres/drivers/node-postgres.js.map +0 -1
- package/dist/esm/connectors/postgres/drivers/pglite.d.ts +0 -3
- package/dist/esm/connectors/postgres/drivers/pglite.d.ts.map +0 -1
- package/dist/esm/connectors/postgres/drivers/pglite.js +0 -3
- package/dist/esm/connectors/postgres/drivers/pglite.js.map +0 -1
- package/dist/esm/connectors/postgres/drivers/postgres-js.d.ts +0 -3
- package/dist/esm/connectors/postgres/drivers/postgres-js.d.ts.map +0 -1
- package/dist/esm/connectors/postgres/drivers/postgres-js.js +0 -3
- package/dist/esm/connectors/postgres/drivers/postgres-js.js.map +0 -1
- package/dist/esm/connectors/postgres/index.d.ts +0 -3
- package/dist/esm/connectors/postgres/index.d.ts.map +0 -1
- package/dist/esm/connectors/postgres/index.js +0 -3
- package/dist/esm/connectors/postgres/index.js.map +0 -1
- package/dist/esm/connectors/postgres/supabase/index.d.ts +0 -3
- package/dist/esm/connectors/postgres/supabase/index.d.ts.map +0 -1
- package/dist/esm/connectors/postgres/supabase/index.js +0 -3
- package/dist/esm/connectors/postgres/supabase/index.js.map +0 -1
- package/dist/esm/connectors/relational/index.d.ts +0 -3
- package/dist/esm/connectors/relational/index.d.ts.map +0 -1
- package/dist/esm/connectors/relational/index.js +0 -3
- package/dist/esm/connectors/relational/index.js.map +0 -1
- package/dist/esm/connectors/search/controllers/index.d.ts +0 -3
- package/dist/esm/connectors/search/controllers/index.d.ts.map +0 -1
- package/dist/esm/connectors/search/controllers/index.js +0 -3
- package/dist/esm/connectors/search/controllers/index.js.map +0 -1
- package/dist/esm/connectors/search/index.d.ts +0 -3
- package/dist/esm/connectors/search/index.d.ts.map +0 -1
- package/dist/esm/connectors/search/index.js +0 -3
- package/dist/esm/connectors/search/index.js.map +0 -1
- package/dist/esm/connectors/sqlite/drivers/libsql.d.ts +0 -3
- package/dist/esm/connectors/sqlite/drivers/libsql.d.ts.map +0 -1
- package/dist/esm/connectors/sqlite/drivers/libsql.js +0 -3
- package/dist/esm/connectors/sqlite/drivers/libsql.js.map +0 -1
- package/dist/esm/connectors/sqlite/index.d.ts +0 -3
- package/dist/esm/connectors/sqlite/index.d.ts.map +0 -1
- package/dist/esm/connectors/sqlite/index.js +0 -3
- package/dist/esm/connectors/sqlite/index.js.map +0 -1
- package/dist/esm/connectors/typesense/controllers/index.d.ts +0 -3
- package/dist/esm/connectors/typesense/controllers/index.d.ts.map +0 -1
- package/dist/esm/connectors/typesense/controllers/index.js +0 -3
- package/dist/esm/connectors/typesense/controllers/index.js.map +0 -1
- package/dist/esm/connectors/typesense/index.d.ts +0 -3
- package/dist/esm/connectors/typesense/index.d.ts.map +0 -1
- package/dist/esm/connectors/typesense/index.js +0 -3
- package/dist/esm/connectors/typesense/index.js.map +0 -1
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* `ALLOW_EMPTY_ENV_VALUE` to `false` or `0`.
|
|
22
22
|
*/
|
|
23
23
|
export declare class EnvironmentKeys {
|
|
24
|
-
/**
|
|
24
|
+
/** The startup banner. */
|
|
25
25
|
static readonly APP_ENV_APPLICATION_NAME = "APP_ENV_APPLICATION_NAME";
|
|
26
26
|
/** `DateUtility`'s default zone and the startup banner. */
|
|
27
27
|
static readonly APP_ENV_APPLICATION_TIMEZONE = "APP_ENV_APPLICATION_TIMEZONE";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../../src/common/environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,eAAe;IAG1B,
|
|
1
|
+
{"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../../../src/common/environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,eAAe;IAG1B,0BAA0B;IAC1B,MAAM,CAAC,QAAQ,CAAC,wBAAwB,8BAA8B;IACtE,2DAA2D;IAC3D,MAAM,CAAC,QAAQ,CAAC,4BAA4B,kCAAkC;IAC9E,yFAAyF;IACzF,MAAM,CAAC,QAAQ,CAAC,0BAA0B,gCAAgC;IAC1E,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,CAAC,mBAAmB,yBAAyB;IAC5D,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,CAAC,mBAAmB,yBAAyB;IAI5D,MAAM,CAAC,QAAQ,CAAC,0BAA0B,gCAAgC;IAC1E,MAAM,CAAC,QAAQ,CAAC,yBAAyB,+BAA+B;IAExE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,wBAAwB;IAC1D,MAAM,CAAC,QAAQ,CAAC,sBAAsB,4BAA4B;IAElE,MAAM,CAAC,QAAQ,CAAC,wBAAwB,8BAA8B;IAEtE,MAAM,CAAC,QAAQ,CAAC,qBAAqB,2BAA2B;IAChE,MAAM,CAAC,QAAQ,CAAC,qBAAqB,2BAA2B;IAChE,MAAM,CAAC,QAAQ,CAAC,yBAAyB,+BAA+B;IACxE,MAAM,CAAC,QAAQ,CAAC,yBAAyB,+BAA+B;IACxE,MAAM,CAAC,QAAQ,CAAC,yBAAyB,+BAA+B;CACzE"}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
export class EnvironmentKeys {
|
|
24
24
|
// --- Read by the framework -------------------------------------------------------------------
|
|
25
|
-
/**
|
|
25
|
+
/** The startup banner. */
|
|
26
26
|
static { this.APP_ENV_APPLICATION_NAME = 'APP_ENV_APPLICATION_NAME'; }
|
|
27
27
|
/** `DateUtility`'s default zone and the startup banner. */
|
|
28
28
|
static { this.APP_ENV_APPLICATION_TIMEZONE = 'APP_ENV_APPLICATION_TIMEZONE'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../src/common/environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAe;IAC1B,gGAAgG;IAEhG,
|
|
1
|
+
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../src/common/environments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAe;IAC1B,gGAAgG;IAEhG,0BAA0B;aACV,6BAAwB,GAAG,0BAA0B,CAAC;IACtE,2DAA2D;aAC3C,iCAA4B,GAAG,8BAA8B,CAAC;IAC9E,yFAAyF;aACzE,+BAA0B,GAAG,4BAA4B,CAAC;IAC1E,+DAA+D;aAC/C,wBAAmB,GAAG,qBAAqB,CAAC;IAC5D,+DAA+D;aAC/C,wBAAmB,GAAG,qBAAqB,CAAC;IAE5D,kGAAkG;aAElF,+BAA0B,GAAG,4BAA4B,CAAC;aAC1D,8BAAyB,GAAG,2BAA2B,CAAC;aAExD,uBAAkB,GAAG,oBAAoB,CAAC;aAC1C,2BAAsB,GAAG,wBAAwB,CAAC;aAElD,6BAAwB,GAAG,0BAA0B,CAAC;aAEtD,0BAAqB,GAAG,uBAAuB,CAAC;aAChD,0BAAqB,GAAG,uBAAuB,CAAC;aAChD,8BAAyB,GAAG,2BAA2B,CAAC;aACxD,8BAAyB,GAAG,2BAA2B,CAAC;aACxD,8BAAyB,GAAG,2BAA2B,CAAC","sourcesContent":["/**\n * Environment variable names.\n *\n * The two groups mean different things and the split is load-bearing: a name in the second group\n * is a CONVENTION an application reads for itself, and setting it changes nothing in IGNIS. Every\n * name here was once presented as framework configuration, which is how a deployment came to set\n * `APP_ENV_APPLICATION_DS_MIGRATION` against a framework that read `APP_ENV_DS_MIGRATION` - and\n * neither name selected anything, so both are gone.\n *\n * A name earns its place by having a reader. `APP_ENV_OAUTH2_VIEW_FOLDER` and\n * `APP_ENV_DATASOURCE_NAME` had none in either IGNIS or its consumers, only entries in `.env` files\n * nobody consulted, so they went the same way. Before adding one here, know who reads it.\n *\n * Two framework variables are deliberately ABSENT from this class, and adding them would be a trap:\n * `APPLICATION_ENV_PREFIX` and `ALLOW_EMPTY_ENV_VALUE`. Neither carries the `APP_ENV` prefix, so\n * `applicationEnvironment` never holds them - a read through `AppEnvs.get()` would answer `undefined`\n * forever. `APPLICATION_ENV_PREFIX` could not go through it in any case: it is what builds the\n * filter. Both are bootstrap variables and are read straight off `process.env`, which is the one\n * legitimate exception to \"do not read process.env directly\". Neither has to be declared or set:\n * the prefix defaults to `APP_ENV`, and empty values are allowed unless you set\n * `ALLOW_EMPTY_ENV_VALUE` to `false` or `0`.\n */\nexport class EnvironmentKeys {\n // --- Read by the framework -------------------------------------------------------------------\n\n /** The startup banner. */\n static readonly APP_ENV_APPLICATION_NAME = 'APP_ENV_APPLICATION_NAME';\n /** `DateUtility`'s default zone and the startup banner. */\n static readonly APP_ENV_APPLICATION_TIMEZONE = 'APP_ENV_APPLICATION_TIMEZONE';\n /** Set it to enable rotating file logs; unset means console. Also the startup banner. */\n static readonly APP_ENV_LOGGER_FOLDER_PATH = 'APP_ENV_LOGGER_FOLDER_PATH';\n /** Fallback host when `IApplicationConfigs.host` is absent. */\n static readonly APP_ENV_SERVER_HOST = 'APP_ENV_SERVER_HOST';\n /** Fallback port when `IApplicationConfigs.port` is absent. */\n static readonly APP_ENV_SERVER_PORT = 'APP_ENV_SERVER_PORT';\n\n // --- Convention only: nothing in IGNIS reads these ---------------------------------------------\n\n static readonly APP_ENV_APPLICATION_SECRET = 'APP_ENV_APPLICATION_SECRET';\n static readonly APP_ENV_APPLICATION_ROLES = 'APP_ENV_APPLICATION_ROLES';\n\n static readonly APP_ENV_JWT_SECRET = 'APP_ENV_JWT_SECRET';\n static readonly APP_ENV_JWT_EXPIRES_IN = 'APP_ENV_JWT_EXPIRES_IN';\n\n static readonly APP_ENV_SERVER_BASE_PATH = 'APP_ENV_SERVER_BASE_PATH';\n\n static readonly APP_ENV_POSTGRES_HOST = 'APP_ENV_POSTGRES_HOST';\n static readonly APP_ENV_POSTGRES_PORT = 'APP_ENV_POSTGRES_PORT';\n static readonly APP_ENV_POSTGRES_USERNAME = 'APP_ENV_POSTGRES_USERNAME';\n static readonly APP_ENV_POSTGRES_PASSWORD = 'APP_ENV_POSTGRES_PASSWORD';\n static readonly APP_ENV_POSTGRES_DATABASE = 'APP_ENV_POSTGRES_DATABASE';\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,gBAAgB,CAAC"}
|
package/dist/esm/common/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,cAAc,uBAAuB,CAAC;AAEtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,cAAc,uBAAuB,CAAC;AAEtC,cAAc,gBAAgB,CAAC","sourcesContent":["// `bindings.ts`, `error-codes.ts` and `statuses.ts` moved to the kernel.\nexport * from '@venizia/ignis-kernel';\n\nexport * from './environments';\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AESAlgorithmType
|
|
1
|
+
import type { AESAlgorithmType } from '@venizia/ignis-helpers';
|
|
2
|
+
import { AES } from '@venizia/ignis-helpers';
|
|
2
3
|
import type { ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
3
4
|
import type { IJWTIssueClaims, IJWTSignOptions, IJWTTokenPayload, IPayloadFieldCodec, TContext, TGetTokenExpiresFn } from '@venizia/ignis-kernel';
|
|
4
5
|
import { BaseService } from '@venizia/ignis-kernel';
|
|
@@ -8,7 +9,7 @@ import type { JWTPayload, JWTVerifyResult, SignJWT } from 'jose';
|
|
|
8
9
|
export declare abstract class AbstractBearerTokenService<E extends Env = Env> extends BaseService {
|
|
9
10
|
/** Standard JWT fields that are never encrypted. */
|
|
10
11
|
static readonly JWT_COMMON_FIELDS: Set<keyof JWTPayload>;
|
|
11
|
-
protected aes:
|
|
12
|
+
protected aes: AES | null;
|
|
12
13
|
protected applicationSecret: string | null;
|
|
13
14
|
protected fieldCodecs: Map<string, IPayloadFieldCodec>;
|
|
14
15
|
/** Configured `iss` / `aud`. Authoritative over anything the payload carries. */
|
|
@@ -18,8 +19,6 @@ export declare abstract class AbstractBearerTokenService<E extends Env = Env> ex
|
|
|
18
19
|
aesAlgorithm?: AESAlgorithmType;
|
|
19
20
|
applicationSecret?: string;
|
|
20
21
|
fieldCodecs?: IPayloadFieldCodec[];
|
|
21
|
-
/** Overrides the cipher. Pass `LegacyAES` to keep reading tokens issued before the PBKDF2 envelope; `aesAlgorithm` is then the cipher's own concern and is ignored here. */
|
|
22
|
-
cipher?: IPayloadCipher;
|
|
23
22
|
sign?: IJWTSignOptions;
|
|
24
23
|
}): void;
|
|
25
24
|
extractCredentials(context: TContext<E, string>): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/abstract.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"abstract.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/abstract.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAwC,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEjE,gGAAgG;AAChG,8BAAsB,0BAA0B,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAE,SAAQ,WAAW;IACvF,oDAAoD;IACpD,MAAM,CAAC,QAAQ,CAAC,iBAAiB,wBAQ9B;IAEH,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAQ;IACjC,SAAS,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAClD,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAa;IAEnE,iFAAiF;IACjF,SAAS,CAAC,WAAW,EAAE,eAAe,GAAG,IAAI,CAAQ;IAErD,mIAAmI;IACnI,SAAS,CAAC,0BAA0B,CAAC,IAAI,EAAE;QACzC,YAAY,CAAC,EAAE,gBAAgB,CAAC;QAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;QACnC,IAAI,CAAC,EAAE,eAAe,CAAC;KACxB,GAAG,IAAI;IAmBR,kBAAkB,CAAC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AAC,SAAS,CAAC,IAAI,EAAE;QACvB,OAAO,EAAE,gBAAgB,CAAC;QAC1B,iBAAiB,EAAE,kBAAkB,CAAC;QACtC,MAAM,CAAC,EAAE,eAAe,CAAC;KAC1B,GAAG,OAAO,CAAC,OAAO,CAAC;IAEpB,SAAS,CAAC,QAAQ,CAAC,aAAa,IAAI,cAAc,CAAC,UAAU,GAAG,SAAS,CAAC;IAE1E,SAAS,CAAC,QAAQ,CAAC,wBAAwB,IAAI,kBAAkB;CAClE"}
|
|
@@ -24,7 +24,7 @@ export class AbstractBearerTokenService extends BaseService {
|
|
|
24
24
|
]); }
|
|
25
25
|
/** Configures AES payload encryption and field codecs. Both aesAlgorithm and applicationSecret required to activate encryption. */
|
|
26
26
|
configurePayloadEncryption(opts) {
|
|
27
|
-
const { aesAlgorithm = 'aes-256-cbc', applicationSecret, fieldCodecs,
|
|
27
|
+
const { aesAlgorithm = 'aes-256-cbc', applicationSecret, fieldCodecs, sign } = opts;
|
|
28
28
|
this.signOptions = sign ?? null;
|
|
29
29
|
if (fieldCodecs) {
|
|
30
30
|
for (const codec of fieldCodecs) {
|
|
@@ -34,7 +34,7 @@ export class AbstractBearerTokenService extends BaseService {
|
|
|
34
34
|
if (!applicationSecret) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
this.aes =
|
|
37
|
+
this.aes = AES.withAlgorithm(aesAlgorithm);
|
|
38
38
|
this.applicationSecret = applicationSecret;
|
|
39
39
|
}
|
|
40
40
|
extractCredentials(context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.service.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/abstract.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AASvD,OAAO,EAAE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;YACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;gBACrB,MAAM,EAAE,IAAI,CAAC,iBAAiB;aAC/B,CAAC,CAAC;YAEH,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;QACzF,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC","sourcesContent":["import type { AESAlgorithmType, IPayloadCipher } from '@venizia/ignis-helpers';\nimport { AES } from '@venizia/ignis-helpers';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type {\n IJWTIssueClaims,\n IJWTSignOptions,\n IJWTTokenPayload,\n IPayloadFieldCodec,\n TContext,\n TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { Authentication, AuthenticationErrors, BaseService } from '@venizia/ignis-kernel';\nimport type { Env } from 'hono';\nimport type { JWTPayload, JWTVerifyResult, SignJWT } from 'jose';\n\n/** Abstract base for Bearer-token services (JWS, JWKS) with optional AES payload encryption. */\nexport abstract class AbstractBearerTokenService<E extends Env = Env> extends BaseService {\n /** Standard JWT fields that are never encrypted. */\n static readonly JWT_COMMON_FIELDS = new Set<keyof JWTPayload>([\n 'iss',\n 'sub',\n 'aud',\n 'jti',\n 'nbf',\n 'exp',\n 'iat',\n ]);\n\n protected aes: IPayloadCipher | null = null;\n protected applicationSecret: string | null = null;\n protected fieldCodecs: Map<string, IPayloadFieldCodec> = new Map();\n\n /** Configured `iss` / `aud`. Authoritative over anything the payload carries. */\n protected signOptions: IJWTSignOptions | null = null;\n\n /** Configures AES payload encryption and field codecs. Both aesAlgorithm and applicationSecret required to activate encryption. */\n protected configurePayloadEncryption(opts: {\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n /** Overrides the cipher. Pass `LegacyAES` to keep reading tokens issued before the PBKDF2 envelope; `aesAlgorithm` is then the cipher's own concern and is ignored here. */\n cipher?: IPayloadCipher;\n sign?: IJWTSignOptions;\n }): void {\n const { aesAlgorithm = 'aes-256-cbc', applicationSecret, fieldCodecs, cipher, sign } = opts;\n\n this.signOptions = sign ?? null;\n\n if (fieldCodecs) {\n for (const codec of fieldCodecs) {\n this.fieldCodecs.set(codec.key, codec);\n }\n }\n\n if (!applicationSecret) {\n return;\n }\n\n this.aes = cipher ?? AES.withAlgorithm(aesAlgorithm);\n this.applicationSecret = applicationSecret;\n }\n\n extractCredentials(context: TContext<E, string>): { type: string; token: string } {\n const request = context.req;\n\n const authHeaderValue = request.header('Authorization');\n if (!authHeaderValue) {\n throw getError({\n error: AuthenticationErrors.HEADER_MISSING,\n message: 'Unauthorized user! Missing authorization header',\n });\n }\n\n if (!authHeaderValue.startsWith(Authentication.TYPE_BEARER)) {\n throw getError({\n error: AuthenticationErrors.SCHEME_INVALID,\n message: 'Unauthorized user! Invalid schema of request token!',\n });\n }\n\n const parts = authHeaderValue.split(' ');\n if (parts.length !== 2) {\n throw getError({\n error: AuthenticationErrors.HEADER_MALFORMED,\n message: `Authorization header value is invalid format. It must follow the pattern: 'Bearer xx.yy.zz' where xx.yy.zz is a valid JWT token.`,\n });\n }\n\n const [tokenType, tokenValue] = parts;\n return { type: tokenType, token: tokenValue };\n }\n\n async verify(opts: { type: string; token: string }): Promise<IJWTTokenPayload> {\n const { token } = opts;\n if (!token) {\n this.logger.for(this.verify.name).error('Missing token for validating request!');\n throw getError({\n error: AuthenticationErrors.TOKEN_MISSING,\n message: '[verify] Invalid request token!',\n });\n }\n\n try {\n const result = await this.doVerify(token);\n return result;\n } catch (error) {\n // No log here - `cause` carries the reason (JWTExpired, signature mismatch) to the error handler, which logs the request once. An expired token is the caller's problem, hence `warn`.\n throw getError({\n error: AuthenticationErrors.TOKEN_INVALID,\n message: '[verify] Invalid or expired token',\n logLevel: 'warn',\n cause: error,\n });\n }\n }\n\n async generate(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn?: TGetTokenExpiresFn;\n /** Per-token registered claims. The supported way to vary `aud` / `sub`; the payload is not. */\n claims?: IJWTIssueClaims;\n }): Promise<string> {\n const { payload, claims, getTokenExpiresFn = this.getDefaultTokenExpiresFn() } = opts;\n\n if (!payload) {\n throw getError({\n error: AuthenticationErrors.TOKEN_PAYLOAD_INVALID,\n message: '[generate] Invalid token payload!',\n });\n }\n\n const signer = await this.getSigner({ payload, getTokenExpiresFn, claims });\n\n try {\n const result = await this.getSigningKey();\n const rs = await signer.sign(result);\n return rs;\n } catch (error) {\n this.logger.for(this.generate.name).error('Failed to generate token | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[generate] Failed to generate token',\n });\n }\n }\n\n protected serializeField(opts: { key: string; value: any }): string {\n const { key, value } = opts;\n const codec = this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.serialize({ value });\n }\n\n return JSON.stringify(value);\n }\n\n async encryptPayload(payload: IJWTTokenPayload): Promise<Record<string, any>> {\n if (!this.aes || !this.applicationSecret) {\n return payload;\n }\n\n const rs: Record<string, string> = {};\n\n const keys = Object.keys(payload);\n for (const key of keys) {\n const value = payload[key];\n\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = value;\n continue;\n }\n\n // NOTE: Skip undefined or null values because they cannot be encrypted\n if (value === undefined || value === null) {\n continue;\n }\n\n const encryptedKey = await this.aes.encrypt({\n message: key,\n secret: this.applicationSecret,\n });\n\n const serialized = this.serializeField({ key, value });\n\n const encryptedValue = await this.aes.encrypt({\n message: serialized,\n secret: this.applicationSecret,\n });\n rs[encryptedKey] = encryptedValue;\n }\n\n return rs;\n }\n\n protected deserializeField(opts: { key: string; value: string }) {\n const { key, value } = opts;\n const codec = this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.deserialize({ raw: value });\n }\n\n return JSON.parse(value);\n }\n\n /**\n * Stamps the configured `iss` / `aud` onto a signer, plus any per-token claims the caller passed.\n *\n * The configured value is AUTHORITATIVE. `iss` and `aud` are in `JWT_COMMON_FIELDS`, so they ride\n * through the AES envelope in the clear and an application-shaped payload can carry them - an\n * issuer identity any payload could overwrite would not be an identity. A conflicting payload\n * claim is overwritten and reported.\n *\n * Per-token audience is an explicit argument rather than a smuggled payload key, so the caller\n * that legitimately needs one says so.\n */\n protected applySignClaims(opts: {\n signer: SignJWT;\n payload: Record<string, any>;\n claims?: IJWTIssueClaims;\n }): SignJWT {\n const { signer, payload, claims } = opts;\n const configured = this.signOptions;\n\n const issuer = claims?.issuer ?? configured?.issuer;\n const audience = claims?.audience ?? configured?.audience;\n\n const logger = this.logger.for(this.applySignClaims.name);\n\n if (issuer !== undefined) {\n if (payload.iss !== undefined && payload.iss !== issuer) {\n logger.warn(\n 'Payload iss overridden by the configured issuer | payload: %s | configured: %s',\n payload.iss,\n issuer,\n );\n }\n\n signer.setIssuer(issuer);\n }\n\n if (audience !== undefined) {\n if (payload.aud !== undefined) {\n logger.warn('Payload aud overridden | payload: %j | applied: %j', payload.aud, audience);\n }\n\n signer.setAudience(audience);\n }\n\n if (claims?.subject !== undefined) {\n signer.setSubject(claims.subject);\n }\n\n if (claims?.jwtId !== undefined) {\n signer.setJti(claims.jwtId);\n }\n\n return signer;\n }\n\n async decryptPayload(opts: {\n result: JWTVerifyResult<IJWTTokenPayload>;\n }): Promise<IJWTTokenPayload> {\n const { payload, protectedHeader } = opts.result;\n\n if (!this.aes || !this.applicationSecret) {\n return payload as IJWTTokenPayload;\n }\n\n this.logger\n .for(this.decryptPayload.name)\n .debug('JWT Token | payload: %j | header: %j', payload, protectedHeader);\n\n const rs: any = {};\n for (const key in payload) {\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = payload[key];\n continue;\n }\n\n const decryptedKey = await this.aes.decrypt({\n message: key,\n secret: this.applicationSecret,\n });\n const decryptedValue = await this.aes.decrypt({\n message: payload[key],\n secret: this.applicationSecret,\n });\n\n rs[decryptedKey] = this.deserializeField({ key: decryptedKey, value: decryptedValue });\n }\n\n return rs;\n }\n\n protected abstract doVerify(token: string): Promise<IJWTTokenPayload>;\n\n abstract getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }): Promise<SignJWT>;\n\n protected abstract getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey>;\n\n protected abstract getDefaultTokenExpiresFn(): TGetTokenExpiresFn;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstract.service.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/abstract.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AASvD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI1F,gGAAgG;AAChG,MAAM,OAAgB,0BAAgD,SAAQ,WAAW;IAAzF;;QAYY,QAAG,GAAe,IAAI,CAAC;QACvB,sBAAiB,GAAkB,IAAI,CAAC;QACxC,gBAAW,GAAoC,IAAI,GAAG,EAAE,CAAC;QAEnE,iFAAiF;QACvE,gBAAW,GAA2B,IAAI,CAAC;IAgRvD,CAAC;IAhSC,oDAAoD;aACpC,sBAAiB,GAAG,IAAI,GAAG,CAAmB;QAC5D,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;KACN,CAAC,AAR+B,CAQ9B;IASH,mIAAmI;IACzH,0BAA0B,CAAC,IAKpC;QACC,MAAM,EAAE,YAAY,GAAG,aAAa,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AAM,CAAC;QAEjD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzC,OAAO,OAA2B,CAAC;QACrC,CAAC;QAED,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;aAC7B,KAAK,CAAC,sCAAsC,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAE3E,MAAM,EAAE,GAAQ,EAAE,CAAC;QACnB,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1D,EAAE,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBACvB,SAAS;YACX,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC1C,OAAO,EAAE,GAAG;gBACZ,MAAM,EAAE,IAAI,CAAC,iBAAiB;aAC/B,CAAC,CAAC;YACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;gBACrB,MAAM,EAAE,IAAI,CAAC,iBAAiB;aAC/B,CAAC,CAAC;YAEH,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;QACzF,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC","sourcesContent":["import type { AESAlgorithmType } from '@venizia/ignis-helpers';\nimport { AES } from '@venizia/ignis-helpers';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type {\n IJWTIssueClaims,\n IJWTSignOptions,\n IJWTTokenPayload,\n IPayloadFieldCodec,\n TContext,\n TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { Authentication, AuthenticationErrors, BaseService } from '@venizia/ignis-kernel';\nimport type { Env } from 'hono';\nimport type { JWTPayload, JWTVerifyResult, SignJWT } from 'jose';\n\n/** Abstract base for Bearer-token services (JWS, JWKS) with optional AES payload encryption. */\nexport abstract class AbstractBearerTokenService<E extends Env = Env> extends BaseService {\n /** Standard JWT fields that are never encrypted. */\n static readonly JWT_COMMON_FIELDS = new Set<keyof JWTPayload>([\n 'iss',\n 'sub',\n 'aud',\n 'jti',\n 'nbf',\n 'exp',\n 'iat',\n ]);\n\n protected aes: AES | null = null;\n protected applicationSecret: string | null = null;\n protected fieldCodecs: Map<string, IPayloadFieldCodec> = new Map();\n\n /** Configured `iss` / `aud`. Authoritative over anything the payload carries. */\n protected signOptions: IJWTSignOptions | null = null;\n\n /** Configures AES payload encryption and field codecs. Both aesAlgorithm and applicationSecret required to activate encryption. */\n protected configurePayloadEncryption(opts: {\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n sign?: IJWTSignOptions;\n }): void {\n const { aesAlgorithm = 'aes-256-cbc', applicationSecret, fieldCodecs, sign } = opts;\n\n this.signOptions = sign ?? null;\n\n if (fieldCodecs) {\n for (const codec of fieldCodecs) {\n this.fieldCodecs.set(codec.key, codec);\n }\n }\n\n if (!applicationSecret) {\n return;\n }\n\n this.aes = AES.withAlgorithm(aesAlgorithm);\n this.applicationSecret = applicationSecret;\n }\n\n extractCredentials(context: TContext<E, string>): { type: string; token: string } {\n const request = context.req;\n\n const authHeaderValue = request.header('Authorization');\n if (!authHeaderValue) {\n throw getError({\n error: AuthenticationErrors.HEADER_MISSING,\n message: 'Unauthorized user! Missing authorization header',\n });\n }\n\n if (!authHeaderValue.startsWith(Authentication.TYPE_BEARER)) {\n throw getError({\n error: AuthenticationErrors.SCHEME_INVALID,\n message: 'Unauthorized user! Invalid schema of request token!',\n });\n }\n\n const parts = authHeaderValue.split(' ');\n if (parts.length !== 2) {\n throw getError({\n error: AuthenticationErrors.HEADER_MALFORMED,\n message: `Authorization header value is invalid format. It must follow the pattern: 'Bearer xx.yy.zz' where xx.yy.zz is a valid JWT token.`,\n });\n }\n\n const [tokenType, tokenValue] = parts;\n return { type: tokenType, token: tokenValue };\n }\n\n async verify(opts: { type: string; token: string }): Promise<IJWTTokenPayload> {\n const { token } = opts;\n if (!token) {\n this.logger.for(this.verify.name).error('Missing token for validating request!');\n throw getError({\n error: AuthenticationErrors.TOKEN_MISSING,\n message: '[verify] Invalid request token!',\n });\n }\n\n try {\n const result = await this.doVerify(token);\n return result;\n } catch (error) {\n // No log here - `cause` carries the reason (JWTExpired, signature mismatch) to the error handler, which logs the request once. An expired token is the caller's problem, hence `warn`.\n throw getError({\n error: AuthenticationErrors.TOKEN_INVALID,\n message: '[verify] Invalid or expired token',\n logLevel: 'warn',\n cause: error,\n });\n }\n }\n\n async generate(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn?: TGetTokenExpiresFn;\n /** Per-token registered claims. The supported way to vary `aud` / `sub`; the payload is not. */\n claims?: IJWTIssueClaims;\n }): Promise<string> {\n const { payload, claims, getTokenExpiresFn = this.getDefaultTokenExpiresFn() } = opts;\n\n if (!payload) {\n throw getError({\n error: AuthenticationErrors.TOKEN_PAYLOAD_INVALID,\n message: '[generate] Invalid token payload!',\n });\n }\n\n const signer = await this.getSigner({ payload, getTokenExpiresFn, claims });\n\n try {\n const result = await this.getSigningKey();\n const rs = await signer.sign(result);\n return rs;\n } catch (error) {\n this.logger.for(this.generate.name).error('Failed to generate token | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[generate] Failed to generate token',\n });\n }\n }\n\n protected serializeField(opts: { key: string; value: any }): string {\n const { key, value } = opts;\n const codec = this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.serialize({ value });\n }\n\n return JSON.stringify(value);\n }\n\n async encryptPayload(payload: IJWTTokenPayload): Promise<Record<string, any>> {\n if (!this.aes || !this.applicationSecret) {\n return payload;\n }\n\n const rs: Record<string, string> = {};\n\n const keys = Object.keys(payload);\n for (const key of keys) {\n const value = payload[key];\n\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = value;\n continue;\n }\n\n // NOTE: Skip undefined or null values because they cannot be encrypted\n if (value === undefined || value === null) {\n continue;\n }\n\n const encryptedKey = await this.aes.encrypt({\n message: key,\n secret: this.applicationSecret,\n });\n\n const serialized = this.serializeField({ key, value });\n\n const encryptedValue = await this.aes.encrypt({\n message: serialized,\n secret: this.applicationSecret,\n });\n rs[encryptedKey] = encryptedValue;\n }\n\n return rs;\n }\n\n protected deserializeField(opts: { key: string; value: string }) {\n const { key, value } = opts;\n const codec = this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.deserialize({ raw: value });\n }\n\n return JSON.parse(value);\n }\n\n /**\n * Stamps the configured `iss` / `aud` onto a signer, plus any per-token claims the caller passed.\n *\n * The configured value is AUTHORITATIVE. `iss` and `aud` are in `JWT_COMMON_FIELDS`, so they ride\n * through the AES envelope in the clear and an application-shaped payload can carry them - an\n * issuer identity any payload could overwrite would not be an identity. A conflicting payload\n * claim is overwritten and reported.\n *\n * Per-token audience is an explicit argument rather than a smuggled payload key, so the caller\n * that legitimately needs one says so.\n */\n protected applySignClaims(opts: {\n signer: SignJWT;\n payload: Record<string, any>;\n claims?: IJWTIssueClaims;\n }): SignJWT {\n const { signer, payload, claims } = opts;\n const configured = this.signOptions;\n\n const issuer = claims?.issuer ?? configured?.issuer;\n const audience = claims?.audience ?? configured?.audience;\n\n const logger = this.logger.for(this.applySignClaims.name);\n\n if (issuer !== undefined) {\n if (payload.iss !== undefined && payload.iss !== issuer) {\n logger.warn(\n 'Payload iss overridden by the configured issuer | payload: %s | configured: %s',\n payload.iss,\n issuer,\n );\n }\n\n signer.setIssuer(issuer);\n }\n\n if (audience !== undefined) {\n if (payload.aud !== undefined) {\n logger.warn('Payload aud overridden | payload: %j | applied: %j', payload.aud, audience);\n }\n\n signer.setAudience(audience);\n }\n\n if (claims?.subject !== undefined) {\n signer.setSubject(claims.subject);\n }\n\n if (claims?.jwtId !== undefined) {\n signer.setJti(claims.jwtId);\n }\n\n return signer;\n }\n\n async decryptPayload(opts: {\n result: JWTVerifyResult<IJWTTokenPayload>;\n }): Promise<IJWTTokenPayload> {\n const { payload, protectedHeader } = opts.result;\n\n if (!this.aes || !this.applicationSecret) {\n return payload as IJWTTokenPayload;\n }\n\n this.logger\n .for(this.decryptPayload.name)\n .debug('JWT Token | payload: %j | header: %j', payload, protectedHeader);\n\n const rs: any = {};\n for (const key in payload) {\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = payload[key];\n continue;\n }\n\n const decryptedKey = await this.aes.decrypt({\n message: key,\n secret: this.applicationSecret,\n });\n const decryptedValue = await this.aes.decrypt({\n message: payload[key],\n secret: this.applicationSecret,\n });\n\n rs[decryptedKey] = this.deserializeField({ key: decryptedKey, value: decryptedValue });\n }\n\n return rs;\n }\n\n protected abstract doVerify(token: string): Promise<IJWTTokenPayload>;\n\n abstract getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }): Promise<SignJWT>;\n\n protected abstract getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey>;\n\n protected abstract getDefaultTokenExpiresFn(): TGetTokenExpiresFn;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issuer.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/issuer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE1F,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAIrB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAG3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,qBAAa,sBAAsB,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAE,SAAQ,wBAAwB,CAAC,CAAC,CAAC;IAOxF,SAAS,CAAC,OAAO,EAAE,kBAAkB;IANvC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,SAAS,GAAG,UAAU,CAAC,CAAQ;IAC/D,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,SAAS,GAAG,UAAU,CAAC,CAAQ;IAC9D,SAAS,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,IAAI,CAAQ;gBAIlC,OAAO,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"issuer.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/issuer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE1F,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAIrB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAG3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,qBAAa,sBAAsB,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAE,SAAQ,wBAAwB,CAAC,CAAC,CAAC;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AAE,CAAC;CAI/C"}
|
|
@@ -28,7 +28,6 @@ let JWKSIssuerTokenService = JWKSIssuerTokenService_1 = class JWKSIssuerTokenSer
|
|
|
28
28
|
aesAlgorithm: this.options.aesAlgorithm,
|
|
29
29
|
applicationSecret: this.options.applicationSecret,
|
|
30
30
|
fieldCodecs: this.options.fieldCodecs,
|
|
31
|
-
cipher: this.options.cipher,
|
|
32
31
|
sign: this.options.sign,
|
|
33
32
|
});
|
|
34
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issuer.service.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/issuer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAuC,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAIvB,MAAM,EACN,cAAc,EACd,cAAc,GAEf,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,IAAa,sBAAsB,8BAAnC,MAAa,sBAA4C,SAAQ,wBAA2B;IAK1F,YAEE,OAAqC;QAErC,KAAK,CAAC,EAAE,KAAK,EAAE,wBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;QAFpC,YAAO,GAAP,OAAO,CAAoB;QAN7B,eAAU,GAAsC,IAAI,CAAC;QACrD,cAAS,GAAsC,IAAI,CAAC;QACpD,SAAI,GAA2B,IAAI,CAAC;QAQ5C,IAAI,CAAC,0BAA0B,CAAC;YAC9B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;YACvC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;YACjD,WAAW,EAAE,IA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AAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACxC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EAAE,iFAAiF;aAC3F,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,IAAK,CAAC;IACpB,CAAC;CACF,CAAA;AAhOY,sBAAsB;IAM9B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAA;;GAN7C,sBAAsB,CAgOlC","sourcesContent":["import { HTTP, type TNullable, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWKSIssuerOptions,\n type IJWTIssueClaims,\n type IJWTTokenPayload,\n inject,\n JWKSKeyDrivers,\n JWKSKeyFormats,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport type { CryptoKey, JWK } from 'jose';\nimport { readFile } from 'node:fs/promises';\nimport { JoseLoader } from '../../jose-loader';\nimport { AbstractJWKSTokenService } from './abstract.service';\n\nexport class JWKSIssuerTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {\n protected privateKey: TNullable<CryptoKey | Uint8Array> = null;\n protected publicKey: TNullable<CryptoKey | Uint8Array> = null;\n protected jwks: { keys: JWK[] } | null = null;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n protected options: IJWKSIssuerOptions,\n ) {\n super({ scope: JWKSIssuerTokenService.name });\n\n this.configurePayloadEncryption({\n aesAlgorithm: this.options.aesAlgorithm,\n applicationSecret: this.options.applicationSecret,\n fieldCodecs: this.options.fieldCodecs,\n cipher: this.options.cipher,\n sign: this.options.sign,\n });\n }\n\n protected override async initialize(): Promise<void> {\n const { keys, algorithm } = this.options;\n\n const raw = await this.resolveKeyContent({ keys });\n const built = await this.parseKeyMaterial({ raw, algorithm, keys });\n\n this.privateKey = built.priv;\n this.publicKey = built.pub;\n\n const { exportJWK } = await JoseLoader.load();\n const publicJWK = await exportJWK(this.publicKey!);\n\n // Belt and braces. `assertPublicJWK` already refused a private JWK on the way IN, but this is\n // the exact object an unauthenticated `/certs` serves - the last place to notice a signing key\n // about to be published, whatever route the material took to get here.\n this.assertPublicJWK({ jwk: publicJWK });\n\n publicJWK.kid = this.options.kid;\n publicJWK.alg = algorithm;\n publicJWK.use = 'sig';\n\n this.jwks = { keys: [publicJWK] };\n\n this.initialized = true;\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'JWKS issuer initialized | driver: %s | format: %s | kid: %s',\n keys.driver,\n keys.format,\n this.options.kid,\n );\n }\n\n protected async resolveKeyContent(opts: { keys: IJWKSIssuerOptions['keys'] }) {\n const { keys } = opts;\n\n switch (keys.driver) {\n case JWKSKeyDrivers.FILE: {\n const [priv, pub] = await Promise.all([\n readFile(keys.private, 'utf-8'),\n readFile(keys.public, 'utf-8'),\n ]);\n return { priv, pub };\n }\n case JWKSKeyDrivers.TEXT: {\n return {\n priv: keys.private,\n pub: keys.public,\n };\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key driver: ${keys.driver}`,\n });\n }\n }\n }\n\n /**\n * Refuses a JWK carrying private material where a PUBLIC key is expected.\n *\n * The `pem` format cannot reach this state - `importSPKI` rejects a private PEM outright. The\n * `jwk` format can: `importJWK` imports whatever it is handed, and a private JWK marked\n * `\"ext\": true` yields an EXTRACTABLE key, so `exportJWK` then carries `d` straight into the\n * document `/certs` serves without authentication. Measured on jose 6.2.3: with `ext: true` the\n * round trip returns `d`; without it, export throws. So the only thing standing between a\n * mis-pasted key and a published signing key was an optional flag on attacker-irrelevant input.\n *\n * Named members, not a blanket scan: `d` covers EC/OKP and RSA's private exponent, and the CRT\n * members are the rest of an RSA private key.\n */\n protected assertPublicJWK(opts: { jwk: JWK }): void {\n const PRIVATE_MEMBERS = ['d', 'p', 'q', 'dp', 'dq', 'qi', 'k'] as const;\n\n const present = PRIVATE_MEMBERS.filter((member) => opts.jwk[member] !== undefined);\n if (present.length === 0) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] The public key material carries PRIVATE members (${present.join(', ')}) | this key would be published at the JWKS endpoint | pass the public half in keys.public`,\n });\n }\n\n protected async parseKeyMaterial(opts: {\n raw: { priv: string; pub: string };\n algorithm: IJWKSIssuerOptions['algorithm'];\n keys: IJWKSIssuerOptions['keys'];\n }) {\n const { raw, algorithm, keys } = opts;\n\n if (!raw.priv) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.priv key!',\n });\n }\n\n if (!raw.pub) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.pub key!',\n });\n }\n\n const { importJWK, importPKCS8, importSPKI } = await JoseLoader.load();\n\n switch (keys.format) {\n case JWKSKeyFormats.PEM: {\n const priv = await importPKCS8(raw.priv, algorithm);\n const pub = await importSPKI(raw.pub, algorithm);\n return { priv, pub };\n }\n case JWKSKeyFormats.JWK: {\n try {\n const parsed = {\n priv: JSON.parse(raw.priv) as JWK,\n pub: JSON.parse(raw.pub) as JWK,\n };\n\n this.assertPublicJWK({ jwk: parsed.pub });\n\n const priv = await importJWK(parsed.priv, algorithm);\n const pub = await importJWK(parsed.pub, algorithm);\n return { priv, pub };\n } catch (error) {\n this.logger\n .for(this.parseKeyMaterial.name)\n .error('Invalid JWK key material | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid JWK key material',\n });\n }\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key format: ${keys.format}`,\n });\n }\n }\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n await this.ensureInitialized();\n const { jwtVerify } = await JoseLoader.load();\n const result = await jwtVerify<IJWTTokenPayload>(token, this.publicKey!, this.options.verify);\n return this.decryptPayload({ result });\n }\n\n override async getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }) {\n await this.ensureInitialized();\n const { SignJWT } = await JoseLoader.load();\n\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = await opts.getTokenExpiresFn();\n\n const encryptedPayload = await this.encryptPayload(opts.payload);\n\n const signer = new SignJWT({ ...encryptedPayload })\n .setProtectedHeader({ alg: this.options.algorithm, kid: this.options.kid })\n .setIssuedAt()\n .setExpirationTime(now + expiresIn)\n .setNotBefore(now);\n\n return this.applySignClaims({ signer, payload: encryptedPayload, claims: opts.claims });\n }\n\n protected override getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey> {\n if (!this.privateKey) {\n throw getError({ message: '[getSigningKey] Invalid privateKey!' });\n }\n\n return this.privateKey;\n }\n\n protected override getDefaultTokenExpiresFn(): TGetTokenExpiresFn {\n return this.options.getTokenExpiresFn;\n }\n\n getJWKS(): { keys: JWK[] } {\n if (!this.jwks) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] JWKS not initialized yet. Call getJWKSAsync() instead.',\n });\n }\n\n return this.jwks;\n }\n\n async getJWKSAsync(): Promise<{ keys: JWK[] }> {\n await this.ensureInitialized();\n return this.jwks!;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"issuer.service.js","sourceRo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pB,CAAC;CACF,CAAA;AA/NY,sBAAsB;IAM9B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAA;;GAN7C,sBAAsB,CA+NlC","sourcesContent":["import { HTTP, type TNullable, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWKSIssuerOptions,\n type IJWTIssueClaims,\n type IJWTTokenPayload,\n inject,\n JWKSKeyDrivers,\n JWKSKeyFormats,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport type { CryptoKey, JWK } from 'jose';\nimport { readFile } from 'node:fs/promises';\nimport { JoseLoader } from '../../jose-loader';\nimport { AbstractJWKSTokenService } from './abstract.service';\n\nexport class JWKSIssuerTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {\n protected privateKey: TNullable<CryptoKey | Uint8Array> = null;\n protected publicKey: TNullable<CryptoKey | Uint8Array> = null;\n protected jwks: { keys: JWK[] } | null = null;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n protected options: IJWKSIssuerOptions,\n ) {\n super({ scope: JWKSIssuerTokenService.name });\n\n this.configurePayloadEncryption({\n aesAlgorithm: this.options.aesAlgorithm,\n applicationSecret: this.options.applicationSecret,\n fieldCodecs: this.options.fieldCodecs,\n sign: this.options.sign,\n });\n }\n\n protected override async initialize(): Promise<void> {\n const { keys, algorithm } = this.options;\n\n const raw = await this.resolveKeyContent({ keys });\n const built = await this.parseKeyMaterial({ raw, algorithm, keys });\n\n this.privateKey = built.priv;\n this.publicKey = built.pub;\n\n const { exportJWK } = await JoseLoader.load();\n const publicJWK = await exportJWK(this.publicKey!);\n\n // Belt and braces. `assertPublicJWK` already refused a private JWK on the way IN, but this is\n // the exact object an unauthenticated `/certs` serves - the last place to notice a signing key\n // about to be published, whatever route the material took to get here.\n this.assertPublicJWK({ jwk: publicJWK });\n\n publicJWK.kid = this.options.kid;\n publicJWK.alg = algorithm;\n publicJWK.use = 'sig';\n\n this.jwks = { keys: [publicJWK] };\n\n this.initialized = true;\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'JWKS issuer initialized | driver: %s | format: %s | kid: %s',\n keys.driver,\n keys.format,\n this.options.kid,\n );\n }\n\n protected async resolveKeyContent(opts: { keys: IJWKSIssuerOptions['keys'] }) {\n const { keys } = opts;\n\n switch (keys.driver) {\n case JWKSKeyDrivers.FILE: {\n const [priv, pub] = await Promise.all([\n readFile(keys.private, 'utf-8'),\n readFile(keys.public, 'utf-8'),\n ]);\n return { priv, pub };\n }\n case JWKSKeyDrivers.TEXT: {\n return {\n priv: keys.private,\n pub: keys.public,\n };\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key driver: ${keys.driver}`,\n });\n }\n }\n }\n\n /**\n * Refuses a JWK carrying private material where a PUBLIC key is expected.\n *\n * The `pem` format cannot reach this state - `importSPKI` rejects a private PEM outright. The\n * `jwk` format can: `importJWK` imports whatever it is handed, and a private JWK marked\n * `\"ext\": true` yields an EXTRACTABLE key, so `exportJWK` then carries `d` straight into the\n * document `/certs` serves without authentication. Measured on jose 6.2.3: with `ext: true` the\n * round trip returns `d`; without it, export throws. So the only thing standing between a\n * mis-pasted key and a published signing key was an optional flag on attacker-irrelevant input.\n *\n * Named members, not a blanket scan: `d` covers EC/OKP and RSA's private exponent, and the CRT\n * members are the rest of an RSA private key.\n */\n protected assertPublicJWK(opts: { jwk: JWK }): void {\n const PRIVATE_MEMBERS = ['d', 'p', 'q', 'dp', 'dq', 'qi', 'k'] as const;\n\n const present = PRIVATE_MEMBERS.filter((member) => opts.jwk[member] !== undefined);\n if (present.length === 0) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] The public key material carries PRIVATE members (${present.join(', ')}) | this key would be published at the JWKS endpoint | pass the public half in keys.public`,\n });\n }\n\n protected async parseKeyMaterial(opts: {\n raw: { priv: string; pub: string };\n algorithm: IJWKSIssuerOptions['algorithm'];\n keys: IJWKSIssuerOptions['keys'];\n }) {\n const { raw, algorithm, keys } = opts;\n\n if (!raw.priv) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.priv key!',\n });\n }\n\n if (!raw.pub) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.pub key!',\n });\n }\n\n const { importJWK, importPKCS8, importSPKI } = await JoseLoader.load();\n\n switch (keys.format) {\n case JWKSKeyFormats.PEM: {\n const priv = await importPKCS8(raw.priv, algorithm);\n const pub = await importSPKI(raw.pub, algorithm);\n return { priv, pub };\n }\n case JWKSKeyFormats.JWK: {\n try {\n const parsed = {\n priv: JSON.parse(raw.priv) as JWK,\n pub: JSON.parse(raw.pub) as JWK,\n };\n\n this.assertPublicJWK({ jwk: parsed.pub });\n\n const priv = await importJWK(parsed.priv, algorithm);\n const pub = await importJWK(parsed.pub, algorithm);\n return { priv, pub };\n } catch (error) {\n this.logger\n .for(this.parseKeyMaterial.name)\n .error('Invalid JWK key material | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid JWK key material',\n });\n }\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key format: ${keys.format}`,\n });\n }\n }\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n await this.ensureInitialized();\n const { jwtVerify } = await JoseLoader.load();\n const result = await jwtVerify<IJWTTokenPayload>(token, this.publicKey!, this.options.verify);\n return this.decryptPayload({ result });\n }\n\n override async getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }) {\n await this.ensureInitialized();\n const { SignJWT } = await JoseLoader.load();\n\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = await opts.getTokenExpiresFn();\n\n const encryptedPayload = await this.encryptPayload(opts.payload);\n\n const signer = new SignJWT({ ...encryptedPayload })\n .setProtectedHeader({ alg: this.options.algorithm, kid: this.options.kid })\n .setIssuedAt()\n .setExpirationTime(now + expiresIn)\n .setNotBefore(now);\n\n return this.applySignClaims({ signer, payload: encryptedPayload, claims: opts.claims });\n }\n\n protected override getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey> {\n if (!this.privateKey) {\n throw getError({ message: '[getSigningKey] Invalid privateKey!' });\n }\n\n return this.privateKey;\n }\n\n protected override getDefaultTokenExpiresFn(): TGetTokenExpiresFn {\n return this.options.getTokenExpiresFn;\n }\n\n getJWKS(): { keys: JWK[] } {\n if (!this.jwks) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] JWKS not initialized yet. Call getJWKSAsync() instead.',\n });\n }\n\n return this.jwks;\n }\n\n async getJWKSAsync(): Promise<{ keys: JWK[] }> {\n await this.ensureInitialized();\n return this.jwks!;\n }\n}\n"]}
|
package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/verifier.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,qBAAa,wBAAwB,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAE,SAAQ,wBAAwB,CAAC,CAAC,CAAC;IAK1F,SAAS,CAAC,OAAO,EAAE,oBAAoB;IAJzC,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAAG,IAAI,CAAQ;gBAIhE,OAAO,EAAE,oBAAoB;
|
|
1
|
+
{"version":3,"file":"verifier.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/verifier.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,qBAAa,wBAAwB,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAE,SAAQ,wBAAwB,CAAC,CAAC,CAAC;IAK1F,SAAS,CAAC,OAAO,EAAE,oBAAoB;IAJzC,SAAS,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAAG,IAAI,CAAQ;gBAIhE,OAAO,EAAE,oBAAoB;cAUhB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAe3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAW5D,SAAS,CAAC,KAAK,EAAE;QAC9B,OAAO,EAAE,gBAAgB,CAAC;QAC1B,iBAAiB,EAAE,kBAAkB,CAAC;KACvC,GAAG,OAAO,CAAC,OAAO,CAAC;cAOD,aAAa,IAAI,KAAK;cAOtB,wBAAwB,IAAI,KAAK;CAMrD"}
|
|
@@ -25,7 +25,6 @@ let JWKSVerifierTokenService = JWKSVerifierTokenService_1 = class JWKSVerifierTo
|
|
|
25
25
|
aesAlgorithm: this.options.aesAlgorithm,
|
|
26
26
|
applicationSecret: this.options.applicationSecret,
|
|
27
27
|
fieldCodecs: this.options.fieldCodecs,
|
|
28
|
-
cipher: this.options.cipher,
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
async initialize() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier.service.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAGvB,MAAM,GAEP,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,IAAa,wBAAwB,gCAArC,MAAa,wBAA8C,SAAQ,wBAA2B;IAG5F,YAEE,OAAuC;QAEvC,KAAK,CAAC,EAAE,KAAK,EAAE,0BAAwB,CAAC,IAAI,EAAE,CAAC,CAAC;QAFtC,YAAO,GAAP,OAAO,CAAsB;QAJ/B,iBAAY,GAAiD,IAAI,CAAC;QAO1E,IAAI,CAAC,0BAA0B,CAAC;YAC9B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;YACvC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;YACjD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"verifier.service.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MA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AC,OAAO,CAAC,CAAC;IACvE,CAAC;IAEkB,KAAK,CAAC,QAAQ,CAAC,KAAa;QAC7C,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,SAAS,CAC5B,KAAK,EACL,IAAI,CAAC,YAAa,EAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CACpB,CAAC;QACF,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAEQ,KAAK,CAAC,SAAS,CAAC,KAGxB;QACC,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IAEkB,aAAa;QAC9B,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IAEkB,wBAAwB;QACzC,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,8DAA8D;SACxE,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhEY,wBAAwB;IAIhC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAA;;GAJ7C,wBAAwB,CAgEpC","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWKSVerifierOptions,\n type IJWTTokenPayload,\n inject,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport type { createRemoteJWKSet, SignJWT } from 'jose';\nimport { JoseLoader } from '../../jose-loader';\nimport { AbstractJWKSTokenService } from './abstract.service';\n\nexport class JWKSVerifierTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {\n protected jwksVerifier: ReturnType<typeof createRemoteJWKSet> | null = null;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n protected options: IJWKSVerifierOptions,\n ) {\n super({ scope: JWKSVerifierTokenService.name });\n this.configurePayloadEncryption({\n aesAlgorithm: this.options.aesAlgorithm,\n applicationSecret: this.options.applicationSecret,\n fieldCodecs: this.options.fieldCodecs,\n });\n }\n\n protected override async initialize(): Promise<void> {\n const { createRemoteJWKSet } = await JoseLoader.load();\n const jwksUrl = new URL(this.options.jwksUrl);\n this.jwksVerifier = createRemoteJWKSet(jwksUrl, {\n cacheMaxAge: this.options.cacheTtlMs ?? 43_200_000,\n cooldownDuration: this.options.cooldownMs ?? 30_000,\n });\n\n this.initialized = true;\n\n this.logger\n .for(this.initialize.name)\n .info('JWKS verifier initialized | url: %s', this.options.jwksUrl);\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n await this.ensureInitialized();\n const { jwtVerify } = await JoseLoader.load();\n const result = await jwtVerify<IJWTTokenPayload>(\n token,\n this.jwksVerifier!,\n this.options.verify,\n );\n return this.decryptPayload({ result });\n }\n\n override async getSigner(_opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n }): Promise<SignJWT> {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode cannot sign tokens',\n });\n }\n\n protected override getSigningKey(): never {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode cannot sign tokens',\n });\n }\n\n protected override getDefaultTokenExpiresFn(): never {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode has no token expiry',\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jws.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/jws.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,8EAA8E;AAC9E,qBAAa,eAAe,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAE,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IAKnF,SAAS,CAAC,OAAO,EAAE,uBAAuB;IAJ5C,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC;gBAIpB,OAAO,EAAE,uBAAuB;
|
|
1
|
+
{"version":3,"file":"jws.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/jws.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,8EAA8E;AAC9E,qBAAa,eAAe,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAE,SAAQ,0BAA0B,CAAC,CAAC,CAAC;IAKnF,SAAS,CAAC,OAAO,EAAE,uBAAuB;IAJ5C,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC;gBAIpB,OAAO,EAAE,uBAAuB;cA6BnB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAU5D,SAAS,CAAC,IAAI,EAAE;QAC7B,OAAO,EAAE,gBAAgB,CAAC;QAC1B,iBAAiB,EAAE,kBAAkB,CAAC;QACtC,MAAM,CAAC,EAAE,eAAe,CAAC;KAC1B;cAgBkB,aAAa,IAAI,cAAc,CAAC,UAAU,CAAC;cAQ3C,wBAAwB,IAAI,kBAAkB;CAGlE"}
|
|
@@ -38,7 +38,6 @@ let JWSTokenService = JWSTokenService_1 = class JWSTokenService extends Abstract
|
|
|
38
38
|
aesAlgorithm,
|
|
39
39
|
applicationSecret,
|
|
40
40
|
fieldCodecs: options.fieldCodecs,
|
|
41
|
-
cipher: options.cipher,
|
|
42
41
|
sign: options.sign,
|
|
43
42
|
});
|
|
44
43
|
this.jwtSecret = new TextEncoder().encode(this.options.jwtSecret);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jws.service.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/jws.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAIvB,MAAM,GAEP,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,8EAA8E;AAC9E,IAAa,eAAe,uBAA5B,MAAa,eAAqC,SAAQ,0BAA6B;IAGrF,YAEY,OAAgC;QAE1C,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAe,CAAC,IAAI,EAAE,CAAC,CAAC;QAF7B,YAAO,GAAP,OAAO,CAAyB;QAI1C,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAExF,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EAAE,qCAAqC;aAC/C,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EAAE,6CAA6C;aACvD,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,0BAA0B,CAAC;YAC9B,YAAY;YACZ,iBAAiB;YACjB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,
|
|
1
|
+
{"version":3,"file":"jws.service.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/jws.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAIvB,MAAM,GAEP,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,8EAA8E;AAC9E,IAAa,eAAe,uBAA5B,MAAa,eAAqC,SAAQ,0BAA6B;IAGrF,YAEY,OAAgC;QAE1C,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAe,CAAC,IAAI,EAAE,CAAC,CAAC;QAF7B,YAAO,GAAP,OAAO,CAAyB;QAI1C,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EA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C,iBAAiB,EAAE,CAAC;QAEjD,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEjE,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;aAC5D,kBAAkB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,OAAO,EAAE,CAAC;aACpE,WAAW,EAAE;aACb,iBAAiB,CAAC,GAAG,GAAG,SAAS,CAAC;aAClC,YAAY,CAAC,GAAG,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1F,CAAC;IAEkB,aAAa;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEkB,wBAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACxC,CAAC;CACF,CAAA;AA3EY,eAAe;IAIvB,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,WAAW,EAAE,CAAC,CAAA;;GAJ5C,eAAe,CA2E3B","sourcesContent":["import { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWSTokenServiceOptions,\n type IJWTIssueClaims,\n type IJWTTokenPayload,\n inject,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport { JoseLoader } from '../jose-loader';\nimport { AbstractBearerTokenService } from './abstract.service';\n\n/** Symmetric JWT (JWS) token service with optional AES-encrypted payloads. */\nexport class JWSTokenService<E extends Env = Env> extends AbstractBearerTokenService<E> {\n protected jwtSecret: Uint8Array;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWT_OPTIONS })\n protected options: IJWSTokenServiceOptions,\n ) {\n super({ scope: JWSTokenService.name });\n\n const { aesAlgorithm, jwtSecret, applicationSecret, getTokenExpiresFn } = options ?? {};\n\n if (!jwtSecret) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWSTokenService] Invalid jwtSecret',\n });\n }\n\n if (!getTokenExpiresFn) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWSTokenService] Invalid getTokenExpiresFn',\n });\n }\n\n this.configurePayloadEncryption({\n aesAlgorithm,\n applicationSecret,\n fieldCodecs: options.fieldCodecs,\n sign: options.sign,\n });\n this.jwtSecret = new TextEncoder().encode(this.options.jwtSecret);\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n const { jwtVerify } = await JoseLoader.load();\n const decodedToken = await jwtVerify<IJWTTokenPayload>(\n token,\n this.jwtSecret,\n this.options.verify,\n );\n return this.decryptPayload({ result: decodedToken });\n }\n\n override async getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }) {\n const { SignJWT } = await JoseLoader.load();\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = await opts.getTokenExpiresFn();\n\n const encryptedPayload = await this.encryptPayload(opts.payload);\n\n const signer = new SignJWT(Object.assign({}, encryptedPayload))\n .setProtectedHeader({ alg: this.options.headerAlgorithm ?? 'HS256' })\n .setIssuedAt()\n .setExpirationTime(now + expiresIn)\n .setNotBefore(now);\n\n return this.applySignClaims({ signer, payload: encryptedPayload, claims: opts.claims });\n }\n\n protected override getSigningKey(): ValueOrPromise<Uint8Array> {\n if (!this.jwtSecret) {\n throw getError({ message: '[getSigningKey] Invalid jwtSecret!' });\n }\n\n return this.jwtSecret;\n }\n\n protected override getDefaultTokenExpiresFn(): TGetTokenExpiresFn {\n return this.options.getTokenExpiresFn;\n }\n}\n"]}
|
|
@@ -15,7 +15,7 @@ export class UserPolicyLineCache extends BaseHelper {
|
|
|
15
15
|
/** Fetch the user's lines, collapsing concurrent misses per key onto one extraction. Best-effort: two misses may race past the cache read and both extract (benign - per-user lines are identical). */
|
|
16
16
|
async fetch(opts) {
|
|
17
17
|
const cacheKey = await this.resolveCacheKey({ user: opts.user });
|
|
18
|
-
// Cache hit - Redis owns expiry (PX on write), so a present key is fresh;
|
|
18
|
+
// Cache hit - Redis owns expiry (PX on write), so a present key is fresh; an entry that does not decode (corrupted, or not an array of policy lines) must NOT 500 the request, so it is discarded and refetched.
|
|
19
19
|
const raw = await this.cached.options.connection.get({ key: cacheKey });
|
|
20
20
|
if (raw) {
|
|
21
21
|
const lines = this.parseLines({ raw, cacheKey });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-policy-line-cache.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/user-policy-line-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EACL,mBAAmB,GAGpB,MAAM,uBAAuB,CAAC;AAK/B;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAOjD,YAAY,IAGX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;QAP7C,4IAA4I;QAC3H,uBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAC;QAOzE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,uMAAuM;IACvM,KAAK,CAAC,KAAK,CAAC,IAAkC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEjE
|
|
1
|
+
{"version":3,"file":"user-policy-line-cache.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authorize/enforcers/user-policy-line-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EACL,mBAAmB,GAGpB,MAAM,uBAAuB,CAAC;AAK/B;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IAOjD,YAAY,IAGX;QACC,KAAK,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC;QAP7C,4IAA4I;QAC3H,uBAAkB,GAAG,IAAI,GAAG,EAA6B,CAAC;QAOzE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,uMAAuM;IACvM,KAAK,CAAC,KAAK,CAAC,IAAkC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEjE,iNAAiN;QACjN,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxE,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;YAEjD,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAA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CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;gBAC9E,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,uEAAuE;iBACjF,CAAC,CAAC;YACL,CAAC;YAED,OAAO,MAAkB,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;iBACzB,IAAI,CAAC,8DAA8D,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC9F,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport {\n AuthorizationErrors,\n type IAuthorizationUser,\n type ICasbinEnforcerCachedRedis,\n} from '@venizia/ignis-kernel';\n\n/** Computes a user's policy lines on a cache miss - CasbinAuthorizationEnforcer wires this to its isolated-enforcer extraction (PolicyLineCodec.extractUserLines). */\nexport type TPolicyLineLoader = (opts: { user: IAuthorizationUser }) => Promise<string[]>;\n\n/**\n * Per-user redis cache of casbin policy lines. Owns the cache key, the TTL, and concurrent-miss\n * de-duplication so N simultaneous misses for the same user collapse onto one extraction.\n */\nexport class UserPolicyLineCache extends BaseHelper {\n private readonly cached: ICasbinEnforcerCachedRedis & { use: true };\n private readonly loadLines: TPolicyLineLoader;\n\n // cacheKey -> in-progress line-fetch; concurrent misses for the same user share one extraction instead of all hitting the DB (see fetch()).\n private readonly pendingLineFetches = new Map<string, Promise<string[]>>();\n\n constructor(opts: {\n cached: ICasbinEnforcerCachedRedis & { use: true };\n loadLines: TPolicyLineLoader;\n }) {\n super({ scope: UserPolicyLineCache.name });\n this.cached = opts.cached;\n this.loadLines = opts.loadLines;\n }\n\n /** Fetch the user's lines, collapsing concurrent misses per key onto one extraction. Best-effort: two misses may race past the cache read and both extract (benign - per-user lines are identical). */\n async fetch(opts: { user: IAuthorizationUser }): Promise<string[]> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n\n // Cache hit - Redis owns expiry (PX on write), so a present key is fresh; an entry that does not decode (corrupted, or not an array of policy lines) must NOT 500 the request, so it is discarded and refetched.\n const raw = await this.cached.options.connection.get({ key: cacheKey });\n if (raw) {\n const lines = this.parseLines({ raw, cacheKey });\n\n if (lines) {\n return lines;\n }\n }\n\n const existing = this.pendingLineFetches.get(cacheKey);\n if (existing) {\n return existing;\n }\n\n // Cache miss (or discarded corrupt entry) - extract from an ISOLATED enforcer so a concurrent load cannot contaminate the cache, persist it, then return the lines for THIS request.\n const task = async () => {\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n return lines;\n };\n\n const promise = task().finally(() => {\n this.pendingLineFetches.delete(cacheKey);\n });\n\n this.pendingLineFetches.set(cacheKey, promise);\n return promise;\n }\n\n /** Drop the user's cached entry. */\n async invalidate(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; invalidatedKeys: number }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n const invalidatedKeys = await this.cached.options.connection.del({ keys: [cacheKey] });\n\n return { cacheKey, invalidatedKeys };\n }\n\n /** Drop then recompute the user's cached entry via `loadLines` - an isolated extraction (never a pooled serving enforcer), so a concurrent request cannot make the cache hold another user's lines. */\n async rebuild(opts: {\n user: IAuthorizationUser;\n }): Promise<{ cacheKey: string; lines: string[] }> {\n const cacheKey = await this.resolveCacheKey({ user: opts.user });\n await this.cached.options.connection.del({ keys: [cacheKey] });\n\n const lines = await this.loadLines({ user: opts.user });\n await this.writeLines({ cacheKey, lines });\n\n return { cacheKey, lines };\n }\n\n /** Compute the user's cache key and reject an empty result - consistent with the read path. */\n private async resolveCacheKey(opts: { user: IAuthorizationUser }): Promise<string> {\n const cacheKey = await this.cached.options.keyFn({ user: opts.user });\n if (!cacheKey) {\n throw getError({\n error: AuthorizationErrors.CACHE_KEY_INVALID,\n message: '[UserPolicyLineCache] keyFn returned an empty cache key.',\n });\n }\n\n return cacheKey;\n }\n\n /** Single source of truth for the cache encoding. Used by the miss path and rebuild(). */\n private async writeLines(opts: { cacheKey: string; lines: string[] }): Promise<void> {\n await this.cached.options.connection.set({\n key: opts.cacheKey,\n value: opts.lines,\n options: { expiresIn: this.cached.options.expiresIn },\n });\n }\n\n /** Decode cached policy lines; on any corruption, log and return null so the caller refetches. */\n private parseLines(opts: { raw: string; cacheKey: string }): TNullable<string[]> {\n try {\n const parsed = JSON.parse(opts.raw);\n\n if (!Array.isArray(parsed) || parsed.some((line) => typeof line !== 'string')) {\n throw getError({\n message: '[UserPolicyLineCache] Cached payload is not an array of policy lines.',\n });\n }\n\n return parsed as string[];\n } catch (error) {\n this.logger\n .for(this.parseLines.name)\n .warn('Discarding corrupted authz cache entry | key: %s | error: %s', opts.cacheKey, error);\n return null;\n }\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# The whole project is the build context (trimmed by the root .dockerignore), because the preset
|
|
6
6
|
# cannot know which workspace packages the app imports. List them by hand for better layer caching.
|
|
7
7
|
|
|
8
|
-
FROM docker.io/oven/bun:1.4.
|
|
8
|
+
FROM docker.io/oven/bun:1.4.4-alpine AS base
|
|
9
9
|
|
|
10
10
|
# A private npm mirror, if the build has no access to the public registry.
|
|
11
11
|
ARG BUN_CONFIG_REGISTRY=
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@hono/zod-openapi": "^1.6.3",
|
|
16
16
|
"@scalar/hono-api-reference": "^0.12.13",
|
|
17
|
-
"@venizia/ignis": "0.4.7-
|
|
18
|
-
"@venizia/ignis-boot": "0.4.7-
|
|
19
|
-
"@venizia/ignis-helpers": "0.4.7-
|
|
17
|
+
"@venizia/ignis": "0.4.7-7",
|
|
18
|
+
"@venizia/ignis-boot": "0.4.7-7",
|
|
19
|
+
"@venizia/ignis-helpers": "0.4.7-6",
|
|
20
20
|
"hono": "^4.13.13",
|
|
21
21
|
"winston": "^3.19.0",
|
|
22
22
|
"winston-daily-rotate-file": "^5.0.0",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/bun": "^1.4.3",
|
|
27
|
-
"@venizia/dev-configs": "0.4.7-
|
|
27
|
+
"@venizia/dev-configs": "0.4.7-5",
|
|
28
28
|
"eslint": "^10.13.0",
|
|
29
29
|
"oxlint": "1.89.0",
|
|
30
30
|
"oxlint-tsgolint": "7.0.2004",
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
"dependencies": {},
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@types/bun": "^1.4.3",
|
|
7
|
-
"@venizia/dev-configs": "0.4.7-
|
|
8
|
-
"@venizia/ignis": "0.4.7-
|
|
7
|
+
"@venizia/dev-configs": "0.4.7-5",
|
|
8
|
+
"@venizia/ignis": "0.4.7-7",
|
|
9
9
|
"eslint": "^10.13.0",
|
|
10
10
|
"oxlint": "1.89.0",
|
|
11
11
|
"oxlint-tsgolint": "7.0.2004",
|
|
12
12
|
"typescript": "^6.0.3"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@venizia/ignis": "0.4.7-
|
|
15
|
+
"@venizia/ignis": "0.4.7-7"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"typecheck": "bun check",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis",
|
|
3
|
-
"version": "0.4.7-
|
|
3
|
+
"version": "0.4.7-7",
|
|
4
4
|
"description": "TypeScript server framework with decorator-based DI, the repository pattern and a component system, on Hono. Features auto-generated OpenAPI docs, Drizzle ORM type-safe SQL, JWT/Basic authentication, Casbin authorization, convention-based bootstrapping, and pluggable components for health checks, Swagger UI, mail, Socket.IO, and static assets. Built for Bun and Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"access-control",
|
|
@@ -100,50 +100,6 @@
|
|
|
100
100
|
"types": "./dist/esm/index.d.ts",
|
|
101
101
|
"default": "./dist/esm/index.js"
|
|
102
102
|
},
|
|
103
|
-
"./postgres": {
|
|
104
|
-
"types": "./dist/esm/connectors/postgres/index.d.ts",
|
|
105
|
-
"default": "./dist/esm/connectors/postgres/index.js"
|
|
106
|
-
},
|
|
107
|
-
"./relational": {
|
|
108
|
-
"types": "./dist/esm/connectors/relational/index.d.ts",
|
|
109
|
-
"default": "./dist/esm/connectors/relational/index.js"
|
|
110
|
-
},
|
|
111
|
-
"./postgres/node-postgres": {
|
|
112
|
-
"types": "./dist/esm/connectors/postgres/drivers/node-postgres.d.ts",
|
|
113
|
-
"default": "./dist/esm/connectors/postgres/drivers/node-postgres.js"
|
|
114
|
-
},
|
|
115
|
-
"./postgres/postgres-js": {
|
|
116
|
-
"types": "./dist/esm/connectors/postgres/drivers/postgres-js.d.ts",
|
|
117
|
-
"default": "./dist/esm/connectors/postgres/drivers/postgres-js.js"
|
|
118
|
-
},
|
|
119
|
-
"./postgres/pglite": {
|
|
120
|
-
"types": "./dist/esm/connectors/postgres/drivers/pglite.d.ts",
|
|
121
|
-
"default": "./dist/esm/connectors/postgres/drivers/pglite.js"
|
|
122
|
-
},
|
|
123
|
-
"./postgres/supabase": {
|
|
124
|
-
"types": "./dist/esm/connectors/postgres/supabase/index.d.ts",
|
|
125
|
-
"default": "./dist/esm/connectors/postgres/supabase/index.js"
|
|
126
|
-
},
|
|
127
|
-
"./sqlite": {
|
|
128
|
-
"types": "./dist/esm/connectors/sqlite/index.d.ts",
|
|
129
|
-
"default": "./dist/esm/connectors/sqlite/index.js"
|
|
130
|
-
},
|
|
131
|
-
"./sqlite/libsql": {
|
|
132
|
-
"types": "./dist/esm/connectors/sqlite/drivers/libsql.d.ts",
|
|
133
|
-
"default": "./dist/esm/connectors/sqlite/drivers/libsql.js"
|
|
134
|
-
},
|
|
135
|
-
"./search": {
|
|
136
|
-
"types": "./dist/esm/connectors/search/index.d.ts",
|
|
137
|
-
"default": "./dist/esm/connectors/search/index.js"
|
|
138
|
-
},
|
|
139
|
-
"./search/controllers": {
|
|
140
|
-
"types": "./dist/esm/connectors/search/controllers/index.d.ts",
|
|
141
|
-
"default": "./dist/esm/connectors/search/controllers/index.js"
|
|
142
|
-
},
|
|
143
|
-
"./meilisearch": {
|
|
144
|
-
"types": "./dist/esm/connectors/meilisearch/index.d.ts",
|
|
145
|
-
"default": "./dist/esm/connectors/meilisearch/index.js"
|
|
146
|
-
},
|
|
147
103
|
"./socket-io": {
|
|
148
104
|
"types": "./dist/esm/components/socket-io/index.d.ts",
|
|
149
105
|
"default": "./dist/esm/components/socket-io/index.js"
|
|
@@ -164,14 +120,6 @@
|
|
|
164
120
|
"types": "./dist/esm/components/websocket/index.d.ts",
|
|
165
121
|
"default": "./dist/esm/components/websocket/index.js"
|
|
166
122
|
},
|
|
167
|
-
"./typesense": {
|
|
168
|
-
"types": "./dist/esm/connectors/typesense/index.d.ts",
|
|
169
|
-
"default": "./dist/esm/connectors/typesense/index.js"
|
|
170
|
-
},
|
|
171
|
-
"./typesense/controllers": {
|
|
172
|
-
"types": "./dist/esm/connectors/typesense/controllers/index.d.ts",
|
|
173
|
-
"default": "./dist/esm/connectors/typesense/controllers/index.js"
|
|
174
|
-
},
|
|
175
123
|
"./testing": {
|
|
176
124
|
"types": "./dist/esm/testing/index.d.ts",
|
|
177
125
|
"default": "./dist/esm/testing/index.js"
|
|
@@ -186,11 +134,11 @@
|
|
|
186
134
|
"force-update": "sh ../../scripts/build/force-update.sh"
|
|
187
135
|
},
|
|
188
136
|
"dependencies": {
|
|
189
|
-
"@venizia/ignis-connectors": "0.4.7-
|
|
190
|
-
"@venizia/ignis-filter": "0.4.6-
|
|
191
|
-
"@venizia/ignis-helpers": "0.4.7-
|
|
192
|
-
"@venizia/ignis-inversion": "0.4.6-
|
|
193
|
-
"@venizia/ignis-kernel": "0.4.7-
|
|
137
|
+
"@venizia/ignis-connectors": "0.4.7-6",
|
|
138
|
+
"@venizia/ignis-filter": "0.4.6-2",
|
|
139
|
+
"@venizia/ignis-helpers": "0.4.7-6",
|
|
140
|
+
"@venizia/ignis-inversion": "0.4.6-2",
|
|
141
|
+
"@venizia/ignis-kernel": "0.4.7-6",
|
|
194
142
|
"reflect-metadata": "^0.2.2"
|
|
195
143
|
},
|
|
196
144
|
"devDependencies": {
|
|
@@ -203,8 +151,8 @@
|
|
|
203
151
|
"@types/bun": "^1.4.3",
|
|
204
152
|
"@types/nodemailer": "^8.0.2",
|
|
205
153
|
"@types/pg": "^8.23.1",
|
|
206
|
-
"@venizia/dev-configs": "0.4.7-
|
|
207
|
-
"@venizia/ignis-boot": "0.4.7-
|
|
154
|
+
"@venizia/dev-configs": "0.4.7-5",
|
|
155
|
+
"@venizia/ignis-boot": "0.4.7-7",
|
|
208
156
|
"casbin": "^5.51.1",
|
|
209
157
|
"eslint": "^10.13.0",
|
|
210
158
|
"meilisearch": "^0.62.0",
|
|
@@ -219,10 +167,8 @@
|
|
|
219
167
|
"@asteasolutions/zod-to-openapi": "^9.1.0",
|
|
220
168
|
"@aws-sdk/client-sesv2": "^3.1154.0",
|
|
221
169
|
"@connectrpc/connect": "^2.2.0",
|
|
222
|
-
"@electric-sql/pglite": "^0.5.10",
|
|
223
170
|
"@hono/swagger-ui": "^0.6.1",
|
|
224
171
|
"@hono/zod-openapi": "^1.6.3",
|
|
225
|
-
"@libsql/client": "^0.17.4",
|
|
226
172
|
"@scalar/hono-api-reference": "^0.12.13",
|
|
227
173
|
"@socket.io/bun-engine": "^0.1.2",
|
|
228
174
|
"@socket.io/redis-adapter": "^8.3.0",
|
|
@@ -234,13 +180,9 @@
|
|
|
234
180
|
"hono": "^4.13.13",
|
|
235
181
|
"jose": "^6.2.13",
|
|
236
182
|
"mailgun.js": "^14.1.0",
|
|
237
|
-
"meilisearch": "^0.62.0",
|
|
238
183
|
"nodemailer": "^10.1.7",
|
|
239
|
-
"pg": "^8.23.1",
|
|
240
|
-
"postgres": "^3.4.9",
|
|
241
184
|
"socket.io": "^4.8.4",
|
|
242
|
-
"socket.io-client": "^4.8.4"
|
|
243
|
-
"typesense": "^3.2.0"
|
|
185
|
+
"socket.io-client": "^4.8.4"
|
|
244
186
|
},
|
|
245
187
|
"peerDependenciesMeta": {
|
|
246
188
|
"@aws-sdk/client-sesv2": {
|
|
@@ -249,15 +191,9 @@
|
|
|
249
191
|
"@connectrpc/connect": {
|
|
250
192
|
"optional": true
|
|
251
193
|
},
|
|
252
|
-
"@electric-sql/pglite": {
|
|
253
|
-
"optional": true
|
|
254
|
-
},
|
|
255
194
|
"@hono/swagger-ui": {
|
|
256
195
|
"optional": true
|
|
257
196
|
},
|
|
258
|
-
"@libsql/client": {
|
|
259
|
-
"optional": true
|
|
260
|
-
},
|
|
261
197
|
"@scalar/hono-api-reference": {
|
|
262
198
|
"optional": true
|
|
263
199
|
},
|
|
@@ -279,26 +215,14 @@
|
|
|
279
215
|
"mailgun.js": {
|
|
280
216
|
"optional": true
|
|
281
217
|
},
|
|
282
|
-
"meilisearch": {
|
|
283
|
-
"optional": true
|
|
284
|
-
},
|
|
285
218
|
"nodemailer": {
|
|
286
219
|
"optional": true
|
|
287
220
|
},
|
|
288
|
-
"pg": {
|
|
289
|
-
"optional": true
|
|
290
|
-
},
|
|
291
|
-
"postgres": {
|
|
292
|
-
"optional": true
|
|
293
|
-
},
|
|
294
221
|
"socket.io": {
|
|
295
222
|
"optional": true
|
|
296
223
|
},
|
|
297
224
|
"socket.io-client": {
|
|
298
225
|
"optional": true
|
|
299
|
-
},
|
|
300
|
-
"typesense": {
|
|
301
|
-
"optional": true
|
|
302
226
|
}
|
|
303
227
|
},
|
|
304
228
|
"engines": {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** Application-wide constants. */
|
|
2
|
-
export declare class App {
|
|
3
|
-
static readonly APPLICATION_NAME: string;
|
|
4
|
-
static readonly DEFAULT_QUERY_LIMIT = 50;
|
|
5
|
-
static readonly DEFAULT_QUERY_OFFSET = 0;
|
|
6
|
-
static readonly DS_POSTGRES = "postgresql";
|
|
7
|
-
static readonly DS_MEMORY = "memory";
|
|
8
|
-
static readonly DS_REDIS = "redis";
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/common/constants.ts"],"names":[],"mappings":"AAEA,kCAAkC;AAClC,qBAAa,GAAG;IACd,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAC0D;IAE1F,MAAM,CAAC,QAAQ,CAAC,mBAAmB,MAAM;IACzC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,KAAK;IAEzC,MAAM,CAAC,QAAQ,CAAC,WAAW,gBAAgB;IAC3C,MAAM,CAAC,QAAQ,CAAC,SAAS,YAAY;IACrC,MAAM,CAAC,QAAQ,CAAC,QAAQ,WAAW;CACpC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ParseUtility } from '@venizia/ignis-helpers/core';
|
|
2
|
-
/** Application-wide constants. */
|
|
3
|
-
export class App {
|
|
4
|
-
static { this.APPLICATION_NAME = ParseUtility.blankToUndefined({ input: process.env.APP_ENV_APPLICATION_NAME }) ?? 'APP'; }
|
|
5
|
-
static { this.DEFAULT_QUERY_LIMIT = 50; }
|
|
6
|
-
static { this.DEFAULT_QUERY_OFFSET = 0; }
|
|
7
|
-
static { this.DS_POSTGRES = 'postgresql'; }
|
|
8
|
-
static { this.DS_MEMORY = 'memory'; }
|
|
9
|
-
static { this.DS_REDIS = 'redis'; }
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,kCAAkC;AAClC,MAAM,OAAO,GAAG;aACE,qBAAgB,GAC9B,YAAY,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC,IAAI,KAAK,CAAC;aAE1E,wBAAmB,GAAG,EAAE,CAAC;aACzB,yBAAoB,GAAG,CAAC,CAAC;aAEzB,gBAAW,GAAG,YAAY,CAAC;aAC3B,cAAS,GAAG,QAAQ,CAAC;aACrB,aAAQ,GAAG,OAAO,CAAC","sourcesContent":["import { ParseUtility } from '@venizia/ignis-helpers/core';\n\n/** Application-wide constants. */\nexport class App {\n static readonly APPLICATION_NAME =\n ParseUtility.blankToUndefined({ input: process.env.APP_ENV_APPLICATION_NAME }) ?? 'APP';\n\n static readonly DEFAULT_QUERY_LIMIT = 50;\n static readonly DEFAULT_QUERY_OFFSET = 0;\n\n static readonly DS_POSTGRES = 'postgresql';\n static readonly DS_MEMORY = 'memory';\n static readonly DS_REDIS = 'redis';\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/meilisearch/index.ts"],"names":[],"mappings":"AAAA,wJAAwJ;AACxJ,cAAc,uCAAuC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/meilisearch/index.ts"],"names":[],"mappings":"AAAA,wJAAwJ;AACxJ,cAAc,uCAAuC,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/meilisearch` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/meilisearch';\n"]}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/postgres/node-postgres` keeps resolving for published consumers. */
|
|
2
|
-
export * from '@venizia/ignis-connectors/postgres/node-postgres';
|
|
3
|
-
//# sourceMappingURL=node-postgres.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-postgres.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/postgres/drivers/node-postgres.ts"],"names":[],"mappings":"AAAA,mKAAmK;AACnK,cAAc,kDAAkD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-postgres.js","sourceRoot":"","sources":["../../../../../src/connectors/postgres/drivers/node-postgres.ts"],"names":[],"mappings":"AAAA,mKAAmK;AACnK,cAAc,kDAAkD,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/postgres/node-postgres` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/postgres/node-postgres';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pglite.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/postgres/drivers/pglite.ts"],"names":[],"mappings":"AAAA,4JAA4J;AAC5J,cAAc,2CAA2C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pglite.js","sourceRoot":"","sources":["../../../../../src/connectors/postgres/drivers/pglite.ts"],"names":[],"mappings":"AAAA,4JAA4J;AAC5J,cAAc,2CAA2C,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/postgres/pglite` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/postgres/pglite';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/postgres/drivers/postgres-js.ts"],"names":[],"mappings":"AAAA,iKAAiK;AACjK,cAAc,gDAAgD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-js.js","sourceRoot":"","sources":["../../../../../src/connectors/postgres/drivers/postgres-js.ts"],"names":[],"mappings":"AAAA,iKAAiK;AACjK,cAAc,gDAAgD,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/postgres/postgres-js` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/postgres/postgres-js';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/postgres/index.ts"],"names":[],"mappings":"AAAA,qJAAqJ;AACrJ,cAAc,oCAAoC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/postgres/index.ts"],"names":[],"mappings":"AAAA,qJAAqJ;AACrJ,cAAc,oCAAoC,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/postgres` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/postgres';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/postgres/supabase/index.ts"],"names":[],"mappings":"AAAA,8JAA8J;AAC9J,cAAc,6CAA6C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/connectors/postgres/supabase/index.ts"],"names":[],"mappings":"AAAA,8JAA8J;AAC9J,cAAc,6CAA6C,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/postgres/supabase` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/postgres/supabase';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/relational/index.ts"],"names":[],"mappings":"AAAA,uJAAuJ;AACvJ,cAAc,sCAAsC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/relational/index.ts"],"names":[],"mappings":"AAAA,uJAAuJ;AACvJ,cAAc,sCAAsC,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/relational` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/relational';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/search/controllers/index.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAC/J,cAAc,8CAA8C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/connectors/search/controllers/index.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAC/J,cAAc,8CAA8C,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/search/controllers` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/search/controllers';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/search/index.ts"],"names":[],"mappings":"AAAA,mJAAmJ;AACnJ,cAAc,kCAAkC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/search/index.ts"],"names":[],"mappings":"AAAA,mJAAmJ;AACnJ,cAAc,kCAAkC,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/search` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/search';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"libsql.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/sqlite/drivers/libsql.ts"],"names":[],"mappings":"AAAA,0JAA0J;AAC1J,cAAc,yCAAyC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"libsql.js","sourceRoot":"","sources":["../../../../../src/connectors/sqlite/drivers/libsql.ts"],"names":[],"mappings":"AAAA,0JAA0J;AAC1J,cAAc,yCAAyC,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/sqlite/libsql` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/sqlite/libsql';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/sqlite/index.ts"],"names":[],"mappings":"AAAA,mJAAmJ;AACnJ,cAAc,kCAAkC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/sqlite/index.ts"],"names":[],"mappings":"AAAA,mJAAmJ;AACnJ,cAAc,kCAAkC,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/sqlite` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/sqlite';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/typesense/controllers/index.ts"],"names":[],"mappings":"AAAA,kKAAkK;AAClK,cAAc,iDAAiD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/connectors/typesense/controllers/index.ts"],"names":[],"mappings":"AAAA,kKAAkK;AAClK,cAAc,iDAAiD,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/typesense/controllers` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/typesense/controllers';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connectors/typesense/index.ts"],"names":[],"mappings":"AAAA,sJAAsJ;AACtJ,cAAc,qCAAqC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connectors/typesense/index.ts"],"names":[],"mappings":"AAAA,sJAAsJ;AACtJ,cAAc,qCAAqC,CAAC","sourcesContent":["/** Alias barrel - the connectors moved to `@venizia/ignis-connectors`. Kept so `@venizia/ignis/typesense` keeps resolving for published consumers. */\nexport * from '@venizia/ignis-connectors/typesense';\n"]}
|