@authup/server-kit 1.0.0-beta.46 → 1.0.0-beta.48
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/cache/adapters/index.d.ts.map +1 -0
- package/dist/cache/adapters/memory.d.ts.map +1 -0
- package/dist/cache/adapters/redis.d.ts.map +1 -0
- package/dist/cache/helper.d.ts.map +1 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/crypto/json-web-token/index.d.ts +1 -1
- package/dist/crypto/json-web-token/index.d.ts.map +1 -1
- package/dist/crypto/json-web-token/sign/types.d.ts +1 -1
- package/dist/crypto/json-web-token/sign/types.d.ts.map +1 -1
- package/dist/crypto/json-web-token/{type.d.ts → types.d.ts} +1 -1
- package/dist/crypto/json-web-token/types.d.ts.map +1 -0
- package/dist/crypto/json-web-token/verify/types.d.ts +1 -1
- package/dist/crypto/json-web-token/verify/types.d.ts.map +1 -1
- package/dist/domain-event/handlers/index.d.ts +3 -0
- package/dist/domain-event/handlers/index.d.ts.map +1 -0
- package/dist/domain-event/handlers/redis/index.d.ts.map +1 -0
- package/dist/domain-event/handlers/redis/module.d.ts +9 -0
- package/dist/domain-event/handlers/redis/module.d.ts.map +1 -0
- package/dist/domain-event/handlers/socket/index.d.ts.map +1 -0
- package/dist/domain-event/handlers/socket/module.d.ts +9 -0
- package/dist/domain-event/handlers/socket/module.d.ts.map +1 -0
- package/dist/domain-event/index.d.ts +2 -3
- package/dist/domain-event/index.d.ts.map +1 -1
- package/dist/domain-event/module.d.ts +11 -4
- package/dist/domain-event/module.d.ts.map +1 -1
- package/dist/domain-event/{type.d.ts → types.d.ts} +6 -1
- package/dist/domain-event/types.d.ts.map +1 -0
- package/dist/domain-event/utils.d.ts +1 -1
- package/dist/domain-event/utils.d.ts.map +1 -1
- package/dist/index.d.mts +109 -100
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +199 -210
- package/dist/index.mjs.map +1 -1
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/module.d.ts.map +1 -0
- package/dist/logger/types.d.ts +17 -0
- package/dist/logger/types.d.ts.map +1 -0
- package/dist/redis/check.d.ts.map +1 -0
- package/dist/redis/factory.d.ts.map +1 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/module.d.ts.map +1 -0
- package/package.json +13 -15
- package/dist/crypto/json-web-token/type.d.ts.map +0 -1
- package/dist/domain-event/redis/index.d.ts.map +0 -1
- package/dist/domain-event/redis/module.d.ts +0 -9
- package/dist/domain-event/redis/module.d.ts.map +0 -1
- package/dist/domain-event/socket/index.d.ts.map +0 -1
- package/dist/domain-event/socket/module.d.ts +0 -9
- package/dist/domain-event/socket/module.d.ts.map +0 -1
- package/dist/domain-event/type.d.ts.map +0 -1
- package/dist/services/cache/adapters/index.d.ts.map +0 -1
- package/dist/services/cache/adapters/memory.d.ts.map +0 -1
- package/dist/services/cache/adapters/redis.d.ts.map +0 -1
- package/dist/services/cache/helper.d.ts.map +0 -1
- package/dist/services/cache/index.d.ts.map +0 -1
- package/dist/services/cache/types.d.ts.map +0 -1
- package/dist/services/index.d.ts +0 -5
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/logger/index.d.ts +0 -4
- package/dist/services/logger/index.d.ts.map +0 -1
- package/dist/services/logger/module.d.ts.map +0 -1
- package/dist/services/logger/singleton.d.ts +0 -7
- package/dist/services/logger/singleton.d.ts.map +0 -1
- package/dist/services/logger/types.d.ts +0 -7
- package/dist/services/logger/types.d.ts.map +0 -1
- package/dist/services/redis/check.d.ts.map +0 -1
- package/dist/services/redis/factory.d.ts.map +0 -1
- package/dist/services/redis/index.d.ts.map +0 -1
- package/dist/services/redis/module.d.ts.map +0 -1
- package/dist/services/vault/index.d.ts +0 -3
- package/dist/services/vault/index.d.ts.map +0 -1
- package/dist/services/vault/module.d.ts +0 -3
- package/dist/services/vault/module.d.ts.map +0 -1
- package/dist/services/vault/singleton.d.ts +0 -6
- package/dist/services/vault/singleton.d.ts.map +0 -1
- /package/dist/{services/cache → cache}/adapters/index.d.ts +0 -0
- /package/dist/{services/cache → cache}/adapters/memory.d.ts +0 -0
- /package/dist/{services/cache → cache}/adapters/redis.d.ts +0 -0
- /package/dist/{services/cache → cache}/helper.d.ts +0 -0
- /package/dist/{services/cache → cache}/index.d.ts +0 -0
- /package/dist/{services/cache → cache}/types.d.ts +0 -0
- /package/dist/domain-event/{redis → handlers/redis}/index.d.ts +0 -0
- /package/dist/domain-event/{socket → handlers/socket}/index.d.ts +0 -0
- /package/dist/{services/logger → logger}/module.d.ts +0 -0
- /package/dist/{services/redis → redis}/check.d.ts +0 -0
- /package/dist/{services/redis → redis}/factory.d.ts +0 -0
- /package/dist/{services/redis → redis}/index.d.ts +0 -0
- /package/dist/{services/redis → redis}/module.d.ts +0 -0
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["compareMethod","hashMethod","isObject","isObject","create","instance"],"sources":["../src/core/service.ts","../src/crypto/hash/compare.ts","../src/crypto/hash/hash.ts","../src/crypto/key/asymmetric/constants.ts","../src/crypto/key/base.ts","../src/crypto/key/asymmetric/helpers/wrap.ts","../src/crypto/key/asymmetric/key-usages.ts","../src/crypto/key/asymmetric/normalize.ts","../src/crypto/key/asymmetric/module.ts","../src/crypto/key/asymmetric/check.ts","../src/crypto/key/asymmetric/create.ts","../src/crypto/key/symmetric/constants.ts","../src/crypto/key/symmetric/check.ts","../src/crypto/key/symmetric/key-usages.ts","../src/crypto/key/symmetric/normalize.ts","../src/crypto/key/symmetric/module.ts","../src/crypto/key/symmetric/create.ts","../src/crypto/json-web-token/extract.ts","../src/crypto/json-web-token/utils.ts","../src/crypto/json-web-token/sign/module.ts","../src/crypto/json-web-token/verify/module.ts","../src/domain-event/module.ts","../src/services/cache/adapters/memory.ts","../src/services/redis/check.ts","../src/services/redis/factory.ts","../src/services/cache/adapters/redis.ts","../src/services/cache/helper.ts","../src/services/logger/module.ts","../src/services/logger/singleton.ts","../src/services/vault/singleton.ts","../src/domain-event/utils.ts","../src/domain-event/redis/module.ts","../src/domain-event/socket/module.ts","../src/utils/has-property.ts"],"sourcesContent":["/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { REALM_MASTER_NAME } from '@authup/core-kit';\nimport { isObject } from '@authup/kit';\nimport type { ActorContext } from './actor/types';\n\nexport abstract class AbstractEntityService {\n protected isActorMasterRealmMember(actor: ActorContext): boolean {\n if (!actor.identity) {\n return false;\n }\n\n const { data } = actor.identity;\n if ('realm' in data && data.realm && typeof data.realm === 'object' && 'name' in data.realm) {\n return data.realm.name === REALM_MASTER_NAME;\n }\n\n return false;\n }\n\n protected getActorRealmId(actor: ActorContext): string | undefined {\n if (!actor.identity) {\n return undefined;\n }\n\n const { data } = actor.identity;\n if (data.realm_id) {\n return data.realm_id;\n }\n\n if (isObject(data.realm) && data.realm.id) {\n return data.realm.id;\n }\n\n return undefined;\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { compare as compareMethod } from '@node-rs/bcrypt';\n\nexport async function compare(value: string, hashedValue: string) : Promise<boolean> {\n return compareMethod(value, hashedValue);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hash as hashMethod } from '@node-rs/bcrypt';\n\nexport async function hash(str: string, rounds: number = 10) : Promise<string> {\n return hashMethod(str, rounds);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum CryptoAsymmetricAlgorithm {\n RSA_PSS = 'RSA-PSS',\n RSASSA_PKCS1_V1_5 = 'RSASSA-PKCS1-v1_5',\n RSA_OAEP = 'RSA-OAEP',\n ECDSA = 'ECDSA',\n ECDH = 'ECDH',\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { arrayBufferToBase64 } from '@authup/kit';\nimport { subtle } from 'uncrypto';\n\nexport abstract class BaseKey {\n protected key : CryptoKey;\n\n // ----------------------------------------------\n\n constructor(cryptoKey : CryptoKey) {\n this.key = cryptoKey;\n }\n\n // ----------------------------------------------\n\n async toArrayBuffer(): Promise<ArrayBuffer> {\n if (this.key.type === 'private') {\n return subtle.exportKey('pkcs8', this.key);\n }\n\n if (this.key.type === 'public') {\n return subtle.exportKey('spki', this.key);\n }\n\n return subtle.exportKey('raw', this.key);\n }\n\n async toUint8Array(): Promise<Uint8Array> {\n const arrayBuffer = await this.toArrayBuffer();\n return new Uint8Array(arrayBuffer);\n }\n\n async toBase64() : Promise<string> {\n const arrayBuffer = await this.toArrayBuffer();\n return arrayBufferToBase64(arrayBuffer);\n }\n\n async toJWK() : Promise<JsonWebKey> {\n return subtle.exportKey('jwk', this.key);\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nfunction enc(\n type: 'PRIVATE KEY' | 'PUBLIC KEY',\n input: string,\n) {\n return `-----BEGIN ${type}-----\\n${input}\\n-----END ${type}-----`;\n}\n\nexport function encodePKCS8ToPEM(base64: string) {\n return enc('PRIVATE KEY', base64);\n}\n\nexport function encodeSPKIToPem(input: string) {\n return enc('PUBLIC KEY', input);\n}\n\n// ------------------------------------------------------------\n\nfunction dec(\n type: 'PRIVATE KEY' | 'PUBLIC KEY',\n input: string,\n) {\n input = input.replace(`-----BEGIN ${type}-----\\n`, '');\n\n input = input.replace(`\\n-----END ${type}-----\\n`, '');\n input = input.replace(`-----END ${type}-----\\n`, '');\n input = input.replace(`\\n-----END ${type}-----`, '');\n\n return input;\n}\n\nexport function decodePemToPKCS8(input: string) {\n return dec('PRIVATE KEY', input);\n}\n\nexport function decodePemToSpki(input: string) {\n return dec('PUBLIC KEY', input);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { CryptoAsymmetricAlgorithm } from './constants';\n\n/**\n * @see https://nodejs.org/api/webcrypto.html#cryptokeyusages\n */\nexport function getKeyUsagesForAsymmetricAlgorithm(\n name: string,\n format?: Exclude<KeyFormat, 'jwk'>,\n) : KeyUsage[] {\n if (\n name === CryptoAsymmetricAlgorithm.RSA_PSS ||\n name === CryptoAsymmetricAlgorithm.ECDSA ||\n name === CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5\n ) {\n if (format === 'spki') {\n return ['verify'];\n } if (format === 'pkcs8') {\n return ['sign'];\n }\n\n return ['sign', 'verify'];\n }\n\n if (name === CryptoAsymmetricAlgorithm.ECDH) {\n if (format === 'spki') {\n return [];\n }\n\n return [\n 'deriveKey',\n 'deriveBits',\n ];\n }\n\n if (name === CryptoAsymmetricAlgorithm.RSA_OAEP) {\n if (format === 'spki') {\n return ['encrypt'];\n } if (format === 'pkcs8') {\n return ['decrypt'];\n }\n\n return ['encrypt', 'decrypt'];\n }\n\n throw new SyntaxError(`Key usages can not be determined for asymmetric algorithm: ${name}`);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { CryptoAsymmetricAlgorithm } from './constants';\nimport type {\n AsymmetricKeyImportOptionsInput,\n AsymmetricKeyPairCreateOptions,\n AsymmetricKeyPairCreateOptionsInput,\n AsymmetricKeyPairImportOptions,\n} from './types';\n\nexport function normalizeAsymmetricKeyPairCreateOptions(\n options: AsymmetricKeyPairCreateOptionsInput,\n) : AsymmetricKeyPairCreateOptions {\n let optionsNormalized : AsymmetricKeyPairCreateOptions;\n switch (options.name) {\n case CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5:\n case CryptoAsymmetricAlgorithm.RSA_PSS:\n case CryptoAsymmetricAlgorithm.RSA_OAEP: {\n optionsNormalized = {\n modulusLength: 2048,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: 'SHA-256',\n ...options,\n };\n break;\n }\n case CryptoAsymmetricAlgorithm.ECDSA:\n case CryptoAsymmetricAlgorithm.ECDH: {\n optionsNormalized = {\n namedCurve: 'P-256',\n ...options,\n };\n }\n }\n\n return optionsNormalized;\n}\n\nexport function normalizeAsymmetricKeyImportOptions(\n options: AsymmetricKeyImportOptionsInput,\n) : AsymmetricKeyPairImportOptions {\n let optionsNormalized : AsymmetricKeyPairImportOptions;\n switch (options.name) {\n case CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5:\n case CryptoAsymmetricAlgorithm.RSA_PSS:\n case CryptoAsymmetricAlgorithm.RSA_OAEP: {\n optionsNormalized = {\n hash: 'SHA-256',\n ...options,\n };\n break;\n }\n case CryptoAsymmetricAlgorithm.ECDSA:\n case CryptoAsymmetricAlgorithm.ECDH: {\n optionsNormalized = {\n namedCurve: 'P-256',\n ...options,\n };\n }\n }\n\n return optionsNormalized;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { base64ToArrayBuffer } from '@authup/kit';\nimport { JWTAlgorithm } from '@authup/specs';\nimport { subtle } from 'uncrypto';\nimport { BaseKey } from '../base';\nimport { CryptoAsymmetricAlgorithm } from './constants';\nimport type { AsymmetricKeyImportContext } from './types';\nimport {\n decodePemToPKCS8, \n decodePemToSpki, \n encodePKCS8ToPEM, \n encodeSPKIToPem,\n} from './helpers';\nimport { getKeyUsagesForAsymmetricAlgorithm } from './key-usages';\nimport { normalizeAsymmetricKeyImportOptions } from './normalize';\n\nexport class AsymmetricKey extends BaseKey {\n async toPem(): Promise<string> {\n const base64 = await this.toBase64();\n\n if (this.key.type === 'public') {\n return encodeSPKIToPem(base64);\n }\n\n if (this.key.type === 'private') {\n return encodePKCS8ToPEM(base64);\n }\n\n throw new Error(`${this.key.type} can not be converted to pem.`);\n }\n\n // ----------------------------------------------------------------\n\n static async fromPem(ctx: AsymmetricKeyImportContext<string>): Promise<AsymmetricKey> {\n if (ctx.format === 'pkcs8') {\n return AsymmetricKey.fromBase64({\n ...ctx,\n key: decodePemToPKCS8(ctx.key), \n });\n }\n return AsymmetricKey.fromBase64({\n ...ctx,\n key: decodePemToSpki(ctx.key), \n });\n }\n\n static async fromBase64(\n ctx: AsymmetricKeyImportContext<string>,\n ) : Promise<AsymmetricKey> {\n const arrayBuffer = base64ToArrayBuffer(ctx.key);\n\n return AsymmetricKey.fromArrayBuffer({\n ...ctx,\n key: arrayBuffer,\n });\n }\n\n static async fromArrayBuffer(\n ctx: AsymmetricKeyImportContext<ArrayBuffer>,\n ) : Promise<AsymmetricKey> {\n const normalizedOptions = normalizeAsymmetricKeyImportOptions(ctx.options);\n\n const cryptoKey = await subtle.importKey(\n ctx.format,\n ctx.key,\n normalizedOptions,\n true,\n getKeyUsagesForAsymmetricAlgorithm(normalizedOptions.name, ctx.format),\n );\n\n return new AsymmetricKey(cryptoKey);\n }\n\n // ----------------------------------------------------------------\n\n static buildImportOptionsForJWTAlgorithm(alg: `${JWTAlgorithm}`) {\n if (alg === JWTAlgorithm.RS256) {\n return {\n name: CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5,\n hash: 'SHA-256',\n };\n }\n\n if (alg === JWTAlgorithm.RS384) {\n return {\n name: CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5,\n hash: 'SHA-384',\n };\n }\n\n if (alg === JWTAlgorithm.RS512) {\n return {\n name: CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5,\n hash: 'SHA-512',\n };\n }\n\n if (alg === JWTAlgorithm.ES256) {\n return {\n name: CryptoAsymmetricAlgorithm.ECDSA,\n namedCurve: 'P-256',\n };\n }\n\n if (alg === JWTAlgorithm.ES384) {\n return {\n name: CryptoAsymmetricAlgorithm.ECDSA,\n namedCurve: 'P-384',\n };\n }\n\n if (alg === JWTAlgorithm.ES512) {\n return {\n name: CryptoAsymmetricAlgorithm.ECDSA,\n namedCurve: 'P-521',\n };\n }\n\n throw new Error(`Signature algorithm ${alg} is not supported.`);\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { CryptoAsymmetricAlgorithm } from './constants';\n\nexport function isAsymmetricAlgorithm(input: string) : input is CryptoAsymmetricAlgorithm {\n return (Object.values(CryptoAsymmetricAlgorithm) as string[]).includes(input);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { subtle } from 'uncrypto';\nimport { getKeyUsagesForAsymmetricAlgorithm } from './key-usages';\nimport { normalizeAsymmetricKeyPairCreateOptions } from './normalize';\nimport type { AsymmetricKeyPairCreateOptionsInput } from './types';\n\nexport async function createAsymmetricKeyPair(options: AsymmetricKeyPairCreateOptionsInput) : Promise<CryptoKeyPair> {\n const optionsNormalized = normalizeAsymmetricKeyPairCreateOptions(options);\n return subtle.generateKey(\n optionsNormalized,\n true,\n getKeyUsagesForAsymmetricAlgorithm(optionsNormalized.name),\n );\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum SymmetricAlgorithm {\n HMAC = 'HMAC',\n AES_CTR = 'AES-CTR',\n AES_CBC = 'AES-CBC',\n AES_GCM = 'AES-GCM',\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SymmetricAlgorithm } from './constants';\n\nexport function isSymmetricAlgorithm(input: string) : input is SymmetricAlgorithm {\n return (Object.values(SymmetricAlgorithm) as string[]).includes(input);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SymmetricAlgorithm } from './constants';\n\nexport function getKeyUsagesForSymmetricAlgorithm(name: string) : KeyUsage[] {\n /**\n * @see https://nodejs.org/api/webcrypto.html#cryptokeyusages\n */\n if (name === SymmetricAlgorithm.HMAC) {\n return [\n 'sign',\n 'verify',\n ];\n }\n\n if (\n name === SymmetricAlgorithm.AES_CBC ||\n name === SymmetricAlgorithm.AES_GCM ||\n name === SymmetricAlgorithm.AES_CTR\n ) {\n return [\n 'encrypt',\n 'decrypt',\n ];\n }\n\n throw new SyntaxError(`Key usages can not be determined for symmetric algorithm: ${name}`);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SymmetricAlgorithm } from './constants';\nimport type {\n SymmetricKeyCreateOptions, \n SymmetricKeyCreateOptionsInput, \n SymmetricKeyImportOptions, \n SymmetricKeyImportOptionsInput,\n} from './types';\n\nexport function normalizeSymmetricKeyCreateOptions(\n input: SymmetricKeyCreateOptionsInput,\n) : SymmetricKeyCreateOptions {\n if (input.name === SymmetricAlgorithm.HMAC) {\n return {\n hash: 'SHA-256',\n ...input,\n };\n }\n\n return {\n length: 256,\n name: input.name,\n };\n}\n\nexport function normalizeSymmetricKeyImportOptions(\n input: SymmetricKeyImportOptionsInput,\n) : SymmetricKeyImportOptions {\n if (input.name === SymmetricAlgorithm.HMAC) {\n return {\n hash: 'SHA-256',\n ...input,\n };\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { base64ToArrayBuffer } from '@authup/kit';\nimport { JWTAlgorithm } from '@authup/specs';\nimport { subtle } from 'uncrypto';\nimport { BaseKey } from '../base';\nimport { SymmetricAlgorithm } from './constants';\nimport { getKeyUsagesForSymmetricAlgorithm } from './key-usages';\nimport { normalizeSymmetricKeyImportOptions } from './normalize';\nimport type { SymmetricKeyImportContext, SymmetricKeyImportOptions } from './types';\n\nexport class SymmetricKey extends BaseKey {\n static async fromBase64(\n ctx: SymmetricKeyImportContext<string>,\n ) : Promise<SymmetricKey> {\n const arrayBuffer = base64ToArrayBuffer(ctx.key);\n\n return SymmetricKey.fromArrayBuffer({\n ...ctx,\n key: arrayBuffer,\n });\n }\n\n static async fromArrayBuffer(\n ctx: SymmetricKeyImportContext<ArrayBuffer>,\n ) : Promise<SymmetricKey> {\n const normalizedOptions : SymmetricKeyImportOptions = normalizeSymmetricKeyImportOptions(ctx.options);\n\n const cryptoKey = await subtle.importKey(\n ctx.format,\n ctx.key,\n normalizedOptions,\n true,\n getKeyUsagesForSymmetricAlgorithm(normalizedOptions.name),\n );\n\n return new SymmetricKey(cryptoKey);\n }\n\n static buildImportOptionsForJWTAlgorithm(alg: `${JWTAlgorithm}`) {\n if (alg === JWTAlgorithm.HS256) {\n return {\n name: SymmetricAlgorithm.HMAC,\n hash: 'SHA-256',\n };\n }\n\n if (alg === JWTAlgorithm.HS384) {\n return {\n name: SymmetricAlgorithm.HMAC,\n hash: 'SHA-384',\n };\n }\n\n if (alg === JWTAlgorithm.HS512) {\n return {\n name: SymmetricAlgorithm.HMAC,\n hash: 'SHA-512',\n };\n }\n\n throw new Error(`Signature algorithm ${alg} is not supported.`);\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { subtle } from 'uncrypto';\nimport { getKeyUsagesForSymmetricAlgorithm } from './key-usages';\nimport { normalizeSymmetricKeyCreateOptions } from './normalize';\nimport type { SymmetricKeyCreateOptionsInput } from './types';\n\nexport async function createSymmetricKey(input: SymmetricKeyCreateOptionsInput) : Promise<CryptoKey> {\n const optionsNormalized = normalizeSymmetricKeyCreateOptions(input);\n\n return subtle.generateKey(\n optionsNormalized,\n true,\n getKeyUsagesForSymmetricAlgorithm(optionsNormalized.name),\n );\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { JWTClaims, JWTHeader } from '@authup/specs';\nimport { JWTError } from '@authup/specs';\n\n/**\n * Decode a JWT token with no verification.\n *\n * @param token\n *\n * @throws JWTError\n */\nexport function extractTokenHeader(\n token: string,\n) : JWTHeader {\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw JWTError.invalid();\n }\n\n const [headerBase64] = parts;\n\n try {\n const payload = atob(headerBase64);\n\n return JSON.parse(payload);\n\n /*\n return {\n typ: 'JWT',\n alg: transformInternalToJWTAlgorithm(header.algorithm),\n cty: header.contentType,\n jku: header.jsonKeyUrl,\n kid: header.keyId,\n x5u: header.x5Url,\n x5c: header.x5CertChain,\n x5t: header.x5CertThumbprint,\n 'x5t#S256': header.x5TS256CertThumbprint,\n };\n */\n } catch {\n throw JWTError.headerInvalid('The token header could not be extracted.');\n }\n}\n\n/**\n * @param token\n *\n * @throws JWTError\n */\nexport function extractTokenPayload(\n token: string,\n) : JWTClaims {\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw JWTError.invalid();\n }\n\n const [, payloadBase64] = parts;\n\n try {\n const payload = atob(payloadBase64);\n\n return JSON.parse(payload);\n } catch {\n throw JWTError.payloadInvalid('The token payload could not be extracted.');\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { JWTAlgorithm, JWTError } from '@authup/specs';\nimport { Algorithm } from '@node-rs/jsonwebtoken';\nimport { isObject } from 'smob';\n\nexport function createErrorForJWTError(e: unknown) : JWTError {\n if (isObject(e)) {\n if (typeof e.name === 'string') {\n switch (e.name) {\n case 'TokenExpiredError': {\n return JWTError.expired();\n }\n case 'NotBeforeError': {\n if (typeof e.date === 'string' || e.date instanceof Date) {\n return JWTError.notActiveBefore(e.date);\n }\n break;\n }\n case 'JsonWebTokenError': {\n if (typeof e.message === 'string') {\n return JWTError.payloadInvalid(e.message);\n }\n\n break;\n }\n }\n }\n\n // @see https://github.com/Keats/jsonwebtoken/blob/master/src/errors.rs\n switch (e.message) {\n case 'ExpiredSignature': {\n return JWTError.expired();\n }\n case 'ImmatureSignature': {\n return JWTError.notActiveBefore();\n }\n case 'InvalidToken':\n case 'InvalidSignature': {\n return JWTError.payloadInvalid();\n }\n }\n }\n\n return new JWTError({\n cause: e as Error,\n message: 'The JWT error could not be determined.',\n });\n}\n\nexport function transformJWTAlgorithmToInternal(algorithm: `${JWTAlgorithm}`) : Algorithm {\n switch (algorithm) {\n case JWTAlgorithm.HS256: {\n return Algorithm.HS256;\n }\n case JWTAlgorithm.HS384: {\n return Algorithm.HS384;\n }\n case JWTAlgorithm.HS512: {\n return Algorithm.HS512;\n }\n case JWTAlgorithm.RS256: {\n return Algorithm.RS256;\n }\n case JWTAlgorithm.RS384: {\n return Algorithm.RS384;\n }\n case JWTAlgorithm.RS512: {\n return Algorithm.RS512;\n }\n case JWTAlgorithm.ES256: {\n return Algorithm.ES256;\n }\n case JWTAlgorithm.ES384: {\n return Algorithm.ES384;\n }\n case JWTAlgorithm.PS256: {\n return Algorithm.PS256;\n }\n case JWTAlgorithm.PS384: {\n return Algorithm.PS384;\n }\n case JWTAlgorithm.PS512: {\n return Algorithm.PS512;\n }\n }\n\n throw new Error(`The algorithm ${algorithm} is not supported.`);\n}\n\nexport function transformInternalToJWTAlgorithm(input: Algorithm) : JWTAlgorithm {\n switch (input) {\n case Algorithm.HS256:\n return JWTAlgorithm.HS256;\n case Algorithm.HS384:\n return JWTAlgorithm.HS384;\n case Algorithm.HS512:\n return JWTAlgorithm.HS512;\n case Algorithm.RS256:\n return JWTAlgorithm.RS256;\n case Algorithm.RS384:\n return JWTAlgorithm.RS384;\n case Algorithm.RS512:\n return JWTAlgorithm.RS512;\n case Algorithm.ES256:\n return JWTAlgorithm.ES256;\n case Algorithm.ES384:\n return JWTAlgorithm.ES384;\n case Algorithm.PS256:\n return JWTAlgorithm.PS256;\n case Algorithm.PS384:\n return JWTAlgorithm.PS384;\n case Algorithm.PS512:\n return JWTAlgorithm.PS512;\n }\n\n throw new SyntaxError(`The algorithm ${input} is not supported.`);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { JWKType, JWTError } from '@authup/specs';\nimport type { JWTClaims } from '@authup/specs';\nimport { Algorithm, sign } from '@node-rs/jsonwebtoken';\nimport { AsymmetricKey, SymmetricKey, encodePKCS8ToPEM } from '../../key';\nimport { transformJWTAlgorithmToInternal } from '../utils';\nimport type { TokenSignOptions } from './types';\n\nconst getUtcTimestamp = () => Math.floor(new Date().getTime() / 1000);\n\nexport async function signToken(claims: JWTClaims, context: TokenSignOptions): Promise<string> {\n if (typeof claims.exp !== 'number') {\n claims.exp = getUtcTimestamp() + 3600;\n }\n if (typeof claims.iat !== 'number') {\n claims.iat = getUtcTimestamp();\n }\n\n switch (context.type) {\n case JWKType.RSA:\n case JWKType.EC: {\n let algorithm : Algorithm;\n\n let key : string;\n if (typeof context.key === 'string') {\n key = encodePKCS8ToPEM(context.key);\n } else {\n const keyContainer = new AsymmetricKey(context.key);\n key = await keyContainer.toPem();\n }\n\n if (context.type === JWKType.RSA) {\n algorithm = context.algorithm ?\n transformJWTAlgorithmToInternal(context.algorithm) :\n Algorithm.RS256;\n } else {\n algorithm = context.algorithm ?\n transformJWTAlgorithmToInternal(context.algorithm) :\n Algorithm.ES256;\n }\n\n return sign(claims, key, {\n algorithm,\n keyId: context.keyId,\n });\n }\n case JWKType.OCT: {\n const algorithm : Algorithm = context.algorithm ?\n transformJWTAlgorithmToInternal(context.algorithm) :\n Algorithm.HS256;\n\n let key : string | Uint8Array;\n if (typeof context.key === 'string') {\n key = context.key;\n } else {\n const keyContainer = new SymmetricKey(context.key);\n key = await keyContainer.toUint8Array();\n }\n\n return sign(claims, key, {\n algorithm,\n keyId: context.keyId,\n });\n }\n }\n\n throw new JWTError();\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { JWKType, JWTError } from '@authup/specs';\nimport type { JWTClaims, OAuth2TokenPayload } from '@authup/specs';\nimport { Algorithm, verify } from '@node-rs/jsonwebtoken';\nimport { AsymmetricKey, SymmetricKey, encodeSPKIToPem } from '../../key';\nimport { createErrorForJWTError, transformJWTAlgorithmToInternal } from '../utils';\nimport type { TokenVerifyOptions } from './types';\n\n/**\n * Verify JWT.\n *\n * @param token\n * @param context\n *\n * @throws OAuth2Error\n */\nexport async function verifyToken(\n token: string,\n context: TokenVerifyOptions,\n) : Promise<OAuth2TokenPayload> {\n let promise : Promise<JWTClaims> | undefined;\n\n let output : JWTClaims | undefined;\n\n try {\n switch (context.type) {\n case JWKType.RSA:\n case JWKType.EC: {\n let algorithms : Algorithm[];\n\n if (context.type === JWKType.RSA) {\n algorithms = context.algorithms ?\n context.algorithms.map((algorithm) => transformJWTAlgorithmToInternal(algorithm)) :\n [\n Algorithm.RS256,\n Algorithm.RS384,\n Algorithm.RS512,\n Algorithm.PS256,\n Algorithm.PS384,\n Algorithm.PS512,\n ];\n } else {\n algorithms = context.algorithms ?\n context.algorithms.map((algorithm) => transformJWTAlgorithmToInternal(algorithm)) :\n [\n Algorithm.ES256,\n Algorithm.ES384,\n ];\n }\n\n let key : string;\n if (typeof context.key === 'string') {\n key = encodeSPKIToPem(context.key);\n } else {\n const keyContainer = new AsymmetricKey(context.key);\n key = await keyContainer.toPem();\n }\n\n promise = verify(token, key, {\n algorithms,\n validateNbf: true,\n });\n break;\n }\n case JWKType.OCT: {\n const algorithms : Algorithm[] = context.algorithms ?\n context.algorithms.map((algorithm) => transformJWTAlgorithmToInternal(algorithm)) :\n [\n Algorithm.HS256,\n Algorithm.HS384,\n Algorithm.HS512,\n ];\n\n let key : string | Uint8Array;\n if (typeof context.key === 'string') {\n key = context.key;\n } else {\n const keyContainer = new SymmetricKey(context.key);\n key = await keyContainer.toUint8Array();\n }\n\n promise = verify(token, key, {\n algorithms,\n validateNbf: true,\n });\n }\n }\n\n if (promise) {\n output = await promise;\n }\n } catch (e) {\n throw createErrorForJWTError(e);\n }\n\n if (!output) {\n throw new JWTError();\n }\n\n return output as OAuth2TokenPayload;\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { EventPayload } from '@authup/core-realtime-kit';\nimport type { DomainEventPublishContext, IDomainEventPublisher } from './type';\n\nexport class DomainEventPublisher implements IDomainEventPublisher {\n protected publishers : Set<IDomainEventPublisher>;\n\n constructor() {\n this.publishers = new Set<IDomainEventPublisher>();\n }\n\n mount(publisher: IDomainEventPublisher): void {\n this.publishers.add(publisher);\n }\n\n async publish<T extends EventPayload>(\n ctx: DomainEventPublishContext<T>,\n ) : Promise<void> {\n const publishers = this.publishers.values();\n while (true) {\n const it = publishers.next();\n if (it.done) {\n return;\n }\n\n await it.value.publish(ctx);\n }\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { TTLCacheOptions } from '@isaacs/ttlcache';\nimport { TTLCache } from '@isaacs/ttlcache';\nimport type { CacheClearOptions, CacheSetOptions, ICache } from '../types';\n\nexport class MemoryCache implements ICache {\n protected instance : TTLCache<string, unknown>;\n\n constructor(options: TTLCacheOptions<string, unknown> = {}) {\n this.instance = new TTLCache<string, unknown>({\n checkAgeOnGet: true,\n ttl: Infinity,\n ...(options || {}),\n });\n }\n\n async pop<T = unknown>(key: string): Promise<T | null> {\n if (this.instance.has(key)) {\n const output = this.instance.get(key);\n this.instance.delete(key);\n return output as T;\n }\n\n return null;\n }\n\n async has(key: string) : Promise<boolean> {\n return this.instance.has(key);\n }\n\n async get<T =unknown>(key: string): Promise<T | null> {\n const output = await this.instance.get(key);\n if (output) {\n return output as T;\n }\n\n return null;\n }\n\n async set(key: string, value: unknown, options: CacheSetOptions): Promise<void> {\n this.instance.set(key, value, { ttl: options.ttl });\n }\n\n async drop(key: string): Promise<void> {\n this.instance.delete(key);\n }\n\n async dropMany(keys: string[]) : Promise<void> {\n for (const key of keys) {\n this.instance.delete(key);\n }\n }\n\n async clear(options: CacheClearOptions = {}) : Promise<void> {\n if (options.prefix) {\n const keys = this.instance.keys();\n let iterator = keys.next();\n while (!iterator.done) {\n if (typeof iterator.value !== 'string') {\n continue;\n }\n\n if (iterator.value.startsWith(options.prefix)) {\n this.instance.delete(iterator.value);\n }\n\n iterator = keys.next();\n }\n\n return;\n }\n\n this.instance.clear();\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from 'smob';\nimport type { RedisClient } from './module';\n\nexport function isRedisClient(data: unknown) : data is RedisClient {\n return isObject(data) &&\n typeof data.connect === 'function' &&\n typeof data.disconnect === 'function';\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createClient } from 'redis-extension';\nimport { isRedisClient } from './check';\nimport type { RedisClient, RedisClientOptions } from './module';\n\nexport type RedisClientCreateInput = string | boolean | RedisClient | RedisClientOptions;\n\nexport function createRedisClient(input: RedisClientCreateInput) {\n if (typeof input === 'boolean') {\n return createClient({ connectionString: 'redis://127.0.0.1' });\n }\n\n if (typeof input === 'string') {\n return createClient({ connectionString: input });\n }\n\n if (!isRedisClient(input)) {\n return createClient({ options: input });\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'redis-extension';\nimport { JsonAdapter } from 'redis-extension';\nimport type { RedisClient, RedisClientOptions } from '../../redis';\nimport { createRedisClient } from '../../redis';\nimport type { CacheClearOptions, CacheSetOptions, ICache } from '../types';\n\nexport class RedisCache implements ICache {\n protected client : Client;\n\n protected jsonAdapter : JsonAdapter;\n\n constructor(input: string | boolean | RedisClient | RedisClientOptions) {\n this.client = createRedisClient(input);\n this.jsonAdapter = new JsonAdapter(this.client);\n }\n\n async get(key: string): Promise<any> {\n const output = await this.jsonAdapter.get(key);\n if (output) {\n return output;\n }\n\n return null;\n }\n\n async pop<T = unknown>(key: string): Promise<T | null> {\n const raw = await this.client.getdel(key);\n if (!raw) {\n return null;\n }\n\n try {\n return JSON.parse(raw) as T;\n } catch {\n return null;\n }\n }\n\n async has(key: string) : Promise<boolean> {\n const output = await this.get(key);\n\n return !!output;\n }\n\n async set(key: string, value: any, options: CacheSetOptions): Promise<void> {\n await this.jsonAdapter.set(key, value, { milliseconds: options.ttl });\n }\n\n async drop(key: string): Promise<void> {\n await this.jsonAdapter.drop(key);\n }\n\n async dropMany(keys: string[]) : Promise<void> {\n const pipeline = this.client.pipeline();\n\n for (const key of keys) {\n pipeline.del(key);\n }\n\n await pipeline.exec();\n }\n\n async clear(options: CacheClearOptions = {}) : Promise<void> {\n if (options.prefix) {\n const pipeline = this.client.pipeline();\n\n const keys = await this.client.keys(`${options.prefix}*`);\n for (const key of keys) {\n pipeline.del(key);\n }\n\n await pipeline.exec();\n\n return;\n }\n await this.client.flushdb();\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildRedisKeyPath } from '../redis';\nimport type { CacheKeyBuildOptions } from './types';\n\nexport function buildCacheKey(options: CacheKeyBuildOptions) {\n return buildRedisKeyPath(options);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport process from 'node:process';\nimport type { LoggerOptions } from 'winston';\nimport { createLogger as create, format, transports } from 'winston';\nimport type { Logger, LoggerCreateContext } from './types';\n\nexport function createNoopLogger() : Logger {\n return create({ silent: true });\n}\n\nexport function createLogger(context: LoggerCreateContext) : Logger {\n let items : LoggerOptions['transports'];\n\n const cwd = context.directory || process.cwd();\n\n if (context.env === 'production') {\n items = [\n new transports.Console({ level: 'info' }),\n new transports.File({\n filename: path.join(cwd, 'http.log'),\n level: 'http',\n maxsize: 10 * 1024 * 1024, // 10MB\n maxFiles: 5,\n }),\n new transports.File({\n filename: path.join(cwd, 'error.log'),\n level: 'warn',\n maxsize: 10 * 1024 * 1024, // 10MB\n maxFiles: 5,\n }),\n ];\n } else {\n items = [\n new transports.Console({ level: 'debug' }),\n ];\n }\n\n // @see https://github.com/winstonjs/triple-beam/blob/master/config/npm.js\n return create({\n format: format.combine(\n format.errors({ stack: true }),\n format.timestamp(),\n format.colorize(),\n format.simple(),\n ),\n transports: items,\n });\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { type Factory, singa } from 'singa';\nimport type { Logger } from 'winston';\n\nconst instance = singa<Logger>({ name: 'logger' });\n\nexport function setLoggerFactory(factory: Factory<Logger>) {\n instance.setFactory(factory);\n}\n\nexport function isLoggerUsable() {\n return instance.has() || instance.hasFactory();\n}\n\nexport function setLogger(input: Logger) {\n instance.set(input);\n}\n\nexport function useLogger() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Factory } from 'singa';\nimport { singa } from 'singa';\nimport type { VaultClient } from '@hapic/vault';\n\nconst instance = singa<VaultClient>({ name: 'vault' });\n\nexport function setVaultFactory(factory: Factory<VaultClient>) {\n instance.setFactory(factory);\n}\n\nexport function isVaultClientUsable() {\n return instance.has() || instance.hasFactory();\n}\n\nexport function useVaultClient() {\n return instance.use();\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from '@authup/kit';\nimport { isObject } from '@authup/kit';\nimport type { DomainEventChannelName } from './type';\n\nexport function transformDomainEventData<T extends ObjectLiteral>(input: T) : T {\n const keys = Object.keys(input);\n for (const key_ of keys) {\n const key = key_ as keyof T;\n\n const value = input[key] as T[keyof T];\n if (!isObject(value)) {\n continue;\n }\n\n if ((value as Record<string, any>) instanceof Date) {\n input[key] = value.toISOString() as T[keyof T];\n }\n }\n\n return input;\n}\n\nexport function buildDomainEventChannelName(\n input: DomainEventChannelName,\n id?: string | number,\n) : string {\n if (typeof input === 'string') {\n return input;\n }\n\n return input(id);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'redis-extension';\nimport type { RedisClientCreateInput } from '../../services';\nimport { createRedisClient } from '../../services';\nimport type { DomainEventPublishContext, IDomainEventPublisher } from '../type';\nimport { buildDomainEventChannelName, transformDomainEventData } from '../utils';\n\nexport class DomainEventRedisPublisher implements IDomainEventPublisher {\n protected driver : Client;\n\n constructor(input: RedisClientCreateInput) {\n this.driver = createRedisClient(input);\n }\n\n async publish(ctx: DomainEventPublishContext) : Promise<void> {\n const data = JSON.stringify(transformDomainEventData(ctx.content));\n\n const pipeline = this.driver.pipeline();\n for (let i = 0; i < ctx.destinations.length; i++) {\n const { namespace } = ctx.destinations[i];\n const keyPrefix = (namespace ? `${namespace}:` : '');\n\n let key = keyPrefix + buildDomainEventChannelName(ctx.destinations[i].channel);\n pipeline.publish(key, data);\n\n if (typeof ctx.destinations[i].channel === 'function') {\n key = keyPrefix + buildDomainEventChannelName(ctx.destinations[i].channel, ctx.content.data.id);\n pipeline.publish(key, data);\n }\n }\n\n await pipeline.exec();\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildEventFullName } from '@authup/core-realtime-kit';\nimport { Emitter } from '@socket.io/redis-emitter';\nimport type { RedisClientCreateInput } from '../../services';\nimport { createRedisClient } from '../../services';\nimport type { DomainEventPublishContext, IDomainEventPublisher } from '../type';\nimport { buildDomainEventChannelName, transformDomainEventData } from '../utils';\n\nexport class DomainEventSocketPublisher implements IDomainEventPublisher {\n protected driver : Emitter;\n\n constructor(input: RedisClientCreateInput) {\n const client = createRedisClient(input);\n this.driver = new Emitter(client);\n }\n\n async publish(ctx: DomainEventPublishContext) : Promise<void> {\n ctx.content = transformDomainEventData(ctx.content);\n\n for (let i = 0; i < ctx.destinations.length; i++) {\n const destination = ctx.destinations[i];\n\n let emitter : Emitter;\n\n if (destination.namespace) {\n emitter = this.driver.of(destination.namespace);\n } else {\n emitter = this.driver;\n }\n\n let roomName = buildDomainEventChannelName(destination.channel);\n\n const fullEventName = buildEventFullName(ctx.content.type, ctx.content.event);\n\n emitter\n .in(roomName)\n .emit(fullEventName, {\n ...ctx.content,\n meta: { roomName },\n });\n\n if (typeof destination.channel === 'function') {\n roomName = buildDomainEventChannelName(destination.channel, ctx.content.data.id);\n\n emitter\n .in(roomName)\n .emit(fullEventName, {\n ...ctx.content,\n meta: {\n roomName,\n roomId: ctx.content.data.id,\n },\n });\n }\n }\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(\n obj: X,\n prop: Y,\n): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,IAAsB,wBAAtB,MAA4C;CACxC,yBAAmC,OAA8B;EAC7D,IAAI,CAAC,MAAM,UACP,OAAO;EAGX,MAAM,EAAE,SAAS,MAAM;EACvB,IAAI,WAAW,QAAQ,KAAK,SAAS,OAAO,KAAK,UAAU,YAAY,UAAU,KAAK,OAClF,OAAO,KAAK,MAAM,SAAS;EAG/B,OAAO;CACX;CAEA,gBAA0B,OAAyC;EAC/D,IAAI,CAAC,MAAM,UACP;EAGJ,MAAM,EAAE,SAAS,MAAM;EACvB,IAAI,KAAK,UACL,OAAO,KAAK;EAGhB,IAAI,SAAS,KAAK,KAAK,KAAK,KAAK,MAAM,IACnC,OAAO,KAAK,MAAM;CAI1B;AACJ;;;AChCA,eAAsB,QAAQ,OAAe,aAAwC;CACjF,OAAOA,UAAc,OAAO,WAAW;AAC3C;;;ACFA,eAAsB,KAAK,KAAa,SAAiB,IAAsB;CAC3E,OAAOC,OAAW,KAAK,MAAM;AACjC;;;ACJA,IAAY,4BAAL,yBAAA,2BAAA;CACH,0BAAA,aAAA;CACA,0BAAA,uBAAA;CACA,0BAAA,cAAA;CACA,0BAAA,WAAA;CACA,0BAAA,UAAA;;AACJ,EAAA,CAAA,CAAA;;;ACHA,IAAsB,UAAtB,MAA8B;CAC1B;CAIA,YAAY,WAAuB;EAC/B,KAAK,MAAM;CACf;CAIA,MAAM,gBAAsC;EACxC,IAAI,KAAK,IAAI,SAAS,WAClB,OAAO,OAAO,UAAU,SAAS,KAAK,GAAG;EAG7C,IAAI,KAAK,IAAI,SAAS,UAClB,OAAO,OAAO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IAAI;KACP,MAAM;MACF;MACA,QAAQ,IAAI,QAAQ,KAAK;KAC7B;IACJ,CAAC;GACT;EACJ;CACJ;AACJ;;;ACvDA,SAAgB,eACZ,KACA,MAC6B;CAC7B,OAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI;AACzD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["isObject","compareMethod","hashMethod","isObject","create"],"sources":["../src/cache/adapters/memory.ts","../src/redis/check.ts","../src/redis/factory.ts","../src/cache/adapters/redis.ts","../src/cache/helper.ts","../src/core/service.ts","../src/crypto/hash/compare.ts","../src/crypto/hash/hash.ts","../src/crypto/key/asymmetric/constants.ts","../src/crypto/key/base.ts","../src/crypto/key/asymmetric/helpers/wrap.ts","../src/crypto/key/asymmetric/key-usages.ts","../src/crypto/key/asymmetric/normalize.ts","../src/crypto/key/asymmetric/module.ts","../src/crypto/key/asymmetric/check.ts","../src/crypto/key/asymmetric/create.ts","../src/crypto/key/symmetric/constants.ts","../src/crypto/key/symmetric/check.ts","../src/crypto/key/symmetric/key-usages.ts","../src/crypto/key/symmetric/normalize.ts","../src/crypto/key/symmetric/module.ts","../src/crypto/key/symmetric/create.ts","../src/crypto/json-web-token/extract.ts","../src/crypto/json-web-token/utils.ts","../src/crypto/json-web-token/sign/module.ts","../src/crypto/json-web-token/verify/module.ts","../src/domain-event/utils.ts","../src/domain-event/handlers/redis/module.ts","../src/domain-event/handlers/socket/module.ts","../src/domain-event/module.ts","../src/logger/module.ts","../src/utils/has-property.ts"],"sourcesContent":["/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { TTLCacheOptions } from '@isaacs/ttlcache';\nimport { TTLCache } from '@isaacs/ttlcache';\nimport type { CacheClearOptions, CacheSetOptions, ICache } from '../types';\n\nexport class MemoryCache implements ICache {\n protected instance : TTLCache<string, unknown>;\n\n constructor(options: TTLCacheOptions<string, unknown> = {}) {\n this.instance = new TTLCache<string, unknown>({\n checkAgeOnGet: true,\n ttl: Infinity,\n ...(options || {}),\n });\n }\n\n async pop<T = unknown>(key: string): Promise<T | null> {\n if (this.instance.has(key)) {\n const output = this.instance.get(key);\n this.instance.delete(key);\n return output as T;\n }\n\n return null;\n }\n\n async has(key: string) : Promise<boolean> {\n return this.instance.has(key);\n }\n\n async get<T =unknown>(key: string): Promise<T | null> {\n const output = await this.instance.get(key);\n if (output) {\n return output as T;\n }\n\n return null;\n }\n\n async set(key: string, value: unknown, options: CacheSetOptions): Promise<void> {\n this.instance.set(key, value, { ttl: options.ttl });\n }\n\n async drop(key: string): Promise<void> {\n this.instance.delete(key);\n }\n\n async dropMany(keys: string[]) : Promise<void> {\n for (const key of keys) {\n this.instance.delete(key);\n }\n }\n\n async clear(options: CacheClearOptions = {}) : Promise<void> {\n if (options.prefix) {\n const keys = this.instance.keys();\n let iterator = keys.next();\n while (!iterator.done) {\n if (typeof iterator.value !== 'string') {\n continue;\n }\n\n if (iterator.value.startsWith(options.prefix)) {\n this.instance.delete(iterator.value);\n }\n\n iterator = keys.next();\n }\n\n return;\n }\n\n this.instance.clear();\n }\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from 'smob';\nimport type { RedisClient } from './module';\n\nexport function isRedisClient(data: unknown) : data is RedisClient {\n return isObject(data) &&\n typeof data.connect === 'function' &&\n typeof data.disconnect === 'function';\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { createClient } from 'redis-extension';\nimport { isRedisClient } from './check';\nimport type { RedisClient, RedisClientOptions } from './module';\n\nexport type RedisClientCreateInput = string | boolean | RedisClient | RedisClientOptions;\n\nexport function createRedisClient(input: RedisClientCreateInput) {\n if (typeof input === 'boolean') {\n return createClient({ connectionString: 'redis://127.0.0.1' });\n }\n\n if (typeof input === 'string') {\n return createClient({ connectionString: input });\n }\n\n if (!isRedisClient(input)) {\n return createClient({ options: input });\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'redis-extension';\nimport { JsonAdapter } from 'redis-extension';\nimport type { RedisClient, RedisClientOptions } from '../../redis';\nimport { createRedisClient } from '../../redis';\nimport type { CacheClearOptions, CacheSetOptions, ICache } from '../types';\n\nexport class RedisCache implements ICache {\n protected client : Client;\n\n protected jsonAdapter : JsonAdapter;\n\n constructor(input: string | boolean | RedisClient | RedisClientOptions) {\n this.client = createRedisClient(input);\n this.jsonAdapter = new JsonAdapter(this.client);\n }\n\n async get(key: string): Promise<any> {\n const output = await this.jsonAdapter.get(key);\n if (output) {\n return output;\n }\n\n return null;\n }\n\n async pop<T = unknown>(key: string): Promise<T | null> {\n const raw = await this.client.getdel(key);\n if (!raw) {\n return null;\n }\n\n try {\n return JSON.parse(raw) as T;\n } catch {\n return null;\n }\n }\n\n async has(key: string) : Promise<boolean> {\n const output = await this.get(key);\n\n return !!output;\n }\n\n async set(key: string, value: any, options: CacheSetOptions): Promise<void> {\n await this.jsonAdapter.set(key, value, { milliseconds: options.ttl });\n }\n\n async drop(key: string): Promise<void> {\n await this.jsonAdapter.drop(key);\n }\n\n async dropMany(keys: string[]) : Promise<void> {\n const pipeline = this.client.pipeline();\n\n for (const key of keys) {\n pipeline.del(key);\n }\n\n await pipeline.exec();\n }\n\n async clear(options: CacheClearOptions = {}) : Promise<void> {\n if (options.prefix) {\n const pipeline = this.client.pipeline();\n\n const keys = await this.client.keys(`${options.prefix}*`);\n for (const key of keys) {\n pipeline.del(key);\n }\n\n await pipeline.exec();\n\n return;\n }\n await this.client.flushdb();\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildRedisKeyPath } from '../redis';\nimport type { CacheKeyBuildOptions } from './types';\n\nexport function buildCacheKey(options: CacheKeyBuildOptions) {\n return buildRedisKeyPath(options);\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { REALM_MASTER_NAME } from '@authup/core-kit';\nimport { isObject } from '@authup/kit';\nimport type { ActorContext } from './actor/types';\n\nexport abstract class AbstractEntityService {\n protected isActorMasterRealmMember(actor: ActorContext): boolean {\n if (!actor.identity) {\n return false;\n }\n\n const { data } = actor.identity;\n if ('realm' in data && data.realm && typeof data.realm === 'object' && 'name' in data.realm) {\n return data.realm.name === REALM_MASTER_NAME;\n }\n\n return false;\n }\n\n protected getActorRealmId(actor: ActorContext): string | undefined {\n if (!actor.identity) {\n return undefined;\n }\n\n const { data } = actor.identity;\n if (data.realm_id) {\n return data.realm_id;\n }\n\n if (isObject(data.realm) && data.realm.id) {\n return data.realm.id;\n }\n\n return undefined;\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { compare as compareMethod } from '@node-rs/bcrypt';\n\nexport async function compare(value: string, hashedValue: string) : Promise<boolean> {\n return compareMethod(value, hashedValue);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hash as hashMethod } from '@node-rs/bcrypt';\n\nexport async function hash(str: string, rounds: number = 10) : Promise<string> {\n return hashMethod(str, rounds);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum CryptoAsymmetricAlgorithm {\n RSA_PSS = 'RSA-PSS',\n RSASSA_PKCS1_V1_5 = 'RSASSA-PKCS1-v1_5',\n RSA_OAEP = 'RSA-OAEP',\n ECDSA = 'ECDSA',\n ECDH = 'ECDH',\n}\n","/*\n * Copyright (c) 2025-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { arrayBufferToBase64 } from '@authup/kit';\nimport { subtle } from 'uncrypto';\n\nexport abstract class BaseKey {\n protected key : CryptoKey;\n\n // ----------------------------------------------\n\n constructor(cryptoKey : CryptoKey) {\n this.key = cryptoKey;\n }\n\n // ----------------------------------------------\n\n async toArrayBuffer(): Promise<ArrayBuffer> {\n if (this.key.type === 'private') {\n return subtle.exportKey('pkcs8', this.key);\n }\n\n if (this.key.type === 'public') {\n return subtle.exportKey('spki', this.key);\n }\n\n return subtle.exportKey('raw', this.key);\n }\n\n async toUint8Array(): Promise<Uint8Array> {\n const arrayBuffer = await this.toArrayBuffer();\n return new Uint8Array(arrayBuffer);\n }\n\n async toBase64() : Promise<string> {\n const arrayBuffer = await this.toArrayBuffer();\n return arrayBufferToBase64(arrayBuffer);\n }\n\n async toJWK() : Promise<JsonWebKey> {\n return subtle.exportKey('jwk', this.key);\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nfunction enc(\n type: 'PRIVATE KEY' | 'PUBLIC KEY',\n input: string,\n) {\n return `-----BEGIN ${type}-----\\n${input}\\n-----END ${type}-----`;\n}\n\nexport function encodePKCS8ToPEM(base64: string) {\n return enc('PRIVATE KEY', base64);\n}\n\nexport function encodeSPKIToPem(input: string) {\n return enc('PUBLIC KEY', input);\n}\n\n// ------------------------------------------------------------\n\nfunction dec(\n type: 'PRIVATE KEY' | 'PUBLIC KEY',\n input: string,\n) {\n input = input.replace(`-----BEGIN ${type}-----\\n`, '');\n\n input = input.replace(`\\n-----END ${type}-----\\n`, '');\n input = input.replace(`-----END ${type}-----\\n`, '');\n input = input.replace(`\\n-----END ${type}-----`, '');\n\n return input;\n}\n\nexport function decodePemToPKCS8(input: string) {\n return dec('PRIVATE KEY', input);\n}\n\nexport function decodePemToSpki(input: string) {\n return dec('PUBLIC KEY', input);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { CryptoAsymmetricAlgorithm } from './constants';\n\n/**\n * @see https://nodejs.org/api/webcrypto.html#cryptokeyusages\n */\nexport function getKeyUsagesForAsymmetricAlgorithm(\n name: string,\n format?: Exclude<KeyFormat, 'jwk'>,\n) : KeyUsage[] {\n if (\n name === CryptoAsymmetricAlgorithm.RSA_PSS ||\n name === CryptoAsymmetricAlgorithm.ECDSA ||\n name === CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5\n ) {\n if (format === 'spki') {\n return ['verify'];\n } if (format === 'pkcs8') {\n return ['sign'];\n }\n\n return ['sign', 'verify'];\n }\n\n if (name === CryptoAsymmetricAlgorithm.ECDH) {\n if (format === 'spki') {\n return [];\n }\n\n return [\n 'deriveKey',\n 'deriveBits',\n ];\n }\n\n if (name === CryptoAsymmetricAlgorithm.RSA_OAEP) {\n if (format === 'spki') {\n return ['encrypt'];\n } if (format === 'pkcs8') {\n return ['decrypt'];\n }\n\n return ['encrypt', 'decrypt'];\n }\n\n throw new SyntaxError(`Key usages can not be determined for asymmetric algorithm: ${name}`);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { CryptoAsymmetricAlgorithm } from './constants';\nimport type {\n AsymmetricKeyImportOptionsInput,\n AsymmetricKeyPairCreateOptions,\n AsymmetricKeyPairCreateOptionsInput,\n AsymmetricKeyPairImportOptions,\n} from './types';\n\nexport function normalizeAsymmetricKeyPairCreateOptions(\n options: AsymmetricKeyPairCreateOptionsInput,\n) : AsymmetricKeyPairCreateOptions {\n let optionsNormalized : AsymmetricKeyPairCreateOptions;\n switch (options.name) {\n case CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5:\n case CryptoAsymmetricAlgorithm.RSA_PSS:\n case CryptoAsymmetricAlgorithm.RSA_OAEP: {\n optionsNormalized = {\n modulusLength: 2048,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: 'SHA-256',\n ...options,\n };\n break;\n }\n case CryptoAsymmetricAlgorithm.ECDSA:\n case CryptoAsymmetricAlgorithm.ECDH: {\n optionsNormalized = {\n namedCurve: 'P-256',\n ...options,\n };\n }\n }\n\n return optionsNormalized;\n}\n\nexport function normalizeAsymmetricKeyImportOptions(\n options: AsymmetricKeyImportOptionsInput,\n) : AsymmetricKeyPairImportOptions {\n let optionsNormalized : AsymmetricKeyPairImportOptions;\n switch (options.name) {\n case CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5:\n case CryptoAsymmetricAlgorithm.RSA_PSS:\n case CryptoAsymmetricAlgorithm.RSA_OAEP: {\n optionsNormalized = {\n hash: 'SHA-256',\n ...options,\n };\n break;\n }\n case CryptoAsymmetricAlgorithm.ECDSA:\n case CryptoAsymmetricAlgorithm.ECDH: {\n optionsNormalized = {\n namedCurve: 'P-256',\n ...options,\n };\n }\n }\n\n return optionsNormalized;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { base64ToArrayBuffer } from '@authup/kit';\nimport { JWTAlgorithm } from '@authup/specs';\nimport { subtle } from 'uncrypto';\nimport { BaseKey } from '../base';\nimport { CryptoAsymmetricAlgorithm } from './constants';\nimport type { AsymmetricKeyImportContext } from './types';\nimport {\n decodePemToPKCS8, \n decodePemToSpki, \n encodePKCS8ToPEM, \n encodeSPKIToPem,\n} from './helpers';\nimport { getKeyUsagesForAsymmetricAlgorithm } from './key-usages';\nimport { normalizeAsymmetricKeyImportOptions } from './normalize';\n\nexport class AsymmetricKey extends BaseKey {\n async toPem(): Promise<string> {\n const base64 = await this.toBase64();\n\n if (this.key.type === 'public') {\n return encodeSPKIToPem(base64);\n }\n\n if (this.key.type === 'private') {\n return encodePKCS8ToPEM(base64);\n }\n\n throw new Error(`${this.key.type} can not be converted to pem.`);\n }\n\n // ----------------------------------------------------------------\n\n static async fromPem(ctx: AsymmetricKeyImportContext<string>): Promise<AsymmetricKey> {\n if (ctx.format === 'pkcs8') {\n return AsymmetricKey.fromBase64({\n ...ctx,\n key: decodePemToPKCS8(ctx.key), \n });\n }\n return AsymmetricKey.fromBase64({\n ...ctx,\n key: decodePemToSpki(ctx.key), \n });\n }\n\n static async fromBase64(\n ctx: AsymmetricKeyImportContext<string>,\n ) : Promise<AsymmetricKey> {\n const arrayBuffer = base64ToArrayBuffer(ctx.key);\n\n return AsymmetricKey.fromArrayBuffer({\n ...ctx,\n key: arrayBuffer,\n });\n }\n\n static async fromArrayBuffer(\n ctx: AsymmetricKeyImportContext<ArrayBuffer>,\n ) : Promise<AsymmetricKey> {\n const normalizedOptions = normalizeAsymmetricKeyImportOptions(ctx.options);\n\n const cryptoKey = await subtle.importKey(\n ctx.format,\n ctx.key,\n normalizedOptions,\n true,\n getKeyUsagesForAsymmetricAlgorithm(normalizedOptions.name, ctx.format),\n );\n\n return new AsymmetricKey(cryptoKey);\n }\n\n // ----------------------------------------------------------------\n\n static buildImportOptionsForJWTAlgorithm(alg: `${JWTAlgorithm}`) {\n if (alg === JWTAlgorithm.RS256) {\n return {\n name: CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5,\n hash: 'SHA-256',\n };\n }\n\n if (alg === JWTAlgorithm.RS384) {\n return {\n name: CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5,\n hash: 'SHA-384',\n };\n }\n\n if (alg === JWTAlgorithm.RS512) {\n return {\n name: CryptoAsymmetricAlgorithm.RSASSA_PKCS1_V1_5,\n hash: 'SHA-512',\n };\n }\n\n if (alg === JWTAlgorithm.ES256) {\n return {\n name: CryptoAsymmetricAlgorithm.ECDSA,\n namedCurve: 'P-256',\n };\n }\n\n if (alg === JWTAlgorithm.ES384) {\n return {\n name: CryptoAsymmetricAlgorithm.ECDSA,\n namedCurve: 'P-384',\n };\n }\n\n if (alg === JWTAlgorithm.ES512) {\n return {\n name: CryptoAsymmetricAlgorithm.ECDSA,\n namedCurve: 'P-521',\n };\n }\n\n throw new Error(`Signature algorithm ${alg} is not supported.`);\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { CryptoAsymmetricAlgorithm } from './constants';\n\nexport function isAsymmetricAlgorithm(input: string) : input is CryptoAsymmetricAlgorithm {\n return (Object.values(CryptoAsymmetricAlgorithm) as string[]).includes(input);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { subtle } from 'uncrypto';\nimport { getKeyUsagesForAsymmetricAlgorithm } from './key-usages';\nimport { normalizeAsymmetricKeyPairCreateOptions } from './normalize';\nimport type { AsymmetricKeyPairCreateOptionsInput } from './types';\n\nexport async function createAsymmetricKeyPair(options: AsymmetricKeyPairCreateOptionsInput) : Promise<CryptoKeyPair> {\n const optionsNormalized = normalizeAsymmetricKeyPairCreateOptions(options);\n return subtle.generateKey(\n optionsNormalized,\n true,\n getKeyUsagesForAsymmetricAlgorithm(optionsNormalized.name),\n );\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum SymmetricAlgorithm {\n HMAC = 'HMAC',\n AES_CTR = 'AES-CTR',\n AES_CBC = 'AES-CBC',\n AES_GCM = 'AES-GCM',\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SymmetricAlgorithm } from './constants';\n\nexport function isSymmetricAlgorithm(input: string) : input is SymmetricAlgorithm {\n return (Object.values(SymmetricAlgorithm) as string[]).includes(input);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SymmetricAlgorithm } from './constants';\n\nexport function getKeyUsagesForSymmetricAlgorithm(name: string) : KeyUsage[] {\n /**\n * @see https://nodejs.org/api/webcrypto.html#cryptokeyusages\n */\n if (name === SymmetricAlgorithm.HMAC) {\n return [\n 'sign',\n 'verify',\n ];\n }\n\n if (\n name === SymmetricAlgorithm.AES_CBC ||\n name === SymmetricAlgorithm.AES_GCM ||\n name === SymmetricAlgorithm.AES_CTR\n ) {\n return [\n 'encrypt',\n 'decrypt',\n ];\n }\n\n throw new SyntaxError(`Key usages can not be determined for symmetric algorithm: ${name}`);\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { SymmetricAlgorithm } from './constants';\nimport type {\n SymmetricKeyCreateOptions, \n SymmetricKeyCreateOptionsInput, \n SymmetricKeyImportOptions, \n SymmetricKeyImportOptionsInput,\n} from './types';\n\nexport function normalizeSymmetricKeyCreateOptions(\n input: SymmetricKeyCreateOptionsInput,\n) : SymmetricKeyCreateOptions {\n if (input.name === SymmetricAlgorithm.HMAC) {\n return {\n hash: 'SHA-256',\n ...input,\n };\n }\n\n return {\n length: 256,\n name: input.name,\n };\n}\n\nexport function normalizeSymmetricKeyImportOptions(\n input: SymmetricKeyImportOptionsInput,\n) : SymmetricKeyImportOptions {\n if (input.name === SymmetricAlgorithm.HMAC) {\n return {\n hash: 'SHA-256',\n ...input,\n };\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2025.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { base64ToArrayBuffer } from '@authup/kit';\nimport { JWTAlgorithm } from '@authup/specs';\nimport { subtle } from 'uncrypto';\nimport { BaseKey } from '../base';\nimport { SymmetricAlgorithm } from './constants';\nimport { getKeyUsagesForSymmetricAlgorithm } from './key-usages';\nimport { normalizeSymmetricKeyImportOptions } from './normalize';\nimport type { SymmetricKeyImportContext, SymmetricKeyImportOptions } from './types';\n\nexport class SymmetricKey extends BaseKey {\n static async fromBase64(\n ctx: SymmetricKeyImportContext<string>,\n ) : Promise<SymmetricKey> {\n const arrayBuffer = base64ToArrayBuffer(ctx.key);\n\n return SymmetricKey.fromArrayBuffer({\n ...ctx,\n key: arrayBuffer,\n });\n }\n\n static async fromArrayBuffer(\n ctx: SymmetricKeyImportContext<ArrayBuffer>,\n ) : Promise<SymmetricKey> {\n const normalizedOptions : SymmetricKeyImportOptions = normalizeSymmetricKeyImportOptions(ctx.options);\n\n const cryptoKey = await subtle.importKey(\n ctx.format,\n ctx.key,\n normalizedOptions,\n true,\n getKeyUsagesForSymmetricAlgorithm(normalizedOptions.name),\n );\n\n return new SymmetricKey(cryptoKey);\n }\n\n static buildImportOptionsForJWTAlgorithm(alg: `${JWTAlgorithm}`) {\n if (alg === JWTAlgorithm.HS256) {\n return {\n name: SymmetricAlgorithm.HMAC,\n hash: 'SHA-256',\n };\n }\n\n if (alg === JWTAlgorithm.HS384) {\n return {\n name: SymmetricAlgorithm.HMAC,\n hash: 'SHA-384',\n };\n }\n\n if (alg === JWTAlgorithm.HS512) {\n return {\n name: SymmetricAlgorithm.HMAC,\n hash: 'SHA-512',\n };\n }\n\n throw new Error(`Signature algorithm ${alg} is not supported.`);\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { subtle } from 'uncrypto';\nimport { getKeyUsagesForSymmetricAlgorithm } from './key-usages';\nimport { normalizeSymmetricKeyCreateOptions } from './normalize';\nimport type { SymmetricKeyCreateOptionsInput } from './types';\n\nexport async function createSymmetricKey(input: SymmetricKeyCreateOptionsInput) : Promise<CryptoKey> {\n const optionsNormalized = normalizeSymmetricKeyCreateOptions(input);\n\n return subtle.generateKey(\n optionsNormalized,\n true,\n getKeyUsagesForSymmetricAlgorithm(optionsNormalized.name),\n );\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { JWTClaims, JWTHeader } from '@authup/specs';\nimport { JWTError } from '@authup/specs';\n\n/**\n * Decode a JWT token with no verification.\n *\n * @param token\n *\n * @throws JWTError\n */\nexport function extractTokenHeader(\n token: string,\n) : JWTHeader {\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw JWTError.invalid();\n }\n\n const [headerBase64] = parts;\n\n try {\n const payload = atob(headerBase64);\n\n return JSON.parse(payload);\n\n /*\n return {\n typ: 'JWT',\n alg: transformInternalToJWTAlgorithm(header.algorithm),\n cty: header.contentType,\n jku: header.jsonKeyUrl,\n kid: header.keyId,\n x5u: header.x5Url,\n x5c: header.x5CertChain,\n x5t: header.x5CertThumbprint,\n 'x5t#S256': header.x5TS256CertThumbprint,\n };\n */\n } catch {\n throw JWTError.headerInvalid('The token header could not be extracted.');\n }\n}\n\n/**\n * @param token\n *\n * @throws JWTError\n */\nexport function extractTokenPayload(\n token: string,\n) : JWTClaims {\n const parts = token.split('.');\n if (parts.length !== 3) {\n throw JWTError.invalid();\n }\n\n const [, payloadBase64] = parts;\n\n try {\n const payload = atob(payloadBase64);\n\n return JSON.parse(payload);\n } catch {\n throw JWTError.payloadInvalid('The token payload could not be extracted.');\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { JWTAlgorithm, JWTError } from '@authup/specs';\nimport { Algorithm } from '@node-rs/jsonwebtoken';\nimport { isObject } from 'smob';\n\nexport function createErrorForJWTError(e: unknown) : JWTError {\n if (isObject(e)) {\n if (typeof e.name === 'string') {\n switch (e.name) {\n case 'TokenExpiredError': {\n return JWTError.expired();\n }\n case 'NotBeforeError': {\n if (typeof e.date === 'string' || e.date instanceof Date) {\n return JWTError.notActiveBefore(e.date);\n }\n break;\n }\n case 'JsonWebTokenError': {\n if (typeof e.message === 'string') {\n return JWTError.payloadInvalid(e.message);\n }\n\n break;\n }\n }\n }\n\n // @see https://github.com/Keats/jsonwebtoken/blob/master/src/errors.rs\n switch (e.message) {\n case 'ExpiredSignature': {\n return JWTError.expired();\n }\n case 'ImmatureSignature': {\n return JWTError.notActiveBefore();\n }\n case 'InvalidToken':\n case 'InvalidSignature': {\n return JWTError.payloadInvalid();\n }\n }\n }\n\n return new JWTError({\n cause: e as Error,\n message: 'The JWT error could not be determined.',\n });\n}\n\nexport function transformJWTAlgorithmToInternal(algorithm: `${JWTAlgorithm}`) : Algorithm {\n switch (algorithm) {\n case JWTAlgorithm.HS256: {\n return Algorithm.HS256;\n }\n case JWTAlgorithm.HS384: {\n return Algorithm.HS384;\n }\n case JWTAlgorithm.HS512: {\n return Algorithm.HS512;\n }\n case JWTAlgorithm.RS256: {\n return Algorithm.RS256;\n }\n case JWTAlgorithm.RS384: {\n return Algorithm.RS384;\n }\n case JWTAlgorithm.RS512: {\n return Algorithm.RS512;\n }\n case JWTAlgorithm.ES256: {\n return Algorithm.ES256;\n }\n case JWTAlgorithm.ES384: {\n return Algorithm.ES384;\n }\n case JWTAlgorithm.PS256: {\n return Algorithm.PS256;\n }\n case JWTAlgorithm.PS384: {\n return Algorithm.PS384;\n }\n case JWTAlgorithm.PS512: {\n return Algorithm.PS512;\n }\n }\n\n throw new Error(`The algorithm ${algorithm} is not supported.`);\n}\n\nexport function transformInternalToJWTAlgorithm(input: Algorithm) : JWTAlgorithm {\n switch (input) {\n case Algorithm.HS256:\n return JWTAlgorithm.HS256;\n case Algorithm.HS384:\n return JWTAlgorithm.HS384;\n case Algorithm.HS512:\n return JWTAlgorithm.HS512;\n case Algorithm.RS256:\n return JWTAlgorithm.RS256;\n case Algorithm.RS384:\n return JWTAlgorithm.RS384;\n case Algorithm.RS512:\n return JWTAlgorithm.RS512;\n case Algorithm.ES256:\n return JWTAlgorithm.ES256;\n case Algorithm.ES384:\n return JWTAlgorithm.ES384;\n case Algorithm.PS256:\n return JWTAlgorithm.PS256;\n case Algorithm.PS384:\n return JWTAlgorithm.PS384;\n case Algorithm.PS512:\n return JWTAlgorithm.PS512;\n }\n\n throw new SyntaxError(`The algorithm ${input} is not supported.`);\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { JWKType, JWTError } from '@authup/specs';\nimport type { JWTClaims } from '@authup/specs';\nimport { Algorithm, sign } from '@node-rs/jsonwebtoken';\nimport { AsymmetricKey, SymmetricKey, encodePKCS8ToPEM } from '../../key';\nimport { transformJWTAlgorithmToInternal } from '../utils';\nimport type { TokenSignOptions } from './types';\n\nconst getUtcTimestamp = () => Math.floor(new Date().getTime() / 1000);\n\nexport async function signToken(claims: JWTClaims, context: TokenSignOptions): Promise<string> {\n if (typeof claims.exp !== 'number') {\n claims.exp = getUtcTimestamp() + 3600;\n }\n if (typeof claims.iat !== 'number') {\n claims.iat = getUtcTimestamp();\n }\n\n switch (context.type) {\n case JWKType.RSA:\n case JWKType.EC: {\n let algorithm : Algorithm;\n\n let key : string;\n if (typeof context.key === 'string') {\n key = encodePKCS8ToPEM(context.key);\n } else {\n const keyContainer = new AsymmetricKey(context.key);\n key = await keyContainer.toPem();\n }\n\n if (context.type === JWKType.RSA) {\n algorithm = context.algorithm ?\n transformJWTAlgorithmToInternal(context.algorithm) :\n Algorithm.RS256;\n } else {\n algorithm = context.algorithm ?\n transformJWTAlgorithmToInternal(context.algorithm) :\n Algorithm.ES256;\n }\n\n return sign(claims, key, {\n algorithm,\n keyId: context.keyId,\n });\n }\n case JWKType.OCT: {\n const algorithm : Algorithm = context.algorithm ?\n transformJWTAlgorithmToInternal(context.algorithm) :\n Algorithm.HS256;\n\n let key : string | Uint8Array;\n if (typeof context.key === 'string') {\n key = context.key;\n } else {\n const keyContainer = new SymmetricKey(context.key);\n key = await keyContainer.toUint8Array();\n }\n\n return sign(claims, key, {\n algorithm,\n keyId: context.keyId,\n });\n }\n }\n\n throw new JWTError();\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { JWKType, JWTError } from '@authup/specs';\nimport type { JWTClaims, OAuth2TokenPayload } from '@authup/specs';\nimport { Algorithm, verify } from '@node-rs/jsonwebtoken';\nimport { AsymmetricKey, SymmetricKey, encodeSPKIToPem } from '../../key';\nimport { createErrorForJWTError, transformJWTAlgorithmToInternal } from '../utils';\nimport type { TokenVerifyOptions } from './types';\n\n/**\n * Verify JWT.\n *\n * @param token\n * @param context\n *\n * @throws OAuth2Error\n */\nexport async function verifyToken(\n token: string,\n context: TokenVerifyOptions,\n) : Promise<OAuth2TokenPayload> {\n let promise : Promise<JWTClaims> | undefined;\n\n let output : JWTClaims | undefined;\n\n try {\n switch (context.type) {\n case JWKType.RSA:\n case JWKType.EC: {\n let algorithms : Algorithm[];\n\n if (context.type === JWKType.RSA) {\n algorithms = context.algorithms ?\n context.algorithms.map((algorithm) => transformJWTAlgorithmToInternal(algorithm)) :\n [\n Algorithm.RS256,\n Algorithm.RS384,\n Algorithm.RS512,\n Algorithm.PS256,\n Algorithm.PS384,\n Algorithm.PS512,\n ];\n } else {\n algorithms = context.algorithms ?\n context.algorithms.map((algorithm) => transformJWTAlgorithmToInternal(algorithm)) :\n [\n Algorithm.ES256,\n Algorithm.ES384,\n ];\n }\n\n let key : string;\n if (typeof context.key === 'string') {\n key = encodeSPKIToPem(context.key);\n } else {\n const keyContainer = new AsymmetricKey(context.key);\n key = await keyContainer.toPem();\n }\n\n promise = verify(token, key, {\n algorithms,\n validateNbf: true,\n });\n break;\n }\n case JWKType.OCT: {\n const algorithms : Algorithm[] = context.algorithms ?\n context.algorithms.map((algorithm) => transformJWTAlgorithmToInternal(algorithm)) :\n [\n Algorithm.HS256,\n Algorithm.HS384,\n Algorithm.HS512,\n ];\n\n let key : string | Uint8Array;\n if (typeof context.key === 'string') {\n key = context.key;\n } else {\n const keyContainer = new SymmetricKey(context.key);\n key = await keyContainer.toUint8Array();\n }\n\n promise = verify(token, key, {\n algorithms,\n validateNbf: true,\n });\n }\n }\n\n if (promise) {\n output = await promise;\n }\n } catch (e) {\n throw createErrorForJWTError(e);\n }\n\n if (!output) {\n throw new JWTError();\n }\n\n return output as OAuth2TokenPayload;\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from '@authup/kit';\nimport { isObject } from '@authup/kit';\nimport type { DomainEventChannelName } from './types';\n\nexport function transformDomainEventData<T extends ObjectLiteral>(input: T) : T {\n const keys = Object.keys(input);\n for (const key_ of keys) {\n const key = key_ as keyof T;\n\n const value = input[key] as T[keyof T];\n if (!isObject(value)) {\n continue;\n }\n\n if ((value as Record<string, any>) instanceof Date) {\n input[key] = value.toISOString() as T[keyof T];\n }\n }\n\n return input;\n}\n\nexport function buildDomainEventChannelName(\n input: DomainEventChannelName,\n id?: string | number,\n) : string {\n if (typeof input === 'string') {\n return input;\n }\n\n return input(id);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { Client } from 'redis-extension';\nimport type { RedisClientCreateInput } from '../../../redis';\nimport { createRedisClient } from '../../../redis';\nimport type { DomainEventPublishContext, IDomainEventHandler } from '../../types';\nimport { buildDomainEventChannelName, transformDomainEventData } from '../../utils';\n\nexport class DomainEventRedisHandler implements IDomainEventHandler {\n protected driver : Client;\n\n constructor(input: RedisClientCreateInput) {\n this.driver = createRedisClient(input);\n }\n\n async handle(ctx: DomainEventPublishContext) : Promise<void> {\n const data = JSON.stringify(transformDomainEventData(ctx.content));\n\n const pipeline = this.driver.pipeline();\n for (let i = 0; i < ctx.destinations.length; i++) {\n const { namespace } = ctx.destinations[i];\n const keyPrefix = (namespace ? `${namespace}:` : '');\n\n let key = keyPrefix + buildDomainEventChannelName(ctx.destinations[i].channel);\n pipeline.publish(key, data);\n\n if (typeof ctx.destinations[i].channel === 'function') {\n key = keyPrefix + buildDomainEventChannelName(ctx.destinations[i].channel, ctx.content.data.id);\n pipeline.publish(key, data);\n }\n }\n\n await pipeline.exec();\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildEventFullName } from '@authup/core-realtime-kit';\nimport { Emitter } from '@socket.io/redis-emitter';\nimport type { RedisClientCreateInput } from '../../../redis';\nimport { createRedisClient } from '../../../redis';\nimport type { DomainEventPublishContext, IDomainEventHandler } from '../../types';\nimport { buildDomainEventChannelName, transformDomainEventData } from '../../utils';\n\nexport class DomainEventSocketHandler implements IDomainEventHandler {\n protected driver : Emitter;\n\n constructor(input: RedisClientCreateInput) {\n const client = createRedisClient(input);\n this.driver = new Emitter(client);\n }\n\n async handle(ctx: DomainEventPublishContext) : Promise<void> {\n ctx.content = transformDomainEventData(ctx.content);\n\n for (let i = 0; i < ctx.destinations.length; i++) {\n const destination = ctx.destinations[i];\n\n let emitter : Emitter;\n\n if (destination.namespace) {\n emitter = this.driver.of(destination.namespace);\n } else {\n emitter = this.driver;\n }\n\n let roomName = buildDomainEventChannelName(destination.channel);\n\n const fullEventName = buildEventFullName(ctx.content.type, ctx.content.event);\n\n emitter\n .in(roomName)\n .emit(fullEventName, {\n ...ctx.content,\n meta: { roomName },\n });\n\n if (typeof destination.channel === 'function') {\n roomName = buildDomainEventChannelName(destination.channel, ctx.content.data.id);\n\n emitter\n .in(roomName)\n .emit(fullEventName, {\n ...ctx.content,\n meta: {\n roomName,\n roomId: ctx.content.data.id,\n },\n });\n }\n }\n }\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { buildEventFullName } from '@authup/core-realtime-kit';\nimport type { EventPayload } from '@authup/core-realtime-kit';\nimport type { Logger } from '../logger';\nimport type {\n DomainEventPublishContext,\n IDomainEventHandler,\n IDomainEventPublisher,\n} from './types';\n\nexport type DomainEventPublisherContext = {\n logger?: Logger\n};\n\nexport class DomainEventPublisher implements IDomainEventPublisher {\n protected handlers : Set<IDomainEventHandler>;\n\n protected logger? : Logger;\n\n constructor(ctx: DomainEventPublisherContext = {}) {\n this.handlers = new Set<IDomainEventHandler>();\n this.logger = ctx.logger;\n }\n\n register(handler: IDomainEventHandler): void {\n this.handlers.add(handler);\n }\n\n async dispose() : Promise<void> {\n for (const handler of this.handlers) {\n if (handler.dispose) {\n await handler.dispose();\n }\n }\n\n this.handlers.clear();\n }\n\n async safePublish<T extends EventPayload>(\n ctx: DomainEventPublishContext<T>,\n ) : Promise<void> {\n try {\n await this.publish(ctx);\n } catch (e) {\n if (this.logger) {\n this.logger.error(`Publishing event ${buildEventFullName(ctx.content.type, ctx.content.event)} failed.`);\n this.logger.error(e);\n }\n }\n }\n\n async publish<T extends EventPayload>(\n ctx: DomainEventPublishContext<T>,\n ) : Promise<void> {\n if (this.handlers.size === 0) {\n return;\n }\n\n if (this.logger) {\n this.logger.debug(`Publishing event ${buildEventFullName(ctx.content.type, ctx.content.event)}...`);\n }\n\n const handlers = this.handlers.values();\n while (true) {\n const it = handlers.next();\n if (it.done) {\n return;\n }\n\n await it.value.handle(ctx);\n }\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport process from 'node:process';\nimport type { LoggerOptions } from 'winston';\nimport { createLogger as create, format, transports } from 'winston';\nimport type { Logger, LoggerCreateContext } from './types';\n\nexport function createNoopLogger() : Logger {\n return create({ silent: true });\n}\n\nexport function createLogger(context: LoggerCreateContext) : Logger {\n let items : LoggerOptions['transports'];\n\n const cwd = context.directory || process.cwd();\n\n if (context.env === 'production') {\n items = [\n new transports.Console({ level: 'info' }),\n new transports.File({\n filename: path.join(cwd, 'http.log'),\n level: 'http',\n maxsize: 10 * 1024 * 1024, // 10MB\n maxFiles: 5,\n }),\n new transports.File({\n filename: path.join(cwd, 'error.log'),\n level: 'warn',\n maxsize: 10 * 1024 * 1024, // 10MB\n maxFiles: 5,\n }),\n ];\n } else {\n items = [\n new transports.Console({ level: 'debug' }),\n ];\n }\n\n // @see https://github.com/winstonjs/triple-beam/blob/master/config/npm.js\n return create({\n format: format.combine(\n format.errors({ stack: true }),\n format.timestamp(),\n format.colorize(),\n format.simple(),\n ),\n transports: items,\n });\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(\n obj: X,\n prop: Y,\n): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAWA,IAAa,cAAb,MAA2C;CACvC;CAEA,YAAY,UAA4C,CAAC,GAAG;EACxD,KAAK,WAAW,IAAI,SAA0B;GAC1C,eAAe;GACf,KAAK;GACL,GAAI,WAAW,CAAC;EACpB,CAAC;CACL;CAEA,MAAM,IAAiB,KAAgC;EACnD,IAAI,KAAK,SAAS,IAAI,GAAG,GAAG;GACxB,MAAM,SAAS,KAAK,SAAS,IAAI,GAAG;GACpC,KAAK,SAAS,OAAO,GAAG;GACxB,OAAO;EACX;EAEA,OAAO;CACX;CAEA,MAA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AO,GAAG;EAC7B;CACJ;AACJ;;;ACjEA,SAAgB,mBAA4B;CACxC,OAAOC,eAAO,EAAE,QAAQ,KAAK,CAAC;AAClC;AAEA,SAAgB,aAAa,SAAuC;CAChE,IAAI;CAEJ,MAAM,MAAM,QAAQ,aAAa,QAAQ,IAAI;CAE7C,IAAI,QAAQ,QAAQ,cAChB,QAAQ;EACJ,IAAI,WAAW,QAAQ,EAAE,OAAO,OAAO,CAAC;EACxC,IAAI,WAAW,KAAK;GAChB,UAAU,KAAK,KAAK,KAAK,UAAU;GACnC,OAAO;GACP,SAAS,KAAK,OAAO;GACrB,UAAU;EACd,CAAC;EACD,IAAI,WAAW,KAAK;GAChB,UAAU,KAAK,KAAK,KAAK,WAAW;GACpC,OAAO;GACP,SAAS,KAAK,OAAO;GACrB,UAAU;EACd,CAAC;CACL;MAEA,QAAQ,CACJ,IAAI,WAAW,QAAQ,EAAE,OAAO,QAAQ,CAAC,CAC7C;CAIJ,OAAOA,eAAO;EACV,QAAQ,OAAO,QACX,OAAO,OAAO,EAAE,OAAO,KAAK,CAAC,GAC7B,OAAO,UAAU,GACjB,OAAO,SAAS,GAChB,OAAO,OAAO,CAClB;EACA,YAAY;CAChB,CAAC;AACL;;;AC/CA,SAAgB,eACZ,KACA,MAC6B;CAC7B,OAAO,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI;AACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/logger/module.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE3D,wBAAgB,gBAAgB,IAAK,MAAM,CAE1C;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAI,MAAM,CAqClE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type LoggerLevelFn<OUT = any> = {
|
|
2
|
+
(message: string, ...meta: any[]): OUT;
|
|
3
|
+
(message: any): OUT;
|
|
4
|
+
};
|
|
5
|
+
export type Logger = {
|
|
6
|
+
error: LoggerLevelFn;
|
|
7
|
+
warn: LoggerLevelFn;
|
|
8
|
+
info: LoggerLevelFn;
|
|
9
|
+
http: LoggerLevelFn;
|
|
10
|
+
verbose: LoggerLevelFn;
|
|
11
|
+
debug: LoggerLevelFn;
|
|
12
|
+
};
|
|
13
|
+
export type LoggerCreateContext = {
|
|
14
|
+
env: string;
|
|
15
|
+
directory?: string;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/logger/types.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,aAAa,CAAC,GAAG,GAAG,GAAG,IAAI;IACnC,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACvC,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/redis/check.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAI,IAAI,IAAI,WAAW,CAIjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/redis/factory.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAc9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/redis/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/redis/module.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,MAAM,IAAI,WAAW,EACrB,WAAW,IAAI,gBAAgB,EAC/B,OAAO,IAAI,YAAY,EACvB,YAAY,IAAI,iBAAiB,EAEjC,SAAS,IAAI,cAAc,EAC3B,YAAY,IAAI,iBAAiB,EACpC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC,OAAO,EACH,WAAW,EACX,gBAAgB,EAChB,YAAY,EAEZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authup/server-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.48",
|
|
5
5
|
"description": "A toolkit for server-side services.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"exports": {
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
},
|
|
57
57
|
"homepage": "https://github.com/authup/authup#readme",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@hapic/vault": "^2.3.11",
|
|
60
59
|
"@isaacs/ttlcache": "^2.1.4",
|
|
61
60
|
"@node-rs/bcrypt": "^1.10.7",
|
|
62
61
|
"@node-rs/jsonwebtoken": "^0.5.9",
|
|
@@ -66,26 +65,25 @@
|
|
|
66
65
|
"uncrypto": "^0.1.3",
|
|
67
66
|
"redis-extension": "^2.0.4",
|
|
68
67
|
"smob": "^1.6.1",
|
|
69
|
-
"singa": "^1.1.0",
|
|
70
68
|
"winston": "^3.19.0"
|
|
71
69
|
},
|
|
72
70
|
"devDependencies": {
|
|
73
|
-
"@authup/access": "^1.0.0-beta.
|
|
74
|
-
"@authup/core-kit": "^1.0.0-beta.
|
|
75
|
-
"@authup/core-realtime-kit": "^1.0.0-beta.
|
|
76
|
-
"@authup/kit": "^1.0.0-beta.
|
|
77
|
-
"@authup/errors": "^1.0.0-beta.
|
|
78
|
-
"@authup/specs": "^1.0.0-beta.
|
|
71
|
+
"@authup/access": "^1.0.0-beta.48",
|
|
72
|
+
"@authup/core-kit": "^1.0.0-beta.48",
|
|
73
|
+
"@authup/core-realtime-kit": "^1.0.0-beta.48",
|
|
74
|
+
"@authup/kit": "^1.0.0-beta.48",
|
|
75
|
+
"@authup/errors": "^1.0.0-beta.48",
|
|
76
|
+
"@authup/specs": "^1.0.0-beta.48",
|
|
79
77
|
"rapiq": "^0.9.0",
|
|
80
78
|
"vitest": "^4.0.14"
|
|
81
79
|
},
|
|
82
80
|
"peerDependencies": {
|
|
83
|
-
"@authup/access": "^1.0.0-beta.
|
|
84
|
-
"@authup/core-kit": "^1.0.0-beta.
|
|
85
|
-
"@authup/core-realtime-kit": "^1.0.0-beta.
|
|
86
|
-
"@authup/kit": "^1.0.0-beta.
|
|
87
|
-
"@authup/errors": "^1.0.0-beta.
|
|
88
|
-
"@authup/specs": "^1.0.0-beta.
|
|
81
|
+
"@authup/access": "^1.0.0-beta.48",
|
|
82
|
+
"@authup/core-kit": "^1.0.0-beta.48",
|
|
83
|
+
"@authup/core-realtime-kit": "^1.0.0-beta.48",
|
|
84
|
+
"@authup/kit": "^1.0.0-beta.48",
|
|
85
|
+
"@authup/errors": "^1.0.0-beta.48",
|
|
86
|
+
"@authup/specs": "^1.0.0-beta.48",
|
|
89
87
|
"rapiq": ">=0.8.0 <1.0.0"
|
|
90
88
|
},
|
|
91
89
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/crypto/json-web-token/type.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,iBAAiB,GAAG,GAAG,YAAY,CAAC,KAAK,EAAE,GACnD,GAAG,YAAY,CAAC,KAAK,EAAE,GACvB,GAAG,YAAY,CAAC,KAAK,EAAE,GACvB,GAAG,YAAY,CAAC,KAAK,EAAE,GACvB,GAAG,YAAY,CAAC,KAAK,EAAE,GACvB,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GAAG,GAAG,YAAY,CAAC,KAAK,EAAE,GAClD,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;AAE5B,MAAM,MAAM,iBAAiB,GAAG,GAAG,YAAY,CAAC,KAAK,EAAE,GACnD,GAAG,YAAY,CAAC,KAAK,EAAE,GACvB,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain-event/redis/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Client } from 'redis-extension';
|
|
2
|
-
import type { RedisClientCreateInput } from '../../services';
|
|
3
|
-
import type { DomainEventPublishContext, IDomainEventPublisher } from '../type';
|
|
4
|
-
export declare class DomainEventRedisPublisher implements IDomainEventPublisher {
|
|
5
|
-
protected driver: Client;
|
|
6
|
-
constructor(input: RedisClientCreateInput);
|
|
7
|
-
publish(ctx: DomainEventPublishContext): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/domain-event/redis/module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGhF,qBAAa,yBAA0B,YAAW,qBAAqB;IACnE,SAAS,CAAC,MAAM,EAAG,MAAM,CAAC;gBAEd,KAAK,EAAE,sBAAsB;IAInC,OAAO,CAAC,GAAG,EAAE,yBAAyB,GAAI,OAAO,CAAC,IAAI,CAAC;CAmBhE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain-event/socket/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Emitter } from '@socket.io/redis-emitter';
|
|
2
|
-
import type { RedisClientCreateInput } from '../../services';
|
|
3
|
-
import type { DomainEventPublishContext, IDomainEventPublisher } from '../type';
|
|
4
|
-
export declare class DomainEventSocketPublisher implements IDomainEventPublisher {
|
|
5
|
-
protected driver: Emitter;
|
|
6
|
-
constructor(input: RedisClientCreateInput);
|
|
7
|
-
publish(ctx: DomainEventPublishContext): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=module.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/domain-event/socket/module.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGhF,qBAAa,0BAA2B,YAAW,qBAAqB;IACpE,SAAS,CAAC,MAAM,EAAG,OAAO,CAAC;gBAEf,KAAK,EAAE,sBAAsB;IAKnC,OAAO,CAAC,GAAG,EAAE,yBAAyB,GAAI,OAAO,CAAC,IAAI,CAAC;CAwChE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/domain-event/type.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC;AACjF,MAAM,MAAM,sBAAsB,GAAG;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,sBAAsB,CAAA;CAClC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,sBAAsB,EAAE,CAAC;AAE/D,MAAM,MAAM,yBAAyB,CACjC,CAAC,SAAS,YAAY,GAAG,YAAY,IACrC;IACA,OAAO,EAAE,CAAC,CAAC;IACX,YAAY,EAAE,uBAAuB,CAAA;CACxC,CAAC;AAEF,MAAM,WAAW,qBAAqB;IAClC,OAAO,CAAC,GAAG,EAAE,yBAAyB,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/cache/adapters/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/services/cache/adapters/memory.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE3E,qBAAa,WAAY,YAAW,MAAM;IACtC,SAAS,CAAC,QAAQ,EAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEnC,OAAO,GAAE,eAAe,CAAC,MAAM,EAAE,OAAO,CAAM;IAQpD,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAUhD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAI,OAAO,CAAC,OAAO,CAAC;IAInC,GAAG,CAAC,CAAC,GAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAS/C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAI,OAAO,C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@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/services/cache/helper.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,UAE1D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/cache/index.ts"],"names":[],"mappings":"AAOA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/cache/types.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,oBAAoB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC1B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACf,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,CAAC;AAEF,MAAM,WAAW,MAAM;IACnB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,eAAe,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEjD,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEjD,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,KAAK,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD"}
|
package/dist/services/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAOA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/logger/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/services/logger/module.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE3D,wBAAgB,gBAAgB,IAAK,MAAM,CAE1C;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAI,MAAM,CAqClE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type Factory } from 'singa';
|
|
2
|
-
import type { Logger } from 'winston';
|
|
3
|
-
export declare function setLoggerFactory(factory: Factory<Logger>): void;
|
|
4
|
-
export declare function isLoggerUsable(): boolean;
|
|
5
|
-
export declare function setLogger(input: Logger): void;
|
|
6
|
-
export declare function useLogger(): Logger;
|
|
7
|
-
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../../src/services/logger/singleton.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAS,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,QAExD;AAED,wBAAgB,cAAc,YAE7B;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,QAEtC;AAED,wBAAgB,SAAS,WAExB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/logger/types.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,MAAM,MAAM,mBAAmB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/services/redis/check.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAI,IAAI,IAAI,WAAW,CAIjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/services/redis/factory.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhE,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAc9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/redis/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/services/redis/module.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,MAAM,IAAI,WAAW,EACrB,WAAW,IAAI,gBAAgB,EAC/B,OAAO,IAAI,YAAY,EACvB,YAAY,IAAI,iBAAiB,EAEjC,SAAS,IAAI,cAAc,EAC3B,YAAY,IAAI,iBAAiB,EACpC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC,OAAO,EACH,WAAW,EACX,gBAAgB,EAChB,YAAY,EAEZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GACpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/vault/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/services/vault/module.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,EACH,WAAW,EACX,iBAAiB,GACpB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Factory } from 'singa';
|
|
2
|
-
import type { VaultClient } from '@hapic/vault';
|
|
3
|
-
export declare function setVaultFactory(factory: Factory<VaultClient>): void;
|
|
4
|
-
export declare function isVaultClientUsable(): boolean;
|
|
5
|
-
export declare function useVaultClient(): VaultClient;
|
|
6
|
-
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../../src/services/vault/singleton.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,QAE5D;AAED,wBAAgB,mBAAmB,YAElC;AAED,wBAAgB,cAAc,gBAE7B"}
|
|
File without changes
|
|
File without changes
|