@ibgib/core-gib 0.0.68 → 0.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/encrypt/encrypt-constants.d.mts +4 -0
- package/dist/common/encrypt/encrypt-constants.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-constants.mjs +4 -0
- package/dist/common/encrypt/encrypt-constants.mjs.map +1 -1
- package/dist/common/encrypt/encrypt-types.d.mts +1 -4
- package/dist/common/encrypt/encrypt-types.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-types.mjs +0 -1
- package/dist/common/encrypt/encrypt-types.mjs.map +1 -1
- package/dist/common/pubsub/subject/subject-v1.d.mts.map +1 -1
- package/dist/common/pubsub/subject/subject-v1.mjs +1 -0
- package/dist/common/pubsub/subject/subject-v1.mjs.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.d.mts +4 -1
- package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.mjs +38 -47
- package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/encrypt/encrypt-constants.mts +5 -0
- package/src/common/encrypt/encrypt-types.mts +2 -2
- package/src/common/pubsub/subject/subject-v1.mts +1 -0
- package/src/witness/space/metaspace/metaspace-base.mts +55 -66
|
@@ -5,9 +5,9 @@ import { IbGib_V1, } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
|
5
5
|
import { GIB, GIB_DELIMITER, IB, ROOT, } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
6
6
|
import { IbGibAddr, TjpIbGibAddr, TransformResult, } from '@ibgib/ts-gib/dist/types.mjs';
|
|
7
7
|
import { getIbGibAddr, } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
8
|
-
import { Factory_V1 as factory } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
9
8
|
import { getGib, getGibInfo, isPrimitive } from '@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs';
|
|
10
9
|
|
|
10
|
+
import { GLOBAL_LOG_A_LOT, GLOBAL_TIMER_NAME } from '../../../core-constants.mjs';
|
|
11
11
|
import {
|
|
12
12
|
DeleteIbGibOpts, DeleteIbGibResult,
|
|
13
13
|
GetIbGibOpts, GetIbGibResult,
|
|
@@ -31,44 +31,37 @@ import {
|
|
|
31
31
|
} from '../../../common/encrypt/encrypt-types.mjs';
|
|
32
32
|
import { RobbotIbGib_V1 } from '../../../witness/robbot/robbot-types.mjs';
|
|
33
33
|
import { AppIbGib_V1 } from '../../../witness/app/app-types.mjs';
|
|
34
|
-
import {
|
|
35
|
-
getTimelinesGroupedByTjp, getTjpAddr, hasTjp
|
|
36
|
-
} from '../../../common/other/ibgib-helper.mjs';
|
|
37
|
-
// import {
|
|
38
|
-
// getFnPrompt, getFnAlert, getFnPromptPassword
|
|
39
|
-
// } from '../../../common/prompt-functions.mjs';
|
|
34
|
+
import { constantIbGib, getTimelinesGroupedByTjp, hasTjp } from '../../../common/other/ibgib-helper.mjs';
|
|
40
35
|
import {
|
|
41
36
|
getValidatedBootstrapIbGib, getLocalSpace, execInSpaceWithLocking,
|
|
42
37
|
updateBootstrapIbGib, getSpaceArgMetadata, createTagIbGibAndSundry,
|
|
43
38
|
getConfigAddr, setConfigAddr, setCurrentRoot, rel8ToCurrentRoot,
|
|
44
39
|
rel8ToSpecialIbGib, registerNewIbGib, persistTransformResult, getFromSpace,
|
|
45
|
-
putInSpace, deleteFromSpace, getLatestAddrs, getTjpIbGib,
|
|
46
|
-
|
|
47
|
-
trash, archive, parseSpaceIb,
|
|
40
|
+
putInSpace, deleteFromSpace, getLatestAddrs, getTjpIbGib, getSpecialIbGib,
|
|
41
|
+
getSpecialRel8dIbGibs, /*createRobbotIbGib, */ trash, archive, parseSpaceIb,
|
|
48
42
|
} from '../../../witness/space/space-helper.mjs';
|
|
49
43
|
import { getDependencyGraph, GetDependencyGraphOptions } from '../../../common/other/graph-helper.mjs';
|
|
50
|
-
import { spaceNameIsValid, } from '../../../witness/space/space-helper.mjs';
|
|
51
44
|
import { RobbotPromptResult } from '../../../witness/robbot/robbot-types.mjs';
|
|
52
45
|
import { createNewRobbot, validateCommonRobbotData, validateCommonRobbotIbGib } from '../../../witness/robbot/robbot-helper.mjs';
|
|
53
46
|
import { AppPromptResult } from '../../../witness/app/app-types.mjs';
|
|
54
47
|
import { createNewApp, } from '../../../witness/app/app-helper.mjs';
|
|
55
|
-
import { CommentIbGib_V1, UpdateCommentPromptResult } from '../../../common/comment/comment-types.mjs';
|
|
56
48
|
import { IbGibCacheService } from '../../../common/cache/cache-types.mjs';
|
|
57
49
|
import { BOOTSTRAP_DATA_KNOWN_SPACE_IDS_KEY, BOOTSTRAP_IBGIB_ADDR } from '../../../witness/space/bootstrap/bootstrap-constants.mjs';
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
|
|
50
|
+
import { DEFAULT_SECONDS_VALID_LOCAL, SYNC_SPACE_REL8N_NAME } from '../../../witness/space/space-constants.mjs';
|
|
51
|
+
import {
|
|
52
|
+
CIPHERTEXT_ATOM, DEFAULT_ENCRYPTION_HASH_ALGORITHM,
|
|
53
|
+
DEFAULT_ENCRYPTION_INITIAL_RECURSIONS,
|
|
54
|
+
DEFAULT_ENCRYPTION_RECURSIONS_PER_HASH, DEFAULT_ENCRYPTION_SALT_STRATEGY,
|
|
55
|
+
ENCRYPTION_REL8N_NAME,
|
|
56
|
+
} from '../../../common/encrypt/encrypt-constants.mjs';
|
|
61
57
|
import { ROBBOT_REL8N_NAME } from '../../../witness/robbot/robbot-constants.mjs';
|
|
62
58
|
import { APP_REL8N_NAME } from '../../../witness/app/app-constants.mjs';
|
|
63
59
|
import { AUTOSYNC_ALWAYS_REL8N_NAME } from '../../../common/other/other-constants.mjs';
|
|
64
60
|
import {
|
|
65
|
-
MetaspaceInitializeOptions, CreateLocalSpaceOptions,
|
|
66
|
-
LocalSpaceFactoryFunction,
|
|
61
|
+
MetaspaceInitializeOptions, CreateLocalSpaceOptions,
|
|
62
|
+
LocalSpaceFactoryFunction, MetaspaceFactory
|
|
67
63
|
} from './metaspace-types.mjs';
|
|
68
64
|
import { MetaspaceService, TempCacheEntry } from './metaspace-types.mjs';
|
|
69
|
-
import { InnerSpace_V1 } from '../../../witness/space/inner-space/inner-space-v1.mjs';
|
|
70
|
-
|
|
71
|
-
import { GLOBAL_LOG_A_LOT, GLOBAL_TIMER_NAME } from '../../../core-constants.mjs';
|
|
72
65
|
import { newupSubject } from '../../../common/pubsub/subject/subject-helper.mjs';
|
|
73
66
|
import { ObservableWitness, } from '../../../common/pubsub/observable/observable-types.mjs';
|
|
74
67
|
import { SubjectWitness } from '../../../common/pubsub/subject/subject-types.mjs';
|
|
@@ -1750,6 +1743,9 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1750
1743
|
}
|
|
1751
1744
|
}
|
|
1752
1745
|
|
|
1746
|
+
/**
|
|
1747
|
+
* creates a ciphertext ibgib (stone) based on the given plaintext.
|
|
1748
|
+
*/
|
|
1753
1749
|
async getCiphertextIbGib<TEncryptionIbGib extends IbGib_V1<EncryptionData_V1>, TMetadata = any>({
|
|
1754
1750
|
plaintext,
|
|
1755
1751
|
password,
|
|
@@ -1773,7 +1769,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1773
1769
|
*/
|
|
1774
1770
|
encryptionIbGib: TEncryptionIbGib,
|
|
1775
1771
|
/**
|
|
1776
|
-
*
|
|
1772
|
+
* Confirms encryption succeeds by doing an immediate decrypt and checking against original data.
|
|
1777
1773
|
*/
|
|
1778
1774
|
confirm?: boolean,
|
|
1779
1775
|
/**
|
|
@@ -1805,7 +1801,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1805
1801
|
try {
|
|
1806
1802
|
const encryptionInfo = encryptionIbGib.data;
|
|
1807
1803
|
if (encryptionInfo?.method !== EncryptionMethod.encrypt_gib) {
|
|
1808
|
-
throw new Error('only encrypt-gib is implemented.');
|
|
1804
|
+
throw new Error('only encrypt-gib is implemented. (E: 1d8eb1be6d3f44f0a79b498f237147e6');
|
|
1809
1805
|
}
|
|
1810
1806
|
const info: EncryptionInfo_EncryptGib = encryptionInfo;
|
|
1811
1807
|
const resEncrypt = await encrypt({
|
|
@@ -1817,6 +1813,8 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1817
1813
|
saltStrategy: info.saltStrategy,
|
|
1818
1814
|
hashAlgorithm: info.hashAlgorithm,
|
|
1819
1815
|
encryptedDataDelimiter: info.encryptedDataDelimiter,
|
|
1816
|
+
blockMode: encryptionInfo.blockMode ? encryptionInfo.blockModeOptions : undefined,
|
|
1817
|
+
indexingMode: encryptionInfo.indexingMode,
|
|
1820
1818
|
confirm,
|
|
1821
1819
|
});
|
|
1822
1820
|
|
|
@@ -1824,40 +1822,34 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1824
1822
|
if (resEncrypt.errors?.length ?? 0 > 0) { throw new Error(resEncrypt.errors!.join('\n')); }
|
|
1825
1823
|
if (!resEncrypt.encryptedData) { throw new Error(`encryptedData is falsy`) }
|
|
1826
1824
|
|
|
1827
|
-
const data: CiphertextData = {
|
|
1825
|
+
const data: CiphertextData = {
|
|
1826
|
+
ciphertext: resEncrypt.encryptedData,
|
|
1827
|
+
uuid: await getUUID(),
|
|
1828
|
+
};
|
|
1828
1829
|
if (publicMetadata) { data.metadata = publicMetadata; }
|
|
1829
1830
|
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1831
|
+
const ciphertextIbGib = await constantIbGib<CiphertextData, CiphertextRel8ns>({
|
|
1832
|
+
parentPrimitiveIb: ibRoot || CIPHERTEXT_ATOM,
|
|
1833
|
+
ib:
|
|
1834
|
+
publicIbMetadata ?
|
|
1835
|
+
`${ibRoot || CIPHERTEXT_ATOM} ${publicIbMetadata}` :
|
|
1836
|
+
`${ibRoot || CIPHERTEXT_ATOM}`,
|
|
1837
|
+
data,
|
|
1838
|
+
rel8ns: undefined,
|
|
1839
|
+
}) as CiphertextIbGib_V1;
|
|
1840
|
+
const resTransform: TransformResult<CiphertextIbGib_V1> = {
|
|
1841
|
+
newIbGib: ciphertextIbGib
|
|
1832
1842
|
}
|
|
1833
1843
|
|
|
1834
|
-
const resCiphertext = (
|
|
1835
|
-
await factory.firstGen({
|
|
1836
|
-
parentIbGib: factory.primitive({ ib: ibRoot || 'ciphertext' }),
|
|
1837
|
-
ib:
|
|
1838
|
-
publicIbMetadata ?
|
|
1839
|
-
`${ibRoot || 'ciphertext'} ${publicIbMetadata}` :
|
|
1840
|
-
`${ibRoot || 'ciphertext'}`,
|
|
1841
|
-
data,
|
|
1842
|
-
rel8ns,
|
|
1843
|
-
dna: false,
|
|
1844
|
-
tjp: { uuid: true, timestamp: true },
|
|
1845
|
-
nCounter: true,
|
|
1846
|
-
})
|
|
1847
|
-
) as TransformResult<CiphertextIbGib_V1>;
|
|
1848
|
-
|
|
1849
|
-
if (!resCiphertext.newIbGib) { throw new Error('Error creating ciphertext ibgib.'); }
|
|
1850
|
-
|
|
1851
1844
|
if (persist) {
|
|
1852
|
-
await this.persistTransformResult({ resTransform
|
|
1845
|
+
await this.persistTransformResult({ resTransform });
|
|
1853
1846
|
}
|
|
1854
1847
|
|
|
1855
|
-
return
|
|
1848
|
+
return resTransform;
|
|
1856
1849
|
} catch (error) {
|
|
1857
1850
|
console.error(`${lc} ${error.message}`);
|
|
1858
1851
|
throw error;
|
|
1859
1852
|
}
|
|
1860
|
-
|
|
1861
1853
|
}
|
|
1862
1854
|
|
|
1863
1855
|
/**
|
|
@@ -2618,18 +2610,20 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2618
2610
|
|
|
2619
2611
|
// have to make sagaId and syncStatus$ early to enable timeLog calls
|
|
2620
2612
|
const sagaId = (await getUUID()).slice(0, 24);
|
|
2621
|
-
const syncStatus$ = await newupSubject<SyncStatusIbGib>();
|
|
2613
|
+
const syncStatus$ = await newupSubject<SyncStatusIbGib>({ replay: true });
|
|
2622
2614
|
const syncTimelogName = `sync_log ${sagaId}`;
|
|
2623
2615
|
console.time(syncTimelogName);
|
|
2624
2616
|
console.timeLog(syncTimelogName, 'start');
|
|
2625
2617
|
this.subSagaSyncTimeLog = await syncStatus$.subscribe(fnObs<SyncStatusIbGib>({
|
|
2626
2618
|
next: async (status) => {
|
|
2619
|
+
// debugger; // metaspacebase syncIbGibs next
|
|
2627
2620
|
if (logalot) { console.log(`${lc}[obs.next] next called (I: 9af8d3267b0ff473fe5f8024f0dbed23)`); }
|
|
2628
2621
|
if (status.data?.statusCode === StatusCode.completed) {
|
|
2629
2622
|
console.timeLog(syncTimelogName, 'StatusCode.complete');
|
|
2630
2623
|
}
|
|
2631
2624
|
},
|
|
2632
2625
|
error: async (_: any) => {
|
|
2626
|
+
// debugger; // metaspacebase syncIbGibs error
|
|
2633
2627
|
if (logalot) { console.log(`${lc}[obs.error] error called (I: 976b08ab82d64299b17927eac16b1693)`); }
|
|
2634
2628
|
console.timeEnd(syncTimelogName)
|
|
2635
2629
|
if (!this.subSagaSyncTimeLog) {
|
|
@@ -2638,6 +2632,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2638
2632
|
await this.subSagaSyncTimeLog!.unsubscribe();
|
|
2639
2633
|
},
|
|
2640
2634
|
complete: async () => {
|
|
2635
|
+
// debugger; // metaspacebase syncIbGibs complete
|
|
2641
2636
|
if (logalot) { console.log(`${lc}[obs.complete] complete called (I: 72307340e2b34b22b0787e3a3c906c06)`); }
|
|
2642
2637
|
console.timeEnd(syncTimelogName)
|
|
2643
2638
|
if (!this.subSagaSyncTimeLog) {
|
|
@@ -2755,10 +2750,13 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2755
2750
|
`${lc} something went wrong (E: d7db873d9e8b4f14b5b490cadd9730f4)`;
|
|
2756
2751
|
console.error(emsg);
|
|
2757
2752
|
if (!sagaInfo.syncStatus$.error) { throw new Error(`(UNEXPECTED) sagaInfo.syncStatus$.error is falsy? (E: 8522f275dbbf0885db75aead27d72923)`); }
|
|
2758
|
-
sagaInfo.syncStatus$.error!(emsg);
|
|
2753
|
+
await sagaInfo.syncStatus$.error!(emsg);
|
|
2759
2754
|
}
|
|
2760
|
-
|
|
2761
|
-
sagaInfo.syncStatus$.complete();
|
|
2755
|
+
// we don't call complete() from within a next() (i don't think)
|
|
2756
|
+
// if (!sagaInfo.syncStatus$.complete) { throw new Error(`(UNEXPECTED) sagaInfo.syncStatus$.complete is falsy? (E: 836f42d8f7084ff9afd73696134d41e6)`); }
|
|
2757
|
+
// if (!sagaInfo.syncStatus$.isCompleteOrErrored) {
|
|
2758
|
+
// await sagaInfo.syncStatus$.complete();
|
|
2759
|
+
// }
|
|
2762
2760
|
}
|
|
2763
2761
|
// I think $.complete() closes subscriptions, but to be double sure...
|
|
2764
2762
|
let toUnsubscribe: SubscriptionWitness[] = [];
|
|
@@ -2766,15 +2764,10 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
2766
2764
|
for (let i = 0; i < subscriptions.length; i++) {
|
|
2767
2765
|
const sub = subscriptions[i];
|
|
2768
2766
|
let unsubscribed = await sub.unsubscribed();
|
|
2769
|
-
if (!unsubscribed) {
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
// .forEach(sub => { sub.unsubscribe(); });
|
|
2774
|
-
// for (let i = 0; i < toUnsubscribe.length; i++) {
|
|
2775
|
-
// let sub = toUnsubscribe[i];
|
|
2776
|
-
// await sub.unsubscribe();
|
|
2777
|
-
// }
|
|
2767
|
+
if (!unsubscribed) {
|
|
2768
|
+
await sub.unsubscribe();
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2778
2771
|
|
|
2779
2772
|
if (logalot) { console.log(`${lc} setting sagaInfo.complete to true (I: 85c34469cdac404782c2024ad6b6fbd1)`); }
|
|
2780
2773
|
sagaInfo.complete = true;
|
|
@@ -3041,25 +3034,21 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3041
3034
|
const sagaInfo = infos[i];
|
|
3042
3035
|
|
|
3043
3036
|
let sub = await sagaInfo.syncStatus$
|
|
3044
|
-
// .pipe(
|
|
3045
|
-
// concatMap(async (status: SyncStatusIbGib) => {
|
|
3046
|
-
// if (logalot) { console.log(`${lc}(sagaId: ${sagaInfo.sagaId}) status received. ${status?.data?.statusCode ?? 'no status'}`) }
|
|
3047
|
-
// await this._handleSyncStatusIbGib({ status, sagaInfo });
|
|
3048
|
-
// return status;
|
|
3049
|
-
// })
|
|
3050
|
-
// )
|
|
3051
3037
|
.subscribe(fnObs({
|
|
3052
3038
|
next: async (status: SyncStatusIbGib) => {
|
|
3039
|
+
// debugger; // metaspacebase handlesagaupdates next
|
|
3053
3040
|
if (logalot) { console.log(`${lc}(sagaId: ${sagaInfo.sagaId}) subscribe next triggered. status: ${status?.data?.statusCode} (I: 41e1f61e5e1b422ead1d72a1c92c7d51)`); }
|
|
3054
3041
|
await this._handleSyncStatusIbGib({ status, sagaInfo });
|
|
3055
3042
|
},
|
|
3056
3043
|
error: async (error: string) => {
|
|
3044
|
+
// debugger; // metaspacebase handlesagaupdates error
|
|
3057
3045
|
const emsg = `${lc}(sagaId: ${sagaInfo.sagaId}) syncStatus$.error: ${error}`;
|
|
3058
3046
|
console.error(emsg);
|
|
3059
3047
|
// await this.getFnAlert!()({title: 'couldnt this.syncIbGibs...', msg: emsg});
|
|
3060
3048
|
await this._finalizeSyncSaga({ sagaInfo, error: emsg });
|
|
3061
3049
|
},
|
|
3062
3050
|
complete: async () => {
|
|
3051
|
+
// debugger; // metaspacebase handlesagaupdates complete
|
|
3063
3052
|
if (logalot) { console.log(`${lc}(sagaId: ${sagaInfo.sagaId}) syncStatus$.complete.`); }
|
|
3064
3053
|
}
|
|
3065
3054
|
}));
|
|
@@ -3146,7 +3135,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
3146
3135
|
if (!sagaInfo.syncStatus$?.error) {
|
|
3147
3136
|
throw new Error(`(UNEXPECTED) sagaInfo.syncStatus$.error falsy? (E: 36cc488835aeb12e1ae6b7a49d0d8523)`);
|
|
3148
3137
|
}
|
|
3149
|
-
sagaInfo.syncStatus$.error(emsg);
|
|
3138
|
+
await sagaInfo.syncStatus$.error(emsg);
|
|
3150
3139
|
}
|
|
3151
3140
|
};
|
|
3152
3141
|
|