cipher-kit 2.0.0-beta.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-J5YHHXDC.js → chunk-6HNTSQAP.js} +60 -29
- package/dist/chunk-6HNTSQAP.js.map +1 -0
- package/dist/{chunk-IYMK2O3K.cjs → chunk-DZLEO2JD.cjs} +136 -98
- package/dist/chunk-DZLEO2JD.cjs.map +1 -0
- package/dist/{chunk-M7V4HSRH.js → chunk-I25C3WUZ.js} +61 -26
- package/dist/chunk-I25C3WUZ.js.map +1 -0
- package/dist/{chunk-N2ZI2CIT.js → chunk-SRGSVNQ2.js} +66 -28
- package/dist/chunk-SRGSVNQ2.js.map +1 -0
- package/dist/{chunk-4IOWANDJ.cjs → chunk-UR5HPMNF.cjs} +128 -93
- package/dist/chunk-UR5HPMNF.cjs.map +1 -0
- package/dist/{chunk-D656BYPA.cjs → chunk-ZIVTPFKN.cjs} +60 -30
- package/dist/chunk-ZIVTPFKN.cjs.map +1 -0
- package/dist/{export-Bh49U7Yf.d.ts → export-C2vQXrZa.d.cts} +35 -26
- package/dist/{export-VUQLKGvM.d.ts → export-DEWwhS-S.d.ts} +35 -26
- package/dist/{export-CrT_Y2Cy.d.cts → export-DzNR1ht3.d.ts} +35 -26
- package/dist/{export-VtQvdOuA.d.cts → export-oVEmcDLI.d.cts} +35 -26
- package/dist/index.cjs +36 -40
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/node.cjs +33 -33
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +2 -2
- package/dist/{validate-CPWPEEAt.d.cts → validate-TRx4DDtg.d.cts} +46 -9
- package/dist/{validate-CPWPEEAt.d.ts → validate-TRx4DDtg.d.ts} +46 -9
- package/dist/web-api.cjs +33 -33
- package/dist/web-api.d.cts +2 -2
- package/dist/web-api.d.ts +2 -2
- package/dist/web-api.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-4IOWANDJ.cjs.map +0 -1
- package/dist/chunk-D656BYPA.cjs.map +0 -1
- package/dist/chunk-IYMK2O3K.cjs.map +0 -1
- package/dist/chunk-J5YHHXDC.js.map +0 -1
- package/dist/chunk-M7V4HSRH.js.map +0 -1
- package/dist/chunk-N2ZI2CIT.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node/kit.ts","../src/node/node-encode.ts","../src/node/node-encrypt.ts"],"names":["__export","$isStr","$err","ENCODING_FORMATS","$ok","Buffer","$fmtError","nodeCrypto","ENCRYPTION_ALGORITHMS","DIGEST_ALGORITHMS","isSecretKey","matchPattern","$stringifyObj","$parseToObj","PASSWORD_HASHING","hash","$fmtResultErr"],"mappings":";;;;;;;;;;;AAAA,IAAA,WAAA,GAAA;AAAAA,0BAAA,CAAA,WAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,aAAA,EAAA,MAAA,aAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,eAAA,EAAA,MAAA,eAAA;AAAA,EAAA,OAAA,EAAA,MAAA,OAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,OAAA,EAAA,MAAA,OAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,IAAA,EAAA,MAAA,IAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,aAAA,EAAA,MAAA,aAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UA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AAA,CAAiB,IAAA,EAAc,IAAA,EAAsB,EAAA,EAAgD;AACnH,EAAA,OAAO,cAAA,CAAe,IAAA,EAAM,IAAA,EAAM,EAAE,CAAA;AACtC;AAWO,SAAS,aAAA,CAAc,IAAA,EAAc,IAAA,EAAsB,EAAA,EAA4B;AAC5F,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,KAAU,cAAA,CAAe,IAAA,EAAM,MAAM,EAAE,CAAA;AACvD,EAAA,IAAI,OAAO,MAAM,IAAI,KAAA,CAAMA,+BAAA,CAAc,KAAK,CAAC,CAAA;AAC/C,EAAA,OAAO,MAAA;AACT","file":"chunk-UR5HPMNF.cjs","sourcesContent":["import type { Buffer } from 'node:buffer';\r\nimport type { DIGEST_ALGORITHMS, ENCRYPTION_ALGORITHMS } from '~/helpers/consts';\r\nimport { $fmtResultErr, type Result } from '~/helpers/error';\r\nimport type { EncodingFormat, SecretKey } from '~/helpers/types';\r\nimport { $convertBytesToStr, $convertFormat, $convertStrToBytes } from './node-encode';\r\nimport {\r\n $createSecretKey,\r\n $decrypt,\r\n $decryptObj,\r\n $encrypt,\r\n $encryptObj,\r\n $generateUuid,\r\n $hash,\r\n $hashPassword,\r\n $verifyPassword,\r\n} from './node-encrypt';\r\n\r\n/**\r\n * Generates a UUID (v4).\r\n *\r\n * @returns A Result containing a string representing the generated UUID or an error.\r\n */\r\nexport function tryGenerateUuid(): Result<string> {\r\n return $generateUuid();\r\n}\r\n\r\n/**\r\n * Generates a UUID (v4).\r\n *\r\n * @returns A string representing the generated UUID.\r\n * @throws {Error} If UUID generation fails.\r\n */\r\nexport function generateUuid(): string {\r\n const { result, error } = $generateUuid();\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Derives a secret key from the provided string for encryption/decryption.\r\n * Internally, the key is hashed using SHA-256 to ensure it meets the required length.\r\n *\r\n * @param secret - The input string to derive the secret key from.\r\n * @returns A Result containing a SecretKey object representing the derived secret key or an error.\r\n */\r\nexport function tryCreateSecretKey(\r\n secret: string,\r\n options: {\r\n algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;\r\n digest?: keyof typeof DIGEST_ALGORITHMS;\r\n salt?: string;\r\n info?: string;\r\n } = {},\r\n): Result<{ result: SecretKey<'node'> }> {\r\n return $createSecretKey(secret, options);\r\n}\r\n\r\n/**\r\n * Derives a secret key from the provided string for encryption/decryption.\r\n * Internally, the key is hashed using SHA-256 to ensure it meets the required length.\r\n *\r\n * @param secret - The input string to derive the secret key from.\r\n * @returns A SecretKey object representing the derived secret key.\r\n * @throws {Error} If the input key is invalid or key generation fails.\r\n */\r\nexport function createSecretKey(\r\n secret: string,\r\n options: {\r\n algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;\r\n digest?: keyof typeof DIGEST_ALGORITHMS;\r\n salt?: string;\r\n info?: string;\r\n } = {},\r\n): SecretKey<'node'> {\r\n const { result, error } = $createSecretKey(secret, options);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Encrypts the input string using the provided secret key.\r\n * The output is a string in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n *\r\n * @param data - The input string to encrypt.\r\n * @param secretKey - The SecretKey object used for encryption.\r\n * @returns A Result containing a string representing the encrypted data in the specified format or an error.\r\n */\r\nexport function tryEncrypt(data: string, secretKey: SecretKey<'node'>): Result<string> {\r\n return $encrypt(data, secretKey);\r\n}\r\n\r\n/**\r\n * Encrypts the input string using the provided secret key.\r\n * The output is a string in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n *\r\n * @param data - The input string to encrypt.\r\n * @param secretKey - The SecretKey object used for encryption.\r\n * @returns A string representing the encrypted data in the specified format.\r\n * @throws {Error} If the input data or key is invalid, or if encryption fails.\r\n */\r\nexport function encrypt(data: string, secretKey: SecretKey<'node'>): string {\r\n const { result, error } = $encrypt(data, secretKey);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Decrypts the input string using the provided secret key.\r\n * The input must be in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n *\r\n * @param encrypted - The input string to decrypt.\r\n * @param secretKey - The SecretKey object used for decryption.\r\n * @returns A Result containing a string representing the decrypted data or an error.\r\n */\r\nexport function tryDecrypt(encrypted: string, secretKey: SecretKey<'node'>): Result<string> {\r\n return $decrypt(encrypted, secretKey);\r\n}\r\n\r\n/**\r\n * Decrypts the input string using the provided secret key.\r\n * The input must be in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n *\r\n * @param encrypted - The input string to decrypt.\r\n * @param secretKey - The SecretKey object used for decryption.\r\n * @returns A string representing the decrypted data.\r\n * @throws {Error} If the input data or key is invalid, or if decryption fails.\r\n */\r\nexport function decrypt(encrypted: string, secretKey: SecretKey<'node'>): string {\r\n const { result, error } = $decrypt(encrypted, secretKey);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Encrypts the input object using the provided secret key.\r\n * The object is first serialized to a JSON string before encryption.\r\n * The output is a string in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n *\r\n * @param data - The input object to encrypt.\r\n * @param secretKey - The SecretKey object used for encryption.\r\n * @returns A Result containing a string representing the encrypted object in the specified format or an error.\r\n */\r\nexport function tryEncryptObj<T extends object = Record<string, unknown>>(\r\n data: T,\r\n secretKey: SecretKey<'node'>,\r\n): Result<string> {\r\n return $encryptObj(data, secretKey);\r\n}\r\n\r\n/**\r\n * Encrypts the input object using the provided secret key.\r\n * The object is first serialized to a JSON string before encryption.\r\n * The output is a string in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n *\r\n * @param data - The input object to encrypt.\r\n * @param secretKey - The SecretKey object used for encryption.\r\n * @returns A string representing the encrypted object in the specified format.\r\n * @throws {Error} If the input data or key is invalid, or if encryption fails.\r\n */\r\nexport function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'node'>): string {\r\n const { result, error } = $encryptObj(data, secretKey);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Decrypts the input string to an object using the provided secret key.\r\n * The input must be in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n * The decrypted string is parsed as JSON to reconstruct the original object.\r\n *\r\n * @param encrypted - The input string to decrypt.\r\n * @param secretKey - The SecretKey object used for decryption.\r\n * @returns A Result containing an object representing the decrypted data or an error.\r\n */\r\nexport function tryDecryptObj<T extends object = Record<string, unknown>>(\r\n encrypted: string,\r\n secretKey: SecretKey<'node'>,\r\n): Result<{ result: T }> {\r\n return $decryptObj<T>(encrypted, secretKey);\r\n}\r\n\r\n/**\r\n * Decrypts the input string to an object using the provided secret key.\r\n * The input must be in the format \"iv.cipher.tag.\" where each component is base64url encoded.\r\n * The decrypted string is parsed as JSON to reconstruct the original object.\r\n *\r\n * @param encrypted - The input string to decrypt.\r\n * @param secretKey - The SecretKey object used for decryption.\r\n * @returns An object representing the decrypted data.\r\n * @throws {Error} If the input data or key is invalid, or if decryption fails.\r\n */\r\nexport function decryptObj<T extends object = Record<string, unknown>>(\r\n encrypted: string,\r\n secretKey: SecretKey<'node'>,\r\n): { result: T } {\r\n const { result, error } = $decryptObj<T>(encrypted, secretKey);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return { result };\r\n}\r\n\r\n/**\r\n * Hashes the input string using SHA-256 and returns the hash in base64url format.\r\n *\r\n * @param data - The input string to hash.\r\n * @returns A Result containing a string representing the SHA-256 hash in base64url format or an error.\r\n */\r\nexport function tryHash(data: string): Result<string> {\r\n return $hash(data);\r\n}\r\n\r\n/**\r\n * Hashes the input string using SHA-256 and returns the hash in base64url format.\r\n *\r\n * @param data - The input string to hash.\r\n * @returns A string representing the SHA-256 hash in base64url format.\r\n * @throws {Error} If the input data is invalid or hashing fails.\r\n */\r\nexport function hash(data: string): string {\r\n const { result, error } = $hash(data);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Hashes a password using PBKDF2 with SHA-512.\r\n *\r\n * @param password - The password to hash.\r\n * @returns A Result containing an object with the hash and salt, or an error.\r\n */\r\nexport function tryHashPassword(password: string): Result<{ hash: string; salt: string }> {\r\n return $hashPassword(password);\r\n}\r\n\r\n/**\r\n * Hashes a password using PBKDF2 with SHA-512.\r\n *\r\n * @param password - The password to hash.\r\n * @returns An object with the hash and salt.\r\n * @throws {Error} If the input password is invalid or hashing fails.\r\n */\r\nexport function hashPassword(password: string): { hash: string; salt: string } {\r\n const { hash, salt, error } = $hashPassword(password);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return { hash, salt };\r\n}\r\n\r\n/**\r\n * Verifies a password against a hashed password and salt.\r\n *\r\n * @param password - The password to verify.\r\n * @param hashedPassword - The hashed password to compare against (in base64url format).\r\n * @param salt - The salt used during hashing (in base64url format).\r\n * @returns A boolean indicating whether the password matches the hashed password.\r\n */\r\nexport function verifyPassword(password: string, hashedPassword: string, salt: string): boolean {\r\n return $verifyPassword(password, hashedPassword, salt);\r\n}\r\n\r\n/**\r\n * Converts a string to a Buffer (byte array) using the specified encoding format.\r\n * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.\r\n *\r\n * @param data - The input string to convert.\r\n * @param format - The encoding format to use (default is 'utf8').\r\n * @returns A Result containing a Node.js Buffer with the encoded data or an error.\r\n */\r\nexport function tryConvertStrToBytes(data: string, format: EncodingFormat = 'utf8'): Result<{ result: Buffer }> {\r\n return $convertStrToBytes(data, format);\r\n}\r\n\r\n/**\r\n * Converts a string to a Buffer (byte array) using the specified encoding format.\r\n * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.\r\n *\r\n * @param data - The input string to convert.\r\n * @param format - The encoding format to use (default is 'utf8').\r\n * @returns A Node.js Buffer containing the encoded data.\r\n * @throws {Error} If the input data is invalid or conversion fails.\r\n */\r\nexport function convertStrToBytes(data: string, format: EncodingFormat = 'utf8'): Buffer {\r\n const { result, error } = $convertStrToBytes(data, format);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Converts a Buffer (byte array) to a string using the specified encoding format.\r\n * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.\r\n *\r\n * @param data - The input Buffer to convert.\r\n * @param format - The encoding format to use (default is 'utf8').\r\n * @returns A Result containing the string representation of the Buffer or an error.\r\n */\r\nexport function tryConvertBytesToStr(data: Buffer, format: EncodingFormat = 'utf8'): Result<string> {\r\n return $convertBytesToStr(data, format);\r\n}\r\n\r\n/**\r\n * Converts a Buffer (byte array) to a string using the specified encoding format.\r\n * Supported formats: 'base64', 'base64url', 'hex', 'utf8', 'latin1'.\r\n *\r\n * @param data - The input Buffer to convert.\r\n * @param format - The encoding format to use (default is 'utf8').\r\n * @returns A string representation of the Buffer in the specified format.\r\n * @throws {Error} If the input data is invalid or conversion fails.\r\n */\r\nexport function convertBytesToStr(data: Buffer, format: EncodingFormat = 'utf8'): string {\r\n const { result, error } = $convertBytesToStr(data, format);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Convert data from one encoding format to another.\r\n *\r\n * @param data - The input data to convert.\r\n * @param from - The encoding format to convert from.\r\n * @param to - The encoding format to convert to.\r\n * @returns A Result containing the converted string or an error.\r\n */\r\nexport function tryConvertFormat(data: string, from: EncodingFormat, to: EncodingFormat): Result<{ result: string }> {\r\n return $convertFormat(data, from, to);\r\n}\r\n\r\n/**\r\n * Convert data from one encoding format to another.\r\n *\r\n * @param data - The input data to convert.\r\n * @param from - The encoding format to convert from.\r\n * @param to - The encoding format to convert to.\r\n * @returns A converted string.\r\n * @throws {Error} If the input data is invalid or conversion fails.\r\n */\r\nexport function convertFormat(data: string, from: EncodingFormat, to: EncodingFormat): string {\r\n const { result, error } = $convertFormat(data, from, to);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n","import { Buffer } from 'node:buffer';\r\nimport { ENCODING_FORMATS } from '~/helpers/consts';\r\nimport { $err, $fmtError, $ok, type Result } from '~/helpers/error';\r\nimport type { EncodingFormat } from '~/helpers/types';\r\nimport { $isStr } from '~/helpers/validate';\r\n\r\nexport function $convertStrToBytes(data: string, format: EncodingFormat = 'utf8'): Result<{ result: Buffer }> {\r\n if (!$isStr(data)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - String to Bytes: Empty data',\r\n desc: 'Data must be a non-empty string',\r\n });\r\n }\r\n if (!ENCODING_FORMATS.includes(format)) {\r\n return $err({\r\n msg: `Crypto NodeJS API - String to Bytes: Unsupported encode format: ${format}`,\r\n desc: 'Use base64, base64url, hex, utf8, or latin1',\r\n });\r\n }\r\n try {\r\n return $ok({ result: Buffer.from(data, format) });\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - String to Bytes: Failed to convert data', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\nexport function $convertBytesToStr(data: Buffer, format: EncodingFormat = 'utf8'): Result<string> {\r\n if (!(data instanceof Buffer)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Bytes to String: Invalid data type',\r\n desc: 'Data must be a Buffer',\r\n });\r\n }\r\n if (!ENCODING_FORMATS.includes(format)) {\r\n return $err({\r\n msg: `Crypto NodeJS API - Bytes to String: Unsupported format: ${format}`,\r\n desc: 'Use base64, base64url, hex, utf8, or latin1',\r\n });\r\n }\r\n try {\r\n return $ok(Buffer.from(data).toString(format));\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - Bytes to String: Failed to convert data', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\nexport function $convertFormat(data: string, from: EncodingFormat, to: EncodingFormat): Result<{ result: string }> {\r\n if (!$isStr(data)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Convert Format: Empty data',\r\n desc: 'Data must be a non-empty string',\r\n });\r\n }\r\n\r\n if (!ENCODING_FORMATS.includes(from) || !ENCODING_FORMATS.includes(to)) {\r\n return $err({\r\n msg: `Crypto NodeJS API - Convert Format: Unsupported format: from ${from} to ${to}`,\r\n desc: 'Use base64, base64url, hex, utf8, or latin1',\r\n });\r\n }\r\n\r\n const bytes = $convertStrToBytes(data, from);\r\n if (bytes.error) return $err({ msg: bytes.error.message, desc: bytes.error.description });\r\n\r\n const str = $convertBytesToStr(bytes.result, to);\r\n if (str.error) return $err({ msg: str.error.message, desc: str.error.description });\r\n\r\n return $ok({ result: str.result });\r\n}\r\n","import { Buffer } from 'node:buffer';\r\nimport nodeCrypto from 'node:crypto';\r\nimport { DIGEST_ALGORITHMS, ENCRYPTION_ALGORITHMS, PASSWORD_HASHING } from '~/helpers/consts';\r\nimport { $err, $fmtError, $ok, type Result } from '~/helpers/error';\r\nimport { $parseToObj, $stringifyObj } from '~/helpers/object';\r\nimport type { SecretKey } from '~/helpers/types';\r\nimport { $isStr, isSecretKey, matchPattern } from '~/helpers/validate';\r\nimport { $convertBytesToStr, $convertStrToBytes } from './node-encode';\r\n\r\nexport function $generateUuid(): Result<string> {\r\n try {\r\n return $ok(nodeCrypto.randomUUID());\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - UUID Generation: Failed to generate UUID', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\nexport function $createSecretKey(\r\n secret: string,\r\n options: {\r\n algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;\r\n digest?: keyof typeof DIGEST_ALGORITHMS;\r\n salt?: string;\r\n info?: string;\r\n } = {},\r\n): Result<{ result: SecretKey<'node'> }> {\r\n if (!$isStr(secret)) {\r\n return $err({ msg: 'Crypto NodeJS API - Key Generation: Empty Secret', desc: 'Secret must be a non-empty string' });\r\n }\r\n\r\n const algorithm = options.algorithm ?? 'aes256gcm';\r\n if (!(algorithm in ENCRYPTION_ALGORITHMS)) {\r\n return $err({\r\n msg: `Crypto NodeJS API - Key Generation: Unsupported algorithm: ${algorithm}`,\r\n desc: `Supported algorithms are: ${Object.keys(ENCRYPTION_ALGORITHMS).join(', ')}`,\r\n });\r\n }\r\n\r\n const digest = options.digest ?? 'sha256';\r\n if (!(digest in DIGEST_ALGORITHMS)) {\r\n return $err({\r\n msg: `Crypto NodeJS API - Key Generation: Unsupported digest: ${digest}`,\r\n desc: `Supported digests are: ${Object.keys(DIGEST_ALGORITHMS).join(', ')}`,\r\n });\r\n }\r\n\r\n const salt = options.salt ?? 'cipher-kit-salt';\r\n if (!$isStr(salt, 8)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Key Generation: Weak salt',\r\n desc: 'Salt must be a non-empty string with at least 8 characters',\r\n });\r\n }\r\n\r\n const info = options.info ?? 'cipher-kit';\r\n if (!$isStr(info)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Key Generation: Invalid info',\r\n desc: 'Info must be a non-empty string',\r\n });\r\n }\r\n\r\n const encryptAlgo = ENCRYPTION_ALGORITHMS[algorithm];\r\n const digestAlgo = DIGEST_ALGORITHMS[digest];\r\n\r\n try {\r\n const derivedKey = nodeCrypto.hkdfSync(\r\n digestAlgo.node,\r\n secret.normalize('NFKC'),\r\n salt.normalize('NFKC'),\r\n info.normalize('NFKC'),\r\n encryptAlgo.keyBytes,\r\n );\r\n const key = nodeCrypto.createSecretKey(Buffer.from(derivedKey));\r\n const secretKey = Object.freeze({\r\n platform: 'node',\r\n digest: digest,\r\n algo: encryptAlgo,\r\n key: key,\r\n }) as SecretKey<'node'>;\r\n\r\n return $ok({ result: secretKey });\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - Key Generation: Failed to create secret key', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\nexport function $encrypt(data: string, secretKey: SecretKey<'node'>): Result<string> {\r\n if (!$isStr(data)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Encryption: Empty data for encryption',\r\n desc: 'Data must be a non-empty string',\r\n });\r\n }\r\n\r\n if (!isSecretKey(secretKey, 'node')) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Encryption: Invalid Secret Key',\r\n desc: 'Expected a Node SecretKey',\r\n });\r\n }\r\n\r\n try {\r\n const iv = nodeCrypto.randomBytes(secretKey.algo.ivLength);\r\n const cipher = nodeCrypto.createCipheriv(secretKey.algo.node, secretKey.key, iv);\r\n const encrypted = Buffer.concat([cipher.update(data, 'utf8'), cipher.final()]);\r\n const tag = cipher.getAuthTag();\r\n\r\n const ivStr = $convertBytesToStr(iv, 'base64url');\r\n const cipherStr = $convertBytesToStr(encrypted, 'base64url');\r\n const tagStr = $convertBytesToStr(tag, 'base64url');\r\n\r\n if (ivStr.error || cipherStr.error || tagStr.error) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Encryption: Failed to convert IV or encrypted data or tag',\r\n desc: `Conversion error: ${ivStr.error || cipherStr.error || tagStr.error}`,\r\n });\r\n }\r\n\r\n return $ok(`${ivStr.result}.${cipherStr.result}.${tagStr.result}.`);\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - Encryption: Failed to encrypt data', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\nexport function $decrypt(encrypted: string, secretKey: SecretKey<'node'>): Result<string> {\r\n if (matchPattern(encrypted, 'node') === false) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Decryption: Invalid encrypted data format',\r\n desc: 'Encrypted data must be in the format \"iv.cipher.tag.\"',\r\n });\r\n }\r\n\r\n const [iv, cipher, tag] = encrypted.split('.', 4);\r\n if (!$isStr(iv) || !$isStr(cipher) || !$isStr(tag)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Decryption: Invalid encrypted data',\r\n desc: 'Encrypted data must contain valid IV, encrypted data, and tag components',\r\n });\r\n }\r\n\r\n if (!isSecretKey(secretKey, 'node')) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Decryption: Invalid Secret Key',\r\n desc: 'Expected a Node SecretKey',\r\n });\r\n }\r\n\r\n const ivBytes = $convertStrToBytes(iv, 'base64url');\r\n const cipherBytes = $convertStrToBytes(cipher, 'base64url');\r\n const tagBytes = $convertStrToBytes(tag, 'base64url');\r\n\r\n if (ivBytes.error || cipherBytes.error || tagBytes.error) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Decryption: Failed to convert IV or encrypted data or tag',\r\n desc: `Conversion error: ${ivBytes.error || cipherBytes.error || tagBytes.error}`,\r\n });\r\n }\r\n\r\n try {\r\n const decipher = nodeCrypto.createDecipheriv(secretKey.algo.node, secretKey.key, ivBytes.result);\r\n decipher.setAuthTag(tagBytes.result);\r\n const decrypted = Buffer.concat([decipher.update(cipherBytes.result), decipher.final()]);\r\n\r\n return $convertBytesToStr(decrypted, 'utf8');\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - Decryption: Failed to decrypt data', desc: $fmtError(error) });\r\n }\r\n}\r\nexport function $encryptObj<T extends object = Record<string, unknown>>(\r\n data: T,\r\n secretKey: SecretKey<'node'>,\r\n): Result<string> {\r\n const { result, error } = $stringifyObj(data);\r\n if (error) return $err(error);\r\n return $encrypt(result, secretKey);\r\n}\r\n\r\nexport function $decryptObj<T extends object = Record<string, unknown>>(\r\n encrypted: string,\r\n secretKey: SecretKey<'node'>,\r\n): Result<{ result: T }> {\r\n const { result, error } = $decrypt(encrypted, secretKey);\r\n if (error) return $err(error);\r\n return $parseToObj<T>(result);\r\n}\r\n\r\nexport function $hash(data: string): Result<string> {\r\n if (!$isStr(data, 0)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Hashing: Empty data for hashing',\r\n desc: 'Data must be a non-empty string',\r\n });\r\n }\r\n\r\n try {\r\n const hashed = nodeCrypto.createHash(DIGEST_ALGORITHMS.sha256.node).update(data).digest();\r\n return $convertBytesToStr(hashed, 'base64url');\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - Hashing: Failed to hash data with Crypto NodeJS', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\nexport function $hashPassword(password: string): Result<{ hash: string; salt: string }> {\r\n if (!$isStr(password)) {\r\n return $err({\r\n msg: 'Crypto NodeJS API - Password Hashing: Empty password for hashing',\r\n desc: 'Password must be a non-empty string',\r\n });\r\n }\r\n\r\n try {\r\n const salt = nodeCrypto.randomBytes(PASSWORD_HASHING.pbkdf2.saltLength);\r\n const hash = nodeCrypto.pbkdf2Sync(\r\n password.normalize('NFKC'),\r\n salt,\r\n PASSWORD_HASHING.pbkdf2.iterations,\r\n PASSWORD_HASHING.pbkdf2.keyLength,\r\n DIGEST_ALGORITHMS.sha512.node,\r\n );\r\n\r\n return $ok({ salt: salt.toString('base64url'), hash: hash.toString('base64url') });\r\n } catch (error) {\r\n return $err({ msg: 'Crypto NodeJS API - Password Hashing: Failed to hash password', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\nexport function $verifyPassword(password: string, hashedPassword: string, salt: string): boolean {\r\n if (!$isStr(password) || !$isStr(hashedPassword) || !$isStr(salt)) return false;\r\n\r\n const saltBytes = $convertStrToBytes(salt, 'base64url');\r\n if (saltBytes.error) return false;\r\n\r\n const hashedPasswordBytes = $convertStrToBytes(hashedPassword, 'base64url');\r\n if (hashedPasswordBytes.error) return false;\r\n\r\n try {\r\n return nodeCrypto.timingSafeEqual(\r\n nodeCrypto.pbkdf2Sync(\r\n password.normalize('NFKC'),\r\n saltBytes.result,\r\n PASSWORD_HASHING.pbkdf2.iterations,\r\n PASSWORD_HASHING.pbkdf2.keyLength,\r\n DIGEST_ALGORITHMS.sha512.node,\r\n ),\r\n hashedPasswordBytes.result,\r\n );\r\n } catch {\r\n return false;\r\n }\r\n}\r\n"]}
|
|
@@ -11,11 +11,64 @@ var __export = (target, all) => {
|
|
|
11
11
|
for (var name in all)
|
|
12
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
// src/helpers/consts.ts
|
|
16
|
+
var ENCODING_FORMATS = Object.freeze(["base64", "base64url", "hex", "utf8", "latin1"]);
|
|
17
|
+
var DIGEST_ALGORITHMS = Object.freeze({
|
|
18
|
+
sha256: { node: "sha256", web: "SHA-256" },
|
|
19
|
+
sha384: { node: "sha384", web: "SHA-384" },
|
|
20
|
+
sha512: { node: "sha512", web: "SHA-512" }
|
|
21
|
+
});
|
|
22
|
+
var ENCRYPTION_ALGORITHMS = Object.freeze({
|
|
23
|
+
aes256gcm: { name: "aes256gcm", keyBytes: 32, ivLength: 12, node: "aes-256-gcm", web: "AES-GCM" },
|
|
24
|
+
aes192gcm: { name: "aes192gcm", keyBytes: 24, ivLength: 12, node: "aes-192-gcm", web: "AES-GCM" },
|
|
25
|
+
aes128gcm: { name: "aes128gcm", keyBytes: 16, ivLength: 12, node: "aes-128-gcm", web: "AES-GCM" }
|
|
26
|
+
});
|
|
27
|
+
var PASSWORD_HASHING = Object.freeze({
|
|
28
|
+
pbkdf2: { saltLength: 16, iterations: 32e4, keyLength: 64 }
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// src/helpers/validate.ts
|
|
32
|
+
function $isStr(x, min = 1) {
|
|
33
|
+
return x !== null && x !== void 0 && typeof x === "string" && x.trim().length >= min;
|
|
16
34
|
}
|
|
17
|
-
function $isObj(
|
|
18
|
-
|
|
35
|
+
function $isObj(x) {
|
|
36
|
+
if (typeof x !== "object" || x === null || x === void 0) return false;
|
|
37
|
+
const proto = Object.getPrototypeOf(x);
|
|
38
|
+
return proto === Object.prototype || proto === null;
|
|
39
|
+
}
|
|
40
|
+
function $isLooseObj(x) {
|
|
41
|
+
return typeof x === "object" && x !== null && x !== void 0;
|
|
42
|
+
}
|
|
43
|
+
var expectedKeys = /* @__PURE__ */ new Set(["platform", "digest", "algo", "key"]);
|
|
44
|
+
var expectedAlgoKeys = /* @__PURE__ */ new Set(["name", "keyBytes", "ivLength", "node", "web"]);
|
|
45
|
+
function isSecretKey(x, platform) {
|
|
46
|
+
if (!$isLooseObj(x) || platform !== "node" && platform !== "web" || x.platform !== platform) return false;
|
|
47
|
+
const keys = Object.keys(x);
|
|
48
|
+
if (keys.length !== expectedKeys.size) return false;
|
|
49
|
+
for (const key of keys) if (!expectedKeys.has(key)) return false;
|
|
50
|
+
for (const key of expectedKeys) if (!Object.hasOwn(x, key)) return false;
|
|
51
|
+
if (typeof x.digest !== "string" || !(x.digest in DIGEST_ALGORITHMS)) return false;
|
|
52
|
+
if (!$isLooseObj(x.algo) || typeof x.algo.name !== "string" || !(x.algo.name in ENCRYPTION_ALGORITHMS)) return false;
|
|
53
|
+
const algoKeys = Object.keys(x.algo);
|
|
54
|
+
if (algoKeys.length !== expectedAlgoKeys.size) return false;
|
|
55
|
+
for (const key of algoKeys) if (!expectedAlgoKeys.has(key)) return false;
|
|
56
|
+
for (const key of expectedAlgoKeys) if (!Object.hasOwn(x.algo, key)) return false;
|
|
57
|
+
const algo = ENCRYPTION_ALGORITHMS[x.algo.name];
|
|
58
|
+
if (x.algo.keyBytes !== algo.keyBytes || x.algo.ivLength !== algo.ivLength || x.algo.node !== algo.node || x.algo.web !== algo.web) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
if (!$isLooseObj(x.key) || x.key.type !== "secret") return false;
|
|
62
|
+
if (platform === "node") {
|
|
63
|
+
if (!(x.key instanceof nodeCrypto__default.default.KeyObject) || typeof x.key.symmetricKeySize === "number" && x.key.symmetricKeySize !== algo.keyBytes) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (!$isLooseObj(x.key.algorithm) || x.key.algorithm.name !== algo.web || typeof x.key.algorithm.length === "number" && x.key.algorithm.length !== algo.keyBytes * 8 || typeof x.key.extractable !== "boolean" || !Array.isArray(x.key.usages) || x.key.usages.length !== 2 || !(x.key.usages.includes("encrypt") && x.key.usages.includes("decrypt"))) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
19
72
|
}
|
|
20
73
|
var ENCRYPTED_REGEX = Object.freeze({
|
|
21
74
|
general: /^(?:[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?\.)$/,
|
|
@@ -27,12 +80,6 @@ function matchPattern(data, format) {
|
|
|
27
80
|
if (!(format in ENCRYPTED_REGEX)) throw new Error(`Unknown format: ${format}`);
|
|
28
81
|
return ENCRYPTED_REGEX[format].test(data);
|
|
29
82
|
}
|
|
30
|
-
function isNodeSecretKey(key) {
|
|
31
|
-
return key instanceof nodeCrypto__default.default.KeyObject;
|
|
32
|
-
}
|
|
33
|
-
function isWebSecretKey(key) {
|
|
34
|
-
return key !== null && key !== void 0 && typeof key === "object" && "type" in key && typeof key.type === "string" && "algorithm" in key && typeof key.algorithm === "object" && "extractable" in key && typeof key.extractable === "boolean" && "usages" in key && Array.isArray(key.usages) && key.usages.every((usage) => typeof usage === "string");
|
|
35
|
-
}
|
|
36
83
|
|
|
37
84
|
// src/helpers/error.ts
|
|
38
85
|
function $ok(result) {
|
|
@@ -93,22 +140,6 @@ function parseToObj(str) {
|
|
|
93
140
|
return result;
|
|
94
141
|
}
|
|
95
142
|
|
|
96
|
-
// src/helpers/consts.ts
|
|
97
|
-
var ENCODING_FORMATS = Object.freeze(["base64", "base64url", "hex", "utf8", "latin1"]);
|
|
98
|
-
var DIGEST_ALGORITHMS = Object.freeze({
|
|
99
|
-
sha256: { node: "sha256", web: "SHA-256" },
|
|
100
|
-
sha384: { node: "sha384", web: "SHA-384" },
|
|
101
|
-
sha512: { node: "sha512", web: "SHA-512" }
|
|
102
|
-
});
|
|
103
|
-
var ENCRYPTION_ALGORITHMS = Object.freeze({
|
|
104
|
-
aes256gcm: { keyBytes: 32, ivLength: 12, node: "aes-256-gcm", web: "AES-GCM" },
|
|
105
|
-
aes192gcm: { keyBytes: 24, ivLength: 12, node: "aes-192-gcm", web: "AES-GCM" },
|
|
106
|
-
aes128gcm: { keyBytes: 16, ivLength: 12, node: "aes-128-gcm", web: "AES-GCM" }
|
|
107
|
-
});
|
|
108
|
-
var PASSWORD_HASHING = Object.freeze({
|
|
109
|
-
pbkdf2: { saltLength: 16, iterations: 32e4, keyLength: 64 }
|
|
110
|
-
});
|
|
111
|
-
|
|
112
143
|
exports.$err = $err;
|
|
113
144
|
exports.$fmtError = $fmtError;
|
|
114
145
|
exports.$fmtResultErr = $fmtResultErr;
|
|
@@ -122,12 +153,11 @@ exports.ENCRYPTED_REGEX = ENCRYPTED_REGEX;
|
|
|
122
153
|
exports.ENCRYPTION_ALGORITHMS = ENCRYPTION_ALGORITHMS;
|
|
123
154
|
exports.PASSWORD_HASHING = PASSWORD_HASHING;
|
|
124
155
|
exports.__export = __export;
|
|
125
|
-
exports.
|
|
126
|
-
exports.isWebSecretKey = isWebSecretKey;
|
|
156
|
+
exports.isSecretKey = isSecretKey;
|
|
127
157
|
exports.matchPattern = matchPattern;
|
|
128
158
|
exports.parseToObj = parseToObj;
|
|
129
159
|
exports.stringifyObj = stringifyObj;
|
|
130
160
|
exports.tryParseToObj = tryParseToObj;
|
|
131
161
|
exports.tryStringifyObj = tryStringifyObj;
|
|
132
|
-
//# sourceMappingURL=chunk-
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
162
|
+
//# sourceMappingURL=chunk-ZIVTPFKN.cjs.map
|
|
163
|
+
//# sourceMappingURL=chunk-ZIVTPFKN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/consts.ts","../src/helpers/validate.ts","../src/helpers/error.ts","../src/helpers/object.ts"],"names":["nodeCrypto"],"mappings":";;;;;;;;;;;;;;;AAAO,IAAM,gBAAA,GAAmB,OAAO,MAAA,CAAO,CAAC,UAAU,WAAA,EAAa,KAAA,EAAO,MAAA,EAAQ,QAAQ,CAAU;AAEhG,IAAM,iBAAA,GAAoB,OAAO,MAAA,CAAO;AAAA,EAC7C,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA,EAAU,KAAK,SAAA,EAAU;AAAA,EACzC,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA,EAAU,KAAK,SAAA,EAAU;AAAA,EACzC,MAAA,EAAQ,EAAE,IAAA,EAAM,QAAA,EAAU,KAAK,SAAA;AACjC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EAAG,OAAO,IAAA,CAAK,EAAE,GAAA,EAAK,wBAAA,EAA0B,IAAA,EAAM,6BAAA,EAA+B,CAAA;AACpG,IAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAE1B,IAAA,IAAI,CAAC,MAAA,CAAO,GAAG,CAAA,EAAG,OAAO,IAAA,CAAK,EAAE,GAAA,EAAK,gCAAA,EAAkC,IAAA,EAAM,mCAAA,EAAqC,CAAA;AAClH,IAAA,OAAO,GAAA,CAAI,EAAE,MAAA,EAAQ,GAAA,EAAU,CAAA;AAAA,EACjC,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,IAAA,CAAK,EAAE,GAAA,EAAK,yBAAA,EAA2B,MAAM,SAAA,CAAU,KAAK,GAAG,CAAA;AAAA,EACxE;AACF;AAQO,SAAS,cAA0D,GAAA,EAAoC;AAC5G,EAAA,OAAO,YAAe,GAAG,CAAA;AAC3B;AASO,SAAS,WAAuD,GAAA,EAAgB;AACrF,EAAA,MAAM,EAAE,MAAA,EAAQ,KAAA,EAAM,GAAI,YAAe,GAAG,CAAA;AAC5C,EAAA,IAAI,OAAO,MAAM,IAAI,KAAA,CAAM,aAAA,CAAc,KAAK,CAAC,CAAA;AAC/C,EAAA,OAAO,MAAA;AACT","file":"chunk-ZIVTPFKN.cjs","sourcesContent":["export const ENCODING_FORMATS = Object.freeze(['base64', 'base64url', 'hex', 'utf8', 'latin1'] as const);\r\n\r\nexport const DIGEST_ALGORITHMS = Object.freeze({\r\n sha256: { node: 'sha256', web: 'SHA-256' },\r\n sha384: { node: 'sha384', web: 'SHA-384' },\r\n sha512: { node: 'sha512', web: 'SHA-512' },\r\n} as const);\r\n\r\nexport const ENCRYPTION_ALGORITHMS = Object.freeze({\r\n aes256gcm: { name: 'aes256gcm', keyBytes: 32, ivLength: 12, node: 'aes-256-gcm', web: 'AES-GCM' },\r\n aes192gcm: { name: 'aes192gcm', keyBytes: 24, ivLength: 12, node: 'aes-192-gcm', web: 'AES-GCM' },\r\n aes128gcm: { name: 'aes128gcm', keyBytes: 16, ivLength: 12, node: 'aes-128-gcm', web: 'AES-GCM' },\r\n} as const);\r\n\r\nexport const PASSWORD_HASHING = Object.freeze({\r\n pbkdf2: { saltLength: 16, iterations: 320_000, keyLength: 64 },\r\n} as const);\r\n","import nodeCrypto from 'node:crypto';\r\nimport type { SecretKey } from '~/helpers/types';\r\nimport { DIGEST_ALGORITHMS, ENCRYPTION_ALGORITHMS } from './consts';\r\n\r\nexport function $isStr(x: unknown, min = 1): x is string {\r\n return x !== null && x !== undefined && typeof x === 'string' && x.trim().length >= min;\r\n}\r\n\r\nexport function $isObj(x: unknown): x is Record<string, unknown> {\r\n if (typeof x !== 'object' || x === null || x === undefined) return false;\r\n const proto = Object.getPrototypeOf(x);\r\n return proto === Object.prototype || proto === null;\r\n}\r\n\r\nexport function $isLooseObj(x: unknown): x is Record<string, unknown> {\r\n return typeof x === 'object' && x !== null && x !== undefined;\r\n}\r\n\r\nconst expectedKeys = new Set(['platform', 'digest', 'algo', 'key']);\r\nconst expectedAlgoKeys = new Set(['name', 'keyBytes', 'ivLength', 'node', 'web']);\r\n\r\nexport function isSecretKey<Platform extends 'node' | 'web'>(x: unknown, platform: Platform): x is SecretKey<Platform> {\r\n if (!$isLooseObj(x) || (platform !== 'node' && platform !== 'web') || x.platform !== platform) return false;\r\n\r\n const keys = Object.keys(x);\r\n if (keys.length !== expectedKeys.size) return false;\r\n for (const key of keys) if (!expectedKeys.has(key)) return false;\r\n for (const key of expectedKeys) if (!Object.hasOwn(x, key)) return false;\r\n\r\n if (typeof x.digest !== 'string' || !(x.digest in DIGEST_ALGORITHMS)) return false;\r\n if (!$isLooseObj(x.algo) || typeof x.algo.name !== 'string' || !(x.algo.name in ENCRYPTION_ALGORITHMS)) return false;\r\n\r\n const algoKeys = Object.keys(x.algo);\r\n if (algoKeys.length !== expectedAlgoKeys.size) return false;\r\n for (const key of algoKeys) if (!expectedAlgoKeys.has(key)) return false;\r\n for (const key of expectedAlgoKeys) if (!Object.hasOwn(x.algo, key)) return false;\r\n\r\n const algo = ENCRYPTION_ALGORITHMS[x.algo.name as keyof typeof ENCRYPTION_ALGORITHMS];\r\n if (\r\n x.algo.keyBytes !== algo.keyBytes ||\r\n x.algo.ivLength !== algo.ivLength ||\r\n x.algo.node !== algo.node ||\r\n x.algo.web !== algo.web\r\n ) {\r\n return false;\r\n }\r\n\r\n if (!$isLooseObj(x.key) || x.key.type !== 'secret') return false;\r\n\r\n if (platform === 'node') {\r\n if (\r\n !(x.key instanceof nodeCrypto.KeyObject) ||\r\n (typeof x.key.symmetricKeySize === 'number' && x.key.symmetricKeySize !== algo.keyBytes)\r\n ) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n if (\r\n !$isLooseObj(x.key.algorithm) ||\r\n x.key.algorithm.name !== algo.web ||\r\n (typeof x.key.algorithm.length === 'number' && x.key.algorithm.length !== algo.keyBytes * 8) ||\r\n typeof x.key.extractable !== 'boolean' ||\r\n !Array.isArray(x.key.usages) ||\r\n x.key.usages.length !== 2 ||\r\n !(x.key.usages.includes('encrypt') && x.key.usages.includes('decrypt'))\r\n ) {\r\n return false;\r\n }\r\n return true;\r\n}\r\n\r\n/** Regular expressions for encrypted data patterns */\r\nexport const ENCRYPTED_REGEX = Object.freeze({\r\n general: /^(?:[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)?\\.)$/,\r\n node: /^([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.$/,\r\n web: /^([A-Za-z0-9_-]+)\\.([A-Za-z0-9_-]+)\\.$/,\r\n});\r\n\r\n/** Checks if the input string matches the specified encrypted data pattern. */\r\nexport function matchPattern(data: string, format: 'general' | 'node' | 'web'): boolean {\r\n if (typeof data !== 'string') return false;\r\n if (!(format in ENCRYPTED_REGEX)) throw new Error(`Unknown format: ${format}`);\r\n return ENCRYPTED_REGEX[format].test(data);\r\n}\r\n","import { $isObj } from './validate';\r\n\r\nexport interface ResultErr {\r\n readonly message: string;\r\n readonly description: string;\r\n}\r\n\r\nexport type Result<T, E = ResultErr> = T extends object\r\n ?\r\n | ({ readonly [K in keyof T]: T[K] } & { readonly success: true; readonly error?: undefined })\r\n | ({ readonly [K in keyof T]?: undefined } & { readonly success: false; readonly error: E })\r\n :\r\n | { readonly success: true; readonly result: T; readonly error?: undefined }\r\n | { readonly success: false; readonly error: E; readonly result?: undefined };\r\n\r\nexport function $ok<T>(result?: T): Result<T> {\r\n if ($isObj(result)) return { success: true, ...(result as T & object) } as Result<T>;\r\n return { success: true, result } as Result<T>;\r\n}\r\n\r\nexport function $err(err: { msg: string; desc: string }): Result<never, ResultErr>;\r\nexport function $err(err: ResultErr): Result<never, ResultErr>;\r\nexport function $err(err: { msg: string; desc: string } | ResultErr): Result<never, ResultErr> {\r\n return {\r\n success: false,\r\n error: {\r\n message: 'msg' in err ? err.msg : err.message,\r\n description: 'desc' in err ? err.desc : err.description,\r\n },\r\n } as Result<never, ResultErr>;\r\n}\r\n\r\nexport function $fmtError(error: unknown): string {\r\n if (error instanceof Error) return error.message;\r\n if (typeof error === 'string') return error;\r\n return String(error);\r\n}\r\n\r\nexport function $fmtResultErr(err: ResultErr): string {\r\n return `${err.message} - ${err.description}`;\r\n}\r\n","import { $err, $fmtError, $fmtResultErr, $ok, type Result } from './error';\r\nimport { $isObj, $isStr } from './validate';\r\n\r\nexport function $stringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string> {\r\n try {\r\n if (!$isObj(obj)) return $err({ msg: 'Invalid object', desc: 'Input is not a plain object' });\r\n return $ok(JSON.stringify(obj));\r\n } catch (error) {\r\n return $err({ msg: 'Utility: Stringify error', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\n/**\r\n * Stringify an object.\r\n *\r\n * @param obj - The object to stringify.\r\n * @returns An JSON string.\r\n * @throws {Error} If the object cannot be stringified.\r\n */\r\nexport function stringifyObj<T extends object = Record<string, unknown>>(obj: T): string {\r\n const { result, error } = $stringifyObj(obj);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n\r\n/**\r\n * Stringify an object.\r\n *\r\n * @param obj - The object to stringify.\r\n * @returns A Result containing the JSON string or an error.\r\n */\r\nexport function tryStringifyObj<T extends object = Record<string, unknown>>(obj: T): Result<string> {\r\n return $stringifyObj(obj);\r\n}\r\n\r\nexport function $parseToObj<T extends object = Record<string, unknown>>(str: string): Result<{ result: T }> {\r\n try {\r\n if (!$isStr(str)) return $err({ msg: 'Utility: Invalid input', desc: 'Input is not a valid string' });\r\n const obj = JSON.parse(str);\r\n\r\n if (!$isObj(obj)) return $err({ msg: 'Utility: Invalid object format', desc: 'Parsed data is not a plain object' });\r\n return $ok({ result: obj as T });\r\n } catch (error) {\r\n return $err({ msg: 'Utility: Invalid format', desc: $fmtError(error) });\r\n }\r\n}\r\n\r\n/**\r\n * Parse a string to an object.\r\n *\r\n * @param str - The JSON string to parse.\r\n * @returns A Result containing the parsed object or an error.\r\n */\r\nexport function tryParseToObj<T extends object = Record<string, unknown>>(str: string): Result<{ result: T }> {\r\n return $parseToObj<T>(str);\r\n}\r\n\r\n/**\r\n * Parse a string to an object.\r\n *\r\n * @param str - The JSON string to parse.\r\n * @returns A parsed object.\r\n * @throws {Error} If the string cannot be parsed or is not a valid object.\r\n */\r\nexport function parseToObj<T extends object = Record<string, unknown>>(str: string): T {\r\n const { result, error } = $parseToObj<T>(str);\r\n if (error) throw new Error($fmtResultErr(error));\r\n return result;\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Result,
|
|
1
|
+
import { R as Result, c as ENCRYPTION_ALGORITHMS, D as DIGEST_ALGORITHMS, S as SecretKey, b as EncodingFormat } from './validate-TRx4DDtg.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Generates a UUID (v4).
|
|
@@ -17,90 +17,100 @@ declare function generateUuid(): string;
|
|
|
17
17
|
* Derives a secret key from the provided string for encryption/decryption.
|
|
18
18
|
* Internally, the key is hashed using SHA-256 to ensure it meets the required length.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @returns A Result containing a
|
|
20
|
+
* @param secret - The input string to derive the secret key from.
|
|
21
|
+
* @returns A Result containing a SecretKey object representing the derived secret key or an error.
|
|
22
22
|
*/
|
|
23
|
-
declare function tryCreateSecretKey(
|
|
24
|
-
|
|
23
|
+
declare function tryCreateSecretKey(secret: string, options?: {
|
|
24
|
+
algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
|
|
25
|
+
digest?: keyof typeof DIGEST_ALGORITHMS;
|
|
26
|
+
salt?: string;
|
|
27
|
+
info?: string;
|
|
28
|
+
}): Promise<Result<{
|
|
29
|
+
result: SecretKey<'web'>;
|
|
25
30
|
}>>;
|
|
26
31
|
/**
|
|
27
32
|
* Derives a secret key from the provided string for encryption/decryption.
|
|
28
33
|
* Internally, the key is hashed using SHA-256 to ensure it meets the required length.
|
|
29
34
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @returns A
|
|
35
|
+
* @param secret - The input string to derive the secret key from.
|
|
36
|
+
* @returns A SecretKey object representing the derived secret key.
|
|
32
37
|
* @throws {Error} If the input key is invalid or key generation fails.
|
|
33
38
|
*/
|
|
34
|
-
declare function createSecretKey(
|
|
39
|
+
declare function createSecretKey(secret: string, options?: {
|
|
40
|
+
algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
|
|
41
|
+
digest?: keyof typeof DIGEST_ALGORITHMS;
|
|
42
|
+
salt?: string;
|
|
43
|
+
info?: string;
|
|
44
|
+
}): Promise<SecretKey<'web'>>;
|
|
35
45
|
/**
|
|
36
46
|
* Encrypts the input string using the provided secret key.
|
|
37
47
|
* The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
|
|
38
48
|
*
|
|
39
49
|
* @param data - The input string to encrypt.
|
|
40
|
-
* @param secretKey - The
|
|
50
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
41
51
|
* @returns A Result containing a string representing the encrypted data in the specified format or an error.
|
|
42
52
|
*/
|
|
43
|
-
declare function tryEncrypt(data: string, secretKey:
|
|
53
|
+
declare function tryEncrypt(data: string, secretKey: SecretKey<'web'>): Promise<Result<string>>;
|
|
44
54
|
/**
|
|
45
55
|
* Encrypts the input string using the provided secret key.
|
|
46
56
|
* The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
|
|
47
57
|
*
|
|
48
58
|
* @param data - The input string to encrypt.
|
|
49
|
-
* @param secretKey - The
|
|
59
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
50
60
|
* @returns A string representing the encrypted data in the specified format.
|
|
51
61
|
* @throws {Error} If the input data or key is invalid, or if encryption fails.
|
|
52
62
|
*/
|
|
53
|
-
declare function encrypt(data: string, secretKey:
|
|
63
|
+
declare function encrypt(data: string, secretKey: SecretKey<'web'>): Promise<string>;
|
|
54
64
|
/**
|
|
55
65
|
* Decrypts the input string using the provided secret key.
|
|
56
66
|
* The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
|
|
57
67
|
*
|
|
58
68
|
* @param encrypted - The input string to decrypt.
|
|
59
|
-
* @param secretKey - The
|
|
69
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
60
70
|
* @returns A Result containing a string representing the decrypted data or an error.
|
|
61
71
|
*/
|
|
62
|
-
declare function tryDecrypt(encrypted: string, secretKey:
|
|
72
|
+
declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'web'>): Promise<Result<string>>;
|
|
63
73
|
/**
|
|
64
74
|
* Decrypts the input string using the provided secret key.
|
|
65
75
|
* The input must be in the format "iv.cipherWithTag" where each component is base64url encoded.
|
|
66
76
|
*
|
|
67
77
|
* @param encrypted - The input string to decrypt.
|
|
68
|
-
* @param secretKey - The
|
|
78
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
69
79
|
* @returns A string representing the decrypted data.
|
|
70
80
|
* @throws {Error} If the input data or key is invalid, or if decryption fails.
|
|
71
81
|
*/
|
|
72
|
-
declare function decrypt(encrypted: string, secretKey:
|
|
82
|
+
declare function decrypt(encrypted: string, secretKey: SecretKey<'web'>): Promise<string>;
|
|
73
83
|
/**
|
|
74
84
|
* Encrypts the input object using the provided secret key.
|
|
75
85
|
* The object is first serialized to a JSON string before encryption.
|
|
76
86
|
* The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
|
|
77
87
|
*
|
|
78
88
|
* @param data - The input object to encrypt.
|
|
79
|
-
* @param secretKey - The
|
|
89
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
80
90
|
* @returns A Result containing a string representing the encrypted object in the specified format or an error.
|
|
81
91
|
*/
|
|
82
|
-
declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey:
|
|
92
|
+
declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>): Promise<Result<string>>;
|
|
83
93
|
/**
|
|
84
94
|
* Encrypts the input object using the provided secret key.
|
|
85
95
|
* The object is first serialized to a JSON string before encryption.
|
|
86
96
|
* The output is a string in the format "iv.cipherWithTag." where each component is base64url encoded.
|
|
87
97
|
*
|
|
88
98
|
* @param data - The input object to encrypt.
|
|
89
|
-
* @param secretKey - The
|
|
99
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
90
100
|
* @returns A string representing the encrypted object in the specified format.
|
|
91
101
|
* @throws {Error} If the input data or key is invalid, or if encryption fails.
|
|
92
102
|
*/
|
|
93
|
-
declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey:
|
|
103
|
+
declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'web'>): Promise<string>;
|
|
94
104
|
/**
|
|
95
105
|
* Decrypts the input string to an object using the provided secret key.
|
|
96
106
|
* The input must be in the format "iv.cipherWithTag." where each component is base64url encoded.
|
|
97
107
|
* The decrypted string is parsed as JSON to reconstruct the original object.
|
|
98
108
|
*
|
|
99
109
|
* @param encrypted - The input string to decrypt.
|
|
100
|
-
* @param secretKey - The
|
|
110
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
101
111
|
* @returns A Result containing an object representing the decrypted data or an error.
|
|
102
112
|
*/
|
|
103
|
-
declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey:
|
|
113
|
+
declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>): Promise<Result<{
|
|
104
114
|
result: T;
|
|
105
115
|
}>>;
|
|
106
116
|
/**
|
|
@@ -109,11 +119,11 @@ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encry
|
|
|
109
119
|
* The decrypted string is parsed as JSON to reconstruct the original object.
|
|
110
120
|
*
|
|
111
121
|
* @param encrypted - The input string to decrypt.
|
|
112
|
-
* @param secretKey - The
|
|
122
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
113
123
|
* @returns An object representing the decrypted data.
|
|
114
124
|
* @throws {Error} If the input data or key is invalid, or if decryption fails.
|
|
115
125
|
*/
|
|
116
|
-
declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey:
|
|
126
|
+
declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'web'>): Promise<{
|
|
117
127
|
result: T;
|
|
118
128
|
}>;
|
|
119
129
|
/**
|
|
@@ -234,7 +244,6 @@ declare const kit_encryptObj: typeof encryptObj;
|
|
|
234
244
|
declare const kit_generateUuid: typeof generateUuid;
|
|
235
245
|
declare const kit_hash: typeof hash;
|
|
236
246
|
declare const kit_hashPassword: typeof hashPassword;
|
|
237
|
-
declare const kit_isWebSecretKey: typeof isWebSecretKey;
|
|
238
247
|
declare const kit_tryConvertBytesToStr: typeof tryConvertBytesToStr;
|
|
239
248
|
declare const kit_tryConvertFormat: typeof tryConvertFormat;
|
|
240
249
|
declare const kit_tryConvertStrToBytes: typeof tryConvertStrToBytes;
|
|
@@ -248,7 +257,7 @@ declare const kit_tryHash: typeof tryHash;
|
|
|
248
257
|
declare const kit_tryHashPassword: typeof tryHashPassword;
|
|
249
258
|
declare const kit_verifyPassword: typeof verifyPassword;
|
|
250
259
|
declare namespace kit {
|
|
251
|
-
export { kit_convertBytesToStr as convertBytesToStr, kit_convertFormat as convertFormat, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashPassword as hashPassword,
|
|
260
|
+
export { kit_convertBytesToStr as convertBytesToStr, kit_convertFormat as convertFormat, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashPassword as hashPassword, kit_tryConvertBytesToStr as tryConvertBytesToStr, kit_tryConvertFormat as tryConvertFormat, kit_tryConvertStrToBytes as tryConvertStrToBytes, kit_tryCreateSecretKey as tryCreateSecretKey, kit_tryDecrypt as tryDecrypt, kit_tryDecryptObj as tryDecryptObj, kit_tryEncrypt as tryEncrypt, kit_tryEncryptObj as tryEncryptObj, kit_tryGenerateUuid as tryGenerateUuid, kit_tryHash as tryHash, kit_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
|
|
252
261
|
}
|
|
253
262
|
|
|
254
263
|
export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h, encryptObj as i, tryDecryptObj as j, kit as k, decryptObj as l, tryHash as m, hash as n, tryHashPassword as o, hashPassword as p, tryConvertStrToBytes as q, convertStrToBytes as r, tryConvertBytesToStr as s, tryGenerateUuid as t, convertBytesToStr as u, verifyPassword as v, tryConvertFormat as w, convertFormat as x };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Result,
|
|
1
|
+
import { R as Result, c as ENCRYPTION_ALGORITHMS, D as DIGEST_ALGORITHMS, S as SecretKey, b as EncodingFormat } from './validate-TRx4DDtg.js';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -18,90 +18,100 @@ declare function generateUuid(): string;
|
|
|
18
18
|
* Derives a secret key from the provided string for encryption/decryption.
|
|
19
19
|
* Internally, the key is hashed using SHA-256 to ensure it meets the required length.
|
|
20
20
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @returns A Result containing a
|
|
21
|
+
* @param secret - The input string to derive the secret key from.
|
|
22
|
+
* @returns A Result containing a SecretKey object representing the derived secret key or an error.
|
|
23
23
|
*/
|
|
24
|
-
declare function tryCreateSecretKey(
|
|
25
|
-
|
|
24
|
+
declare function tryCreateSecretKey(secret: string, options?: {
|
|
25
|
+
algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
|
|
26
|
+
digest?: keyof typeof DIGEST_ALGORITHMS;
|
|
27
|
+
salt?: string;
|
|
28
|
+
info?: string;
|
|
29
|
+
}): Result<{
|
|
30
|
+
result: SecretKey<'node'>;
|
|
26
31
|
}>;
|
|
27
32
|
/**
|
|
28
33
|
* Derives a secret key from the provided string for encryption/decryption.
|
|
29
34
|
* Internally, the key is hashed using SHA-256 to ensure it meets the required length.
|
|
30
35
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @returns A
|
|
36
|
+
* @param secret - The input string to derive the secret key from.
|
|
37
|
+
* @returns A SecretKey object representing the derived secret key.
|
|
33
38
|
* @throws {Error} If the input key is invalid or key generation fails.
|
|
34
39
|
*/
|
|
35
|
-
declare function createSecretKey(
|
|
40
|
+
declare function createSecretKey(secret: string, options?: {
|
|
41
|
+
algorithm?: keyof typeof ENCRYPTION_ALGORITHMS;
|
|
42
|
+
digest?: keyof typeof DIGEST_ALGORITHMS;
|
|
43
|
+
salt?: string;
|
|
44
|
+
info?: string;
|
|
45
|
+
}): SecretKey<'node'>;
|
|
36
46
|
/**
|
|
37
47
|
* Encrypts the input string using the provided secret key.
|
|
38
48
|
* The output is a string in the format "iv.cipher.tag." where each component is base64url encoded.
|
|
39
49
|
*
|
|
40
50
|
* @param data - The input string to encrypt.
|
|
41
|
-
* @param secretKey - The
|
|
51
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
42
52
|
* @returns A Result containing a string representing the encrypted data in the specified format or an error.
|
|
43
53
|
*/
|
|
44
|
-
declare function tryEncrypt(data: string, secretKey:
|
|
54
|
+
declare function tryEncrypt(data: string, secretKey: SecretKey<'node'>): Result<string>;
|
|
45
55
|
/**
|
|
46
56
|
* Encrypts the input string using the provided secret key.
|
|
47
57
|
* The output is a string in the format "iv.cipher.tag." where each component is base64url encoded.
|
|
48
58
|
*
|
|
49
59
|
* @param data - The input string to encrypt.
|
|
50
|
-
* @param secretKey - The
|
|
60
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
51
61
|
* @returns A string representing the encrypted data in the specified format.
|
|
52
62
|
* @throws {Error} If the input data or key is invalid, or if encryption fails.
|
|
53
63
|
*/
|
|
54
|
-
declare function encrypt(data: string, secretKey:
|
|
64
|
+
declare function encrypt(data: string, secretKey: SecretKey<'node'>): string;
|
|
55
65
|
/**
|
|
56
66
|
* Decrypts the input string using the provided secret key.
|
|
57
67
|
* The input must be in the format "iv.cipher.tag." where each component is base64url encoded.
|
|
58
68
|
*
|
|
59
69
|
* @param encrypted - The input string to decrypt.
|
|
60
|
-
* @param secretKey - The
|
|
70
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
61
71
|
* @returns A Result containing a string representing the decrypted data or an error.
|
|
62
72
|
*/
|
|
63
|
-
declare function tryDecrypt(encrypted: string, secretKey:
|
|
73
|
+
declare function tryDecrypt(encrypted: string, secretKey: SecretKey<'node'>): Result<string>;
|
|
64
74
|
/**
|
|
65
75
|
* Decrypts the input string using the provided secret key.
|
|
66
76
|
* The input must be in the format "iv.cipher.tag." where each component is base64url encoded.
|
|
67
77
|
*
|
|
68
78
|
* @param encrypted - The input string to decrypt.
|
|
69
|
-
* @param secretKey - The
|
|
79
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
70
80
|
* @returns A string representing the decrypted data.
|
|
71
81
|
* @throws {Error} If the input data or key is invalid, or if decryption fails.
|
|
72
82
|
*/
|
|
73
|
-
declare function decrypt(encrypted: string, secretKey:
|
|
83
|
+
declare function decrypt(encrypted: string, secretKey: SecretKey<'node'>): string;
|
|
74
84
|
/**
|
|
75
85
|
* Encrypts the input object using the provided secret key.
|
|
76
86
|
* The object is first serialized to a JSON string before encryption.
|
|
77
87
|
* The output is a string in the format "iv.cipher.tag." where each component is base64url encoded.
|
|
78
88
|
*
|
|
79
89
|
* @param data - The input object to encrypt.
|
|
80
|
-
* @param secretKey - The
|
|
90
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
81
91
|
* @returns A Result containing a string representing the encrypted object in the specified format or an error.
|
|
82
92
|
*/
|
|
83
|
-
declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey:
|
|
93
|
+
declare function tryEncryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'node'>): Result<string>;
|
|
84
94
|
/**
|
|
85
95
|
* Encrypts the input object using the provided secret key.
|
|
86
96
|
* The object is first serialized to a JSON string before encryption.
|
|
87
97
|
* The output is a string in the format "iv.cipher.tag." where each component is base64url encoded.
|
|
88
98
|
*
|
|
89
99
|
* @param data - The input object to encrypt.
|
|
90
|
-
* @param secretKey - The
|
|
100
|
+
* @param secretKey - The SecretKey object used for encryption.
|
|
91
101
|
* @returns A string representing the encrypted object in the specified format.
|
|
92
102
|
* @throws {Error} If the input data or key is invalid, or if encryption fails.
|
|
93
103
|
*/
|
|
94
|
-
declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey:
|
|
104
|
+
declare function encryptObj<T extends object = Record<string, unknown>>(data: T, secretKey: SecretKey<'node'>): string;
|
|
95
105
|
/**
|
|
96
106
|
* Decrypts the input string to an object using the provided secret key.
|
|
97
107
|
* The input must be in the format "iv.cipher.tag." where each component is base64url encoded.
|
|
98
108
|
* The decrypted string is parsed as JSON to reconstruct the original object.
|
|
99
109
|
*
|
|
100
110
|
* @param encrypted - The input string to decrypt.
|
|
101
|
-
* @param secretKey - The
|
|
111
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
102
112
|
* @returns A Result containing an object representing the decrypted data or an error.
|
|
103
113
|
*/
|
|
104
|
-
declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey:
|
|
114
|
+
declare function tryDecryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'node'>): Result<{
|
|
105
115
|
result: T;
|
|
106
116
|
}>;
|
|
107
117
|
/**
|
|
@@ -110,11 +120,11 @@ declare function tryDecryptObj<T extends object = Record<string, unknown>>(encry
|
|
|
110
120
|
* The decrypted string is parsed as JSON to reconstruct the original object.
|
|
111
121
|
*
|
|
112
122
|
* @param encrypted - The input string to decrypt.
|
|
113
|
-
* @param secretKey - The
|
|
123
|
+
* @param secretKey - The SecretKey object used for decryption.
|
|
114
124
|
* @returns An object representing the decrypted data.
|
|
115
125
|
* @throws {Error} If the input data or key is invalid, or if decryption fails.
|
|
116
126
|
*/
|
|
117
|
-
declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey:
|
|
127
|
+
declare function decryptObj<T extends object = Record<string, unknown>>(encrypted: string, secretKey: SecretKey<'node'>): {
|
|
118
128
|
result: T;
|
|
119
129
|
};
|
|
120
130
|
/**
|
|
@@ -235,7 +245,6 @@ declare const kit_encryptObj: typeof encryptObj;
|
|
|
235
245
|
declare const kit_generateUuid: typeof generateUuid;
|
|
236
246
|
declare const kit_hash: typeof hash;
|
|
237
247
|
declare const kit_hashPassword: typeof hashPassword;
|
|
238
|
-
declare const kit_isNodeSecretKey: typeof isNodeSecretKey;
|
|
239
248
|
declare const kit_tryConvertBytesToStr: typeof tryConvertBytesToStr;
|
|
240
249
|
declare const kit_tryConvertFormat: typeof tryConvertFormat;
|
|
241
250
|
declare const kit_tryConvertStrToBytes: typeof tryConvertStrToBytes;
|
|
@@ -249,7 +258,7 @@ declare const kit_tryHash: typeof tryHash;
|
|
|
249
258
|
declare const kit_tryHashPassword: typeof tryHashPassword;
|
|
250
259
|
declare const kit_verifyPassword: typeof verifyPassword;
|
|
251
260
|
declare namespace kit {
|
|
252
|
-
export { kit_convertBytesToStr as convertBytesToStr, kit_convertFormat as convertFormat, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashPassword as hashPassword,
|
|
261
|
+
export { kit_convertBytesToStr as convertBytesToStr, kit_convertFormat as convertFormat, kit_convertStrToBytes as convertStrToBytes, kit_createSecretKey as createSecretKey, kit_decrypt as decrypt, kit_decryptObj as decryptObj, kit_encrypt as encrypt, kit_encryptObj as encryptObj, kit_generateUuid as generateUuid, kit_hash as hash, kit_hashPassword as hashPassword, kit_tryConvertBytesToStr as tryConvertBytesToStr, kit_tryConvertFormat as tryConvertFormat, kit_tryConvertStrToBytes as tryConvertStrToBytes, kit_tryCreateSecretKey as tryCreateSecretKey, kit_tryDecrypt as tryDecrypt, kit_tryDecryptObj as tryDecryptObj, kit_tryEncrypt as tryEncrypt, kit_tryEncryptObj as tryEncryptObj, kit_tryGenerateUuid as tryGenerateUuid, kit_tryHash as tryHash, kit_tryHashPassword as tryHashPassword, kit_verifyPassword as verifyPassword };
|
|
253
262
|
}
|
|
254
263
|
|
|
255
264
|
export { tryCreateSecretKey as a, tryEncrypt as b, createSecretKey as c, tryDecrypt as d, encrypt as e, decrypt as f, generateUuid as g, tryEncryptObj as h, encryptObj as i, tryDecryptObj as j, kit as k, decryptObj as l, tryHash as m, hash as n, tryHashPassword as o, hashPassword as p, tryConvertStrToBytes as q, convertStrToBytes as r, tryConvertBytesToStr as s, tryGenerateUuid as t, convertBytesToStr as u, verifyPassword as v, tryConvertFormat as w, convertFormat as x };
|