@ibgib/core-gib 0.0.52 → 0.0.53
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/common/encrypt/encrypt-constants.d.mts +8 -0
- package/dist/common/encrypt/encrypt-constants.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-constants.mjs +8 -0
- package/dist/common/encrypt/encrypt-constants.mjs.map +1 -1
- package/dist/common/encrypt/encrypt-helper.d.mts +44 -1
- package/dist/common/encrypt/encrypt-helper.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-helper.mjs +308 -1
- package/dist/common/encrypt/encrypt-helper.mjs.map +1 -1
- package/dist/common/encrypt/encrypt-types.d.mts +35 -8
- package/dist/common/encrypt/encrypt-types.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-types.mjs +12 -0
- package/dist/common/encrypt/encrypt-types.mjs.map +1 -1
- package/dist/common/secret/secret-helper.d.mts.map +1 -1
- package/dist/common/secret/secret-helper.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/encrypt/encrypt-constants.mts +10 -0
- package/src/common/encrypt/encrypt-helper.mts +345 -0
- package/src/common/encrypt/encrypt-types.mts +38 -10
- package/src/common/secret/secret-helper.mts +0 -2
|
@@ -11,6 +11,14 @@ export declare const MAX_ENCRYPTION_PASSWORD_LENGTH = 9999999;
|
|
|
11
11
|
export declare const DEFAULT_ENCRYPTION_SALT_STRATEGY: SaltStrategy;
|
|
12
12
|
export declare const DEFAULT_ENCRYPTION_RECURSIONS_PER_HASH = 10;
|
|
13
13
|
export declare const DEFAULT_ENCRYPTION_HASH_ALGORITHM = "SHA-256";
|
|
14
|
+
/**
|
|
15
|
+
* atom at the start of encryption ibgibs' `ib`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ENCRYPTION_ATOM = "encryption";
|
|
18
|
+
/**
|
|
19
|
+
* default regexp for a simple name string.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ENCRYPTION_NAME_REGEXP: RegExp;
|
|
14
22
|
/**
|
|
15
23
|
* An encryptions ibgib uses this rel8n name for its children encryptions.
|
|
16
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-constants.d.mts","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,eAAO,MAAM,qCAAqC,QAAQ,CAAC;AAC3D,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,iCAAiC,WAAW,CAAC;AAC1D,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD,eAAO,MAAM,kCAAkC,OAAO,CAAC;AACvD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAChD,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAChD,eAAO,MAAM,8BAA8B,UAAU,CAAC;AACtD,eAAO,MAAM,gCAAgC,EAAE,YAAyC,CAAC;AACzF,eAAO,MAAM,sCAAsC,KAAK,CAAC;AACzD,eAAO,MAAM,iCAAiC,YAAY,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"encrypt-constants.d.mts","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,eAAO,MAAM,qCAAqC,QAAQ,CAAC;AAC3D,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,iCAAiC,WAAW,CAAC;AAC1D,eAAO,MAAM,kCAAkC,IAAI,CAAC;AACpD,eAAO,MAAM,kCAAkC,OAAO,CAAC;AACvD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAChD,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAChD,eAAO,MAAM,8BAA8B,UAAU,CAAC;AACtD,eAAO,MAAM,gCAAgC,EAAE,YAAyC,CAAC;AACzF,eAAO,MAAM,sCAAsC,KAAK,CAAC;AACzD,eAAO,MAAM,iCAAiC,YAAY,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe,eAAe,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAA6B,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC"}
|
|
@@ -11,6 +11,14 @@ export const MAX_ENCRYPTION_PASSWORD_LENGTH = 9999999;
|
|
|
11
11
|
export const DEFAULT_ENCRYPTION_SALT_STRATEGY = SaltStrategy.appendPerHash;
|
|
12
12
|
export const DEFAULT_ENCRYPTION_RECURSIONS_PER_HASH = 10;
|
|
13
13
|
export const DEFAULT_ENCRYPTION_HASH_ALGORITHM = 'SHA-256';
|
|
14
|
+
/**
|
|
15
|
+
* atom at the start of encryption ibgibs' `ib`.
|
|
16
|
+
*/
|
|
17
|
+
export const ENCRYPTION_ATOM = 'encryption';
|
|
18
|
+
/**
|
|
19
|
+
* default regexp for a simple name string.
|
|
20
|
+
*/
|
|
21
|
+
export const ENCRYPTION_NAME_REGEXP = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
14
22
|
/**
|
|
15
23
|
* An encryptions ibgib uses this rel8n name for its children encryptions.
|
|
16
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-constants.mjs","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-constants.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC;AAC3D,MAAM,C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G,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAC;AACtD,MAAM,CAAC,MAAM,gCAAgC,GAAiB,YAAY,CAAC,aAAa,CAAC;AACzF,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,CAAC;AACzD,MAAM,CAAC,MAAM,iCAAiC,GAAG,SAAS,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAClD;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC"}
|
|
@@ -1,2 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module encrypt helper/util/etc. functions
|
|
3
|
+
*
|
|
4
|
+
* this is where you will find helper functions like those that generate
|
|
5
|
+
* and parse ibs for encryption ibgibs.
|
|
6
|
+
*/
|
|
7
|
+
import { Ib } from '@ibgib/ts-gib/dist/types.mjs';
|
|
8
|
+
import { EncryptionData_V1, EncryptionIbGib_V1, EncryptionInfo, EncryptionMethod } from './encrypt-types.mjs';
|
|
9
|
+
import { MetaspaceService } from "../../witness/space/metaspace/metaspace-types.mjs";
|
|
10
|
+
import { IbGibSpaceAny } from "../../witness/space/space-base-v1.mjs";
|
|
11
|
+
export declare function validateCommonEncryptionData({ data, }: {
|
|
12
|
+
data?: EncryptionData_V1;
|
|
13
|
+
}): string[];
|
|
14
|
+
export declare function validateCommonEncryptionIbGib({ ibGib, }: {
|
|
15
|
+
ibGib: EncryptionIbGib_V1;
|
|
16
|
+
}): Promise<string[] | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* builds the ib based on data.
|
|
19
|
+
*
|
|
20
|
+
* atow (02/2024) this is only data.name and data.method.
|
|
21
|
+
*
|
|
22
|
+
* @returns `${ENCRYPTION_ATOM} ${method} ${name}` atow (02/2024)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getEncryptionIb({ data, }: {
|
|
25
|
+
data: EncryptionData_V1;
|
|
26
|
+
}): Ib;
|
|
27
|
+
/**
|
|
28
|
+
* Current schema is `${ENCRYPTION_ATOM} ${method} ${name}`
|
|
29
|
+
*
|
|
30
|
+
* NOTE this is space-delimited
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseEncryptionIb({ ib, }: {
|
|
33
|
+
ib: Ib;
|
|
34
|
+
}): {
|
|
35
|
+
atom: string;
|
|
36
|
+
method: string;
|
|
37
|
+
name: string;
|
|
38
|
+
};
|
|
39
|
+
export declare function createAndRegisterNewEncryption({ encryptionMethod, encryptionInfo, metaspace, space, }: {
|
|
40
|
+
encryptionMethod: EncryptionMethod;
|
|
41
|
+
encryptionInfo: EncryptionInfo;
|
|
42
|
+
metaspace: MetaspaceService;
|
|
43
|
+
space: IbGibSpaceAny;
|
|
44
|
+
}): Promise<EncryptionIbGib_V1>;
|
|
2
45
|
//# sourceMappingURL=encrypt-helper.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-helper.d.mts","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-helper.mts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"encrypt-helper.d.mts","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,EAAE,EAAE,EAAG,MAAM,8BAA8B,CAAC;AAKnD,OAAO,EACH,iBAAiB,EAAE,kBAAkB,EACrC,cAAc,EAA6B,gBAAgB,EAE9D,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAStE,wBAAgB,4BAA4B,CAAC,EACzC,IAAI,GACP,EAAE;IACC,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC5B,GAAG,MAAM,EAAE,CAgDX;AAiED,wBAAsB,6BAA6B,CAAC,EAChD,KAAK,GACR,EAAE;IACC,KAAK,EAAE,kBAAkB,CAAC;CAC7B,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA+BhC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAC5B,IAAI,GACP,EAAE;IACC,IAAI,EAAE,iBAAiB,CAAC;CAC3B,GAAG,EAAE,CAaL;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAC9B,EAAE,GACL,EAAE;IACC,EAAE,EAAE,EAAE,CAAC;CACV,GAAG;IACA,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CAChB,CAkBA;AAGD,wBAAsB,8BAA8B,CAAC,EACjD,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,KAAK,GACR,EAAE;IACC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,KAAK,EAAE,aAAa,CAAC;CACxB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsB9B"}
|
|
@@ -1,2 +1,309 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module encrypt helper/util/etc. functions
|
|
3
|
+
*
|
|
4
|
+
* this is where you will find helper functions like those that generate
|
|
5
|
+
* and parse ibs for encryption ibgibs.
|
|
6
|
+
*/
|
|
7
|
+
// import * as pathUtils from 'path';
|
|
8
|
+
// import { statSync } from 'node:fs';
|
|
9
|
+
// import { readFile, } from 'node:fs/promises';
|
|
10
|
+
// import * as readline from 'node:readline/promises';
|
|
11
|
+
// import { stdin, stdout } from 'node:process'; // decide if use this or not
|
|
12
|
+
import { extractErrorMsg, } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
13
|
+
import { CLASSNAME_REGEXP, UUID_REGEXP, } from '@ibgib/helper-gib/dist/constants.mjs';
|
|
14
|
+
import { HASH_ALGORITHMS, SALT_STRATEGIES } from '@ibgib/encrypt-gib/dist/types.mjs';
|
|
15
|
+
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
16
|
+
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
17
|
+
import { GLOBAL_LOG_A_LOT } from "../../core-constants.mjs";
|
|
18
|
+
import { EncryptionMethod, VALID_ENCRYPTION_METHODS, } from './encrypt-types.mjs';
|
|
19
|
+
import { ENCRYPTION_REL8N_NAME, ENCRYPTION_ATOM, ENCRYPTION_NAME_REGEXP, } from './encrypt-constants.mjs';
|
|
20
|
+
import { SpecialIbGibType } from '../other/other-types.mjs';
|
|
21
|
+
/**
|
|
22
|
+
* for verbose logging
|
|
23
|
+
*/
|
|
24
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
25
|
+
export function validateCommonEncryptionData({ data, }) {
|
|
26
|
+
const lc = `[${validateCommonEncryptionData.name}]`;
|
|
27
|
+
try {
|
|
28
|
+
if (logalot) {
|
|
29
|
+
console.log(`${lc} starting...`);
|
|
30
|
+
}
|
|
31
|
+
if (!data) {
|
|
32
|
+
throw new Error(`data required (E: )`);
|
|
33
|
+
}
|
|
34
|
+
const errors = [];
|
|
35
|
+
const { name, uuid, classname, method, } = data;
|
|
36
|
+
if (name) {
|
|
37
|
+
if (!name.match(ENCRYPTION_NAME_REGEXP)) {
|
|
38
|
+
errors.push(`name must match regexp: ${ENCRYPTION_NAME_REGEXP} (E: )`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
errors.push(`name required. (E: )`);
|
|
43
|
+
}
|
|
44
|
+
if (method) {
|
|
45
|
+
if (!VALID_ENCRYPTION_METHODS.includes(method)) {
|
|
46
|
+
errors.push(`method (${method}) is invalid. must be one of ${VALID_ENCRYPTION_METHODS.join(', ')} (E: )`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
errors.push(`method required. (E: )`);
|
|
51
|
+
}
|
|
52
|
+
if (uuid) {
|
|
53
|
+
if (!uuid.match(UUID_REGEXP)) {
|
|
54
|
+
errors.push(`uuid must match regexp: ${UUID_REGEXP} (E: )`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (classname) {
|
|
58
|
+
if (!classname.match(CLASSNAME_REGEXP)) {
|
|
59
|
+
errors.push(`classname must match regexp: ${CLASSNAME_REGEXP} (E: )`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (method === EncryptionMethod.encrypt_gib_weak) {
|
|
63
|
+
const encryptGibErrors = validateCommonEncryptionData_encryptGib({ data });
|
|
64
|
+
encryptGibErrors.forEach(x => errors.push(x));
|
|
65
|
+
}
|
|
66
|
+
return errors;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
if (logalot) {
|
|
74
|
+
console.log(`${lc} complete.`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function validateCommonEncryptionData_encryptGib({ data, }) {
|
|
79
|
+
const lc = `[${validateCommonEncryptionData_encryptGib.name}]`;
|
|
80
|
+
try {
|
|
81
|
+
if (logalot) {
|
|
82
|
+
console.log(`${lc} starting... (I: 2da8272bd687b2c488a4af0c592b1524)`);
|
|
83
|
+
}
|
|
84
|
+
const errors = [];
|
|
85
|
+
if (data.encryptedDataDelimiter) {
|
|
86
|
+
if (typeof data.encryptedDataDelimiter !== 'string') {
|
|
87
|
+
errors.push(`encryptedDataDelimiter must be string (E: fcd4f6b27a084b219244cfbab641f840)`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (data.hashAlgorithm) {
|
|
91
|
+
if (!HASH_ALGORITHMS.includes(data.hashAlgorithm)) {
|
|
92
|
+
errors.push(`invalid hashAlgorithm (${data.hashAlgorithm}). must be one of ${HASH_ALGORITHMS}. (E: 5f7a75b2d1164e07b10a78adc155774a)`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (data.initialRecursions) {
|
|
96
|
+
if (typeof data.initialRecursions !== 'number') {
|
|
97
|
+
errors.push(`invalid initialRecursions (${data.initialRecursions}, typeof: ${typeof data.initialRecursions}). must be type "number" (E: 03c3f5fae9fe48bf92bb82ec806fa293)`);
|
|
98
|
+
}
|
|
99
|
+
else if (data.initialRecursions < 0) {
|
|
100
|
+
errors.push(`invalid dataRecursions (${data.initialRecursions}). must be positive integer or 0. (E: a12658e792c8448a9b31d8e0b001a1b2)`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
errors.push(`initialRecursions required. (E: bb14b31042074f9aad4ed8fc08846c62)`);
|
|
105
|
+
}
|
|
106
|
+
if (data.recursionsPerHash) {
|
|
107
|
+
if (typeof data.recursionsPerHash !== 'number') {
|
|
108
|
+
errors.push(`invalid recursionsPerHash (${data.recursionsPerHash}, typeof: ${typeof data.recursionsPerHash}). must be type "number" (E: b373d88bf22043408c1da42df9902211)`);
|
|
109
|
+
}
|
|
110
|
+
else if (data.recursionsPerHash <= 0) {
|
|
111
|
+
errors.push(`invalid recursionsPerHash (${data.recursionsPerHash}). must be positive integer. (E: 7eec3ccd22ed4bbf96c06479e2de02b7)`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (data.salt) {
|
|
115
|
+
if (typeof data.salt !== 'string') {
|
|
116
|
+
errors.push(`invalid salt (${data.salt}, typeof: ${typeof data.salt}). must be "string". (E: 0bee1f049dfd4f6e937cd423bb1b0c90)`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
errors.push(`salt required. (E: 7ee8e2a760184999b13e7966a8057b2b)`);
|
|
121
|
+
}
|
|
122
|
+
if (data.saltStrategy) {
|
|
123
|
+
if (!SALT_STRATEGIES.includes(data.saltStrategy)) {
|
|
124
|
+
errors.push(`invalid saltStrategy (${data.saltStrategy}). must be one of ${SALT_STRATEGIES}. (E: 7da81150e5144c448876e950e373e7e5)`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return errors;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
if (logalot) {
|
|
135
|
+
console.log(`${lc} complete.`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export async function validateCommonEncryptionIbGib({ ibGib, }) {
|
|
140
|
+
const lc = `[${validateCommonEncryptionIbGib.name}]`;
|
|
141
|
+
try {
|
|
142
|
+
if (logalot) {
|
|
143
|
+
console.log(`${lc} starting... (I: )`);
|
|
144
|
+
}
|
|
145
|
+
const intrinsicErrors = await validateIbGibIntrinsically({ ibGib: ibGib }) ?? [];
|
|
146
|
+
if (!ibGib.data) {
|
|
147
|
+
throw new Error(`EncryptionIbGib.data required (E: )`);
|
|
148
|
+
}
|
|
149
|
+
const ibErrors = [];
|
|
150
|
+
// ib
|
|
151
|
+
let { atom, method, name, } = parseEncryptionIb({ ib: ibGib.ib });
|
|
152
|
+
if (atom !== ENCRYPTION_ATOM) {
|
|
153
|
+
ibErrors.push(`invalid encryption atom. must be ${ENCRYPTION_ATOM} (E: )`);
|
|
154
|
+
}
|
|
155
|
+
if (!method) {
|
|
156
|
+
ibErrors.push(`encryption method required (E: )`);
|
|
157
|
+
}
|
|
158
|
+
if (!name) {
|
|
159
|
+
ibErrors.push(`encryption name required (E: )`);
|
|
160
|
+
}
|
|
161
|
+
// data
|
|
162
|
+
const dataErrors = validateCommonEncryptionData({ data: ibGib.data });
|
|
163
|
+
let result = [...(intrinsicErrors ?? []), ...(ibErrors ?? []), ...(dataErrors ?? [])];
|
|
164
|
+
if (result.length > 0) {
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
if (logalot) {
|
|
177
|
+
console.log(`${lc} complete.`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* builds the ib based on data.
|
|
183
|
+
*
|
|
184
|
+
* atow (02/2024) this is only data.name and data.method.
|
|
185
|
+
*
|
|
186
|
+
* @returns `${ENCRYPTION_ATOM} ${method} ${name}` atow (02/2024)
|
|
187
|
+
*/
|
|
188
|
+
export function getEncryptionIb({ data, }) {
|
|
189
|
+
const lc = `[${getEncryptionIb.name}]`;
|
|
190
|
+
try {
|
|
191
|
+
const validationErrors = validateCommonEncryptionData({ data });
|
|
192
|
+
if (validationErrors.length > 0) {
|
|
193
|
+
throw new Error(`invalid Encryption data: ${validationErrors} (E: )`);
|
|
194
|
+
}
|
|
195
|
+
const { name, method } = data;
|
|
196
|
+
return `${ENCRYPTION_ATOM} ${method} ${name}`;
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Current schema is `${ENCRYPTION_ATOM} ${method} ${name}`
|
|
205
|
+
*
|
|
206
|
+
* NOTE this is space-delimited
|
|
207
|
+
*/
|
|
208
|
+
export function parseEncryptionIb({ ib, }) {
|
|
209
|
+
const lc = `[${parseEncryptionIb.name}]`;
|
|
210
|
+
try {
|
|
211
|
+
if (!ib) {
|
|
212
|
+
throw new Error(`Encryption ib required (E: )`);
|
|
213
|
+
}
|
|
214
|
+
const [atom, method, name] = ib.split(' ');
|
|
215
|
+
if (atom !== ENCRYPTION_ATOM) {
|
|
216
|
+
throw new Error(`atom !== ${ENCRYPTION_ATOM} (E: )`);
|
|
217
|
+
}
|
|
218
|
+
if (method !== EncryptionMethod.encrypt_gib_weak) {
|
|
219
|
+
console.warn(`${lc} method !== EncryptionMethod.encrypt_gib_weak. atow (02/2024) .ncrypt_gib_weak is the only thing we got. (W: )`);
|
|
220
|
+
}
|
|
221
|
+
if (!name.match(ENCRYPTION_NAME_REGEXP)) {
|
|
222
|
+
throw new Error(`!name.match(ENCRYPTION_NAME_REGEXP) (E: )`);
|
|
223
|
+
}
|
|
224
|
+
return { atom, method, name, };
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
228
|
+
throw error;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export async function createAndRegisterNewEncryption({ encryptionMethod, encryptionInfo, metaspace, space, }) {
|
|
232
|
+
const lc = `[${createAndRegisterNewEncryption.name}]`;
|
|
233
|
+
try {
|
|
234
|
+
if (logalot) {
|
|
235
|
+
console.log(`${lc} starting... (I: )`);
|
|
236
|
+
}
|
|
237
|
+
let resEncryptionIbGib;
|
|
238
|
+
if (encryptionMethod !== EncryptionMethod.encrypt_gib_weak) {
|
|
239
|
+
throw new Error(`unknown encryptionMethod (${encryptionMethod}). only "encrypt-gib" encryption method currently implemented. (E: )`);
|
|
240
|
+
}
|
|
241
|
+
resEncryptionIbGib = await createAndRegisterNewEncryption_encryptGib({
|
|
242
|
+
encryptionInfo: encryptionInfo,
|
|
243
|
+
metaspace,
|
|
244
|
+
space,
|
|
245
|
+
});
|
|
246
|
+
return resEncryptionIbGib;
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
finally {
|
|
253
|
+
if (logalot) {
|
|
254
|
+
console.log(`${lc} complete.`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function createAndRegisterNewEncryption_encryptGib({ encryptionInfo, metaspace, space, }) {
|
|
259
|
+
const lc = `[${createAndRegisterNewEncryption_encryptGib.name}]`;
|
|
260
|
+
try {
|
|
261
|
+
if (logalot) {
|
|
262
|
+
console.log(`${lc} starting... (I: )`);
|
|
263
|
+
}
|
|
264
|
+
const { method: encryptionMethod } = encryptionInfo;
|
|
265
|
+
if (encryptionMethod !== 'encrypt-gib (weak)') {
|
|
266
|
+
throw new Error(`(UNEXPECTED) encryptionMethod !== 'encrypt-gib (weak)'? (E: )`);
|
|
267
|
+
}
|
|
268
|
+
// create the encryption ibgib
|
|
269
|
+
const data = {
|
|
270
|
+
...encryptionInfo,
|
|
271
|
+
};
|
|
272
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
273
|
+
ib: getEncryptionIb({ data }),
|
|
274
|
+
parentIbGib: Factory_V1.primitive({ ib: ENCRYPTION_ATOM }),
|
|
275
|
+
data,
|
|
276
|
+
dna: true,
|
|
277
|
+
nCounter: true,
|
|
278
|
+
tjp: { timestamp: true, },
|
|
279
|
+
});
|
|
280
|
+
const encryptionIbGib = resFirstGen.newIbGib;
|
|
281
|
+
// validate right away before anything else
|
|
282
|
+
const validationErrors = await validateCommonEncryptionIbGib({ ibGib: encryptionIbGib }) ?? [];
|
|
283
|
+
if (validationErrors.length > 0) {
|
|
284
|
+
throw new Error(`(UNEXPECTED) newly created encryptionIbGib has validationErrors? validationErrors: ${validationErrors} (E: )`);
|
|
285
|
+
}
|
|
286
|
+
// save first in the space...
|
|
287
|
+
await metaspace.persistTransformResult({ resTransform: resFirstGen, space });
|
|
288
|
+
// register the new encryption with the ibgib space in general...
|
|
289
|
+
await metaspace.registerNewIbGib({ ibGib: encryptionIbGib, space });
|
|
290
|
+
// register the new encryption with the encryptions index
|
|
291
|
+
await metaspace.rel8ToSpecialIbGib({
|
|
292
|
+
type: SpecialIbGibType.encryptions,
|
|
293
|
+
rel8nName: ENCRYPTION_REL8N_NAME,
|
|
294
|
+
ibGibsToRel8: [encryptionIbGib],
|
|
295
|
+
space,
|
|
296
|
+
});
|
|
297
|
+
return encryptionIbGib;
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
finally {
|
|
304
|
+
if (logalot) {
|
|
305
|
+
console.log(`${lc} complete.`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
2
309
|
//# sourceMappingURL=encrypt-helper.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-helper.mjs","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-helper.mts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"encrypt-helper.mjs","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,sCAAsC;AACtC,gDAAgD;AAChD,sDAAsD;AACtD,6EAA6E;AAE7E,OAAO,EACH,eAAe,GAElB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,WAAW,GAAG,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAErF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAEwC,gBAAgB,EAC3D,wBAAwB,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,sBAAsB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sBAAsB,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;QAE7E,iEAAiE;QACjE,MAAM,SAAS,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAC;QAEpE,yDAAyD;QACzD,MAAM,SAAS,CAAC,kBAAkB,CAAC;YAC/B,IAAI,EAAE,gBAAgB,CAAC,WAAW;YAClC,SAAS,EAAE,qBAAqB;YAChC,YAAY,EAAE,CAAC,eAAe,CAAC;YAC/B,KAAK;SACR,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAAC,CAAC;IACpD,CAAC;AACL,CAAC"}
|
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import { HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
-
import { IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
2
|
+
import { IbGibData_V1, IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
3
3
|
import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
4
4
|
import { SaltStrategy } from '@ibgib/encrypt-gib/dist/types.mjs';
|
|
5
5
|
import { ENCRYPTION_REL8N_NAME } from './encrypt-constants.mjs';
|
|
6
|
-
export interface EncryptionInfo {
|
|
7
|
-
name: string;
|
|
8
|
-
description?: string;
|
|
9
|
-
method: EncryptionMethod;
|
|
10
|
-
}
|
|
11
6
|
export type EncryptionMethod = 'encrypt-gib (weak)';
|
|
7
|
+
/**
|
|
8
|
+
* Discriminator for the algorithm used in encryption that specifies the
|
|
9
|
+
* algorithm used in encryption.
|
|
10
|
+
*
|
|
11
|
+
* The value of this will decide which descending encryption interface is used
|
|
12
|
+
* that specifies parameters specific to this method.
|
|
13
|
+
*/
|
|
12
14
|
export declare const EncryptionMethod: {
|
|
15
|
+
/**
|
|
16
|
+
* custom probably very weak algorithm that uses indexing into a recursive
|
|
17
|
+
* hash-based rounding function instead of keystream generation.
|
|
18
|
+
*/
|
|
13
19
|
encrypt_gib_weak: "encrypt-gib (weak)";
|
|
14
20
|
};
|
|
21
|
+
export declare const VALID_ENCRYPTION_METHODS: "encrypt-gib (weak)"[];
|
|
22
|
+
/**
|
|
23
|
+
* Encryption-specific information that will form the {@link EncryptionData_V1}
|
|
24
|
+
* shape. If you examine that interface, you'll see that it is this type
|
|
25
|
+
*/
|
|
15
26
|
export interface EncryptionInfo {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
/**
|
|
30
|
+
* @see {@link EncryptionMethod}
|
|
31
|
+
*/
|
|
16
32
|
method: EncryptionMethod;
|
|
17
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Parameter information that is specific to the encrypt-gib algorithm.
|
|
36
|
+
*/
|
|
18
37
|
export interface EncryptionInfo_EncryptGib extends EncryptionInfo {
|
|
19
38
|
method: 'encrypt-gib (weak)';
|
|
20
39
|
/**
|
|
@@ -52,11 +71,19 @@ export interface EncryptionInfo_EncryptGib extends EncryptionInfo {
|
|
|
52
71
|
*/
|
|
53
72
|
encryptedDataDelimiter?: string;
|
|
54
73
|
}
|
|
55
|
-
|
|
74
|
+
/**
|
|
75
|
+
* @see {@link EncryptionIbGib_V1}
|
|
76
|
+
*/
|
|
77
|
+
export type EncryptionData_V1 = IbGibData_V1 & EncryptionInfo & (EncryptionInfo_EncryptGib);
|
|
78
|
+
/**
|
|
79
|
+
* @see {@link EncryptionIbGib_V1}
|
|
80
|
+
*/
|
|
56
81
|
export interface EncryptionRel8ns_V1 extends IbGibRel8ns_V1 {
|
|
57
82
|
}
|
|
58
83
|
/**
|
|
59
|
-
* IbGib that represents encryption settings
|
|
84
|
+
* IbGib that represents encryption settings.
|
|
85
|
+
*
|
|
86
|
+
* This determines the {@link EncryptionMethod}
|
|
60
87
|
*/
|
|
61
88
|
export interface EncryptionIbGib_V1 extends IbGib_V1<EncryptionData_V1, EncryptionRel8ns_V1> {
|
|
62
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-types.d.mts","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-types.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"encrypt-types.d.mts","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-types.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAE,SAAS,EAAG,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACpD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;IACzB;;;OAGG;;CAEN,CAAA;AACD,eAAO,MAAM,wBAAwB,wBAAkC,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,cAAc;IAC7D,MAAM,EAAE,oBAAoB,CAAA;IAC5B;;;OAGG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,cAAc,GAAG,CAC5D,yBAAyB,CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,cAAc;CAAI;AAE/D;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,QAAQ,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;CAAI;AAEhG;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,SAAS,GAAG,GAAG;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD,CAAC,qBAAqB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,SAAS,GAAG,GAAG,CAC/C,SAAQ,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAChE"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { ENCRYPTION_REL8N_NAME } from './encrypt-constants.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Discriminator for the algorithm used in encryption that specifies the
|
|
4
|
+
* algorithm used in encryption.
|
|
5
|
+
*
|
|
6
|
+
* The value of this will decide which descending encryption interface is used
|
|
7
|
+
* that specifies parameters specific to this method.
|
|
8
|
+
*/
|
|
2
9
|
export const EncryptionMethod = {
|
|
10
|
+
/**
|
|
11
|
+
* custom probably very weak algorithm that uses indexing into a recursive
|
|
12
|
+
* hash-based rounding function instead of keystream generation.
|
|
13
|
+
*/
|
|
3
14
|
encrypt_gib_weak: 'encrypt-gib (weak)',
|
|
4
15
|
};
|
|
16
|
+
export const VALID_ENCRYPTION_METHODS = Object.values(EncryptionMethod);
|
|
5
17
|
//# sourceMappingURL=encrypt-types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encrypt-types.mjs","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-types.mts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"encrypt-types.mjs","sourceRoot":"","sources":["../../../src/common/encrypt/encrypt-types.mts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B;;;OAGG;IACH,gBAAgB,EAAE,oBAAwC;CAC7D,CAAA;AACD,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-helper.d.mts","sourceRoot":"","sources":["../../../src/common/secret/secret-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"secret-helper.d.mts","sourceRoot":"","sources":["../../../src/common/secret/secret-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAEmC,aAAa,EACtD,MAAM,iDAAiD,CAAC;AAGzD,OAAO,EAAE,EAAE,EAAG,MAAM,8BAA8B,CAAC;AAKnD,OAAO,EAAE,kCAAkC,EA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AEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,SAAS,EAAE,aAAa,CAAC;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAqD9C;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAAC,EAC1C,QAAQ,EACR,SAAS,GACZ,EAAE;IACC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,kCAAkC,CAAC;CACjD,GAAG,OAAO,CAAC,OAAO,CAAC,CAmBnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-helper.mjs","sourceRoot":"","sources":["../../../src/common/secret/secret-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"secret-helper.mjs","sourceRoot":"","sources":["../../../src/common/secret/secret-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,sCAAsC;AACtC,gDAAgD;AAChD,sDAAsD;AACtD,6EAA6E;AAE7E,OAAO,EACH,eAAe,GAElB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAe,gBAAgB,GAAG,MAAM,sCAAsC,CAAC;AAEtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAsG,UAAU,EAAE,kBAAkB,GAAG,MAAM,oBAAoB,CAAC;AACzK,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,GAAG,MAAM,wBAAwB,CAAC;AAI7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,GAAG,gBAAgB,CA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AC;QAAC,CAAC;IACpD,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,EAC1C,QAAQ,EACR,SAAS,GAIZ;IACG,MAAM,EAAE,GAAG,IAAI,uBAAuB,CAAC,IAAI,GAAG,CAAC;IAC/C,IAAI,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,oDAAoD,CAAC,CAAC;QAAC,CAAC;QACxF,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;QACjF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC;YAC7B,CAAC,EAAE,QAAQ;YACX,cAAc;YACd,oBAAoB;YACpB,SAAS;SACZ,CAAC,CAAC;QACH,MAAM,kBAAkB,GAAG,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACxD,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAAC,CAAC;IACpD,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibgib/core-gib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"description": "ibgib core functionality, including base architecture for witnesses, spaces, apps, robbots, etc., as well as shared utility functions. Node v19+ needed for heavily-used isomorphic webcrypto hashing consumed in both node and browsers.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://gitlab.com/ibgib/core-gib",
|
|
@@ -13,6 +13,16 @@ export const DEFAULT_ENCRYPTION_SALT_STRATEGY: SaltStrategy = SaltStrategy.appen
|
|
|
13
13
|
export const DEFAULT_ENCRYPTION_RECURSIONS_PER_HASH = 10;
|
|
14
14
|
export const DEFAULT_ENCRYPTION_HASH_ALGORITHM = 'SHA-256';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* atom at the start of encryption ibgibs' `ib`.
|
|
18
|
+
*/
|
|
19
|
+
export const ENCRYPTION_ATOM = 'encryption';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* default regexp for a simple name string.
|
|
23
|
+
*/
|
|
24
|
+
export const ENCRYPTION_NAME_REGEXP = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
27
|
* An encryptions ibgib uses this rel8n name for its children encryptions.
|
|
18
28
|
*/
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module encrypt helper/util/etc. functions
|
|
3
|
+
*
|
|
4
|
+
* this is where you will find helper functions like those that generate
|
|
5
|
+
* and parse ibs for encryption ibgibs.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// import * as pathUtils from 'path';
|
|
9
|
+
// import { statSync } from 'node:fs';
|
|
10
|
+
// import { readFile, } from 'node:fs/promises';
|
|
11
|
+
// import * as readline from 'node:readline/promises';
|
|
12
|
+
// import { stdin, stdout } from 'node:process'; // decide if use this or not
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
extractErrorMsg, delay, getSaferSubstring,
|
|
16
|
+
getTimestampInTicks, getUUID, pretty, HashAlgorithm, getTimestamp,
|
|
17
|
+
} from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
18
|
+
import { CLASSNAME_REGEXP, UUID_REGEXP, } from '@ibgib/helper-gib/dist/constants.mjs';
|
|
19
|
+
import { HASH_ALGORITHMS, SALT_STRATEGIES } from '@ibgib/encrypt-gib/dist/types.mjs';
|
|
20
|
+
import { Ib, } from '@ibgib/ts-gib/dist/types.mjs';
|
|
21
|
+
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
22
|
+
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
23
|
+
|
|
24
|
+
import { GLOBAL_LOG_A_LOT } from "../../core-constants.mjs";
|
|
25
|
+
import {
|
|
26
|
+
EncryptionData_V1, EncryptionIbGib_V1,
|
|
27
|
+
EncryptionInfo, EncryptionInfo_EncryptGib, EncryptionMethod,
|
|
28
|
+
VALID_ENCRYPTION_METHODS,
|
|
29
|
+
} from './encrypt-types.mjs';
|
|
30
|
+
import { ENCRYPTION_REL8N_NAME, ENCRYPTION_ATOM, ENCRYPTION_NAME_REGEXP, } from './encrypt-constants.mjs';
|
|
31
|
+
import { MetaspaceService } from "../../witness/space/metaspace/metaspace-types.mjs";
|
|
32
|
+
import { IbGibSpaceAny } from "../../witness/space/space-base-v1.mjs";
|
|
33
|
+
import { SpecialIbGibType } from '../other/other-types.mjs';
|
|
34
|
+
import { encrypt } from '@ibgib/encrypt-gib/dist/encrypt-decrypt.mjs';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* for verbose logging
|
|
38
|
+
*/
|
|
39
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
40
|
+
|
|
41
|
+
export function validateCommonEncryptionData({
|
|
42
|
+
data,
|
|
43
|
+
}: {
|
|
44
|
+
data?: EncryptionData_V1,
|
|
45
|
+
}): string[] {
|
|
46
|
+
const lc = `[${validateCommonEncryptionData.name}]`;
|
|
47
|
+
try {
|
|
48
|
+
if (logalot) { console.log(`${lc} starting...`); }
|
|
49
|
+
if (!data) { throw new Error(`data required (E: )`); }
|
|
50
|
+
const errors: string[] = [];
|
|
51
|
+
const { name, uuid, classname, method, } = data;
|
|
52
|
+
|
|
53
|
+
if (name) {
|
|
54
|
+
if (!name.match(ENCRYPTION_NAME_REGEXP)) {
|
|
55
|
+
errors.push(`name must match regexp: ${ENCRYPTION_NAME_REGEXP} (E: )`);
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
errors.push(`name required. (E: )`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (method) {
|
|
62
|
+
if (!VALID_ENCRYPTION_METHODS.includes(method)) {
|
|
63
|
+
errors.push(`method (${method}) is invalid. must be one of ${VALID_ENCRYPTION_METHODS.join(', ')} (E: )`);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
errors.push(`method required. (E: )`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (uuid) {
|
|
70
|
+
if (!uuid.match(UUID_REGEXP)) {
|
|
71
|
+
errors.push(`uuid must match regexp: ${UUID_REGEXP} (E: )`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (classname) {
|
|
76
|
+
if (!classname.match(CLASSNAME_REGEXP)) {
|
|
77
|
+
errors.push(`classname must match regexp: ${CLASSNAME_REGEXP} (E: )`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (method === EncryptionMethod.encrypt_gib_weak) {
|
|
82
|
+
const encryptGibErrors = validateCommonEncryptionData_encryptGib({ data });
|
|
83
|
+
encryptGibErrors.forEach(x => errors.push(x));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return errors;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
89
|
+
throw error;
|
|
90
|
+
} finally {
|
|
91
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function validateCommonEncryptionData_encryptGib({
|
|
96
|
+
data,
|
|
97
|
+
}: {
|
|
98
|
+
data: EncryptionData_V1,
|
|
99
|
+
}): string[] {
|
|
100
|
+
const lc = `[${validateCommonEncryptionData_encryptGib.name}]`;
|
|
101
|
+
try {
|
|
102
|
+
if (logalot) { console.log(`${lc} starting... (I: 2da8272bd687b2c488a4af0c592b1524)`); }
|
|
103
|
+
const errors: string[] = [];
|
|
104
|
+
|
|
105
|
+
if (data.encryptedDataDelimiter) {
|
|
106
|
+
if (typeof data.encryptedDataDelimiter !== 'string') {
|
|
107
|
+
errors.push(`encryptedDataDelimiter must be string (E: fcd4f6b27a084b219244cfbab641f840)`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (data.hashAlgorithm) {
|
|
112
|
+
if (!HASH_ALGORITHMS.includes(data.hashAlgorithm)) {
|
|
113
|
+
errors.push(`invalid hashAlgorithm (${data.hashAlgorithm}). must be one of ${HASH_ALGORITHMS}. (E: 5f7a75b2d1164e07b10a78adc155774a)`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (data.initialRecursions) {
|
|
118
|
+
if (typeof data.initialRecursions !== 'number') {
|
|
119
|
+
errors.push(`invalid initialRecursions (${data.initialRecursions}, typeof: ${typeof data.initialRecursions}). must be type "number" (E: 03c3f5fae9fe48bf92bb82ec806fa293)`);
|
|
120
|
+
} else if (data.initialRecursions < 0) {
|
|
121
|
+
errors.push(`invalid dataRecursions (${data.initialRecursions}). must be positive integer or 0. (E: a12658e792c8448a9b31d8e0b001a1b2)`);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
errors.push(`initialRecursions required. (E: bb14b31042074f9aad4ed8fc08846c62)`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (data.recursionsPerHash) {
|
|
128
|
+
if (typeof data.recursionsPerHash !== 'number') {
|
|
129
|
+
errors.push(`invalid recursionsPerHash (${data.recursionsPerHash}, typeof: ${typeof data.recursionsPerHash}). must be type "number" (E: b373d88bf22043408c1da42df9902211)`);
|
|
130
|
+
} else if (data.recursionsPerHash <= 0) {
|
|
131
|
+
errors.push(`invalid recursionsPerHash (${data.recursionsPerHash}). must be positive integer. (E: 7eec3ccd22ed4bbf96c06479e2de02b7)`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (data.salt) {
|
|
136
|
+
if (typeof data.salt !== 'string') {
|
|
137
|
+
errors.push(`invalid salt (${data.salt}, typeof: ${typeof data.salt}). must be "string". (E: 0bee1f049dfd4f6e937cd423bb1b0c90)`)
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
errors.push(`salt required. (E: 7ee8e2a760184999b13e7966a8057b2b)`)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (data.saltStrategy) {
|
|
144
|
+
if (!SALT_STRATEGIES.includes(data.saltStrategy)) {
|
|
145
|
+
errors.push(`invalid saltStrategy (${data.saltStrategy}). must be one of ${SALT_STRATEGIES}. (E: 7da81150e5144c448876e950e373e7e5)`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return errors;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
152
|
+
throw error;
|
|
153
|
+
} finally {
|
|
154
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export async function validateCommonEncryptionIbGib({
|
|
159
|
+
ibGib,
|
|
160
|
+
}: {
|
|
161
|
+
ibGib: EncryptionIbGib_V1,
|
|
162
|
+
}): Promise<string[] | undefined> {
|
|
163
|
+
const lc = `[${validateCommonEncryptionIbGib.name}]`;
|
|
164
|
+
try {
|
|
165
|
+
if (logalot) { console.log(`${lc} starting... (I: )`); }
|
|
166
|
+
const intrinsicErrors: string[] = await validateIbGibIntrinsically({ ibGib: ibGib }) ?? [];
|
|
167
|
+
|
|
168
|
+
if (!ibGib.data) { throw new Error(`EncryptionIbGib.data required (E: )`); }
|
|
169
|
+
const ibErrors: string[] = [];
|
|
170
|
+
|
|
171
|
+
// ib
|
|
172
|
+
let { atom, method, name, } =
|
|
173
|
+
parseEncryptionIb({ ib: ibGib.ib });
|
|
174
|
+
if (atom !== ENCRYPTION_ATOM) { ibErrors.push(`invalid encryption atom. must be ${ENCRYPTION_ATOM} (E: )`); }
|
|
175
|
+
if (!method) { ibErrors.push(`encryption method required (E: )`); }
|
|
176
|
+
if (!name) { ibErrors.push(`encryption name required (E: )`); }
|
|
177
|
+
|
|
178
|
+
// data
|
|
179
|
+
const dataErrors = validateCommonEncryptionData({ data: ibGib.data });
|
|
180
|
+
|
|
181
|
+
let result = [...(intrinsicErrors ?? []), ...(ibErrors ?? []), ...(dataErrors ?? [])];
|
|
182
|
+
if (result.length > 0) {
|
|
183
|
+
return result;
|
|
184
|
+
} else {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
} catch (error) {
|
|
188
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
189
|
+
throw error;
|
|
190
|
+
} finally {
|
|
191
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* builds the ib based on data.
|
|
197
|
+
*
|
|
198
|
+
* atow (02/2024) this is only data.name and data.method.
|
|
199
|
+
*
|
|
200
|
+
* @returns `${ENCRYPTION_ATOM} ${method} ${name}` atow (02/2024)
|
|
201
|
+
*/
|
|
202
|
+
export function getEncryptionIb({
|
|
203
|
+
data,
|
|
204
|
+
}: {
|
|
205
|
+
data: EncryptionData_V1,
|
|
206
|
+
}): Ib {
|
|
207
|
+
const lc = `[${getEncryptionIb.name}]`;
|
|
208
|
+
try {
|
|
209
|
+
const validationErrors = validateCommonEncryptionData({ data });
|
|
210
|
+
if (validationErrors.length > 0) { throw new Error(`invalid Encryption data: ${validationErrors} (E: )`); }
|
|
211
|
+
|
|
212
|
+
const { name, method } = data;
|
|
213
|
+
|
|
214
|
+
return `${ENCRYPTION_ATOM} ${method} ${name}`;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Current schema is `${ENCRYPTION_ATOM} ${method} ${name}`
|
|
223
|
+
*
|
|
224
|
+
* NOTE this is space-delimited
|
|
225
|
+
*/
|
|
226
|
+
export function parseEncryptionIb({
|
|
227
|
+
ib,
|
|
228
|
+
}: {
|
|
229
|
+
ib: Ib,
|
|
230
|
+
}): {
|
|
231
|
+
atom: string,
|
|
232
|
+
method: string,
|
|
233
|
+
name: string,
|
|
234
|
+
} {
|
|
235
|
+
const lc = `[${parseEncryptionIb.name}]`;
|
|
236
|
+
try {
|
|
237
|
+
if (!ib) { throw new Error(`Encryption ib required (E: )`); }
|
|
238
|
+
|
|
239
|
+
const [atom, method, name] = ib.split(' ');
|
|
240
|
+
|
|
241
|
+
if (atom !== ENCRYPTION_ATOM) { throw new Error(`atom !== ${ENCRYPTION_ATOM} (E: )`); }
|
|
242
|
+
|
|
243
|
+
if (method !== EncryptionMethod.encrypt_gib_weak) { console.warn(`${lc} method !== EncryptionMethod.encrypt_gib_weak. atow (02/2024) .ncrypt_gib_weak is the only thing we got. (W: )`) }
|
|
244
|
+
|
|
245
|
+
if (!name.match(ENCRYPTION_NAME_REGEXP)) { throw new Error(`!name.match(ENCRYPTION_NAME_REGEXP) (E: )`); }
|
|
246
|
+
|
|
247
|
+
return { atom, method, name, };
|
|
248
|
+
} catch (error) {
|
|
249
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
export async function createAndRegisterNewEncryption({
|
|
256
|
+
encryptionMethod,
|
|
257
|
+
encryptionInfo,
|
|
258
|
+
metaspace,
|
|
259
|
+
space,
|
|
260
|
+
}: {
|
|
261
|
+
encryptionMethod: EncryptionMethod,
|
|
262
|
+
encryptionInfo: EncryptionInfo,
|
|
263
|
+
metaspace: MetaspaceService,
|
|
264
|
+
space: IbGibSpaceAny,
|
|
265
|
+
}): Promise<EncryptionIbGib_V1> {
|
|
266
|
+
const lc = `[${createAndRegisterNewEncryption.name}]`;
|
|
267
|
+
try {
|
|
268
|
+
if (logalot) { console.log(`${lc} starting... (I: )`); }
|
|
269
|
+
|
|
270
|
+
let resEncryptionIbGib: EncryptionIbGib_V1;
|
|
271
|
+
|
|
272
|
+
if (encryptionMethod !== EncryptionMethod.encrypt_gib_weak) { throw new Error(`unknown encryptionMethod (${encryptionMethod}). only "encrypt-gib" encryption method currently implemented. (E: )`); }
|
|
273
|
+
|
|
274
|
+
resEncryptionIbGib = await createAndRegisterNewEncryption_encryptGib({
|
|
275
|
+
encryptionInfo: encryptionInfo as EncryptionInfo_EncryptGib,
|
|
276
|
+
metaspace,
|
|
277
|
+
space,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
return resEncryptionIbGib;
|
|
281
|
+
} catch (error) {
|
|
282
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
283
|
+
throw error;
|
|
284
|
+
} finally {
|
|
285
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async function createAndRegisterNewEncryption_encryptGib({
|
|
290
|
+
encryptionInfo,
|
|
291
|
+
metaspace,
|
|
292
|
+
space,
|
|
293
|
+
}: {
|
|
294
|
+
encryptionInfo: EncryptionInfo_EncryptGib,
|
|
295
|
+
metaspace: MetaspaceService,
|
|
296
|
+
space: IbGibSpaceAny,
|
|
297
|
+
}): Promise<EncryptionIbGib_V1> {
|
|
298
|
+
const lc = `[${createAndRegisterNewEncryption_encryptGib.name}]`;
|
|
299
|
+
try {
|
|
300
|
+
if (logalot) { console.log(`${lc} starting... (I: )`); }
|
|
301
|
+
|
|
302
|
+
const { method: encryptionMethod } = encryptionInfo;
|
|
303
|
+
if (encryptionMethod !== 'encrypt-gib (weak)') { throw new Error(`(UNEXPECTED) encryptionMethod !== 'encrypt-gib (weak)'? (E: )`); }
|
|
304
|
+
|
|
305
|
+
// create the encryption ibgib
|
|
306
|
+
const data: EncryptionData_V1 = {
|
|
307
|
+
...encryptionInfo,
|
|
308
|
+
};
|
|
309
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
310
|
+
ib: getEncryptionIb({ data }),
|
|
311
|
+
parentIbGib: Factory_V1.primitive({ ib: ENCRYPTION_ATOM }),
|
|
312
|
+
data,
|
|
313
|
+
dna: true,
|
|
314
|
+
nCounter: true,
|
|
315
|
+
tjp: { timestamp: true, },
|
|
316
|
+
});
|
|
317
|
+
const encryptionIbGib = resFirstGen.newIbGib as EncryptionIbGib_V1;
|
|
318
|
+
|
|
319
|
+
// validate right away before anything else
|
|
320
|
+
const validationErrors =
|
|
321
|
+
await validateCommonEncryptionIbGib({ ibGib: encryptionIbGib }) ?? [];
|
|
322
|
+
if (validationErrors.length > 0) { throw new Error(`(UNEXPECTED) newly created encryptionIbGib has validationErrors? validationErrors: ${validationErrors} (E: )`); }
|
|
323
|
+
|
|
324
|
+
// save first in the space...
|
|
325
|
+
await metaspace.persistTransformResult({ resTransform: resFirstGen, space });
|
|
326
|
+
|
|
327
|
+
// register the new encryption with the ibgib space in general...
|
|
328
|
+
await metaspace.registerNewIbGib({ ibGib: encryptionIbGib, space });
|
|
329
|
+
|
|
330
|
+
// register the new encryption with the encryptions index
|
|
331
|
+
await metaspace.rel8ToSpecialIbGib({
|
|
332
|
+
type: SpecialIbGibType.encryptions,
|
|
333
|
+
rel8nName: ENCRYPTION_REL8N_NAME,
|
|
334
|
+
ibGibsToRel8: [encryptionIbGib],
|
|
335
|
+
space,
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
return encryptionIbGib;
|
|
339
|
+
} catch (error) {
|
|
340
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
341
|
+
throw error;
|
|
342
|
+
} finally {
|
|
343
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
344
|
+
}
|
|
345
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
-
import { IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
2
|
+
import { IbGibData_V1, IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
3
3
|
import { IbGibAddr, } from '@ibgib/ts-gib/dist/types.mjs';
|
|
4
4
|
import { SaltStrategy } from '@ibgib/encrypt-gib/dist/types.mjs';
|
|
5
5
|
|
|
@@ -7,21 +7,39 @@ import { ENCRYPTION_REL8N_NAME } from './encrypt-constants.mjs';
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
export interface EncryptionInfo {
|
|
11
|
-
name: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
method: EncryptionMethod;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
10
|
export type EncryptionMethod = 'encrypt-gib (weak)';
|
|
11
|
+
/**
|
|
12
|
+
* Discriminator for the algorithm used in encryption that specifies the
|
|
13
|
+
* algorithm used in encryption.
|
|
14
|
+
*
|
|
15
|
+
* The value of this will decide which descending encryption interface is used
|
|
16
|
+
* that specifies parameters specific to this method.
|
|
17
|
+
*/
|
|
17
18
|
export const EncryptionMethod = {
|
|
19
|
+
/**
|
|
20
|
+
* custom probably very weak algorithm that uses indexing into a recursive
|
|
21
|
+
* hash-based rounding function instead of keystream generation.
|
|
22
|
+
*/
|
|
18
23
|
encrypt_gib_weak: 'encrypt-gib (weak)' as EncryptionMethod,
|
|
19
24
|
}
|
|
25
|
+
export const VALID_ENCRYPTION_METHODS = Object.values(EncryptionMethod);
|
|
20
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Encryption-specific information that will form the {@link EncryptionData_V1}
|
|
29
|
+
* shape. If you examine that interface, you'll see that it is this type
|
|
30
|
+
*/
|
|
21
31
|
export interface EncryptionInfo {
|
|
22
|
-
|
|
32
|
+
name: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
/**
|
|
35
|
+
* @see {@link EncryptionMethod}
|
|
36
|
+
*/
|
|
37
|
+
method: EncryptionMethod;
|
|
23
38
|
}
|
|
24
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Parameter information that is specific to the encrypt-gib algorithm.
|
|
42
|
+
*/
|
|
25
43
|
export interface EncryptionInfo_EncryptGib extends EncryptionInfo {
|
|
26
44
|
method: 'encrypt-gib (weak)'
|
|
27
45
|
/**
|
|
@@ -60,12 +78,22 @@ export interface EncryptionInfo_EncryptGib extends EncryptionInfo {
|
|
|
60
78
|
encryptedDataDelimiter?: string;
|
|
61
79
|
}
|
|
62
80
|
|
|
63
|
-
|
|
81
|
+
/**
|
|
82
|
+
* @see {@link EncryptionIbGib_V1}
|
|
83
|
+
*/
|
|
84
|
+
export type EncryptionData_V1 = IbGibData_V1 & EncryptionInfo & (
|
|
85
|
+
EncryptionInfo_EncryptGib // extends this with logical OR of subtypes
|
|
86
|
+
);
|
|
64
87
|
|
|
88
|
+
/**
|
|
89
|
+
* @see {@link EncryptionIbGib_V1}
|
|
90
|
+
*/
|
|
65
91
|
export interface EncryptionRel8ns_V1 extends IbGibRel8ns_V1 { }
|
|
66
92
|
|
|
67
93
|
/**
|
|
68
|
-
* IbGib that represents encryption settings
|
|
94
|
+
* IbGib that represents encryption settings.
|
|
95
|
+
*
|
|
96
|
+
* This determines the {@link EncryptionMethod}
|
|
69
97
|
*/
|
|
70
98
|
export interface EncryptionIbGib_V1 extends IbGib_V1<EncryptionData_V1, EncryptionRel8ns_V1> { }
|
|
71
99
|
|