@piggly/secrets
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -12,5 +12,6 @@ "use strict"; | ||
class KeyPairManagerService { | ||
constructor(abspath) { | ||
constructor(abspath, current_version) { | ||
this._keypairs = new Map(); | ||
this._path = abspath; | ||
this._current_version = current_version ?? 1; | ||
} | ||
@@ -38,3 +39,3 @@ get raw() { | ||
const pk = _fs.default.readFileSync(_path.default.join(this._path, `${name}.pk.key`)); | ||
keypairs.set(0, { | ||
keypairs.set(1, { | ||
sk, | ||
@@ -51,11 +52,9 @@ pk | ||
const keypair = this._keypairs.get(name); | ||
if (version) { | ||
if (keypair.has(version) === false) { | ||
throw Error(`Key-pair ${name} version ${version} not found.`); | ||
} | ||
return keypair.get(version); | ||
const v = version ?? this._current_version; | ||
if (keypair.has(v) === false) { | ||
throw Error(`Key-pair ${name} version ${v} not found.`); | ||
} | ||
return keypair.get(0); | ||
return keypair.get(v); | ||
} | ||
} | ||
exports.KeyPairManagerService = KeyPairManagerService; |
@@ -12,5 +12,6 @@ "use strict"; | ||
class SecretManagerService { | ||
constructor(abspath) { | ||
constructor(abspath, current_version) { | ||
this._secrets = new Map(); | ||
this._path = abspath; | ||
this._current_version = current_version ?? 1; | ||
} | ||
@@ -34,3 +35,3 @@ get raw() { | ||
const secret = _fs.default.readFileSync(_path.default.join(this._path, `${name}.secret.key`)); | ||
secrets.set(0, secret); | ||
secrets.set(1, secret); | ||
this._secrets.set(name, secrets); | ||
@@ -44,11 +45,9 @@ return true; | ||
const secret = this._secrets.get(name); | ||
if (version) { | ||
if (secret.has(version) === false) { | ||
throw Error(`Secret ${name} version ${version} not found.`); | ||
} | ||
return secret.get(version); | ||
const v = version ?? this._current_version; | ||
if (secret.has(v) === false) { | ||
throw Error(`Secret ${name} version ${v} not found.`); | ||
} | ||
return secret.get(0); | ||
return secret.get(v); | ||
} | ||
} | ||
exports.SecretManagerService = SecretManagerService; |
@@ -5,5 +5,6 @@ import path from 'path'; | ||
export class KeyPairManagerService { | ||
constructor(abspath) { | ||
constructor(abspath, current_version) { | ||
this._keypairs = new Map(); | ||
this._path = abspath; | ||
this._current_version = current_version ?? 1; | ||
} | ||
@@ -31,3 +32,3 @@ get raw() { | ||
const pk = fs.readFileSync(path.join(this._path, `${name}.pk.key`)); | ||
keypairs.set(0, { | ||
keypairs.set(1, { | ||
sk, | ||
@@ -44,10 +45,8 @@ pk | ||
const keypair = this._keypairs.get(name); | ||
if (version) { | ||
if (keypair.has(version) === false) { | ||
throw Error(`Key-pair ${name} version ${version} not found.`); | ||
} | ||
return keypair.get(version); | ||
const v = version ?? this._current_version; | ||
if (keypair.has(v) === false) { | ||
throw Error(`Key-pair ${name} version ${v} not found.`); | ||
} | ||
return keypair.get(0); | ||
return keypair.get(v); | ||
} | ||
} |
@@ -5,5 +5,6 @@ import path from 'path'; | ||
export class SecretManagerService { | ||
constructor(abspath) { | ||
constructor(abspath, current_version) { | ||
this._secrets = new Map(); | ||
this._path = abspath; | ||
this._current_version = current_version ?? 1; | ||
} | ||
@@ -27,3 +28,3 @@ get raw() { | ||
const secret = fs.readFileSync(path.join(this._path, `${name}.secret.key`)); | ||
secrets.set(0, secret); | ||
secrets.set(1, secret); | ||
this._secrets.set(name, secrets); | ||
@@ -37,10 +38,8 @@ return true; | ||
const secret = this._secrets.get(name); | ||
if (version) { | ||
if (secret.has(version) === false) { | ||
throw Error(`Secret ${name} version ${version} not found.`); | ||
} | ||
return secret.get(version); | ||
const v = version ?? this._current_version; | ||
if (secret.has(v) === false) { | ||
throw Error(`Secret ${name} version ${v} not found.`); | ||
} | ||
return secret.get(0); | ||
return secret.get(v); | ||
} | ||
} |
/// <reference types="node" /> | ||
export declare class KeyPairManagerService { | ||
private _keypairs; | ||
private _current_version; | ||
private _path; | ||
constructor(abspath: string); | ||
constructor(abspath: string, current_version?: number); | ||
get raw(): Map<string, Map<number, { | ||
@@ -7,0 +8,0 @@ sk: Buffer; |
/// <reference types="node" /> | ||
export declare class SecretManagerService { | ||
private _secrets; | ||
private _current_version; | ||
private _path; | ||
constructor(abspath: string); | ||
constructor(abspath: string, current_version?: number); | ||
get raw(): Map<string, Map<number, Buffer>>; | ||
@@ -7,0 +8,0 @@ load(name: string, index_name?: string): Promise<true>; |
@@ -33,1 +33,2 @@ import { generateSecret as generateSecretAES256, concatSecrets as concatSecretsAES256, prepareSecret as prepareSecretAES256, prepareEncryption as prepareEncryptionAES256, encrypt as encryptAES256, encryptStream as encryptStreamAES256, decrypt as decryptAES256, decryptStream as decryptStreamAES256 } from './core/secrets/aes256'; | ||
}; | ||
export type { AvailableMnemonicLanguage, GenerateMnemonicOptions, GenerateMnemonicSeedOptions, AvailableKeyPairAlgorithm, GenerateKeyPairOptions, GenerateSecretOptions, VersionedKey, VersionedKeyPair, } from './types'; |
{ | ||
"name": "@piggly/secrets", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "An ESM/CommonJS library to better manage local secrets.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80516
1741