@ibgib/core-gib 0.0.49 → 0.0.50
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 +0 -4
- package/dist/common/encrypt/encrypt-constants.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-constants.mjs +0 -4
- package/dist/common/encrypt/encrypt-constants.mjs.map +1 -1
- package/dist/common/encrypt/encrypt-helper.d.mts +2 -0
- package/dist/common/encrypt/encrypt-helper.d.mts.map +1 -0
- package/dist/common/encrypt/encrypt-helper.mjs +2 -0
- package/dist/common/encrypt/encrypt-helper.mjs.map +1 -0
- package/dist/common/encrypt/encrypt-types.d.mts +0 -34
- package/dist/common/encrypt/encrypt-types.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-types.mjs +0 -4
- package/dist/common/encrypt/encrypt-types.mjs.map +1 -1
- package/dist/common/other/ibgib-helper.d.mts +15 -1
- package/dist/common/other/ibgib-helper.d.mts.map +1 -1
- package/dist/common/other/ibgib-helper.mjs +17 -4
- package/dist/common/other/ibgib-helper.mjs.map +1 -1
- package/dist/common/secret/secret-constants.d.mts +30 -0
- package/dist/common/secret/secret-constants.d.mts.map +1 -0
- package/dist/common/secret/secret-constants.mjs +42 -0
- package/dist/common/secret/secret-constants.mjs.map +1 -0
- package/dist/common/secret/secret-helper.d.mts +85 -0
- package/dist/common/secret/secret-helper.d.mts.map +1 -0
- package/dist/common/secret/secret-helper.mjs +358 -0
- package/dist/common/secret/secret-helper.mjs.map +1 -0
- package/dist/common/secret/secret-types.d.mts +192 -0
- package/dist/common/secret/secret-types.d.mts.map +1 -0
- package/dist/common/secret/secret-types.mjs +8 -0
- package/dist/common/secret/secret-types.mjs.map +1 -0
- package/dist/common/secret/secret.respec.d.mts +7 -0
- package/dist/common/secret/secret.respec.d.mts.map +1 -0
- package/dist/common/secret/secret.respec.mjs +160 -0
- package/dist/common/secret/secret.respec.mjs.map +1 -0
- package/dist/witness/space/metaspace/metaspace-base.d.mts +2 -1
- package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.mjs +24 -18
- package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -1
- package/dist/witness/space/metaspace/metaspace-types.d.mts +2 -1
- package/dist/witness/space/metaspace/metaspace-types.d.mts.map +1 -1
- package/package.json +3 -3
- package/src/common/other/ibgib-helper.mts +28 -3
- package/src/common/secret/secret-constants.mts +13 -0
- package/src/common/secret/secret-helper.mts +211 -54
- package/src/common/secret/secret-types.mts +138 -8
- package/src/common/secret/secret.respec.mts +144 -5
- package/src/witness/space/metaspace/metaspace-base.mts +3 -2
- package/src/witness/space/metaspace/metaspace-types.mts +1 -1
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module secret helper/util/etc. functions
|
|
3
|
+
*
|
|
4
|
+
* this is where you will find helper functions like those that generate
|
|
5
|
+
* and parse ibs for secret.
|
|
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, } from '@ibgib/helper-gib/dist/constants.mjs';
|
|
14
|
+
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
15
|
+
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
16
|
+
import { GLOBAL_LOG_A_LOT } from "../../core-constants.mjs";
|
|
17
|
+
import { SecretType, VALID_SECRET_TYPES, } from './secret-types.mjs';
|
|
18
|
+
import { SECRET_ATOM, SECRET_NAME_REGEXP, SECRET_REL8N_NAME, } from './secret-constants.mjs';
|
|
19
|
+
import { INVALID_DATE_STRING } from '../other/other-constants.mjs';
|
|
20
|
+
import { hash16816 } from '../other/ibgib-helper.mjs';
|
|
21
|
+
/**
|
|
22
|
+
* for verbose logging
|
|
23
|
+
*/
|
|
24
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
25
|
+
export function validateCommonSecretData({ data, }) {
|
|
26
|
+
const lc = `[${validateCommonSecretData.name}]`;
|
|
27
|
+
try {
|
|
28
|
+
if (logalot) {
|
|
29
|
+
console.log(`${lc} starting...`);
|
|
30
|
+
}
|
|
31
|
+
if (!data) {
|
|
32
|
+
throw new Error(`data required (E: f7d9a12390e2d3821c07c115a289b5af)`);
|
|
33
|
+
}
|
|
34
|
+
const errors = [];
|
|
35
|
+
const { name, /*uuid,*/ classname, expirationUTC, type, } = data;
|
|
36
|
+
if (name) {
|
|
37
|
+
if (!name.match(SECRET_NAME_REGEXP)) {
|
|
38
|
+
errors.push(`name must match regexp: ${SECRET_NAME_REGEXP} (E: 27023cc5e5afb456e4b8ebfd1e653de6)`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
errors.push(`name required. (E: fe088277e7677ad295b5e914ed644ab4)`);
|
|
43
|
+
}
|
|
44
|
+
if (type) {
|
|
45
|
+
if (!VALID_SECRET_TYPES.includes(type)) {
|
|
46
|
+
errors.push(`type (${type}) is invalid. must be one of ${VALID_SECRET_TYPES.join(', ')} (E: 413a1c899dcc4623a38be35bdf144217)`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
errors.push(`type required. (E: 6126767cc5fd4c898d432b139652e5d1)`);
|
|
51
|
+
}
|
|
52
|
+
// if (uuid) {
|
|
53
|
+
// if (!uuid.match(UUID_REGEXP)) {
|
|
54
|
+
// errors.push(`uuid must match regexp: ${UUID_REGEXP} (E: 1b035a31d191435217010ac272681c82)`);
|
|
55
|
+
// }
|
|
56
|
+
// } else {
|
|
57
|
+
// errors.push(`uuid required. (E: 55fee43e758fcf542866bdabe7321633)`);
|
|
58
|
+
// }
|
|
59
|
+
if (classname) {
|
|
60
|
+
if (!classname.match(CLASSNAME_REGEXP)) {
|
|
61
|
+
errors.push(`classname must match regexp: ${CLASSNAME_REGEXP} (E: 301c325035ad3297c2744fd25ec618dd)`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (expirationUTC) {
|
|
65
|
+
let date = new Date(expirationUTC);
|
|
66
|
+
if (date.toString() === INVALID_DATE_STRING) {
|
|
67
|
+
errors.push(`invalid expirationUTC (${expirationUTC}) (E: 969a126f12b742adbf9d671d3fdd782f)`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
errors.push(`expirationUTC required (E: f1ff3bcec74946908f0f37f9282e917d)`);
|
|
72
|
+
}
|
|
73
|
+
return errors;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
if (logalot) {
|
|
81
|
+
console.log(`${lc} complete.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export async function validateCommonSecretIbGib({ ibGib, }) {
|
|
86
|
+
const lc = `[${validateCommonSecretIbGib.name}]`;
|
|
87
|
+
try {
|
|
88
|
+
if (logalot) {
|
|
89
|
+
console.log(`${lc} starting... (I: 596f5952f6a18ebb23ff270520818eaa)`);
|
|
90
|
+
}
|
|
91
|
+
const intrinsicErrors = await validateIbGibIntrinsically({ ibGib: ibGib }) ?? [];
|
|
92
|
+
if (!ibGib.data) {
|
|
93
|
+
throw new Error(`SecretIbGib.data required (E: df00780071919f55c762ee0756cf46bc)`);
|
|
94
|
+
}
|
|
95
|
+
const ibErrors = [];
|
|
96
|
+
// ib
|
|
97
|
+
let { atom, type, name, } = parseSecretIb({ ib: ibGib.ib });
|
|
98
|
+
if (atom !== SECRET_ATOM) {
|
|
99
|
+
ibErrors.push(`invalid secret atom. must be ${SECRET_ATOM} (E: 56c5874056ff8d07e1875cc38eccf0c3)`);
|
|
100
|
+
}
|
|
101
|
+
if (!type) {
|
|
102
|
+
ibErrors.push(`secret type required (E: 273042f54b363c094b466f85baef3c10)`);
|
|
103
|
+
}
|
|
104
|
+
if (!name) {
|
|
105
|
+
ibErrors.push(`secret name required (E: 670718e47214d0cdfa844d8f7d756477)`);
|
|
106
|
+
}
|
|
107
|
+
// data
|
|
108
|
+
const dataErrors = validateCommonSecretData({ data: ibGib.data });
|
|
109
|
+
let result = [...(intrinsicErrors ?? []), ...(ibErrors ?? []), ...(dataErrors ?? [])];
|
|
110
|
+
if (result.length > 0) {
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
if (logalot) {
|
|
123
|
+
console.log(`${lc} complete.`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function getSecretIb({ data, }) {
|
|
128
|
+
const lc = `[${getSecretIb.name}]`;
|
|
129
|
+
try {
|
|
130
|
+
const validationErrors = validateCommonSecretData({ data });
|
|
131
|
+
if (validationErrors.length > 0) {
|
|
132
|
+
throw new Error(`invalid Secret data: ${validationErrors} (E: 07a71e9ba5d574274e2c6a289a3fbabe)`);
|
|
133
|
+
}
|
|
134
|
+
const { name, type } = data;
|
|
135
|
+
return `${SECRET_ATOM} ${type} ${name}`;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Current schema is '[SECRET_ATOM] [type] [name]'
|
|
144
|
+
*
|
|
145
|
+
* NOTE this is space-delimited
|
|
146
|
+
*/
|
|
147
|
+
export function parseSecretIb({ ib, }) {
|
|
148
|
+
const lc = `[${parseSecretIb.name}]`;
|
|
149
|
+
try {
|
|
150
|
+
if (!ib) {
|
|
151
|
+
throw new Error(`Secret ib required (E: 115e8097c30538526536b240ce4b8e87)`);
|
|
152
|
+
}
|
|
153
|
+
const [atom, type, name] = ib.split(' ');
|
|
154
|
+
if (atom !== SECRET_ATOM) {
|
|
155
|
+
throw new Error(`atom !== ${SECRET_ATOM} (E: 942f3ab95687772a5483ec926ad98124)`);
|
|
156
|
+
}
|
|
157
|
+
if (type !== SecretType.password) {
|
|
158
|
+
console.warn(`${lc} type !== SecretType.password. atow (02/2024) password is the only thing we got. (W: 66511ca217b045629a7816adc4e41fad)`);
|
|
159
|
+
}
|
|
160
|
+
if (!name.match(SECRET_NAME_REGEXP)) {
|
|
161
|
+
throw new Error(`!name.match(SECRET_NAME_REGEXP) (E: 6c95dbb65d3d6d9e0400412bf7ba6824)`);
|
|
162
|
+
}
|
|
163
|
+
return { atom, type, name, };
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export async function createAndRegisterNewSecret({ secretType, secretInfo, metaspace, space, }) {
|
|
171
|
+
const lc = `[${createAndRegisterNewSecret.name}]`;
|
|
172
|
+
try {
|
|
173
|
+
if (logalot) {
|
|
174
|
+
console.log(`${lc} starting... (I: 08a3b2c784ff4689a8abf3ba8f1d7af4)`);
|
|
175
|
+
}
|
|
176
|
+
let resSecretIbGib;
|
|
177
|
+
if (secretType !== SecretType.password) {
|
|
178
|
+
throw new Error(`unknown secretType (${secretType}). only "password" secret type currently implemented. (E: ce3dd7aef4f48f9799f2d37217eed224)`);
|
|
179
|
+
}
|
|
180
|
+
resSecretIbGib = await createAndRegisterNewSecret_password({
|
|
181
|
+
secretType: secretType,
|
|
182
|
+
secretInfo: secretInfo,
|
|
183
|
+
metaspace,
|
|
184
|
+
space,
|
|
185
|
+
});
|
|
186
|
+
return resSecretIbGib;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
if (logalot) {
|
|
194
|
+
console.log(`${lc} complete.`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async function createAndRegisterNewSecret_password({ secretType, secretInfo, metaspace, space, }) {
|
|
199
|
+
const lc = `[${createAndRegisterNewSecret_password.name}]`;
|
|
200
|
+
try {
|
|
201
|
+
if (logalot) {
|
|
202
|
+
console.log(`${lc} starting... (I: ab330733d4b6bb733f5b5655bcd70a24)`);
|
|
203
|
+
}
|
|
204
|
+
if (secretType !== 'password') {
|
|
205
|
+
throw new Error(`(UNEXPECTED) secretType !== 'password'? (E: b086c3494808a38ad967e55a82364824)`);
|
|
206
|
+
}
|
|
207
|
+
// create the secret ibgib
|
|
208
|
+
const data = {
|
|
209
|
+
...secretInfo,
|
|
210
|
+
};
|
|
211
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
212
|
+
ib: getSecretIb({ data }),
|
|
213
|
+
parentIbGib: Factory_V1.primitive({ ib: SECRET_ATOM }),
|
|
214
|
+
data,
|
|
215
|
+
dna: true,
|
|
216
|
+
nCounter: true,
|
|
217
|
+
tjp: { timestamp: true, },
|
|
218
|
+
});
|
|
219
|
+
const secretIbGib = resFirstGen.newIbGib;
|
|
220
|
+
// validate right away before anything else
|
|
221
|
+
const validationErrors = await validateCommonSecretIbGib({ ibGib: secretIbGib }) ?? [];
|
|
222
|
+
if (validationErrors.length > 0) {
|
|
223
|
+
throw new Error(`(UNEXPECTED) newly created secretIbGib has validationErrors? validationErrors: ${validationErrors} (E: 458708237973aea6c72121016d98af24)`);
|
|
224
|
+
}
|
|
225
|
+
// save first in the space...
|
|
226
|
+
await metaspace.persistTransformResult({ resTransform: resFirstGen, space });
|
|
227
|
+
// register the new secret with the ibgib space in general...
|
|
228
|
+
await metaspace.registerNewIbGib({ ibGib: secretIbGib, space });
|
|
229
|
+
// register the new secret with the secrets index
|
|
230
|
+
await metaspace.rel8ToSpecialIbGib({
|
|
231
|
+
type: "secrets",
|
|
232
|
+
rel8nName: SECRET_REL8N_NAME,
|
|
233
|
+
ibGibsToRel8: [secretIbGib],
|
|
234
|
+
space,
|
|
235
|
+
});
|
|
236
|
+
// localIndex_secretIbGibs = await metaspace.getSpecialRel8dIbGibs({
|
|
237
|
+
// type: "secrets",
|
|
238
|
+
// rel8nName: SECRET_REL8N_NAME,
|
|
239
|
+
// space,
|
|
240
|
+
// });
|
|
241
|
+
return secretIbGib;
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
finally {
|
|
248
|
+
if (logalot) {
|
|
249
|
+
console.log(`${lc} complete.`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* executes the hash16816 fn on the incoming {@link password} using parameters
|
|
255
|
+
* {@link recursionCount}, {@link saltPrependedPerHash} and {@link algorithm}.
|
|
256
|
+
* Then selects a random contiguous substring of {@link substringLength} of the
|
|
257
|
+
* resultant hash.
|
|
258
|
+
*
|
|
259
|
+
* @returns {@link substringLength} of deterministic hash
|
|
260
|
+
*
|
|
261
|
+
* This is a novel idea only useful in a byzantine fault tolerant distributed
|
|
262
|
+
* computation context, so to understand how this is used, PLEASE...
|
|
263
|
+
* @see {@link CheckIfPasswordProbablyCorrectInfo}
|
|
264
|
+
*/
|
|
265
|
+
export async function getCheckIfPasswordProbablyCorrectInfo({ password, substringLength, recursionCount, saltPrependedPerHash, algorithm, }) {
|
|
266
|
+
const lc = `[${getCheckIfPasswordProbablyCorrectInfo.name}]`;
|
|
267
|
+
try {
|
|
268
|
+
if (logalot) {
|
|
269
|
+
console.log(`${lc} starting... (I: 9dc41fcf83a6d0e6054d3a9e79803224)`);
|
|
270
|
+
}
|
|
271
|
+
if (!substringLength) {
|
|
272
|
+
throw new Error(`substringLength (${substringLength}) required (E: d1d4fbfaa1562abac7ec42cdd0264224)`);
|
|
273
|
+
}
|
|
274
|
+
recursionCount ?? (recursionCount = 16816);
|
|
275
|
+
algorithm ?? (algorithm = 'SHA-256');
|
|
276
|
+
const fullHash = await hash16816({
|
|
277
|
+
s: password,
|
|
278
|
+
algorithm: 'SHA-256',
|
|
279
|
+
recursionCount,
|
|
280
|
+
saltPrependedPerHash,
|
|
281
|
+
});
|
|
282
|
+
// we want to pick a random starting point for the substring. on the
|
|
283
|
+
// consuming end, we don't need to know this random index, we will just
|
|
284
|
+
// confirm that the fullHash generated when the user enters their
|
|
285
|
+
// password conatins this substring at all (not where it starts from).
|
|
286
|
+
// 64 = length of sha256 hash
|
|
287
|
+
// 64-1 = 0-indexed adjustment
|
|
288
|
+
const r = Math.random();
|
|
289
|
+
const substringStartIndex = Math.floor(r * (63 - substringLength));
|
|
290
|
+
const resSubstring = fullHash.substring(substringStartIndex, substringStartIndex + substringLength);
|
|
291
|
+
// defensive checks here (atow 02/2024), remove at some point once we
|
|
292
|
+
// see that this isn't throwing and it's tested well enough
|
|
293
|
+
if (resSubstring.length !== substringLength) {
|
|
294
|
+
throw new Error(`(UNEXPECTED) resSubstring.length (${resSubstring.length}) !== substringLength (${substringLength})?\nfullHash: ${fullHash}\nr: ${r}\nsubstringStartIndex: ${substringStartIndex}\nresSubstring: ${resSubstring}(E: c45acd126b4c70041e92f6ad5329c424)`);
|
|
295
|
+
}
|
|
296
|
+
const confirmResult = await passwordProbablyCorrect({
|
|
297
|
+
password, checkInfo: {
|
|
298
|
+
substring: resSubstring,
|
|
299
|
+
algorithm,
|
|
300
|
+
recursionCount,
|
|
301
|
+
saltPrependedPerHash,
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
if (!confirmResult) {
|
|
305
|
+
throw new Error(`(UNEXPECTED) !confirmResult? uhh... (E: cc757a8ef07b6468793b1bddbafca924)`);
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
substring: resSubstring,
|
|
309
|
+
saltPrependedPerHash: saltPrependedPerHash ?? '',
|
|
310
|
+
recursionCount,
|
|
311
|
+
algorithm,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
finally {
|
|
319
|
+
if (logalot) {
|
|
320
|
+
console.log(`${lc} complete.`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* confirmation side of verifying if a consumer's password is **probably**
|
|
326
|
+
* correct. Basically computes the silly hash of the password and checks to see
|
|
327
|
+
* if it contains the given substring.
|
|
328
|
+
*
|
|
329
|
+
* @see {@link CheckIfPasswordProbablyCorrectInfo}
|
|
330
|
+
* @see {@link getCheckIfPasswordProbablyCorrectInfo}
|
|
331
|
+
*/
|
|
332
|
+
export async function passwordProbablyCorrect({ password, checkInfo, }) {
|
|
333
|
+
const lc = `[${passwordProbablyCorrect.name}]`;
|
|
334
|
+
try {
|
|
335
|
+
if (logalot) {
|
|
336
|
+
console.log(`${lc} starting... (I: ce745a0d8b5de7a24ddc83fe432e4224)`);
|
|
337
|
+
}
|
|
338
|
+
const { substring, recursionCount, saltPrependedPerHash, algorithm } = checkInfo;
|
|
339
|
+
const fullHash = await hash16816({
|
|
340
|
+
s: password,
|
|
341
|
+
recursionCount,
|
|
342
|
+
saltPrependedPerHash,
|
|
343
|
+
algorithm,
|
|
344
|
+
});
|
|
345
|
+
const resProbablyCorrect = fullHash.includes(substring);
|
|
346
|
+
return resProbablyCorrect;
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
350
|
+
throw error;
|
|
351
|
+
}
|
|
352
|
+
finally {
|
|
353
|
+
if (logalot) {
|
|
354
|
+
console.log(`${lc} complete.`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=secret-helper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-helper.mjs","sourceRoot":"","sources":["../../../src/common/secret/secret-helper.mts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,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,CAAC;AAEjC,MAAM,UAAU,wBAAwB,CAAC,EACrC,IAAI,GAGP;IACG,MAAM,EAAE,GAAG,IAAI,wBAAwB,CAAC,IAAI,GAAG,CAAC;IAChD,IAAI,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAA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AAC;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"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module secret types (and enums)
|
|
3
|
+
*/
|
|
4
|
+
import { HashAlgorithm } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
5
|
+
import { IbGibData_V1, IbGibRel8ns_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
6
|
+
export type SecretType = "password";
|
|
7
|
+
export declare const SecretType: {
|
|
8
|
+
password: "password";
|
|
9
|
+
};
|
|
10
|
+
export declare const VALID_SECRET_TYPES: "password"[];
|
|
11
|
+
export interface SecretInfo {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
expirationUTC: string;
|
|
15
|
+
type: SecretType;
|
|
16
|
+
}
|
|
17
|
+
export interface SecretInfo_Password extends SecretInfo {
|
|
18
|
+
type: 'password';
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link CheckIfPasswordProbablyCorrectInfo}
|
|
21
|
+
*/
|
|
22
|
+
passwordProbablyCorrectInfo: CheckIfPasswordProbablyCorrectInfo;
|
|
23
|
+
/**
|
|
24
|
+
* Public hint to help you remember your secret (or help the bad person
|
|
25
|
+
* attack your secret).
|
|
26
|
+
*/
|
|
27
|
+
hint?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* This contains information for doing a **convenience check** of whether or
|
|
31
|
+
* not the user/consumer has entered a password that is "probably" correct.
|
|
32
|
+
*
|
|
33
|
+
* ## READ THIS
|
|
34
|
+
*
|
|
35
|
+
* Distributed sovereignty has different requirements than a trusted server
|
|
36
|
+
* approach when it comes to handling secrets.
|
|
37
|
+
*
|
|
38
|
+
* ### trusted servers store entire hashes for authentication
|
|
39
|
+
*
|
|
40
|
+
* In a trusted server approach, we will check the password against some hashing
|
|
41
|
+
* mechanism with varying implementation details. But we will almost certainly
|
|
42
|
+
* check against the entire hash, because we will decide authentication based on
|
|
43
|
+
* this proof.
|
|
44
|
+
*
|
|
45
|
+
* ### distributed data works differently
|
|
46
|
+
*
|
|
47
|
+
* In the distributed model, however, the only utility of a password is in
|
|
48
|
+
* encryption and signatures. So when a user/consumer enters a password, it
|
|
49
|
+
* actually **does** something, i.e., creates derivative data. Either it creates
|
|
50
|
+
* an encrypted file or performs a signature (I hesitate to discuss asymmetric
|
|
51
|
+
* encryption because I still don't believe in it, and when keystones are
|
|
52
|
+
* implemented in ibgib, passwords will evolve the stone (it works _somewhat_
|
|
53
|
+
* similarly to a double-ratchet algorithm but is more hardened and expressive
|
|
54
|
+
* because it works on top of ibgib's already-established "chaining"
|
|
55
|
+
* infrastructure)).
|
|
56
|
+
*
|
|
57
|
+
* But the question is:
|
|
58
|
+
* **How does the user/consumer know that they entered the right password?**
|
|
59
|
+
*
|
|
60
|
+
* ### we can't store entire hashes
|
|
61
|
+
*
|
|
62
|
+
* In the distributed model, we assume a brute-forcer will have access to the
|
|
63
|
+
* encrypted data and any metadata we might store. This includes those would-be
|
|
64
|
+
* hashes and that would be bad - even if they are randomly salted.
|
|
65
|
+
*
|
|
66
|
+
* This is because this approach would preclude the ability for the user to
|
|
67
|
+
* encrypt some large data with mitigations against short-circuit decryption
|
|
68
|
+
* until the entire data block was decrypted (I refer you to encrypt-gib
|
|
69
|
+
* documentation here). IOW, the brute-forcer would only have to use the
|
|
70
|
+
* password and check against the hash, which can be an extremely quick
|
|
71
|
+
* operation - even if we set iterations insanely high on some KDF, this still
|
|
72
|
+
* would provide a relatively quick avenue for brute force attacks.
|
|
73
|
+
*
|
|
74
|
+
* ### we can store partial hashes
|
|
75
|
+
*
|
|
76
|
+
* We won't save the entire hash, just some substring of the hash. (We could
|
|
77
|
+
* conceivably store other metadata that checks against the hash, e.g., parity
|
|
78
|
+
* checks like the number of 1s, 2s, etc.).
|
|
79
|
+
*
|
|
80
|
+
* ### partial hash dynamics
|
|
81
|
+
*
|
|
82
|
+
* * The larger the partial hash, the less likely false collisions are produced.
|
|
83
|
+
* * when a user typos a password, we do NOT want a false collision.
|
|
84
|
+
* * when a brute-forcer makes a password attempt, we DO want a false
|
|
85
|
+
* collision.
|
|
86
|
+
* * a user's **unique** typos compose the set that we want to avoid false
|
|
87
|
+
* collisions.
|
|
88
|
+
* * the same typo only counts once.
|
|
89
|
+
*
|
|
90
|
+
* So we want to...
|
|
91
|
+
* * maximize the time wasted in brute forcing
|
|
92
|
+
* * or IOW, minimize the information gained by the brute forcer
|
|
93
|
+
* * this will statistically slow down brute force attacks that work against
|
|
94
|
+
* this information alone.
|
|
95
|
+
* * minimize the inconvenience by a password failure due to a false collision
|
|
96
|
+
* by the legitimate user/consumer.
|
|
97
|
+
* * there should be in place a well-hardened fail path for when the false
|
|
98
|
+
* password is given but the false collision allows it to pass the initial
|
|
99
|
+
* quick check phase.
|
|
100
|
+
*
|
|
101
|
+
* ### my implementation notes
|
|
102
|
+
*
|
|
103
|
+
* I am not doing this mathematically/rigorously, because that would take way
|
|
104
|
+
* too long, rather I am working from...
|
|
105
|
+
* * my personal experience with searching for hashes in the ibgib code bases.
|
|
106
|
+
* * Most ibgib codebase error messages are accompanied by a hash to uniquely
|
|
107
|
+
* identify the error.
|
|
108
|
+
* * I often search the codebase based on a substring of this when I am
|
|
109
|
+
* troubleshooting.
|
|
110
|
+
* * atow (02/2024) there are 1171 of these hashes in just core-gib.
|
|
111
|
+
* * To get a unique hash, the absolute MOST I have to actually enter is 4 or
|
|
112
|
+
* 5 letters
|
|
113
|
+
* * 5 is extremely rare.
|
|
114
|
+
* * unit testing observations
|
|
115
|
+
* * I've found that 4 letters gives false collisions on average every 900-ish
|
|
116
|
+
* hashes.
|
|
117
|
+
*
|
|
118
|
+
* As such, I am setting the length to 4. But note that in consuming code, we
|
|
119
|
+
* always just check for the substring, so changing this value in the future
|
|
120
|
+
* should not affect code a la an exception thrown, but rather, it will just
|
|
121
|
+
* change this dynamic of good faith typos vs. brute force cracking.
|
|
122
|
+
*
|
|
123
|
+
* ## warnings
|
|
124
|
+
*
|
|
125
|
+
* NOTHING GIVING ACTUAL AUTHORIZATION SHOULD CHECK AGAINST THIS INFO.
|
|
126
|
+
* NOTHING GIVING ACTUAL AUTHORIZATION SHOULD CHECK AGAINST THIS INFO.
|
|
127
|
+
* NOTHING GIVING ACTUAL AUTHORIZATION SHOULD CHECK AGAINST THIS INFO.
|
|
128
|
+
* NOTHING GIVING ACTUAL AUTHORIZATION SHOULD CHECK AGAINST THIS INFO.
|
|
129
|
+
*/
|
|
130
|
+
export interface CheckIfPasswordProbablyCorrectInfo {
|
|
131
|
+
/**
|
|
132
|
+
* NOTHING GIVING ACTUAL AUTHORIZATION SHOULD CHECK AGAINST THIS INFO.
|
|
133
|
+
* NOTHING GIVING ACTUAL AUTHORIZATION SHOULD CHECK AGAINST THIS INFO.
|
|
134
|
+
* NOTHING GIVING ACTUAL AUTHORIZATION SHOULD CHECK AGAINST THIS INFO.
|
|
135
|
+
* @see {CheckIfPasswordProbablyCorrectInfo}
|
|
136
|
+
*
|
|
137
|
+
* substring contained in the resultant recursive hash built on the password
|
|
138
|
+
* and other parameters of this info.
|
|
139
|
+
*
|
|
140
|
+
* other parameters:
|
|
141
|
+
* * {@link recursions}
|
|
142
|
+
* * {@link saltPrependedPerHash}
|
|
143
|
+
* * {@link algorithm}
|
|
144
|
+
*/
|
|
145
|
+
substring: string;
|
|
146
|
+
/**
|
|
147
|
+
* the number of times to recursively call the hash function, analogous to a
|
|
148
|
+
* naive key stretching algorithm.
|
|
149
|
+
*/
|
|
150
|
+
recursionCount: number;
|
|
151
|
+
/**
|
|
152
|
+
* salt that will be prepended to the password/intermediate hash each hash
|
|
153
|
+
* round.
|
|
154
|
+
*/
|
|
155
|
+
saltPrependedPerHash: string;
|
|
156
|
+
/**
|
|
157
|
+
* hash algorithm to use per hash round.
|
|
158
|
+
*/
|
|
159
|
+
algorithm: HashAlgorithm;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* ibgib's intrinsic data.
|
|
163
|
+
*
|
|
164
|
+
* atow (02/2024) we are doing most of this in {@link SecretInfo} (from ionic-gib port)
|
|
165
|
+
*
|
|
166
|
+
* @see {@link SecretInfo}
|
|
167
|
+
* @see {@link IbGib_V1.data}
|
|
168
|
+
* @see {@link SecretIbGib_V1}
|
|
169
|
+
*/
|
|
170
|
+
export interface SecretData_V1 extends IbGibData_V1, SecretInfo {
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* rel8ns (named edges/links in DAG) go here.
|
|
174
|
+
*
|
|
175
|
+
* @see {@link IbGib_V1.rel8ns}
|
|
176
|
+
* @see {@link SecretIbGib_V1}
|
|
177
|
+
*/
|
|
178
|
+
export interface SecretRel8ns_V1 extends IbGibRel8ns_V1 {
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* this is the ibgib object itself.
|
|
182
|
+
*
|
|
183
|
+
* If this is a plain ibgib data only object, this acts as a dto. You may also
|
|
184
|
+
* want to generate a witness ibgib, which is slightly different, for ibgibs
|
|
185
|
+
* that will have behavior (i.e. methods).
|
|
186
|
+
*
|
|
187
|
+
* @see {@link SecretData_V1}
|
|
188
|
+
* @see {@link SecretRel8ns_V1}
|
|
189
|
+
*/
|
|
190
|
+
export interface SecretIbGib_V1 extends IbGib_V1<SecretData_V1, SecretRel8ns_V1> {
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=secret-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-types.d.mts","sourceRoot":"","sources":["../../../src/common/secret/secret-types.mts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEzF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AACpC,eAAO,MAAM,UAAU;;CAEtB,CAAA;AACD,eAAO,MAAM,kBAAkB,cAAqC,CAAC;AAErE,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACnD,IAAI,EAAE,UAAU,CAAC;IAEjB;;OAEG;IACH,2BAA2B,EAAE,kCAAkC,CAAC;IAEhE;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;AACH,MAAM,WAAW,kCAAkC;IAC/C;;;;;;;;;;;;;OAaG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,SAAS,EAAE,aAAa,CAAC;CAC5B;AAGD;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAc,SAAQ,YAAY,EAAE,UAAU;CAC9D;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc;CAatD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAe,SAAQ,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC;CAE/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-types.mjs","sourceRoot":"","sources":["../../../src/common/secret/secret-types.mts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,QAAQ,EAAE,UAAwB;CACrC,CAAA;AACD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret.respec.d.mts","sourceRoot":"","sources":["../../../src/common/secret/secret.respec.mts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|