@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 { GIB, GIB_DELIMITER, ROOT, } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
4
5
|
import { getIbGibAddr, } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
5
6
|
import { Factory_V1 as factory } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
@@ -13,9 +14,9 @@ import { getTimelinesGroupedByTjp, hasTjp } from '../../../common/other/ibgib-he
|
|
|
13
14
|
import { getValidatedBootstrapIbGib, getLocalSpace, execInSpaceWithLocking, updateBootstrapIbGib, getSpaceArgMetadata, createTagIbGibAndSundry, getConfigAddr, setConfigAddr, setCurrentRoot, rel8ToCurrentRoot, rel8ToSpecialIbGib, registerNewIbGib, persistTransformResult, getFromSpace, putInSpace, deleteFromSpace, getLatestAddrs, getTjpIbGib, getSpecialIbGib, getSpecialRel8dIbGibs, /*createRobbotIbGib, */ trash, archive, parseSpaceIb, } from '../../../witness/space/space-helper.mjs';
|
|
14
15
|
import { getDependencyGraph } from '../../../common/other/graph-helper.mjs';
|
|
15
16
|
import { createNewRobbot, validateCommonRobbotIbGib } from '../../../witness/robbot/robbot-helper.mjs';
|
|
16
|
-
import { createNewApp,
|
|
17
|
+
import { createNewApp, } from '../../../witness/app/app-helper.mjs';
|
|
17
18
|
import { BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY, BOOTSTRAP_IBGIB_ADDR } from '../../../witness/space/bootstrap/bootstrap-constants.mjs';
|
|
18
|
-
import {
|
|
19
|
+
import { DEFAULT_SECONDS_VALID_LOCAL, SYNC_SPACE_REL8N_NAME } from '../../../witness/space/space-constants.mjs';
|
|
19
20
|
import { DEFAULT_ENCRYPTION_HASH_ALGORITHM, DEFAULT_ENCRYPTION_INITIAL_RECURSIONS, DEFAULT_ENCRYPTION_RECURSIONS_PER_HASH, DEFAULT_ENCRYPTION_SALT_STRATEGY, ENCRYPTION_REL8N_NAME, } from '../../../common/encrypt/encrypt-constants.mjs';
|
|
20
21
|
import { ROBBOT_REL8N_NAME } from '../../../witness/robbot/robbot-constants.mjs';
|
|
21
22
|
import { APP_REL8N_NAME } from '../../../witness/app/app-constants.mjs';
|
|
@@ -1618,7 +1619,7 @@ export class MetaspaceBase {
|
|
|
1618
1619
|
try {
|
|
1619
1620
|
// validate
|
|
1620
1621
|
if ((secretIbGibs || []).length === 0) {
|
|
1621
|
-
throw new Error(`secretIbGibs required
|
|
1622
|
+
throw new Error(`secretIbGibs required. (E: 99a605b540c54b6db4d2ffe2caeb226a)`);
|
|
1622
1623
|
}
|
|
1623
1624
|
if (!ciphertextIbGib.data) {
|
|
1624
1625
|
throw new Error(`ciphertextIbGib.data falsy (E: 598fc6473149e240a7d6916ecf642323)`);
|
|
@@ -1627,23 +1628,23 @@ export class MetaspaceBase {
|
|
|
1627
1628
|
throw new Error(`ciphertextIbGib.data.ciphertext falsy (E: 0e764a71ec214132a5a528f17f495a7c)`);
|
|
1628
1629
|
}
|
|
1629
1630
|
if (!ciphertextIbGib.rel8ns?.encryption) {
|
|
1630
|
-
throw new Error(`ciphertextIbGib.rel8ns.encryption falsy`);
|
|
1631
|
+
throw new Error(`ciphertextIbGib.rel8ns.encryption falsy (E: a0b4d5d8674b4d0191fa619164153022)`);
|
|
1631
1632
|
}
|
|
1632
1633
|
if (ciphertextIbGib.rel8ns.encryption.length !== 1) {
|
|
1633
|
-
throw new Error(`ciphertextIbGib.rel8ns!.encryption!.length !== 1`);
|
|
1634
|
+
throw new Error(`ciphertextIbGib.rel8ns!.encryption!.length !== 1 (E: a4a463e1ef0e45b4917eb04cb40d8173)`);
|
|
1634
1635
|
}
|
|
1635
1636
|
// get corresponding encryption ibgib for encryption settings
|
|
1636
1637
|
const encryptionAddr = ciphertextIbGib.rel8ns.encryption[0];
|
|
1637
1638
|
const resEncryption = await this.get({ addr: encryptionAddr, space });
|
|
1638
1639
|
if (!resEncryption.success) {
|
|
1639
|
-
throw new Error(`get encryption failed`);
|
|
1640
|
+
throw new Error(`get encryption failed (E: feef34c05fae439c81ade7fc23037af1)`);
|
|
1640
1641
|
}
|
|
1641
1642
|
if ((resEncryption.ibGibs || []).length !== 1) {
|
|
1642
|
-
throw new Error(`get encryption retrieved non-1 length (eesh)`);
|
|
1643
|
+
throw new Error(`get encryption retrieved non-1 length (eesh) (E: 5d7e2023cc2b4e349574c17d5cfc8867)`);
|
|
1643
1644
|
}
|
|
1644
1645
|
const encryptionIbGib = resEncryption.ibGibs[0];
|
|
1645
1646
|
if (!encryptionIbGib.data) {
|
|
1646
|
-
throw new Error(
|
|
1647
|
+
throw new Error(`encryptionIbGib.data falsy (E: 409a243afbf24c20987524f6588816fa)`);
|
|
1647
1648
|
}
|
|
1648
1649
|
// prompt user for the password
|
|
1649
1650
|
const password = await this.getPasswordForSecrets({
|
|
@@ -1656,20 +1657,31 @@ export class MetaspaceBase {
|
|
|
1656
1657
|
// we're about the decrypt, but maybe the data doesn't have everything.
|
|
1657
1658
|
// So WARN for any defaults we're using.
|
|
1658
1659
|
if (!encryptionIbGib.data.initialRecursions) {
|
|
1659
|
-
console.warn(`${lc} using default initialRecursions`);
|
|
1660
|
+
console.warn(`${lc} using default initialRecursions because encryptionIbGib does not state this explicitly (W: 66774cbfccd44423949d34167da6d50b)`);
|
|
1660
1661
|
}
|
|
1661
1662
|
if (!encryptionIbGib.data.recursionsPerHash) {
|
|
1662
|
-
console.warn(`${lc} using default recursionsPerHash`);
|
|
1663
|
+
console.warn(`${lc} using default recursionsPerHash because encryptionIbGib does not state this explicitly (W: 29e264094f384d259319ba8587cd4f63)`);
|
|
1663
1664
|
}
|
|
1664
1665
|
if (!encryptionIbGib.data.saltStrategy) {
|
|
1665
|
-
console.warn(`${lc} using default saltStrategy`);
|
|
1666
|
+
console.warn(`${lc} using default saltStrategy because encryptionIbGib does not state this explicitly (W: 7a5acadb8d634c7e87f62c86b57ac7a2)`);
|
|
1666
1667
|
}
|
|
1667
1668
|
if (!encryptionIbGib.data.hashAlgorithm) {
|
|
1668
|
-
console.warn(`${lc} using default hashAlgorithm`);
|
|
1669
|
+
console.warn(`${lc} using default hashAlgorithm because encryptionIbGib does not state this explicitly(W: 2254db3569534b239a8c471b700c8500)`);
|
|
1670
|
+
}
|
|
1671
|
+
const defaultIndexingMode = encryptionIbGib.data.blockMode ?
|
|
1672
|
+
DEFAULT_ALPHABET_INDEXING_MODE_BLOCKMODE :
|
|
1673
|
+
DEFAULT_ALPHABET_INDEXING_MODE_LEGACY;
|
|
1674
|
+
if (encryptionIbGib.data.blockMode) {
|
|
1675
|
+
if (!encryptionIbGib.data.blockModeOptions) {
|
|
1676
|
+
throw new Error(`invalid encryptionIbGib.data. blockMode is truthy but blockModeOptions is falsy. (E: 84bbc27a5248b7c4734a1674e41dd224)`);
|
|
1677
|
+
}
|
|
1678
|
+
if (!encryptionIbGib.data.indexingMode) {
|
|
1679
|
+
console.warn(`${lc} not complete. using default indexingMode ${defaultIndexingMode} because encryptionIbGib does not state this explicitly. (W: c15797cd8d0740ea886a348c10be2e5c)`);
|
|
1680
|
+
}
|
|
1669
1681
|
}
|
|
1670
1682
|
// do actual decryption
|
|
1671
1683
|
if (logalot) {
|
|
1672
|
-
console.log(`${lc} starting decrypt
|
|
1684
|
+
console.log(`${lc} starting decrypt... (I: e14176ebc9a7470fb977d2184f1e2430)`);
|
|
1673
1685
|
}
|
|
1674
1686
|
const timerName = 'sync_log decrypt';
|
|
1675
1687
|
console.time(timerName);
|
|
@@ -1683,11 +1695,13 @@ export class MetaspaceBase {
|
|
|
1683
1695
|
saltStrategy: encryptionIbGib.data.saltStrategy || DEFAULT_ENCRYPTION_SALT_STRATEGY,
|
|
1684
1696
|
hashAlgorithm: encryptionIbGib.data.hashAlgorithm || DEFAULT_ENCRYPTION_HASH_ALGORITHM,
|
|
1685
1697
|
encryptedDataDelimiter: encryptionIbGib.data.encryptedDataDelimiter,
|
|
1698
|
+
blockMode: encryptionIbGib.data.blockMode ? encryptionIbGib.data.blockModeOptions : undefined,
|
|
1699
|
+
indexingMode: encryptionIbGib.data.indexingMode || defaultIndexingMode,
|
|
1686
1700
|
});
|
|
1687
1701
|
console.timeLog(timerName, 'decrypting complete.');
|
|
1688
1702
|
console.timeEnd(timerName);
|
|
1689
1703
|
if (logalot) {
|
|
1690
|
-
console.log(`${lc} decrypt complete
|
|
1704
|
+
console.log(`${lc} decrypt complete. (I: 15a8182230294a8a96504ba3667f039a)`);
|
|
1691
1705
|
}
|
|
1692
1706
|
if (resDecrypt.errors?.length ?? 0 > 0) {
|
|
1693
1707
|
throw new Error(resDecrypt.errors.join('|'));
|
|
@@ -1703,77 +1717,70 @@ export class MetaspaceBase {
|
|
|
1703
1717
|
throw error;
|
|
1704
1718
|
}
|
|
1705
1719
|
}
|
|
1706
|
-
async unwrapEncryptedSyncSpace({
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
// return awsSpace;
|
|
1771
|
-
}
|
|
1772
|
-
catch (error) {
|
|
1773
|
-
console.error(`${lc} ${error.message}`);
|
|
1774
|
-
throw error;
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1720
|
+
// async unwrapEncryptedSyncSpace({
|
|
1721
|
+
// encryptedSpace,
|
|
1722
|
+
// fnPromptPassword,
|
|
1723
|
+
// dontPrompt,
|
|
1724
|
+
// space,
|
|
1725
|
+
// fnSpaceFactory,
|
|
1726
|
+
// }: {
|
|
1727
|
+
// encryptedSpace: IbGibSpaceAny,
|
|
1728
|
+
// fnPromptPassword: (title: string, msg: string) => Promise<string | null>,
|
|
1729
|
+
// dontPrompt?: boolean,
|
|
1730
|
+
// space?: IbGibSpaceAny,
|
|
1731
|
+
// fnSpaceFactory: (syncSpaceIbGib: SyncSpaceIbGib) => Promise<IbGibSpaceAny>,
|
|
1732
|
+
// }): Promise<IbGibSpaceAny> {
|
|
1733
|
+
// const lc = `${this.lc}[${this.unwrapEncryptedSyncSpace.name}]`;
|
|
1734
|
+
// try {
|
|
1735
|
+
// // validation
|
|
1736
|
+
// if (!space) { throw new Error(`space required (E: d4d3eaa2d7b9143cf1173b8ae6344c23)`); }
|
|
1737
|
+
// if (!encryptedSpace.rel8ns?.ciphertext) { throw new Error(`encryptedSpace is not a ciphertext (E: be5504a5e2b84f3eaa8fbd6e13aab659)`); }
|
|
1738
|
+
// if (encryptedSpace.rel8ns!.ciphertext!.length !== 1) { throw new Error(`only 1 ciphertext rel8n allowed... (E: e8ab2ec38ad844dfb229efc5b8981946)`); }
|
|
1739
|
+
// // get ciphertext ibgib
|
|
1740
|
+
// const ciphertextAddr = encryptedSpace.rel8ns!.ciphertext![0];
|
|
1741
|
+
// const resCiphertext = await this.get({ addr: ciphertextAddr, space });
|
|
1742
|
+
// if (!resCiphertext.success) { throw new Error(`get ciphertext failed (E: e58b3471c0334cd7bc626998106e6547)`); }
|
|
1743
|
+
// if ((resCiphertext.ibGibs || []).length !== 1) { throw new Error(`get ciphertext retrieved non-1 length (eesh) (E: a3a1f00e827b4f88a42b4a7433cf1065)`); }
|
|
1744
|
+
// const ciphertextIbGib = resCiphertext.ibGibs![0] as CiphertextIbGib_V1;
|
|
1745
|
+
// // get secrets associated with enciphered space
|
|
1746
|
+
// if (!encryptedSpace.rel8ns?.secret) { throw new Error(`!encryptionIbGib.rel8ns?.secret (E: 8bfed1541976433da9402d7d3a9138dd)`); }
|
|
1747
|
+
// const secretAddrs = encryptedSpace.rel8ns!.secret!;
|
|
1748
|
+
// const localUserSpace = await this.getLocalUserSpace({});
|
|
1749
|
+
// if (!localUserSpace) { throw new Error(`(UNEXPECTED) could not get localUserSpace? (E: 3c5687a15b3b58e3dcf1eca4f5fe5723) (E: c123b340177647968e10a6b119d84d2b)`); }
|
|
1750
|
+
// const argGetSecrets = await localUserSpace.argy({
|
|
1751
|
+
// argData: { ibGibAddrs: secretAddrs, cmd: 'get', }
|
|
1752
|
+
// });
|
|
1753
|
+
// const resSecrets = await localUserSpace.witness(argGetSecrets);
|
|
1754
|
+
// if (!resSecrets.data?.success || (resSecrets.ibGibs || []).length === 0) {
|
|
1755
|
+
// throw new Error(`couldn't get secret ibgibs (E: cb17687f842f4296a9ecf89d9a568e46)`);
|
|
1756
|
+
// }
|
|
1757
|
+
// const secretIbGibs = resSecrets.ibGibs.concat() as IbGib_V1<SecretData_V1>[];
|
|
1758
|
+
// // get plaintext now that we have the ciphertext ibgib and secret ibgib(s)
|
|
1759
|
+
// const plaintextString = await this.getPlaintextString({
|
|
1760
|
+
// ciphertextIbGib,
|
|
1761
|
+
// fnPromptPassword,
|
|
1762
|
+
// dontPrompt,
|
|
1763
|
+
// secretIbGibs,
|
|
1764
|
+
// space,
|
|
1765
|
+
// });
|
|
1766
|
+
// const syncSpaceData = JSON.parse(plaintextString) as OuterSpaceData;
|
|
1767
|
+
// if (syncSpaceData.type !== 'sync') { throw new Error(`syncSpaceData.type !== 'sync'...this is the only one implemented right now (E: 509b2373d6f8445ebe5bd6f27f62af93)`); }
|
|
1768
|
+
// if (syncSpaceData.subtype !== 'aws-dynamodb') { throw new Error(`syncSpaceData.subtype !== 'aws-dynamodb'...only one right now dude (E: b5caaf3b4c60438eb2cee58ce8e1d3f6)`); }
|
|
1769
|
+
// // this is the original aws only implementation. I've just added (untested)
|
|
1770
|
+
// // a quick factory function where the consumer would do the following code.
|
|
1771
|
+
// const unwrappedSpace = await fnSpaceFactory(syncSpaceData);
|
|
1772
|
+
// return unwrappedSpace;
|
|
1773
|
+
// // so we have a syncspace data (only aws-dynamodb space right now).
|
|
1774
|
+
// // load this data into a space class with behavior (not just the dto).
|
|
1775
|
+
// // const awsSpace = new AWSDynamoSpace_V1(syncSpaceData, null);
|
|
1776
|
+
// // awsSpace.gib = await getGib({ ibGib: awsSpace, hasTjp: false });
|
|
1777
|
+
// // if (logalot) { console.log(`awsSpace.gib: ${awsSpace.gib}`); }
|
|
1778
|
+
// // return awsSpace;
|
|
1779
|
+
// } catch (error) {
|
|
1780
|
+
// console.error(`${lc} ${error.message}`);
|
|
1781
|
+
// throw error;
|
|
1782
|
+
// }
|
|
1783
|
+
// }
|
|
1777
1784
|
/**
|
|
1778
1785
|
* Caching user password secret in memory only.
|
|
1779
1786
|
*
|
|
@@ -2049,82 +2056,102 @@ export class MetaspaceBase {
|
|
|
2049
2056
|
throw error;
|
|
2050
2057
|
}
|
|
2051
2058
|
}
|
|
2052
|
-
async
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2059
|
+
// async getSyncSpaces({
|
|
2060
|
+
// createIfNone,
|
|
2061
|
+
// dontPrompt,
|
|
2062
|
+
// space,
|
|
2063
|
+
// outerspaceIds,
|
|
2064
|
+
// // fnSpaceFactory,
|
|
2065
|
+
// fnPromptSecret,
|
|
2066
|
+
// fnPromptEncryption,
|
|
2067
|
+
// fnPromptOuterSpace,
|
|
2068
|
+
// }: {
|
|
2069
|
+
// // unwrapEncrypted: boolean,
|
|
2070
|
+
// createIfNone: boolean,
|
|
2071
|
+
// /**
|
|
2072
|
+
// * If true, don't prompt the user if we don't have it already cached.
|
|
2073
|
+
// *
|
|
2074
|
+
// * We don't want the user to hit the page and then always have to type in
|
|
2075
|
+
// * the password, just because my password code sucks atow.
|
|
2076
|
+
// */
|
|
2077
|
+
// dontPrompt?: boolean,
|
|
2078
|
+
// space?: IbGibSpaceAny,
|
|
2079
|
+
// /**
|
|
2080
|
+
// * @see {@link syncIbGibs} arg of the same name
|
|
2081
|
+
// */
|
|
2082
|
+
// outerspaceIds?: SpaceId[],
|
|
2083
|
+
// // fnSpaceFactory: (unencryptedSpaceData: any) => Promise<IbGibSpaceAny>,
|
|
2084
|
+
// fnPromptSecret: (space: IbGibSpaceAny) => Promise<SecretIbGib_V1 | undefined>,
|
|
2085
|
+
// fnPromptEncryption: (space: IbGibSpaceAny) => Promise<EncryptionIbGib_V1 | undefined>,
|
|
2086
|
+
// fnPromptOuterSpace: (space: IbGibSpaceAny) => Promise<IbGibSpaceAny | undefined>,
|
|
2087
|
+
// }): Promise<SyncSpaceIbGib[]> {
|
|
2088
|
+
// const lc = `${this.lc}[${this.getSyncSpaces.name}]`;
|
|
2089
|
+
// try {
|
|
2090
|
+
// space = space ?? await this.getLocalUserSpace({});
|
|
2091
|
+
// if (!space) { throw new Error(`space falsy and localUserSpace not initialized (?) (E: bf09346708ba4d6e9a1389bd1b66d500)`); }
|
|
2092
|
+
// // get existing
|
|
2093
|
+
// let resSyncSpaces: SyncSpaceIbGib[] =
|
|
2094
|
+
// await this.getSpecialRel8dIbGibs<SyncSpaceIbGib>({
|
|
2095
|
+
// type: "outerspaces",
|
|
2096
|
+
// rel8nName: SYNC_SPACE_REL8N_NAME,
|
|
2097
|
+
// space,
|
|
2098
|
+
// });
|
|
2099
|
+
// // filter if applicable
|
|
2100
|
+
// const hasOuterspaceIds = (outerspaceIds?.length ?? 0) > 0;
|
|
2101
|
+
// if (hasOuterspaceIds) {
|
|
2102
|
+
// resSyncSpaces = resSyncSpaces.filter(x => outerspaceIds!.includes(x.data!.uuid!));
|
|
2103
|
+
// }
|
|
2104
|
+
// // create if applicable
|
|
2105
|
+
// if (resSyncSpaces.length === 0) {
|
|
2106
|
+
// if (createIfNone) {
|
|
2107
|
+
// 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)`); }
|
|
2108
|
+
// const createdReqs = await this._createOuterspaceAndRequiredIbGibs({
|
|
2109
|
+
// space,
|
|
2110
|
+
// fnPromptSecret,
|
|
2111
|
+
// fnPromptEncryption,
|
|
2112
|
+
// fnPromptOuterSpace,
|
|
2113
|
+
// });
|
|
2114
|
+
// if (createdReqs) {
|
|
2115
|
+
// resSyncSpaces = await this.getSpecialRel8dIbGibs<SyncSpaceIbGib>({
|
|
2116
|
+
// type: "outerspaces",
|
|
2117
|
+
// rel8nName: SYNC_SPACE_REL8N_NAME,
|
|
2118
|
+
// space,
|
|
2119
|
+
// });
|
|
2120
|
+
// }
|
|
2121
|
+
// } else {
|
|
2122
|
+
// 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)`);
|
|
2123
|
+
// }
|
|
2124
|
+
// }
|
|
2125
|
+
// // unwrap if requested
|
|
2126
|
+
// // let resSpaces: SyncSpaceIbGib[] = [];
|
|
2127
|
+
// // if (unwrapEncrypted) {
|
|
2128
|
+
// // for (let i = 0; i < syncSpaceIbGibs.length; i++) {
|
|
2129
|
+
// // let syncSpace = syncSpaceIbGibs[i];
|
|
2130
|
+
// // if (syncSpace.rel8ns) {
|
|
2131
|
+
// // if (syncSpace.rel8ns.ciphertext) {
|
|
2132
|
+
// // syncSpace = await this.unwrapEncryptedSyncSpace({
|
|
2133
|
+
// // encryptedSpace: syncSpace,
|
|
2134
|
+
// // fnPromptPassword: this.getFnPromptPassword!(),
|
|
2135
|
+
// // dontPrompt,
|
|
2136
|
+
// // space,
|
|
2137
|
+
// // fnSpaceFactory,
|
|
2138
|
+
// // });
|
|
2139
|
+
// // }
|
|
2140
|
+
// // resSpaces.push(syncSpace);
|
|
2141
|
+
// // } else {
|
|
2142
|
+
// // }
|
|
2143
|
+
// // }
|
|
2144
|
+
// // } else {
|
|
2145
|
+
// // still (probably) encrypted
|
|
2146
|
+
// // resSpaces = syncSpaceIbGibs;
|
|
2147
|
+
// // }
|
|
2148
|
+
// // return resSpaces;
|
|
2149
|
+
// return resSyncSpaces;
|
|
2150
|
+
// } catch (error) {
|
|
2151
|
+
// console.error(`${lc} ${error.message}`);
|
|
2152
|
+
// return [];
|
|
2153
|
+
// }
|
|
2154
|
+
// }
|
|
2128
2155
|
// async createRobbotIbGib({
|
|
2129
2156
|
// robbotData,
|
|
2130
2157
|
// space,
|
|
@@ -2256,10 +2283,9 @@ export class MetaspaceBase {
|
|
|
2256
2283
|
return [];
|
|
2257
2284
|
}
|
|
2258
2285
|
}
|
|
2259
|
-
async syncIbGibs({ dependencyGraphIbGibs,
|
|
2260
|
-
// confirm,
|
|
2286
|
+
async syncIbGibs({ dependencyGraphIbGibs, syncSpaceIbGibs,
|
|
2261
2287
|
// watch,
|
|
2262
|
-
|
|
2288
|
+
}) {
|
|
2263
2289
|
const lc = `${this.lc}[${this.syncIbGibs.name}]`;
|
|
2264
2290
|
// map of saga infos across all spaces
|
|
2265
2291
|
// const sagaInfoMap: { [spaceGib: string]: SyncSagaInfo } = {};
|
|
@@ -2313,7 +2339,10 @@ export class MetaspaceBase {
|
|
|
2313
2339
|
console.log(`${lc} starting...`);
|
|
2314
2340
|
}
|
|
2315
2341
|
if (!dependencyGraphIbGibs || dependencyGraphIbGibs.length === 0) {
|
|
2316
|
-
throw new Error(`
|
|
2342
|
+
throw new Error(`dependencyGraphIbGibs required. (E: 404c36475fb84fc285a23a67c0b8fcb2)`);
|
|
2343
|
+
}
|
|
2344
|
+
if (!syncSpaceIbGibs || syncSpaceIbGibs.length === 0) {
|
|
2345
|
+
throw new Error(`syncSpaceIbGibs required (E: c5a022454b9ce34856e141e61e337d24)`);
|
|
2317
2346
|
}
|
|
2318
2347
|
// #endregion
|
|
2319
2348
|
const localUserSpace = await this.getLocalUserSpace({});
|
|
@@ -2327,61 +2356,24 @@ export class MetaspaceBase {
|
|
|
2327
2356
|
if (logalot) {
|
|
2328
2357
|
console.log(`${lc} get sync spaces (returns if none)`);
|
|
2329
2358
|
}
|
|
2330
|
-
console.timeLog(syncTimelogName, 'getAppSyncSpaces starting (unwrapEncrypted is true) starting...');
|
|
2331
|
-
if (fnPreSyncProgress) {
|
|
2332
|
-
fnPreSyncProgress('getting app sync spaces... (I: aa2e8f32ab26457bad703218aa7fb47d)');
|
|
2333
|
-
}
|
|
2334
|
-
const appSyncSpaces = await this.getAppSyncSpaces({
|
|
2335
|
-
unwrapEncrypted: true,
|
|
2336
|
-
createIfNone: true,
|
|
2337
|
-
space: localUserSpace,
|
|
2338
|
-
outerspaceIds,
|
|
2339
|
-
fnSpaceFactory,
|
|
2340
|
-
fnPromptSecret,
|
|
2341
|
-
fnPromptEncryption,
|
|
2342
|
-
fnPromptOuterSpace,
|
|
2343
|
-
});
|
|
2344
|
-
if (fnPreSyncProgress) {
|
|
2345
|
-
fnPreSyncProgress('build complete. (I: 391a9aa7749d45b1aecf9a0010d9937f)');
|
|
2346
|
-
}
|
|
2347
|
-
console.timeLog(syncTimelogName, 'getAppSyncSpaces starting (unwrapEncrypted is true) complete.');
|
|
2348
|
-
if (appSyncSpaces.length === 0) {
|
|
2349
|
-
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)`;
|
|
2350
|
-
if (logalot) {
|
|
2351
|
-
console.log(`${lc} ${msg}`);
|
|
2352
|
-
}
|
|
2353
|
-
;
|
|
2354
|
-
const fnAlert = this.getFnAlert();
|
|
2355
|
-
await fnAlert({ title: "Sync Cancelled", msg });
|
|
2356
|
-
this._syncing = false;
|
|
2357
|
-
console.timeLog(syncTimelogName, 'cancelled');
|
|
2358
|
-
console.timeEnd(syncTimelogName);
|
|
2359
|
-
return undefined; /* <<<< returns early */
|
|
2360
|
-
}
|
|
2361
|
-
// const localUserSpace = await this.getLocalUserSpace({});
|
|
2362
2359
|
const participants = [
|
|
2363
2360
|
// local user space is the src
|
|
2364
2361
|
{ id: localUserSpace.data.uuid, gib: localUserSpace.gib, s_d: 'src', },
|
|
2365
2362
|
// each sync space is a destination
|
|
2366
|
-
...
|
|
2363
|
+
...syncSpaceIbGibs.map(s => {
|
|
2367
2364
|
if (!s.data) {
|
|
2368
|
-
throw new Error(`
|
|
2365
|
+
throw new Error(`syncSpaceIbGib.data required. (E: 3c192771e84445a4b6476d5193b07e9d)`);
|
|
2369
2366
|
}
|
|
2370
2367
|
if (!s.data.uuid) {
|
|
2371
|
-
throw new Error(`
|
|
2368
|
+
throw new Error(`syncSpaceIbGib.data.uuid required. (E: d27e9998227840f99d45a3ed245f3196)`);
|
|
2372
2369
|
}
|
|
2373
2370
|
if (!s.gib) {
|
|
2374
|
-
throw new Error(`
|
|
2371
|
+
throw new Error(`syncSpaceIbGib.gib required. (E: db73aceb2f8445d8964ae49b59957072)`);
|
|
2375
2372
|
}
|
|
2376
2373
|
return { id: s.data.uuid, gib: s.gib, s_d: 'dest', };
|
|
2377
2374
|
}),
|
|
2378
2375
|
];
|
|
2379
2376
|
// #endregion
|
|
2380
|
-
// if (fnPreSyncProgress) { fnPreSyncProgress('building dependency graph... (I: ae178a39c2594557b6d0489b02336ecd)'); }
|
|
2381
|
-
// get **ALL** ibgibs that we'll need to put/merge
|
|
2382
|
-
// const allIbGibsToSync: { [addr: string]: IbGib_V1 } = {};
|
|
2383
|
-
// dependencyGraphIbGibs.forEach(x => { allIbGibsToSync[getIbGibAddr({ ibGib: x })] = x });
|
|
2384
|
-
// await this._getAllIbGibsToSyncFromGraph({ dependencyGraphIbGibs, space: localUserSpace });
|
|
2385
2377
|
// _NOW_ we can finally put/merge into sync spaces.
|
|
2386
2378
|
// this returns to us the most recent versions which we can update
|
|
2387
2379
|
// our local timelines if we so choose (which we will).
|
|
@@ -2393,7 +2385,7 @@ export class MetaspaceBase {
|
|
|
2393
2385
|
}
|
|
2394
2386
|
const multiSpaceOpId = await getUUID();
|
|
2395
2387
|
const allSagaInfos = [];
|
|
2396
|
-
const startSyncPromises =
|
|
2388
|
+
const startSyncPromises = syncSpaceIbGibs.map(async (syncSpace) => {
|
|
2397
2389
|
// create the info that will track progress over entire sync saga
|
|
2398
2390
|
const sagaInfo = await this._createNewSyncSagaInfo({
|
|
2399
2391
|
multiSpaceOpId,
|
|
@@ -2436,7 +2428,7 @@ export class MetaspaceBase {
|
|
|
2436
2428
|
}
|
|
2437
2429
|
catch (error) {
|
|
2438
2430
|
console.error(`${lc} ${error.message}`);
|
|
2439
|
-
await this.
|
|
2431
|
+
await this._finalizeAllSyncSagas_NoThrow({ error });
|
|
2440
2432
|
throw error;
|
|
2441
2433
|
}
|
|
2442
2434
|
finally {
|
|
@@ -2445,8 +2437,8 @@ export class MetaspaceBase {
|
|
|
2445
2437
|
}
|
|
2446
2438
|
}
|
|
2447
2439
|
}
|
|
2448
|
-
async
|
|
2449
|
-
const lc = `${this.lc}[${this.
|
|
2440
|
+
async _finalizeSyncSaga({ sagaInfo, error, }) {
|
|
2441
|
+
const lc = `${this.lc}[${this._finalizeSyncSaga.name}]`;
|
|
2450
2442
|
try {
|
|
2451
2443
|
if (logalot) {
|
|
2452
2444
|
console.log(`${lc} starting...`);
|
|
@@ -2513,13 +2505,13 @@ export class MetaspaceBase {
|
|
|
2513
2505
|
}
|
|
2514
2506
|
}
|
|
2515
2507
|
}
|
|
2516
|
-
async
|
|
2517
|
-
const lc = `${this.lc}[${this.
|
|
2508
|
+
async _finalizeAllSyncSagas_NoThrow({ error, }) {
|
|
2509
|
+
const lc = `${this.lc}[${this._finalizeAllSyncSagas_NoThrow.name}]`;
|
|
2518
2510
|
try {
|
|
2519
2511
|
const syncSagaInfos_NotComplete = Object.values(this.sagaInfoMap).filter(x => !x.complete);
|
|
2520
2512
|
for (let i = 0; i < syncSagaInfos_NotComplete.length; i++) {
|
|
2521
2513
|
const sagaInfo = syncSagaInfos_NotComplete[i];
|
|
2522
|
-
await this.
|
|
2514
|
+
await this._finalizeSyncSaga({ sagaInfo, error });
|
|
2523
2515
|
}
|
|
2524
2516
|
}
|
|
2525
2517
|
catch (error) {
|
|
@@ -2632,7 +2624,6 @@ export class MetaspaceBase {
|
|
|
2632
2624
|
*/
|
|
2633
2625
|
async _startSync({ syncSagaInfo,
|
|
2634
2626
|
// watch,
|
|
2635
|
-
// confirm,
|
|
2636
2627
|
syncTimelogName, }) {
|
|
2637
2628
|
const lc = `${this.lc}[${this._startSync.name}]`;
|
|
2638
2629
|
try {
|
|
@@ -2753,7 +2744,7 @@ export class MetaspaceBase {
|
|
|
2753
2744
|
const emsg = `${lc}(sagaId: ${sagaInfo.sagaId}) syncStatus$.error: ${error}`;
|
|
2754
2745
|
console.error(emsg);
|
|
2755
2746
|
// await this.getFnAlert!()({title: 'couldnt this.syncIbGibs...', msg: emsg});
|
|
2756
|
-
await this.
|
|
2747
|
+
await this._finalizeSyncSaga({ sagaInfo, error: emsg });
|
|
2757
2748
|
},
|
|
2758
2749
|
complete: async () => {
|
|
2759
2750
|
if (logalot) {
|
|
@@ -2812,17 +2803,17 @@ export class MetaspaceBase {
|
|
|
2812
2803
|
// nothing further to do? hmm...
|
|
2813
2804
|
break;
|
|
2814
2805
|
case StatusCode.merged_dna:
|
|
2815
|
-
await this.
|
|
2806
|
+
await this._handleSyncStatus_Merged({ status });
|
|
2816
2807
|
break;
|
|
2817
2808
|
case StatusCode.merged_state:
|
|
2818
|
-
await this.
|
|
2809
|
+
await this._handleSyncStatus_Merged({ status });
|
|
2819
2810
|
break;
|
|
2820
2811
|
case StatusCode.already_synced:
|
|
2821
2812
|
// await this.handleSyncComplete_AlreadySynced({sagaInfo, status});
|
|
2822
2813
|
// nothing further to do? hmm...
|
|
2823
2814
|
break;
|
|
2824
2815
|
case StatusCode.completed:
|
|
2825
|
-
await this.
|
|
2816
|
+
await this._handleSyncStatus_Complete({ sagaInfo });
|
|
2826
2817
|
break;
|
|
2827
2818
|
case StatusCode.undefined:
|
|
2828
2819
|
// atow undefined is used in primitive status parentage
|
|
@@ -2845,8 +2836,8 @@ export class MetaspaceBase {
|
|
|
2845
2836
|
}
|
|
2846
2837
|
}
|
|
2847
2838
|
;
|
|
2848
|
-
async
|
|
2849
|
-
const lc = `${this.lc}[${this.
|
|
2839
|
+
async _handleSyncStatus_Merged({ status, }) {
|
|
2840
|
+
const lc = `${this.lc}[${this._handleSyncStatus_Merged.name}]`;
|
|
2850
2841
|
try {
|
|
2851
2842
|
if (logalot) {
|
|
2852
2843
|
console.log(`${lc} starting...`);
|
|
@@ -2942,20 +2933,20 @@ export class MetaspaceBase {
|
|
|
2942
2933
|
throw error;
|
|
2943
2934
|
}
|
|
2944
2935
|
}
|
|
2945
|
-
async
|
|
2946
|
-
const lc = `${this.lc}[${this.
|
|
2936
|
+
async _handleSyncStatus_Complete({ sagaInfo, }) {
|
|
2937
|
+
const lc = `${this.lc}[${this._handleSyncStatus_Complete.name}]`;
|
|
2947
2938
|
try {
|
|
2948
2939
|
// cleanup just this saga, which corresponds to a single sync space.
|
|
2949
|
-
await this.
|
|
2940
|
+
await this._finalizeSyncSaga({ sagaInfo });
|
|
2950
2941
|
// if this is the last saga across all spaces, clean up the rest.
|
|
2951
2942
|
const allSagaInfos = Object.values(this.sagaInfoMap);
|
|
2952
2943
|
if (allSagaInfos.every(x => x.complete)) {
|
|
2953
|
-
await this.
|
|
2944
|
+
await this._finalizeAllSyncSagas_NoThrow({});
|
|
2954
2945
|
}
|
|
2955
2946
|
}
|
|
2956
2947
|
catch (error) {
|
|
2957
2948
|
console.error(`${lc} ${error.message}`);
|
|
2958
|
-
await this.
|
|
2949
|
+
await this._finalizeAllSyncSagas_NoThrow({ error });
|
|
2959
2950
|
}
|
|
2960
2951
|
}
|
|
2961
2952
|
/**
|
|
@@ -3064,96 +3055,89 @@ export class MetaspaceBase {
|
|
|
3064
3055
|
throw error;
|
|
3065
3056
|
}
|
|
3066
3057
|
}
|
|
3067
|
-
async handleWatchTjpUpdates({
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
}
|
|
3151
|
-
finally {
|
|
3152
|
-
if (logalot) {
|
|
3153
|
-
console.log(`${lc} complete.`);
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
}
|
|
3058
|
+
// protected async handleWatchTjpUpdates({
|
|
3059
|
+
// updates,
|
|
3060
|
+
// outerSpace,
|
|
3061
|
+
// localUserSpace,
|
|
3062
|
+
// }: {
|
|
3063
|
+
// updates: { [tjpAddr: string]: IbGibAddr; }
|
|
3064
|
+
// outerSpace: IbGibSpaceAny,
|
|
3065
|
+
// localUserSpace: IbGibSpaceAny,
|
|
3066
|
+
// }): Promise<void> {
|
|
3067
|
+
// const lc = `${this.lc}[${this.handleWatchTjpUpdates.name}]`;
|
|
3068
|
+
// if (logalot) { console.log(`${lc} starting...`); }
|
|
3069
|
+
// try {
|
|
3070
|
+
// if (!outerSpace.data) { throw new Error(`outerSpace.data falsy (E: b5fde89e87bef9b8b6ce38e24be4a823)`); }
|
|
3071
|
+
// /**
|
|
3072
|
+
// * compile list of addrs we have locally for all updates, so we don't try
|
|
3073
|
+
// * to download them from outer space unnecessarily.
|
|
3074
|
+
// */
|
|
3075
|
+
// const latestAddrsLocallyWithUpdate: IbGibAddr[] = [];
|
|
3076
|
+
// const tjpAddrs = Object.keys(updates);
|
|
3077
|
+
// const latestAddrs_Store = Object.values(updates);
|
|
3078
|
+
// for (let i = 0; i < tjpAddrs.length; i++) {
|
|
3079
|
+
// const tjpAddr = tjpAddrs[i];
|
|
3080
|
+
// if (logalot) { console.log(`${lc} tjpAddr: ${tjpAddr}`); }
|
|
3081
|
+
// const latestAddrLocally = await this.getLatestAddr({ tjpAddr }) ?? tjpAddr;
|
|
3082
|
+
// if (
|
|
3083
|
+
// !latestAddrs_Store.includes(latestAddrLocally) &&
|
|
3084
|
+
// !latestAddrsLocallyWithUpdate.includes(latestAddrLocally)
|
|
3085
|
+
// ) {
|
|
3086
|
+
// latestAddrsLocallyWithUpdate.push(latestAddrLocally);
|
|
3087
|
+
// }
|
|
3088
|
+
// }
|
|
3089
|
+
// if (latestAddrsLocallyWithUpdate.length === 0) {
|
|
3090
|
+
// if (logalot) { console.log(`${lc} latestAddrsLocallyWithUpdate.length === 0. We already had all of the updates locally perhaps. Returning early. (I: 844193c515084d0ebc348349f1ac41f4)`); }
|
|
3091
|
+
// return; /* <<<< returns early */
|
|
3092
|
+
// }
|
|
3093
|
+
// /**
|
|
3094
|
+
// * LOCAL dependencies for latest LOCAL addrs for all tjpAddrs in updates.
|
|
3095
|
+
// */
|
|
3096
|
+
// const localDependencyGraphs = await this.getDependencyGraph({
|
|
3097
|
+
// ibGibAddrs: latestAddrsLocallyWithUpdate,
|
|
3098
|
+
// live: true,
|
|
3099
|
+
// maxRetries: DEFAULT_MAX_RETRIES_GET_DEPENDENCY_GRAPH_OUTERSPACE,
|
|
3100
|
+
// msBetweenRetries: DEFAULT_MS_BETWEEN_RETRIES_GET_DEPENDENCY_GRAPH_OUTERSPACE,
|
|
3101
|
+
// space: localUserSpace,
|
|
3102
|
+
// });
|
|
3103
|
+
// /** all addrs we already have locally */
|
|
3104
|
+
// const addrsAlreadyStoredLocally = Object.keys(localDependencyGraphs);
|
|
3105
|
+
// // get dependency graph from outer space, skipping all addrs in local already
|
|
3106
|
+
// const newerAddrsFromOuterSpace: IbGibAddr[] = Object.values(updates);
|
|
3107
|
+
// const newerIbGibDependencyGraphFromOuterSpace = await getDependencyGraph({
|
|
3108
|
+
// ibGibAddrs: newerAddrsFromOuterSpace,
|
|
3109
|
+
// live: false,
|
|
3110
|
+
// skipAddrs: addrsAlreadyStoredLocally,
|
|
3111
|
+
// space: outerSpace,
|
|
3112
|
+
// });
|
|
3113
|
+
// const newerIbGibsFromOuterSpace: IbGib_V1[] =
|
|
3114
|
+
// Object.values(newerIbGibDependencyGraphFromOuterSpace);
|
|
3115
|
+
// if (logalot) { console.log(`${lc} got ${newerIbGibsFromOuterSpace.length} ibGibs from outerspace`); }
|
|
3116
|
+
// // save locally
|
|
3117
|
+
// if (logalot) { console.log(`${lc} saving new ibgibs from outerspace in local space...`); }
|
|
3118
|
+
// if (newerIbGibsFromOuterSpace.length > 0) {
|
|
3119
|
+
// await this.put({ ibGibs: newerIbGibsFromOuterSpace });
|
|
3120
|
+
// // register the newest tjp ibGibs locally
|
|
3121
|
+
// if (logalot) { console.log(`${lc} registering "new" updated tjp ibgibs locally...`); }
|
|
3122
|
+
// for (let i = 0; i < tjpAddrs.length; i++) {
|
|
3123
|
+
// const tjpAddr = tjpAddrs[i];
|
|
3124
|
+
// const updatedAddr = updates[tjpAddr];
|
|
3125
|
+
// if (!addrsAlreadyStoredLocally.includes(updatedAddr)) {
|
|
3126
|
+
// const updatedIbGib = newerIbGibDependencyGraphFromOuterSpace[updatedAddr];
|
|
3127
|
+
// if (!updatedIbGib) {
|
|
3128
|
+
// throw new Error(`did not get updatedIbGib (${updatedAddr}) from outerspace (${outerSpace.data.uuid}) (E: 818de70f5b444a3ba198ba6480a15b04)`);
|
|
3129
|
+
// }
|
|
3130
|
+
// await this.registerNewIbGib({ ibGib: updatedIbGib });
|
|
3131
|
+
// }
|
|
3132
|
+
// }
|
|
3133
|
+
// }
|
|
3134
|
+
// } catch (error) {
|
|
3135
|
+
// console.error(`${lc} ${error.message}`);
|
|
3136
|
+
// // does not rethrow
|
|
3137
|
+
// } finally {
|
|
3138
|
+
// if (logalot) { console.log(`${lc} complete.`); }
|
|
3139
|
+
// }
|
|
3140
|
+
// }
|
|
3157
3141
|
// #endregion syncIbGibs related
|
|
3158
3142
|
// #region autosync
|
|
3159
3143
|
async enableAutosync({ tjpIbGibs, }) {
|