@twin.org/synchronised-storage-service 0.0.1-next.8 → 0.0.3-next.1
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/es/data/verifiableStorageKeys.json +5 -0
- package/dist/es/entities/syncSnapshotEntry.js +93 -0
- package/dist/es/entities/syncSnapshotEntry.js.map +1 -0
- package/dist/es/helpers/blobStorageHelper.js +185 -0
- package/dist/es/helpers/blobStorageHelper.js.map +1 -0
- package/dist/es/helpers/changeSetHelper.js +215 -0
- package/dist/es/helpers/changeSetHelper.js.map +1 -0
- package/dist/es/helpers/localSyncStateHelper.js +384 -0
- package/dist/es/helpers/localSyncStateHelper.js.map +1 -0
- package/dist/es/helpers/remoteSyncStateHelper.js +560 -0
- package/dist/es/helpers/remoteSyncStateHelper.js.map +1 -0
- package/dist/es/helpers/versions.js +6 -0
- package/dist/es/helpers/versions.js.map +1 -0
- package/dist/es/index.js +13 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/ISyncPointerStore.js +4 -0
- package/dist/es/models/ISyncPointerStore.js.map +1 -0
- package/dist/es/models/ISyncSnapshot.js +4 -0
- package/dist/es/models/ISyncSnapshot.js.map +1 -0
- package/dist/es/models/ISyncState.js +2 -0
- package/dist/es/models/ISyncState.js.map +1 -0
- package/dist/es/models/ISynchronisedStorageServiceConfig.js +4 -0
- package/dist/es/models/ISynchronisedStorageServiceConfig.js.map +1 -0
- package/dist/es/models/ISynchronisedStorageServiceConstructorOptions.js +2 -0
- package/dist/es/models/ISynchronisedStorageServiceConstructorOptions.js.map +1 -0
- package/dist/es/restEntryPoints.js +10 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/es/schema.js +11 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/es/synchronisedStorageRoutes.js +153 -0
- package/dist/es/synchronisedStorageRoutes.js.map +1 -0
- package/dist/es/synchronisedStorageService.js +554 -0
- package/dist/es/synchronisedStorageService.js.map +1 -0
- package/dist/types/entities/syncSnapshotEntry.d.ts +3 -3
- package/dist/types/helpers/blobStorageHelper.d.ts +3 -3
- package/dist/types/helpers/changeSetHelper.d.ts +16 -32
- package/dist/types/helpers/localSyncStateHelper.d.ts +11 -11
- package/dist/types/helpers/remoteSyncStateHelper.d.ts +18 -14
- package/dist/types/index.d.ts +10 -10
- package/dist/types/models/ISyncState.d.ts +1 -1
- package/dist/types/models/ISynchronisedStorageServiceConfig.d.ts +3 -8
- package/dist/types/models/ISynchronisedStorageServiceConstructorOptions.d.ts +7 -6
- package/dist/types/synchronisedStorageRoutes.d.ts +1 -1
- package/dist/types/synchronisedStorageService.d.ts +18 -21
- package/docs/architecture.md +168 -12
- package/docs/changelog.md +149 -0
- package/docs/open-api/spec.json +62 -57
- package/docs/reference/classes/SyncSnapshotEntry.md +4 -10
- package/docs/reference/classes/SynchronisedStorageService.md +38 -50
- package/docs/reference/interfaces/ISynchronisedStorageServiceConfig.md +3 -17
- package/docs/reference/interfaces/ISynchronisedStorageServiceConstructorOptions.md +9 -8
- package/locales/en.json +11 -16
- package/package.json +26 -9
- package/dist/cjs/index.cjs +0 -2233
- package/dist/esm/index.mjs +0 -2225
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ISyncChange
|
|
1
|
+
import type { ISyncChange } from "@twin.org/synchronised-storage-models";
|
|
2
2
|
/**
|
|
3
3
|
* Class representing an entry for the sync snapshot.
|
|
4
4
|
*/
|
|
5
|
-
export declare class SyncSnapshotEntry
|
|
5
|
+
export declare class SyncSnapshotEntry {
|
|
6
6
|
/**
|
|
7
7
|
* The id for the snapshot.
|
|
8
8
|
*/
|
|
@@ -42,5 +42,5 @@ export declare class SyncSnapshotEntry<T extends ISynchronisedEntity = ISynchron
|
|
|
42
42
|
/**
|
|
43
43
|
* The changes that were made in this snapshot, if this is a local snapshot.
|
|
44
44
|
*/
|
|
45
|
-
changes?: ISyncChange
|
|
45
|
+
changes?: ISyncChange[];
|
|
46
46
|
}
|
|
@@ -8,16 +8,16 @@ export declare class BlobStorageHelper {
|
|
|
8
8
|
/**
|
|
9
9
|
* Runtime name for the class.
|
|
10
10
|
*/
|
|
11
|
-
readonly CLASS_NAME: string;
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
13
|
* Create a new instance of BlobStorageHelper.
|
|
14
|
-
* @param
|
|
14
|
+
* @param logging The logging component to use for logging.
|
|
15
15
|
* @param vaultConnector The vault connector to use for for the encryption key.
|
|
16
16
|
* @param blobStorageConnector The blob storage component to use.
|
|
17
17
|
* @param blobStorageEncryptionKeyId The id of the vault key to use for encrypting/decrypting blobs.
|
|
18
18
|
* @param isTrustedNode Is this a trusted node.
|
|
19
19
|
*/
|
|
20
|
-
constructor(
|
|
20
|
+
constructor(logging: ILoggingComponent | undefined, vaultConnector: IVaultConnector, blobStorageConnector: IBlobStorageConnector, blobStorageEncryptionKeyId: string, isTrustedNode: boolean);
|
|
21
21
|
/**
|
|
22
22
|
* Load a blob from storage.
|
|
23
23
|
* @param blobId The id of the blob to apply.
|
|
@@ -1,81 +1,65 @@
|
|
|
1
1
|
import type { IEventBusComponent } from "@twin.org/event-bus-models";
|
|
2
|
-
import { type IIdentityConnector } from "@twin.org/identity-models";
|
|
3
2
|
import type { ILoggingComponent } from "@twin.org/logging-models";
|
|
4
|
-
import { type
|
|
5
|
-
import
|
|
6
|
-
import type { BlobStorageHelper } from "./blobStorageHelper";
|
|
3
|
+
import { type ISyncChangeSet, type SyncNodeIdMode } from "@twin.org/synchronised-storage-models";
|
|
4
|
+
import type { BlobStorageHelper } from "./blobStorageHelper.js";
|
|
7
5
|
/**
|
|
8
6
|
* Class for performing change set operations.
|
|
9
7
|
*/
|
|
10
|
-
export declare class ChangeSetHelper
|
|
8
|
+
export declare class ChangeSetHelper {
|
|
11
9
|
/**
|
|
12
10
|
* Runtime name for the class.
|
|
13
11
|
*/
|
|
14
|
-
readonly CLASS_NAME: string;
|
|
12
|
+
static readonly CLASS_NAME: string;
|
|
15
13
|
/**
|
|
16
14
|
* Create a new instance of ChangeSetHelper.
|
|
17
|
-
* @param
|
|
15
|
+
* @param logging The logging component to use for logging.
|
|
18
16
|
* @param eventBusComponent The event bus component to use for events.
|
|
19
|
-
* @param identityConnector The identity connector to use for signing/verifying changesets.
|
|
20
17
|
* @param blobStorageHelper The blob storage component to use for remote sync states.
|
|
21
|
-
* @param decentralisedStorageMethodId The id of the identity method to use when signing/verifying changesets.
|
|
22
18
|
*/
|
|
23
|
-
constructor(
|
|
19
|
+
constructor(logging: ILoggingComponent | undefined, eventBusComponent: IEventBusComponent, blobStorageHelper: BlobStorageHelper);
|
|
24
20
|
/**
|
|
25
21
|
* Set the node identity to use for signing changesets.
|
|
26
|
-
* @param
|
|
22
|
+
* @param nodeId The identity of the node that is performing the update.
|
|
27
23
|
*/
|
|
28
|
-
|
|
24
|
+
setNodeId(nodeId: string): void;
|
|
29
25
|
/**
|
|
30
|
-
* Get
|
|
26
|
+
* Get a changeset.
|
|
31
27
|
* @param changeSetStorageId The id of the sync changeset to apply.
|
|
32
28
|
* @returns The changeset if it was verified.
|
|
33
29
|
*/
|
|
34
|
-
|
|
30
|
+
getChangeset(changeSetStorageId: string): Promise<ISyncChangeSet | undefined>;
|
|
35
31
|
/**
|
|
36
32
|
* Apply a sync changeset.
|
|
37
33
|
* @param changeSetStorageId The id of the sync changeset to apply.
|
|
38
34
|
* @returns The changeset if it existed.
|
|
39
35
|
*/
|
|
40
|
-
getAndApplyChangeset(changeSetStorageId: string): Promise<ISyncChangeSet
|
|
36
|
+
getAndApplyChangeset(changeSetStorageId: string): Promise<ISyncChangeSet | undefined>;
|
|
41
37
|
/**
|
|
42
38
|
* Apply a sync changeset.
|
|
43
39
|
* @param syncChangeset The sync changeset to apply.
|
|
44
40
|
* @returns Nothing.
|
|
45
41
|
*/
|
|
46
|
-
applyChangeset(syncChangeset: ISyncChangeSet
|
|
42
|
+
applyChangeset(syncChangeset: ISyncChangeSet): Promise<void>;
|
|
47
43
|
/**
|
|
48
44
|
* Store the changeset.
|
|
49
45
|
* @param syncChangeSet The sync change set to store.
|
|
50
46
|
* @returns The id of the change set.
|
|
51
47
|
*/
|
|
52
48
|
storeChangeSet(syncChangeSet: ISyncChangeSet): Promise<string>;
|
|
53
|
-
/**
|
|
54
|
-
* Verify the proof of a sync changeset.
|
|
55
|
-
* @param syncChangeset The sync changeset to verify.
|
|
56
|
-
* @returns True if the proof is valid, false otherwise.
|
|
57
|
-
*/
|
|
58
|
-
verifyChangesetProof(syncChangeset: ISyncChangeSet): Promise<boolean>;
|
|
59
|
-
/**
|
|
60
|
-
* Create the proof of a sync change set.
|
|
61
|
-
* @param syncChangeset The sync changeset to create the proof for.
|
|
62
|
-
* @returns The proof.
|
|
63
|
-
*/
|
|
64
|
-
createChangeSetProof(syncChangeset: ISyncChangeSet): Promise<IProof>;
|
|
65
49
|
/**
|
|
66
50
|
* Copy a change set.
|
|
67
51
|
* @param syncChangeSet The sync changeset to copy.
|
|
68
52
|
* @returns The id of the updated change set.
|
|
69
53
|
*/
|
|
70
|
-
copyChangeset(syncChangeSet: ISyncChangeSet
|
|
71
|
-
syncChangeSet: ISyncChangeSet
|
|
54
|
+
copyChangeset(syncChangeSet: ISyncChangeSet): Promise<{
|
|
55
|
+
syncChangeSet: ISyncChangeSet;
|
|
72
56
|
changeSetStorageId: string;
|
|
73
57
|
} | undefined>;
|
|
74
58
|
/**
|
|
75
59
|
* Reset the storage for a given storage key.
|
|
76
60
|
* @param storageKey The key of the storage to reset.
|
|
77
|
-
* @param resetMode The reset mode, this will use the
|
|
61
|
+
* @param resetMode The reset mode, this will use the nodeId in the entities to determine which are local/remote.
|
|
78
62
|
* @returns Nothing.
|
|
79
63
|
*/
|
|
80
|
-
reset(storageKey: string, resetMode:
|
|
64
|
+
reset(storageKey: string, resetMode: SyncNodeIdMode): Promise<void>;
|
|
81
65
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import type { IEntityStorageConnector } from "@twin.org/entity-storage-models";
|
|
2
2
|
import type { ILoggingComponent } from "@twin.org/logging-models";
|
|
3
|
-
import { type
|
|
4
|
-
import type { ChangeSetHelper } from "./changeSetHelper";
|
|
5
|
-
import type { SyncSnapshotEntry } from "../entities/syncSnapshotEntry";
|
|
6
|
-
import type { ISyncState } from "../models/ISyncState";
|
|
3
|
+
import { type SyncChangeOperation } from "@twin.org/synchronised-storage-models";
|
|
4
|
+
import type { ChangeSetHelper } from "./changeSetHelper.js";
|
|
5
|
+
import type { SyncSnapshotEntry } from "../entities/syncSnapshotEntry.js";
|
|
6
|
+
import type { ISyncState } from "../models/ISyncState.js";
|
|
7
7
|
/**
|
|
8
8
|
* Class for performing entity storage operations in decentralised storage.
|
|
9
9
|
*/
|
|
10
|
-
export declare class LocalSyncStateHelper
|
|
10
|
+
export declare class LocalSyncStateHelper {
|
|
11
11
|
/**
|
|
12
12
|
* Runtime name for the class.
|
|
13
13
|
*/
|
|
14
|
-
readonly CLASS_NAME: string;
|
|
14
|
+
static readonly CLASS_NAME: string;
|
|
15
15
|
/**
|
|
16
16
|
* Create a new instance of LocalSyncStateHelper.
|
|
17
|
-
* @param
|
|
17
|
+
* @param logging The logging component to use for logging.
|
|
18
18
|
* @param snapshotEntryEntityStorage The storage connector for the sync snapshot entries.
|
|
19
19
|
* @param changeSetHelper The change set helper to use for applying changesets.
|
|
20
20
|
*/
|
|
21
|
-
constructor(
|
|
21
|
+
constructor(logging: ILoggingComponent | undefined, snapshotEntryEntityStorage: IEntityStorageConnector<SyncSnapshotEntry>, changeSetHelper: ChangeSetHelper);
|
|
22
22
|
/**
|
|
23
23
|
* Add a new change to the local snapshot.
|
|
24
24
|
* @param storageKey The storage key of the snapshot to add the change for.
|
|
@@ -33,19 +33,19 @@ export declare class LocalSyncStateHelper<T extends ISynchronisedEntity = ISynch
|
|
|
33
33
|
* @param isLocal Whether to get the local snapshot or not.
|
|
34
34
|
* @returns The local snapshot entry.
|
|
35
35
|
*/
|
|
36
|
-
getSnapshots(storageKey: string, isLocal: boolean): Promise<SyncSnapshotEntry
|
|
36
|
+
getSnapshots(storageKey: string, isLocal: boolean): Promise<SyncSnapshotEntry[]>;
|
|
37
37
|
/**
|
|
38
38
|
* Set the current local snapshot with changes for this node.
|
|
39
39
|
* @param localChangeSnapshot The local change snapshot to set.
|
|
40
40
|
* @returns Nothing.
|
|
41
41
|
*/
|
|
42
|
-
setLocalChangeSnapshot(localChangeSnapshot: SyncSnapshotEntry
|
|
42
|
+
setLocalChangeSnapshot(localChangeSnapshot: SyncSnapshotEntry): Promise<void>;
|
|
43
43
|
/**
|
|
44
44
|
* Get the current local snapshot with the changes for this node.
|
|
45
45
|
* @param localChangeSnapshot The local change snapshot to remove.
|
|
46
46
|
* @returns Nothing.
|
|
47
47
|
*/
|
|
48
|
-
removeLocalChangeSnapshot(localChangeSnapshot: SyncSnapshotEntry
|
|
48
|
+
removeLocalChangeSnapshot(localChangeSnapshot: SyncSnapshotEntry): Promise<void>;
|
|
49
49
|
/**
|
|
50
50
|
* Apply a sync state to the local node.
|
|
51
51
|
* @param storageKey The storage key of the snapshot to sync with.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { IEventBusComponent } from "@twin.org/event-bus-models";
|
|
2
2
|
import type { ILoggingComponent } from "@twin.org/logging-models";
|
|
3
|
-
import { type ISyncChange, type ISyncChangeSet
|
|
3
|
+
import { type ISyncChange, type ISyncChangeSet } from "@twin.org/synchronised-storage-models";
|
|
4
4
|
import type { IVerifiableStorageConnector } from "@twin.org/verifiable-storage-models";
|
|
5
|
-
import type { BlobStorageHelper } from "./blobStorageHelper";
|
|
6
|
-
import type { ChangeSetHelper } from "./changeSetHelper";
|
|
7
|
-
import type { ISyncPointerStore } from "../models/ISyncPointerStore";
|
|
8
|
-
import type { ISyncState } from "../models/ISyncState";
|
|
5
|
+
import type { BlobStorageHelper } from "./blobStorageHelper.js";
|
|
6
|
+
import type { ChangeSetHelper } from "./changeSetHelper.js";
|
|
7
|
+
import type { ISyncPointerStore } from "../models/ISyncPointerStore.js";
|
|
8
|
+
import type { ISyncState } from "../models/ISyncState.js";
|
|
9
9
|
/**
|
|
10
10
|
* Class for performing entity storage operations in decentralised storage.
|
|
11
11
|
*/
|
|
12
|
-
export declare class RemoteSyncStateHelper
|
|
12
|
+
export declare class RemoteSyncStateHelper {
|
|
13
13
|
/**
|
|
14
14
|
* Runtime name for the class.
|
|
15
15
|
*/
|
|
16
|
-
readonly CLASS_NAME: string;
|
|
16
|
+
static readonly CLASS_NAME: string;
|
|
17
17
|
/**
|
|
18
|
-
* Create a new instance of
|
|
18
|
+
* Create a new instance of RemoteSyncStateHelper.
|
|
19
19
|
* @param loggingComponent The logging component to use for logging.
|
|
20
20
|
* @param eventBusComponent The event bus component to use for events.
|
|
21
21
|
* @param verifiableSyncPointerStorageConnector The verifiable storage connector to use for storing sync pointers.
|
|
@@ -24,12 +24,16 @@ export declare class RemoteSyncStateHelper<T extends ISynchronisedEntity = ISync
|
|
|
24
24
|
* @param isTrustedNode Whether the node is trusted or not.
|
|
25
25
|
* @param maxConsolidations The maximum number of consolidations to keep in storage.
|
|
26
26
|
*/
|
|
27
|
-
constructor(loggingComponent: ILoggingComponent | undefined, eventBusComponent: IEventBusComponent, verifiableSyncPointerStorageConnector: IVerifiableStorageConnector, blobStorageHelper: BlobStorageHelper, changeSetHelper: ChangeSetHelper
|
|
27
|
+
constructor(loggingComponent: ILoggingComponent | undefined, eventBusComponent: IEventBusComponent, verifiableSyncPointerStorageConnector: IVerifiableStorageConnector, blobStorageHelper: BlobStorageHelper, changeSetHelper: ChangeSetHelper, isTrustedNode: boolean, maxConsolidations: number);
|
|
28
28
|
/**
|
|
29
29
|
* Set the node identity to use for signing changesets.
|
|
30
|
-
* @param
|
|
30
|
+
* @param nodeId The identity of the node that is performing the update.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
setNodeId(nodeId: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Start the remote sync state helper.
|
|
35
|
+
*/
|
|
36
|
+
start(): Promise<void>;
|
|
33
37
|
/**
|
|
34
38
|
* Set the synchronised storage key.
|
|
35
39
|
* @param synchronisedStorageKey The synchronised storage key to use.
|
|
@@ -42,18 +46,18 @@ export declare class RemoteSyncStateHelper<T extends ISynchronisedEntity = ISync
|
|
|
42
46
|
* @param completeCallback The callback to call when the changeset is created and stored.
|
|
43
47
|
* @returns The storage id of the change set if created.
|
|
44
48
|
*/
|
|
45
|
-
buildChangeSet(storageKey: string, changes: ISyncChange
|
|
49
|
+
buildChangeSet(storageKey: string, changes: ISyncChange[], completeCallback: (syncChangeSet?: ISyncChangeSet, id?: string) => Promise<void>): Promise<void>;
|
|
46
50
|
/**
|
|
47
51
|
* Finalise the full details for the sync change set.
|
|
48
52
|
* @param storageKey The storage key of the change set.
|
|
49
53
|
* @param completeCallback The callback to call when the changeset is populated.
|
|
50
54
|
* @returns Nothing.
|
|
51
55
|
*/
|
|
52
|
-
finaliseFullChanges(storageKey: string, completeCallback: (syncChangeSet?: ISyncChangeSet
|
|
56
|
+
finaliseFullChanges(storageKey: string, completeCallback: (syncChangeSet?: ISyncChangeSet, id?: string) => Promise<void>): Promise<void>;
|
|
53
57
|
/**
|
|
54
58
|
* Add a new changeset into the sync state.
|
|
55
59
|
* @param storageKey The storage key of the change set to add.
|
|
56
|
-
* @param changeSetStorageId The id of the change set to add the
|
|
60
|
+
* @param changeSetStorageId The id of the change set to add the current state
|
|
57
61
|
* @returns Nothing.
|
|
58
62
|
*/
|
|
59
63
|
addChangeSetToSyncState(storageKey: string, changeSetStorageId: string): Promise<void>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./entities/syncSnapshotEntry";
|
|
2
|
-
export * from "./models/ISynchronisedStorageServiceConfig";
|
|
3
|
-
export * from "./models/ISynchronisedStorageServiceConstructorOptions";
|
|
4
|
-
export * from "./models/ISyncPointerStore";
|
|
5
|
-
export * from "./models/ISyncSnapshot";
|
|
6
|
-
export * from "./models/ISyncState";
|
|
7
|
-
export * from "./restEntryPoints";
|
|
8
|
-
export * from "./schema";
|
|
9
|
-
export * from "./synchronisedStorageRoutes";
|
|
10
|
-
export * from "./synchronisedStorageService";
|
|
1
|
+
export * from "./entities/syncSnapshotEntry.js";
|
|
2
|
+
export * from "./models/ISynchronisedStorageServiceConfig.js";
|
|
3
|
+
export * from "./models/ISynchronisedStorageServiceConstructorOptions.js";
|
|
4
|
+
export * from "./models/ISyncPointerStore.js";
|
|
5
|
+
export * from "./models/ISyncSnapshot.js";
|
|
6
|
+
export * from "./models/ISyncState.js";
|
|
7
|
+
export * from "./restEntryPoints.js";
|
|
8
|
+
export * from "./schema.js";
|
|
9
|
+
export * from "./synchronisedStorageRoutes.js";
|
|
10
|
+
export * from "./synchronisedStorageService.js";
|
|
@@ -2,28 +2,23 @@
|
|
|
2
2
|
* Configuration for the Synchronised Storage Service.
|
|
3
3
|
*/
|
|
4
4
|
export interface ISynchronisedStorageServiceConfig {
|
|
5
|
-
/**
|
|
6
|
-
* The id of the identity method to use when signing/verifying requests and changesets.
|
|
7
|
-
* @default synchronised-storage-assertion
|
|
8
|
-
*/
|
|
9
|
-
synchronisedStorageMethodId?: string;
|
|
10
5
|
/**
|
|
11
6
|
* How often to check for entity updates in minutes.
|
|
12
7
|
* @default 5
|
|
13
8
|
*/
|
|
14
9
|
entityUpdateIntervalMinutes?: number;
|
|
15
10
|
/**
|
|
16
|
-
* Interval to perform consolidation of changesets, only used if
|
|
11
|
+
* Interval to perform consolidation of changesets, only used if this is a trusted node.
|
|
17
12
|
* @default 60
|
|
18
13
|
*/
|
|
19
14
|
consolidationIntervalMinutes?: number;
|
|
20
15
|
/**
|
|
21
|
-
* The number of entities to process in a single consolidation batch.
|
|
16
|
+
* The number of entities to process in a single consolidation batch, only used if this is a trusted node.
|
|
22
17
|
* @default 1000
|
|
23
18
|
*/
|
|
24
19
|
consolidationBatchSize?: number;
|
|
25
20
|
/**
|
|
26
|
-
* The maximum number of consolidations to keep in storage.
|
|
21
|
+
* The maximum number of consolidations to keep in storage, only used if this is a trusted node.
|
|
27
22
|
* @default 5
|
|
28
23
|
*/
|
|
29
24
|
maxConsolidations?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ISynchronisedStorageServiceConfig } from "./ISynchronisedStorageServiceConfig";
|
|
1
|
+
import type { ISynchronisedStorageServiceConfig } from "./ISynchronisedStorageServiceConfig.js";
|
|
2
2
|
/**
|
|
3
3
|
* Options for the Synchronised Storage Service constructor.
|
|
4
4
|
*/
|
|
@@ -30,16 +30,17 @@ export interface ISynchronisedStorageServiceConstructorOptions {
|
|
|
30
30
|
* @default verifiable-storage
|
|
31
31
|
*/
|
|
32
32
|
verifiableStorageConnectorType?: string;
|
|
33
|
-
/**
|
|
34
|
-
* The identity connector.
|
|
35
|
-
* @default identity
|
|
36
|
-
*/
|
|
37
|
-
identityConnectorType?: string;
|
|
38
33
|
/**
|
|
39
34
|
* The task scheduler component.
|
|
40
35
|
* @default task-scheduler
|
|
41
36
|
*/
|
|
42
37
|
taskSchedulerComponentType?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The rights management enforcement component to use for verifying untrusted node access.
|
|
40
|
+
* Only required on a trusted node to enforce access control.
|
|
41
|
+
* @default policy-enforcement-point
|
|
42
|
+
*/
|
|
43
|
+
policyEnforcementPointComponentType?: string;
|
|
43
44
|
/**
|
|
44
45
|
* The synchronised entity storage component type to use if this node is not trusted.
|
|
45
46
|
* If this is set, this node uses it as the trusted node to store changesets.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IHttpRequestContext, INoContentResponse, IRestRoute, ITag } from "@twin.org/api-models";
|
|
2
|
-
import type
|
|
2
|
+
import { type ISyncChangeSetRequest, type ISyncDecryptionKeyRequest, type ISyncDecryptionKeyResponse } from "@twin.org/synchronised-storage-models";
|
|
3
3
|
/**
|
|
4
4
|
* The tag to associate with the routes.
|
|
5
5
|
*/
|
|
@@ -1,51 +1,48 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type ISyncChangeSet, type
|
|
3
|
-
import type { ISynchronisedStorageServiceConstructorOptions } from "./models/ISynchronisedStorageServiceConstructorOptions";
|
|
1
|
+
import { type IIdentityAuthenticationActionRequest } from "@twin.org/identity-authentication";
|
|
2
|
+
import { type ISyncChangeSet, type ISynchronisedStorageComponent } from "@twin.org/synchronised-storage-models";
|
|
3
|
+
import type { ISynchronisedStorageServiceConstructorOptions } from "./models/ISynchronisedStorageServiceConstructorOptions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class for performing synchronised storage operations.
|
|
6
6
|
*/
|
|
7
|
-
export declare class SynchronisedStorageService
|
|
7
|
+
export declare class SynchronisedStorageService implements ISynchronisedStorageComponent {
|
|
8
8
|
/**
|
|
9
9
|
* Runtime name for the class.
|
|
10
10
|
*/
|
|
11
|
-
readonly CLASS_NAME: string;
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
13
|
* Create a new instance of SynchronisedStorageService.
|
|
14
14
|
* @param options The options for the service.
|
|
15
15
|
*/
|
|
16
16
|
constructor(options: ISynchronisedStorageServiceConstructorOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
17
22
|
/**
|
|
18
23
|
* The component needs to be started when the node is initialized.
|
|
19
|
-
* @param
|
|
20
|
-
* @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
|
|
21
|
-
* @param componentState A persistent state which can be modified by the method.
|
|
24
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
22
25
|
* @returns Nothing.
|
|
23
26
|
*/
|
|
24
|
-
start(
|
|
25
|
-
[id: string]: unknown;
|
|
26
|
-
}): Promise<void>;
|
|
27
|
+
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
27
28
|
/**
|
|
28
29
|
* The component needs to be stopped when the node is closed.
|
|
29
|
-
* @param
|
|
30
|
-
* @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
|
|
31
|
-
* @param componentState A persistent state which can be modified by the method.
|
|
30
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
32
31
|
* @returns Nothing.
|
|
33
32
|
*/
|
|
34
|
-
stop(
|
|
35
|
-
[id: string]: unknown;
|
|
36
|
-
}): Promise<void>;
|
|
33
|
+
stop(nodeLoggingComponentType?: string): Promise<void>;
|
|
37
34
|
/**
|
|
38
35
|
* Get the decryption key for the synchronised storage.
|
|
39
36
|
* This is used to decrypt the data stored in the synchronised storage.
|
|
40
|
-
* @param
|
|
41
|
-
* @param proof The proof of the request so we know the request is from the specified node.
|
|
37
|
+
* @param actionRequest The action request used in the verifiable credential.
|
|
42
38
|
* @returns The decryption key.
|
|
43
39
|
*/
|
|
44
|
-
getDecryptionKey(
|
|
40
|
+
getDecryptionKey(actionRequest: IIdentityAuthenticationActionRequest): Promise<string>;
|
|
45
41
|
/**
|
|
46
42
|
* Synchronise a set of changes from an untrusted node, assumes this is a trusted node.
|
|
47
43
|
* @param syncChangeSet The change set to synchronise.
|
|
44
|
+
* @param actionRequest The action request used in the verifiable credential.
|
|
48
45
|
* @returns Nothing.
|
|
49
46
|
*/
|
|
50
|
-
syncChangeSet(syncChangeSet: ISyncChangeSet
|
|
47
|
+
syncChangeSet(syncChangeSet: ISyncChangeSet, actionRequest: IIdentityAuthenticationActionRequest): Promise<void>;
|
|
51
48
|
}
|