@push.rocks/smartsecret 1.0.2 → 1.1.0
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/.smartconfig.json +48 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/index.d.ts +4 -0
- package/dist_ts/index.js +3 -1
- package/dist_ts/smartsecret.keyring.d.ts +81 -0
- package/dist_ts/smartsecret.keyring.error.d.ts +17 -0
- package/dist_ts/smartsecret.keyring.error.js +46 -0
- package/dist_ts/smartsecret.keyring.js +758 -0
- package/dist_ts/smartsecret.keyring.protocol.d.ts +57 -0
- package/dist_ts/smartsecret.keyring.protocol.js +290 -0
- package/dist_ts/smartsecret.plugins.d.ts +2 -1
- package/dist_ts/smartsecret.plugins.js +4 -2
- package/package.json +16 -13
- package/readme.hints.md +8 -1
- package/readme.md +111 -3
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/index.ts +10 -0
- package/ts/smartsecret.keyring.error.ts +76 -0
- package/ts/smartsecret.keyring.protocol.ts +377 -0
- package/ts/smartsecret.keyring.ts +955 -0
- package/ts/smartsecret.plugins.ts +4 -1
- package/npmextra.json +0 -44
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@git.zone/cli": {
|
|
3
|
+
"schemaVersion": 2,
|
|
4
|
+
"projectType": "npm",
|
|
5
|
+
"module": {
|
|
6
|
+
"githost": "code.foss.global",
|
|
7
|
+
"gitscope": "push.rocks",
|
|
8
|
+
"gitrepo": "smartsecret",
|
|
9
|
+
"description": "OS keychain-based secret storage with encrypted-file fallback for Node.js.",
|
|
10
|
+
"npmPackagename": "@push.rocks/smartsecret",
|
|
11
|
+
"license": "MIT"
|
|
12
|
+
},
|
|
13
|
+
"commit": {
|
|
14
|
+
"confirmation": "prompt",
|
|
15
|
+
"steps": ["analyze", "test", "build", "changelog", "commit", "push"]
|
|
16
|
+
},
|
|
17
|
+
"release": {
|
|
18
|
+
"confirmation": "prompt",
|
|
19
|
+
"preflight": {
|
|
20
|
+
"requireCleanTree": true,
|
|
21
|
+
"test": true,
|
|
22
|
+
"build": true
|
|
23
|
+
},
|
|
24
|
+
"targets": {
|
|
25
|
+
"git": {
|
|
26
|
+
"enabled": true,
|
|
27
|
+
"remote": "origin",
|
|
28
|
+
"pushBranch": true,
|
|
29
|
+
"pushTags": true
|
|
30
|
+
},
|
|
31
|
+
"npm": {
|
|
32
|
+
"enabled": true,
|
|
33
|
+
"registries": [
|
|
34
|
+
"https://registry.npmjs.org",
|
|
35
|
+
"https://verdaccio.lossless.digital"
|
|
36
|
+
],
|
|
37
|
+
"accessLevel": "public",
|
|
38
|
+
"alreadyPublished": "success"
|
|
39
|
+
},
|
|
40
|
+
"docker": {
|
|
41
|
+
"enabled": false,
|
|
42
|
+
"engine": "tsdocker",
|
|
43
|
+
"patterns": []
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartsecret',
|
|
6
|
-
version: '1.0
|
|
6
|
+
version: '1.1.0',
|
|
7
7
|
description: 'OS keychain-based secret storage with encrypted-file fallback for Node.js.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx5QkFBeUI7SUFDL0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLDRFQUE0RTtDQUMxRixDQUFBIn0=
|
package/dist_ts/index.d.ts
CHANGED
|
@@ -3,3 +3,7 @@ export type { ISecretBackend, TBackendType } from './smartsecret.backends.base.j
|
|
|
3
3
|
export { MacosKeychainBackend } from './smartsecret.backends.macos.js';
|
|
4
4
|
export { LinuxSecretServiceBackend } from './smartsecret.backends.linux.js';
|
|
5
5
|
export { FileEncryptedBackend } from './smartsecret.backends.file.js';
|
|
6
|
+
export * from './smartsecret.keyring.js';
|
|
7
|
+
export { SmartSecretKeyringError } from './smartsecret.keyring.error.js';
|
|
8
|
+
export type { ISmartSecretKeyringErrorJson, TSmartSecretKeyringErrorCode, } from './smartsecret.keyring.error.js';
|
|
9
|
+
export type { ISmartSecretEnvelopeV1, TSmartSecretKeyringProfile, } from './smartsecret.keyring.protocol.js';
|
package/dist_ts/index.js
CHANGED
|
@@ -2,4 +2,6 @@ export * from './smartsecret.classes.smartsecret.js';
|
|
|
2
2
|
export { MacosKeychainBackend } from './smartsecret.backends.macos.js';
|
|
3
3
|
export { LinuxSecretServiceBackend } from './smartsecret.backends.linux.js';
|
|
4
4
|
export { FileEncryptedBackend } from './smartsecret.backends.file.js';
|
|
5
|
-
|
|
5
|
+
export * from './smartsecret.keyring.js';
|
|
6
|
+
export { SmartSecretKeyringError } from './smartsecret.keyring.error.js';
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHNDQUFzQyxDQUFDO0FBRXJELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ3ZFLE9BQU8sRUFBRSx5QkFBeUIsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzVFLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3RFLGNBQWMsMEJBQTBCLENBQUM7QUFDekMsT0FBTyxFQUFFLHVCQUF1QixFQUFFLE1BQU0sZ0NBQWdDLENBQUMifQ==
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type ISmartSecretEnvelopeV1 } from './smartsecret.keyring.protocol.js';
|
|
2
|
+
export type TSmartSecretKekStatus = 'active' | 'retired' | 'revoked';
|
|
3
|
+
export interface ISmartSecretKekDescriptor {
|
|
4
|
+
version: number;
|
|
5
|
+
status: TSmartSecretKekStatus;
|
|
6
|
+
credentialPath?: string;
|
|
7
|
+
expectedFingerprint?: `sha256:${string}`;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
activatedAt: number;
|
|
10
|
+
retiredAt?: number;
|
|
11
|
+
revokedAt?: number;
|
|
12
|
+
escrowReference?: string;
|
|
13
|
+
escrowedAt?: number;
|
|
14
|
+
recoveryTestedAt?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ISmartSecretKeyringConfig {
|
|
17
|
+
keyringId: string;
|
|
18
|
+
keys: readonly ISmartSecretKekDescriptor[];
|
|
19
|
+
}
|
|
20
|
+
export interface ISmartSecretKekInspection {
|
|
21
|
+
version: number;
|
|
22
|
+
status: TSmartSecretKekStatus;
|
|
23
|
+
expectedFingerprint?: `sha256:${string}`;
|
|
24
|
+
createdAt: number;
|
|
25
|
+
activatedAt: number;
|
|
26
|
+
retiredAt?: number;
|
|
27
|
+
revokedAt?: number;
|
|
28
|
+
escrowReference?: string;
|
|
29
|
+
escrowedAt?: number;
|
|
30
|
+
recoveryTestedAt?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface ISmartSecretKeyringInspection {
|
|
33
|
+
keyringId: string;
|
|
34
|
+
activeVersion: number;
|
|
35
|
+
keys: ISmartSecretKekInspection[];
|
|
36
|
+
}
|
|
37
|
+
export interface IEncryptSmartSecretEnvelopeOptions {
|
|
38
|
+
envelopeId: string;
|
|
39
|
+
plaintext: Uint8Array;
|
|
40
|
+
context: Uint8Array;
|
|
41
|
+
createdAt?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface IDecryptSmartSecretEnvelopeOptions {
|
|
44
|
+
envelope: unknown;
|
|
45
|
+
expectedEnvelopeId: string;
|
|
46
|
+
context: Uint8Array;
|
|
47
|
+
}
|
|
48
|
+
export interface IRewrapSmartSecretEnvelopeOptions {
|
|
49
|
+
envelope: unknown;
|
|
50
|
+
expectedEnvelopeId: string;
|
|
51
|
+
context: Uint8Array;
|
|
52
|
+
targetVersion?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface ISmartSecretRecoverySelfTestResult {
|
|
55
|
+
keyringId: string;
|
|
56
|
+
version: number;
|
|
57
|
+
status: 'active' | 'retired';
|
|
58
|
+
fingerprint: `sha256:${string}`;
|
|
59
|
+
testedAt: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A Linux-only, immutable KEK snapshot for strict DEK/KEK envelopes.
|
|
63
|
+
* Envelope persistence and compare-and-swap coordination remain consumer responsibilities.
|
|
64
|
+
*/
|
|
65
|
+
export declare class SmartSecretKeyring {
|
|
66
|
+
private readonly keyringId;
|
|
67
|
+
private readonly descriptors;
|
|
68
|
+
private readonly activeVersion;
|
|
69
|
+
private readonly loadedKeys;
|
|
70
|
+
private destroyed;
|
|
71
|
+
private constructor();
|
|
72
|
+
static create(configArg: ISmartSecretKeyringConfig): Promise<SmartSecretKeyring>;
|
|
73
|
+
private requireAlive;
|
|
74
|
+
private requireEnvelopeKey;
|
|
75
|
+
inspect(): ISmartSecretKeyringInspection;
|
|
76
|
+
destroy(): void;
|
|
77
|
+
encryptEnvelope(optionsArg: IEncryptSmartSecretEnvelopeOptions): Promise<ISmartSecretEnvelopeV1>;
|
|
78
|
+
decryptEnvelope(optionsArg: IDecryptSmartSecretEnvelopeOptions): Promise<Uint8Array>;
|
|
79
|
+
rewrapEnvelope(optionsArg: IRewrapSmartSecretEnvelopeOptions): Promise<ISmartSecretEnvelopeV1>;
|
|
80
|
+
recoverySelfTest(versionArg: number): Promise<ISmartSecretRecoverySelfTestResult>;
|
|
81
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type TSmartSecretKeyringErrorCode = 'AUTHENTICATION_FAILED' | 'CONFIG_INVALID' | 'CONTEXT_MISMATCH' | 'CRYPTO_OPERATION_FAILED' | 'CREDENTIAL_FILE_INVALID' | 'DESTROYED' | 'ENVELOPE_ID_MISMATCH' | 'ENVELOPE_INVALID' | 'KEK_FINGERPRINT_MISMATCH' | 'KEK_UNAVAILABLE' | 'INVALID_ARGUMENT' | 'PLATFORM_UNSUPPORTED' | 'SIZE_LIMIT_EXCEEDED' | 'TARGET_VERSION_MISMATCH';
|
|
2
|
+
export interface ISmartSecretKeyringErrorJson {
|
|
3
|
+
name: 'SmartSecretKeyringError';
|
|
4
|
+
code: TSmartSecretKeyringErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
declare const inspectSymbol: unique symbol;
|
|
8
|
+
/** A code-only error that intentionally retains no operation values or causes. */
|
|
9
|
+
export declare class SmartSecretKeyringError extends Error {
|
|
10
|
+
readonly code: TSmartSecretKeyringErrorCode;
|
|
11
|
+
readonly cause: undefined;
|
|
12
|
+
constructor(codeArg: TSmartSecretKeyringErrorCode);
|
|
13
|
+
toJSON(): ISmartSecretKeyringErrorJson;
|
|
14
|
+
[inspectSymbol](): ISmartSecretKeyringErrorJson;
|
|
15
|
+
}
|
|
16
|
+
export declare const createSmartSecretKeyringError: (codeArg: TSmartSecretKeyringErrorCode) => SmartSecretKeyringError;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const inspectSymbol = Symbol.for('nodejs.util.inspect.custom');
|
|
2
|
+
const errorCodes = new Set([
|
|
3
|
+
'AUTHENTICATION_FAILED',
|
|
4
|
+
'CONFIG_INVALID',
|
|
5
|
+
'CONTEXT_MISMATCH',
|
|
6
|
+
'CRYPTO_OPERATION_FAILED',
|
|
7
|
+
'CREDENTIAL_FILE_INVALID',
|
|
8
|
+
'DESTROYED',
|
|
9
|
+
'ENVELOPE_ID_MISMATCH',
|
|
10
|
+
'ENVELOPE_INVALID',
|
|
11
|
+
'KEK_FINGERPRINT_MISMATCH',
|
|
12
|
+
'KEK_UNAVAILABLE',
|
|
13
|
+
'INVALID_ARGUMENT',
|
|
14
|
+
'PLATFORM_UNSUPPORTED',
|
|
15
|
+
'SIZE_LIMIT_EXCEEDED',
|
|
16
|
+
'TARGET_VERSION_MISMATCH',
|
|
17
|
+
]);
|
|
18
|
+
/** A code-only error that intentionally retains no operation values or causes. */
|
|
19
|
+
export class SmartSecretKeyringError extends Error {
|
|
20
|
+
constructor(codeArg) {
|
|
21
|
+
const code = errorCodes.has(codeArg) ? codeArg : 'INVALID_ARGUMENT';
|
|
22
|
+
const message = `SmartSecret keyring operation failed (${code}).`;
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'SmartSecretKeyringError';
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.stack = `${this.name}: ${message}`;
|
|
27
|
+
Object.defineProperty(this, 'cause', {
|
|
28
|
+
configurable: false,
|
|
29
|
+
enumerable: false,
|
|
30
|
+
value: undefined,
|
|
31
|
+
writable: false,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
toJSON() {
|
|
35
|
+
return {
|
|
36
|
+
name: 'SmartSecretKeyringError',
|
|
37
|
+
code: this.code,
|
|
38
|
+
message: this.message,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
[inspectSymbol]() {
|
|
42
|
+
return this.toJSON();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export const createSmartSecretKeyringError = (codeArg) => new SmartSecretKeyringError(codeArg);
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzZWNyZXQua2V5cmluZy5lcnJvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0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