@ibgib/core-gib 0.0.64 → 0.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/other/other-constants.d.mts +0 -2
- package/dist/common/other/other-constants.d.mts.map +1 -1
- package/dist/common/other/other-constants.mjs +0 -2
- package/dist/common/other/other-constants.mjs.map +1 -1
- package/dist/witness/app/app-helper.d.mts +0 -1
- package/dist/witness/app/app-helper.d.mts.map +1 -1
- package/dist/witness/app/app-helper.mjs +3 -3
- package/dist/witness/app/app-helper.mjs.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.d.mts +9 -59
- package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.mjs +299 -315
- package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -1
- package/dist/witness/space/metaspace/metaspace-types.d.mts +6 -29
- package/dist/witness/space/metaspace/metaspace-types.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-helper.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-helper.mjs +5 -0
- package/dist/witness/space/outer-space/outer-space-helper.mjs.map +1 -1
- package/dist/witness/space/outer-space/outer-space-types.d.mts +9 -4
- package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -1
- package/dist/witness/space/outer-space/outer-space-types.mjs +0 -1
- package/dist/witness/space/outer-space/outer-space-types.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/other/other-constants.mts +0 -4
- package/src/witness/app/app-helper.mts +3 -3
- package/src/witness/space/metaspace/metaspace-base.mts +326 -371
- package/src/witness/space/metaspace/metaspace-types.mts +27 -62
- package/src/witness/space/outer-space/outer-space-helper.mts +9 -0
- package/src/witness/space/outer-space/outer-space-types.mts +9 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { delay, getUUID, groupBy, pretty } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
2
|
import { encrypt, decrypt, } from '@ibgib/encrypt-gib/dist/encrypt-decrypt.mjs';
|
|
3
|
+
import { DEFAULT_ALPHABET_INDEXING_MODE_BLOCKMODE, DEFAULT_ALPHABET_INDEXING_MODE_LEGACY } from '@ibgib/encrypt-gib/dist/constants.mjs';
|
|
3
4
|
import { IbGib_V1, } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
4
5
|
import { GIB, GIB_DELIMITER, IB, ROOT, } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
5
6
|
import { IbGibAddr, TjpIbGibAddr, TransformResult, } from '@ibgib/ts-gib/dist/types.mjs';
|
|
@@ -14,7 +15,8 @@ import {
|
|
|
14
15
|
} from '../../../common/other/other-types.mjs';
|
|
15
16
|
import { TagIbGib_V1 } from '../../../common/tag/tag-types.mjs';
|
|
16
17
|
import {
|
|
17
|
-
|
|
18
|
+
OuterSpaceData,
|
|
19
|
+
ParticipantInfo, StatusCode, SyncSagaInfo, SyncSpaceIbGib, SyncSpaceOptionsData,
|
|
18
20
|
SyncSpaceOptionsIbGib, SyncSpaceResultIbGib, SyncStatusIbGib,
|
|
19
21
|
} from '../../../witness/space/outer-space/outer-space-types.mjs';
|
|
20
22
|
import { IbGibSpaceData, IbGibSpaceRel8ns, SpaceId } from '../../../witness/space/space-types.mjs';
|
|
@@ -49,7 +51,7 @@ import { spaceNameIsValid, } from '../../../witness/space/space-helper.mjs';
|
|
|
49
51
|
import { RobbotPromptResult } from '../../../witness/robbot/robbot-types.mjs';
|
|
50
52
|
import { createNewRobbot, validateCommonRobbotData, validateCommonRobbotIbGib } from '../../../witness/robbot/robbot-helper.mjs';
|
|
51
53
|
import { AppPromptResult } from '../../../witness/app/app-types.mjs';
|
|
52
|
-
import { createNewApp,
|
|
54
|
+
import { createNewApp, } from '../../../witness/app/app-helper.mjs';
|
|
53
55
|
import { CommentIbGib_V1, UpdateCommentPromptResult } from '../../../common/comment/comment-types.mjs';
|
|
54
56
|
import { IbGibCacheService } from '../../../common/cache/cache-types.mjs';
|
|
55
57
|
import { BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY, BOOTSTRAP_IBGIB_ADDR } from '../../../witness/space/bootstrap/bootstrap-constants.mjs';
|
|
@@ -1879,19 +1881,19 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1879
1881
|
const lc = `${this.lc}[${this.getPlaintextString.name}]`;
|
|
1880
1882
|
try {
|
|
1881
1883
|
// validate
|
|
1882
|
-
if ((secretIbGibs || []).length === 0) { throw new Error(`secretIbGibs required
|
|
1884
|
+
if ((secretIbGibs || []).length === 0) { throw new Error(`secretIbGibs required. (E: 99a605b540c54b6db4d2ffe2caeb226a)`); }
|
|
1883
1885
|
if (!ciphertextIbGib.data) { throw new Error(`ciphertextIbGib.data falsy (E: 598fc6473149e240a7d6916ecf642323)`); }
|
|
1884
1886
|
if (!ciphertextIbGib.data.ciphertext) { throw new Error(`ciphertextIbGib.data.ciphertext falsy (E: 0e764a71ec214132a5a528f17f495a7c)`); }
|
|
1885
|
-
if (!ciphertextIbGib.rel8ns?.encryption) { throw new Error(`ciphertextIbGib.rel8ns.encryption falsy`) }
|
|
1886
|
-
if (ciphertextIbGib.rel8ns!.encryption!.length !== 1) { throw new Error(`ciphertextIbGib.rel8ns!.encryption!.length !== 1`); }
|
|
1887
|
+
if (!ciphertextIbGib.rel8ns?.encryption) { throw new Error(`ciphertextIbGib.rel8ns.encryption falsy (E: a0b4d5d8674b4d0191fa619164153022)`) }
|
|
1888
|
+
if (ciphertextIbGib.rel8ns!.encryption!.length !== 1) { throw new Error(`ciphertextIbGib.rel8ns!.encryption!.length !== 1 (E: a4a463e1ef0e45b4917eb04cb40d8173)`); }
|
|
1887
1889
|
|
|
1888
1890
|
// get corresponding encryption ibgib for encryption settings
|
|
1889
1891
|
const encryptionAddr = ciphertextIbGib.rel8ns!.encryption![0];
|
|
1890
1892
|
const resEncryption = await this.get({ addr: encryptionAddr, space });
|
|
1891
|
-
if (!resEncryption.success) { throw new Error(`get encryption failed`); }
|
|
1892
|
-
if ((resEncryption.ibGibs || []).length !== 1) { throw new Error(`get encryption retrieved non-1 length (eesh)`); }
|
|
1893
|
+
if (!resEncryption.success) { throw new Error(`get encryption failed (E: feef34c05fae439c81ade7fc23037af1)`); }
|
|
1894
|
+
if ((resEncryption.ibGibs || []).length !== 1) { throw new Error(`get encryption retrieved non-1 length (eesh) (E: 5d7e2023cc2b4e349574c17d5cfc8867)`); }
|
|
1893
1895
|
const encryptionIbGib = resEncryption.ibGibs![0] as IbGib_V1<EncryptionData_V1>;
|
|
1894
|
-
if (!encryptionIbGib.data) { throw new Error(
|
|
1896
|
+
if (!encryptionIbGib.data) { throw new Error(`encryptionIbGib.data falsy (E: 409a243afbf24c20987524f6588816fa)`); }
|
|
1895
1897
|
|
|
1896
1898
|
// prompt user for the password
|
|
1897
1899
|
const password = await this.getPasswordForSecrets({
|
|
@@ -1904,13 +1906,23 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1904
1906
|
|
|
1905
1907
|
// we're about the decrypt, but maybe the data doesn't have everything.
|
|
1906
1908
|
// So WARN for any defaults we're using.
|
|
1907
|
-
if (!encryptionIbGib.data.initialRecursions) { console.warn(`${lc} using default initialRecursions`); }
|
|
1908
|
-
if (!encryptionIbGib.data.recursionsPerHash) { console.warn(`${lc} using default recursionsPerHash`); }
|
|
1909
|
-
if (!encryptionIbGib.data.saltStrategy) { console.warn(`${lc} using default saltStrategy`); }
|
|
1910
|
-
if (!encryptionIbGib.data.hashAlgorithm) { console.warn(`${lc} using default hashAlgorithm`); }
|
|
1909
|
+
if (!encryptionIbGib.data.initialRecursions) { console.warn(`${lc} using default initialRecursions because encryptionIbGib does not state this explicitly (W: 66774cbfccd44423949d34167da6d50b)`); }
|
|
1910
|
+
if (!encryptionIbGib.data.recursionsPerHash) { console.warn(`${lc} using default recursionsPerHash because encryptionIbGib does not state this explicitly (W: 29e264094f384d259319ba8587cd4f63)`); }
|
|
1911
|
+
if (!encryptionIbGib.data.saltStrategy) { console.warn(`${lc} using default saltStrategy because encryptionIbGib does not state this explicitly (W: 7a5acadb8d634c7e87f62c86b57ac7a2)`); }
|
|
1912
|
+
if (!encryptionIbGib.data.hashAlgorithm) { console.warn(`${lc} using default hashAlgorithm because encryptionIbGib does not state this explicitly(W: 2254db3569534b239a8c471b700c8500)`); }
|
|
1913
|
+
|
|
1914
|
+
const defaultIndexingMode = encryptionIbGib.data.blockMode ?
|
|
1915
|
+
DEFAULT_ALPHABET_INDEXING_MODE_BLOCKMODE :
|
|
1916
|
+
DEFAULT_ALPHABET_INDEXING_MODE_LEGACY;
|
|
1917
|
+
if (encryptionIbGib.data.blockMode) {
|
|
1918
|
+
if (!encryptionIbGib.data.blockModeOptions) { throw new Error(`invalid encryptionIbGib.data. blockMode is truthy but blockModeOptions is falsy. (E: 84bbc27a5248b7c4734a1674e41dd224)`); }
|
|
1919
|
+
if (!encryptionIbGib.data.indexingMode) {
|
|
1920
|
+
console.warn(`${lc} not complete. using default indexingMode ${defaultIndexingMode} because encryptionIbGib does not state this explicitly. (W: c15797cd8d0740ea886a348c10be2e5c)`)
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1911
1923
|
|
|
1912
1924
|
// do actual decryption
|
|
1913
|
-
if (logalot) { console.log(`${lc} starting decrypt
|
|
1925
|
+
if (logalot) { console.log(`${lc} starting decrypt... (I: e14176ebc9a7470fb977d2184f1e2430)`); }
|
|
1914
1926
|
const timerName = 'sync_log decrypt';
|
|
1915
1927
|
console.time(timerName);
|
|
1916
1928
|
console.timeLog(timerName, 'decrypting...');
|
|
@@ -1927,10 +1939,12 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1927
1939
|
hashAlgorithm:
|
|
1928
1940
|
encryptionIbGib.data.hashAlgorithm || DEFAULT_ENCRYPTION_HASH_ALGORITHM,
|
|
1929
1941
|
encryptedDataDelimiter: encryptionIbGib.data.encryptedDataDelimiter,
|
|
1942
|
+
blockMode: encryptionIbGib.data.blockMode ? encryptionIbGib.data.blockModeOptions! : undefined,
|
|
1943
|
+
indexingMode: encryptionIbGib.data.indexingMode || defaultIndexingMode,
|
|
1930
1944
|
});
|
|
1931
1945
|
console.timeLog(timerName, 'decrypting complete.');
|
|
1932
1946
|
console.timeEnd(timerName);
|
|
1933
|
-
if (logalot) { console.log(`${lc} decrypt complete
|
|
1947
|
+
if (logalot) { console.log(`${lc} decrypt complete. (I: 15a8182230294a8a96504ba3667f039a)`); }
|
|
1934
1948
|
if (resDecrypt.errors?.length ?? 0 > 0) { throw new Error(resDecrypt.errors!.join('|')); }
|
|
1935
1949
|
|
|
1936
1950
|
if (!resDecrypt.decryptedData) { throw new Error(`(UNEXPECTED) resDecrypt has no errors but resDecrypt.decryptedData falsy? (E: 06e73992fb02e45e3c18db33f9a61b23)`); }
|
|
@@ -1943,76 +1957,76 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1943
1957
|
}
|
|
1944
1958
|
}
|
|
1945
1959
|
|
|
1946
|
-
async unwrapEncryptedSyncSpace({
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
}: {
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
}): Promise<IbGibSpaceAny> {
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
}
|
|
1960
|
+
// async unwrapEncryptedSyncSpace({
|
|
1961
|
+
// encryptedSpace,
|
|
1962
|
+
// fnPromptPassword,
|
|
1963
|
+
// dontPrompt,
|
|
1964
|
+
// space,
|
|
1965
|
+
// fnSpaceFactory,
|
|
1966
|
+
// }: {
|
|
1967
|
+
// encryptedSpace: IbGibSpaceAny,
|
|
1968
|
+
// fnPromptPassword: (title: string, msg: string) => Promise<string | null>,
|
|
1969
|
+
// dontPrompt?: boolean,
|
|
1970
|
+
// space?: IbGibSpaceAny,
|
|
1971
|
+
// fnSpaceFactory: (syncSpaceIbGib: SyncSpaceIbGib) => Promise<IbGibSpaceAny>,
|
|
1972
|
+
// }): Promise<IbGibSpaceAny> {
|
|
1973
|
+
// const lc = `${this.lc}[${this.unwrapEncryptedSyncSpace.name}]`;
|
|
1974
|
+
// try {
|
|
1975
|
+
// // validation
|
|
1976
|
+
// if (!space) { throw new Error(`space required (E: d4d3eaa2d7b9143cf1173b8ae6344c23)`); }
|
|
1977
|
+
// if (!encryptedSpace.rel8ns?.ciphertext) { throw new Error(`encryptedSpace is not a ciphertext (E: be5504a5e2b84f3eaa8fbd6e13aab659)`); }
|
|
1978
|
+
// if (encryptedSpace.rel8ns!.ciphertext!.length !== 1) { throw new Error(`only 1 ciphertext rel8n allowed... (E: e8ab2ec38ad844dfb229efc5b8981946)`); }
|
|
1979
|
+
|
|
1980
|
+
// // get ciphertext ibgib
|
|
1981
|
+
// const ciphertextAddr = encryptedSpace.rel8ns!.ciphertext![0];
|
|
1982
|
+
// const resCiphertext = await this.get({ addr: ciphertextAddr, space });
|
|
1983
|
+
// if (!resCiphertext.success) { throw new Error(`get ciphertext failed (E: e58b3471c0334cd7bc626998106e6547)`); }
|
|
1984
|
+
// if ((resCiphertext.ibGibs || []).length !== 1) { throw new Error(`get ciphertext retrieved non-1 length (eesh) (E: a3a1f00e827b4f88a42b4a7433cf1065)`); }
|
|
1985
|
+
// const ciphertextIbGib = resCiphertext.ibGibs![0] as CiphertextIbGib_V1;
|
|
1986
|
+
|
|
1987
|
+
// // get secrets associated with enciphered space
|
|
1988
|
+
// if (!encryptedSpace.rel8ns?.secret) { throw new Error(`!encryptionIbGib.rel8ns?.secret (E: 8bfed1541976433da9402d7d3a9138dd)`); }
|
|
1989
|
+
// const secretAddrs = encryptedSpace.rel8ns!.secret!;
|
|
1990
|
+
// const localUserSpace = await this.getLocalUserSpace({});
|
|
1991
|
+
// if (!localUserSpace) { throw new Error(`(UNEXPECTED) could not get localUserSpace? (E: 3c5687a15b3b58e3dcf1eca4f5fe5723) (E: c123b340177647968e10a6b119d84d2b)`); }
|
|
1992
|
+
// const argGetSecrets = await localUserSpace.argy({
|
|
1993
|
+
// argData: { ibGibAddrs: secretAddrs, cmd: 'get', }
|
|
1994
|
+
// });
|
|
1995
|
+
// const resSecrets = await localUserSpace.witness(argGetSecrets);
|
|
1996
|
+
// if (!resSecrets.data?.success || (resSecrets.ibGibs || []).length === 0) {
|
|
1997
|
+
// throw new Error(`couldn't get secret ibgibs (E: cb17687f842f4296a9ecf89d9a568e46)`);
|
|
1998
|
+
// }
|
|
1999
|
+
// const secretIbGibs = resSecrets.ibGibs.concat() as IbGib_V1<SecretData_V1>[];
|
|
2000
|
+
|
|
2001
|
+
// // get plaintext now that we have the ciphertext ibgib and secret ibgib(s)
|
|
2002
|
+
// const plaintextString = await this.getPlaintextString({
|
|
2003
|
+
// ciphertextIbGib,
|
|
2004
|
+
// fnPromptPassword,
|
|
2005
|
+
// dontPrompt,
|
|
2006
|
+
// secretIbGibs,
|
|
2007
|
+
// space,
|
|
2008
|
+
// });
|
|
2009
|
+
|
|
2010
|
+
// const syncSpaceData = JSON.parse(plaintextString) as OuterSpaceData;
|
|
2011
|
+
// if (syncSpaceData.type !== 'sync') { throw new Error(`syncSpaceData.type !== 'sync'...this is the only one implemented right now (E: 509b2373d6f8445ebe5bd6f27f62af93)`); }
|
|
2012
|
+
// if (syncSpaceData.subtype !== 'aws-dynamodb') { throw new Error(`syncSpaceData.subtype !== 'aws-dynamodb'...only one right now dude (E: b5caaf3b4c60438eb2cee58ce8e1d3f6)`); }
|
|
2013
|
+
|
|
2014
|
+
// // this is the original aws only implementation. I've just added (untested)
|
|
2015
|
+
// // a quick factory function where the consumer would do the following code.
|
|
2016
|
+
// const unwrappedSpace = await fnSpaceFactory(syncSpaceData);
|
|
2017
|
+
// return unwrappedSpace;
|
|
2018
|
+
// // so we have a syncspace data (only aws-dynamodb space right now).
|
|
2019
|
+
// // load this data into a space class with behavior (not just the dto).
|
|
2020
|
+
// // const awsSpace = new AWSDynamoSpace_V1(syncSpaceData, null);
|
|
2021
|
+
// // awsSpace.gib = await getGib({ ibGib: awsSpace, hasTjp: false });
|
|
2022
|
+
// // if (logalot) { console.log(`awsSpace.gib: ${awsSpace.gib}`); }
|
|
2023
|
+
// // return awsSpace;
|
|
2024
|
+
|
|
2025
|
+
// } catch (error) {
|
|
2026
|
+
// console.error(`${lc} ${error.message}`);
|
|
2027
|
+
// throw error;
|
|
2028
|
+
// }
|
|
2029
|
+
// }
|
|
2016
2030
|
|
|
2017
2031
|
/**
|
|
2018
2032
|
* Caching user password secret in memory only.
|
|
@@ -2300,113 +2314,110 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2300
2314
|
}
|
|
2301
2315
|
}
|
|
2302
2316
|
|
|
2303
|
-
async
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
return [];
|
|
2408
|
-
}
|
|
2409
|
-
}
|
|
2317
|
+
// async getSyncSpaces({
|
|
2318
|
+
// createIfNone,
|
|
2319
|
+
// dontPrompt,
|
|
2320
|
+
// space,
|
|
2321
|
+
// outerspaceIds,
|
|
2322
|
+
// // fnSpaceFactory,
|
|
2323
|
+
// fnPromptSecret,
|
|
2324
|
+
// fnPromptEncryption,
|
|
2325
|
+
// fnPromptOuterSpace,
|
|
2326
|
+
// }: {
|
|
2327
|
+
// // unwrapEncrypted: boolean,
|
|
2328
|
+
// createIfNone: boolean,
|
|
2329
|
+
// /**
|
|
2330
|
+
// * If true, don't prompt the user if we don't have it already cached.
|
|
2331
|
+
// *
|
|
2332
|
+
// * We don't want the user to hit the page and then always have to type in
|
|
2333
|
+
// * the password, just because my password code sucks atow.
|
|
2334
|
+
// */
|
|
2335
|
+
// dontPrompt?: boolean,
|
|
2336
|
+
// space?: IbGibSpaceAny,
|
|
2337
|
+
// /**
|
|
2338
|
+
// * @see {@link syncIbGibs} arg of the same name
|
|
2339
|
+
// */
|
|
2340
|
+
// outerspaceIds?: SpaceId[],
|
|
2341
|
+
// // fnSpaceFactory: (unencryptedSpaceData: any) => Promise<IbGibSpaceAny>,
|
|
2342
|
+
// fnPromptSecret: (space: IbGibSpaceAny) => Promise<SecretIbGib_V1 | undefined>,
|
|
2343
|
+
// fnPromptEncryption: (space: IbGibSpaceAny) => Promise<EncryptionIbGib_V1 | undefined>,
|
|
2344
|
+
// fnPromptOuterSpace: (space: IbGibSpaceAny) => Promise<IbGibSpaceAny | undefined>,
|
|
2345
|
+
// }): Promise<SyncSpaceIbGib[]> {
|
|
2346
|
+
// const lc = `${this.lc}[${this.getSyncSpaces.name}]`;
|
|
2347
|
+
// try {
|
|
2348
|
+
// space = space ?? await this.getLocalUserSpace({});
|
|
2349
|
+
// if (!space) { throw new Error(`space falsy and localUserSpace not initialized (?) (E: bf09346708ba4d6e9a1389bd1b66d500)`); }
|
|
2350
|
+
|
|
2351
|
+
// // get existing
|
|
2352
|
+
// let resSyncSpaces: SyncSpaceIbGib[] =
|
|
2353
|
+
// await this.getSpecialRel8dIbGibs<SyncSpaceIbGib>({
|
|
2354
|
+
// type: "outerspaces",
|
|
2355
|
+
// rel8nName: SYNC_SPACE_REL8N_NAME,
|
|
2356
|
+
// space,
|
|
2357
|
+
// });
|
|
2358
|
+
|
|
2359
|
+
// // filter if applicable
|
|
2360
|
+
// const hasOuterspaceIds = (outerspaceIds?.length ?? 0) > 0;
|
|
2361
|
+
// if (hasOuterspaceIds) {
|
|
2362
|
+
// resSyncSpaces = resSyncSpaces.filter(x => outerspaceIds!.includes(x.data!.uuid!));
|
|
2363
|
+
// }
|
|
2364
|
+
|
|
2365
|
+
// // create if applicable
|
|
2366
|
+
// if (resSyncSpaces.length === 0) {
|
|
2367
|
+
// if (createIfNone) {
|
|
2368
|
+
// if (hasOuterspaceIds) { throw new Error(`(UNEXPECTED) both createIfNone true and outerspaceIds (filter) also true? you cannot have both of these set, it's one of the other. (E: 9caaa121dee3e41e6e29916614cd4e24)`); }
|
|
2369
|
+
// const createdReqs = await this._createOuterspaceAndRequiredIbGibs({
|
|
2370
|
+
// space,
|
|
2371
|
+
// fnPromptSecret,
|
|
2372
|
+
// fnPromptEncryption,
|
|
2373
|
+
// fnPromptOuterSpace,
|
|
2374
|
+
// });
|
|
2375
|
+
// if (createdReqs) {
|
|
2376
|
+
// resSyncSpaces = await this.getSpecialRel8dIbGibs<SyncSpaceIbGib>({
|
|
2377
|
+
// type: "outerspaces",
|
|
2378
|
+
// rel8nName: SYNC_SPACE_REL8N_NAME,
|
|
2379
|
+
// space,
|
|
2380
|
+
// });
|
|
2381
|
+
// }
|
|
2382
|
+
// } else {
|
|
2383
|
+
// throw new Error(`No sync spaces found. First create a sync outerspace (like a cloud sync space) in order to synchronize with it (E: 8f395f226ac7b558b9317befefbcb724)`);
|
|
2384
|
+
// }
|
|
2385
|
+
// }
|
|
2386
|
+
|
|
2387
|
+
// // unwrap if requested
|
|
2388
|
+
// // let resSpaces: SyncSpaceIbGib[] = [];
|
|
2389
|
+
// // if (unwrapEncrypted) {
|
|
2390
|
+
// // for (let i = 0; i < syncSpaceIbGibs.length; i++) {
|
|
2391
|
+
// // let syncSpace = syncSpaceIbGibs[i];
|
|
2392
|
+
|
|
2393
|
+
// // if (syncSpace.rel8ns) {
|
|
2394
|
+
// // if (syncSpace.rel8ns.ciphertext) {
|
|
2395
|
+
// // syncSpace = await this.unwrapEncryptedSyncSpace({
|
|
2396
|
+
// // encryptedSpace: syncSpace,
|
|
2397
|
+
// // fnPromptPassword: this.getFnPromptPassword!(),
|
|
2398
|
+
// // dontPrompt,
|
|
2399
|
+
// // space,
|
|
2400
|
+
// // fnSpaceFactory,
|
|
2401
|
+
// // });
|
|
2402
|
+
// // }
|
|
2403
|
+
|
|
2404
|
+
// // resSpaces.push(syncSpace);
|
|
2405
|
+
// // } else {
|
|
2406
|
+
// // }
|
|
2407
|
+
|
|
2408
|
+
// // }
|
|
2409
|
+
// // } else {
|
|
2410
|
+
// // still (probably) encrypted
|
|
2411
|
+
// // resSpaces = syncSpaceIbGibs;
|
|
2412
|
+
// // }
|
|
2413
|
+
|
|
2414
|
+
// // return resSpaces;
|
|
2415
|
+
// return resSyncSpaces;
|
|
2416
|
+
// } catch (error) {
|
|
2417
|
+
// console.error(`${lc} ${error.message}`);
|
|
2418
|
+
// return [];
|
|
2419
|
+
// }
|
|
2420
|
+
// }
|
|
2410
2421
|
|
|
2411
2422
|
// async createRobbotIbGib({
|
|
2412
2423
|
// robbotData,
|
|
@@ -2576,39 +2587,22 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2576
2587
|
|
|
2577
2588
|
async syncIbGibs({
|
|
2578
2589
|
dependencyGraphIbGibs,
|
|
2579
|
-
|
|
2590
|
+
syncSpaceIbGibs,
|
|
2580
2591
|
// watch,
|
|
2581
|
-
outerspaceIds,
|
|
2582
|
-
fnPreSyncProgress,
|
|
2583
|
-
fnSpaceFactory,
|
|
2584
|
-
fnPromptSecret,
|
|
2585
|
-
fnPromptEncryption,
|
|
2586
|
-
fnPromptOuterSpace,
|
|
2587
2592
|
}: {
|
|
2593
|
+
/**
|
|
2594
|
+
* @see {@link MetaspaceService.syncIbGibs}
|
|
2595
|
+
*/
|
|
2588
2596
|
dependencyGraphIbGibs?: IbGib_V1[],
|
|
2589
|
-
|
|
2597
|
+
/**
|
|
2598
|
+
* @see {@link MetaspaceService.syncIbGibs}
|
|
2599
|
+
*/
|
|
2600
|
+
syncSpaceIbGibs: IbGibSpaceAny[],
|
|
2590
2601
|
// /**
|
|
2591
2602
|
// * If true, will watch ibgibs in dependency graph that have timelines
|
|
2592
2603
|
// * (tjps).
|
|
2593
2604
|
// */
|
|
2594
2605
|
// watch?: boolean,
|
|
2595
|
-
/**
|
|
2596
|
-
* if provided, these will determine which outerspace(s) we will sync
|
|
2597
|
-
* the {@link dependencyGraphIbGibs} with.
|
|
2598
|
-
*/
|
|
2599
|
-
outerspaceIds?: SpaceId[],
|
|
2600
|
-
/**
|
|
2601
|
-
* The meat of the sync process is tracked via a status within the sync
|
|
2602
|
-
* spaces themselves. I'm addign this fn to track the pre and post progress
|
|
2603
|
-
* stuff, since decrypting takes some time, and building the dependency
|
|
2604
|
-
* graphs takes time. Both of these happen before the actual syncing occurs
|
|
2605
|
-
* in the spaces.
|
|
2606
|
-
*/
|
|
2607
|
-
fnPreSyncProgress?: (msg: string) => Promise<void>,
|
|
2608
|
-
fnSpaceFactory: (unencryptedSpaceData: any) => Promise<IbGibSpaceAny>,
|
|
2609
|
-
fnPromptSecret: (space: IbGibSpaceAny) => Promise<SecretIbGib_V1 | undefined>,
|
|
2610
|
-
fnPromptEncryption: (space: IbGibSpaceAny) => Promise<EncryptionIbGib_V1 | undefined>,
|
|
2611
|
-
fnPromptOuterSpace: (space: IbGibSpaceAny) => Promise<IbGibSpaceAny | undefined>,
|
|
2612
2606
|
}): Promise<SyncSagaInfo[] | undefined> {
|
|
2613
2607
|
const lc = `${this.lc}[${this.syncIbGibs.name}]`;
|
|
2614
2608
|
// map of saga infos across all spaces
|
|
@@ -2655,7 +2649,8 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2655
2649
|
|
|
2656
2650
|
// #region validate
|
|
2657
2651
|
if (logalot) { console.log(`${lc} starting...`); }
|
|
2658
|
-
if (!dependencyGraphIbGibs || dependencyGraphIbGibs.length === 0) { throw new Error(`
|
|
2652
|
+
if (!dependencyGraphIbGibs || dependencyGraphIbGibs.length === 0) { throw new Error(`dependencyGraphIbGibs required. (E: 404c36475fb84fc285a23a67c0b8fcb2)`); }
|
|
2653
|
+
if (!syncSpaceIbGibs || syncSpaceIbGibs.length === 0) { throw new Error(`syncSpaceIbGibs required (E: c5a022454b9ce34856e141e61e337d24)`); }
|
|
2659
2654
|
// #endregion
|
|
2660
2655
|
|
|
2661
2656
|
const localUserSpace = await this.getLocalUserSpace({});
|
|
@@ -2664,52 +2659,20 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2664
2659
|
|
|
2665
2660
|
// #region get sync spaces and build participant infos
|
|
2666
2661
|
if (logalot) { console.log(`${lc} get sync spaces (returns if none)`); }
|
|
2667
|
-
console.timeLog(syncTimelogName, 'getAppSyncSpaces starting (unwrapEncrypted is true) starting...');
|
|
2668
|
-
if (fnPreSyncProgress) { fnPreSyncProgress('getting app sync spaces... (I: aa2e8f32ab26457bad703218aa7fb47d)'); }
|
|
2669
|
-
const appSyncSpaces: IbGibSpaceAny[] = await this.getAppSyncSpaces({
|
|
2670
|
-
unwrapEncrypted: true,
|
|
2671
|
-
createIfNone: true,
|
|
2672
|
-
space: localUserSpace,
|
|
2673
|
-
outerspaceIds,
|
|
2674
|
-
fnSpaceFactory,
|
|
2675
|
-
fnPromptSecret,
|
|
2676
|
-
fnPromptEncryption,
|
|
2677
|
-
fnPromptOuterSpace,
|
|
2678
|
-
});
|
|
2679
|
-
if (fnPreSyncProgress) { fnPreSyncProgress('build complete. (I: 391a9aa7749d45b1aecf9a0010d9937f)'); }
|
|
2680
|
-
console.timeLog(syncTimelogName, 'getAppSyncSpaces starting (unwrapEncrypted is true) complete.');
|
|
2681
|
-
if (appSyncSpaces.length === 0) {
|
|
2682
|
-
const msg = `Hmm, we seem to not have any sync spaces, and we can't exactly sync without them. Sometimes this is because of a wrong password? (I: 902bd3e00c3246abb646a750f2f2b782)`;
|
|
2683
|
-
if (logalot) { console.log(`${lc} ${msg}`) };
|
|
2684
|
-
const fnAlert = this.getFnAlert!();
|
|
2685
|
-
await fnAlert({ title: "Sync Cancelled", msg });
|
|
2686
|
-
this._syncing = false;
|
|
2687
|
-
console.timeLog(syncTimelogName, 'cancelled');
|
|
2688
|
-
console.timeEnd(syncTimelogName);
|
|
2689
|
-
return undefined; /* <<<< returns early */
|
|
2690
|
-
}
|
|
2691
|
-
// const localUserSpace = await this.getLocalUserSpace({});
|
|
2692
2662
|
const participants: ParticipantInfo[] = [
|
|
2693
2663
|
// local user space is the src
|
|
2694
2664
|
{ id: localUserSpace.data.uuid, gib: localUserSpace.gib, s_d: 'src', },
|
|
2695
2665
|
|
|
2696
2666
|
// each sync space is a destination
|
|
2697
|
-
...
|
|
2698
|
-
if (!s.data) { throw new Error(`
|
|
2699
|
-
if (!s.data.uuid) { throw new Error(`
|
|
2700
|
-
if (!s.gib) { throw new Error(`
|
|
2701
|
-
return { id: s.data.uuid, gib: s.gib, s_d: 'dest', }
|
|
2667
|
+
...syncSpaceIbGibs.map(s => {
|
|
2668
|
+
if (!s.data) { throw new Error(`syncSpaceIbGib.data required. (E: 3c192771e84445a4b6476d5193b07e9d)`); }
|
|
2669
|
+
if (!s.data.uuid) { throw new Error(`syncSpaceIbGib.data.uuid required. (E: d27e9998227840f99d45a3ed245f3196)`); }
|
|
2670
|
+
if (!s.gib) { throw new Error(`syncSpaceIbGib.gib required. (E: db73aceb2f8445d8964ae49b59957072)`); }
|
|
2671
|
+
return { id: s.data.uuid, gib: s.gib, s_d: 'dest', } satisfies ParticipantInfo;
|
|
2702
2672
|
}),
|
|
2703
2673
|
];
|
|
2704
2674
|
// #endregion
|
|
2705
2675
|
|
|
2706
|
-
// if (fnPreSyncProgress) { fnPreSyncProgress('building dependency graph... (I: ae178a39c2594557b6d0489b02336ecd)'); }
|
|
2707
|
-
// get **ALL** ibgibs that we'll need to put/merge
|
|
2708
|
-
// const allIbGibsToSync: { [addr: string]: IbGib_V1 } = {};
|
|
2709
|
-
// dependencyGraphIbGibs.forEach(x => { allIbGibsToSync[getIbGibAddr({ ibGib: x })] = x });
|
|
2710
|
-
|
|
2711
|
-
// await this._getAllIbGibsToSyncFromGraph({ dependencyGraphIbGibs, space: localUserSpace });
|
|
2712
|
-
|
|
2713
2676
|
// _NOW_ we can finally put/merge into sync spaces.
|
|
2714
2677
|
// this returns to us the most recent versions which we can update
|
|
2715
2678
|
// our local timelines if we so choose (which we will).
|
|
@@ -2720,7 +2683,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2720
2683
|
if (logalot) { console.log(`${lc} syncing to spaces in parallel...`); }
|
|
2721
2684
|
const multiSpaceOpId = await getUUID();
|
|
2722
2685
|
const allSagaInfos: SyncSagaInfo[] = [];
|
|
2723
|
-
const startSyncPromises: Promise<void>[] =
|
|
2686
|
+
const startSyncPromises: Promise<void>[] = syncSpaceIbGibs.map(async syncSpace => {
|
|
2724
2687
|
// create the info that will track progress over entire sync saga
|
|
2725
2688
|
const sagaInfo =
|
|
2726
2689
|
await this._createNewSyncSagaInfo({
|
|
@@ -2765,21 +2728,21 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2765
2728
|
return allSagaInfos;
|
|
2766
2729
|
} catch (error) {
|
|
2767
2730
|
console.error(`${lc} ${error.message}`);
|
|
2768
|
-
await this.
|
|
2731
|
+
await this._finalizeAllSyncSagas_NoThrow({ error });
|
|
2769
2732
|
throw error;
|
|
2770
2733
|
} finally {
|
|
2771
2734
|
if (logalot) { console.log(`${lc} complete.`); }
|
|
2772
2735
|
}
|
|
2773
2736
|
}
|
|
2774
2737
|
|
|
2775
|
-
protected async
|
|
2738
|
+
protected async _finalizeSyncSaga({
|
|
2776
2739
|
sagaInfo,
|
|
2777
2740
|
error,
|
|
2778
2741
|
}: {
|
|
2779
2742
|
sagaInfo: SyncSagaInfo,
|
|
2780
2743
|
error?: any,
|
|
2781
2744
|
}): Promise<void> {
|
|
2782
|
-
const lc = `${this.lc}[${this.
|
|
2745
|
+
const lc = `${this.lc}[${this._finalizeSyncSaga.name}]`;
|
|
2783
2746
|
try {
|
|
2784
2747
|
if (logalot) { console.log(`${lc} starting...`); }
|
|
2785
2748
|
if (sagaInfo.complete) { return; }
|
|
@@ -2828,18 +2791,18 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2828
2791
|
}
|
|
2829
2792
|
}
|
|
2830
2793
|
|
|
2831
|
-
protected async
|
|
2794
|
+
protected async _finalizeAllSyncSagas_NoThrow({
|
|
2832
2795
|
error,
|
|
2833
2796
|
}: {
|
|
2834
2797
|
error?: any,
|
|
2835
2798
|
}): Promise<void> {
|
|
2836
|
-
const lc = `${this.lc}[${this.
|
|
2799
|
+
const lc = `${this.lc}[${this._finalizeAllSyncSagas_NoThrow.name}]`;
|
|
2837
2800
|
try {
|
|
2838
2801
|
const syncSagaInfos_NotComplete =
|
|
2839
2802
|
Object.values(this.sagaInfoMap).filter(x => !x.complete);
|
|
2840
2803
|
for (let i = 0; i < syncSagaInfos_NotComplete.length; i++) {
|
|
2841
2804
|
const sagaInfo = syncSagaInfos_NotComplete[i];
|
|
2842
|
-
await this.
|
|
2805
|
+
await this._finalizeSyncSaga({ sagaInfo, error });
|
|
2843
2806
|
}
|
|
2844
2807
|
} catch (error) {
|
|
2845
2808
|
console.error(`${lc}(UNEXPECTED) ${error.message}`);
|
|
@@ -2966,18 +2929,10 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2966
2929
|
protected async _startSync({
|
|
2967
2930
|
syncSagaInfo,
|
|
2968
2931
|
// watch,
|
|
2969
|
-
// confirm,
|
|
2970
2932
|
syncTimelogName,
|
|
2971
2933
|
}: {
|
|
2972
2934
|
syncSagaInfo: SyncSagaInfo,
|
|
2973
2935
|
// watch?: boolean,
|
|
2974
|
-
/**
|
|
2975
|
-
* Will confirm via checking existence of ibgibs in sync space after
|
|
2976
|
-
* writing them.
|
|
2977
|
-
*
|
|
2978
|
-
* NOTE: IGNORED ATM
|
|
2979
|
-
*/
|
|
2980
|
-
// confirm?: boolean,
|
|
2981
2936
|
syncTimelogName: string,
|
|
2982
2937
|
}): Promise<SyncSpaceResultIbGib> {
|
|
2983
2938
|
const lc = `${this.lc}[${this._startSync.name}]`;
|
|
@@ -3102,7 +3057,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3102
3057
|
const emsg = `${lc}(sagaId: ${sagaInfo.sagaId}) syncStatus$.error: ${error}`;
|
|
3103
3058
|
console.error(emsg);
|
|
3104
3059
|
// await this.getFnAlert!()({title: 'couldnt this.syncIbGibs...', msg: emsg});
|
|
3105
|
-
await this.
|
|
3060
|
+
await this._finalizeSyncSaga({ sagaInfo, error: emsg });
|
|
3106
3061
|
},
|
|
3107
3062
|
complete: async () => {
|
|
3108
3063
|
if (logalot) { console.log(`${lc}(sagaId: ${sagaInfo.sagaId}) syncStatus$.complete.`); }
|
|
@@ -3160,11 +3115,11 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3160
3115
|
break;
|
|
3161
3116
|
|
|
3162
3117
|
case StatusCode.merged_dna:
|
|
3163
|
-
await this.
|
|
3118
|
+
await this._handleSyncStatus_Merged({ status });
|
|
3164
3119
|
break;
|
|
3165
3120
|
|
|
3166
3121
|
case StatusCode.merged_state:
|
|
3167
|
-
await this.
|
|
3122
|
+
await this._handleSyncStatus_Merged({ status });
|
|
3168
3123
|
break;
|
|
3169
3124
|
|
|
3170
3125
|
case StatusCode.already_synced:
|
|
@@ -3173,7 +3128,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3173
3128
|
break;
|
|
3174
3129
|
|
|
3175
3130
|
case StatusCode.completed:
|
|
3176
|
-
await this.
|
|
3131
|
+
await this._handleSyncStatus_Complete({ sagaInfo });
|
|
3177
3132
|
break;
|
|
3178
3133
|
|
|
3179
3134
|
case StatusCode.undefined:
|
|
@@ -3195,12 +3150,12 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3195
3150
|
}
|
|
3196
3151
|
};
|
|
3197
3152
|
|
|
3198
|
-
protected async
|
|
3153
|
+
protected async _handleSyncStatus_Merged({
|
|
3199
3154
|
status,
|
|
3200
3155
|
}: {
|
|
3201
3156
|
status: SyncStatusIbGib,
|
|
3202
3157
|
}): Promise<void> {
|
|
3203
|
-
const lc = `${this.lc}[${this.
|
|
3158
|
+
const lc = `${this.lc}[${this._handleSyncStatus_Merged.name}]`;
|
|
3204
3159
|
try {
|
|
3205
3160
|
if (logalot) { console.log(`${lc} starting...`); }
|
|
3206
3161
|
// #region validate
|
|
@@ -3284,24 +3239,24 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3284
3239
|
}
|
|
3285
3240
|
}
|
|
3286
3241
|
|
|
3287
|
-
protected async
|
|
3242
|
+
protected async _handleSyncStatus_Complete({
|
|
3288
3243
|
sagaInfo,
|
|
3289
3244
|
}: {
|
|
3290
3245
|
sagaInfo: SyncSagaInfo,
|
|
3291
3246
|
}): Promise<void> {
|
|
3292
|
-
const lc = `${this.lc}[${this.
|
|
3247
|
+
const lc = `${this.lc}[${this._handleSyncStatus_Complete.name}]`;
|
|
3293
3248
|
try {
|
|
3294
3249
|
// cleanup just this saga, which corresponds to a single sync space.
|
|
3295
|
-
await this.
|
|
3250
|
+
await this._finalizeSyncSaga({ sagaInfo });
|
|
3296
3251
|
|
|
3297
3252
|
// if this is the last saga across all spaces, clean up the rest.
|
|
3298
3253
|
const allSagaInfos = Object.values(this.sagaInfoMap);
|
|
3299
3254
|
if (allSagaInfos.every(x => x.complete)) {
|
|
3300
|
-
await this.
|
|
3255
|
+
await this._finalizeAllSyncSagas_NoThrow({});
|
|
3301
3256
|
}
|
|
3302
3257
|
} catch (error) {
|
|
3303
3258
|
console.error(`${lc} ${error.message}`);
|
|
3304
|
-
await this.
|
|
3259
|
+
await this._finalizeAllSyncSagas_NoThrow({ error });
|
|
3305
3260
|
}
|
|
3306
3261
|
}
|
|
3307
3262
|
|
|
@@ -3433,97 +3388,97 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3433
3388
|
}
|
|
3434
3389
|
}
|
|
3435
3390
|
|
|
3436
|
-
protected async handleWatchTjpUpdates({
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
}: {
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
}): Promise<void> {
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
}
|
|
3391
|
+
// protected async handleWatchTjpUpdates({
|
|
3392
|
+
// updates,
|
|
3393
|
+
// outerSpace,
|
|
3394
|
+
// localUserSpace,
|
|
3395
|
+
// }: {
|
|
3396
|
+
// updates: { [tjpAddr: string]: IbGibAddr; }
|
|
3397
|
+
// outerSpace: IbGibSpaceAny,
|
|
3398
|
+
// localUserSpace: IbGibSpaceAny,
|
|
3399
|
+
// }): Promise<void> {
|
|
3400
|
+
// const lc = `${this.lc}[${this.handleWatchTjpUpdates.name}]`;
|
|
3401
|
+
// if (logalot) { console.log(`${lc} starting...`); }
|
|
3402
|
+
// try {
|
|
3403
|
+
// if (!outerSpace.data) { throw new Error(`outerSpace.data falsy (E: b5fde89e87bef9b8b6ce38e24be4a823)`); }
|
|
3404
|
+
|
|
3405
|
+
// /**
|
|
3406
|
+
// * compile list of addrs we have locally for all updates, so we don't try
|
|
3407
|
+
// * to download them from outer space unnecessarily.
|
|
3408
|
+
// */
|
|
3409
|
+
// const latestAddrsLocallyWithUpdate: IbGibAddr[] = [];
|
|
3410
|
+
// const tjpAddrs = Object.keys(updates);
|
|
3411
|
+
// const latestAddrs_Store = Object.values(updates);
|
|
3412
|
+
// for (let i = 0; i < tjpAddrs.length; i++) {
|
|
3413
|
+
// const tjpAddr = tjpAddrs[i];
|
|
3414
|
+
// if (logalot) { console.log(`${lc} tjpAddr: ${tjpAddr}`); }
|
|
3415
|
+
// const latestAddrLocally = await this.getLatestAddr({ tjpAddr }) ?? tjpAddr;
|
|
3416
|
+
// if (
|
|
3417
|
+
// !latestAddrs_Store.includes(latestAddrLocally) &&
|
|
3418
|
+
// !latestAddrsLocallyWithUpdate.includes(latestAddrLocally)
|
|
3419
|
+
// ) {
|
|
3420
|
+
// latestAddrsLocallyWithUpdate.push(latestAddrLocally);
|
|
3421
|
+
// }
|
|
3422
|
+
// }
|
|
3423
|
+
// if (latestAddrsLocallyWithUpdate.length === 0) {
|
|
3424
|
+
// if (logalot) { console.log(`${lc} latestAddrsLocallyWithUpdate.length === 0. We already had all of the updates locally perhaps. Returning early. (I: 844193c515084d0ebc348349f1ac41f4)`); }
|
|
3425
|
+
// return; /* <<<< returns early */
|
|
3426
|
+
// }
|
|
3427
|
+
|
|
3428
|
+
// /**
|
|
3429
|
+
// * LOCAL dependencies for latest LOCAL addrs for all tjpAddrs in updates.
|
|
3430
|
+
// */
|
|
3431
|
+
// const localDependencyGraphs = await this.getDependencyGraph({
|
|
3432
|
+
// ibGibAddrs: latestAddrsLocallyWithUpdate,
|
|
3433
|
+
// live: true,
|
|
3434
|
+
// maxRetries: DEFAULT_MAX_RETRIES_GET_DEPENDENCY_GRAPH_OUTERSPACE,
|
|
3435
|
+
// msBetweenRetries: DEFAULT_MS_BETWEEN_RETRIES_GET_DEPENDENCY_GRAPH_OUTERSPACE,
|
|
3436
|
+
// space: localUserSpace,
|
|
3437
|
+
// });
|
|
3438
|
+
|
|
3439
|
+
// /** all addrs we already have locally */
|
|
3440
|
+
// const addrsAlreadyStoredLocally = Object.keys(localDependencyGraphs);
|
|
3441
|
+
|
|
3442
|
+
// // get dependency graph from outer space, skipping all addrs in local already
|
|
3443
|
+
// const newerAddrsFromOuterSpace: IbGibAddr[] = Object.values(updates);
|
|
3444
|
+
// const newerIbGibDependencyGraphFromOuterSpace = await getDependencyGraph({
|
|
3445
|
+
// ibGibAddrs: newerAddrsFromOuterSpace,
|
|
3446
|
+
// live: false,
|
|
3447
|
+
// skipAddrs: addrsAlreadyStoredLocally,
|
|
3448
|
+
// space: outerSpace,
|
|
3449
|
+
// });
|
|
3450
|
+
// const newerIbGibsFromOuterSpace: IbGib_V1[] =
|
|
3451
|
+
// Object.values(newerIbGibDependencyGraphFromOuterSpace);
|
|
3452
|
+
|
|
3453
|
+
// if (logalot) { console.log(`${lc} got ${newerIbGibsFromOuterSpace.length} ibGibs from outerspace`); }
|
|
3454
|
+
|
|
3455
|
+
// // save locally
|
|
3456
|
+
// if (logalot) { console.log(`${lc} saving new ibgibs from outerspace in local space...`); }
|
|
3457
|
+
// if (newerIbGibsFromOuterSpace.length > 0) {
|
|
3458
|
+
// await this.put({ ibGibs: newerIbGibsFromOuterSpace });
|
|
3459
|
+
|
|
3460
|
+
// // register the newest tjp ibGibs locally
|
|
3461
|
+
// if (logalot) { console.log(`${lc} registering "new" updated tjp ibgibs locally...`); }
|
|
3462
|
+
// for (let i = 0; i < tjpAddrs.length; i++) {
|
|
3463
|
+
// const tjpAddr = tjpAddrs[i];
|
|
3464
|
+
// const updatedAddr = updates[tjpAddr];
|
|
3465
|
+
// if (!addrsAlreadyStoredLocally.includes(updatedAddr)) {
|
|
3466
|
+
// const updatedIbGib = newerIbGibDependencyGraphFromOuterSpace[updatedAddr];
|
|
3467
|
+
// if (!updatedIbGib) {
|
|
3468
|
+
// throw new Error(`did not get updatedIbGib (${updatedAddr}) from outerspace (${outerSpace.data.uuid}) (E: 818de70f5b444a3ba198ba6480a15b04)`);
|
|
3469
|
+
// }
|
|
3470
|
+
// await this.registerNewIbGib({ ibGib: updatedIbGib });
|
|
3471
|
+
// }
|
|
3472
|
+
// }
|
|
3473
|
+
// }
|
|
3474
|
+
|
|
3475
|
+
// } catch (error) {
|
|
3476
|
+
// console.error(`${lc} ${error.message}`);
|
|
3477
|
+
// // does not rethrow
|
|
3478
|
+
// } finally {
|
|
3479
|
+
// if (logalot) { console.log(`${lc} complete.`); }
|
|
3480
|
+
// }
|
|
3481
|
+
// }
|
|
3527
3482
|
|
|
3528
3483
|
// #endregion syncIbGibs related
|
|
3529
3484
|
|