@softwear/latestcollectioncore 1.0.135 → 1.0.136

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.
@@ -1,9 +1,5 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- /// <reference types="node" />
4
3
  import { Buffer } from 'node:buffer';
5
- import type { CipherKey } from 'node:crypto';
6
- type KeyMaterial = Extract<CipherKey, Buffer>;
7
- export declare function encrypt(plain: string, KEY: KeyMaterial): string;
8
- export declare function decrypt(enc: string, KEY: KeyMaterial): string;
9
- export {};
4
+ export declare function encrypt(plain: string, KEY: Buffer): string;
5
+ export declare function decrypt(enc: string, KEY: Buffer): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.135",
3
+ "version": "1.0.136",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,10 +1,7 @@
1
1
  import { Buffer } from 'node:buffer'
2
2
  import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto'
3
- import type { CipherKey } from 'node:crypto'
4
3
 
5
- type KeyMaterial = Extract<CipherKey, Buffer>
6
-
7
- export function encrypt(plain: string, KEY: KeyMaterial): string {
4
+ export function encrypt(plain: string, KEY: Buffer): string {
8
5
  const iv = randomBytes(12)
9
6
  const cipher = createCipheriv('aes-256-gcm', KEY, iv)
10
7
  const ciphertext = Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()])
@@ -15,7 +12,7 @@ export function encrypt(plain: string, KEY: KeyMaterial): string {
15
12
  return `v1:${b64(iv)}:${b64(ciphertext)}:${b64(tag)}`
16
13
  }
17
14
 
18
- export function decrypt(enc: string, KEY: KeyMaterial): string {
15
+ export function decrypt(enc: string, KEY: Buffer): string {
19
16
  const [version, ivB64, ctB64, tagB64] = enc.split(':')
20
17
  if (version !== 'v1') throw new Error('Unsupported version')
21
18