@ibgib/space-gib 0.0.19 → 0.0.20
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/client/bootstrap.mjs +7 -7
- package/dist/client/chunk-3RNUFRNV.mjs +22 -0
- package/dist/client/chunk-TVMLARYE.mjs +2762 -0
- package/dist/client/index.html +3 -2
- package/dist/client/index.mjs +5 -5
- package/dist/client/script.mjs +1 -1
- package/dist/server/server.mjs +807 -583
- package/package.json +4 -4
- package/src/client/AUTO-GENERATED-version.mts +1 -1
- package/src/client/README.md +113 -0
- package/src/client/dev-tools/common.mts +1 -0
- package/src/client/index.html +3 -2
- package/dist/client/chunk-NLLBRWVU.mjs +0 -18
- package/dist/client/chunk-YJGD7KHK.mjs +0 -2665
package/dist/server/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/server/server.mts
|
|
2
2
|
import { createServer } from "node:http";
|
|
3
|
-
import { join as
|
|
3
|
+
import { join as join11, dirname } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|
|
6
6
|
// ../../libs/helper-gib/dist/constants.mjs
|
|
@@ -247,10 +247,10 @@ function isExpired({ expirationTimestampUTC }) {
|
|
|
247
247
|
function unique(arr) {
|
|
248
248
|
return Array.from(new Set(arr));
|
|
249
249
|
}
|
|
250
|
-
function patchObject({ obj, value, path:
|
|
250
|
+
function patchObject({ obj, value, path: path8, pathDelimiter, logalot: logalot75 }) {
|
|
251
251
|
const lc2 = `[${patchObject.name}]`;
|
|
252
252
|
try {
|
|
253
|
-
if (
|
|
253
|
+
if (logalot75) {
|
|
254
254
|
console.log(`${lc2} starting...`);
|
|
255
255
|
}
|
|
256
256
|
if (!obj) {
|
|
@@ -259,12 +259,12 @@ function patchObject({ obj, value, path: path7, pathDelimiter, logalot: logalot7
|
|
|
259
259
|
if (typeof obj !== "object") {
|
|
260
260
|
throw new Error(`obj must be type 'object' (E: 66fdc289b32c06492bd95f5d266e6a22)`);
|
|
261
261
|
}
|
|
262
|
-
if (!
|
|
262
|
+
if (!path8) {
|
|
263
263
|
throw new Error(`path required (at the very least should be the key in the root obj.) (E: fc779e7794ead8a0b44e5f2e776b0e22)`);
|
|
264
264
|
}
|
|
265
265
|
pathDelimiter = pathDelimiter || DEFAULT_DATA_PATH_DELIMITER;
|
|
266
266
|
let targetObj = obj;
|
|
267
|
-
const pathPieces =
|
|
267
|
+
const pathPieces = path8.split(pathDelimiter).filter((x) => !!x);
|
|
268
268
|
const key = pathPieces.pop();
|
|
269
269
|
pathPieces.forEach((piece) => {
|
|
270
270
|
let currentValue = targetObj[piece];
|
|
@@ -282,7 +282,7 @@ function patchObject({ obj, value, path: path7, pathDelimiter, logalot: logalot7
|
|
|
282
282
|
console.error(`${lc2} ${error.message}`);
|
|
283
283
|
throw error;
|
|
284
284
|
} finally {
|
|
285
|
-
if (
|
|
285
|
+
if (logalot75) {
|
|
286
286
|
console.log(`${lc2} complete.`);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
@@ -1149,18 +1149,18 @@ function validateRawPath(rawPath) {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
}
|
|
1152
|
-
function isSafePath(
|
|
1153
|
-
const errors = validateRawPath(
|
|
1152
|
+
function isSafePath(path8) {
|
|
1153
|
+
const errors = validateRawPath(path8);
|
|
1154
1154
|
return errors.length === 0;
|
|
1155
1155
|
}
|
|
1156
|
-
function validateStaticPath(
|
|
1156
|
+
function validateStaticPath(path8) {
|
|
1157
1157
|
const lc2 = `[${validateStaticPath.name}]`;
|
|
1158
1158
|
try {
|
|
1159
1159
|
if (logalot3) {
|
|
1160
1160
|
console.log(`${lc2} starting... (I: 4f9cf8ffd528c7dd88324529528eeb26)`);
|
|
1161
1161
|
}
|
|
1162
1162
|
const errors = [];
|
|
1163
|
-
if (!VALID_STATIC_PATH_REGEX.test(
|
|
1163
|
+
if (!VALID_STATIC_PATH_REGEX.test(path8)) {
|
|
1164
1164
|
errors.push(`static path fails to match VALID_STATIC_PATH_REGEX of ${VALID_STATIC_PATH_REGEX} (E: dfdf38a0439d4d09186e6fa81ab66826) `);
|
|
1165
1165
|
}
|
|
1166
1166
|
return errors;
|
|
@@ -1172,11 +1172,11 @@ function validateStaticPath(path7) {
|
|
|
1172
1172
|
}
|
|
1173
1173
|
}
|
|
1174
1174
|
}
|
|
1175
|
-
function isValidStaticPath(
|
|
1176
|
-
if (!isSafePath(
|
|
1175
|
+
function isValidStaticPath(path8) {
|
|
1176
|
+
if (!isSafePath(path8)) {
|
|
1177
1177
|
return false;
|
|
1178
1178
|
}
|
|
1179
|
-
const errors = validateStaticPath(
|
|
1179
|
+
const errors = validateStaticPath(path8);
|
|
1180
1180
|
return errors.length === 0;
|
|
1181
1181
|
}
|
|
1182
1182
|
function validateAddressSegment(encodedAddr) {
|
|
@@ -9408,17 +9408,17 @@ var B2TFS_DEFAULT_ENCODINGS_TO_TRY = [
|
|
|
9408
9408
|
|
|
9409
9409
|
// ../../libs/node-gib/dist/witness/space/node-filesystem-space/node-filesystem-space-helper.mjs
|
|
9410
9410
|
var logalot15 = GLOBAL_LOG_A_LOT3;
|
|
9411
|
-
async function tryRead({ path:
|
|
9411
|
+
async function tryRead({ path: path8, directory, encoding }) {
|
|
9412
9412
|
const lc2 = `[${tryRead.name}]`;
|
|
9413
9413
|
try {
|
|
9414
9414
|
if (logalot15) {
|
|
9415
9415
|
console.log(`${lc2} starting...`);
|
|
9416
9416
|
console.log(`${lc2} cwd: ${cwd()}`);
|
|
9417
|
-
if (
|
|
9417
|
+
if (path8.includes("bootstrap^gib")) {
|
|
9418
9418
|
console.log(`${lc2} trying bootstrap^gib... (I: dacfdbe5a2d640ab947a7c17e3c56f78)`);
|
|
9419
9419
|
}
|
|
9420
9420
|
}
|
|
9421
|
-
const fullPath = pathUtils.join(directory,
|
|
9421
|
+
const fullPath = pathUtils.join(directory, path8);
|
|
9422
9422
|
if (logalot15) {
|
|
9423
9423
|
console.log(`${lc2} fullPath: ${fullPath} (I: 459b416ac32c711bfbab54177839b323)`);
|
|
9424
9424
|
}
|
|
@@ -9432,7 +9432,7 @@ async function tryRead({ path: path7, directory, encoding }) {
|
|
|
9432
9432
|
return resRead;
|
|
9433
9433
|
} catch (error) {
|
|
9434
9434
|
if (logalot15) {
|
|
9435
|
-
console.log(`${lc2} fullPath not found from directory (${directory}) and path (${
|
|
9435
|
+
console.log(`${lc2} fullPath not found from directory (${directory}) and path (${path8})
|
|
9436
9436
|
error:
|
|
9437
9437
|
${extractErrorMsg(error)} (I: 1fde689d29aa47fcb589b3e7dac8929b)`);
|
|
9438
9438
|
}
|
|
@@ -9443,17 +9443,17 @@ ${extractErrorMsg(error)} (I: 1fde689d29aa47fcb589b3e7dac8929b)`);
|
|
|
9443
9443
|
}
|
|
9444
9444
|
}
|
|
9445
9445
|
}
|
|
9446
|
-
async function tryRead_bin({ path:
|
|
9446
|
+
async function tryRead_bin({ path: path8, directory, encoding }) {
|
|
9447
9447
|
const lc2 = `[${tryRead_bin.name}]`;
|
|
9448
9448
|
try {
|
|
9449
9449
|
if (logalot15) {
|
|
9450
9450
|
console.log(`${lc2} starting...`);
|
|
9451
9451
|
console.log(`${lc2} cwd: ${cwd()}`);
|
|
9452
|
-
if (
|
|
9452
|
+
if (path8.includes("bootstrap^gib")) {
|
|
9453
9453
|
console.log(`${lc2} trying bootstrap^gib... (I: 5eb010444b814addb1a6bbe18ca3dbfa)`);
|
|
9454
9454
|
}
|
|
9455
9455
|
}
|
|
9456
|
-
const fullPath = pathUtils.join(directory,
|
|
9456
|
+
const fullPath = pathUtils.join(directory, path8);
|
|
9457
9457
|
if (logalot15) {
|
|
9458
9458
|
console.log(`${lc2} fullPath: ${fullPath} (I: c342bf56df354e9ab2653855a458b99d)`);
|
|
9459
9459
|
}
|
|
@@ -9483,7 +9483,7 @@ async function tryRead_bin({ path: path7, directory, encoding }) {
|
|
|
9483
9483
|
};
|
|
9484
9484
|
} catch (error) {
|
|
9485
9485
|
if (logalot15) {
|
|
9486
|
-
console.log(`${lc2} fullPath not found from directory (${directory}) and path (${
|
|
9486
|
+
console.log(`${lc2} fullPath not found from directory (${directory}) and path (${path8})
|
|
9487
9487
|
error:
|
|
9488
9488
|
${extractErrorMsg(error)} (I: 882e54f079024c94864bdaa74979b397)`);
|
|
9489
9489
|
}
|
|
@@ -9692,23 +9692,23 @@ var NodeFilesystemSpace_V1 = class _NodeFilesystemSpace_V1 extends FilesystemSpa
|
|
|
9692
9692
|
}
|
|
9693
9693
|
;
|
|
9694
9694
|
const thisData = this.data;
|
|
9695
|
-
let
|
|
9695
|
+
let path8 = "";
|
|
9696
9696
|
let data = "";
|
|
9697
9697
|
const addr = getIbGibAddr({ ibGib });
|
|
9698
9698
|
const isBin = isBinary({ addr });
|
|
9699
|
-
|
|
9699
|
+
path8 = await this.buildPath({
|
|
9700
9700
|
addr,
|
|
9701
9701
|
isDna: isDna2 ?? false,
|
|
9702
9702
|
isBin,
|
|
9703
9703
|
ensureMetaStonePaths: true
|
|
9704
9704
|
});
|
|
9705
|
-
await this.ensureDirsImpl([pathUtils2.dirname(
|
|
9706
|
-
let fullPath = pathUtils2.join(thisData.baseDir,
|
|
9705
|
+
await this.ensureDirsImpl([pathUtils2.dirname(path8)]);
|
|
9706
|
+
let fullPath = pathUtils2.join(thisData.baseDir, path8);
|
|
9707
9707
|
if (logalot16) {
|
|
9708
9708
|
console.log(`${lc2} fullPath: ${fullPath} (I: 2441a896f7e6418db57c0341d5c65ef2)`);
|
|
9709
9709
|
}
|
|
9710
9710
|
if (logalot16) {
|
|
9711
|
-
console.log(`${lc2} path: ${
|
|
9711
|
+
console.log(`${lc2} path: ${path8}, directory: ${thisData.baseDir}, thisData.encoding: ${thisData.encoding} (I: d4440ececbe6c859f8fcf6d7ece12522)`);
|
|
9712
9712
|
}
|
|
9713
9713
|
let encoding;
|
|
9714
9714
|
if (!isBin) {
|
|
@@ -9744,15 +9744,15 @@ var NodeFilesystemSpace_V1 = class _NodeFilesystemSpace_V1 extends FilesystemSpa
|
|
|
9744
9744
|
throw new Error(`this.data required (E: 27e1f5206d96d635e617f5ba69141423)`);
|
|
9745
9745
|
}
|
|
9746
9746
|
const data = this.data;
|
|
9747
|
-
let
|
|
9747
|
+
let path8 = "";
|
|
9748
9748
|
if (!isBinary({ addr })) {
|
|
9749
|
-
|
|
9749
|
+
path8 = await this.buildPath({
|
|
9750
9750
|
addr,
|
|
9751
9751
|
isDna: isDna2 ?? false,
|
|
9752
9752
|
ensureMetaStonePaths: true
|
|
9753
9753
|
});
|
|
9754
9754
|
} else {
|
|
9755
|
-
|
|
9755
|
+
path8 = await this.buildPath({
|
|
9756
9756
|
addr,
|
|
9757
9757
|
isDna: false,
|
|
9758
9758
|
isBin: true,
|
|
@@ -9760,12 +9760,12 @@ var NodeFilesystemSpace_V1 = class _NodeFilesystemSpace_V1 extends FilesystemSpa
|
|
|
9760
9760
|
});
|
|
9761
9761
|
}
|
|
9762
9762
|
if (logalot16) {
|
|
9763
|
-
console.log(`${lc2} path: ${
|
|
9763
|
+
console.log(`${lc2} path: ${path8}, directory: ${data.baseDir}`);
|
|
9764
9764
|
}
|
|
9765
|
-
const fullPath = pathUtils2.join(this.data.baseDir,
|
|
9765
|
+
const fullPath = pathUtils2.join(this.data.baseDir, path8);
|
|
9766
9766
|
await rm(fullPath, { force: true });
|
|
9767
9767
|
if (logalot16) {
|
|
9768
|
-
console.log(`${lc2} deleted. path: ${
|
|
9768
|
+
console.log(`${lc2} deleted. path: ${path8}`);
|
|
9769
9769
|
}
|
|
9770
9770
|
result.success = true;
|
|
9771
9771
|
} catch (error) {
|
|
@@ -9967,10 +9967,10 @@ var NodeFilesystemSpace_V1 = class _NodeFilesystemSpace_V1 extends FilesystemSpa
|
|
|
9967
9967
|
return;
|
|
9968
9968
|
}
|
|
9969
9969
|
for (let i = 0; i < paths.length; i++) {
|
|
9970
|
-
const
|
|
9971
|
-
const lc22 = `${lc2}[(path: ${
|
|
9972
|
-
const fullPath = pathUtils2.join(directory,
|
|
9973
|
-
const pathExistsKey = getPathKey(
|
|
9970
|
+
const path8 = paths[i];
|
|
9971
|
+
const lc22 = `${lc2}[(path: ${path8}, directory: ${directory})]`;
|
|
9972
|
+
const fullPath = pathUtils2.join(directory, path8);
|
|
9973
|
+
const pathExistsKey = getPathKey(path8);
|
|
9974
9974
|
let exists = this.pathExistsMap[pathExistsKey] || false;
|
|
9975
9975
|
if (!exists) {
|
|
9976
9976
|
try {
|
|
@@ -12316,19 +12316,19 @@ var DynamicFormFactoryBase = class _DynamicFormFactoryBase extends WitnessFactor
|
|
|
12316
12316
|
}
|
|
12317
12317
|
for (let i = 0; i < items.length; i++) {
|
|
12318
12318
|
const item = items[i];
|
|
12319
|
-
const
|
|
12319
|
+
const path8 = contextPath ? contextPath + pathDelimiter + item.name : item.name;
|
|
12320
12320
|
if (!item.items) {
|
|
12321
12321
|
patchObject({
|
|
12322
12322
|
obj: data,
|
|
12323
12323
|
value: item.value,
|
|
12324
|
-
path:
|
|
12324
|
+
path: path8,
|
|
12325
12325
|
logalot: logalot21,
|
|
12326
12326
|
pathDelimiter
|
|
12327
12327
|
});
|
|
12328
12328
|
} else if (item.items.length > 0) {
|
|
12329
12329
|
this.patchDataFromItems({
|
|
12330
12330
|
data,
|
|
12331
|
-
contextPath:
|
|
12331
|
+
contextPath: path8,
|
|
12332
12332
|
items: item.items,
|
|
12333
12333
|
pathDelimiter
|
|
12334
12334
|
});
|
|
@@ -17609,28 +17609,41 @@ var IdentityIndexService = class _IdentityIndexService {
|
|
|
17609
17609
|
* Throws `duplicate_identity_409` error if email is already registered.
|
|
17610
17610
|
*/
|
|
17611
17611
|
async registerEmailIndex({ email, tjpAddr, primaryTjpAddr }) {
|
|
17612
|
-
const
|
|
17613
|
-
if (!targetAddr) {
|
|
17614
|
-
throw new Error("Either tjpAddr or primaryTjpAddr must be provided. (E: 62f15851b9a8c8d718279ab84e426826)");
|
|
17615
|
-
}
|
|
17616
|
-
const emailHash = await getIdentityEmailHash({ email, salt: this.salt });
|
|
17617
|
-
const { folderPath, filePath } = getShardedIndexPath({
|
|
17618
|
-
baseDir: this.baseDir,
|
|
17619
|
-
emailHash
|
|
17620
|
-
});
|
|
17621
|
-
await fs.mkdir(folderPath, { recursive: true });
|
|
17622
|
-
const record = {
|
|
17623
|
-
tjpAddr: targetAddr,
|
|
17624
|
-
createdAt: Date.now()
|
|
17625
|
-
};
|
|
17612
|
+
const lc2 = `${this.lc}[${this.registerEmailIndex.name}]`;
|
|
17626
17613
|
try {
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17614
|
+
if (logalot38) {
|
|
17615
|
+
console.log(`${lc2} starting... (I: 5d1728a955657616a8cf6ce8b5afa226)`);
|
|
17616
|
+
}
|
|
17617
|
+
const targetAddr = tjpAddr || primaryTjpAddr;
|
|
17618
|
+
if (!targetAddr) {
|
|
17619
|
+
throw new Error("Either tjpAddr or primaryTjpAddr must be provided. (E: 62f15851b9a8c8d718279ab84e426826)");
|
|
17620
|
+
}
|
|
17621
|
+
const emailHash = await getIdentityEmailHash({ email, salt: this.salt });
|
|
17622
|
+
const { folderPath, filePath } = getShardedIndexPath({
|
|
17623
|
+
baseDir: this.baseDir,
|
|
17624
|
+
emailHash
|
|
17625
|
+
});
|
|
17626
|
+
await fs.mkdir(folderPath, { recursive: true });
|
|
17627
|
+
const record = {
|
|
17628
|
+
tjpAddr: targetAddr,
|
|
17629
|
+
createdAt: Date.now()
|
|
17630
|
+
};
|
|
17631
|
+
try {
|
|
17632
|
+
await fs.writeFile(filePath, JSON.stringify(record, null, 2), { flag: "wx" });
|
|
17633
|
+
return { emailHash, filePath, record };
|
|
17634
|
+
} catch (error) {
|
|
17635
|
+
if (error.code === "EEXIST") {
|
|
17636
|
+
throw new Error(`Email is already registered (E: duplicate_identity_409)`);
|
|
17637
|
+
}
|
|
17638
|
+
throw error;
|
|
17632
17639
|
}
|
|
17640
|
+
} catch (error) {
|
|
17641
|
+
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
17633
17642
|
throw error;
|
|
17643
|
+
} finally {
|
|
17644
|
+
if (logalot38) {
|
|
17645
|
+
console.log(`${lc2} complete.`);
|
|
17646
|
+
}
|
|
17634
17647
|
}
|
|
17635
17648
|
}
|
|
17636
17649
|
/**
|
|
@@ -19239,6 +19252,7 @@ var KeystoneProfileBuilder = class _KeystoneProfileBuilder {
|
|
|
19239
19252
|
};
|
|
19240
19253
|
|
|
19241
19254
|
// ../../libs/core-gib/dist/keystone/delegate/delegate-constants.mjs
|
|
19255
|
+
var KEYSTONE_ROLE_CUSTODIAL_SYNC = "custodial-sync";
|
|
19242
19256
|
var DEFAULT_DELEGATE_TTL_SECONDS = 30 * 24 * 60 * 60;
|
|
19243
19257
|
var CUSTODIAN_POOL_ID_PREFIX = "custodian-manage-";
|
|
19244
19258
|
|
|
@@ -19264,6 +19278,9 @@ function isKeystoneExpired({ keystone, nowUTC }) {
|
|
|
19264
19278
|
return currentMs > expirationMs;
|
|
19265
19279
|
}
|
|
19266
19280
|
function isDelegateExpired({ delegateInfo, delegateKeystone, nowUTC }) {
|
|
19281
|
+
if (!delegateInfo && !delegateKeystone) {
|
|
19282
|
+
throw new Error(`either delegateInfo or delegateKeystone required. (E: d1baa55ca8d23b26f8562a28179d2126)`);
|
|
19283
|
+
}
|
|
19267
19284
|
if (delegateKeystone) {
|
|
19268
19285
|
return isKeystoneExpired({ keystone: delegateKeystone, nowUTC });
|
|
19269
19286
|
}
|
|
@@ -19277,6 +19294,35 @@ function isDelegateExpired({ delegateInfo, delegateKeystone, nowUTC }) {
|
|
|
19277
19294
|
const currentMs = nowUTC !== void 0 ? typeof nowUTC === "number" ? nowUTC : nowUTC instanceof Date ? nowUTC.getTime() : Date.parse(nowUTC) : Date.now();
|
|
19278
19295
|
return currentMs > expirationMs;
|
|
19279
19296
|
}
|
|
19297
|
+
function isCustodialDelegate({ delegateInfo, delegateKeystone, providerId }) {
|
|
19298
|
+
if (!delegateInfo && !delegateKeystone) {
|
|
19299
|
+
return false;
|
|
19300
|
+
}
|
|
19301
|
+
const role = delegateInfo?.role || delegateKeystone?.data?.frameDetails?.role;
|
|
19302
|
+
const deviceName = delegateInfo?.deviceName || delegateKeystone?.data?.frameDetails?.deviceTag;
|
|
19303
|
+
const metadataProvider = delegateInfo?.metadata?.provider || delegateKeystone?.data?.frameDetails?.custodianProvider || delegateKeystone?.data?.frameDetails?.metadata?.provider;
|
|
19304
|
+
const isExplicitCustodialRole = role === KEYSTONE_ROLE_CUSTODIAL_SYNC || role === "custodial-sync";
|
|
19305
|
+
if (metadataProvider) {
|
|
19306
|
+
if (providerId) {
|
|
19307
|
+
return String(metadataProvider).toLowerCase() === String(providerId).toLowerCase();
|
|
19308
|
+
}
|
|
19309
|
+
return true;
|
|
19310
|
+
}
|
|
19311
|
+
if (deviceName) {
|
|
19312
|
+
const lowerDevice = deviceName.toLowerCase();
|
|
19313
|
+
if (providerId) {
|
|
19314
|
+
const lowerProvider = String(providerId).toLowerCase();
|
|
19315
|
+
return lowerDevice.includes(lowerProvider) || isExplicitCustodialRole && lowerDevice.includes("custodian");
|
|
19316
|
+
}
|
|
19317
|
+
if (lowerDevice.includes("custodian") || lowerDevice.includes("oauth2") || lowerDevice.includes("google") || lowerDevice.includes("github") || lowerDevice.startsWith("email-") || lowerDevice.includes("@")) {
|
|
19318
|
+
return true;
|
|
19319
|
+
}
|
|
19320
|
+
}
|
|
19321
|
+
if (!providerId && isExplicitCustodialRole) {
|
|
19322
|
+
return true;
|
|
19323
|
+
}
|
|
19324
|
+
return false;
|
|
19325
|
+
}
|
|
19280
19326
|
|
|
19281
19327
|
// ../../libs/core-gib/dist/keystone/strategy/hash-reveal-v1/hash-reveal-v1.mjs
|
|
19282
19328
|
var KeystoneStrategy_HashRevealV1 = class _KeystoneStrategy_HashRevealV1 extends KeystoneStrategy {
|
|
@@ -20437,7 +20483,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20437
20483
|
/**
|
|
20438
20484
|
* Creates a brand new Keystone Identity Timeline.
|
|
20439
20485
|
*/
|
|
20440
|
-
async genesis({ masterSecret, emails, frameDetails, configs, metaspace, space, isPrimary }) {
|
|
20486
|
+
async genesis({ masterSecret, emails, frameDetails, credentialIds, dataToPatch, configs, metaspace, space, isPrimary }) {
|
|
20441
20487
|
const lc2 = `${this.lc}[${this.genesis.name}]`;
|
|
20442
20488
|
try {
|
|
20443
20489
|
if (logalot46) {
|
|
@@ -20462,12 +20508,18 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20462
20508
|
if (emails && emails.length > 0) {
|
|
20463
20509
|
data.emails = [...emails];
|
|
20464
20510
|
}
|
|
20511
|
+
if (credentialIds && credentialIds.length > 0) {
|
|
20512
|
+
data.credentialIds = [...credentialIds];
|
|
20513
|
+
}
|
|
20465
20514
|
if (frameDetails || isPrimary !== void 0) {
|
|
20466
20515
|
data.frameDetails = { ...frameDetails || {} };
|
|
20467
20516
|
if (isPrimary !== void 0) {
|
|
20468
20517
|
data.frameDetails.isPrimary = isPrimary;
|
|
20469
20518
|
}
|
|
20470
20519
|
}
|
|
20520
|
+
if (dataToPatch) {
|
|
20521
|
+
Object.assign(data, dataToPatch);
|
|
20522
|
+
}
|
|
20471
20523
|
const keystoneIbGib = await createKeystoneIbGibImpl({ data, metaspace, space });
|
|
20472
20524
|
return keystoneIbGib;
|
|
20473
20525
|
} catch (error) {
|
|
@@ -20580,12 +20632,15 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20580
20632
|
* to the parent's `delegates` map. This operation is signed using the parent's `manage` pool.
|
|
20581
20633
|
* Validates the delegate keystone's entire graph/timeline before registering.
|
|
20582
20634
|
*/
|
|
20583
|
-
async registerDelegate({ parentKeystone, delegateKeystone, masterSecret, frameDetails, metaspace, space, allowedVerbs, deviceName, expirationUTC, ttlSeconds }) {
|
|
20635
|
+
async registerDelegate({ parentKeystone, delegateKeystone, masterSecret, signingPoolId, frameDetails, metaspace, space, allowedVerbs, deviceName, expirationUTC, ttlSeconds }) {
|
|
20584
20636
|
const lc2 = `${this.lc}[${this.registerDelegate.name}]`;
|
|
20585
20637
|
try {
|
|
20586
20638
|
if (logalot46) {
|
|
20587
20639
|
console.log(`${lc2} starting...`);
|
|
20588
20640
|
}
|
|
20641
|
+
if (!signingPoolId) {
|
|
20642
|
+
throw new Error(`signingPoolId is required (E: a1b2c3d4e5f6818fa8ab28c9b60e6899)`);
|
|
20643
|
+
}
|
|
20589
20644
|
const validationErrors = await validateKeystoneGraph({
|
|
20590
20645
|
keystoneIbGib: delegateKeystone,
|
|
20591
20646
|
getLatest: true,
|
|
@@ -20596,9 +20651,14 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20596
20651
|
throw new Error(`Delegate keystone validation failed: ${validationErrors.join(", ")} (E: 88fa8ab28c9b60e68994511a5825)`);
|
|
20597
20652
|
}
|
|
20598
20653
|
const prevData = parentKeystone.data;
|
|
20599
|
-
const
|
|
20600
|
-
if (!
|
|
20601
|
-
throw new Error(`Parent keystone does not
|
|
20654
|
+
const signingPool = prevData.challengePools.find((p) => p.id === signingPoolId);
|
|
20655
|
+
if (!signingPool) {
|
|
20656
|
+
throw new Error(`Parent keystone does not contain signing pool: ${signingPoolId} (E: 818fa8ab28c9b60e68994511a5825)`);
|
|
20657
|
+
}
|
|
20658
|
+
if (signingPool.config.allowedVerbs && signingPool.config.allowedVerbs.length > 0) {
|
|
20659
|
+
if (!signingPool.config.allowedVerbs.includes(KEYSTONE_VERB_MANAGE)) {
|
|
20660
|
+
throw new Error(`Signing pool ${signingPoolId} is not authorized for verb: ${KEYSTONE_VERB_MANAGE} (E: 918fa8ab28c9b60e68994511a5825)`);
|
|
20661
|
+
}
|
|
20602
20662
|
}
|
|
20603
20663
|
const delegateTjpAddr = getTjpAddr({ ibGib: delegateKeystone });
|
|
20604
20664
|
if (!delegateTjpAddr) {
|
|
@@ -20618,13 +20678,14 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20618
20678
|
deviceName,
|
|
20619
20679
|
allowedVerbs,
|
|
20620
20680
|
spaceId,
|
|
20621
|
-
expirationUTC: effectiveExpirationUTC
|
|
20681
|
+
expirationUTC: effectiveExpirationUTC,
|
|
20682
|
+
role: delegateKeystone.data?.frameDetails?.role
|
|
20622
20683
|
};
|
|
20623
20684
|
const evolved = await this.sign({
|
|
20624
20685
|
latestKeystone: parentKeystone,
|
|
20625
20686
|
masterSecret,
|
|
20626
20687
|
claim,
|
|
20627
|
-
poolId:
|
|
20688
|
+
poolId: signingPoolId,
|
|
20628
20689
|
frameDetails,
|
|
20629
20690
|
metaspace,
|
|
20630
20691
|
space,
|
|
@@ -20644,18 +20705,26 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20644
20705
|
}
|
|
20645
20706
|
/**
|
|
20646
20707
|
* Unregisters a delegate keystone from the parent keystone by removing its entry
|
|
20647
|
-
* from the parent's `delegates` map.
|
|
20708
|
+
* from the parent's `delegates` map.
|
|
20648
20709
|
*/
|
|
20649
|
-
async unregisterDelegate({ parentKeystone, delegateTjpAddr, masterSecret, frameDetails, metaspace, space }) {
|
|
20710
|
+
async unregisterDelegate({ parentKeystone, delegateTjpAddr, masterSecret, signingPoolId, frameDetails, metaspace, space }) {
|
|
20650
20711
|
const lc2 = `${this.lc}[${this.unregisterDelegate.name}]`;
|
|
20651
20712
|
try {
|
|
20652
20713
|
if (logalot46) {
|
|
20653
20714
|
console.log(`${lc2} starting...`);
|
|
20654
20715
|
}
|
|
20716
|
+
if (!signingPoolId) {
|
|
20717
|
+
throw new Error(`signingPoolId is required (E: b2c3d4e5f6a13889f8ab28c9b60e6899)`);
|
|
20718
|
+
}
|
|
20655
20719
|
const prevData = parentKeystone.data;
|
|
20656
|
-
const
|
|
20657
|
-
if (!
|
|
20658
|
-
throw new Error(`Parent keystone does not
|
|
20720
|
+
const signingPool = prevData.challengePools.find((p) => p.id === signingPoolId);
|
|
20721
|
+
if (!signingPool) {
|
|
20722
|
+
throw new Error(`Parent keystone does not contain signing pool: ${signingPoolId} (E: 3889f8ab28c9b60e68994511a5825)`);
|
|
20723
|
+
}
|
|
20724
|
+
if (signingPool.config.allowedVerbs && signingPool.config.allowedVerbs.length > 0) {
|
|
20725
|
+
if (!signingPool.config.allowedVerbs.includes(KEYSTONE_VERB_MANAGE)) {
|
|
20726
|
+
throw new Error(`Signing pool ${signingPoolId} is not authorized for verb: ${KEYSTONE_VERB_MANAGE} (E: 4889f8ab28c9b60e68994511a5825)`);
|
|
20727
|
+
}
|
|
20659
20728
|
}
|
|
20660
20729
|
const claim = {
|
|
20661
20730
|
target: delegateTjpAddr,
|
|
@@ -20670,7 +20739,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20670
20739
|
latestKeystone: parentKeystone,
|
|
20671
20740
|
masterSecret,
|
|
20672
20741
|
claim,
|
|
20673
|
-
poolId:
|
|
20742
|
+
poolId: signingPoolId,
|
|
20674
20743
|
frameDetails,
|
|
20675
20744
|
metaspace,
|
|
20676
20745
|
space,
|
|
@@ -20753,7 +20822,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20753
20822
|
if (logalot46) {
|
|
20754
20823
|
console.log(`${lc2} starting...`);
|
|
20755
20824
|
}
|
|
20756
|
-
const latestAddr = await metaspace.getLatestAddr({
|
|
20825
|
+
const latestAddr = await metaspace.getLatestAddr({ addr, space });
|
|
20757
20826
|
if (!latestAddr) {
|
|
20758
20827
|
throw new Error(`could not find latest addr for ${addr}`);
|
|
20759
20828
|
}
|
|
@@ -20891,7 +20960,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20891
20960
|
* Requires the Master Secret to authorize the change via a pool containing
|
|
20892
20961
|
* the 'manage' verb.
|
|
20893
20962
|
*/
|
|
20894
|
-
async addPools({ latestKeystone, masterSecret, newPools, metaspace, space }) {
|
|
20963
|
+
async addPools({ latestKeystone, masterSecret, newPools, frameDetails, dataToPatch, metaspace, space }) {
|
|
20895
20964
|
const lc2 = `${this.lc}[${this.addPools.name}]`;
|
|
20896
20965
|
try {
|
|
20897
20966
|
if (logalot46) {
|
|
@@ -20947,7 +21016,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20947
21016
|
if (n % KEYSTONE_CHECKPOINT_FREQUENCY === 0) {
|
|
20948
21017
|
const currentFrameView = {
|
|
20949
21018
|
...latestKeystone,
|
|
20950
|
-
data: { ...prevData, challengePools: finalPools }
|
|
21019
|
+
data: { ...prevData, challengePools: finalPools, frameDetails }
|
|
20951
21020
|
};
|
|
20952
21021
|
checkpointDetails = await this.getAggregateDetails({
|
|
20953
21022
|
latestKeystone: currentFrameView,
|
|
@@ -20959,8 +21028,10 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20959
21028
|
challengePools: finalPools,
|
|
20960
21029
|
proofs: [proof],
|
|
20961
21030
|
// The proof authorizes the structure change
|
|
21031
|
+
frameDetails,
|
|
20962
21032
|
checkpointDetails,
|
|
20963
|
-
...prevData.delegates ? { delegates: prevData.delegates } : {}
|
|
21033
|
+
...prevData.delegates ? { delegates: prevData.delegates } : {},
|
|
21034
|
+
...dataToPatch
|
|
20964
21035
|
};
|
|
20965
21036
|
const newKeystone = await evolvePersistAndRegisterKeystone({
|
|
20966
21037
|
prevIbGib: latestKeystone,
|
|
@@ -20986,7 +21057,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
20986
21057
|
* Requires the Master Secret to authorize the change via a pool containing
|
|
20987
21058
|
* the 'manage' verb (the administrative manage pool).
|
|
20988
21059
|
*/
|
|
20989
|
-
async removePools({ latestKeystone, masterSecret, poolIds, metaspace, space }) {
|
|
21060
|
+
async removePools({ latestKeystone, masterSecret, poolIds, frameDetails, dataToPatch, metaspace, space }) {
|
|
20990
21061
|
const lc2 = `${this.lc}[${this.removePools.name}]`;
|
|
20991
21062
|
try {
|
|
20992
21063
|
if (logalot46) {
|
|
@@ -21040,7 +21111,7 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
21040
21111
|
if (n % KEYSTONE_CHECKPOINT_FREQUENCY === 0) {
|
|
21041
21112
|
const currentFrameView = {
|
|
21042
21113
|
...latestKeystone,
|
|
21043
|
-
data: { ...prevData, challengePools: finalPools }
|
|
21114
|
+
data: { ...prevData, challengePools: finalPools, frameDetails }
|
|
21044
21115
|
};
|
|
21045
21116
|
checkpointDetails = await this.getAggregateDetails({
|
|
21046
21117
|
latestKeystone: currentFrameView,
|
|
@@ -21051,8 +21122,10 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
21051
21122
|
const newData = {
|
|
21052
21123
|
challengePools: finalPools,
|
|
21053
21124
|
proofs: [proof],
|
|
21125
|
+
frameDetails,
|
|
21054
21126
|
checkpointDetails,
|
|
21055
|
-
...prevData.delegates ? { delegates: prevData.delegates } : {}
|
|
21127
|
+
...prevData.delegates ? { delegates: prevData.delegates } : {},
|
|
21128
|
+
...dataToPatch
|
|
21056
21129
|
};
|
|
21057
21130
|
const newKeystone = await evolvePersistAndRegisterKeystone({
|
|
21058
21131
|
prevIbGib: latestKeystone,
|
|
@@ -21104,10 +21177,12 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
21104
21177
|
}
|
|
21105
21178
|
const res = await metaspace.get({ addr: prevAddr, space });
|
|
21106
21179
|
if (!res.success || !res.ibGibs || res.ibGibs.length === 0) {
|
|
21107
|
-
|
|
21180
|
+
console.warn(`${lc2} Could not find previous keystone frame at ${prevAddr} (W: e3d069b22e11e550e58844889ddb5325). Returning aggregated details collected so far.`);
|
|
21181
|
+
break;
|
|
21108
21182
|
}
|
|
21109
21183
|
current = res.ibGibs[0];
|
|
21110
21184
|
}
|
|
21185
|
+
this.pruneTombstoneNulls(aggregated);
|
|
21111
21186
|
return aggregated;
|
|
21112
21187
|
} catch (error) {
|
|
21113
21188
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
@@ -21397,22 +21472,32 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
21397
21472
|
if ((poolIds ?? []).length === 0) {
|
|
21398
21473
|
const delegateSigningSecret = await deriveDelegateSecret({ masterSecret: signingSecret });
|
|
21399
21474
|
const delegateNewMasterSecret = await deriveDelegateSecret({ masterSecret: newMasterSecret });
|
|
21400
|
-
const
|
|
21401
|
-
for (const delegateTjpAddr of
|
|
21402
|
-
|
|
21403
|
-
|
|
21404
|
-
|
|
21405
|
-
|
|
21406
|
-
|
|
21407
|
-
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
|
|
21411
|
-
|
|
21412
|
-
|
|
21413
|
-
|
|
21475
|
+
const delegatesMap = latestKeystone.data.delegates ?? {};
|
|
21476
|
+
for (const [delegateTjpAddr, delegateInfo] of Object.entries(delegatesMap)) {
|
|
21477
|
+
if (isCustodialDelegate({ delegateInfo })) {
|
|
21478
|
+
if (logalot46) {
|
|
21479
|
+
console.log(`${lc2} Skipping custodial delegate rotation for ${delegateTjpAddr} (${delegateInfo.deviceName})`);
|
|
21480
|
+
}
|
|
21481
|
+
continue;
|
|
21482
|
+
}
|
|
21483
|
+
try {
|
|
21484
|
+
const { newKeystone: newDelegate, newDelegates: newDelegatesSecondOrder } = await this.changePassword({
|
|
21485
|
+
keystoneAddr: delegateTjpAddr,
|
|
21486
|
+
metaspace,
|
|
21487
|
+
space,
|
|
21488
|
+
newMasterSecret: delegateNewMasterSecret,
|
|
21489
|
+
signingSecret: delegateSigningSecret,
|
|
21490
|
+
signingPoolId,
|
|
21491
|
+
poolIds: void 0,
|
|
21492
|
+
frameDetails
|
|
21493
|
+
});
|
|
21494
|
+
if (newDelegatesSecondOrder && newDelegatesSecondOrder.length > 0) {
|
|
21495
|
+
throw new Error(`(UNEXPECTED) Delegate keystone has its own delegate(s)? ATOW (07/20/2026) second order delegates are not supported. (E: de45a7b7d9b8f61f6e58158269acba26)`);
|
|
21496
|
+
}
|
|
21497
|
+
newDelegates.push(newDelegate);
|
|
21498
|
+
} catch (delegateErr) {
|
|
21499
|
+
console.warn(`${lc2} Error rotating user delegate ${delegateTjpAddr}: ${extractErrorMsg(delegateErr)}. Continuing.`);
|
|
21414
21500
|
}
|
|
21415
|
-
newDelegates.push(newDelegate);
|
|
21416
21501
|
}
|
|
21417
21502
|
}
|
|
21418
21503
|
return { newKeystone: newKeystoneIbGib, newDelegates: newDelegates.length > 0 ? newDelegates : void 0 };
|
|
@@ -21429,20 +21514,55 @@ var KeystoneService_V1 = class _KeystoneService_V1 {
|
|
|
21429
21514
|
* Verifies if a candidate signing secret (password) is correct for a specific challenge pool.
|
|
21430
21515
|
* Does not mutate any state.
|
|
21431
21516
|
*/
|
|
21432
|
-
|
|
21517
|
+
/**
|
|
21518
|
+
* Verifies if a given secret successfully solves challenges in the specified pool
|
|
21519
|
+
* (or any candidate manage pool if poolId is omitted).
|
|
21520
|
+
*/
|
|
21521
|
+
async verifySigningSecret({ keystoneIbGib, signingSecret, poolId, verb = KEYSTONE_VERB_MANAGE }) {
|
|
21433
21522
|
const lc2 = `${this.lc}[${this.verifySigningSecret.name}]`;
|
|
21434
21523
|
try {
|
|
21435
21524
|
if (!keystoneIbGib.data)
|
|
21436
21525
|
return false;
|
|
21437
|
-
const
|
|
21438
|
-
if (
|
|
21439
|
-
|
|
21440
|
-
|
|
21526
|
+
const pools = keystoneIbGib.data.challengePools;
|
|
21527
|
+
if (poolId) {
|
|
21528
|
+
const pool = pools.find((p) => p.id === poolId);
|
|
21529
|
+
if (!pool)
|
|
21530
|
+
return false;
|
|
21531
|
+
return await verifyPoolSecret({ pool, signingSecret });
|
|
21532
|
+
}
|
|
21533
|
+
const candidatePools = pools.filter((p) => p.id === "manage" || p.id.startsWith("passkey-manage-") || p.config.allowedVerbs && verb && p.config.allowedVerbs.includes(verb));
|
|
21534
|
+
for (const candidate of candidatePools) {
|
|
21535
|
+
const isValid = await verifyPoolSecret({ pool: candidate, signingSecret });
|
|
21536
|
+
if (isValid) {
|
|
21537
|
+
return true;
|
|
21538
|
+
}
|
|
21539
|
+
}
|
|
21540
|
+
return false;
|
|
21441
21541
|
} catch (error) {
|
|
21442
21542
|
console.warn(`${lc2} Exception during verification: ${extractErrorMsg(error)}`);
|
|
21443
21543
|
return false;
|
|
21444
21544
|
}
|
|
21445
21545
|
}
|
|
21546
|
+
/**
|
|
21547
|
+
* Recursively prunes keys whose value is strictly `null` (tombstone records)
|
|
21548
|
+
* from aggregated detail maps/arrays.
|
|
21549
|
+
*/
|
|
21550
|
+
pruneTombstoneNulls(obj) {
|
|
21551
|
+
if (!obj || typeof obj !== "object") {
|
|
21552
|
+
return obj;
|
|
21553
|
+
}
|
|
21554
|
+
if (Array.isArray(obj)) {
|
|
21555
|
+
return obj.filter((item) => item !== null).map((item) => this.pruneTombstoneNulls(item));
|
|
21556
|
+
}
|
|
21557
|
+
for (const key of Object.keys(obj)) {
|
|
21558
|
+
if (obj[key] === null) {
|
|
21559
|
+
delete obj[key];
|
|
21560
|
+
} else if (typeof obj[key] === "object") {
|
|
21561
|
+
this.pruneTombstoneNulls(obj[key]);
|
|
21562
|
+
}
|
|
21563
|
+
}
|
|
21564
|
+
return obj;
|
|
21565
|
+
}
|
|
21446
21566
|
};
|
|
21447
21567
|
|
|
21448
21568
|
// ../../libs/node-gib/dist/email/verify/email-verify-helpers.mjs
|
|
@@ -21811,16 +21931,20 @@ function generateVerificationCode() {
|
|
|
21811
21931
|
const codeNum = Math.floor(1e5 + Math.random() * 9e5);
|
|
21812
21932
|
return codeNum.toString();
|
|
21813
21933
|
}
|
|
21814
|
-
async function savePendingCodeRecord({ pendingDir, code, maxAttempts = 5, ttlMs = DEFAULT_MAGIC_LINK_TTL_MS }) {
|
|
21934
|
+
async function savePendingCodeRecord({ pendingDir, code, maxAttempts = 5, ttlMs = DEFAULT_MAGIC_LINK_TTL_MS, resendCount = 0, attempts = 0 }) {
|
|
21815
21935
|
const codeHash = await hash({ s: `verificationcode${code}` });
|
|
21816
21936
|
const record = {
|
|
21817
21937
|
codeHash,
|
|
21818
|
-
|
|
21938
|
+
rawCode: code,
|
|
21939
|
+
attempts,
|
|
21819
21940
|
maxAttempts,
|
|
21820
|
-
expiresAt: Date.now() + ttlMs
|
|
21941
|
+
expiresAt: Date.now() + ttlMs,
|
|
21942
|
+
dispatchedAt: Date.now(),
|
|
21943
|
+
resendCount
|
|
21821
21944
|
};
|
|
21822
21945
|
const codeFilePath = path4.join(pendingDir, "code.json");
|
|
21823
21946
|
await fs2.writeFile(codeFilePath, JSON.stringify(record, null, 2), "utf-8");
|
|
21947
|
+
return record;
|
|
21824
21948
|
}
|
|
21825
21949
|
function createDefaultEmailSender() {
|
|
21826
21950
|
const rawMode = process.env.EMAIL_MODE;
|
|
@@ -22493,6 +22617,7 @@ function loadSsoServerConfig() {
|
|
|
22493
22617
|
|
|
22494
22618
|
// ../../libs/node-gib/dist/identity/sso/sso-custodian-service.mjs
|
|
22495
22619
|
import { createPublicKey, verify } from "node:crypto";
|
|
22620
|
+
var logalot49 = GLOBAL_LOG_A_LOT || true;
|
|
22496
22621
|
var SsoCustodianService = class _SsoCustodianService {
|
|
22497
22622
|
config;
|
|
22498
22623
|
lc = `[${_SsoCustodianService.name}]`;
|
|
@@ -22524,25 +22649,37 @@ var SsoCustodianService = class _SsoCustodianService {
|
|
|
22524
22649
|
* - Generator: Client/Server (Derived from environmental configuration and sent by client).
|
|
22525
22650
|
*/
|
|
22526
22651
|
async getOAuthUserInfo(providerId, code, redirectUri) {
|
|
22527
|
-
const lc2 =
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22652
|
+
const lc2 = `[${this.getOAuthUserInfo.name}]`;
|
|
22653
|
+
try {
|
|
22654
|
+
if (logalot49) {
|
|
22655
|
+
console.log(`${lc2} starting... (I: 3ad578b5065ec6d5517469571a4da826)`);
|
|
22656
|
+
}
|
|
22657
|
+
const providerConfig = this.config.providers[providerId];
|
|
22658
|
+
if (!providerConfig) {
|
|
22659
|
+
throw new Error(`Provider '${providerId}' is not configured on this server. (E: c28900abfefd23e89cf23f12)`);
|
|
22660
|
+
}
|
|
22661
|
+
console.log(`${lc2} Exchanging code for provider: ${providerId}`);
|
|
22662
|
+
const tokens = await this.exchangeCodeForTokens(providerConfig, code, redirectUri);
|
|
22663
|
+
if (providerId === "google") {
|
|
22664
|
+
if (!tokens.id_token) {
|
|
22665
|
+
throw new Error(`Google token exchange did not return id_token. (E: e28900abfefd23e89cf45f23)`);
|
|
22666
|
+
}
|
|
22667
|
+
return this.verifyAndNormalizeGoogleToken(tokens.id_token);
|
|
22668
|
+
} else if (providerId === "github") {
|
|
22669
|
+
if (!tokens.access_token) {
|
|
22670
|
+
throw new Error(`GitHub token exchange did not return access_token. (E: a28900abfefd23e89cf56f34)`);
|
|
22671
|
+
}
|
|
22672
|
+
return this.fetchAndNormalizeGithubUser(providerConfig, tokens.access_token);
|
|
22537
22673
|
}
|
|
22538
|
-
|
|
22539
|
-
}
|
|
22540
|
-
|
|
22541
|
-
|
|
22674
|
+
throw new Error(`Unsupported provider: ${providerId}. (E: d28900abfefd23e89cf67f45)`);
|
|
22675
|
+
} catch (error) {
|
|
22676
|
+
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
22677
|
+
throw error;
|
|
22678
|
+
} finally {
|
|
22679
|
+
if (logalot49) {
|
|
22680
|
+
console.log(`${lc2} complete.`);
|
|
22542
22681
|
}
|
|
22543
|
-
return this.fetchAndNormalizeGithubUser(providerConfig, tokens.access_token);
|
|
22544
22682
|
}
|
|
22545
|
-
throw new Error(`Unsupported provider: ${providerId}. (E: d28900abfefd23e89cf67f45)`);
|
|
22546
22683
|
}
|
|
22547
22684
|
/**
|
|
22548
22685
|
* Directly validates a Google ID Token (JWT) locally and returns normalized user info.
|
|
@@ -22799,62 +22936,75 @@ var SsoCustodianService = class _SsoCustodianService {
|
|
|
22799
22936
|
* - Generator: Client (Generated on user's device).
|
|
22800
22937
|
*/
|
|
22801
22938
|
async createCustodianChallengePool({ providerId, providerKey, userNonce, keystoneAddr, metaspace, space }) {
|
|
22802
|
-
const
|
|
22803
|
-
|
|
22804
|
-
|
|
22805
|
-
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
|
|
22809
|
-
|
|
22810
|
-
|
|
22811
|
-
|
|
22812
|
-
if (!userManagePool) {
|
|
22813
|
-
throw new Error(`Keystone manage pool not found. Custodian manage pool must match the user manage pool's security config. (E: 7c4e5f6a7b8c9d0e1f2a3b4c5e6f7a8b)`);
|
|
22814
|
-
}
|
|
22815
|
-
if (!providerId || !KEYSTONE_POOL_ID_REGEXP.test(providerId)) {
|
|
22816
|
-
throw new Error(`Invalid providerId: "${providerId}". Must match ${KEYSTONE_POOL_ID_REGEXP} (E: 3a2c4e5f6a7b8c9d0e1f2a3b4c5e6f)`);
|
|
22817
|
-
}
|
|
22818
|
-
const poolId = `custodian-manage-${providerId}`;
|
|
22819
|
-
const custodianSecret = await this.deriveServerDelegateSecret(providerKey, userNonce);
|
|
22820
|
-
const poolSalt = await hash({
|
|
22821
|
-
s: `${providerKey}:${userNonce}:salt`,
|
|
22822
|
-
algorithm: HashAlgorithm.sha_256
|
|
22823
|
-
});
|
|
22824
|
-
const poolSaltShort = poolSalt.substring(0, 16);
|
|
22825
|
-
const config = {
|
|
22826
|
-
...userManagePool.config,
|
|
22827
|
-
id: poolId,
|
|
22828
|
-
salt: poolSaltShort,
|
|
22829
|
-
allowedVerbs: [KEYSTONE_VERB_MANAGE, KEYSTONE_VERB_REVOKE]
|
|
22830
|
-
};
|
|
22831
|
-
const strategy = KeystoneStrategyFactory.create({ config });
|
|
22832
|
-
const poolSecret = await strategy.derivePoolSecret({ masterSecret: custodianSecret });
|
|
22833
|
-
const challenges = {};
|
|
22834
|
-
const timestamp = Date.now().toString();
|
|
22835
|
-
for (let i = 0; i < config.behavior.size; i++) {
|
|
22836
|
-
const challengeId = await generateOpaqueChallengeId({
|
|
22837
|
-
salt: config.salt,
|
|
22838
|
-
timestamp,
|
|
22839
|
-
index: i
|
|
22939
|
+
const lc2 = `[${this.createCustodianChallengePool.name}]`;
|
|
22940
|
+
try {
|
|
22941
|
+
if (logalot49) {
|
|
22942
|
+
console.log(`${lc2} starting... (I: 4238580990ff19dd2815d5186ffa0826)`);
|
|
22943
|
+
}
|
|
22944
|
+
const keystoneService = new KeystoneService_V1();
|
|
22945
|
+
const targetKeystone = await keystoneService.getLatestKeystone({
|
|
22946
|
+
addr: keystoneAddr,
|
|
22947
|
+
metaspace,
|
|
22948
|
+
space
|
|
22840
22949
|
});
|
|
22841
|
-
|
|
22842
|
-
|
|
22843
|
-
|
|
22844
|
-
|
|
22950
|
+
if (!targetKeystone) {
|
|
22951
|
+
throw new Error(`Keystone not found for address: ${keystoneAddr} (E: 8a9c2b1d3e5f6a7b8c9d0e1f2a3b4c5d)`);
|
|
22952
|
+
}
|
|
22953
|
+
const userManagePool = targetKeystone.data?.challengePools.find((p) => p.id === POOL_ID_MANAGE);
|
|
22954
|
+
if (!userManagePool) {
|
|
22955
|
+
throw new Error(`Keystone manage pool not found. Custodian manage pool must match the user manage pool's security config. (E: 7c4e5f6a7b8c9d0e1f2a3b4c5e6f7a8b)`);
|
|
22956
|
+
}
|
|
22957
|
+
if (!providerId || !KEYSTONE_POOL_ID_REGEXP.test(providerId)) {
|
|
22958
|
+
throw new Error(`Invalid providerId: "${providerId}". Must match ${KEYSTONE_POOL_ID_REGEXP} (E: 3a2c4e5f6a7b8c9d0e1f2a3b4c5e6f)`);
|
|
22959
|
+
}
|
|
22960
|
+
const poolId = `custodian-manage-${providerId}`;
|
|
22961
|
+
const custodianSecret = await this.deriveServerDelegateSecret(providerKey, userNonce);
|
|
22962
|
+
const poolSalt = await hash({
|
|
22963
|
+
s: `${providerKey}:${userNonce}:salt`,
|
|
22964
|
+
algorithm: HashAlgorithm.sha_256
|
|
22845
22965
|
});
|
|
22846
|
-
|
|
22847
|
-
|
|
22848
|
-
|
|
22849
|
-
|
|
22850
|
-
|
|
22851
|
-
|
|
22852
|
-
|
|
22853
|
-
|
|
22854
|
-
|
|
22855
|
-
|
|
22966
|
+
const poolSaltShort = poolSalt.substring(0, 16);
|
|
22967
|
+
const config = {
|
|
22968
|
+
...userManagePool.config,
|
|
22969
|
+
id: poolId,
|
|
22970
|
+
salt: poolSaltShort,
|
|
22971
|
+
allowedVerbs: [KEYSTONE_VERB_MANAGE, KEYSTONE_VERB_REVOKE]
|
|
22972
|
+
};
|
|
22973
|
+
const strategy = KeystoneStrategyFactory.create({ config });
|
|
22974
|
+
const poolSecret = await strategy.derivePoolSecret({ masterSecret: custodianSecret });
|
|
22975
|
+
const challenges = {};
|
|
22976
|
+
const timestamp = Date.now().toString();
|
|
22977
|
+
for (let i = 0; i < config.behavior.size; i++) {
|
|
22978
|
+
const challengeId = await generateOpaqueChallengeId({
|
|
22979
|
+
salt: config.salt,
|
|
22980
|
+
timestamp,
|
|
22981
|
+
index: i
|
|
22982
|
+
});
|
|
22983
|
+
const solution = await strategy.generateSolution({
|
|
22984
|
+
poolSecret,
|
|
22985
|
+
poolId: config.id,
|
|
22986
|
+
challengeId
|
|
22987
|
+
});
|
|
22988
|
+
challenges[challengeId] = await strategy.generateChallenge({ solution });
|
|
22856
22989
|
}
|
|
22857
|
-
|
|
22990
|
+
return {
|
|
22991
|
+
id: poolId,
|
|
22992
|
+
config,
|
|
22993
|
+
challenges,
|
|
22994
|
+
isForeign: true,
|
|
22995
|
+
metadata: {
|
|
22996
|
+
owner: "custodian",
|
|
22997
|
+
providerKey
|
|
22998
|
+
}
|
|
22999
|
+
};
|
|
23000
|
+
} catch (error) {
|
|
23001
|
+
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23002
|
+
throw error;
|
|
23003
|
+
} finally {
|
|
23004
|
+
if (logalot49) {
|
|
23005
|
+
console.log(`${lc2} complete.`);
|
|
23006
|
+
}
|
|
23007
|
+
}
|
|
22858
23008
|
}
|
|
22859
23009
|
/**
|
|
22860
23010
|
* Maps private server configuration to safe public client configurations.
|
|
@@ -22930,9 +23080,17 @@ var SsoCustodianService = class _SsoCustodianService {
|
|
|
22930
23080
|
}
|
|
22931
23081
|
}
|
|
22932
23082
|
};
|
|
23083
|
+
var ssoCustodianService;
|
|
23084
|
+
function getSsoCustodianService() {
|
|
23085
|
+
if (!ssoCustodianService) {
|
|
23086
|
+
const config = loadSsoServerConfig();
|
|
23087
|
+
ssoCustodianService = new SsoCustodianService(config);
|
|
23088
|
+
}
|
|
23089
|
+
return ssoCustodianService;
|
|
23090
|
+
}
|
|
22933
23091
|
|
|
22934
23092
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/keystone/keystone-evolve.handler.mjs
|
|
22935
|
-
var
|
|
23093
|
+
var logalot50 = GLOBAL_LOG_A_LOT;
|
|
22936
23094
|
var KeystoneEvolveHandler = class _KeystoneEvolveHandler extends ServeGibHandlerWithMetaspaceBase {
|
|
22937
23095
|
lc = `[${_KeystoneEvolveHandler.name}]`;
|
|
22938
23096
|
method = "PUT";
|
|
@@ -22942,7 +23100,11 @@ var KeystoneEvolveHandler = class _KeystoneEvolveHandler extends ServeGibHandler
|
|
|
22942
23100
|
if (match && match.length >= 3) {
|
|
22943
23101
|
const domainIb = decodeURIComponent(match[1]);
|
|
22944
23102
|
const domainGib = decodeURIComponent(match[2]);
|
|
22945
|
-
|
|
23103
|
+
let domainAddr = getIbGibAddr({ ib: domainIb, gib: domainGib });
|
|
23104
|
+
const { tjpGib } = getGibInfo({ ibGibAddr: domainAddr });
|
|
23105
|
+
if (tjpGib && domainIb) {
|
|
23106
|
+
domainAddr = `${domainIb}^${tjpGib}`;
|
|
23107
|
+
}
|
|
22946
23108
|
return {
|
|
22947
23109
|
domainAddr,
|
|
22948
23110
|
domainInfo: this.getDomainInfo({ domainAddr })
|
|
@@ -22957,7 +23119,7 @@ var KeystoneEvolveHandler = class _KeystoneEvolveHandler extends ServeGibHandler
|
|
|
22957
23119
|
async handleRouteImpl(reqCtx) {
|
|
22958
23120
|
const lc2 = `${this.lc}[handleRouteImpl]`;
|
|
22959
23121
|
try {
|
|
22960
|
-
if (
|
|
23122
|
+
if (logalot50) {
|
|
22961
23123
|
console.log(`${lc2} starting...`);
|
|
22962
23124
|
}
|
|
22963
23125
|
if (!reqCtx.params) {
|
|
@@ -23028,7 +23190,7 @@ var KeystoneEvolveHandler = class _KeystoneEvolveHandler extends ServeGibHandler
|
|
|
23028
23190
|
const removeInfo = claim.details.info;
|
|
23029
23191
|
if (removeInfo && Array.isArray(removeInfo.remove)) {
|
|
23030
23192
|
const config = loadSsoServerConfig();
|
|
23031
|
-
const
|
|
23193
|
+
const custodian = new SsoCustodianService(config);
|
|
23032
23194
|
for (const poolId of removeInfo.remove) {
|
|
23033
23195
|
if (poolId.startsWith("custodian-manage-")) {
|
|
23034
23196
|
const providerId = poolId.replace("custodian-manage-", "");
|
|
@@ -23036,7 +23198,7 @@ var KeystoneEvolveHandler = class _KeystoneEvolveHandler extends ServeGibHandler
|
|
|
23036
23198
|
const token = parsed.revokeTokens?.[providerId];
|
|
23037
23199
|
if (token) {
|
|
23038
23200
|
try {
|
|
23039
|
-
await
|
|
23201
|
+
await custodian.revokeToken(providerId, token);
|
|
23040
23202
|
} catch (e) {
|
|
23041
23203
|
console.warn(`${lc2} Failed to revoke token for provider ${providerId}: ${extractErrorMsg(e)}`);
|
|
23042
23204
|
}
|
|
@@ -23054,7 +23216,7 @@ var KeystoneEvolveHandler = class _KeystoneEvolveHandler extends ServeGibHandler
|
|
|
23054
23216
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23055
23217
|
return this.error(422, `Evolve validation/persistence failed: ${extractErrorMsg(error)}`);
|
|
23056
23218
|
} finally {
|
|
23057
|
-
if (
|
|
23219
|
+
if (logalot50) {
|
|
23058
23220
|
console.log(`${lc2} complete.`);
|
|
23059
23221
|
}
|
|
23060
23222
|
}
|
|
@@ -23062,7 +23224,7 @@ var KeystoneEvolveHandler = class _KeystoneEvolveHandler extends ServeGibHandler
|
|
|
23062
23224
|
};
|
|
23063
23225
|
|
|
23064
23226
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/keystone/keystone-post.handler.mjs
|
|
23065
|
-
var
|
|
23227
|
+
var logalot51 = GLOBAL_LOG_A_LOT;
|
|
23066
23228
|
var KeystonePostHandler = class _KeystonePostHandler extends ServeGibHandlerWithMetaspaceBase {
|
|
23067
23229
|
lc = `[${_KeystonePostHandler.name}]`;
|
|
23068
23230
|
method = "POST";
|
|
@@ -23092,7 +23254,7 @@ var KeystonePostHandler = class _KeystonePostHandler extends ServeGibHandlerWith
|
|
|
23092
23254
|
async handleRouteImpl(reqCtx) {
|
|
23093
23255
|
const lc2 = `[${this.handleRouteImpl.name}]`;
|
|
23094
23256
|
try {
|
|
23095
|
-
if (
|
|
23257
|
+
if (logalot51) {
|
|
23096
23258
|
console.log(`${lc2} starting... (I: 63bab8214834cb6e383e0fc364ee8826)`);
|
|
23097
23259
|
}
|
|
23098
23260
|
const { metaspace } = reqCtx;
|
|
@@ -23117,7 +23279,7 @@ var KeystonePostHandler = class _KeystonePostHandler extends ServeGibHandlerWith
|
|
|
23117
23279
|
console.error(emsg);
|
|
23118
23280
|
return this.error(500, emsg);
|
|
23119
23281
|
} finally {
|
|
23120
|
-
if (
|
|
23282
|
+
if (logalot51) {
|
|
23121
23283
|
console.log(`${lc2} complete.`);
|
|
23122
23284
|
}
|
|
23123
23285
|
}
|
|
@@ -23125,7 +23287,7 @@ var KeystonePostHandler = class _KeystonePostHandler extends ServeGibHandlerWith
|
|
|
23125
23287
|
};
|
|
23126
23288
|
|
|
23127
23289
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/keystone/keystone-get.handler.mjs
|
|
23128
|
-
var
|
|
23290
|
+
var logalot52 = GLOBAL_LOG_A_LOT;
|
|
23129
23291
|
var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMetaspaceBase {
|
|
23130
23292
|
lc = `[${_KeystoneGetHandler.name}]`;
|
|
23131
23293
|
method = "GET";
|
|
@@ -23133,7 +23295,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23133
23295
|
async parseParamsImpl(reqCtx) {
|
|
23134
23296
|
const lc2 = `${this.lc}[${this.parseParamsImpl.name}]`;
|
|
23135
23297
|
try {
|
|
23136
|
-
if (
|
|
23298
|
+
if (logalot52) {
|
|
23137
23299
|
console.log(`${lc2} starting...`);
|
|
23138
23300
|
}
|
|
23139
23301
|
const match = reqCtx.pathname.match(this.regex);
|
|
@@ -23150,7 +23312,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23150
23312
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23151
23313
|
throw error;
|
|
23152
23314
|
} finally {
|
|
23153
|
-
if (
|
|
23315
|
+
if (logalot52) {
|
|
23154
23316
|
console.log(`${lc2} complete.`);
|
|
23155
23317
|
}
|
|
23156
23318
|
}
|
|
@@ -23158,7 +23320,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23158
23320
|
async validateQueryParams({ queryParams }) {
|
|
23159
23321
|
const lc2 = `${this.lc}[${this.validateQueryParams.name}]`;
|
|
23160
23322
|
try {
|
|
23161
|
-
if (
|
|
23323
|
+
if (logalot52) {
|
|
23162
23324
|
console.log(`${lc2} starting... (I: f619e8121988498cd8e8928986663826)`);
|
|
23163
23325
|
}
|
|
23164
23326
|
const errors = [];
|
|
@@ -23183,7 +23345,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23183
23345
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23184
23346
|
throw error;
|
|
23185
23347
|
} finally {
|
|
23186
|
-
if (
|
|
23348
|
+
if (logalot52) {
|
|
23187
23349
|
console.log(`${lc2} complete.`);
|
|
23188
23350
|
}
|
|
23189
23351
|
}
|
|
@@ -23191,7 +23353,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23191
23353
|
async handleRouteImpl(reqCtx) {
|
|
23192
23354
|
const lc2 = `[${this.handleRouteImpl.name}]`;
|
|
23193
23355
|
try {
|
|
23194
|
-
if (
|
|
23356
|
+
if (logalot52) {
|
|
23195
23357
|
console.log(`${lc2} starting...`);
|
|
23196
23358
|
}
|
|
23197
23359
|
const { metaspace } = reqCtx;
|
|
@@ -23203,7 +23365,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23203
23365
|
throw new Error(`(UNEXPECTED) reqCtx.params.domainInfo falsy? at this point, we've passed canHandleRoute so this should be truthy (E: 5d3e96d9f8d8f65258d530af0e223826)`);
|
|
23204
23366
|
}
|
|
23205
23367
|
const { addr: domainAddr } = domainInfo;
|
|
23206
|
-
if (
|
|
23368
|
+
if (logalot52) {
|
|
23207
23369
|
console.log(`${lc2} domainAddr: ${domainAddr} (I: ea08786359e85481a89c77d84e8f0826)`);
|
|
23208
23370
|
}
|
|
23209
23371
|
const queryParams = {
|
|
@@ -23261,7 +23423,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23261
23423
|
console.error(emsg);
|
|
23262
23424
|
return this.error(500, emsg);
|
|
23263
23425
|
} finally {
|
|
23264
|
-
if (
|
|
23426
|
+
if (logalot52) {
|
|
23265
23427
|
console.log(`${lc2} complete.`);
|
|
23266
23428
|
}
|
|
23267
23429
|
}
|
|
@@ -23269,7 +23431,7 @@ var KeystoneGetHandler = class _KeystoneGetHandler extends ServeGibHandlerWithMe
|
|
|
23269
23431
|
};
|
|
23270
23432
|
|
|
23271
23433
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/keystone/keystone-lookup.handler.mjs
|
|
23272
|
-
var
|
|
23434
|
+
var logalot53 = GLOBAL_LOG_A_LOT2 || true;
|
|
23273
23435
|
var KeystoneLookupHandler = class _KeystoneLookupHandler extends ServeGibHandlerBase {
|
|
23274
23436
|
lc = `[${_KeystoneLookupHandler.name}]`;
|
|
23275
23437
|
method = "POST";
|
|
@@ -23292,11 +23454,11 @@ var KeystoneLookupHandler = class _KeystoneLookupHandler extends ServeGibHandler
|
|
|
23292
23454
|
return this.error(400, "Identifier is required");
|
|
23293
23455
|
}
|
|
23294
23456
|
const indexService = getIdentityIndexService();
|
|
23295
|
-
if (
|
|
23457
|
+
if (logalot53) {
|
|
23296
23458
|
console.log(`${lc2} identifier: ${identifier} (I: 1c417812d9781c5888090ae8d18d0826)`);
|
|
23297
23459
|
}
|
|
23298
23460
|
const record = await indexService.getEmailIndex({ email: identifier });
|
|
23299
|
-
if (
|
|
23461
|
+
if (logalot53) {
|
|
23300
23462
|
console.log(`${lc2} record: ${record ? pretty(record) : "undefined"} (I: 7c6ce86b3ad8e3a138991211b5ec5826)`);
|
|
23301
23463
|
}
|
|
23302
23464
|
if (!record) {
|
|
@@ -23368,15 +23530,7 @@ var KeystoneCheckEmailHandler = class _KeystoneCheckEmailHandler extends ServeGi
|
|
|
23368
23530
|
};
|
|
23369
23531
|
|
|
23370
23532
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/keystone/sso-config.handler.mjs
|
|
23371
|
-
var
|
|
23372
|
-
var custodian;
|
|
23373
|
-
function getCustodian() {
|
|
23374
|
-
if (!custodian) {
|
|
23375
|
-
const config = loadSsoServerConfig();
|
|
23376
|
-
custodian = new SsoCustodianService(config);
|
|
23377
|
-
}
|
|
23378
|
-
return custodian;
|
|
23379
|
-
}
|
|
23533
|
+
var logalot54 = GLOBAL_LOG_A_LOT;
|
|
23380
23534
|
var SsoConfigHandler = class _SsoConfigHandler extends ServeGibHandlerBase {
|
|
23381
23535
|
lc = `[${_SsoConfigHandler.name}]`;
|
|
23382
23536
|
method = "GET";
|
|
@@ -23395,10 +23549,10 @@ var SsoConfigHandler = class _SsoConfigHandler extends ServeGibHandlerBase {
|
|
|
23395
23549
|
async handleRouteImpl(reqCtx) {
|
|
23396
23550
|
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
23397
23551
|
try {
|
|
23398
|
-
if (
|
|
23552
|
+
if (logalot54) {
|
|
23399
23553
|
console.log(`${lc2} starting...`);
|
|
23400
23554
|
}
|
|
23401
|
-
const service =
|
|
23555
|
+
const service = getSsoCustodianService();
|
|
23402
23556
|
const hostUrl = `${reqCtx.protocol}://${reqCtx.headers.host}`;
|
|
23403
23557
|
const providers = service.getSsoClientConfigs(hostUrl);
|
|
23404
23558
|
return this.ok({
|
|
@@ -23410,7 +23564,7 @@ var SsoConfigHandler = class _SsoConfigHandler extends ServeGibHandlerBase {
|
|
|
23410
23564
|
console.error(`${lc2} Fetching SSO config failed: ${emsg}`);
|
|
23411
23565
|
return this.error(500, `SSO configuration retrieval failed: ${emsg}`);
|
|
23412
23566
|
} finally {
|
|
23413
|
-
if (
|
|
23567
|
+
if (logalot54) {
|
|
23414
23568
|
console.log(`${lc2} complete.`);
|
|
23415
23569
|
}
|
|
23416
23570
|
}
|
|
@@ -23425,44 +23579,134 @@ function isSsoProviderLinked({ keystone, providerId }) {
|
|
|
23425
23579
|
return keystone.data.challengePools.some((p) => p.id === targetPoolId);
|
|
23426
23580
|
}
|
|
23427
23581
|
|
|
23428
|
-
// ../../libs/node-gib/dist/
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23582
|
+
// ../../libs/node-gib/dist/identity/sso/custodian-auth-helpers.mjs
|
|
23583
|
+
async function deriveCustodianAuthCode({ custodianReqsOmitAuthCode, serverSecret }) {
|
|
23584
|
+
const lc2 = `[${deriveCustodianAuthCode.name}]`;
|
|
23585
|
+
try {
|
|
23586
|
+
if (!serverSecret) {
|
|
23587
|
+
throw new Error("serverSecret required for custodian auth code derivation (E: a1b2c3d4e5f67890123456789abcdef0)");
|
|
23588
|
+
}
|
|
23589
|
+
const salt = await hash({
|
|
23590
|
+
s: JSON.stringify(custodianReqsOmitAuthCode),
|
|
23591
|
+
algorithm: HashAlgorithm.sha_512
|
|
23592
|
+
});
|
|
23593
|
+
return await kdf_recursiveSaltWrap({
|
|
23594
|
+
masterSecret: serverSecret,
|
|
23595
|
+
salt,
|
|
23596
|
+
rounds: 1e3,
|
|
23597
|
+
algorithm: HashAlgorithm.sha_512
|
|
23598
|
+
});
|
|
23599
|
+
} catch (error) {
|
|
23600
|
+
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23601
|
+
throw error;
|
|
23435
23602
|
}
|
|
23436
|
-
return custodian2;
|
|
23437
23603
|
}
|
|
23438
|
-
|
|
23439
|
-
|
|
23440
|
-
|
|
23441
|
-
|
|
23442
|
-
|
|
23443
|
-
let parsed;
|
|
23444
|
-
try {
|
|
23445
|
-
parsed = JSON.parse(reqCtx.body);
|
|
23446
|
-
} catch {
|
|
23447
|
-
return void 0;
|
|
23604
|
+
async function generateCustodianRequirements({ primaryTjpAddr, ttlMs = 15 * 60 * 1e3, allowedVerbs = [KEYSTONE_VERB_SYNC, KEYSTONE_VERB_CONNECT], serverSecret }) {
|
|
23605
|
+
const lc2 = `[${generateCustodianRequirements.name}]`;
|
|
23606
|
+
try {
|
|
23607
|
+
if (!primaryTjpAddr) {
|
|
23608
|
+
throw new Error("primaryTjpAddr is required to generate custodian requirements (E: b2c3d4e5f67890123456789abcdef01)");
|
|
23448
23609
|
}
|
|
23449
|
-
|
|
23450
|
-
|
|
23451
|
-
return void 0;
|
|
23610
|
+
if (!serverSecret) {
|
|
23611
|
+
throw new Error("serverSecret is required to generate custodian requirements (E: c3d4e5f67890123456789abcdef012)");
|
|
23452
23612
|
}
|
|
23613
|
+
const nonce = await getUUID();
|
|
23614
|
+
const expiresAt = Date.now() + ttlMs;
|
|
23615
|
+
const custodianReqsOmitAuthCode = {
|
|
23616
|
+
primaryTjpAddr,
|
|
23617
|
+
nonce,
|
|
23618
|
+
expiresAt,
|
|
23619
|
+
allowedVerbs
|
|
23620
|
+
};
|
|
23621
|
+
const authCode = await deriveCustodianAuthCode({
|
|
23622
|
+
custodianReqsOmitAuthCode,
|
|
23623
|
+
serverSecret
|
|
23624
|
+
});
|
|
23453
23625
|
return {
|
|
23454
|
-
|
|
23455
|
-
|
|
23626
|
+
...custodianReqsOmitAuthCode,
|
|
23627
|
+
authCode
|
|
23456
23628
|
};
|
|
23629
|
+
} catch (error) {
|
|
23630
|
+
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23631
|
+
throw error;
|
|
23457
23632
|
}
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23462
|
-
|
|
23463
|
-
|
|
23464
|
-
|
|
23465
|
-
|
|
23633
|
+
}
|
|
23634
|
+
async function getAuthCustodianIndex({ custodianReqs }) {
|
|
23635
|
+
return await hash({
|
|
23636
|
+
s: JSON.stringify(custodianReqs),
|
|
23637
|
+
algorithm: HashAlgorithm.sha_256
|
|
23638
|
+
});
|
|
23639
|
+
}
|
|
23640
|
+
async function verifyCustodianRequirements({ custodianReqs, serverSecret }) {
|
|
23641
|
+
try {
|
|
23642
|
+
if (!custodianReqs || !custodianReqs.authCode || !custodianReqs.nonce || !custodianReqs.expiresAt || !custodianReqs.primaryTjpAddr) {
|
|
23643
|
+
return { valid: false, error: "Malformed custodian requirements structure. (E: d4e5f67890123456789abcdef0123)" };
|
|
23644
|
+
}
|
|
23645
|
+
if (Date.now() > custodianReqs.expiresAt) {
|
|
23646
|
+
return { valid: false, error: "Custodian requirements have expired. (E: e5f67890123456789abcdef01234)" };
|
|
23647
|
+
}
|
|
23648
|
+
const { authCode, ...custodianReqsOmitAuthCode } = custodianReqs;
|
|
23649
|
+
const expectedAuthCode = await deriveCustodianAuthCode({
|
|
23650
|
+
custodianReqsOmitAuthCode,
|
|
23651
|
+
serverSecret
|
|
23652
|
+
});
|
|
23653
|
+
if (authCode !== expectedAuthCode) {
|
|
23654
|
+
return { valid: false, error: "Cryptographic authCode mismatch. Requirement payload tampered or invalid. (E: f67890123456789abcdef012345)" };
|
|
23655
|
+
}
|
|
23656
|
+
return { valid: true };
|
|
23657
|
+
} catch (error) {
|
|
23658
|
+
return { valid: false, error: `Verification failed: ${extractErrorMsg(error)} (E: 7890123456789abcdef0123456)` };
|
|
23659
|
+
}
|
|
23660
|
+
}
|
|
23661
|
+
|
|
23662
|
+
// ../../libs/node-gib/dist/serve-gib/handlers/api/keystone/sso-link.handler.mjs
|
|
23663
|
+
var logalot55 = GLOBAL_LOG_A_LOT || true;
|
|
23664
|
+
var SsoLinkHandler = class _SsoLinkHandler extends ServeGibHandlerWithMetaspaceBase {
|
|
23665
|
+
lc = `[${_SsoLinkHandler.name}]`;
|
|
23666
|
+
method = "POST";
|
|
23667
|
+
regex = API_PATH_REGEXES.IDENTITY_SSO_LINK;
|
|
23668
|
+
async parseParamsImpl(reqCtx) {
|
|
23669
|
+
const lc2 = `${this.lc}[${this.parseParamsImpl.name}]`;
|
|
23670
|
+
try {
|
|
23671
|
+
if (logalot55) {
|
|
23672
|
+
console.log(`${lc2} starting... (I: a38f2cee647c127b48ec6ad1e8d1e826)`);
|
|
23673
|
+
}
|
|
23674
|
+
let parsed;
|
|
23675
|
+
try {
|
|
23676
|
+
parsed = JSON.parse(reqCtx.body);
|
|
23677
|
+
} catch {
|
|
23678
|
+
return void 0;
|
|
23679
|
+
}
|
|
23680
|
+
let parentTjpAddr = parsed?.parentTjpAddr;
|
|
23681
|
+
if (!parentTjpAddr) {
|
|
23682
|
+
return void 0;
|
|
23683
|
+
}
|
|
23684
|
+
const { ib } = getIbAndGib({ ibGibAddr: parentTjpAddr });
|
|
23685
|
+
const { tjpGib } = getGibInfo({ ibGibAddr: parentTjpAddr });
|
|
23686
|
+
if (tjpGib && ib) {
|
|
23687
|
+
parentTjpAddr = `${ib}^${tjpGib}`;
|
|
23688
|
+
}
|
|
23689
|
+
return {
|
|
23690
|
+
parentTjpAddr,
|
|
23691
|
+
domainInfo: this.getDomainInfo({ domainAddr: parentTjpAddr })
|
|
23692
|
+
};
|
|
23693
|
+
} catch (error) {
|
|
23694
|
+
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23695
|
+
throw error;
|
|
23696
|
+
} finally {
|
|
23697
|
+
if (logalot55) {
|
|
23698
|
+
console.log(`${lc2} complete.`);
|
|
23699
|
+
}
|
|
23700
|
+
}
|
|
23701
|
+
}
|
|
23702
|
+
async validateQueryParams({ queryParams }) {
|
|
23703
|
+
return [];
|
|
23704
|
+
}
|
|
23705
|
+
async handleRouteImpl(reqCtx) {
|
|
23706
|
+
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
23707
|
+
try {
|
|
23708
|
+
if (logalot55) {
|
|
23709
|
+
console.log(`${lc2} starting... (I: 8a4c1f930e7b2d5a6c1e9f8a3b5c7d1e)`);
|
|
23466
23710
|
}
|
|
23467
23711
|
if (!reqCtx.params) {
|
|
23468
23712
|
return this.error(400, "Invalid parameters: parentTjpAddr missing (E: c9f1a2b3d4e5f60718293a4b5c6d7e8f)");
|
|
@@ -23476,10 +23720,18 @@ var SsoLinkHandler = class _SsoLinkHandler extends ServeGibHandlerWithMetaspaceB
|
|
|
23476
23720
|
} catch {
|
|
23477
23721
|
return this.error(400, "Request body must be valid JSON (E: e1b2c3d4e5f67890a1b2c3d4e5f67890)");
|
|
23478
23722
|
}
|
|
23479
|
-
|
|
23723
|
+
let { code, providerId, parentTjpAddr, userNonce, redirectUri } = parsed;
|
|
23480
23724
|
if (!code || !providerId || !parentTjpAddr || !userNonce || !redirectUri) {
|
|
23481
23725
|
return this.error(400, "Body missing required parameters (code, providerId, parentTjpAddr, userNonce, redirectUri) (E: f2c3d4e5f6789012a3b4c5d6e7f89012)");
|
|
23482
23726
|
}
|
|
23727
|
+
if (logalot55) {
|
|
23728
|
+
console.log(`${lc2} LinkBody parsed (I: 7525b8bd29c8504e989e918825d4e826)`);
|
|
23729
|
+
}
|
|
23730
|
+
const { ib } = getIbAndGib({ ibGibAddr: parentTjpAddr });
|
|
23731
|
+
const { tjpGib } = getGibInfo({ ibGibAddr: parentTjpAddr });
|
|
23732
|
+
if (tjpGib && ib) {
|
|
23733
|
+
parentTjpAddr = `${ib}^${tjpGib}`;
|
|
23734
|
+
}
|
|
23483
23735
|
const space = await reqCtx.metaspace.getLocalUserSpace({ lock: false });
|
|
23484
23736
|
if (!space) {
|
|
23485
23737
|
return this.error(500, "No local user space found in domain metaspace (E: 03d4e5f678901234b5c6d7e8f9012345)");
|
|
@@ -23493,10 +23745,20 @@ var SsoLinkHandler = class _SsoLinkHandler extends ServeGibHandlerWithMetaspaceB
|
|
|
23493
23745
|
if (!targetKeystone) {
|
|
23494
23746
|
return this.error(400, `Keystone not found for address: ${parentTjpAddr} (E: 14e5f67890123456c7d8e9f012345678)`);
|
|
23495
23747
|
}
|
|
23496
|
-
if (
|
|
23748
|
+
if (logalot55) {
|
|
23749
|
+
console.log(`${lc2} targetKeystone gotten. addr: ${getIbGibAddr({ ibGib: targetKeystone })}, pools: ${JSON.stringify(targetKeystone.data?.challengePools?.map((p) => p.id))}, frameDetails: ${JSON.stringify(targetKeystone.data?.frameDetails)} (I: 3d2068e16cb4da0428d601a7a74e3826)`);
|
|
23750
|
+
}
|
|
23751
|
+
const isLinked = isSsoProviderLinked({ keystone: targetKeystone, providerId });
|
|
23752
|
+
if (logalot55) {
|
|
23753
|
+
console.log(`${lc2} isSsoProviderLinked for ${providerId}: ${isLinked}`);
|
|
23754
|
+
}
|
|
23755
|
+
if (isLinked) {
|
|
23497
23756
|
return this.error(400, `SSO provider "${providerId}" is already linked to this keystone. (E: 25f6789012345678d9e0f12345678901)`);
|
|
23498
23757
|
}
|
|
23499
|
-
const service =
|
|
23758
|
+
const service = getSsoCustodianService();
|
|
23759
|
+
if (logalot55) {
|
|
23760
|
+
console.log(`${lc2} getSsoCustodianService returned (I: f7e0b290ed2a2dcde807ff2853016226)`);
|
|
23761
|
+
}
|
|
23500
23762
|
const userInfo = await service.getOAuthUserInfo(providerId, code, redirectUri);
|
|
23501
23763
|
if (userInfo.email) {
|
|
23502
23764
|
try {
|
|
@@ -23518,112 +23780,31 @@ var SsoLinkHandler = class _SsoLinkHandler extends ServeGibHandlerWithMetaspaceB
|
|
|
23518
23780
|
space
|
|
23519
23781
|
});
|
|
23520
23782
|
console.log(`${lc2} created custodian pool for: ${userInfo.providerKey} (I: 4718901234567890f1a2b34567890123)`);
|
|
23783
|
+
const ssoConfig = loadSsoServerConfig();
|
|
23784
|
+
const serverSecret = ssoConfig.ssoServerKdfSecret;
|
|
23785
|
+
const custodianReqs = await generateCustodianRequirements({
|
|
23786
|
+
primaryTjpAddr: parentTjpAddr,
|
|
23787
|
+
serverSecret
|
|
23788
|
+
});
|
|
23521
23789
|
return this.ok({
|
|
23522
23790
|
success: true,
|
|
23523
|
-
custodianPool
|
|
23791
|
+
custodianPool,
|
|
23792
|
+
custodianReqs
|
|
23524
23793
|
}, 200);
|
|
23525
23794
|
} catch (error) {
|
|
23526
23795
|
const emsg = extractErrorMsg(error);
|
|
23527
23796
|
console.error(`${lc2} Link failed: ${emsg} (E: 5829012345678901a2b3c45678901234)`);
|
|
23528
23797
|
return this.error(500, `Link failed: ${emsg} (E: 693a012345678901b2c3d45678901234)`);
|
|
23529
23798
|
} finally {
|
|
23530
|
-
if (
|
|
23799
|
+
if (logalot55) {
|
|
23531
23800
|
console.log(`${lc2} complete. (I: 7a4b123456789012c3d4e56789012345)`);
|
|
23532
23801
|
}
|
|
23533
23802
|
}
|
|
23534
23803
|
}
|
|
23535
23804
|
};
|
|
23536
23805
|
|
|
23537
|
-
// ../../libs/node-gib/dist/identity/sso/custodian-auth-helpers.mjs
|
|
23538
|
-
async function deriveCustodianAuthCode({ custodianReqsOmitAuthCode, serverSecret }) {
|
|
23539
|
-
const lc2 = `[${deriveCustodianAuthCode.name}]`;
|
|
23540
|
-
try {
|
|
23541
|
-
if (!serverSecret) {
|
|
23542
|
-
throw new Error("serverSecret required for custodian auth code derivation (E: a1b2c3d4e5f67890123456789abcdef0)");
|
|
23543
|
-
}
|
|
23544
|
-
const salt = await hash({
|
|
23545
|
-
s: JSON.stringify(custodianReqsOmitAuthCode),
|
|
23546
|
-
algorithm: HashAlgorithm.sha_512
|
|
23547
|
-
});
|
|
23548
|
-
return await kdf_recursiveSaltWrap({
|
|
23549
|
-
masterSecret: serverSecret,
|
|
23550
|
-
salt,
|
|
23551
|
-
rounds: 1e3,
|
|
23552
|
-
algorithm: HashAlgorithm.sha_512
|
|
23553
|
-
});
|
|
23554
|
-
} catch (error) {
|
|
23555
|
-
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23556
|
-
throw error;
|
|
23557
|
-
}
|
|
23558
|
-
}
|
|
23559
|
-
async function generateCustodianRequirements({ primaryTjpAddr, ttlMs = 15 * 60 * 1e3, allowedVerbs = [KEYSTONE_VERB_SYNC, KEYSTONE_VERB_CONNECT], serverSecret }) {
|
|
23560
|
-
const lc2 = `[${generateCustodianRequirements.name}]`;
|
|
23561
|
-
try {
|
|
23562
|
-
if (!primaryTjpAddr) {
|
|
23563
|
-
throw new Error("primaryTjpAddr is required to generate custodian requirements (E: b2c3d4e5f67890123456789abcdef01)");
|
|
23564
|
-
}
|
|
23565
|
-
if (!serverSecret) {
|
|
23566
|
-
throw new Error("serverSecret is required to generate custodian requirements (E: c3d4e5f67890123456789abcdef012)");
|
|
23567
|
-
}
|
|
23568
|
-
const nonce = await getUUID();
|
|
23569
|
-
const expiresAt = Date.now() + ttlMs;
|
|
23570
|
-
const custodianReqsOmitAuthCode = {
|
|
23571
|
-
primaryTjpAddr,
|
|
23572
|
-
nonce,
|
|
23573
|
-
expiresAt,
|
|
23574
|
-
allowedVerbs
|
|
23575
|
-
};
|
|
23576
|
-
const authCode = await deriveCustodianAuthCode({
|
|
23577
|
-
custodianReqsOmitAuthCode,
|
|
23578
|
-
serverSecret
|
|
23579
|
-
});
|
|
23580
|
-
return {
|
|
23581
|
-
...custodianReqsOmitAuthCode,
|
|
23582
|
-
authCode
|
|
23583
|
-
};
|
|
23584
|
-
} catch (error) {
|
|
23585
|
-
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
23586
|
-
throw error;
|
|
23587
|
-
}
|
|
23588
|
-
}
|
|
23589
|
-
async function getAuthCustodianIndex({ custodianReqs }) {
|
|
23590
|
-
return await hash({
|
|
23591
|
-
s: JSON.stringify(custodianReqs),
|
|
23592
|
-
algorithm: HashAlgorithm.sha_256
|
|
23593
|
-
});
|
|
23594
|
-
}
|
|
23595
|
-
async function verifyCustodianRequirements({ custodianReqs, serverSecret }) {
|
|
23596
|
-
try {
|
|
23597
|
-
if (!custodianReqs || !custodianReqs.authCode || !custodianReqs.nonce || !custodianReqs.expiresAt || !custodianReqs.primaryTjpAddr) {
|
|
23598
|
-
return { valid: false, error: "Malformed custodian requirements structure. (E: d4e5f67890123456789abcdef0123)" };
|
|
23599
|
-
}
|
|
23600
|
-
if (Date.now() > custodianReqs.expiresAt) {
|
|
23601
|
-
return { valid: false, error: "Custodian requirements have expired. (E: e5f67890123456789abcdef01234)" };
|
|
23602
|
-
}
|
|
23603
|
-
const { authCode, ...custodianReqsOmitAuthCode } = custodianReqs;
|
|
23604
|
-
const expectedAuthCode = await deriveCustodianAuthCode({
|
|
23605
|
-
custodianReqsOmitAuthCode,
|
|
23606
|
-
serverSecret
|
|
23607
|
-
});
|
|
23608
|
-
if (authCode !== expectedAuthCode) {
|
|
23609
|
-
return { valid: false, error: "Cryptographic authCode mismatch. Requirement payload tampered or invalid. (E: f67890123456789abcdef012345)" };
|
|
23610
|
-
}
|
|
23611
|
-
return { valid: true };
|
|
23612
|
-
} catch (error) {
|
|
23613
|
-
return { valid: false, error: `Verification failed: ${extractErrorMsg(error)} (E: 7890123456789abcdef0123456)` };
|
|
23614
|
-
}
|
|
23615
|
-
}
|
|
23616
|
-
|
|
23617
23806
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/keystone/sso-login.handler.mjs
|
|
23618
|
-
var
|
|
23619
|
-
var custodian3;
|
|
23620
|
-
function getCustodian3() {
|
|
23621
|
-
if (!custodian3) {
|
|
23622
|
-
const config = loadSsoServerConfig();
|
|
23623
|
-
custodian3 = new SsoCustodianService(config);
|
|
23624
|
-
}
|
|
23625
|
-
return custodian3;
|
|
23626
|
-
}
|
|
23807
|
+
var logalot56 = GLOBAL_LOG_A_LOT;
|
|
23627
23808
|
var SsoLoginHandler = class _SsoLoginHandler extends ServeGibHandlerBase {
|
|
23628
23809
|
lc = `[${_SsoLoginHandler.name}]`;
|
|
23629
23810
|
method = "POST";
|
|
@@ -23637,7 +23818,7 @@ var SsoLoginHandler = class _SsoLoginHandler extends ServeGibHandlerBase {
|
|
|
23637
23818
|
async handleRouteImpl(reqCtx) {
|
|
23638
23819
|
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
23639
23820
|
try {
|
|
23640
|
-
if (
|
|
23821
|
+
if (logalot56) {
|
|
23641
23822
|
console.log(`${lc2} starting... (I: 9b5d2a3c4e5f67890a1b2c3d4e5f6789)`);
|
|
23642
23823
|
}
|
|
23643
23824
|
if (reqCtx.method !== "POST") {
|
|
@@ -23656,7 +23837,7 @@ var SsoLoginHandler = class _SsoLoginHandler extends ServeGibHandlerBase {
|
|
|
23656
23837
|
if (!code || !providerId || !redirectUri) {
|
|
23657
23838
|
return this.error(400, "Body missing required parameters (code, providerId, redirectUri) (E: 2b2c3d4e5f678901b2c3d4e5f6789012)");
|
|
23658
23839
|
}
|
|
23659
|
-
const service =
|
|
23840
|
+
const service = getSsoCustodianService();
|
|
23660
23841
|
const userInfo = await service.getOAuthUserInfo(providerId, code, redirectUri);
|
|
23661
23842
|
if (!userInfo || !userInfo.email) {
|
|
23662
23843
|
return this.error(400, `No email address returned from SSO provider ${providerId} (E: 3c3d4e5f67890123c4d5e6f789012345)`);
|
|
@@ -23738,7 +23919,7 @@ var SsoLoginHandler = class _SsoLoginHandler extends ServeGibHandlerBase {
|
|
|
23738
23919
|
console.error(`${lc2} SSO login failed: ${emsg} (E: 4d5e6f7890123456e7f8901234567890)`);
|
|
23739
23920
|
return this.error(500, `SSO login failed: ${emsg}`);
|
|
23740
23921
|
} finally {
|
|
23741
|
-
if (
|
|
23922
|
+
if (logalot56) {
|
|
23742
23923
|
console.log(`${lc2} complete.`);
|
|
23743
23924
|
}
|
|
23744
23925
|
}
|
|
@@ -23747,7 +23928,7 @@ var SsoLoginHandler = class _SsoLoginHandler extends ServeGibHandlerBase {
|
|
|
23747
23928
|
|
|
23748
23929
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/identity/keystone-custodian-genesis.handler.mjs
|
|
23749
23930
|
import * as fs3 from "node:fs/promises";
|
|
23750
|
-
var
|
|
23931
|
+
var logalot57 = GLOBAL_LOG_A_LOT || true;
|
|
23751
23932
|
var KeystoneCustodianGenesisHandler = class _KeystoneCustodianGenesisHandler extends ServeGibHandlerBase {
|
|
23752
23933
|
lc = `[${_KeystoneCustodianGenesisHandler.name}]`;
|
|
23753
23934
|
method = "POST";
|
|
@@ -23755,7 +23936,7 @@ var KeystoneCustodianGenesisHandler = class _KeystoneCustodianGenesisHandler ext
|
|
|
23755
23936
|
async handleRouteImpl(reqCtx) {
|
|
23756
23937
|
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
23757
23938
|
try {
|
|
23758
|
-
if (
|
|
23939
|
+
if (logalot57) {
|
|
23759
23940
|
console.log(`${lc2} starting... (I: a123456789abcdef0123456789b0001)`);
|
|
23760
23941
|
}
|
|
23761
23942
|
if (reqCtx.method !== "POST") {
|
|
@@ -23894,7 +24075,7 @@ var KeystoneCustodianGenesisHandler = class _KeystoneCustodianGenesisHandler ext
|
|
|
23894
24075
|
console.error(`${lc2} ${emsg}`);
|
|
23895
24076
|
return this.error(500, emsg);
|
|
23896
24077
|
} finally {
|
|
23897
|
-
if (
|
|
24078
|
+
if (logalot57) {
|
|
23898
24079
|
console.log(`${lc2} complete.`);
|
|
23899
24080
|
}
|
|
23900
24081
|
}
|
|
@@ -23904,7 +24085,7 @@ var KeystoneCustodianGenesisHandler = class _KeystoneCustodianGenesisHandler ext
|
|
|
23904
24085
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/identity/keystone-custodian-register-delegate.handler.mjs
|
|
23905
24086
|
import * as fs4 from "fs/promises";
|
|
23906
24087
|
import * as path5 from "path";
|
|
23907
|
-
var
|
|
24088
|
+
var logalot58 = GLOBAL_LOG_A_LOT || true;
|
|
23908
24089
|
var KeystoneCustodianRegisterDelegateHandler = class _KeystoneCustodianRegisterDelegateHandler extends ServeGibHandlerBase {
|
|
23909
24090
|
lc = `[${_KeystoneCustodianRegisterDelegateHandler.name}]`;
|
|
23910
24091
|
method = "POST";
|
|
@@ -23913,7 +24094,7 @@ var KeystoneCustodianRegisterDelegateHandler = class _KeystoneCustodianRegisterD
|
|
|
23913
24094
|
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
23914
24095
|
let authFilePathToClean;
|
|
23915
24096
|
try {
|
|
23916
|
-
if (
|
|
24097
|
+
if (logalot58) {
|
|
23917
24098
|
console.log(`${lc2} starting... (I: a23456789abcdef0123456789c0001)`);
|
|
23918
24099
|
}
|
|
23919
24100
|
if (reqCtx.method !== "POST") {
|
|
@@ -23991,14 +24172,16 @@ var KeystoneCustodianRegisterDelegateHandler = class _KeystoneCustodianRegisterD
|
|
|
23991
24172
|
return this.error(500, `Could not determine primary email for identity ${custodianReqs.primaryTjpAddr}`);
|
|
23992
24173
|
}
|
|
23993
24174
|
const primarySecret = await hash({ s: `${serverSecret}_custodian_${primaryEmail}` });
|
|
24175
|
+
const delegateDeviceName = delegateKeystone.data?.frameDetails?.deviceTag || frameDetails?.deviceTag || "client-delegate";
|
|
23994
24176
|
const evolvedPrimaryKeystone = await keystoneService.registerDelegate({
|
|
23995
24177
|
parentKeystone,
|
|
23996
24178
|
delegateKeystone,
|
|
23997
24179
|
masterSecret: primarySecret,
|
|
24180
|
+
signingPoolId: "manage",
|
|
23998
24181
|
metaspace,
|
|
23999
24182
|
space,
|
|
24000
24183
|
allowedVerbs: custodianReqs.allowedVerbs || [KEYSTONE_VERB_SYNC, KEYSTONE_VERB_CONNECT],
|
|
24001
|
-
deviceName:
|
|
24184
|
+
deviceName: delegateDeviceName
|
|
24002
24185
|
});
|
|
24003
24186
|
await metaspace.put({ ibGibs: [delegateKeystone], space });
|
|
24004
24187
|
await metaspace.registerNewIbGib({ ibGib: delegateKeystone, space });
|
|
@@ -24026,7 +24209,7 @@ var KeystoneCustodianRegisterDelegateHandler = class _KeystoneCustodianRegisterD
|
|
|
24026
24209
|
} catch {
|
|
24027
24210
|
}
|
|
24028
24211
|
}
|
|
24029
|
-
if (
|
|
24212
|
+
if (logalot58) {
|
|
24030
24213
|
console.log(`${lc2} complete.`);
|
|
24031
24214
|
}
|
|
24032
24215
|
}
|
|
@@ -24034,15 +24217,7 @@ var KeystoneCustodianRegisterDelegateHandler = class _KeystoneCustodianRegisterD
|
|
|
24034
24217
|
};
|
|
24035
24218
|
|
|
24036
24219
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/identity/keystone-custodian-add-master-password.handler.mjs
|
|
24037
|
-
var
|
|
24038
|
-
var custodian4;
|
|
24039
|
-
function getCustodian4() {
|
|
24040
|
-
if (!custodian4) {
|
|
24041
|
-
const config = loadSsoServerConfig();
|
|
24042
|
-
custodian4 = new SsoCustodianService(config);
|
|
24043
|
-
}
|
|
24044
|
-
return custodian4;
|
|
24045
|
-
}
|
|
24220
|
+
var logalot59 = GLOBAL_LOG_A_LOT || true;
|
|
24046
24221
|
var KeystoneCustodianAddMasterPasswordHandler = class _KeystoneCustodianAddMasterPasswordHandler extends ServeGibHandlerBase {
|
|
24047
24222
|
lc = `[${_KeystoneCustodianAddMasterPasswordHandler.name}]`;
|
|
24048
24223
|
method = "POST";
|
|
@@ -24050,7 +24225,7 @@ var KeystoneCustodianAddMasterPasswordHandler = class _KeystoneCustodianAddMaste
|
|
|
24050
24225
|
async handleRouteImpl(reqCtx) {
|
|
24051
24226
|
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
24052
24227
|
try {
|
|
24053
|
-
if (
|
|
24228
|
+
if (logalot59) {
|
|
24054
24229
|
console.log(`${lc2} starting... (I: 8a1b2c3d4e5f67890a1b2c3d4e5f6790)`);
|
|
24055
24230
|
}
|
|
24056
24231
|
if (reqCtx.method !== "POST") {
|
|
@@ -24078,7 +24253,7 @@ var KeystoneCustodianAddMasterPasswordHandler = class _KeystoneCustodianAddMaste
|
|
|
24078
24253
|
let verifiedEmail;
|
|
24079
24254
|
let effectiveProvider = providerId || "email";
|
|
24080
24255
|
if (providerId && code && redirectUri) {
|
|
24081
|
-
const service =
|
|
24256
|
+
const service = getSsoCustodianService();
|
|
24082
24257
|
const userInfo = await service.getOAuthUserInfo(providerId, code, redirectUri);
|
|
24083
24258
|
if (!userInfo || !userInfo.email) {
|
|
24084
24259
|
return this.error(401, `Failed to authenticate with SSO provider ${providerId} (E: 8a1b2c3d4e5f67890a1b2c3d4e5f6796)`);
|
|
@@ -24090,7 +24265,11 @@ var KeystoneCustodianAddMasterPasswordHandler = class _KeystoneCustodianAddMaste
|
|
|
24090
24265
|
}
|
|
24091
24266
|
verifiedEmail = normalizeEmail(email);
|
|
24092
24267
|
const tjpHash = await getPendingTjpHash(primaryTjpAddr);
|
|
24093
|
-
|
|
24268
|
+
let pendingInfo = reqCtx.dataDir && tjpHash ? await getPendingStagingDir({ dataDir: reqCtx.dataDir, tjpHash }) : void 0;
|
|
24269
|
+
if (!pendingInfo) {
|
|
24270
|
+
const emailTjpHash = await getPendingTjpHash(`pending:${verifiedEmail}`);
|
|
24271
|
+
pendingInfo = reqCtx.dataDir && emailTjpHash ? await getPendingStagingDir({ dataDir: reqCtx.dataDir, tjpHash: emailTjpHash }) : void 0;
|
|
24272
|
+
}
|
|
24094
24273
|
if (!pendingInfo || pendingInfo.isExpired) {
|
|
24095
24274
|
return this.error(400, "Verification record missing or expired. Please request a new verification code. (E: 8a1b2c3d4e5f67890a1b2c3d4e5f6798)");
|
|
24096
24275
|
}
|
|
@@ -24171,10 +24350,16 @@ var KeystoneCustodianAddMasterPasswordHandler = class _KeystoneCustodianAddMaste
|
|
|
24171
24350
|
});
|
|
24172
24351
|
await metaspace.put({ ibGibs: [evolvedKeystone], space });
|
|
24173
24352
|
await metaspace.registerNewIbGib({ ibGib: evolvedKeystone, space });
|
|
24353
|
+
const primaryGraph = await getDependencyGraph({
|
|
24354
|
+
ibGib: evolvedKeystone,
|
|
24355
|
+
space,
|
|
24356
|
+
live: false
|
|
24357
|
+
});
|
|
24174
24358
|
const response = {
|
|
24175
24359
|
success: true,
|
|
24176
24360
|
primaryTjpAddr,
|
|
24177
24361
|
primaryKeystone: evolvedKeystone,
|
|
24362
|
+
primaryGraph,
|
|
24178
24363
|
message: "Successfully elevated identity to sovereign master password"
|
|
24179
24364
|
};
|
|
24180
24365
|
return this.ok(response);
|
|
@@ -24364,7 +24549,10 @@ var EmailOutboundHandler = class _EmailOutboundHandler extends ServeGibHandlerBa
|
|
|
24364
24549
|
};
|
|
24365
24550
|
|
|
24366
24551
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/email/email-verification-code.handler.mjs
|
|
24367
|
-
|
|
24552
|
+
import * as path6 from "node:path";
|
|
24553
|
+
import * as fs5 from "node:fs/promises";
|
|
24554
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
24555
|
+
var logalot60 = GLOBAL_LOG_A_LOT || true;
|
|
24368
24556
|
var EmailVerificationCodeHandler = class _EmailVerificationCodeHandler extends ServeGibHandlerBase {
|
|
24369
24557
|
lc = `[${_EmailVerificationCodeHandler.name}]`;
|
|
24370
24558
|
method = "POST";
|
|
@@ -24378,10 +24566,10 @@ var EmailVerificationCodeHandler = class _EmailVerificationCodeHandler extends S
|
|
|
24378
24566
|
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
24379
24567
|
const timestampUUID = `${lc2}[${(await getUUID()).substring(0, 8)}]`;
|
|
24380
24568
|
try {
|
|
24381
|
-
if (
|
|
24569
|
+
if (logalot60) {
|
|
24382
24570
|
console.log(`${lc2} starting... (I: f123456789abcdef0123456789a0001)`);
|
|
24383
24571
|
}
|
|
24384
|
-
if (
|
|
24572
|
+
if (logalot60) {
|
|
24385
24573
|
console.time(timestampUUID);
|
|
24386
24574
|
}
|
|
24387
24575
|
if (reqCtx.method !== "POST") {
|
|
@@ -24396,17 +24584,18 @@ var EmailVerificationCodeHandler = class _EmailVerificationCodeHandler extends S
|
|
|
24396
24584
|
} catch {
|
|
24397
24585
|
return this.error(400, "Request body must be valid JSON (E: d2e3f4a5b67890123456789abcdef01)");
|
|
24398
24586
|
}
|
|
24399
|
-
if (
|
|
24587
|
+
if (logalot60) {
|
|
24400
24588
|
console.timeLog(timestampUUID, "parse complete");
|
|
24401
24589
|
}
|
|
24402
24590
|
const { email, primaryTjpAddr } = body;
|
|
24403
24591
|
if (!email || !validateEmail3(email)) {
|
|
24404
24592
|
return this.error(400, "Invalid email address format (E: e3f4a5b67890123456789abcdef012)");
|
|
24405
24593
|
}
|
|
24594
|
+
await delay(1e3 + Math.random() * 500);
|
|
24406
24595
|
const normEmail = normalizeEmail(email);
|
|
24407
24596
|
const effectivePrimaryTjpAddr = primaryTjpAddr || `pending:${normEmail}`;
|
|
24408
24597
|
const tjpHash = await getPendingTjpHash(effectivePrimaryTjpAddr);
|
|
24409
|
-
|
|
24598
|
+
let code = generateVerificationCode();
|
|
24410
24599
|
if (reqCtx.dataDir && tjpHash) {
|
|
24411
24600
|
let info = await getPendingStagingDir({ dataDir: reqCtx.dataDir, tjpHash });
|
|
24412
24601
|
if (!info) {
|
|
@@ -24418,9 +24607,44 @@ var EmailVerificationCodeHandler = class _EmailVerificationCodeHandler extends S
|
|
|
24418
24607
|
info = await getPendingStagingDir({ dataDir: reqCtx.dataDir, tjpHash });
|
|
24419
24608
|
}
|
|
24420
24609
|
if (info) {
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
|
|
24610
|
+
const codeFilePath = path6.join(info.pendingDir, "code.json");
|
|
24611
|
+
let existingRecord;
|
|
24612
|
+
if (existsSync6(codeFilePath)) {
|
|
24613
|
+
try {
|
|
24614
|
+
existingRecord = JSON.parse(await fs5.readFile(codeFilePath, "utf-8"));
|
|
24615
|
+
} catch {
|
|
24616
|
+
}
|
|
24617
|
+
}
|
|
24618
|
+
const now = Date.now();
|
|
24619
|
+
if (existingRecord) {
|
|
24620
|
+
const elapsedMs = now - (existingRecord.dispatchedAt || 0);
|
|
24621
|
+
if (elapsedMs < 3e4) {
|
|
24622
|
+
const remainingSecs = Math.ceil((3e4 - elapsedMs) / 1e3);
|
|
24623
|
+
return this.error(429, `Please wait ${remainingSecs}s before requesting another verification code.`);
|
|
24624
|
+
}
|
|
24625
|
+
if (existingRecord.resendCount >= 5 && now < existingRecord.expiresAt) {
|
|
24626
|
+
return this.error(429, "Too many verification code requests. Please wait 15 minutes before trying again.");
|
|
24627
|
+
}
|
|
24628
|
+
if (existingRecord.rawCode && now < existingRecord.expiresAt && existingRecord.attempts < existingRecord.maxAttempts) {
|
|
24629
|
+
code = existingRecord.rawCode;
|
|
24630
|
+
existingRecord.dispatchedAt = now;
|
|
24631
|
+
existingRecord.resendCount = (existingRecord.resendCount || 0) + 1;
|
|
24632
|
+
await fs5.writeFile(codeFilePath, JSON.stringify(existingRecord, null, 2), "utf-8");
|
|
24633
|
+
} else {
|
|
24634
|
+
code = generateVerificationCode();
|
|
24635
|
+
await savePendingCodeRecord({
|
|
24636
|
+
pendingDir: info.pendingDir,
|
|
24637
|
+
code,
|
|
24638
|
+
resendCount: (existingRecord.resendCount || 0) + 1,
|
|
24639
|
+
attempts: 0
|
|
24640
|
+
});
|
|
24641
|
+
}
|
|
24642
|
+
} else {
|
|
24643
|
+
code = generateVerificationCode();
|
|
24644
|
+
await savePendingCodeRecord({ pendingDir: info.pendingDir, code, resendCount: 0, attempts: 0 });
|
|
24645
|
+
}
|
|
24646
|
+
if (logalot60) {
|
|
24647
|
+
console.timeLog(timestampUUID, "code record processed in pending staging");
|
|
24424
24648
|
}
|
|
24425
24649
|
} else {
|
|
24426
24650
|
console.warn(`${lc2} Failed to create or access pending staging directory for tjpHash ${tjpHash}`);
|
|
@@ -24447,7 +24671,7 @@ If you did not request this, please ignore this email.`,
|
|
|
24447
24671
|
</div>`
|
|
24448
24672
|
};
|
|
24449
24673
|
const sendResult = await this.sender.sendEmail(outboundEmail);
|
|
24450
|
-
if (
|
|
24674
|
+
if (logalot60) {
|
|
24451
24675
|
console.timeLog(timestampUUID, "email send complete");
|
|
24452
24676
|
}
|
|
24453
24677
|
if (sendResult.success) {
|
|
@@ -24467,7 +24691,7 @@ If you did not request this, please ignore this email.`,
|
|
|
24467
24691
|
console.error(`${lc2} Magic link dispatch error: ${emsg} (E: 67890123456789abcdef0123456789a)`);
|
|
24468
24692
|
return this.error(500, `Magic link dispatch error: ${emsg}`);
|
|
24469
24693
|
} finally {
|
|
24470
|
-
if (
|
|
24694
|
+
if (logalot60) {
|
|
24471
24695
|
console.log(`${lc2} complete.`);
|
|
24472
24696
|
console.timeEnd(timestampUUID);
|
|
24473
24697
|
}
|
|
@@ -24476,10 +24700,10 @@ If you did not request this, please ignore this email.`,
|
|
|
24476
24700
|
};
|
|
24477
24701
|
|
|
24478
24702
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/email/email-verify-code-onetime.handler.mjs
|
|
24479
|
-
import * as
|
|
24480
|
-
import { existsSync as
|
|
24481
|
-
import * as
|
|
24482
|
-
var
|
|
24703
|
+
import * as fs6 from "node:fs/promises";
|
|
24704
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
24705
|
+
import * as path7 from "node:path";
|
|
24706
|
+
var logalot61 = GLOBAL_LOG_A_LOT || true;
|
|
24483
24707
|
var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends ServeGibHandlerBase {
|
|
24484
24708
|
lc = `[${_EmailVerifyCodeOnetimeHandler.name}]`;
|
|
24485
24709
|
method = "POST";
|
|
@@ -24488,10 +24712,10 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24488
24712
|
const lc2 = `${this.lc}[${this.handleRouteImpl.name}]`;
|
|
24489
24713
|
const timestampUUID = `${lc2}[${(await getUUID()).substring(0, 8)}]`;
|
|
24490
24714
|
try {
|
|
24491
|
-
if (
|
|
24715
|
+
if (logalot61) {
|
|
24492
24716
|
console.log(`${lc2} starting... (I: e123456789abcdef0123456789a0001)`);
|
|
24493
24717
|
}
|
|
24494
|
-
if (
|
|
24718
|
+
if (logalot61) {
|
|
24495
24719
|
console.time(timestampUUID);
|
|
24496
24720
|
}
|
|
24497
24721
|
if (reqCtx.method !== "POST") {
|
|
@@ -24506,7 +24730,7 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24506
24730
|
} catch {
|
|
24507
24731
|
return this.error(400, "Request body must be valid JSON (E: 123456789abcdef0123456789a0002)");
|
|
24508
24732
|
}
|
|
24509
|
-
if (
|
|
24733
|
+
if (logalot61) {
|
|
24510
24734
|
console.timeLog(timestampUUID, "parse complete");
|
|
24511
24735
|
}
|
|
24512
24736
|
const { email, primaryTjpAddr, code } = body;
|
|
@@ -24528,7 +24752,7 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24528
24752
|
dataDir: reqCtx.dataDir,
|
|
24529
24753
|
tjpHash
|
|
24530
24754
|
});
|
|
24531
|
-
if (
|
|
24755
|
+
if (logalot61) {
|
|
24532
24756
|
console.timeLog(timestampUUID, "pending staging lookup complete");
|
|
24533
24757
|
}
|
|
24534
24758
|
if (!pendingInfo || pendingInfo.isExpired) {
|
|
@@ -24550,7 +24774,7 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24550
24774
|
pendingDir,
|
|
24551
24775
|
code
|
|
24552
24776
|
});
|
|
24553
|
-
if (
|
|
24777
|
+
if (logalot61) {
|
|
24554
24778
|
console.timeLog(timestampUUID, "code verification check complete");
|
|
24555
24779
|
}
|
|
24556
24780
|
if (!codeVerifyResult.valid) {
|
|
@@ -24559,20 +24783,20 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24559
24783
|
console.error(`${lc2} Code verification failed for ${normEmail}: ${codeVerifyResult.error} (E: 123456789abcdef0123456789a0008)`);
|
|
24560
24784
|
return this.error(statusCode, codeVerifyResult.error || "Incorrect verification code.");
|
|
24561
24785
|
}
|
|
24562
|
-
const emailsDir =
|
|
24786
|
+
const emailsDir = path7.join(pendingDir, "emails");
|
|
24563
24787
|
const emailHash = await hash({ s: `emailindex${normEmail}` });
|
|
24564
|
-
const emailMetaPath =
|
|
24565
|
-
await
|
|
24566
|
-
if (
|
|
24788
|
+
const emailMetaPath = path7.join(emailsDir, `${emailHash}.json`);
|
|
24789
|
+
await fs6.writeFile(emailMetaPath, JSON.stringify({ email: normEmail, verified: true, verifiedAt: Date.now() }, null, 2), "utf-8");
|
|
24790
|
+
if (logalot61) {
|
|
24567
24791
|
console.timeLog(timestampUUID, "email metadata marked verified");
|
|
24568
24792
|
}
|
|
24569
|
-
const emailFiles = await
|
|
24793
|
+
const emailFiles = await fs6.readdir(emailsDir);
|
|
24570
24794
|
const verifiedEmails = [];
|
|
24571
24795
|
let allVerified = true;
|
|
24572
24796
|
for (const file of emailFiles) {
|
|
24573
24797
|
if (file.endsWith(".json")) {
|
|
24574
24798
|
try {
|
|
24575
|
-
const content = await
|
|
24799
|
+
const content = await fs6.readFile(path7.join(emailsDir, file), "utf-8");
|
|
24576
24800
|
const meta = JSON.parse(content);
|
|
24577
24801
|
if (meta.verified === true && meta.email) {
|
|
24578
24802
|
verifiedEmails.push(meta.email);
|
|
@@ -24585,14 +24809,14 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24585
24809
|
}
|
|
24586
24810
|
}
|
|
24587
24811
|
if (allVerified) {
|
|
24588
|
-
const keystonePath =
|
|
24589
|
-
if (
|
|
24812
|
+
const keystonePath = path7.join(pendingDir, "keystone.json");
|
|
24813
|
+
if (existsSync7(keystonePath)) {
|
|
24590
24814
|
try {
|
|
24591
|
-
const keystoneContent = await
|
|
24815
|
+
const keystoneContent = await fs6.readFile(keystonePath, "utf-8");
|
|
24592
24816
|
const keystone = JSON.parse(keystoneContent);
|
|
24593
24817
|
const addr = getIbGibAddr({ ibGib: keystone });
|
|
24594
24818
|
const metaspace = await bootstrapDomainMetaspace(addr, reqCtx.dataDir);
|
|
24595
|
-
if (
|
|
24819
|
+
if (logalot61) {
|
|
24596
24820
|
console.timeLog(timestampUUID, "domain metaspace bootstrap complete");
|
|
24597
24821
|
}
|
|
24598
24822
|
const space = await metaspace.getLocalUserSpace({ lock: false });
|
|
@@ -24600,7 +24824,7 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24600
24824
|
await metaspace.put({ ibGibs: [keystone], space });
|
|
24601
24825
|
await metaspace.registerNewIbGib({ ibGib: keystone, space });
|
|
24602
24826
|
}
|
|
24603
|
-
if (
|
|
24827
|
+
if (logalot61) {
|
|
24604
24828
|
console.timeLog(timestampUUID, "keystone promoted to domain space");
|
|
24605
24829
|
}
|
|
24606
24830
|
} catch (promoErr) {
|
|
@@ -24619,14 +24843,14 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24619
24843
|
}
|
|
24620
24844
|
}
|
|
24621
24845
|
}
|
|
24622
|
-
if (
|
|
24846
|
+
if (logalot61) {
|
|
24623
24847
|
console.timeLog(timestampUUID, "official email indices registered");
|
|
24624
24848
|
}
|
|
24625
24849
|
try {
|
|
24626
|
-
await
|
|
24850
|
+
await fs6.rm(pendingDir, { recursive: true, force: true });
|
|
24627
24851
|
} catch {
|
|
24628
24852
|
}
|
|
24629
|
-
if (
|
|
24853
|
+
if (logalot61) {
|
|
24630
24854
|
console.timeLog(timestampUUID, "pending staging directory cleaned");
|
|
24631
24855
|
}
|
|
24632
24856
|
console.log(`${lc2} 100% verification achieved via 6-digit code. Promoted identity & registered indices for ${primaryTjpAddr} (I: 123456789abcdef0123456789a0011)`);
|
|
@@ -24647,7 +24871,7 @@ var EmailVerifyCodeOnetimeHandler = class _EmailVerifyCodeOnetimeHandler extends
|
|
|
24647
24871
|
console.error(`${lc2} Error verifying code: ${emsg} (E: 123456789abcdef0123456789a0012)`);
|
|
24648
24872
|
return this.error(500, `Code verification error: ${emsg}`);
|
|
24649
24873
|
} finally {
|
|
24650
|
-
if (
|
|
24874
|
+
if (logalot61) {
|
|
24651
24875
|
console.log(`${lc2} complete.`);
|
|
24652
24876
|
console.timeEnd(timestampUUID);
|
|
24653
24877
|
}
|
|
@@ -24793,7 +25017,7 @@ var WebSocketFrameDecoder = class {
|
|
|
24793
25017
|
};
|
|
24794
25018
|
|
|
24795
25019
|
// ../../libs/node-gib/dist/serve-gib/handlers/api/debug/ws-echo.handler.mjs
|
|
24796
|
-
var
|
|
25020
|
+
var logalot62 = GLOBAL_LOG_A_LOT;
|
|
24797
25021
|
var lc = `[WsEchoHandler]`;
|
|
24798
25022
|
function canHandleWsUpgrade(req) {
|
|
24799
25023
|
const pathname = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
@@ -24802,7 +25026,7 @@ function canHandleWsUpgrade(req) {
|
|
|
24802
25026
|
function handleWsEchoUpgrade(req, socket, head) {
|
|
24803
25027
|
const lc_fn = `${lc}[handleWsEchoUpgrade]`;
|
|
24804
25028
|
try {
|
|
24805
|
-
if (
|
|
25029
|
+
if (logalot62) {
|
|
24806
25030
|
console.log(`${lc_fn} starting...`);
|
|
24807
25031
|
}
|
|
24808
25032
|
const ok = performConnect(req, socket);
|
|
@@ -24816,7 +25040,7 @@ function handleWsEchoUpgrade(req, socket, head) {
|
|
|
24816
25040
|
decoder.addChunk(data);
|
|
24817
25041
|
let frameText = decoder.nextFrame();
|
|
24818
25042
|
while (frameText !== null) {
|
|
24819
|
-
if (
|
|
25043
|
+
if (logalot62) {
|
|
24820
25044
|
console.log(`${lc_fn} echo: ${frameText}`);
|
|
24821
25045
|
}
|
|
24822
25046
|
socket.write(encodeTextFrame(JSON.stringify({ echo: frameText })));
|
|
@@ -24832,7 +25056,7 @@ function handleWsEchoUpgrade(req, socket, head) {
|
|
|
24832
25056
|
console.error(`${lc_fn} socket error: ${extractErrorMsg(error)}`);
|
|
24833
25057
|
});
|
|
24834
25058
|
socket.on("close", () => {
|
|
24835
|
-
if (
|
|
25059
|
+
if (logalot62) {
|
|
24836
25060
|
console.log(`${lc_fn} socket closed.`);
|
|
24837
25061
|
}
|
|
24838
25062
|
});
|
|
@@ -24840,7 +25064,7 @@ function handleWsEchoUpgrade(req, socket, head) {
|
|
|
24840
25064
|
console.error(`${lc_fn} ${extractErrorMsg(error)}`);
|
|
24841
25065
|
socket.destroy();
|
|
24842
25066
|
} finally {
|
|
24843
|
-
if (
|
|
25067
|
+
if (logalot62) {
|
|
24844
25068
|
console.log(`${lc_fn} complete.`);
|
|
24845
25069
|
}
|
|
24846
25070
|
}
|
|
@@ -24944,7 +25168,7 @@ var MergeTextStrategy = {
|
|
|
24944
25168
|
var MERGE_TEXT_STRATEGY_VALID_VALUES = Object.values(MergeTextStrategy);
|
|
24945
25169
|
|
|
24946
25170
|
// ../../libs/core-gib/dist/sync/graft-info/graft-info-helpers.mjs
|
|
24947
|
-
var
|
|
25171
|
+
var logalot63 = GLOBAL_LOG_A_LOT3;
|
|
24948
25172
|
async function getGraftInfoIb({ data }) {
|
|
24949
25173
|
if (!data.conflictStrategy) {
|
|
24950
25174
|
throw new Error(`(UNEXPECTED) data.conflictStrategy required for GraftInfoIb (E: 2c0968a0dac8d0ab3d67da9756d6df26)`);
|
|
@@ -24960,7 +25184,7 @@ async function getGraftInfoIb({ data }) {
|
|
|
24960
25184
|
async function createGraftInfo({ conflictStrategy, details, addlGraftDetails, latestCommonFrameAddr, baseAddrsSinceLCA, orphanAddrsSinceLCA, dnaAddrsApplied }) {
|
|
24961
25185
|
const lc2 = `[${createGraftInfo.name}]`;
|
|
24962
25186
|
try {
|
|
24963
|
-
if (
|
|
25187
|
+
if (logalot63) {
|
|
24964
25188
|
console.log(`${lc2} starting... (I: 0030f62cbae28cf5882f87981edc3826)`);
|
|
24965
25189
|
}
|
|
24966
25190
|
if (baseAddrsSinceLCA.length === 0) {
|
|
@@ -24995,7 +25219,7 @@ async function createGraftInfo({ conflictStrategy, details, addlGraftDetails, la
|
|
|
24995
25219
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
24996
25220
|
throw error;
|
|
24997
25221
|
} finally {
|
|
24998
|
-
if (
|
|
25222
|
+
if (logalot63) {
|
|
24999
25223
|
console.log(`${lc2} complete.`);
|
|
25000
25224
|
}
|
|
25001
25225
|
}
|
|
@@ -25070,7 +25294,7 @@ async function mergeTextByLongestCommonSubsequence({ textA, textB }) {
|
|
|
25070
25294
|
function isGraftInfo(ibGib) {
|
|
25071
25295
|
const lc2 = `[${isGraftInfo.name}]`;
|
|
25072
25296
|
try {
|
|
25073
|
-
if (
|
|
25297
|
+
if (logalot63) {
|
|
25074
25298
|
console.log(`${lc2} starting... (I: fe9adfe1a3175d87982507c8851f5826)`);
|
|
25075
25299
|
}
|
|
25076
25300
|
if (!ibGib) {
|
|
@@ -25084,19 +25308,19 @@ function isGraftInfo(ibGib) {
|
|
|
25084
25308
|
}
|
|
25085
25309
|
return true;
|
|
25086
25310
|
} catch (error) {
|
|
25087
|
-
if (
|
|
25311
|
+
if (logalot63) {
|
|
25088
25312
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25089
25313
|
}
|
|
25090
25314
|
return false;
|
|
25091
25315
|
} finally {
|
|
25092
|
-
if (
|
|
25316
|
+
if (logalot63) {
|
|
25093
25317
|
console.log(`${lc2} complete.`);
|
|
25094
25318
|
}
|
|
25095
25319
|
}
|
|
25096
25320
|
}
|
|
25097
25321
|
|
|
25098
25322
|
// ../../libs/core-gib/dist/sync/sync-helpers.mjs
|
|
25099
|
-
var
|
|
25323
|
+
var logalot64 = GLOBAL_LOG_A_LOT3;
|
|
25100
25324
|
async function getSyncIb({ data }) {
|
|
25101
25325
|
const lc2 = `[${getSyncIb.name}]`;
|
|
25102
25326
|
try {
|
|
@@ -25117,7 +25341,7 @@ async function getTempSpaceName() {
|
|
|
25117
25341
|
async function isPastFrame({ olderAddr, newerAddr, space }) {
|
|
25118
25342
|
const lc2 = `[${isPastFrame.name}]`;
|
|
25119
25343
|
try {
|
|
25120
|
-
if (
|
|
25344
|
+
if (logalot64) {
|
|
25121
25345
|
console.log(`${lc2} starting... (I: 4b3548cbc9a2eb749f447ed82fdcf826)`);
|
|
25122
25346
|
}
|
|
25123
25347
|
if (olderAddr === newerAddr) {
|
|
@@ -25152,7 +25376,7 @@ async function isPastFrame({ olderAddr, newerAddr, space }) {
|
|
|
25152
25376
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25153
25377
|
throw error;
|
|
25154
25378
|
} finally {
|
|
25155
|
-
if (
|
|
25379
|
+
if (logalot64) {
|
|
25156
25380
|
console.log(`${lc2} complete.`);
|
|
25157
25381
|
}
|
|
25158
25382
|
}
|
|
@@ -25185,7 +25409,7 @@ async function getSyncSagaFrameDependencyGraph({ sagaIbGib, localSpace }) {
|
|
|
25185
25409
|
async function getFullSyncSagaHistory({ sagaIbGib, space }) {
|
|
25186
25410
|
const lc2 = `[${getFullSyncSagaHistory.name}]`;
|
|
25187
25411
|
try {
|
|
25188
|
-
if (
|
|
25412
|
+
if (logalot64) {
|
|
25189
25413
|
console.log(`${lc2} starting... (I: 1ea3f804dd07d1e917a2afaaad497826)`);
|
|
25190
25414
|
}
|
|
25191
25415
|
if (!sagaIbGib.data) {
|
|
@@ -25203,7 +25427,7 @@ async function getFullSyncSagaHistory({ sagaIbGib, space }) {
|
|
|
25203
25427
|
if (resGet.success && resGet.ibGibs && resGet.ibGibs.length === 1) {
|
|
25204
25428
|
sagaFrame = resGet.ibGibs[0];
|
|
25205
25429
|
} else {
|
|
25206
|
-
if (
|
|
25430
|
+
if (logalot64) {
|
|
25207
25431
|
console.log(`${lc2} failed getting full history of sagaIbGib:
|
|
25208
25432
|
${pretty(sagaIbGib)} (I: 2a35685bfe038f63182c7db39b44c826)`);
|
|
25209
25433
|
}
|
|
@@ -25220,7 +25444,7 @@ ${pretty(sagaIbGib)} (I: 2a35685bfe038f63182c7db39b44c826)`);
|
|
|
25220
25444
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25221
25445
|
throw error;
|
|
25222
25446
|
} finally {
|
|
25223
|
-
if (
|
|
25447
|
+
if (logalot64) {
|
|
25224
25448
|
console.log(`${lc2} complete.`);
|
|
25225
25449
|
}
|
|
25226
25450
|
}
|
|
@@ -25228,7 +25452,7 @@ ${pretty(sagaIbGib)} (I: 2a35685bfe038f63182c7db39b44c826)`);
|
|
|
25228
25452
|
async function validateSyncSagaFrame({ sagaIbGib }) {
|
|
25229
25453
|
const lc2 = `[${validateSyncSagaFrame.name}]`;
|
|
25230
25454
|
try {
|
|
25231
|
-
if (
|
|
25455
|
+
if (logalot64) {
|
|
25232
25456
|
console.log(`${lc2} starting... (I: dac978e9ec5820f128fbbff817b82826)`);
|
|
25233
25457
|
}
|
|
25234
25458
|
const errors = await validateIbGibIntrinsically({ ibGib: sagaIbGib }) ?? [];
|
|
@@ -25279,7 +25503,7 @@ async function validateSyncSagaFrame({ sagaIbGib }) {
|
|
|
25279
25503
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25280
25504
|
throw error;
|
|
25281
25505
|
} finally {
|
|
25282
|
-
if (
|
|
25506
|
+
if (logalot64) {
|
|
25283
25507
|
console.log(`${lc2} complete.`);
|
|
25284
25508
|
}
|
|
25285
25509
|
}
|
|
@@ -25287,7 +25511,7 @@ async function validateSyncSagaFrame({ sagaIbGib }) {
|
|
|
25287
25511
|
async function validateFullSyncSagaHistory({ history }) {
|
|
25288
25512
|
const lc2 = `[${validateFullSyncSagaHistory.name}]`;
|
|
25289
25513
|
try {
|
|
25290
|
-
if (
|
|
25514
|
+
if (logalot64) {
|
|
25291
25515
|
console.log(`${lc2} starting... (I: df02b802f6989096b8d8f728e2c0a526)`);
|
|
25292
25516
|
}
|
|
25293
25517
|
console.error(`${lc2} NAG ERROR (NOT THROWN) need to implement more validation on full saga history. (E: 9bfcc9247a1c783fd361a4a8216fef26)`);
|
|
@@ -25296,7 +25520,7 @@ async function validateFullSyncSagaHistory({ history }) {
|
|
|
25296
25520
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25297
25521
|
throw error;
|
|
25298
25522
|
} finally {
|
|
25299
|
-
if (
|
|
25523
|
+
if (logalot64) {
|
|
25300
25524
|
console.log(`${lc2} complete.`);
|
|
25301
25525
|
}
|
|
25302
25526
|
}
|
|
@@ -25304,7 +25528,7 @@ async function validateFullSyncSagaHistory({ history }) {
|
|
|
25304
25528
|
async function putInSpace_dnasThenNonDnas({ ibGibs, space }) {
|
|
25305
25529
|
const lc2 = `[${putInSpace_dnasThenNonDnas.name}]`;
|
|
25306
25530
|
try {
|
|
25307
|
-
if (
|
|
25531
|
+
if (logalot64) {
|
|
25308
25532
|
console.log(`${lc2} starting... (I: aa3ab828402836b3914800a8ffa1b826)`);
|
|
25309
25533
|
}
|
|
25310
25534
|
const payload_Dnas = [];
|
|
@@ -25330,7 +25554,7 @@ async function putInSpace_dnasThenNonDnas({ ibGibs, space }) {
|
|
|
25330
25554
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25331
25555
|
throw error;
|
|
25332
25556
|
} finally {
|
|
25333
|
-
if (
|
|
25557
|
+
if (logalot64) {
|
|
25334
25558
|
console.log(`${lc2} complete.`);
|
|
25335
25559
|
}
|
|
25336
25560
|
}
|
|
@@ -25338,7 +25562,7 @@ async function putInSpace_dnasThenNonDnas({ ibGibs, space }) {
|
|
|
25338
25562
|
function getSyncSagaFrameOrigin({ sagaFrame }) {
|
|
25339
25563
|
const lc2 = `[${getSyncSagaFrameOrigin.name}]`;
|
|
25340
25564
|
try {
|
|
25341
|
-
if (
|
|
25565
|
+
if (logalot64) {
|
|
25342
25566
|
console.log(`${lc2} starting... (I: 93521332d0dd2f5e88398b7db95e8126)`);
|
|
25343
25567
|
}
|
|
25344
25568
|
if (!sagaFrame) {
|
|
@@ -25362,7 +25586,7 @@ function getSyncSagaFrameOrigin({ sagaFrame }) {
|
|
|
25362
25586
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25363
25587
|
throw error;
|
|
25364
25588
|
} finally {
|
|
25365
|
-
if (
|
|
25589
|
+
if (logalot64) {
|
|
25366
25590
|
console.log(`${lc2} complete.`);
|
|
25367
25591
|
}
|
|
25368
25592
|
}
|
|
@@ -25370,7 +25594,7 @@ function getSyncSagaFrameOrigin({ sagaFrame }) {
|
|
|
25370
25594
|
async function getFinalConflictsInfo({ sagaHistory }) {
|
|
25371
25595
|
const lc2 = `[${getFinalConflictsInfo.name}]`;
|
|
25372
25596
|
try {
|
|
25373
|
-
if (
|
|
25597
|
+
if (logalot64) {
|
|
25374
25598
|
console.log(`${lc2} starting... (I: fe93a8f29e5d8ab2c8bd0e08e56f7826)`);
|
|
25375
25599
|
}
|
|
25376
25600
|
const lastDeltaHistorySlice = sagaHistory.findLast((x) => x.msgStones.some((msgStone) => msgStone.data.stage === SyncStage.delta));
|
|
@@ -25387,7 +25611,7 @@ async function getFinalConflictsInfo({ sagaHistory }) {
|
|
|
25387
25611
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25388
25612
|
throw error;
|
|
25389
25613
|
} finally {
|
|
25390
|
-
if (
|
|
25614
|
+
if (logalot64) {
|
|
25391
25615
|
console.log(`${lc2} complete.`);
|
|
25392
25616
|
}
|
|
25393
25617
|
}
|
|
@@ -25395,12 +25619,12 @@ async function getFinalConflictsInfo({ sagaHistory }) {
|
|
|
25395
25619
|
async function getAllOrphanedAddresses({ sagaHistory, myTempSpace }) {
|
|
25396
25620
|
const lc2 = `[${getAllOrphanedAddresses.name}]`;
|
|
25397
25621
|
try {
|
|
25398
|
-
if (
|
|
25622
|
+
if (logalot64) {
|
|
25399
25623
|
console.log(`${lc2} starting... (I: b755627e99c9a221566d86a81b0da526)`);
|
|
25400
25624
|
}
|
|
25401
25625
|
const conflicts = await getFinalConflictsInfo({ sagaHistory });
|
|
25402
25626
|
if (!conflicts || conflicts.length === 0) {
|
|
25403
|
-
if (
|
|
25627
|
+
if (logalot64) {
|
|
25404
25628
|
console.log(`${lc2} no conflicts found. returning empty array (I: 5dce98010128a284c8ec92cd466a3826)`);
|
|
25405
25629
|
}
|
|
25406
25630
|
return [];
|
|
@@ -25435,7 +25659,7 @@ async function getAllOrphanedAddresses({ sagaHistory, myTempSpace }) {
|
|
|
25435
25659
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25436
25660
|
throw error;
|
|
25437
25661
|
} finally {
|
|
25438
|
-
if (
|
|
25662
|
+
if (logalot64) {
|
|
25439
25663
|
console.log(`${lc2} complete.`);
|
|
25440
25664
|
}
|
|
25441
25665
|
}
|
|
@@ -25443,7 +25667,7 @@ async function getAllOrphanedAddresses({ sagaHistory, myTempSpace }) {
|
|
|
25443
25667
|
async function deriveSessionSecret({ senderSecret, sagaId }) {
|
|
25444
25668
|
const lc2 = `[${deriveSessionSecret.name}]`;
|
|
25445
25669
|
try {
|
|
25446
|
-
if (
|
|
25670
|
+
if (logalot64) {
|
|
25447
25671
|
console.log(`${lc2} starting... (I: 0de03f8dcd3e32f1fca244e8f2a8a826)`);
|
|
25448
25672
|
}
|
|
25449
25673
|
if (!senderSecret) {
|
|
@@ -25466,14 +25690,14 @@ async function deriveSessionSecret({ senderSecret, sagaId }) {
|
|
|
25466
25690
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25467
25691
|
throw error;
|
|
25468
25692
|
} finally {
|
|
25469
|
-
if (
|
|
25693
|
+
if (logalot64) {
|
|
25470
25694
|
console.log(`${lc2} complete.`);
|
|
25471
25695
|
}
|
|
25472
25696
|
}
|
|
25473
25697
|
}
|
|
25474
25698
|
|
|
25475
25699
|
// ../../libs/core-gib/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs
|
|
25476
|
-
var
|
|
25700
|
+
var logalot65 = GLOBAL_LOG_A_LOT3;
|
|
25477
25701
|
async function getSyncSagaContextIb({ data }) {
|
|
25478
25702
|
const lc2 = `[${getSyncSagaContextIb.name}]`;
|
|
25479
25703
|
try {
|
|
@@ -25495,7 +25719,7 @@ async function getSyncSagaContextIb({ data }) {
|
|
|
25495
25719
|
async function validateContextAndSagaFrame({ context }) {
|
|
25496
25720
|
const lc2 = `[${validateContextAndSagaFrame.name}]`;
|
|
25497
25721
|
try {
|
|
25498
|
-
if (
|
|
25722
|
+
if (logalot65) {
|
|
25499
25723
|
console.log(`${lc2} starting... (I: 7797f8294bd8f7e5089cb722ad468226)`);
|
|
25500
25724
|
}
|
|
25501
25725
|
const errors = [];
|
|
@@ -25535,7 +25759,7 @@ async function validateContextAndSagaFrame({ context }) {
|
|
|
25535
25759
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25536
25760
|
throw error;
|
|
25537
25761
|
} finally {
|
|
25538
|
-
if (
|
|
25762
|
+
if (logalot65) {
|
|
25539
25763
|
console.log(`${lc2} complete.`);
|
|
25540
25764
|
}
|
|
25541
25765
|
}
|
|
@@ -25547,7 +25771,7 @@ async function authenticateContextIntrinsically({
|
|
|
25547
25771
|
}) {
|
|
25548
25772
|
const lc2 = `[${authenticateContextIntrinsically.name}]`;
|
|
25549
25773
|
try {
|
|
25550
|
-
if (
|
|
25774
|
+
if (logalot65) {
|
|
25551
25775
|
console.log(`${lc2} starting... (I: 3c34e8f1d6ef965f98725c88459ea926)`);
|
|
25552
25776
|
}
|
|
25553
25777
|
const errors = [];
|
|
@@ -25570,7 +25794,7 @@ async function authenticateContextIntrinsically({
|
|
|
25570
25794
|
errors.push("Context has no signed session identity, but context.rel8ns.sessionIdentity is truthy. (E: 96a04a8a6c88ea8bf88118f89ad8e326)");
|
|
25571
25795
|
return errors;
|
|
25572
25796
|
} else {
|
|
25573
|
-
if (
|
|
25797
|
+
if (logalot65) {
|
|
25574
25798
|
console.log(`${lc2} context has no signedSessionIdentity and sync saga frame doesn't state there should be session identity. So nothing further to authenticate - returning early with no authentication errors. (I: d708735f9a2899ee98f762b8a09ed826)`);
|
|
25575
25799
|
}
|
|
25576
25800
|
return [];
|
|
@@ -25725,14 +25949,14 @@ async function authenticateContextIntrinsically({
|
|
|
25725
25949
|
console.error(emsg);
|
|
25726
25950
|
return [`authentication produced an error: ${emsg} (E: 45e014b82af81993d936611ca6fc4d26)`];
|
|
25727
25951
|
} finally {
|
|
25728
|
-
if (
|
|
25952
|
+
if (logalot65) {
|
|
25729
25953
|
console.log(`${lc2} complete.`);
|
|
25730
25954
|
}
|
|
25731
25955
|
}
|
|
25732
25956
|
}
|
|
25733
25957
|
|
|
25734
25958
|
// ../../libs/core-gib/dist/sync/sync-peer/sync-peer-v1.mjs
|
|
25735
|
-
var
|
|
25959
|
+
var logalot66 = GLOBAL_LOG_A_LOT3;
|
|
25736
25960
|
var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
25737
25961
|
lc = `[${_SyncPeer_V1.name}]`;
|
|
25738
25962
|
opts;
|
|
@@ -25845,7 +26069,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25845
26069
|
async connect(opts) {
|
|
25846
26070
|
const lc2 = `${this.lc}[${this.connect.name}]`;
|
|
25847
26071
|
try {
|
|
25848
|
-
if (
|
|
26072
|
+
if (logalot66) {
|
|
25849
26073
|
console.log(`${lc2} starting... (I: ad89d8137351662fb8a30114a1fa4826)`);
|
|
25850
26074
|
}
|
|
25851
26075
|
await this.preConnectCheck(opts);
|
|
@@ -25854,7 +26078,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25854
26078
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25855
26079
|
throw error;
|
|
25856
26080
|
} finally {
|
|
25857
|
-
if (
|
|
26081
|
+
if (logalot66) {
|
|
25858
26082
|
console.log(`${lc2} complete.`);
|
|
25859
26083
|
}
|
|
25860
26084
|
}
|
|
@@ -25879,7 +26103,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25879
26103
|
async establishSessionIdentity() {
|
|
25880
26104
|
const lc2 = `${this.lc}[${this.establishSessionIdentity.name}]`;
|
|
25881
26105
|
try {
|
|
25882
|
-
if (
|
|
26106
|
+
if (logalot66) {
|
|
25883
26107
|
console.log(`${lc2} starting... (I: f2a1b3c4d5e6f7a8b9c0d1e2f3a4b526)`);
|
|
25884
26108
|
}
|
|
25885
26109
|
if (!this.opts) {
|
|
@@ -25887,7 +26111,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25887
26111
|
}
|
|
25888
26112
|
const { senderIdentity, fnSenderSecret, senderDomainAddr, sagaId, localMetaspace, localSpace } = this.opts;
|
|
25889
26113
|
if (!senderIdentity || !fnSenderSecret) {
|
|
25890
|
-
if (
|
|
26114
|
+
if (logalot66) {
|
|
25891
26115
|
console.log(`${lc2} no senderIdentity/fnSenderSecret \u2014 skipping establish (I: f29348a77d1542326d14043ea4b69126)`);
|
|
25892
26116
|
}
|
|
25893
26117
|
return void 0;
|
|
@@ -25946,7 +26170,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25946
26170
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25947
26171
|
throw error;
|
|
25948
26172
|
} finally {
|
|
25949
|
-
if (
|
|
26173
|
+
if (logalot66) {
|
|
25950
26174
|
console.log(`${lc2} complete.`);
|
|
25951
26175
|
}
|
|
25952
26176
|
}
|
|
@@ -25962,7 +26186,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25962
26186
|
async initializeOpts(opts) {
|
|
25963
26187
|
const lc2 = `${this.lc}[${this.initializeOpts.name}]`;
|
|
25964
26188
|
try {
|
|
25965
|
-
if (
|
|
26189
|
+
if (logalot66) {
|
|
25966
26190
|
console.log(`${lc2} starting... (I: 31bd5fda37c89fa37fbaf14daf5fe726)`);
|
|
25967
26191
|
}
|
|
25968
26192
|
this.opts = opts;
|
|
@@ -25970,7 +26194,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25970
26194
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25971
26195
|
throw error;
|
|
25972
26196
|
} finally {
|
|
25973
|
-
if (
|
|
26197
|
+
if (logalot66) {
|
|
25974
26198
|
console.log(`${lc2} complete.`);
|
|
25975
26199
|
}
|
|
25976
26200
|
}
|
|
@@ -25978,13 +26202,13 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25978
26202
|
setOptionalOpts(arg) {
|
|
25979
26203
|
const lc2 = `${this.lc}[${this.setOptionalOpts.name}]`;
|
|
25980
26204
|
try {
|
|
25981
|
-
if (
|
|
26205
|
+
if (logalot66) {
|
|
25982
26206
|
console.log(`${lc2} starting... (I: ae5ddbd3577db267f84743175a736626)`);
|
|
25983
26207
|
}
|
|
25984
26208
|
if (!this.opts) {
|
|
25985
26209
|
throw new Error(`(UNEXPECTED) this.opts falsy? (E: 0dd4d6080a6e2f31d86cf4d86e11b826)`);
|
|
25986
26210
|
}
|
|
25987
|
-
if (
|
|
26211
|
+
if (logalot66) {
|
|
25988
26212
|
console.log(`${lc2} updating opts. arg keys: ${Object.keys(arg)} (I: 452d78a558f8fc3468c8e2e68c70b226)`);
|
|
25989
26213
|
}
|
|
25990
26214
|
this.opts = { ...this.opts, ...arg };
|
|
@@ -25992,7 +26216,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
25992
26216
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
25993
26217
|
throw error;
|
|
25994
26218
|
} finally {
|
|
25995
|
-
if (
|
|
26219
|
+
if (logalot66) {
|
|
25996
26220
|
console.log(`${lc2} complete.`);
|
|
25997
26221
|
}
|
|
25998
26222
|
}
|
|
@@ -26017,7 +26241,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
26017
26241
|
async authenticateAndValidate({ context }) {
|
|
26018
26242
|
const lc2 = `${this.lc}[${this.authenticateAndValidate.name}]`;
|
|
26019
26243
|
try {
|
|
26020
|
-
if (
|
|
26244
|
+
if (logalot66) {
|
|
26021
26245
|
console.log(`${lc2} starting... (I: add238055cd84a222c5b8c89913af526)`);
|
|
26022
26246
|
}
|
|
26023
26247
|
if (!this.opts) {
|
|
@@ -26039,7 +26263,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
26039
26263
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26040
26264
|
throw error;
|
|
26041
26265
|
} finally {
|
|
26042
|
-
if (
|
|
26266
|
+
if (logalot66) {
|
|
26043
26267
|
console.log(`${lc2} complete.`);
|
|
26044
26268
|
}
|
|
26045
26269
|
}
|
|
@@ -26056,7 +26280,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
26056
26280
|
async witness(context) {
|
|
26057
26281
|
const lc2 = `${this.lc}[${this.witness.name}]`;
|
|
26058
26282
|
try {
|
|
26059
|
-
if (
|
|
26283
|
+
if (logalot66) {
|
|
26060
26284
|
console.log(`${lc2} starting...`);
|
|
26061
26285
|
}
|
|
26062
26286
|
if (!this.opts) {
|
|
@@ -26074,7 +26298,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
26074
26298
|
});
|
|
26075
26299
|
return response;
|
|
26076
26300
|
} else {
|
|
26077
|
-
if (
|
|
26301
|
+
if (logalot66) {
|
|
26078
26302
|
console.log(`${lc2} No response from peer. this may be normal if we just sent the very last commit frame. (I: 1855b7728c8898e1f9c001f8170ba826)`);
|
|
26079
26303
|
}
|
|
26080
26304
|
return void 0;
|
|
@@ -26083,7 +26307,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
26083
26307
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26084
26308
|
throw error;
|
|
26085
26309
|
} finally {
|
|
26086
|
-
if (
|
|
26310
|
+
if (logalot66) {
|
|
26087
26311
|
console.log(`${lc2} complete.`);
|
|
26088
26312
|
}
|
|
26089
26313
|
}
|
|
@@ -26097,7 +26321,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
26097
26321
|
async getLocalIbGib(addr) {
|
|
26098
26322
|
const lc2 = `${this.lc}[${this.getLocalIbGib.name}]`;
|
|
26099
26323
|
try {
|
|
26100
|
-
if (
|
|
26324
|
+
if (logalot66) {
|
|
26101
26325
|
console.log(`${lc2} starting... (I: 27b248cb9801eeb2386b71485389a826)`);
|
|
26102
26326
|
}
|
|
26103
26327
|
console.warn(`${lc2} possibly a bottleneck here, getLocalIbGib only gets a single ibgib... (W: 2fd448a435480e6b128f6b8bcbef4826)`);
|
|
@@ -26115,7 +26339,7 @@ var SyncPeer_V1 = class _SyncPeer_V1 extends LightWitnessBase_V1 {
|
|
|
26115
26339
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26116
26340
|
throw error;
|
|
26117
26341
|
} finally {
|
|
26118
|
-
if (
|
|
26342
|
+
if (logalot66) {
|
|
26119
26343
|
console.log(`${lc2} complete.`);
|
|
26120
26344
|
}
|
|
26121
26345
|
}
|
|
@@ -26164,7 +26388,7 @@ var SyncWebSocketMsgType = {
|
|
|
26164
26388
|
var SYNC_WEB_SOCKET_MSG_TYPE_VALID_VALUES = Object.values(SyncWebSocketMsgType);
|
|
26165
26389
|
|
|
26166
26390
|
// ../../libs/core-gib/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mjs
|
|
26167
|
-
var
|
|
26391
|
+
var logalot67 = GLOBAL_LOG_A_LOT3;
|
|
26168
26392
|
var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends SyncPeer_V1 {
|
|
26169
26393
|
lc = `[${_SyncPeerWebSocketReceiver_V1.name}]`;
|
|
26170
26394
|
get classname() {
|
|
@@ -26241,7 +26465,7 @@ var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends S
|
|
|
26241
26465
|
allowCancel: false,
|
|
26242
26466
|
spaceName: tempSpaceName,
|
|
26243
26467
|
getFnPrompt: localMetaspace.getFnPrompt,
|
|
26244
|
-
logalot:
|
|
26468
|
+
logalot: logalot67
|
|
26245
26469
|
}
|
|
26246
26470
|
});
|
|
26247
26471
|
if (!localTempSpace) {
|
|
@@ -26266,7 +26490,7 @@ var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends S
|
|
|
26266
26490
|
throw new Error(`WebSocket wrapper not bound to receiver peer (E: ad4c5838d1b87259586b21a89b2c7726)`);
|
|
26267
26491
|
}
|
|
26268
26492
|
const msg = JSON.parse(messageText);
|
|
26269
|
-
if (
|
|
26493
|
+
if (logalot67) {
|
|
26270
26494
|
console.log(`${lc2} received frame: ${msg.type}`);
|
|
26271
26495
|
}
|
|
26272
26496
|
if (!this.isAuthenticated) {
|
|
@@ -26367,7 +26591,7 @@ var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends S
|
|
|
26367
26591
|
const space = this.opts.localSpace;
|
|
26368
26592
|
if (msg.type === SyncWebSocketMsgType.auth_init) {
|
|
26369
26593
|
const { sAddr } = msg;
|
|
26370
|
-
if (
|
|
26594
|
+
if (logalot67) {
|
|
26371
26595
|
console.log(`${lc2} auth-init for ${sAddr}`);
|
|
26372
26596
|
}
|
|
26373
26597
|
const authorizedS = await this.getSessionKeystone(sAddr);
|
|
@@ -26386,7 +26610,7 @@ var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends S
|
|
|
26386
26610
|
}));
|
|
26387
26611
|
} else if (msg.type === SyncWebSocketMsgType.auth_proof) {
|
|
26388
26612
|
const { proofFrame } = msg;
|
|
26389
|
-
if (
|
|
26613
|
+
if (logalot67) {
|
|
26390
26614
|
console.log(`${lc2} verifying auth-proof...`);
|
|
26391
26615
|
}
|
|
26392
26616
|
if (!this.sessionS_tjpAddr) {
|
|
@@ -26405,7 +26629,7 @@ var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends S
|
|
|
26405
26629
|
});
|
|
26406
26630
|
await metaspace.put({ ibGibs: [proofFrame], space });
|
|
26407
26631
|
await metaspace.registerNewIbGib({ ibGib: proofFrame, space });
|
|
26408
|
-
if (
|
|
26632
|
+
if (logalot67) {
|
|
26409
26633
|
console.log(`${lc2} connect validation successful! Connection upgraded to active sync session.`);
|
|
26410
26634
|
}
|
|
26411
26635
|
this.isAuthenticated = true;
|
|
@@ -26422,7 +26646,7 @@ var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends S
|
|
|
26422
26646
|
async executeIncomingSyncRequestAndRespond({ context }) {
|
|
26423
26647
|
const lc2 = `${this.lc}[${this.executeIncomingSyncRequestAndRespond.name}]`;
|
|
26424
26648
|
try {
|
|
26425
|
-
if (
|
|
26649
|
+
if (logalot67) {
|
|
26426
26650
|
console.log(`${lc2} executing incoming sync turn...`);
|
|
26427
26651
|
}
|
|
26428
26652
|
if (!this.opts) {
|
|
@@ -26446,7 +26670,7 @@ var SyncPeerWebSocketReceiver_V1 = class _SyncPeerWebSocketReceiver_V1 extends S
|
|
|
26446
26670
|
context: responseCtx
|
|
26447
26671
|
}));
|
|
26448
26672
|
} else {
|
|
26449
|
-
if (
|
|
26673
|
+
if (logalot67) {
|
|
26450
26674
|
console.log(`${lc2} synchronization session completed successfully.`);
|
|
26451
26675
|
}
|
|
26452
26676
|
}
|
|
@@ -26466,11 +26690,11 @@ var GraftPreference;
|
|
|
26466
26690
|
})(GraftPreference || (GraftPreference = {}));
|
|
26467
26691
|
|
|
26468
26692
|
// ../../libs/core-gib/dist/timeline/timeline-api.mjs
|
|
26469
|
-
var
|
|
26693
|
+
var logalot68 = GLOBAL_LOG_A_LOT3;
|
|
26470
26694
|
async function getLockScope({ timeline }) {
|
|
26471
26695
|
const lc2 = `[${getLockScope.name}]`;
|
|
26472
26696
|
try {
|
|
26473
|
-
if (
|
|
26697
|
+
if (logalot68) {
|
|
26474
26698
|
console.log(`${lc2} starting...`);
|
|
26475
26699
|
}
|
|
26476
26700
|
if (isPrimitive({ ibGib: timeline })) {
|
|
@@ -26488,7 +26712,7 @@ async function getLockScope({ timeline }) {
|
|
|
26488
26712
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26489
26713
|
throw error;
|
|
26490
26714
|
} finally {
|
|
26491
|
-
if (
|
|
26715
|
+
if (logalot68) {
|
|
26492
26716
|
console.log(`${lc2} complete.`);
|
|
26493
26717
|
}
|
|
26494
26718
|
}
|
|
@@ -26496,7 +26720,7 @@ async function getLockScope({ timeline }) {
|
|
|
26496
26720
|
async function appendToTimeline({ timeline, rel8nInfos, rel8nRemovalInfos, timelineIndexInfo, metaspace, space, skipLock, noDna }) {
|
|
26497
26721
|
const lc2 = `[${appendToTimeline.name}]`;
|
|
26498
26722
|
try {
|
|
26499
|
-
if (
|
|
26723
|
+
if (logalot68) {
|
|
26500
26724
|
console.log(`${lc2} starting... (I: fcdff10832215068019355265f4cbc25)`);
|
|
26501
26725
|
}
|
|
26502
26726
|
space ??= await metaspace.getLocalUserSpace({ lock: false });
|
|
@@ -26592,7 +26816,7 @@ async function appendToTimeline({ timeline, rel8nInfos, rel8nRemovalInfos, timel
|
|
|
26592
26816
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26593
26817
|
throw error;
|
|
26594
26818
|
} finally {
|
|
26595
|
-
if (
|
|
26819
|
+
if (logalot68) {
|
|
26596
26820
|
console.log(`${lc2} complete.`);
|
|
26597
26821
|
}
|
|
26598
26822
|
}
|
|
@@ -26600,7 +26824,7 @@ async function appendToTimeline({ timeline, rel8nInfos, rel8nRemovalInfos, timel
|
|
|
26600
26824
|
async function updateSpecialIndex({ type, rel8nInfos, dataToAddOrPatch, metaspace, space, skipLock }) {
|
|
26601
26825
|
const lc2 = `[${updateSpecialIndex.name}]`;
|
|
26602
26826
|
try {
|
|
26603
|
-
if (
|
|
26827
|
+
if (logalot68) {
|
|
26604
26828
|
console.log(`${lc2} starting... (I: 6e7d05fe916d813b71766e2eaa747c25)`);
|
|
26605
26829
|
}
|
|
26606
26830
|
if (type === "latest") {
|
|
@@ -26698,7 +26922,7 @@ async function updateSpecialIndex({ type, rel8nInfos, dataToAddOrPatch, metaspac
|
|
|
26698
26922
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26699
26923
|
throw error;
|
|
26700
26924
|
} finally {
|
|
26701
|
-
if (
|
|
26925
|
+
if (logalot68) {
|
|
26702
26926
|
console.log(`${lc2} complete.`);
|
|
26703
26927
|
}
|
|
26704
26928
|
}
|
|
@@ -26706,7 +26930,7 @@ async function updateSpecialIndex({ type, rel8nInfos, dataToAddOrPatch, metaspac
|
|
|
26706
26930
|
async function getLatestTimelineIbGibDto_nonLocking({ timeline, timelineAddr, metaspace, space }) {
|
|
26707
26931
|
const lc2 = `[${getLatestTimelineIbGibDto_nonLocking.name}]`;
|
|
26708
26932
|
try {
|
|
26709
|
-
if (
|
|
26933
|
+
if (logalot68) {
|
|
26710
26934
|
console.log(`${lc2} starting... (I: f2b605361368e1956f6db878dbfeb825)`);
|
|
26711
26935
|
}
|
|
26712
26936
|
if (!timeline && !timelineAddr) {
|
|
@@ -26748,7 +26972,7 @@ async function getLatestTimelineIbGibDto_nonLocking({ timeline, timelineAddr, me
|
|
|
26748
26972
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26749
26973
|
throw error;
|
|
26750
26974
|
} finally {
|
|
26751
|
-
if (
|
|
26975
|
+
if (logalot68) {
|
|
26752
26976
|
console.log(`${lc2} complete.`);
|
|
26753
26977
|
}
|
|
26754
26978
|
}
|
|
@@ -26756,7 +26980,7 @@ async function getLatestTimelineIbGibDto_nonLocking({ timeline, timelineAddr, me
|
|
|
26756
26980
|
async function createTimeline({ ib, data, rel8ns, noDna, parentIb, parentIbGib, metaspace, space }) {
|
|
26757
26981
|
const lc2 = `[${createTimeline.name}]`;
|
|
26758
26982
|
try {
|
|
26759
|
-
if (
|
|
26983
|
+
if (logalot68) {
|
|
26760
26984
|
console.log(`${lc2} starting...`);
|
|
26761
26985
|
}
|
|
26762
26986
|
space ??= await metaspace.getLocalUserSpace({ lock: false });
|
|
@@ -26800,7 +27024,7 @@ async function createTimeline({ ib, data, rel8ns, noDna, parentIb, parentIbGib,
|
|
|
26800
27024
|
async function getDna({ ibGib, metaspace, space }) {
|
|
26801
27025
|
const lc2 = `[${getDna.name}]`;
|
|
26802
27026
|
try {
|
|
26803
|
-
if (
|
|
27027
|
+
if (logalot68) {
|
|
26804
27028
|
console.log(`${lc2} starting...`);
|
|
26805
27029
|
}
|
|
26806
27030
|
space ??= await metaspace.getLocalUserSpace({ lock: false });
|
|
@@ -26825,7 +27049,7 @@ async function getDna({ ibGib, metaspace, space }) {
|
|
|
26825
27049
|
async function getHistory({ timeline, getLatest, includeDna, metaspace, space }) {
|
|
26826
27050
|
const lc2 = `[${getHistory.name}]`;
|
|
26827
27051
|
try {
|
|
26828
|
-
if (
|
|
27052
|
+
if (logalot68) {
|
|
26829
27053
|
console.log(`${lc2} starting... (I: 7fbc442a27e8f9fda8ac4228ded84825)`);
|
|
26830
27054
|
}
|
|
26831
27055
|
space ??= await metaspace.getLocalUserSpace({ lock: false });
|
|
@@ -26871,7 +27095,7 @@ async function getHistory({ timeline, getLatest, includeDna, metaspace, space })
|
|
|
26871
27095
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26872
27096
|
throw error;
|
|
26873
27097
|
} finally {
|
|
26874
|
-
if (
|
|
27098
|
+
if (logalot68) {
|
|
26875
27099
|
console.log(`${lc2} complete.`);
|
|
26876
27100
|
}
|
|
26877
27101
|
}
|
|
@@ -26879,7 +27103,7 @@ async function getHistory({ timeline, getLatest, includeDna, metaspace, space })
|
|
|
26879
27103
|
async function getHistoryAddrs({ timeline, getLatest, metaspace, space }) {
|
|
26880
27104
|
const lc2 = `[${getHistoryAddrs.name}]`;
|
|
26881
27105
|
try {
|
|
26882
|
-
if (
|
|
27106
|
+
if (logalot68) {
|
|
26883
27107
|
console.log(`${lc2} starting... (I: c7a328b14018642138ebb47870c15626)`);
|
|
26884
27108
|
}
|
|
26885
27109
|
const historyInfo = await getHistory({
|
|
@@ -26895,7 +27119,7 @@ async function getHistoryAddrs({ timeline, getLatest, metaspace, space }) {
|
|
|
26895
27119
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26896
27120
|
throw error;
|
|
26897
27121
|
} finally {
|
|
26898
|
-
if (
|
|
27122
|
+
if (logalot68) {
|
|
26899
27123
|
console.log(`${lc2} complete.`);
|
|
26900
27124
|
}
|
|
26901
27125
|
}
|
|
@@ -26942,11 +27166,11 @@ async function getSyncSagaMessageFromFrame({ frameIbGib, space }) {
|
|
|
26942
27166
|
}
|
|
26943
27167
|
|
|
26944
27168
|
// ../../libs/core-gib/dist/witness/space/reconciliation-space/reconciliation-space-helper.mjs
|
|
26945
|
-
var
|
|
27169
|
+
var logalot69 = GLOBAL_LOG_A_LOT3;
|
|
26946
27170
|
function getUniqueDnas({ base, extended, throwIfExtendedDoesntContainBase }) {
|
|
26947
27171
|
const lc2 = `[${getUniqueDnas.name}]`;
|
|
26948
27172
|
try {
|
|
26949
|
-
if (
|
|
27173
|
+
if (logalot69) {
|
|
26950
27174
|
console.log(`${lc2} starting... (I: 00d70d79a0249165c2a230389c962526)`);
|
|
26951
27175
|
}
|
|
26952
27176
|
let baseIsStartingSubsetOfExtended = true;
|
|
@@ -26975,7 +27199,7 @@ function getUniqueDnas({ base, extended, throwIfExtendedDoesntContainBase }) {
|
|
|
26975
27199
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
26976
27200
|
throw error;
|
|
26977
27201
|
} finally {
|
|
26978
|
-
if (
|
|
27202
|
+
if (logalot69) {
|
|
26979
27203
|
console.log(`${lc2} complete.`);
|
|
26980
27204
|
}
|
|
26981
27205
|
}
|
|
@@ -27037,7 +27261,7 @@ async function applyTransforms({ src, createdIbGibs_Running, dnaAddrsToApplyToSt
|
|
|
27037
27261
|
}
|
|
27038
27262
|
|
|
27039
27263
|
// ../../libs/core-gib/dist/sync/graft-info/graft-merge-strategy-base-v1.mjs
|
|
27040
|
-
var
|
|
27264
|
+
var logalot70 = GLOBAL_LOG_A_LOT3;
|
|
27041
27265
|
var GraftMergeStrategyBase_V1 = class {
|
|
27042
27266
|
defaultGraftPreference;
|
|
27043
27267
|
constructor(opts) {
|
|
@@ -27094,7 +27318,7 @@ var GraftMergeStrategyBase_V1 = class {
|
|
|
27094
27318
|
async applyTransformAndRegister({ resTransform, space, newGraftDnaIbGibs, newGraftedIntermediateIbGibs_ordered }) {
|
|
27095
27319
|
const lc2 = `[${this.constructor.name}][${this.applyTransformAndRegister.name}]`;
|
|
27096
27320
|
try {
|
|
27097
|
-
if (
|
|
27321
|
+
if (logalot70) {
|
|
27098
27322
|
console.log(`${lc2} starting... (I: 2e8a1d7f6c4342138901a1b2c3d4e5f6)`);
|
|
27099
27323
|
}
|
|
27100
27324
|
if (!resTransform) {
|
|
@@ -27119,7 +27343,7 @@ var GraftMergeStrategyBase_V1 = class {
|
|
|
27119
27343
|
console.error(`${lc2} ${extractErrorMsg(error)} (E: d2384a8b792e42429bc7891234567826)`);
|
|
27120
27344
|
throw error;
|
|
27121
27345
|
} finally {
|
|
27122
|
-
if (
|
|
27346
|
+
if (logalot70) {
|
|
27123
27347
|
console.log(`${lc2} complete.`);
|
|
27124
27348
|
}
|
|
27125
27349
|
}
|
|
@@ -27127,7 +27351,7 @@ var GraftMergeStrategyBase_V1 = class {
|
|
|
27127
27351
|
};
|
|
27128
27352
|
|
|
27129
27353
|
// ../../libs/core-gib/dist/sync/graft-info/strategies/default-dna-replay-graft-strategy.mjs
|
|
27130
|
-
var
|
|
27354
|
+
var logalot71 = GLOBAL_LOG_A_LOT3;
|
|
27131
27355
|
var DefaultDnaReplayGraftStrategy = class extends GraftMergeStrategyBase_V1 {
|
|
27132
27356
|
strategyId = "DefaultDnaReplayGraftStrategy";
|
|
27133
27357
|
canGraft(context) {
|
|
@@ -27157,7 +27381,7 @@ var DefaultDnaReplayGraftStrategy = class extends GraftMergeStrategyBase_V1 {
|
|
|
27157
27381
|
}
|
|
27158
27382
|
};
|
|
27159
27383
|
var throwIfUnexpected = throwIfUnexpected2;
|
|
27160
|
-
if (
|
|
27384
|
+
if (logalot71) {
|
|
27161
27385
|
console.log(`${lc2} starting default DNA replay graft... (I: 8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d)`);
|
|
27162
27386
|
}
|
|
27163
27387
|
const { conflictStrategy, timelineAddrsA, timelineAddrsB, latestCommonFrameAddr, ibGibReadCache, space, graftPreference } = context;
|
|
@@ -27198,10 +27422,10 @@ var DefaultDnaReplayGraftStrategy = class extends GraftMergeStrategyBase_V1 {
|
|
|
27198
27422
|
const baseBranchAddrs = baseBranch.map((x) => getIbGibAddr({ ibGib: x }));
|
|
27199
27423
|
const orphanTipAddr = getIbGibAddr({ ibGib: orphanTip });
|
|
27200
27424
|
const orphanBranchAddrs = orphanBranch.map((x) => getIbGibAddr({ ibGib: x }));
|
|
27201
|
-
if (
|
|
27425
|
+
if (logalot71) {
|
|
27202
27426
|
console.log(`${lc2} baseTipAddr: ${baseTipAddr} (I: 93353d9b9b68b17088f57958df85e826)`);
|
|
27203
27427
|
}
|
|
27204
|
-
if (
|
|
27428
|
+
if (logalot71) {
|
|
27205
27429
|
console.log(`${lc2} orphanTipAddr: ${orphanTipAddr} (I: 14df8867adc5dab97ff3c1e989b40e26)`);
|
|
27206
27430
|
}
|
|
27207
27431
|
const [latestCommonFrameIbGib] = await getIbGibsFromCache_fallbackToSpaces({
|
|
@@ -27324,7 +27548,7 @@ var DefaultDnaReplayGraftStrategy = class extends GraftMergeStrategyBase_V1 {
|
|
|
27324
27548
|
console.error(`${lc2} ${extractErrorMsg(error)} (E: 7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f)`);
|
|
27325
27549
|
throw error;
|
|
27326
27550
|
} finally {
|
|
27327
|
-
if (
|
|
27551
|
+
if (logalot71) {
|
|
27328
27552
|
console.log(`${lc2} complete.`);
|
|
27329
27553
|
}
|
|
27330
27554
|
}
|
|
@@ -27332,7 +27556,7 @@ var DefaultDnaReplayGraftStrategy = class extends GraftMergeStrategyBase_V1 {
|
|
|
27332
27556
|
};
|
|
27333
27557
|
|
|
27334
27558
|
// ../../libs/core-gib/dist/sync/graft-info/graft-strategy-service.mjs
|
|
27335
|
-
var
|
|
27559
|
+
var logalot72 = GLOBAL_LOG_A_LOT3;
|
|
27336
27560
|
var lcFile = `[graft-strategy-service]`;
|
|
27337
27561
|
var GraftStrategyService = class _GraftStrategyService {
|
|
27338
27562
|
static _instance;
|
|
@@ -27354,7 +27578,7 @@ var GraftStrategyService = class _GraftStrategyService {
|
|
|
27354
27578
|
throw new Error(`(UNEXPECTED) strategy falsy (E: 7c8b9a0d1e2f3a4b5c6d7e8f9a0b1c2d)`);
|
|
27355
27579
|
}
|
|
27356
27580
|
if (!this._registeredStrategies.some((s) => s.strategyId === strategy.strategyId)) {
|
|
27357
|
-
if (
|
|
27581
|
+
if (logalot72) {
|
|
27358
27582
|
console.log(`${lc2} registering strategy ${strategy.strategyId} (I: 8b9a0c1d2e3f4a5b6c7d8e9f0a1b2c3d)`);
|
|
27359
27583
|
}
|
|
27360
27584
|
this._registeredStrategies.push(strategy);
|
|
@@ -27368,7 +27592,7 @@ var GraftStrategyService = class _GraftStrategyService {
|
|
|
27368
27592
|
if (!strategy) {
|
|
27369
27593
|
throw new Error(`(UNEXPECTED) fallback strategy falsy (E: 9c0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c)`);
|
|
27370
27594
|
}
|
|
27371
|
-
if (
|
|
27595
|
+
if (logalot72) {
|
|
27372
27596
|
console.log(`${lc2} setting fallback strategy ${strategy.strategyId} (I: 0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d)`);
|
|
27373
27597
|
}
|
|
27374
27598
|
this._fallbackStrategy = strategy;
|
|
@@ -27384,7 +27608,7 @@ var GraftStrategyService = class _GraftStrategyService {
|
|
|
27384
27608
|
*/
|
|
27385
27609
|
reset() {
|
|
27386
27610
|
const lc2 = `${lcFile}[${this.reset.name}]`;
|
|
27387
|
-
if (
|
|
27611
|
+
if (logalot72) {
|
|
27388
27612
|
console.log(`${lc2} resetting strategies to default fallback... (I: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`);
|
|
27389
27613
|
}
|
|
27390
27614
|
this._registeredStrategies = [];
|
|
@@ -27400,7 +27624,7 @@ var GraftStrategyService = class _GraftStrategyService {
|
|
|
27400
27624
|
async graftTimelines({ timelineAddrsA, timelineAddrsB, latestCommonFrameAddr, conflictStrategy, ibGibReadCache, space, graftPreference }) {
|
|
27401
27625
|
const lc2 = `[${this.graftTimelines.name}]`;
|
|
27402
27626
|
try {
|
|
27403
|
-
if (
|
|
27627
|
+
if (logalot72) {
|
|
27404
27628
|
console.log(`${lc2} starting... (I: 3b4c3e8e59c883d9d3c352efd6380826)`);
|
|
27405
27629
|
}
|
|
27406
27630
|
if (timelineAddrsA.length === 0) {
|
|
@@ -27453,7 +27677,7 @@ var GraftStrategyService = class _GraftStrategyService {
|
|
|
27453
27677
|
}
|
|
27454
27678
|
let resGraft = void 0;
|
|
27455
27679
|
for (const strategy of strategyPipeline) {
|
|
27456
|
-
if (
|
|
27680
|
+
if (logalot72) {
|
|
27457
27681
|
console.log(`${lc2} executing graft strategy ${strategy.strategyId} (I: 5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f)`);
|
|
27458
27682
|
}
|
|
27459
27683
|
resGraft = await strategy.graft(context);
|
|
@@ -27469,7 +27693,7 @@ var GraftStrategyService = class _GraftStrategyService {
|
|
|
27469
27693
|
console.error(`${lc2} ${extractErrorMsg(error)} (E: 9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d)`);
|
|
27470
27694
|
throw error;
|
|
27471
27695
|
} finally {
|
|
27472
|
-
if (
|
|
27696
|
+
if (logalot72) {
|
|
27473
27697
|
console.log(`${lc2} complete.`);
|
|
27474
27698
|
}
|
|
27475
27699
|
}
|
|
@@ -27477,7 +27701,7 @@ var GraftStrategyService = class _GraftStrategyService {
|
|
|
27477
27701
|
};
|
|
27478
27702
|
|
|
27479
27703
|
// ../../libs/core-gib/dist/sync/sync-saga-coordinator.mjs
|
|
27480
|
-
var
|
|
27704
|
+
var logalot73 = GLOBAL_LOG_A_LOT3;
|
|
27481
27705
|
var logalotControlDomain = false;
|
|
27482
27706
|
var lcControlDomain = "[ControlDomain]";
|
|
27483
27707
|
var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
@@ -27531,7 +27755,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27531
27755
|
*/
|
|
27532
27756
|
async sync({ peer, domainIbGibs, senderIdentityInfo, fnSenderSecret, conflictStrategy = SyncConflictStrategy.abort, graftPreference, metaspace, localSpace }) {
|
|
27533
27757
|
const lc2 = `${this.lc}[${this.sync.name}]`;
|
|
27534
|
-
if (
|
|
27758
|
+
if (logalot73) {
|
|
27535
27759
|
console.log(`${lc2} starting...`);
|
|
27536
27760
|
}
|
|
27537
27761
|
if (!localSpace) {
|
|
@@ -27571,7 +27795,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27571
27795
|
allowCancel: false,
|
|
27572
27796
|
spaceName: tempSpaceName,
|
|
27573
27797
|
getFnPrompt: metaspace.getFnPrompt,
|
|
27574
|
-
logalot:
|
|
27798
|
+
logalot: logalot73
|
|
27575
27799
|
}
|
|
27576
27800
|
});
|
|
27577
27801
|
if (!tempSpace) {
|
|
@@ -27645,7 +27869,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27645
27869
|
async continueSync({ sagaContext, mySpace, myTempSpace, metaspace, peer }) {
|
|
27646
27870
|
const lc2 = `${this.lc}[${this.continueSync.name}]`;
|
|
27647
27871
|
try {
|
|
27648
|
-
if (
|
|
27872
|
+
if (logalot73) {
|
|
27649
27873
|
console.log(`${lc2} starting... (I: f64e08bf77d1425378601f380384ec26)`);
|
|
27650
27874
|
}
|
|
27651
27875
|
const contextResult = await this.handleResponseSagaContext({
|
|
@@ -27655,7 +27879,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27655
27879
|
metaspace
|
|
27656
27880
|
});
|
|
27657
27881
|
if (!contextResult) {
|
|
27658
|
-
if (
|
|
27882
|
+
if (logalot73) {
|
|
27659
27883
|
console.log(`${lc2} Handler returned null (Saga End). (I: 43da8bb6c846b1fe7766332643be0e26)`);
|
|
27660
27884
|
}
|
|
27661
27885
|
return null;
|
|
@@ -27688,7 +27912,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27688
27912
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
27689
27913
|
throw error;
|
|
27690
27914
|
} finally {
|
|
27691
|
-
if (
|
|
27915
|
+
if (logalot73) {
|
|
27692
27916
|
console.log(`${lc2} complete.`);
|
|
27693
27917
|
}
|
|
27694
27918
|
}
|
|
@@ -27717,7 +27941,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27717
27941
|
const sublc = `${lc2}[peer.payloadIbGibsDomainReceived$]`;
|
|
27718
27942
|
const subscription = await peer.payloadIbGibsDomainReceived$.subscribe(fnObs({
|
|
27719
27943
|
next: async (ibgib) => {
|
|
27720
|
-
if (
|
|
27944
|
+
if (logalot73) {
|
|
27721
27945
|
console.log(`${sublc} next fired. (I: 2b4bdf502a38a90ba33d9711e7cb7826)`);
|
|
27722
27946
|
}
|
|
27723
27947
|
const addr = getIbGibAddr({ ibGib: ibgib });
|
|
@@ -27735,7 +27959,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27735
27959
|
}
|
|
27736
27960
|
},
|
|
27737
27961
|
complete: async () => {
|
|
27738
|
-
if (
|
|
27962
|
+
if (logalot73) {
|
|
27739
27963
|
console.log(`${sublc} complete fired. (I: a47218aa9e4433fdb97c068880a45826)`);
|
|
27740
27964
|
}
|
|
27741
27965
|
await subscription.unsubscribe();
|
|
@@ -27770,7 +27994,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27770
27994
|
if (currentFrame) {
|
|
27771
27995
|
const msg = await getSyncSagaMessageFromFrame({ frameIbGib: currentFrame, space: localSpace });
|
|
27772
27996
|
if (msg?.data?.stage === SyncStage.commit) {
|
|
27773
|
-
if (
|
|
27997
|
+
if (logalot73) {
|
|
27774
27998
|
console.log(`${lc2} Sender sent Commit. Peer returned no response. Saga Complete. (I: 26f9ee073858ca78b8284753368b5226)`);
|
|
27775
27999
|
}
|
|
27776
28000
|
currentFrame = null;
|
|
@@ -27830,7 +28054,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27830
28054
|
console.error(`${lc2} NAG ERROR (DOES NOT THROW): does this ever hit now? (E: e04d02efc2a8e72a88b79f1f0f95ca26)`);
|
|
27831
28055
|
break;
|
|
27832
28056
|
} else if (contextResult.nextFrameInfo?.sagaComplete) {
|
|
27833
|
-
if (
|
|
28057
|
+
if (logalot73) {
|
|
27834
28058
|
console.log(`${lc2} Handler returned null (Saga End). (I: 123bf9e7dca8886de72553a8d4f29e26)`);
|
|
27835
28059
|
}
|
|
27836
28060
|
break;
|
|
@@ -27868,7 +28092,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27868
28092
|
async createSyncSagaContext({ sagaFrame, payloadIbGibsDomain, metaspace, localSpace, sessionIdentityAddr, peer, skipSign }) {
|
|
27869
28093
|
const lc2 = `[${this.createSyncSagaContext.name}]`;
|
|
27870
28094
|
try {
|
|
27871
|
-
if (
|
|
28095
|
+
if (logalot73) {
|
|
27872
28096
|
console.log(`${lc2} starting... (I: 6b87bee313e811d1d2fc90e87fbec826)`);
|
|
27873
28097
|
}
|
|
27874
28098
|
if (!sagaFrame.data) {
|
|
@@ -27942,7 +28166,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27942
28166
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
27943
28167
|
throw error;
|
|
27944
28168
|
} finally {
|
|
27945
|
-
if (
|
|
28169
|
+
if (logalot73) {
|
|
27946
28170
|
console.log(`${lc2} complete.`);
|
|
27947
28171
|
}
|
|
27948
28172
|
}
|
|
@@ -27954,7 +28178,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27954
28178
|
async getKnowledgeMap({ space, metaspace, domainIbGibs, tjpAddrs }) {
|
|
27955
28179
|
const lc2 = `${this.lc}[${this.getKnowledgeMap.name}]`;
|
|
27956
28180
|
try {
|
|
27957
|
-
if (
|
|
28181
|
+
if (logalot73) {
|
|
27958
28182
|
console.log(`${lc2} starting... (I: e184f8a7818666febfbbd2d841ed3826)`);
|
|
27959
28183
|
}
|
|
27960
28184
|
if (!(domainIbGibs && domainIbGibs.length > 0) && !(tjpAddrs && tjpAddrs.length > 0)) {
|
|
@@ -27987,7 +28211,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
27987
28211
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
27988
28212
|
throw error;
|
|
27989
28213
|
} finally {
|
|
27990
|
-
if (
|
|
28214
|
+
if (logalot73) {
|
|
27991
28215
|
console.log(`${lc2} complete.`);
|
|
27992
28216
|
}
|
|
27993
28217
|
}
|
|
@@ -28003,7 +28227,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28003
28227
|
space
|
|
28004
28228
|
});
|
|
28005
28229
|
const graphIsValid = fullGraph && Object.keys(fullGraph).length > 0;
|
|
28006
|
-
if (
|
|
28230
|
+
if (logalot73) {
|
|
28007
28231
|
console.log(`${lc2} graph generated. nodes: ${graphIsValid ? Object.keys(fullGraph).length : 0}`);
|
|
28008
28232
|
}
|
|
28009
28233
|
const srcIbGibs = graphIsValid ? Object.values(fullGraph) : [];
|
|
@@ -28026,7 +28250,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28026
28250
|
async createInitFrame({ sagaId, domainIbGibs, conflictStrategy, graftPreference, metaspace, localSpace, tempSpace, peer }) {
|
|
28027
28251
|
const lc2 = `${this.lc}[${this.createInitFrame.name}]`;
|
|
28028
28252
|
try {
|
|
28029
|
-
if (
|
|
28253
|
+
if (logalot73) {
|
|
28030
28254
|
console.log(`${lc2} starting... (I: 551af8b411ae9be712ce3358d43ee726)`);
|
|
28031
28255
|
}
|
|
28032
28256
|
const analysis = await this.analyzeDomainIbGibs({ domainIbGibs, space: localSpace });
|
|
@@ -28045,7 +28269,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28045
28269
|
mode: SyncMode.sync,
|
|
28046
28270
|
stones: srcStones.map((s) => getIbGibAddr({ ibGib: s }))
|
|
28047
28271
|
};
|
|
28048
|
-
if (
|
|
28272
|
+
if (logalot73) {
|
|
28049
28273
|
console.log(`${lc2} SyncStage.init: ${SyncStage.init}, SyncStage.commit: ${SyncStage.commit}`);
|
|
28050
28274
|
console.log(`${lc2} initData.stage: ${initData.stage}`);
|
|
28051
28275
|
}
|
|
@@ -28062,7 +28286,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28062
28286
|
localSpace,
|
|
28063
28287
|
sessionIdentity: peer.currentSessionIdentity
|
|
28064
28288
|
});
|
|
28065
|
-
if (
|
|
28289
|
+
if (logalot73) {
|
|
28066
28290
|
console.log(`${lc2} sagaFrame (init): ${pretty(sagaFrame)} (I: b3d6a8be69248f18713cc3073cb08626)`);
|
|
28067
28291
|
}
|
|
28068
28292
|
return { initFrame: sagaFrame, initDomainGraph: fullGraph };
|
|
@@ -28070,7 +28294,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28070
28294
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
28071
28295
|
throw error;
|
|
28072
28296
|
} finally {
|
|
28073
|
-
if (
|
|
28297
|
+
if (logalot73) {
|
|
28074
28298
|
console.log(`${lc2} complete.`);
|
|
28075
28299
|
}
|
|
28076
28300
|
}
|
|
@@ -28111,7 +28335,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28111
28335
|
} catch (error) {
|
|
28112
28336
|
errors.push(`Error during validateReturnContext: ${extractErrorMsg(error)} (E: da878e1239aa88ee27bdfca005c28226)`);
|
|
28113
28337
|
}
|
|
28114
|
-
if (
|
|
28338
|
+
if (logalot73 && errors.length > 0) {
|
|
28115
28339
|
console.log(`${lc2} errors: ${errors.join("\n")} (I: cbc119df45aa13daa9009de392c4b226)`);
|
|
28116
28340
|
}
|
|
28117
28341
|
return errors;
|
|
@@ -28125,7 +28349,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28125
28349
|
async pollForDomainPayloads({ expectedAddrs, pollIntervalMs, domainPayloadsMap, tempSpace }) {
|
|
28126
28350
|
const lc2 = `${this.lc}[${this.pollForDomainPayloads.name}]`;
|
|
28127
28351
|
try {
|
|
28128
|
-
if (
|
|
28352
|
+
if (logalot73) {
|
|
28129
28353
|
console.log(`${lc2} starting... (I: 26dce86bfca572939885798802d6e926)`);
|
|
28130
28354
|
}
|
|
28131
28355
|
let resultDomainPayloads = [];
|
|
@@ -28164,7 +28388,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28164
28388
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
28165
28389
|
throw error;
|
|
28166
28390
|
} finally {
|
|
28167
|
-
if (
|
|
28391
|
+
if (logalot73) {
|
|
28168
28392
|
console.log(`${lc2} complete.`);
|
|
28169
28393
|
}
|
|
28170
28394
|
}
|
|
@@ -28198,18 +28422,18 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28198
28422
|
async handleResponseSagaContext({ sagaContext, initDomainGraph, mySpace, myTempSpace, metaspace }) {
|
|
28199
28423
|
const lc2 = `${this.lc}[${this.handleResponseSagaContext.name}]`;
|
|
28200
28424
|
try {
|
|
28201
|
-
if (
|
|
28425
|
+
if (logalot73) {
|
|
28202
28426
|
console.log(`${lc2} starting... (I: 5deec8a1f7a6d263c88cd458ad990826)`);
|
|
28203
28427
|
}
|
|
28204
28428
|
const sagaIbGib = sagaContext.sagaFrame;
|
|
28205
28429
|
if (!sagaIbGib.data) {
|
|
28206
28430
|
throw new Error(`(UNEXPECTED) sagaIbGib.data falsy? (E: 71b938adf1d87c2527bfd4f86dfd0826)`);
|
|
28207
28431
|
}
|
|
28208
|
-
if (
|
|
28432
|
+
if (logalot73) {
|
|
28209
28433
|
console.log(`${lc2} sagaIbGib: ${pretty(sagaIbGib)} (I: 1b99d87d262e9d18d8a607a80b1a0126)`);
|
|
28210
28434
|
}
|
|
28211
28435
|
const { stage, messageData } = await this.getStageAndPayloadFromFrame({ sagaFrame: sagaIbGib, space: mySpace });
|
|
28212
|
-
if (
|
|
28436
|
+
if (logalot73) {
|
|
28213
28437
|
console.log(`${lc2} handling frame stage: ${stage}`);
|
|
28214
28438
|
}
|
|
28215
28439
|
let nextFrameInfo;
|
|
@@ -28246,7 +28470,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28246
28470
|
});
|
|
28247
28471
|
break;
|
|
28248
28472
|
case SyncStage.commit:
|
|
28249
|
-
if (
|
|
28473
|
+
if (logalot73) {
|
|
28250
28474
|
console.log(`${lc2}[${getSyncSagaFrameOrigin({ sagaFrame: sagaIbGib })}] mySpace.ib: ${mySpace.ib} (I: 5b270996d848907238d817fffa64a126)`);
|
|
28251
28475
|
}
|
|
28252
28476
|
nextFrameInfo = await this.handleCommitFrame({
|
|
@@ -28259,7 +28483,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28259
28483
|
default:
|
|
28260
28484
|
throw new Error(`${lc2} (UNEXPECTED) Unknown sync stage: ${stage} (E: 9c2b4c8a6d34469f8263544710183355)`);
|
|
28261
28485
|
}
|
|
28262
|
-
if (
|
|
28486
|
+
if (logalot73) {
|
|
28263
28487
|
console.log(`${lc2} nextFrameInfo: ${nextFrameInfo ? pretty(nextFrameInfo) : "undefined"} (I: a8ad281ca8e89385686d18327a105726)`);
|
|
28264
28488
|
}
|
|
28265
28489
|
return { errorMsg: void 0, nextFrameInfo };
|
|
@@ -28268,7 +28492,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28268
28492
|
console.error(errorMsg);
|
|
28269
28493
|
return { errorMsg };
|
|
28270
28494
|
} finally {
|
|
28271
|
-
if (
|
|
28495
|
+
if (logalot73) {
|
|
28272
28496
|
console.log(`${lc2} complete.`);
|
|
28273
28497
|
}
|
|
28274
28498
|
}
|
|
@@ -28289,10 +28513,10 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28289
28513
|
async handleInitFrame({ sagaIbGib, messageData, mySpace, myTempSpace, metaspace }) {
|
|
28290
28514
|
const lc2 = `${this.lc}[${this.handleInitFrame.name}]`;
|
|
28291
28515
|
try {
|
|
28292
|
-
if (
|
|
28516
|
+
if (logalot73) {
|
|
28293
28517
|
console.log(`${lc2} starting... (I: 9d88dcad0408c029e898a4bcf3b08426)`);
|
|
28294
28518
|
}
|
|
28295
|
-
if (
|
|
28519
|
+
if (logalot73) {
|
|
28296
28520
|
console.log(`${lc2} [TEST DEBUG] Receiver mySpace: ${mySpace.ib}`);
|
|
28297
28521
|
}
|
|
28298
28522
|
const initData = messageData;
|
|
@@ -28308,7 +28532,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28308
28532
|
const pushOfferInfos = [];
|
|
28309
28533
|
const stones = initData.stones || [];
|
|
28310
28534
|
if (stones.length > 0) {
|
|
28311
|
-
if (
|
|
28535
|
+
if (logalot73) {
|
|
28312
28536
|
console.log(`${lc2} processing stones: ${stones.length}`);
|
|
28313
28537
|
}
|
|
28314
28538
|
const resStones = await getFromSpace({ space: mySpace, addrs: stones });
|
|
@@ -28318,7 +28542,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28318
28542
|
}
|
|
28319
28543
|
const addrsNotFound = rawResultIbGib.data.addrsNotFound;
|
|
28320
28544
|
if (addrsNotFound && addrsNotFound.length > 0) {
|
|
28321
|
-
if (
|
|
28545
|
+
if (logalot73) {
|
|
28322
28546
|
console.log(`${lc2} stones missing (requesting): ${addrsNotFound.length}`);
|
|
28323
28547
|
}
|
|
28324
28548
|
addrsNotFound.forEach((addr) => {
|
|
@@ -28329,14 +28553,14 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28329
28553
|
}
|
|
28330
28554
|
}
|
|
28331
28555
|
const senderKnowledge = initData.knowledgeMap;
|
|
28332
|
-
if (
|
|
28556
|
+
if (logalot73) {
|
|
28333
28557
|
console.log(`${lc2} senderKnowledge: ${pretty(senderKnowledge)} (I: 9f957862356dfeae183c200854e86e26)`);
|
|
28334
28558
|
}
|
|
28335
28559
|
const senderTjpAddrs = Object.keys(senderKnowledge);
|
|
28336
|
-
if (
|
|
28560
|
+
if (logalot73) {
|
|
28337
28561
|
console.log(`${lc2} [TEST DEBUG] senderTjpAddrs: ${JSON.stringify(senderTjpAddrs)}`);
|
|
28338
28562
|
}
|
|
28339
|
-
if (
|
|
28563
|
+
if (logalot73) {
|
|
28340
28564
|
console.log(`${lc2} senderTjpAddrs: ${pretty(senderTjpAddrs)} (I: 86ea4c53db0dc184c8b253386c402126)`);
|
|
28341
28565
|
}
|
|
28342
28566
|
let receiverLatestAddrsMap = {};
|
|
@@ -28353,10 +28577,10 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28353
28577
|
throw new Error(`(UNEXPECTED) resGetLatestAddrs.data.latestAddrsMap falsy? (E: 16bc386dd51d0ff53a49620b1e641826)`);
|
|
28354
28578
|
}
|
|
28355
28579
|
receiverLatestAddrsMap = resGetLatestAddrs.data.latestAddrsMap;
|
|
28356
|
-
if (
|
|
28580
|
+
if (logalot73) {
|
|
28357
28581
|
console.log(`${lc2} [TEST DEBUG] receiverLatestAddrsMap: ${JSON.stringify(receiverLatestAddrsMap)}`);
|
|
28358
28582
|
}
|
|
28359
|
-
if (
|
|
28583
|
+
if (logalot73) {
|
|
28360
28584
|
console.log(`${lc2} receiverLatestAddrsMap: ${pretty(receiverLatestAddrsMap)} (I: 980975642cbccd8018cf0cd808d30826)`);
|
|
28361
28585
|
}
|
|
28362
28586
|
}
|
|
@@ -28364,7 +28588,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28364
28588
|
const senderTipAddr = senderKnowledge[tjpAddr];
|
|
28365
28589
|
const receiverTipAddr = receiverLatestAddrsMap[tjpAddr];
|
|
28366
28590
|
if (!receiverTipAddr) {
|
|
28367
|
-
if (
|
|
28591
|
+
if (logalot73) {
|
|
28368
28592
|
console.log(`${lc2} [TEST DEBUG] Missing receiver timeline for TJP: ${tjpAddr}. Requesting remoteAddr: ${senderTipAddr}`);
|
|
28369
28593
|
}
|
|
28370
28594
|
deltaRequestAddrInfos.push({
|
|
@@ -28376,12 +28600,12 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28376
28600
|
continue;
|
|
28377
28601
|
}
|
|
28378
28602
|
if (receiverTipAddr === senderTipAddr) {
|
|
28379
|
-
if (
|
|
28603
|
+
if (logalot73) {
|
|
28380
28604
|
console.log(`${lc2} [TEST DEBUG] TJP ${tjpAddr}: Synced (receiverTipAddr === remoteAddr)`);
|
|
28381
28605
|
}
|
|
28382
28606
|
continue;
|
|
28383
28607
|
}
|
|
28384
|
-
if (
|
|
28608
|
+
if (logalot73) {
|
|
28385
28609
|
console.log(`${lc2} [TEST DEBUG] TJP ${tjpAddr}: receiverTipAddr=${receiverTipAddr}, remoteAddr=${senderTipAddr} - checking for divergence...`);
|
|
28386
28610
|
}
|
|
28387
28611
|
let remoteIsInPast;
|
|
@@ -28396,7 +28620,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28396
28620
|
remoteIsInPast = false;
|
|
28397
28621
|
}
|
|
28398
28622
|
if (remoteIsInPast) {
|
|
28399
|
-
if (
|
|
28623
|
+
if (logalot73) {
|
|
28400
28624
|
console.log(`${lc2} [TEST DEBUG] TJP ${tjpAddr}: Remote (sender) is in past - offering push`);
|
|
28401
28625
|
}
|
|
28402
28626
|
const deltaGraph = await getDeltaDependencyGraph({
|
|
@@ -28416,12 +28640,12 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28416
28640
|
space: mySpace
|
|
28417
28641
|
});
|
|
28418
28642
|
} catch (error) {
|
|
28419
|
-
if (
|
|
28643
|
+
if (logalot73) {
|
|
28420
28644
|
console.log(`${lc2} isPastFrame just threw, but is an expected error if we don't have remote. verbose logging error though: ${extractErrorMsg(error)} (I: 47ea08d0b418cf4aa8a502a7bcb80826)`);
|
|
28421
28645
|
}
|
|
28422
28646
|
}
|
|
28423
28647
|
if (receiverIsInPast) {
|
|
28424
|
-
if (
|
|
28648
|
+
if (logalot73) {
|
|
28425
28649
|
console.log(`${lc2} [TEST DEBUG] TJP ${tjpAddr}: receiver is in past - requesting delta`);
|
|
28426
28650
|
}
|
|
28427
28651
|
deltaRequestAddrInfos.push({
|
|
@@ -28430,7 +28654,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28430
28654
|
latestAddrAlreadyHave: receiverTipAddr
|
|
28431
28655
|
});
|
|
28432
28656
|
} else {
|
|
28433
|
-
if (
|
|
28657
|
+
if (logalot73) {
|
|
28434
28658
|
console.log(`${lc2} [TEST DEBUG] TJP ${tjpAddr}: DIVERGENCE DETECTED! conflictStrategy=${conflictStrategy}`);
|
|
28435
28659
|
}
|
|
28436
28660
|
if (conflictStrategy === "abort") {
|
|
@@ -28470,7 +28694,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28470
28694
|
}
|
|
28471
28695
|
const hasTerminalConflicts = conflicts.some((c) => c.terminal);
|
|
28472
28696
|
if (hasTerminalConflicts) {
|
|
28473
|
-
if (
|
|
28697
|
+
if (logalot73) {
|
|
28474
28698
|
console.warn(`${lc2} ABORTING Sync Saga due to terminal conflicts: ${JSON.stringify(conflicts)}`);
|
|
28475
28699
|
}
|
|
28476
28700
|
throw new Error(`the saga has terminal conflicts. conflicts: ${JSON.stringify(conflicts)} (E: f2edbe93cc07a63b38bfc013d2213b26)`);
|
|
@@ -28493,7 +28717,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28493
28717
|
localSpace: mySpace,
|
|
28494
28718
|
metaspace
|
|
28495
28719
|
});
|
|
28496
|
-
if (
|
|
28720
|
+
if (logalot73) {
|
|
28497
28721
|
console.log(`${lc2} ackStone created: ${pretty(ackStone)} (I: 313708132dd53ff946befb7833657826)`);
|
|
28498
28722
|
}
|
|
28499
28723
|
const ackFrame = await this.evolveSyncSagaIbGib({
|
|
@@ -28536,7 +28760,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28536
28760
|
domainAddrs.forEach((x) => searchSecondSpaceAddrs.push(x));
|
|
28537
28761
|
}
|
|
28538
28762
|
if (searchSecondSpaceAddrs.length > 0) {
|
|
28539
|
-
if (
|
|
28763
|
+
if (logalot73) {
|
|
28540
28764
|
console.log(`${lc2} couldn't get all addrs in mySpace (${mySpace.ib}). searchSecondSpaceAddrs: ${searchSecondSpaceAddrs} (I: 233fd954dbd84e51bca02fa8eed5f826)`);
|
|
28541
28765
|
}
|
|
28542
28766
|
const resGet2 = await getFromSpace({ addrs: searchSecondSpaceAddrs, space: myTempSpace });
|
|
@@ -28557,7 +28781,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28557
28781
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
28558
28782
|
throw error;
|
|
28559
28783
|
} finally {
|
|
28560
|
-
if (
|
|
28784
|
+
if (logalot73) {
|
|
28561
28785
|
console.log(`${lc2} complete.`);
|
|
28562
28786
|
}
|
|
28563
28787
|
}
|
|
@@ -28580,7 +28804,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28580
28804
|
async handleAckFrame({ sagaContext, sagaIbGib, initDomainGraph, mySpace, myTempSpace, metaspace }) {
|
|
28581
28805
|
const lc2 = `${this.lc}[${this.handleAckFrame.name}]`;
|
|
28582
28806
|
try {
|
|
28583
|
-
if (
|
|
28807
|
+
if (logalot73) {
|
|
28584
28808
|
console.log(`${lc2} starting... (I: 605b6860e898267a5b50c6d85704be26)`);
|
|
28585
28809
|
}
|
|
28586
28810
|
const { messageData } = await this.getStageAndPayloadFromFrame({ sagaFrame: sagaIbGib, space: mySpace });
|
|
@@ -28592,22 +28816,22 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28592
28816
|
if (ackData.stage !== SyncStage.ack) {
|
|
28593
28817
|
throw new Error(`${lc2} Invalid ack frame: ackData.stage !== SyncStage.ack (E: 2e8b0a94b5954a66a6a1a7a0b3f5b7a1)`);
|
|
28594
28818
|
}
|
|
28595
|
-
if (
|
|
28819
|
+
if (logalot73) {
|
|
28596
28820
|
console.log(`${lc2} ackData: ${pretty(ackData)} (I: b817c5571c5e916fe8f90b892b3e8e26)`);
|
|
28597
28821
|
}
|
|
28598
28822
|
if (!sagaIbGib.data) {
|
|
28599
28823
|
throw new Error(`(UNEXPECTED) sagaIbGib.data falsy? (E: e3f2e8f162484859787651b85c011826)`);
|
|
28600
28824
|
}
|
|
28601
28825
|
const conflicts = ackData.conflicts ? clone(ackData.conflicts) : [];
|
|
28602
|
-
if (
|
|
28826
|
+
if (logalot73) {
|
|
28603
28827
|
console.log(`${lc2} [CONFLICT DEBUG] Received conflicts from Ack: ${conflicts.length}`);
|
|
28604
28828
|
}
|
|
28605
|
-
if (
|
|
28829
|
+
if (logalot73 && conflicts.length > 0) {
|
|
28606
28830
|
console.log(`${lc2} [CONFLICT DEBUG] Conflicts detail: ${JSON.stringify(conflicts, null, 2)}`);
|
|
28607
28831
|
}
|
|
28608
28832
|
const terminalConflicts = conflicts.filter((c) => c.terminal);
|
|
28609
28833
|
if (terminalConflicts.length > 0) {
|
|
28610
|
-
if (
|
|
28834
|
+
if (logalot73) {
|
|
28611
28835
|
console.warn(`${lc2} Received terminal conflicts from Ack: ${JSON.stringify(terminalConflicts)}`);
|
|
28612
28836
|
}
|
|
28613
28837
|
throw new Error(`${lc2} Peer reported terminal conflicts. (E: 23a0096ee05a2ccfa89334e8f156b426)`);
|
|
@@ -28615,7 +28839,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28615
28839
|
const outgoingPayloadIbGibsDomain_conflicts = [];
|
|
28616
28840
|
const activeConflicts = [];
|
|
28617
28841
|
if (conflicts.length > 0) {
|
|
28618
|
-
if (
|
|
28842
|
+
if (logalot73) {
|
|
28619
28843
|
console.log(`${lc2} [CONFLICT DEBUG] Processing ${conflicts.length} non-terminal conflicts`);
|
|
28620
28844
|
}
|
|
28621
28845
|
for (const conflict of conflicts) {
|
|
@@ -28678,7 +28902,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28678
28902
|
});
|
|
28679
28903
|
const isFastForward = latestCommonFrameAddr === receiverTipAddr;
|
|
28680
28904
|
if (isFastForward) {
|
|
28681
|
-
if (
|
|
28905
|
+
if (logalot73) {
|
|
28682
28906
|
console.log(`${lc2} [CONFLICT DEBUG] TJP ${tjpAddr}: Fast-forward detected (receiver behind sender). Excluding from active conflicts and sending delta payload.`);
|
|
28683
28907
|
}
|
|
28684
28908
|
} else {
|
|
@@ -28694,11 +28918,11 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28694
28918
|
} else {
|
|
28695
28919
|
proposeCommit = true;
|
|
28696
28920
|
}
|
|
28697
|
-
if (
|
|
28921
|
+
if (logalot73) {
|
|
28698
28922
|
console.log(`${lc2} [CONFLICT DEBUG] Finished processing ${conflicts.length} conflicts. Active (divergent) conflicts: ${activeConflicts.length}. outgoingPayloadIbGibsDomain_conflicts.length (total outgoing payload ibgibs for ALL conflicts): ${outgoingPayloadIbGibsDomain_conflicts.length}`);
|
|
28699
28923
|
}
|
|
28700
28924
|
} else {
|
|
28701
|
-
if (
|
|
28925
|
+
if (logalot73) {
|
|
28702
28926
|
console.log(`${lc2} [CONFLICT DEBUG] No optimistic conflicts to process`);
|
|
28703
28927
|
}
|
|
28704
28928
|
}
|
|
@@ -28749,7 +28973,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28749
28973
|
proposeCommit
|
|
28750
28974
|
};
|
|
28751
28975
|
let rel8ns = void 0;
|
|
28752
|
-
if (
|
|
28976
|
+
if (logalot73) {
|
|
28753
28977
|
console.log(`${lc2} Creating Delta Stone. Data stage: ${deltaData.stage}`);
|
|
28754
28978
|
}
|
|
28755
28979
|
const deltaStone = await this.createSyncMsgStone({
|
|
@@ -28764,7 +28988,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28764
28988
|
localSpace: mySpace,
|
|
28765
28989
|
metaspace
|
|
28766
28990
|
});
|
|
28767
|
-
if (
|
|
28991
|
+
if (logalot73) {
|
|
28768
28992
|
console.log(`${lc2} Delta Frame created. Rel8ns: ${JSON.stringify(deltaFrame.rel8ns)}`);
|
|
28769
28993
|
}
|
|
28770
28994
|
return { frame: deltaFrame, payloadIbGibsDomain: outgoingPayloadsDomain_all };
|
|
@@ -28772,7 +28996,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28772
28996
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
28773
28997
|
throw error;
|
|
28774
28998
|
} finally {
|
|
28775
|
-
if (
|
|
28999
|
+
if (logalot73) {
|
|
28776
29000
|
console.log(`${lc2} complete.`);
|
|
28777
29001
|
}
|
|
28778
29002
|
}
|
|
@@ -28793,7 +29017,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28793
29017
|
async handleDeltaFrame({ sagaContext, sagaIbGib, mySpace, myTempSpace, metaspace }) {
|
|
28794
29018
|
const lc2 = `${this.lc}[${this.handleDeltaFrame.name}]`;
|
|
28795
29019
|
try {
|
|
28796
|
-
if (
|
|
29020
|
+
if (logalot73) {
|
|
28797
29021
|
console.log(`${lc2} starting... (I: a1d0a85eb4189466f86dfd61e3df2626)`);
|
|
28798
29022
|
}
|
|
28799
29023
|
const { messageData } = await this.getStageAndPayloadFromFrame({ sagaFrame: sagaIbGib, space: mySpace });
|
|
@@ -28810,24 +29034,24 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
28810
29034
|
if (deltaData.stage !== SyncStage.delta) {
|
|
28811
29035
|
throw new Error(`${lc2} Invalid delta frame: deltaData.stage !== SyncStage.delta (E: 0c28c8d8f08a4421b8344e6727271421)`);
|
|
28812
29036
|
}
|
|
28813
|
-
if (
|
|
29037
|
+
if (logalot73) {
|
|
28814
29038
|
console.log(`${lc2} deltaData: ${pretty(deltaData)} (I: a76008681df458cfbcdc4848f825a826)`);
|
|
28815
29039
|
}
|
|
28816
|
-
if (
|
|
29040
|
+
if (logalot73) {
|
|
28817
29041
|
console.log(`${lc2} [CONFLICT DEBUG] deltaData.payloadAddrsDomain count: ${deltaData.payloadAddrsDomain?.length || 0}`);
|
|
28818
29042
|
}
|
|
28819
29043
|
const { conflictStrategy, graftPreference } = sagaIbGib.data;
|
|
28820
29044
|
const { deltaRequestAddrInfos, payloadAddrsDomain, proposeCommit } = deltaData;
|
|
28821
29045
|
const peerProposesCommit = deltaData.proposeCommit ?? false;
|
|
28822
29046
|
const receivedPayloadIbGibs = sagaContext.payloadIbGibsDomain ?? [];
|
|
28823
|
-
if (
|
|
29047
|
+
if (logalot73) {
|
|
28824
29048
|
console.log(`${lc2} [CONFLICT DEBUG] Fulfilling ${(deltaData.deltaRequestAddrInfos || []).length} peer requests`);
|
|
28825
29049
|
}
|
|
28826
29050
|
const outgoingPayload = await this.getPayloadsForRequestedInfos({
|
|
28827
29051
|
deltaRequestAddrInfos: deltaData.deltaRequestAddrInfos || [],
|
|
28828
29052
|
mySpace
|
|
28829
29053
|
});
|
|
28830
|
-
if (
|
|
29054
|
+
if (logalot73) {
|
|
28831
29055
|
console.log(`${lc2} [CONFLICT DEBUG] Outgoing payload size (with deps): ${outgoingPayload.length}`);
|
|
28832
29056
|
}
|
|
28833
29057
|
const conflicts = deltaData.conflicts ? clone(deltaData.conflicts) : [];
|
|
@@ -29028,7 +29252,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29028
29252
|
metaspace
|
|
29029
29253
|
});
|
|
29030
29254
|
if (deltaData.proposeCommit) {
|
|
29031
|
-
if (
|
|
29255
|
+
if (logalot73) {
|
|
29032
29256
|
console.log(`${lc2} Peer proposed commit. Accepting & Committing.`);
|
|
29033
29257
|
}
|
|
29034
29258
|
const commitData = {
|
|
@@ -29057,7 +29281,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29057
29281
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
29058
29282
|
throw error;
|
|
29059
29283
|
} finally {
|
|
29060
|
-
if (
|
|
29284
|
+
if (logalot73) {
|
|
29061
29285
|
console.log(`${lc2} complete.`);
|
|
29062
29286
|
}
|
|
29063
29287
|
}
|
|
@@ -29068,7 +29292,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29068
29292
|
async executeLocalCommit({ deltaFrame, commitFrame, sagaHistory, metaspace, localSpace, localTempSpace }) {
|
|
29069
29293
|
const lc2 = `${this.lc}[${this.executeLocalCommit.name}]`;
|
|
29070
29294
|
try {
|
|
29071
|
-
if (
|
|
29295
|
+
if (logalot73) {
|
|
29072
29296
|
console.log(`${lc2} starting... (I: 6734980446b86a63c1af6e2e206de826)`);
|
|
29073
29297
|
}
|
|
29074
29298
|
if (!deltaFrame && !commitFrame) {
|
|
@@ -29082,7 +29306,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29082
29306
|
throw new Error(`(UNEXPECTED) !currentFrame? something wrong with my logic. (E: 4ec0ce6625cc1d677bc902c839ca1a26)`);
|
|
29083
29307
|
}
|
|
29084
29308
|
const currentFrameOrigin = getSyncSagaFrameOrigin({ sagaFrame: currentFrame });
|
|
29085
|
-
if (
|
|
29309
|
+
if (logalot73) {
|
|
29086
29310
|
console.log(`${lc2} currentFrameOrigin: ${currentFrameOrigin} (I: 3add8f8390c89743ae554bd3cc60b826)`);
|
|
29087
29311
|
}
|
|
29088
29312
|
if (!currentFrame.data) {
|
|
@@ -29125,7 +29349,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29125
29349
|
}
|
|
29126
29350
|
});
|
|
29127
29351
|
});
|
|
29128
|
-
if (
|
|
29352
|
+
if (logalot73) {
|
|
29129
29353
|
console.log(`${lc2}[${currentFrameOrigin}] allPayloadAddrsDomainTransferred: ${allPayloadAddrsDomainReceived.length > 0 ? allPayloadAddrsDomainReceived.join(", ") : "none"} (I: a1950eb3ca95bdc9ec18a4b8823e9826)`);
|
|
29130
29354
|
}
|
|
29131
29355
|
let allPayloadIbGibsDomainTransferred = [];
|
|
@@ -29164,7 +29388,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29164
29388
|
throw new Error(`(UNEXPECTED) finalConflict.createdDnaAddrs falsy/empty? (E: 9689f8be5bd19650b8d4a058b65db826)`);
|
|
29165
29389
|
}
|
|
29166
29390
|
if (!replayedDnaAddrs || replayedDnaAddrs.length === 0) {
|
|
29167
|
-
if (
|
|
29391
|
+
if (logalot73) {
|
|
29168
29392
|
console.log(`${lc2} finalConflict.replayedDnaAddrs falsy/empty (I: e88eb8a76b5815e07f10cbb2fa2ab826)`);
|
|
29169
29393
|
}
|
|
29170
29394
|
}
|
|
@@ -29182,21 +29406,21 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29182
29406
|
allPayloadIbGibsDomainTransferred.forEach((x) => allTransferredOrCreatedFromGraftIbGibs.push(x));
|
|
29183
29407
|
createdFromConflictGraftsIbGibs.forEach((x) => allTransferredOrCreatedFromGraftIbGibs.push(x));
|
|
29184
29408
|
if (allTransferredOrCreatedFromGraftIbGibs.length === 0) {
|
|
29185
|
-
if (
|
|
29409
|
+
if (logalot73) {
|
|
29186
29410
|
console.log(`${lc2}[${currentFrameOrigin}] no changes on this end (I: fa30d18e83a87ee9e8487fbb5d632b26)`);
|
|
29187
29411
|
}
|
|
29188
29412
|
} else {
|
|
29189
|
-
if (
|
|
29413
|
+
if (logalot73) {
|
|
29190
29414
|
console.log(`${lc2}[${currentFrameOrigin}] ${allTransferredOrCreatedFromGraftIbGibs.length} changes detected (I: fa30d18e83a87ee9e8487fbb5d632b26)`);
|
|
29191
29415
|
}
|
|
29192
|
-
if (
|
|
29416
|
+
if (logalot73) {
|
|
29193
29417
|
console.log(`${lc2} put all into localSpace (${localSpace.ib}) starting... (I: d5e0d9870e380b61e80c729660058826)`);
|
|
29194
29418
|
}
|
|
29195
29419
|
const { payload_Dnas, payload_NonDnas } = await putInSpace_dnasThenNonDnas({
|
|
29196
29420
|
ibGibs: allTransferredOrCreatedFromGraftIbGibs,
|
|
29197
29421
|
space: localSpace
|
|
29198
29422
|
});
|
|
29199
|
-
if (
|
|
29423
|
+
if (logalot73) {
|
|
29200
29424
|
console.log(`${lc2} put all into localSpace (${localSpace.ib}) complete. (I: d5e0d9870e380b61e80c729660058826)`);
|
|
29201
29425
|
}
|
|
29202
29426
|
const orphanedAddresses = await getAllOrphanedAddresses({
|
|
@@ -29207,12 +29431,12 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29207
29431
|
myTempSpace: localTempSpace
|
|
29208
29432
|
});
|
|
29209
29433
|
const { mapWithTjp_NoDna, mapWithTjp_YesDna, mapWithoutTjps } = splitPerTjpAndOrDna({ ibGibs: payload_NonDnas, filterPrimitives: true });
|
|
29210
|
-
if (
|
|
29434
|
+
if (logalot73) {
|
|
29211
29435
|
console.log(`${lc2} register mapWithoutTjps starting... (I: 2b84d8f8dda85adde88696d8419bf726)`);
|
|
29212
29436
|
}
|
|
29213
29437
|
const nonTjpIbGibs = Object.values(mapWithoutTjps);
|
|
29214
29438
|
for (const nontjp of nonTjpIbGibs) {
|
|
29215
|
-
if (
|
|
29439
|
+
if (logalot73) {
|
|
29216
29440
|
console.log(`${lc2} registering ${getIbGibAddr({ ibGib: nontjp })} (I: 4647b4f42d27cffe0fbfce8846755826)`);
|
|
29217
29441
|
}
|
|
29218
29442
|
await metaspace.registerNewIbGib({
|
|
@@ -29220,10 +29444,10 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29220
29444
|
space: localSpace
|
|
29221
29445
|
});
|
|
29222
29446
|
}
|
|
29223
|
-
if (
|
|
29447
|
+
if (logalot73) {
|
|
29224
29448
|
console.log(`${lc2} mapWithoutTjps complete. (I: 2b84d8f8dda85adde88696d8419bf726)`);
|
|
29225
29449
|
}
|
|
29226
|
-
if (
|
|
29450
|
+
if (logalot73) {
|
|
29227
29451
|
console.log(`${lc2} register mapWithTjp_NoDna starting... (I: 96e648e4db382499b8bfaa1b37c24826)`);
|
|
29228
29452
|
}
|
|
29229
29453
|
const timelinesByTjpAddr_NoDna = getTimelinesGroupedByTjp({ ibGibs: Object.values(mapWithTjp_NoDna) });
|
|
@@ -29237,10 +29461,10 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29237
29461
|
});
|
|
29238
29462
|
}
|
|
29239
29463
|
}
|
|
29240
|
-
if (
|
|
29464
|
+
if (logalot73) {
|
|
29241
29465
|
console.log(`${lc2} register mapWithTjp_NoDna complete. (I: 96e648e4db382499b8bfaa1b37c24826)`);
|
|
29242
29466
|
}
|
|
29243
|
-
if (
|
|
29467
|
+
if (logalot73) {
|
|
29244
29468
|
console.log(`${lc2} register mapWithTjp_YesDna starting... (I: d54a820e9442dee4681f6228a6795926)`);
|
|
29245
29469
|
}
|
|
29246
29470
|
const timelinesByTjpAddr_YesDna = getTimelinesGroupedByTjp({ ibGibs: Object.values(mapWithTjp_YesDna) });
|
|
@@ -29256,7 +29480,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29256
29480
|
}
|
|
29257
29481
|
}
|
|
29258
29482
|
}
|
|
29259
|
-
if (
|
|
29483
|
+
if (logalot73) {
|
|
29260
29484
|
console.log(`${lc2} register mapWithTjp_YesDna complete. (I: d54a820e9442dee4681f6228a6795926)`);
|
|
29261
29485
|
}
|
|
29262
29486
|
}
|
|
@@ -29264,7 +29488,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29264
29488
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
29265
29489
|
throw error;
|
|
29266
29490
|
} finally {
|
|
29267
|
-
if (
|
|
29491
|
+
if (logalot73) {
|
|
29268
29492
|
console.log(`${lc2} complete.`);
|
|
29269
29493
|
}
|
|
29270
29494
|
}
|
|
@@ -29272,7 +29496,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29272
29496
|
async createCommitFrame({ sagaIbGib, errors, metaspace, mySpace }) {
|
|
29273
29497
|
const lc2 = `[${this.createCommitFrame.name}]`;
|
|
29274
29498
|
try {
|
|
29275
|
-
if (
|
|
29499
|
+
if (logalot73) {
|
|
29276
29500
|
console.log(`${lc2} starting... (I: 48fc57c023f80122135a284855757526)`);
|
|
29277
29501
|
}
|
|
29278
29502
|
const commitData = errors && errors.length > 0 ? {
|
|
@@ -29303,7 +29527,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29303
29527
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
29304
29528
|
throw error;
|
|
29305
29529
|
} finally {
|
|
29306
|
-
if (
|
|
29530
|
+
if (logalot73) {
|
|
29307
29531
|
console.log(`${lc2} complete.`);
|
|
29308
29532
|
}
|
|
29309
29533
|
}
|
|
@@ -29311,7 +29535,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29311
29535
|
async handleCommitFrame({ sagaIbGib, mySpace, myTempSpace, metaspace }) {
|
|
29312
29536
|
const lc2 = `${this.lc}[${this.handleCommitFrame.name}]`;
|
|
29313
29537
|
try {
|
|
29314
|
-
if (
|
|
29538
|
+
if (logalot73) {
|
|
29315
29539
|
console.log(`${lc2} starting... (I: e179573bdd881202f8ba3168da1c3826)`);
|
|
29316
29540
|
}
|
|
29317
29541
|
if (!sagaIbGib.data) {
|
|
@@ -29344,7 +29568,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29344
29568
|
metaspace
|
|
29345
29569
|
});
|
|
29346
29570
|
console.error(`${lc2} NAG ERROR (NOT THROWN): implement cleanup logic, including add a cleanup method to the peer (E: 3a9a24befb98a981a88fbdbf52920e26)`);
|
|
29347
|
-
if (
|
|
29571
|
+
if (logalot73) {
|
|
29348
29572
|
console.log(`${lc2} Peer committed. Finalizing saga locally. Saga Complete.`);
|
|
29349
29573
|
}
|
|
29350
29574
|
return { sagaComplete: true };
|
|
@@ -29360,7 +29584,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29360
29584
|
});
|
|
29361
29585
|
return { frame: errorCommitFrame };
|
|
29362
29586
|
} finally {
|
|
29363
|
-
if (
|
|
29587
|
+
if (logalot73) {
|
|
29364
29588
|
console.log(`${lc2} complete.`);
|
|
29365
29589
|
}
|
|
29366
29590
|
}
|
|
@@ -29369,7 +29593,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29369
29593
|
async createSyncMsgStone({ data, rel8ns, localSpace, metaspace }) {
|
|
29370
29594
|
const lc2 = `${this.lc}[${this.createSyncMsgStone.name}]`;
|
|
29371
29595
|
try {
|
|
29372
|
-
if (
|
|
29596
|
+
if (logalot73) {
|
|
29373
29597
|
console.log(`${lc2} starting... (I: 5f7f98e8ff980364f7191fcee4531e26)`);
|
|
29374
29598
|
}
|
|
29375
29599
|
const ib = await getSyncSagaMessageIb({ data });
|
|
@@ -29381,7 +29605,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29381
29605
|
uuid: true
|
|
29382
29606
|
// we want the stone to have its own uniqueness
|
|
29383
29607
|
});
|
|
29384
|
-
if (
|
|
29608
|
+
if (logalot73) {
|
|
29385
29609
|
console.log(`${lc2} Created stone: ${getIbGibAddr({ ibGib: stone })}`);
|
|
29386
29610
|
}
|
|
29387
29611
|
await metaspace.put({ ibGib: stone, space: localSpace });
|
|
@@ -29391,7 +29615,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29391
29615
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
29392
29616
|
throw error;
|
|
29393
29617
|
} finally {
|
|
29394
|
-
if (
|
|
29618
|
+
if (logalot73) {
|
|
29395
29619
|
console.log(`${lc2} complete.`);
|
|
29396
29620
|
}
|
|
29397
29621
|
}
|
|
@@ -29399,7 +29623,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29399
29623
|
async getPayloadsForRequestedInfos({ deltaRequestAddrInfos, mySpace }) {
|
|
29400
29624
|
const lc2 = `${this.lc}[${this.getPayloadsForRequestedInfos.name}]`;
|
|
29401
29625
|
try {
|
|
29402
|
-
if (
|
|
29626
|
+
if (logalot73) {
|
|
29403
29627
|
console.log(`${lc2} starting... (I: 4fe13d0d80050f20a8b74ba80cee5826)`);
|
|
29404
29628
|
}
|
|
29405
29629
|
const outgoingPayloadIbGibsDomainGraph = {};
|
|
@@ -29434,7 +29658,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29434
29658
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
29435
29659
|
throw error;
|
|
29436
29660
|
} finally {
|
|
29437
|
-
if (
|
|
29661
|
+
if (logalot73) {
|
|
29438
29662
|
console.log(`${lc2} complete.`);
|
|
29439
29663
|
}
|
|
29440
29664
|
}
|
|
@@ -29537,7 +29761,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29537
29761
|
async getStageAndPayloadFromFrame({ sagaFrame, space }) {
|
|
29538
29762
|
const lc2 = `${this.lc}[${this.getStageAndPayloadFromFrame.name}]`;
|
|
29539
29763
|
try {
|
|
29540
|
-
if (
|
|
29764
|
+
if (logalot73) {
|
|
29541
29765
|
console.log(`${lc2} starting... (I: fddc287bd4d55253dc50e519fd352226)`);
|
|
29542
29766
|
}
|
|
29543
29767
|
if (!sagaFrame.rel8ns) {
|
|
@@ -29566,7 +29790,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29566
29790
|
console.error(`${lc2} ${extractErrorMsg(error)}`);
|
|
29567
29791
|
throw error;
|
|
29568
29792
|
} finally {
|
|
29569
|
-
if (
|
|
29793
|
+
if (logalot73) {
|
|
29570
29794
|
console.log(`${lc2} complete.`);
|
|
29571
29795
|
}
|
|
29572
29796
|
}
|
|
@@ -29626,7 +29850,7 @@ var SyncSagaCoordinator = class _SyncSagaCoordinator {
|
|
|
29626
29850
|
};
|
|
29627
29851
|
|
|
29628
29852
|
// ../../libs/node-gib/dist/serve-gib/handlers/ws/sync-upgrade-handler-base.mjs
|
|
29629
|
-
var
|
|
29853
|
+
var logalot74 = GLOBAL_LOG_A_LOT;
|
|
29630
29854
|
var SyncUpgradeHandlerBase = class _SyncUpgradeHandlerBase extends ServeGibHandlerWithMetaspaceBase {
|
|
29631
29855
|
lc = `[${_SyncUpgradeHandlerBase.name}]`;
|
|
29632
29856
|
method = "GET";
|
|
@@ -29637,7 +29861,7 @@ var SyncUpgradeHandlerBase = class _SyncUpgradeHandlerBase extends ServeGibHandl
|
|
|
29637
29861
|
async handleUpgrade(reqCtx, socket, head) {
|
|
29638
29862
|
const lc_fn = `${this.lc}[handleUpgrade]`;
|
|
29639
29863
|
try {
|
|
29640
|
-
if (
|
|
29864
|
+
if (logalot74) {
|
|
29641
29865
|
console.log(`${lc_fn} starting...`);
|
|
29642
29866
|
}
|
|
29643
29867
|
if (!this.canHandleRoute(reqCtx)) {
|
|
@@ -29675,7 +29899,7 @@ var SyncUpgradeHandlerBase = class _SyncUpgradeHandlerBase extends ServeGibHandl
|
|
|
29675
29899
|
// Resolved dynamically inside runtime turns
|
|
29676
29900
|
});
|
|
29677
29901
|
socket.on("error", (err) => {
|
|
29678
|
-
if (
|
|
29902
|
+
if (logalot74) {
|
|
29679
29903
|
console.warn(`[SyncUpgradeHandlerBase] Socket error: ${extractErrorMsg(err)}`);
|
|
29680
29904
|
}
|
|
29681
29905
|
try {
|
|
@@ -29689,7 +29913,7 @@ var SyncUpgradeHandlerBase = class _SyncUpgradeHandlerBase extends ServeGibHandl
|
|
|
29689
29913
|
try {
|
|
29690
29914
|
socket.write(encodeTextFrame(data));
|
|
29691
29915
|
} catch (e) {
|
|
29692
|
-
if (
|
|
29916
|
+
if (logalot74) {
|
|
29693
29917
|
console.warn(`[SyncUpgradeHandlerBase] failed to write message frame: ${extractErrorMsg(e)}`);
|
|
29694
29918
|
}
|
|
29695
29919
|
}
|
|
@@ -29706,7 +29930,7 @@ var SyncUpgradeHandlerBase = class _SyncUpgradeHandlerBase extends ServeGibHandl
|
|
|
29706
29930
|
frameText = decoder.nextFrame();
|
|
29707
29931
|
}
|
|
29708
29932
|
} catch (error) {
|
|
29709
|
-
if (
|
|
29933
|
+
if (logalot74) {
|
|
29710
29934
|
console.warn(`[SyncUpgradeHandlerBase] closing connection due to decoder error: ${extractErrorMsg(error)}`);
|
|
29711
29935
|
}
|
|
29712
29936
|
if (socket.writable) {
|
|
@@ -29843,8 +30067,8 @@ function getStandardServeGibHandlers(opts = {}) {
|
|
|
29843
30067
|
// src/server/server.mts
|
|
29844
30068
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
29845
30069
|
var PORT = parseInt(process.env.PORT ?? "3000", 10);
|
|
29846
|
-
var DATA_DIR = process.env.DATA_DIR ??
|
|
29847
|
-
var CLIENT_DIR =
|
|
30070
|
+
var DATA_DIR = process.env.DATA_DIR ?? join11(__dirname, "../../.data/ibgib-space");
|
|
30071
|
+
var CLIENT_DIR = join11(__dirname, "../client");
|
|
29848
30072
|
async function main() {
|
|
29849
30073
|
const lc2 = "[space-gib server]";
|
|
29850
30074
|
try {
|