@twin.org/node-core 0.0.2-next.9 → 0.0.3-next.2
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/README.md +1 -1
- package/dist/es/bootstrap.js +374 -0
- package/dist/es/bootstrap.js.map +1 -0
- package/dist/es/builders/engineEnvBuilder.js +1051 -0
- package/dist/es/builders/engineEnvBuilder.js.map +1 -0
- package/dist/es/builders/engineServerEnvBuilder.js +197 -0
- package/dist/es/builders/engineServerEnvBuilder.js.map +1 -0
- package/dist/es/builders/extensionsBuilder.js +109 -0
- package/dist/es/builders/extensionsBuilder.js.map +1 -0
- package/dist/es/defaults.js +9 -0
- package/dist/es/defaults.js.map +1 -0
- package/dist/es/identity.js +169 -0
- package/dist/es/identity.js.map +1 -0
- package/dist/es/index.js +23 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/ICacheMetadata.js +4 -0
- package/dist/es/models/ICacheMetadata.js.map +1 -0
- package/dist/es/models/IEngineEnvironmentVariables.js +4 -0
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -0
- package/dist/es/models/IEngineServerEnvironmentVariables.js +2 -0
- package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -0
- package/dist/es/models/IModuleProtocol.js +2 -0
- package/dist/es/models/IModuleProtocol.js.map +1 -0
- package/dist/es/models/INodeEngineConfig.js +2 -0
- package/dist/es/models/INodeEngineConfig.js.map +1 -0
- package/dist/es/models/INodeEngineState.js +2 -0
- package/dist/es/models/INodeEngineState.js.map +1 -0
- package/dist/es/models/INodeEnvironmentVariables.js +2 -0
- package/dist/es/models/INodeEnvironmentVariables.js.map +1 -0
- package/dist/es/models/INodeOptions.js +2 -0
- package/dist/es/models/INodeOptions.js.map +1 -0
- package/dist/es/models/IProtocolHandlerResult.js +4 -0
- package/dist/es/models/IProtocolHandlerResult.js.map +1 -0
- package/dist/es/models/moduleProtocol.js +29 -0
- package/dist/es/models/moduleProtocol.js.map +1 -0
- package/dist/es/models/nodeExtensionMethods.js +2 -0
- package/dist/es/models/nodeExtensionMethods.js.map +1 -0
- package/dist/es/models/nodeFeatures.js +21 -0
- package/dist/es/models/nodeFeatures.js.map +1 -0
- package/dist/es/node.js +265 -0
- package/dist/es/node.js.map +1 -0
- package/dist/es/server.js +78 -0
- package/dist/es/server.js.map +1 -0
- package/dist/es/utils.js +418 -0
- package/dist/es/utils.js.map +1 -0
- package/dist/types/bootstrap.d.ts +27 -10
- package/dist/types/builders/engineEnvBuilder.d.ts +3 -2
- package/dist/types/builders/engineServerEnvBuilder.d.ts +4 -3
- package/dist/types/builders/extensionsBuilder.d.ts +32 -0
- package/dist/types/defaults.d.ts +6 -0
- package/dist/types/identity.d.ts +14 -0
- package/dist/types/index.d.ts +20 -11
- package/dist/types/models/ICacheMetadata.d.ts +17 -0
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +132 -24
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +12 -3
- package/dist/types/models/IModuleProtocol.d.ts +18 -0
- package/dist/types/models/INodeEngineConfig.d.ts +6 -0
- package/dist/types/models/INodeEngineState.d.ts +22 -0
- package/dist/types/models/INodeEnvironmentVariables.d.ts +50 -10
- package/dist/types/models/INodeOptions.d.ts +14 -3
- package/dist/types/models/IProtocolHandlerResult.d.ts +13 -0
- package/dist/types/models/moduleProtocol.d.ts +29 -0
- package/dist/types/models/nodeExtensionMethods.d.ts +27 -0
- package/dist/types/models/nodeFeatures.d.ts +5 -5
- package/dist/types/node.d.ts +17 -7
- package/dist/types/server.d.ts +9 -6
- package/dist/types/utils.d.ts +87 -2
- package/docs/changelog.md +185 -0
- package/docs/detailed-guide.md +129 -0
- package/docs/reference/functions/bootstrap.md +1 -1
- package/docs/reference/functions/bootstrapAuth.md +1 -1
- package/docs/reference/functions/bootstrapBlobEncryption.md +1 -1
- package/docs/reference/functions/bootstrapContextIdHandlers.md +35 -0
- package/docs/reference/functions/bootstrapImmutableProofMethod.md +1 -1
- package/docs/reference/functions/{bootstrapNodeUser.md → bootstrapNodeAdminUser.md} +3 -3
- package/docs/reference/functions/{bootstrapNodeIdentity.md → bootstrapNodeId.md} +3 -3
- package/docs/reference/functions/bootstrapSynchronisedStorage.md +1 -1
- package/docs/reference/functions/bootstrapTenantId.md +35 -0
- package/docs/reference/functions/buildConfiguration.md +2 -2
- package/docs/reference/functions/buildEngineConfiguration.md +8 -2
- package/docs/reference/functions/buildEngineServerConfiguration.md +9 -3
- package/docs/reference/functions/createModuleImportUrl.md +21 -0
- package/docs/reference/functions/directoryExists.md +19 -0
- package/docs/reference/functions/extensionsConfiguration.md +25 -0
- package/docs/reference/functions/extensionsInitialiseEngine.md +25 -0
- package/docs/reference/functions/extensionsInitialiseEngineServer.md +31 -0
- package/docs/reference/functions/getExtensionsCacheDir.md +31 -0
- package/docs/reference/functions/getFiles.md +19 -0
- package/docs/reference/functions/getSubFolders.md +19 -0
- package/docs/reference/functions/handleHttpsProtocol.md +49 -0
- package/docs/reference/functions/handleNpmProtocol.md +31 -0
- package/docs/reference/functions/hashUrl.md +19 -0
- package/docs/reference/functions/isCacheExpired.md +31 -0
- package/docs/reference/functions/overrideModuleImport.md +8 -2
- package/docs/reference/functions/parseModuleProtocol.md +19 -0
- package/docs/reference/functions/resolvePackageEntryPoint.md +32 -0
- package/docs/reference/functions/run.md +3 -3
- package/docs/reference/functions/shutdownExtensions.md +25 -0
- package/docs/reference/functions/start.md +11 -5
- package/docs/reference/index.md +36 -2
- package/docs/reference/interfaces/ICacheMetadata.md +27 -0
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +255 -37
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +1696 -5
- package/docs/reference/interfaces/IModuleProtocol.md +27 -0
- package/docs/reference/interfaces/INodeEngineConfig.md +7 -0
- package/docs/reference/interfaces/INodeEngineState.md +39 -0
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +609 -165
- package/docs/reference/interfaces/INodeOptions.md +27 -3
- package/docs/reference/interfaces/IProtocolHandlerResult.md +19 -0
- package/docs/reference/type-aliases/ModuleProtocol.md +5 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineMethod.md +18 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineServerMethod.md +24 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +23 -0
- package/docs/reference/type-aliases/NodeExtensionShutdownMethod.md +10 -0
- package/docs/reference/variables/ATTESTATION_VERIFICATION_METHOD_ID.md +3 -0
- package/docs/reference/variables/AUTH_SIGNING_KEY_ID.md +3 -0
- package/docs/reference/variables/BLOB_STORAGE_ENCRYPTION_KEY_ID.md +3 -0
- package/docs/reference/variables/IMMUTABLE_PROOF_VERIFICATION_METHOD_ID.md +3 -0
- package/docs/reference/variables/ModuleProtocol.md +37 -0
- package/docs/reference/variables/NodeFeatures.md +7 -7
- package/docs/reference/variables/SYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID.md +3 -0
- package/docs/reference/variables/VC_AUTHENTICATION_VERIFICATION_METHOD_ID.md +3 -0
- package/locales/en.json +27 -9
- package/package.json +27 -9
- package/dist/cjs/index.cjs +0 -1910
- package/dist/esm/index.mjs +0 -1870
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { Converter, I18n, Is, RandomHelper, Urn } from "@twin.org/core";
|
|
4
|
+
import { Bip39 } from "@twin.org/crypto";
|
|
5
|
+
import { IdentityConnectorType, WalletConnectorType } from "@twin.org/engine-types";
|
|
6
|
+
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
7
|
+
import { IdentityConnectorFactory, IdentityResolverConnectorFactory } from "@twin.org/identity-models";
|
|
8
|
+
import { VaultConnectorFactory } from "@twin.org/vault-models";
|
|
9
|
+
import { WalletConnectorFactory } from "@twin.org/wallet-models";
|
|
10
|
+
/**
|
|
11
|
+
* Generate an identity and fund it.
|
|
12
|
+
* @param engineCore The engine core for the node.
|
|
13
|
+
* @param envVars The environment variables for the node.
|
|
14
|
+
* @param configIdentity A identity from config to use.
|
|
15
|
+
* @param configMnemonic A mnemonic from config to use.
|
|
16
|
+
* @param controller The controller for the identity.
|
|
17
|
+
* @param identityType The type of identity.
|
|
18
|
+
* @param addWallet Whether to add a wallet for the identity.
|
|
19
|
+
* @returns The identity that was generated.
|
|
20
|
+
*/
|
|
21
|
+
export async function createIdentity(engineCore, envVars, configIdentity, configMnemonic, controller, identityType, addWallet) {
|
|
22
|
+
engineCore.logInfo(I18n.formatMessage("node.processingIdentity", { identityType }));
|
|
23
|
+
// We have a chicken and egg problem in that we can't create the identity
|
|
24
|
+
// to store the mnemonic in the vault without an identity. We use a temporary identity
|
|
25
|
+
// and then replace it with the new identity later in the process.
|
|
26
|
+
const defaultVaultConnectorType = engineCore.getRegisteredInstanceType("vaultConnector");
|
|
27
|
+
const vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);
|
|
28
|
+
const workingIdentity = configIdentity ?? `bootstrap-temp-${Converter.bytesToHex(RandomHelper.generate(16))}`;
|
|
29
|
+
const workingController = controller ?? workingIdentity;
|
|
30
|
+
await bootstrapMnemonic(engineCore, vaultConnector, workingIdentity, configMnemonic);
|
|
31
|
+
const addresses = addWallet ? await generateWallet(engineCore, envVars, workingIdentity) : [];
|
|
32
|
+
const finalIdentity = await generateIdentity(engineCore, envVars, workingController, workingIdentity, identityType);
|
|
33
|
+
await finaliseWallet(engineCore, envVars, finalIdentity, addresses);
|
|
34
|
+
await finaliseMnemonic(vaultConnector, workingIdentity, finalIdentity);
|
|
35
|
+
return finalIdentity;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate a mnemonic for the node identity.
|
|
39
|
+
* @param engineCore The engine core for the node.
|
|
40
|
+
* @param vaultConnector The vault connector to use.
|
|
41
|
+
* @param identity The identity of the node.
|
|
42
|
+
* @param existingMnemonic An existing mnemonic to use.
|
|
43
|
+
*/
|
|
44
|
+
async function bootstrapMnemonic(engineCore, vaultConnector, identity, existingMnemonic) {
|
|
45
|
+
let mnemonic = existingMnemonic;
|
|
46
|
+
let storeMnemonic = false;
|
|
47
|
+
try {
|
|
48
|
+
const storedMnemonic = await vaultConnector.getSecret(`${identity}/mnemonic`);
|
|
49
|
+
storeMnemonic = storedMnemonic !== mnemonic;
|
|
50
|
+
mnemonic = storedMnemonic;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
storeMnemonic = true;
|
|
54
|
+
}
|
|
55
|
+
// If there is no mnemonic then we need to generate one
|
|
56
|
+
if (Is.empty(mnemonic)) {
|
|
57
|
+
mnemonic = Bip39.randomMnemonic();
|
|
58
|
+
storeMnemonic = true;
|
|
59
|
+
engineCore.logInfo(I18n.formatMessage("node.generatingMnemonic", { mnemonic }));
|
|
60
|
+
}
|
|
61
|
+
// If there is no mnemonic stored in the vault then we need to store it
|
|
62
|
+
if (storeMnemonic) {
|
|
63
|
+
engineCore.logInfo(I18n.formatMessage("node.storingMnemonic"));
|
|
64
|
+
await vaultConnector.setSecret(`${identity}/mnemonic`, mnemonic);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
engineCore.logInfo(I18n.formatMessage("node.existingMnemonic"));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Finalise the mnemonic for the node identity.
|
|
72
|
+
* @param vaultConnector The vault connector to use.
|
|
73
|
+
* @param workingIdentity The identity of the node.
|
|
74
|
+
* @param finalIdentity The final identity for the node.
|
|
75
|
+
*/
|
|
76
|
+
async function finaliseMnemonic(vaultConnector, workingIdentity, finalIdentity) {
|
|
77
|
+
// Now that we have an identity we can remove the temporary one
|
|
78
|
+
// and store the mnemonic with the new identity
|
|
79
|
+
if (workingIdentity.startsWith("bootstrap-temp-") && workingIdentity !== finalIdentity) {
|
|
80
|
+
const mnemonic = await vaultConnector.getSecret(`${workingIdentity}/mnemonic`);
|
|
81
|
+
await vaultConnector.setSecret(`${finalIdentity}/mnemonic`, mnemonic);
|
|
82
|
+
await vaultConnector.removeSecret(`${workingIdentity}/mnemonic`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Bootstrap the identity for the node.
|
|
87
|
+
* @param engineCore The engine core for the node.
|
|
88
|
+
* @param envVars The environment variables for the node.
|
|
89
|
+
* @param finalIdentity The identity of the node.
|
|
90
|
+
* @param addresses The addresses for the wallet.
|
|
91
|
+
*/
|
|
92
|
+
async function finaliseWallet(engineCore, envVars, finalIdentity, addresses) {
|
|
93
|
+
if (Is.arrayValue(addresses)) {
|
|
94
|
+
const defaultWalletConnectorType = engineCore.getRegisteredInstanceType("walletConnector");
|
|
95
|
+
// If we are using entity storage for wallet the identity associated with the
|
|
96
|
+
// address will be wrong, so fix it
|
|
97
|
+
if (defaultWalletConnectorType.startsWith(WalletConnectorType.EntityStorage)) {
|
|
98
|
+
const walletAddress = EntityStorageConnectorFactory.get("wallet-address");
|
|
99
|
+
const addr = await walletAddress.get(addresses[0]);
|
|
100
|
+
if (!Is.empty(addr)) {
|
|
101
|
+
addr.identity = finalIdentity;
|
|
102
|
+
await walletAddress.set(addr);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Bootstrap the wallet for the node.
|
|
109
|
+
* @param engineCore The engine core for the node.
|
|
110
|
+
* @param envVars The environment variables for the node.
|
|
111
|
+
* @param identity The identity to create the wallet for.
|
|
112
|
+
* @returns The addresses for the wallet.
|
|
113
|
+
*/
|
|
114
|
+
async function generateWallet(engineCore, envVars, identity) {
|
|
115
|
+
const defaultWalletConnectorType = engineCore.getRegisteredInstanceType("walletConnector");
|
|
116
|
+
const walletConnector = WalletConnectorFactory.get(defaultWalletConnectorType);
|
|
117
|
+
const addresses = await walletConnector.getAddresses(identity, 0, 0, 5);
|
|
118
|
+
const balance = await walletConnector.getBalance(identity, addresses[0]);
|
|
119
|
+
if (balance === 0n) {
|
|
120
|
+
let address0 = addresses[0];
|
|
121
|
+
if (defaultWalletConnectorType.startsWith(WalletConnectorType.Iota)) {
|
|
122
|
+
address0 = `${envVars.iotaExplorerEndpoint}address/${address0}?network=${envVars.iotaNetwork}`;
|
|
123
|
+
}
|
|
124
|
+
engineCore.logInfo(I18n.formatMessage("node.fundingWallet", { address: address0 }));
|
|
125
|
+
// Add some funds to the wallet from the faucet
|
|
126
|
+
await walletConnector.ensureBalance(identity, addresses[0], 1000000000n);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
engineCore.logInfo(I18n.formatMessage("node.fundedWallet"));
|
|
130
|
+
}
|
|
131
|
+
return addresses;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Bootstrap the identity for the node.
|
|
135
|
+
* @param engineCore The engine core for the node.
|
|
136
|
+
* @param envVars The environment variables for the node.
|
|
137
|
+
* @param controller The controller for the identity.
|
|
138
|
+
* @param identity The existing identity if there is one.
|
|
139
|
+
* @param identityType The type of identity.
|
|
140
|
+
* @returns The addresses for the wallet.
|
|
141
|
+
*/
|
|
142
|
+
async function generateIdentity(engineCore, envVars, controller, identity, identityType) {
|
|
143
|
+
const defaultIdentityConnectorType = engineCore.getRegisteredInstanceType("identityConnector");
|
|
144
|
+
// Now create an identity for the node controlled by the address we just funded
|
|
145
|
+
const identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);
|
|
146
|
+
let identityDocument;
|
|
147
|
+
try {
|
|
148
|
+
const defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType("identityResolverConnector");
|
|
149
|
+
const identityResolverConnector = IdentityResolverConnectorFactory.get(defaultIdentityResolverConnectorType);
|
|
150
|
+
identityDocument = await identityResolverConnector.resolveDocument(identity);
|
|
151
|
+
engineCore.logInfo(I18n.formatMessage("node.existingIdentity", { identity }));
|
|
152
|
+
}
|
|
153
|
+
catch { }
|
|
154
|
+
if (Is.empty(identityDocument)) {
|
|
155
|
+
engineCore.logInfo(I18n.formatMessage("node.generatingIdentity", { identityType }));
|
|
156
|
+
identityDocument = await identityConnector.createDocument(controller);
|
|
157
|
+
engineCore.logInfo(I18n.formatMessage("node.createdIdentity", { identity: identityDocument.id }));
|
|
158
|
+
}
|
|
159
|
+
if (defaultIdentityConnectorType.startsWith(IdentityConnectorType.Iota)) {
|
|
160
|
+
const didUrn = Urn.fromValidString(identityDocument.id);
|
|
161
|
+
const didParts = didUrn.parts();
|
|
162
|
+
const objectId = didParts[3];
|
|
163
|
+
engineCore.logInfo(I18n.formatMessage("node.identityExplorer", {
|
|
164
|
+
url: `${envVars.iotaExplorerEndpoint}object/${objectId}?network=${envVars.iotaNetwork}`
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
return identityDocument.id;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAwB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAGjE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,UAAuB,EACvB,OAAkC,EAClC,cAAkC,EAClC,cAAkC,EACl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E,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC/E,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,IAAI,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAChC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,yBAAyB,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;QAEpF,gBAAgB,GAAG,MAAM,iBAAiB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAEtE,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,sBAAsB,EAAE,EAAE,QAAQ,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAC7E,CAAC;IACH,CAAC;IAED,IAAI,4BAA4B,CAAC,UAAU,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;QACzE,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE7B,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,uBAAuB,EAAE;YAC3C,GAAG,EAAE,GAAG,OAAO,CAAC,oBAAoB,UAAU,QAAQ,YAAY,OAAO,CAAC,WAAW,EAAE;SACvF,CAAC,CACF,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, I18n, Is, RandomHelper, Urn } from \"@twin.org/core\";\nimport { Bip39 } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { IdentityConnectorType, WalletConnectorType } from \"@twin.org/engine-types\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tIdentityConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport { type IVaultConnector, VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport type { WalletAddress } from \"@twin.org/wallet-connector-entity-storage\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\n\n/**\n * Generate an identity and fund it.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param configIdentity A identity from config to use.\n * @param configMnemonic A mnemonic from config to use.\n * @param controller The controller for the identity.\n * @param identityType The type of identity.\n * @param addWallet Whether to add a wallet for the identity.\n * @returns The identity that was generated.\n */\nexport async function createIdentity(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tconfigIdentity: string | undefined,\n\tconfigMnemonic: string | undefined,\n\tcontroller: string | undefined,\n\tidentityType: \"node\" | \"organization\" | \"user\",\n\taddWallet: boolean\n): Promise<string> {\n\tengineCore.logInfo(I18n.formatMessage(\"node.processingIdentity\", { identityType }));\n\n\t// We have a chicken and egg problem in that we can't create the identity\n\t// to store the mnemonic in the vault without an identity. We use a temporary identity\n\t// and then replace it with the new identity later in the process.\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tconst workingIdentity =\n\t\tconfigIdentity ?? `bootstrap-temp-${Converter.bytesToHex(RandomHelper.generate(16))}`;\n\tconst workingController = controller ?? workingIdentity;\n\n\tawait bootstrapMnemonic(engineCore, vaultConnector, workingIdentity, configMnemonic);\n\n\tconst addresses = addWallet ? await generateWallet(engineCore, envVars, workingIdentity) : [];\n\n\tconst finalIdentity = await generateIdentity(\n\t\tengineCore,\n\t\tenvVars,\n\t\tworkingController,\n\t\tworkingIdentity,\n\t\tidentityType\n\t);\n\n\tawait finaliseWallet(engineCore, envVars, finalIdentity, addresses);\n\n\tawait finaliseMnemonic(vaultConnector, workingIdentity, finalIdentity);\n\n\treturn finalIdentity;\n}\n\n/**\n * Generate a mnemonic for the node identity.\n * @param engineCore The engine core for the node.\n * @param vaultConnector The vault connector to use.\n * @param identity The identity of the node.\n * @param existingMnemonic An existing mnemonic to use.\n */\nasync function bootstrapMnemonic(\n\tengineCore: IEngineCore,\n\tvaultConnector: IVaultConnector,\n\tidentity: string,\n\texistingMnemonic?: string\n): Promise<void> {\n\tlet mnemonic = existingMnemonic;\n\tlet storeMnemonic = false;\n\n\ttry {\n\t\tconst storedMnemonic = await vaultConnector.getSecret<string>(`${identity}/mnemonic`);\n\t\tstoreMnemonic = storedMnemonic !== mnemonic;\n\t\tmnemonic = storedMnemonic;\n\t} catch {\n\t\tstoreMnemonic = true;\n\t}\n\n\t// If there is no mnemonic then we need to generate one\n\tif (Is.empty(mnemonic)) {\n\t\tmnemonic = Bip39.randomMnemonic();\n\t\tstoreMnemonic = true;\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.generatingMnemonic\", { mnemonic }));\n\t}\n\n\t// If there is no mnemonic stored in the vault then we need to store it\n\tif (storeMnemonic) {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.storingMnemonic\"));\n\t\tawait vaultConnector.setSecret(`${identity}/mnemonic`, mnemonic);\n\t} else {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingMnemonic\"));\n\t}\n}\n\n/**\n * Finalise the mnemonic for the node identity.\n * @param vaultConnector The vault connector to use.\n * @param workingIdentity The identity of the node.\n * @param finalIdentity The final identity for the node.\n */\nasync function finaliseMnemonic(\n\tvaultConnector: IVaultConnector,\n\tworkingIdentity: string,\n\tfinalIdentity: string\n): Promise<void> {\n\t// Now that we have an identity we can remove the temporary one\n\t// and store the mnemonic with the new identity\n\tif (workingIdentity.startsWith(\"bootstrap-temp-\") && workingIdentity !== finalIdentity) {\n\t\tconst mnemonic = await vaultConnector.getSecret(`${workingIdentity}/mnemonic`);\n\t\tawait vaultConnector.setSecret(`${finalIdentity}/mnemonic`, mnemonic);\n\t\tawait vaultConnector.removeSecret(`${workingIdentity}/mnemonic`);\n\t}\n}\n\n/**\n * Bootstrap the identity for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param finalIdentity The identity of the node.\n * @param addresses The addresses for the wallet.\n */\nasync function finaliseWallet(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tfinalIdentity: string,\n\taddresses: string[]\n): Promise<void> {\n\tif (Is.arrayValue(addresses)) {\n\t\tconst defaultWalletConnectorType = engineCore.getRegisteredInstanceType(\"walletConnector\");\n\n\t\t// If we are using entity storage for wallet the identity associated with the\n\t\t// address will be wrong, so fix it\n\t\tif (defaultWalletConnectorType.startsWith(WalletConnectorType.EntityStorage)) {\n\t\t\tconst walletAddress =\n\t\t\t\tEntityStorageConnectorFactory.get<IEntityStorageConnector<WalletAddress>>(\n\t\t\t\t\tnameofKebabCase<WalletAddress>()\n\t\t\t\t);\n\t\t\tconst addr = await walletAddress.get(addresses[0]);\n\t\t\tif (!Is.empty(addr)) {\n\t\t\t\taddr.identity = finalIdentity;\n\t\t\t\tawait walletAddress.set(addr);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the wallet for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param identity The identity to create the wallet for.\n * @returns The addresses for the wallet.\n */\nasync function generateWallet(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tidentity: string\n): Promise<string[]> {\n\tconst defaultWalletConnectorType = engineCore.getRegisteredInstanceType(\"walletConnector\");\n\n\tconst walletConnector = WalletConnectorFactory.get(defaultWalletConnectorType);\n\tconst addresses = await walletConnector.getAddresses(identity, 0, 0, 5);\n\n\tconst balance = await walletConnector.getBalance(identity, addresses[0]);\n\tif (balance === 0n) {\n\t\tlet address0 = addresses[0];\n\n\t\tif (defaultWalletConnectorType.startsWith(WalletConnectorType.Iota)) {\n\t\t\taddress0 = `${envVars.iotaExplorerEndpoint}address/${address0}?network=${envVars.iotaNetwork}`;\n\t\t}\n\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.fundingWallet\", { address: address0 }));\n\n\t\t// Add some funds to the wallet from the faucet\n\t\tawait walletConnector.ensureBalance(identity, addresses[0], 1000000000n);\n\t} else {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.fundedWallet\"));\n\t}\n\treturn addresses;\n}\n\n/**\n * Bootstrap the identity for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param controller The controller for the identity.\n * @param identity The existing identity if there is one.\n * @param identityType The type of identity.\n * @returns The addresses for the wallet.\n */\nasync function generateIdentity(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tcontroller: string,\n\tidentity: string,\n\tidentityType: \"node\" | \"organization\" | \"user\"\n): Promise<string> {\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\n\t// Now create an identity for the node controlled by the address we just funded\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tlet identityDocument;\n\n\ttry {\n\t\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\t\"identityResolverConnector\"\n\t\t);\n\n\t\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\t\tdefaultIdentityResolverConnectorType\n\t\t);\n\t\tidentityDocument = await identityResolverConnector.resolveDocument(identity);\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingIdentity\", { identity }));\n\t} catch {}\n\n\tif (Is.empty(identityDocument)) {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.generatingIdentity\", { identityType }));\n\n\t\tidentityDocument = await identityConnector.createDocument(controller);\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.createdIdentity\", { identity: identityDocument.id })\n\t\t);\n\t}\n\n\tif (defaultIdentityConnectorType.startsWith(IdentityConnectorType.Iota)) {\n\t\tconst didUrn = Urn.fromValidString(identityDocument.id);\n\t\tconst didParts = didUrn.parts();\n\t\tconst objectId = didParts[3];\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.identityExplorer\", {\n\t\t\t\turl: `${envVars.iotaExplorerEndpoint}object/${objectId}?network=${envVars.iotaNetwork}`\n\t\t\t})\n\t\t);\n\t}\n\treturn identityDocument.id;\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./bootstrap.js";
|
|
4
|
+
export * from "./builders/engineEnvBuilder.js";
|
|
5
|
+
export * from "./builders/engineServerEnvBuilder.js";
|
|
6
|
+
export * from "./builders/extensionsBuilder.js";
|
|
7
|
+
export * from "./defaults.js";
|
|
8
|
+
export * from "./models/ICacheMetadata.js";
|
|
9
|
+
export * from "./models/IEngineEnvironmentVariables.js";
|
|
10
|
+
export * from "./models/IEngineServerEnvironmentVariables.js";
|
|
11
|
+
export * from "./models/IModuleProtocol.js";
|
|
12
|
+
export * from "./models/INodeEngineConfig.js";
|
|
13
|
+
export * from "./models/INodeEngineState.js";
|
|
14
|
+
export * from "./models/INodeEnvironmentVariables.js";
|
|
15
|
+
export * from "./models/INodeOptions.js";
|
|
16
|
+
export * from "./models/IProtocolHandlerResult.js";
|
|
17
|
+
export * from "./models/moduleProtocol.js";
|
|
18
|
+
export * from "./models/nodeExtensionMethods.js";
|
|
19
|
+
export * from "./models/nodeFeatures.js";
|
|
20
|
+
export * from "./node.js";
|
|
21
|
+
export * from "./server.js";
|
|
22
|
+
export * from "./utils.js";
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./bootstrap.js\";\nexport * from \"./builders/engineEnvBuilder.js\";\nexport * from \"./builders/engineServerEnvBuilder.js\";\nexport * from \"./builders/extensionsBuilder.js\";\nexport * from \"./defaults.js\";\nexport * from \"./models/ICacheMetadata.js\";\nexport * from \"./models/IEngineEnvironmentVariables.js\";\nexport * from \"./models/IEngineServerEnvironmentVariables.js\";\nexport * from \"./models/IModuleProtocol.js\";\nexport * from \"./models/INodeEngineConfig.js\";\nexport * from \"./models/INodeEngineState.js\";\nexport * from \"./models/INodeEnvironmentVariables.js\";\nexport * from \"./models/INodeOptions.js\";\nexport * from \"./models/IProtocolHandlerResult.js\";\nexport * from \"./models/moduleProtocol.js\";\nexport * from \"./models/nodeExtensionMethods.js\";\nexport * from \"./models/nodeFeatures.js\";\nexport * from \"./node.js\";\nexport * from \"./server.js\";\nexport * from \"./utils.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICacheMetadata.js","sourceRoot":"","sources":["../../../src/models/ICacheMetadata.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Metadata for cached HTTPS extensions.\n */\nexport interface ICacheMetadata {\n\t/**\n\t * Timestamp when the file was downloaded.\n\t */\n\tdownloadedAt: number;\n\n\t/**\n\t * Original URL of the cached file.\n\t */\n\turl: string;\n\n\t/**\n\t * Size of the cached file in bytes.\n\t */\n\tsize: number;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEngineEnvironmentVariables.js","sourceRoot":"","sources":["../../../src/models/IEngineEnvironmentVariables.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The engine core environment variables.\n */\nexport interface IEngineEnvironmentVariables {\n\t/**\n\t * Start the engine in debug mode.\n\t */\n\tdebug?: string;\n\n\t/**\n\t * The root directory for storing items like state file.\n\t */\n\tstorageFileRoot?: string;\n\n\t/**\n\t * The name of the state file.\n\t */\n\tstateFilename?: string;\n\n\t/**\n\t * Is multi-tenant support enabled, defaults to false.\n\t */\n\ttenantEnabled?: string;\n\n\t/**\n\t * A tenant id to use as a default for the node.\n\t */\n\ttenantId?: string;\n\n\t/**\n\t * A tenant api key to use as a default for the node.\n\t */\n\ttenantApiKey?: string;\n\n\t/**\n\t * The type of the entity storage to create, comma separate for more than one connector.\n\t * values: file, memory, aws-dynamodb, azure-cosmosdb, gcp-firestoredb, scylladb, mysql, mongodb, postgresql\n\t */\n\tentityStorageConnectorType?: string;\n\n\t/**\n\t * The default entity storage connector to use, defaults to the first one in the list.\n\t */\n\tentityStorageConnectorDefault?: string;\n\n\t/**\n\t * A prefix for all the table in entity-storage, can be empty.\n\t */\n\tentityStorageTablePrefix?: string;\n\n\t/**\n\t * AWS DynamoDB auth mode, either credentials or pod.\n\t */\n\tawsDynamodbAuthMode?: string;\n\n\t/**\n\t * AWS Dynamo DB access key id.\n\t */\n\tawsDynamodbAccessKeyId?: string;\n\n\t/**\n\t * AWS Dynamo DB Endpoint if running local instance.\n\t */\n\tawsDynamodbEndpoint?: string;\n\n\t/**\n\t * AWS Dynamo DB region.\n\t */\n\tawsDynamodbRegion?: string;\n\n\t/**\n\t * AWS Dynamo DB secret access key.\n\t */\n\tawsDynamodbSecretAccessKey?: string;\n\n\t/**\n\t * Azure Cosmos DB key.\n\t */\n\tazureCosmosdbKey?: string;\n\n\t/**\n\t * Azure Cosmos DB container id.\n\t */\n\tazureCosmosdbContainerId?: string;\n\n\t/**\n\t * Azure Cosmos DB database id.\n\t */\n\tazureCosmosdbDatabaseId?: string;\n\n\t/**\n\t * Azure Cosmos DB endpoint.\n\t */\n\tazureCosmosdbEndpoint?: string;\n\n\t/**\n\t * GCP Firestore collection name.\n\t */\n\tgcpFirestoreCollectionName?: string;\n\n\t/**\n\t * GCP Firestore credentials.\n\t */\n\tgcpFirestoreCredentials?: string;\n\n\t/**\n\t * GCP Firestore database id.\n\t */\n\tgcpFirestoreDatabaseId?: string;\n\n\t/**\n\t * GCP Firestore endpoint.\n\t */\n\tgcpFirestoreApiEndpoint?: string;\n\n\t/**\n\t * GCP Firestore project id.\n\t */\n\tgcpFirestoreProjectId?: string;\n\n\t/**\n\t * ScyllaDB hosts as comma separated string.\n\t */\n\tscylladbHosts?: string;\n\n\t/**\n\t * ScyllaDB keyspace.\n\t */\n\tscylladbKeyspace?: string;\n\n\t/**\n\t * ScyllaDB local data center.\n\t */\n\tscylladbLocalDataCenter?: string;\n\n\t/**\n\t * ScyllaDB port.\n\t */\n\tscylladbPort?: string;\n\n\t/**\n\t * MySQL host.\n\t */\n\tmySqlHost?: string;\n\n\t/**\n\t * MySQL port.\n\t */\n\tmySqlPort?: number;\n\n\t/**\n\t * MySQL username.\n\t */\n\tmySqlUser?: string;\n\n\t/**\n\t * MySQL password.\n\t */\n\tmySqlPassword?: string;\n\n\t/**\n\t * MySQL Database.\n\t */\n\tmySqlDatabase?: string;\n\n\t/**\n\t * MongoDB host.\n\t */\n\tmongoDbHost?: string;\n\n\t/**\n\t * MongoDB port.\n\t */\n\tmongoDbPort?: number;\n\n\t/**\n\t * MongoDB username.\n\t */\n\tmongoDbUser?: string;\n\n\t/**\n\t * MongoDB password.\n\t */\n\tmongoDbPassword?: string;\n\n\t/**\n\t * MongoDB Database.\n\t */\n\tmongoDbDatabase?: string;\n\n\t/**\n\t * PostgreSQl host.\n\t */\n\tpostgreSqlHost?: string;\n\n\t/**\n\t * PostgreSQl port.\n\t */\n\tpostgreSqlPort?: number;\n\n\t/**\n\t * PostgreSQl username.\n\t */\n\tpostgreSqlUser?: string;\n\n\t/**\n\t * PostgreSQl password.\n\t */\n\tpostgreSqlPassword?: string;\n\n\t/**\n\t * PostgreSQl Database.\n\t */\n\tpostgreSqlDatabase?: string;\n\n\t/**\n\t * The security token for accessing IPFS API.\n\t */\n\tipfsBearerToken?: string;\n\n\t/**\n\t * The url for accessing IPFS API.\n\t */\n\tipfsApiUrl?: string;\n\n\t/**\n\t * The type of the entity storage to create, comma separate for more than one connector.\n\t * values: memory, file, ipfs, aws-s3, azure-storage, gcp-storage.\n\t */\n\tblobStorageConnectorType?: string;\n\n\t/**\n\t * The default blob storage connector to use, defaults to the first one in the list.\n\t */\n\tblobStorageConnectorDefault?: string;\n\n\t/**\n\t * Blog storage connector which has public access.\n\t */\n\tblobStorageConnectorPublic?: string;\n\n\t/**\n\t * Enable encryption for the blob storage.\n\t */\n\tblobStorageEnableEncryption?: string;\n\n\t/**\n\t * The id of the encryption key for the blob storage.\n\t */\n\tblobStorageEncryptionKeyId?: string;\n\n\t/**\n\t * A symmetric encryption key for the blob storage, should be ChaCha20Poly1305 in base64 format.\n\t * If encryption is enabled but a key is not provided one will be generated.\n\t */\n\tblobStorageSymmetricEncryptionKey?: string;\n\n\t/**\n\t * A prefix for all the blobs in blob-storage, can be empty.\n\t */\n\tblobStoragePrefix?: string;\n\n\t/**\n\t * AWS S3 region.\n\t */\n\tawsS3Region?: string;\n\n\t/**\n\t * AWS S3 bucket name.\n\t */\n\tawsS3BucketName?: string;\n\n\t/**\n\t * AWS S3 auth mode, either credentials or pod, defaults to credentials.\n\t */\n\tawsS3AuthMode?: string;\n\n\t/**\n\t * AWS S3 access key id.\n\t */\n\tawsS3AccessKeyId?: string;\n\n\t/**\n\t * AWS S3 secret access key.\n\t */\n\tawsS3SecretAccessKey?: string;\n\n\t/**\n\t * AWS S3 endpoint.\n\t */\n\tawsS3Endpoint?: string;\n\n\t/**\n\t * Azure Storage account key.\n\t */\n\tazureStorageAccountKey?: string;\n\n\t/**\n\t * Azure Storage account name.\n\t */\n\tazureStorageAccountName?: string;\n\n\t/**\n\t * Azure Storage container.\n\t */\n\tazureStorageContainerName?: string;\n\n\t/**\n\t * Azure Storage endpoint.\n\t */\n\tazureStorageEndpoint?: string;\n\n\t/**\n\t * GCP Storage bucket.\n\t */\n\tgcpStorageBucketName?: string;\n\n\t/**\n\t * GCP Storage credentials.\n\t */\n\tgcpStorageCredentials?: string;\n\n\t/**\n\t * GCP Storage endpoint.\n\t */\n\tgcpStorageEndpoint?: string;\n\n\t/**\n\t * GCP Storage project id.\n\t */\n\tgcpStorageProjectId?: string;\n\n\t/**\n\t * The type of the default vault connector: entity-storage, hashicorp.\n\t */\n\tvaultConnector?: string;\n\n\t/**\n\t * Hashicorp Vault token.\n\t */\n\thashicorpVaultToken?: string;\n\n\t/**\n\t * Hashicorp Vault endpoint.\n\t */\n\thashicorpVaultEndpoint?: string;\n\n\t/**\n\t * The type of logging task connector, can be a comma separated list: console, entity-storage.\n\t */\n\tloggingConnector?: string;\n\n\t/**\n\t * The type of background task connector: entity-storage.\n\t */\n\tbackgroundTaskConnector?: string;\n\n\t/**\n\t * The type of event bus connector: local.\n\t */\n\teventBusConnector?: string;\n\n\t/**\n\t * The type of event bus component: service.\n\t */\n\teventBusComponent?: string;\n\n\t/**\n\t * Are the messaging components enabled, defaults to false.\n\t */\n\tmessagingEnabled?: string;\n\n\t/**\n\t * AWS SES region.\n\t */\n\tawsSesRegion?: string;\n\n\t/**\n\t * AWS SES auth mode, either credentials or pod, defaults to credentials.\n\t */\n\tawsSesAuthMode?: string;\n\n\t/**\n\t * AWS SES secret access key.\n\t */\n\tawsSesSecretAccessKey?: string;\n\n\t/**\n\t * AWS SES access key id.\n\t */\n\tawsSesAccessKeyId?: string;\n\n\t/**\n\t * AWS SES endpoint.\n\t */\n\tawsSesEndpoint?: string;\n\n\t/**\n\t * The applications for the push notifications JSON stringified array of IAwsApplicationSettings.\n\t */\n\tawsMessagingPushNotificationApplications?: string;\n\n\t/**\n\t * The type of messaging email connector: entity-storage, aws.\n\t */\n\tmessagingEmailConnector?: string;\n\n\t/**\n\t * The type of messaging sms connector: entity-storage, aws.\n\t */\n\tmessagingSmsConnector?: string;\n\n\t/**\n\t * The type of messaging push notification connector: entity-storage, aws.\n\t */\n\tmessagingPushNotificationConnector?: string;\n\n\t/**\n\t * The type of telemetry connector: entity-storage.\n\t */\n\ttelemetryConnector?: string;\n\n\t/**\n\t * The type of faucet connector: entity-storage, iota.\n\t */\n\tfaucetConnector?: string;\n\n\t/**\n\t * The type of wallet connector: entity-storage, iota.\n\t */\n\twalletConnector?: string;\n\n\t/**\n\t * The type of NFT connector: entity-storage, iota.\n\t */\n\tnftConnector?: string;\n\n\t/**\n\t * The type of identity connector: entity-storage, iota.\n\t */\n\tidentityConnector?: string;\n\n\t/**\n\t * The type of identity resolver connector: entity-storage, iota.\n\t */\n\tidentityResolverConnector?: string;\n\n\t/**\n\t * The type of verifiable storage connector: entity-storage, iota.\n\t */\n\tverifiableStorageConnector?: string;\n\n\t/**\n\t * IOTA Faucet Endpoint.\n\t */\n\tiotaFaucetEndpoint?: string;\n\n\t/**\n\t * IOTA Node Endpoint.\n\t */\n\tiotaNodeEndpoint?: string;\n\n\t/**\n\t * IOTA network.\n\t */\n\tiotaNetwork?: string;\n\n\t/**\n\t * IOTA coin type.\n\t */\n\tiotaCoinType?: string;\n\n\t/**\n\t * IOTA Explorer Endpoint.\n\t */\n\tiotaExplorerEndpoint?: string;\n\n\t/**\n\t * IOTA Gas Station Endpoint.\n\t */\n\tiotaGasStationEndpoint?: string;\n\n\t/**\n\t * IOTA Gas Station Authentication Token.\n\t */\n\tiotaGasStationAuthToken?: string;\n\n\t/**\n\t * Universal Resolver Endpoint.\n\t */\n\tuniversalResolverEndpoint?: string;\n\n\t/**\n\t * The type of identity profile connector: entity-storage.\n\t */\n\tidentityProfileConnector?: string;\n\n\t/**\n\t * The identity verification method id to use with immutable proofs.\n\t */\n\timmutableProofVerificationMethodId?: string;\n\n\t/**\n\t * The type of attestation connector: entity-storage, iota.\n\t */\n\tattestationConnector?: string;\n\n\t/**\n\t * The identity verification method id to use with attestation.\n\t */\n\tattestationVerificationMethodId?: string;\n\n\t/**\n\t * Is the data processing enabled, defaults to false.\n\t */\n\tdataProcessingEnabled?: string;\n\n\t/**\n\t * The type of the default data converters, can be a comma separated list: json, xml.\n\t */\n\tdataConverterConnectors?: string;\n\n\t/**\n\t * The type of the default data extractor, can be a comma separated list: json-path.\n\t */\n\tdataExtractorConnectors?: string;\n\n\t/**\n\t * Is the auditable item graph enabled, defaults to false.\n\t */\n\tauditableItemGraphEnabled?: string;\n\n\t/**\n\t * Is the auditable item stream enabled, defaults to false.\n\t */\n\tauditableItemStreamEnabled?: string;\n\n\t/**\n\t * Is the document management enabled, defaults to false.\n\t */\n\tdocumentManagementEnabled?: string;\n\n\t/**\n\t * Is the synchronised storage enabled, defaults to false.\n\t */\n\tsynchronisedStorageEnabled?: string;\n\n\t/**\n\t * Url which points to the api for a trusted synchronised storage node, not required if this is a trusted node.\n\t */\n\tsynchronisedStorageTrustedUrl?: string;\n\n\t/**\n\t * The key for the smart contract which contains the verifiable storage pointer store for synchronised storage.\n\t * This only required if using a custom verifiable storage item, otherwise it will default to the network name.\n\t */\n\tsynchronisedStorageVerifiableStorageKeyId?: string;\n\n\t/**\n\t * The key from the vault which is used to encrypt the synchronised storage blobs.\n\t * Only required for trusted nodes, as regular nodes will request from the trusted nodes.\n\t * Defaults to synchronised-storage-blob-encryption\n\t */\n\tsynchronisedStorageBlobStorageEncryptionKeyId?: string;\n\n\t/**\n\t * The key used for blob encryption, should be ChaCha20Poly1305 encoded as base64.\n\t * Only required for trusted nodes, as regular nodes will not write encrypted data.\n\t */\n\tsynchronisedStorageBlobStorageKey?: string;\n\n\t/**\n\t * How often to check for entity updates in minutes.\n\t * @default 5\n\t */\n\tsynchronisedStorageEntityUpdateIntervalMinutes?: string;\n\n\t/**\n\t * Interval to perform consolidation of changesets, only used if this is a trusted node.\n\t * @default 60\n\t */\n\tsynchronisedStorageConsolidationIntervalMinutes?: string;\n\n\t/**\n\t * The number of entities to process in a single consolidation batch, only used if this is a trusted node.\n\t * @default 1000\n\t */\n\tsynchronisedStorageConsolidationBatchSize?: string;\n\n\t/**\n\t * The maximum number of consolidations to keep in storage, only used if this is a trusted node.\n\t * @default 5\n\t */\n\tsynchronisedStorageMaxConsolidations?: string;\n\n\t/**\n\t * Is the federated catalogue enabled, defaults to false.\n\t */\n\tfederatedCatalogueEnabled?: string;\n\n\t/**\n\t * Federated catalog TTL for the cache.\n\t */\n\tfederatedCatalogueCacheTtlMs?: number;\n\n\t/**\n\t * Federated catalog clearing house approver list, stringified array of DIDs.\n\t */\n\tfederatedCatalogueClearingHouseApproverList?: string;\n\n\t/**\n\t * Is the rights management enabled, defaults to false.\n\t */\n\trightsManagementEnabled?: string;\n\n\t/**\n\t * What is the base callback url for rights management negotiations e.g. https://my-node/rights-management.\n\t */\n\trightsManagementBaseCallbackUrl?: string;\n\n\t/**\n\t * The rights management configuration which includes the information sources modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementInformationSources?: string;\n\n\t/**\n\t * The rights management configuration which includes the negotiator modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementNegotiators?: string;\n\n\t/**\n\t * The rights management configuration which includes the requester modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementRequesters?: string;\n\n\t/**\n\t * The rights management configuration which includes the execution actions modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementExecutionActions?: string;\n\n\t/**\n\t * The rights management configuration which includes the enforcement processor modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementEnforcementProcessors?: string;\n\n\t/**\n\t * The rights management configuration which includes the arbiter modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementArbiters?: string;\n\n\t/**\n\t * The rights management configuration which includes the offer modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementOffers?: string;\n\n\t/**\n\t * Is the task scheduler enabled, defaults to false.\n\t */\n\ttaskSchedulerEnabled?: string;\n\n\t/**\n\t * Is the data space connector enabled, defaults to false.\n\t */\n\tdataSpaceConnectorEnabled?: string;\n\n\t/**\n\t * The length of time to retain the activity logs for in minutes, set to -1 to keep forever.\n\t * @default 10\n\t */\n\tdataSpaceConnectorRetainActivityLogsFor?: string;\n\n\t/**\n\t * The interval for cleaning up the activity logs.\n\t * @default 60\n\t */\n\tdataSpaceConnectorActivityLogsCleanUpInterval?: string;\n\n\t/**\n\t * Enable verifiable credential authentication for the API.\n\t */\n\tvcAuthenticationEnabled?: string;\n\n\t/**\n\t * Verifiable credential assertion for node to node communication.\n\t * Defaults to node-authentication-assertion.\n\t */\n\tvcAuthenticationVerificationMethodId?: string;\n\n\t/**\n\t * A comma separated list of additional node extensions to load, the initialiseExtension method will be called for each extension.\n\t */\n\textensions?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEngineServerEnvironmentVariables.js","sourceRoot":"","sources":["../../../src/models/IEngineServerEnvironmentVariables.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineEnvironmentVariables } from \"./IEngineEnvironmentVariables.js\";\n\n/**\n * The engine server environment variables.\n */\nexport interface IEngineServerEnvironmentVariables extends IEngineEnvironmentVariables {\n\t/**\n\t * The port to serve the API from.\n\t */\n\tport?: string;\n\n\t/**\n\t * The host to serve the API from.\n\t */\n\thost?: string;\n\n\t/**\n\t * The CORS origins to allow, defaults to *.\n\t */\n\tcorsOrigins?: string;\n\n\t/**\n\t * The CORS methods to allow, defaults to GET, POST, PUT, DELETE, OPTIONS.\n\t */\n\thttpMethods?: string;\n\n\t/**\n\t * The CORS headers to allow.\n\t */\n\thttpAllowedHeaders?: string;\n\n\t/**\n\t * The CORS headers to expose.\n\t */\n\thttpExposedHeaders?: string;\n\n\t/**\n\t * The type of auth admin processor to use on the API: entity-storage.\n\t */\n\tauthAdminProcessorType?: string;\n\n\t/**\n\t * The type of auth processor to use on the API: entity-storage.\n\t */\n\tauthProcessorType?: string;\n\n\t/**\n\t * The id of the key in the vault to use for signing in auth operations.\n\t */\n\tauthSigningKeyId?: string;\n\n\t/**\n\t * Additional MIME type processors to include, comma separated.\n\t */\n\tmimeTypeProcessors?: string;\n\n\t/**\n\t * Include the body in the REST logging output, useful for debugging.\n\t */\n\trouteLoggingIncludeBody?: string;\n\n\t/**\n\t * Include the full base 64 output in the REST logging output, useful for debugging.\n\t */\n\trouteLoggingFullBase64?: string;\n\n\t/**\n\t * List of properties to obfuscate in the REST logging output, comma separated.\n\t */\n\trouteLoggingObfuscateProperties?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModuleProtocol.js","sourceRoot":"","sources":["../../../src/models/IModuleProtocol.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ModuleProtocol } from \"./moduleProtocol.js\";\n\n/**\n * The parsed module protocol information.\n */\nexport interface IModuleProtocol {\n\t/**\n\t * The protocol type.\n\t */\n\tprotocol: ModuleProtocol;\n\n\t/**\n\t * The identifier after the protocol (or the original if no protocol).\n\t */\n\tidentifier: string;\n\n\t/**\n\t * The original module string.\n\t */\n\toriginal: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"INodeEngineConfig.js","sourceRoot":"","sources":["../../../src/models/INodeEngineConfig.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\n\n/**\n * The config for the node.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface INodeEngineConfig extends IEngineServerConfig {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"INodeEngineState.js","sourceRoot":"","sources":["../../../src/models/INodeEngineState.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineState } from \"@twin.org/engine-models\";\n\n/**\n * The engine state for the node.\n */\nexport interface INodeEngineState extends IEngineState {\n\t/**\n\t * The identity for the node.\n\t */\n\tnodeId?: string;\n\n\t/**\n\t * The tenant id for the node.\n\t */\n\tnodeTenantId?: string;\n\n\t/**\n\t * The identity for the organization.\n\t */\n\tnodeOrganizationId?: string;\n\n\t/**\n\t * The identity for the admin user.\n\t */\n\tnodeAdminUserId?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"INodeEnvironmentVariables.js","sourceRoot":"","sources":["../../../src/models/INodeEnvironmentVariables.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineServerEnvironmentVariables } from \"./IEngineServerEnvironmentVariables.js\";\n\n/**\n * The environment variables for the node.\n */\nexport interface INodeEnvironmentVariables extends IEngineServerEnvironmentVariables {\n\t/**\n\t * The features that are enabled on the node.\n\t * @default []\n\t */\n\tfeatures?: string;\n\n\t/**\n\t * The identity of the node which, if empty and node-identity feature is enabled it will be generated.\n\t */\n\tnodeIdentity?: string;\n\n\t/**\n\t * The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.\n\t */\n\tnodeMnemonic?: string;\n\n\t/**\n\t * If the node-admin-user feature is enabled, this will be the organization of the user, if one is not provided it will be generated\n\t */\n\torganizationIdentity?: string;\n\n\t/**\n\t * The mnemonic for the organization, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t */\n\torganizationMnemonic?: string;\n\n\t/**\n\t * If the node-admin-user feature is enabled, this will be the identity of the user, if one is not provided it will be generated\n\t */\n\tadminUserIdentity?: string;\n\n\t/**\n\t * The mnemonic for the admin user, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t */\n\tadminUserMnemonic?: string;\n\n\t/**\n\t * If the node-admin-user feature is enabled, this will be the name of the user.\n\t * @default admin@node\n\t */\n\tadminUserName?: string;\n\n\t/**\n\t * If the node-admin-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.\n\t */\n\tadminUserPassword?: string;\n\n\t/**\n\t * Maximum size in MB for HTTPS extensions downloads.\n\t * @default 10\n\t */\n\textensionsMaxSizeMb?: number;\n\n\t/**\n\t * Whether to clear the extensions cache on startup.\n\t * @default false\n\t */\n\textensionsClearCache?: boolean;\n\n\t/**\n\t * Custom directory for extensions cache storage.\n\t * @default \".tmp\"\n\t */\n\textensionsCacheDirectory?: string;\n\n\t/**\n\t * TTL in hours for HTTPS extensions cache.\n\t * @default 24\n\t */\n\textensionsCacheTtlHours?: number;\n\n\t/**\n\t * Force refresh of all cached extensions.\n\t * @default false\n\t */\n\textensionsForceRefresh?: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"INodeOptions.js","sourceRoot":"","sources":["../../../src/models/INodeOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineCore, IEngineServer, IEngineStateStorage } from \"@twin.org/engine-models\";\nimport type { IEngineConfig } from \"@twin.org/engine-types\";\nimport type { INodeEngineConfig } from \"./INodeEngineConfig.js\";\nimport type { INodeEnvironmentVariables } from \"./INodeEnvironmentVariables.js\";\n\n/**\n * The options when running the node.\n */\nexport interface INodeOptions {\n\t/**\n\t * The name of the server, defaults to \"TWIN Node Server\".\n\t * @default \"TWIN Node Server\"\n\t */\n\tserverName?: string;\n\n\t/**\n\t * The version of the server, defaults to the current version.\n\t */\n\tserverVersion?: string;\n\n\t/**\n\t * Additional environment variables to set.\n\t */\n\tenvVars?: { [key: string]: string };\n\n\t/**\n\t * Additional environment variable filenames to load, defaults to .env.\n\t */\n\tenvFilenames?: string[];\n\n\t/**\n\t * The prefix for environment variables, defaults to \"TWIN_\".\n\t */\n\tenvPrefix?: string;\n\n\t/**\n\t * A list of JSON files to load as configuration files.\n\t * The files will be loaded in the order they are provided, and the last one will\n\t * override any previous values.\n\t */\n\tconfigFilenames?: string[];\n\n\t/**\n\t * Provides the ability to have some initial custom configuration for the engine.\n\t * This will be merged with any configuration loaded from the environment variables.\n\t */\n\tconfig?: IEngineConfig;\n\n\t/**\n\t * The directory to override the execution location, defaults to process directory.\n\t */\n\texecutionDirectory?: string;\n\n\t/**\n\t * The directory to override the locales directory, defaults to the locales directory.\n\t */\n\tlocalesDirectory?: string;\n\n\t/**\n\t * The path to the OpenAPI spec file, defaults to docs/open-api/spec.json.\n\t */\n\topenApiSpecFile?: string;\n\n\t/**\n\t * The path to the favicon, defaults to static/favicon.png.\n\t */\n\tfavIconFile?: string;\n\n\t/**\n\t * Method to extend the engine environment variables with any additional custom configuration.\n\t */\n\textendEnvVars?: (envVars: INodeEnvironmentVariables) => Promise<void>;\n\n\t/**\n\t * Method to extend the engine configuration with any additional custom configuration.\n\t */\n\textendConfig?: (envVars: INodeEnvironmentVariables, config: INodeEngineConfig) => Promise<void>;\n\n\t/**\n\t * Method to extend the engine with any additional options.\n\t */\n\textendEngine?: (engine: IEngineCore) => Promise<void>;\n\n\t/**\n\t * Method to extend the engine server with any additional options.\n\t */\n\textendEngineServer?: (engineServer: IEngineServer) => Promise<void>;\n\n\t/**\n\t * The state storage to use for the engine.\n\t * If not provided, a default file-based state storage will be used.\n\t */\n\tstateStorage?: IEngineStateStorage;\n\n\t/**\n\t * Disables process.exit calls on fatal errors and throws instead.\n\t */\n\tdisableProcessExitOnFailure?: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IProtocolHandlerResult.js","sourceRoot":"","sources":["../../../src/models/IProtocolHandlerResult.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The result from a protocol handler.\n */\nexport interface IProtocolHandlerResult {\n\t/**\n\t * The resolved path to the module file.\n\t */\n\tresolvedPath: string;\n\n\t/**\n\t * Whether the module was cached.\n\t */\n\tcached: boolean;\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The protocol types for modules.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const ModuleProtocol = {
|
|
8
|
+
/**
|
|
9
|
+
* Local module (starts with . or / or file://).
|
|
10
|
+
*/
|
|
11
|
+
Local: "local",
|
|
12
|
+
/**
|
|
13
|
+
* NPM package (starts with npm:).
|
|
14
|
+
*/
|
|
15
|
+
Npm: "npm",
|
|
16
|
+
/**
|
|
17
|
+
* HTTPS URL (starts with https://).
|
|
18
|
+
*/
|
|
19
|
+
Https: "https",
|
|
20
|
+
/**
|
|
21
|
+
* HTTP URL (starts with http://).
|
|
22
|
+
*/
|
|
23
|
+
Http: "http",
|
|
24
|
+
/**
|
|
25
|
+
* Default/standard module resolution.
|
|
26
|
+
*/
|
|
27
|
+
Default: "default"
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=moduleProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleProtocol.js","sourceRoot":"","sources":["../../../src/models/moduleProtocol.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B;;OAEG;IACH,KAAK,EAAE,OAAO;IAEd;;OAEG;IACH,GAAG,EAAE,KAAK;IAEV;;OAEG;IACH,KAAK,EAAE,OAAO;IAEd;;OAEG;IACH,IAAI,EAAE,MAAM;IAEZ;;OAEG;IACH,OAAO,EAAE,SAAS;CACT,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The protocol types for modules.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ModuleProtocol = {\n\t/**\n\t * Local module (starts with . or / or file://).\n\t */\n\tLocal: \"local\",\n\n\t/**\n\t * NPM package (starts with npm:).\n\t */\n\tNpm: \"npm\",\n\n\t/**\n\t * HTTPS URL (starts with https://).\n\t */\n\tHttps: \"https\",\n\n\t/**\n\t * HTTP URL (starts with http://).\n\t */\n\tHttp: \"http\",\n\n\t/**\n\t * Default/standard module resolution.\n\t */\n\tDefault: \"default\"\n} as const;\n\n/**\n * The protocol type for a module.\n */\nexport type ModuleProtocol = (typeof ModuleProtocol)[keyof typeof ModuleProtocol];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExtensionMethods.js","sourceRoot":"","sources":["../../../src/models/nodeExtensionMethods.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineCore, IEngineServer } from \"@twin.org/engine-models\";\nimport type { INodeEngineConfig } from \"./INodeEngineConfig.js\";\nimport type { INodeEnvironmentVariables } from \"./INodeEnvironmentVariables.js\";\n\n/**\n * The type for the initialise method of an extension module.\n * @param envVars The environment variables for the node.\n * @param nodeEngineConfig The node engine config.\n */\nexport type NodeExtensionInitialiseMethod = (\n\tenvVars: INodeEnvironmentVariables,\n\tnodeEngineConfig: INodeEngineConfig\n) => Promise<void>;\n\n/**\n * The type for the initialise engine method of an extension module.\n * This is called when the engine has been constructed but not yet started.\n * @param engineCore The engine core instance.\n */\nexport type NodeExtensionInitialiseEngineMethod = (engineCore: IEngineCore) => Promise<void>;\n\n/**\n * The type for the initialise engine server method of an extension module.\n * This is called when the engine server has been constructed but not yet started.\n * @param engineCore The engine core instance.\n * @param engineServer The engine server instance.\n */\nexport type NodeExtensionInitialiseEngineServerMethod = (\n\tengineCore: IEngineCore,\n\tengineServer: IEngineServer\n) => Promise<void>;\n\n/**\n * The type for the shutdown method of an extension module.\n * This is called when the engine is shutting down.\n */\nexport type NodeExtensionShutdownMethod = () => Promise<void>;\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The features that can be enabled on the node.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const NodeFeatures = {
|
|
8
|
+
/**
|
|
9
|
+
* NodeId - generates an identity for the node if not provided in config.
|
|
10
|
+
*/
|
|
11
|
+
NodeId: "node-identity",
|
|
12
|
+
/**
|
|
13
|
+
* NodeAdminUser - generates an admin user for the node if not provided in config.
|
|
14
|
+
*/
|
|
15
|
+
NodeAdminUser: "node-admin-user",
|
|
16
|
+
/**
|
|
17
|
+
* NodeWallet - generates wallets for any identities that need them.
|
|
18
|
+
*/
|
|
19
|
+
NodeWallet: "node-wallet"
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=nodeFeatures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeFeatures.js","sourceRoot":"","sources":["../../../src/models/nodeFeatures.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,eAAe;IAEvB;;OAEG;IACH,aAAa,EAAE,iBAAiB;IAEhC;;OAEG;IACH,UAAU,EAAE,aAAa;CAChB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The features that can be enabled on the node.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const NodeFeatures = {\n\t/**\n\t * NodeId - generates an identity for the node if not provided in config.\n\t */\n\tNodeId: \"node-identity\",\n\n\t/**\n\t * NodeAdminUser - generates an admin user for the node if not provided in config.\n\t */\n\tNodeAdminUser: \"node-admin-user\",\n\n\t/**\n\t * NodeWallet - generates wallets for any identities that need them.\n\t */\n\tNodeWallet: \"node-wallet\"\n} as const;\n\n/**\n * The features that can be enabled on the node.\n */\nexport type NodeFeatures = (typeof NodeFeatures)[keyof typeof NodeFeatures];\n"]}
|