@fgv/ts-extras 5.1.0-10 → 5.1.0-12
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/packlets/crypto-utils/keystore/keyStore.js +11 -4
- package/dist/ts-extras.d.ts +24 -4
- package/lib/packlets/crypto-utils/keystore/keyStore.d.ts +11 -5
- package/lib/packlets/crypto-utils/keystore/keyStore.js +11 -4
- package/lib/packlets/crypto-utils/keystore/model.d.ts +12 -0
- package/package.json +7 -7
|
@@ -360,14 +360,21 @@ export class KeyStore {
|
|
|
360
360
|
return succeed({ entry, replaced });
|
|
361
361
|
}
|
|
362
362
|
/**
|
|
363
|
-
* Imports
|
|
363
|
+
* Imports raw 32-byte key material into the vault.
|
|
364
|
+
*
|
|
365
|
+
* Always validates that the key is exactly 32 bytes (AES-256). The optional
|
|
366
|
+
* `type` field is a classification label stored with the entry; it does not
|
|
367
|
+
* change the validation rules. For importing UTF-8 API key strings (variable
|
|
368
|
+
* length), use {@link KeyStore.importApiKey} instead.
|
|
369
|
+
*
|
|
364
370
|
* @param name - Unique name for the secret
|
|
365
|
-
* @param key - The 32-byte AES-256 key
|
|
366
|
-
* @param options - Optional description, whether to replace existing
|
|
371
|
+
* @param key - The 32-byte AES-256 key material
|
|
372
|
+
* @param options - Optional type classification, description, whether to replace existing
|
|
367
373
|
* @returns Success with entry, Failure if locked, key invalid, or exists and !replace
|
|
368
374
|
* @public
|
|
369
375
|
*/
|
|
370
376
|
importSecret(name, key, options) {
|
|
377
|
+
var _a;
|
|
371
378
|
if (!this._secrets) {
|
|
372
379
|
return fail('Key store is locked');
|
|
373
380
|
}
|
|
@@ -383,7 +390,7 @@ export class KeyStore {
|
|
|
383
390
|
}
|
|
384
391
|
const entry = {
|
|
385
392
|
name,
|
|
386
|
-
type: 'encryption-key',
|
|
393
|
+
type: (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : 'encryption-key',
|
|
387
394
|
key: new Uint8Array(key), // Copy to prevent external modification
|
|
388
395
|
description: options === null || options === void 0 ? void 0 : options.description,
|
|
389
396
|
createdAt: getCurrentTimestamp()
|
package/dist/ts-extras.d.ts
CHANGED
|
@@ -1095,6 +1095,19 @@ declare interface IEncryptionResult {
|
|
|
1095
1095
|
readonly encryptedData: Uint8Array;
|
|
1096
1096
|
}
|
|
1097
1097
|
|
|
1098
|
+
/**
|
|
1099
|
+
* Options for importing raw key material via {@link KeyStore.importSecret}.
|
|
1100
|
+
* Extends {@link IImportSecretOptions} with a type classification.
|
|
1101
|
+
* @public
|
|
1102
|
+
*/
|
|
1103
|
+
declare interface IImportKeyOptions extends IImportSecretOptions {
|
|
1104
|
+
/**
|
|
1105
|
+
* Secret type classification for the imported key material.
|
|
1106
|
+
* @defaultValue 'encryption-key'
|
|
1107
|
+
*/
|
|
1108
|
+
readonly type?: KeyStoreSecretType;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1098
1111
|
/**
|
|
1099
1112
|
* Options for importing a secret.
|
|
1100
1113
|
* @public
|
|
@@ -1500,6 +1513,7 @@ declare namespace KeyStore {
|
|
|
1500
1513
|
IAddSecretResult,
|
|
1501
1514
|
IAddSecretOptions,
|
|
1502
1515
|
IImportSecretOptions,
|
|
1516
|
+
IImportKeyOptions,
|
|
1503
1517
|
IAddSecretFromPasswordOptions,
|
|
1504
1518
|
DEFAULT_SECRET_ITERATIONS,
|
|
1505
1519
|
IAddSecretFromPasswordResult
|
|
@@ -1644,14 +1658,20 @@ declare class KeyStore_2 implements IEncryptionProvider {
|
|
|
1644
1658
|
*/
|
|
1645
1659
|
addSecret(name: string, options?: IAddSecretOptions): Promise<Result<IAddSecretResult>>;
|
|
1646
1660
|
/**
|
|
1647
|
-
* Imports
|
|
1661
|
+
* Imports raw 32-byte key material into the vault.
|
|
1662
|
+
*
|
|
1663
|
+
* Always validates that the key is exactly 32 bytes (AES-256). The optional
|
|
1664
|
+
* `type` field is a classification label stored with the entry; it does not
|
|
1665
|
+
* change the validation rules. For importing UTF-8 API key strings (variable
|
|
1666
|
+
* length), use {@link KeyStore.importApiKey} instead.
|
|
1667
|
+
*
|
|
1648
1668
|
* @param name - Unique name for the secret
|
|
1649
|
-
* @param key - The 32-byte AES-256 key
|
|
1650
|
-
* @param options - Optional description, whether to replace existing
|
|
1669
|
+
* @param key - The 32-byte AES-256 key material
|
|
1670
|
+
* @param options - Optional type classification, description, whether to replace existing
|
|
1651
1671
|
* @returns Success with entry, Failure if locked, key invalid, or exists and !replace
|
|
1652
1672
|
* @public
|
|
1653
1673
|
*/
|
|
1654
|
-
importSecret(name: string, key: Uint8Array, options?:
|
|
1674
|
+
importSecret(name: string, key: Uint8Array, options?: IImportKeyOptions): Result<IAddSecretResult>;
|
|
1655
1675
|
/**
|
|
1656
1676
|
* Adds a secret derived from a password using PBKDF2.
|
|
1657
1677
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JsonValue } from '@fgv/ts-json-base';
|
|
2
2
|
import { Result } from '@fgv/ts-utils';
|
|
3
3
|
import { ICryptoProvider, IEncryptedFile, IEncryptionConfig, IEncryptionProvider, SecretProvider } from '../model';
|
|
4
|
-
import { IAddSecretFromPasswordOptions, IAddSecretFromPasswordResult, IAddSecretOptions, IAddSecretResult, IImportSecretOptions, IKeyStoreCreateParams, IKeyStoreFile, IKeyStoreOpenParams, IKeyStoreSecretEntry, KeyStoreLockState, KeyStoreSecretType } from './model';
|
|
4
|
+
import { IAddSecretFromPasswordOptions, IAddSecretFromPasswordResult, IAddSecretOptions, IAddSecretResult, IImportKeyOptions, IImportSecretOptions, IKeyStoreCreateParams, IKeyStoreFile, IKeyStoreOpenParams, IKeyStoreSecretEntry, KeyStoreLockState, KeyStoreSecretType } from './model';
|
|
5
5
|
/**
|
|
6
6
|
* Password-protected key store for managing encryption secrets.
|
|
7
7
|
*
|
|
@@ -140,14 +140,20 @@ export declare class KeyStore implements IEncryptionProvider {
|
|
|
140
140
|
*/
|
|
141
141
|
addSecret(name: string, options?: IAddSecretOptions): Promise<Result<IAddSecretResult>>;
|
|
142
142
|
/**
|
|
143
|
-
* Imports
|
|
143
|
+
* Imports raw 32-byte key material into the vault.
|
|
144
|
+
*
|
|
145
|
+
* Always validates that the key is exactly 32 bytes (AES-256). The optional
|
|
146
|
+
* `type` field is a classification label stored with the entry; it does not
|
|
147
|
+
* change the validation rules. For importing UTF-8 API key strings (variable
|
|
148
|
+
* length), use {@link KeyStore.importApiKey} instead.
|
|
149
|
+
*
|
|
144
150
|
* @param name - Unique name for the secret
|
|
145
|
-
* @param key - The 32-byte AES-256 key
|
|
146
|
-
* @param options - Optional description, whether to replace existing
|
|
151
|
+
* @param key - The 32-byte AES-256 key material
|
|
152
|
+
* @param options - Optional type classification, description, whether to replace existing
|
|
147
153
|
* @returns Success with entry, Failure if locked, key invalid, or exists and !replace
|
|
148
154
|
* @public
|
|
149
155
|
*/
|
|
150
|
-
importSecret(name: string, key: Uint8Array, options?:
|
|
156
|
+
importSecret(name: string, key: Uint8Array, options?: IImportKeyOptions): Result<IAddSecretResult>;
|
|
151
157
|
/**
|
|
152
158
|
* Adds a secret derived from a password using PBKDF2.
|
|
153
159
|
*
|
|
@@ -396,14 +396,21 @@ class KeyStore {
|
|
|
396
396
|
return (0, ts_utils_1.succeed)({ entry, replaced });
|
|
397
397
|
}
|
|
398
398
|
/**
|
|
399
|
-
* Imports
|
|
399
|
+
* Imports raw 32-byte key material into the vault.
|
|
400
|
+
*
|
|
401
|
+
* Always validates that the key is exactly 32 bytes (AES-256). The optional
|
|
402
|
+
* `type` field is a classification label stored with the entry; it does not
|
|
403
|
+
* change the validation rules. For importing UTF-8 API key strings (variable
|
|
404
|
+
* length), use {@link KeyStore.importApiKey} instead.
|
|
405
|
+
*
|
|
400
406
|
* @param name - Unique name for the secret
|
|
401
|
-
* @param key - The 32-byte AES-256 key
|
|
402
|
-
* @param options - Optional description, whether to replace existing
|
|
407
|
+
* @param key - The 32-byte AES-256 key material
|
|
408
|
+
* @param options - Optional type classification, description, whether to replace existing
|
|
403
409
|
* @returns Success with entry, Failure if locked, key invalid, or exists and !replace
|
|
404
410
|
* @public
|
|
405
411
|
*/
|
|
406
412
|
importSecret(name, key, options) {
|
|
413
|
+
var _a;
|
|
407
414
|
if (!this._secrets) {
|
|
408
415
|
return (0, ts_utils_1.fail)('Key store is locked');
|
|
409
416
|
}
|
|
@@ -419,7 +426,7 @@ class KeyStore {
|
|
|
419
426
|
}
|
|
420
427
|
const entry = {
|
|
421
428
|
name,
|
|
422
|
-
type: 'encryption-key',
|
|
429
|
+
type: (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : 'encryption-key',
|
|
423
430
|
key: new Uint8Array(key), // Copy to prevent external modification
|
|
424
431
|
description: options === null || options === void 0 ? void 0 : options.description,
|
|
425
432
|
createdAt: getCurrentTimestamp()
|
|
@@ -199,6 +199,18 @@ export interface IImportSecretOptions extends IAddSecretOptions {
|
|
|
199
199
|
*/
|
|
200
200
|
readonly replace?: boolean;
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Options for importing raw key material via {@link KeyStore.importSecret}.
|
|
204
|
+
* Extends {@link IImportSecretOptions} with a type classification.
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
export interface IImportKeyOptions extends IImportSecretOptions {
|
|
208
|
+
/**
|
|
209
|
+
* Secret type classification for the imported key material.
|
|
210
|
+
* @defaultValue 'encryption-key'
|
|
211
|
+
*/
|
|
212
|
+
readonly type?: KeyStoreSecretType;
|
|
213
|
+
}
|
|
202
214
|
/**
|
|
203
215
|
* Options for adding a secret derived from a password.
|
|
204
216
|
* @public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-extras",
|
|
3
|
-
"version": "5.1.0-
|
|
3
|
+
"version": "5.1.0-12",
|
|
4
4
|
"description": "Assorted Typescript Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-extras.d.ts",
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
"@types/js-yaml": "~4.0.9",
|
|
87
87
|
"typedoc": "~0.28.16",
|
|
88
88
|
"typedoc-plugin-markdown": "~4.9.0",
|
|
89
|
-
"@fgv/heft-dual-rig": "5.1.0-
|
|
90
|
-
"@fgv/ts-utils-jest": "5.1.0-
|
|
91
|
-
"@fgv/
|
|
92
|
-
"@fgv/
|
|
89
|
+
"@fgv/heft-dual-rig": "5.1.0-12",
|
|
90
|
+
"@fgv/ts-utils-jest": "5.1.0-12",
|
|
91
|
+
"@fgv/ts-utils": "5.1.0-12",
|
|
92
|
+
"@fgv/typedoc-compact-theme": "5.1.0-12"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"luxon": "^3.7.2",
|
|
@@ -97,10 +97,10 @@
|
|
|
97
97
|
"papaparse": "^5.4.1",
|
|
98
98
|
"fflate": "~0.8.2",
|
|
99
99
|
"js-yaml": "~4.1.1",
|
|
100
|
-
"@fgv/ts-json-base": "5.1.0-
|
|
100
|
+
"@fgv/ts-json-base": "5.1.0-12"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@fgv/ts-utils": "5.1.0-
|
|
103
|
+
"@fgv/ts-utils": "5.1.0-12"
|
|
104
104
|
},
|
|
105
105
|
"repository": {
|
|
106
106
|
"type": "git",
|