@twin.org/node-core 0.0.3-next.2 → 0.0.3-next.21

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.
Files changed (151) hide show
  1. package/dist/es/builders/engineEnvBuilder.js +168 -105
  2. package/dist/es/builders/engineEnvBuilder.js.map +1 -1
  3. package/dist/es/builders/engineServerEnvBuilder.js +49 -25
  4. package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
  5. package/dist/es/cli.js +247 -0
  6. package/dist/es/cli.js.map +1 -0
  7. package/dist/es/commands/bootstrapLegacy.js +183 -0
  8. package/dist/es/commands/bootstrapLegacy.js.map +1 -0
  9. package/dist/es/commands/help.js +85 -0
  10. package/dist/es/commands/help.js.map +1 -0
  11. package/dist/es/commands/identityCreate.js +316 -0
  12. package/dist/es/commands/identityCreate.js.map +1 -0
  13. package/dist/es/commands/identityImports.js +82 -0
  14. package/dist/es/commands/identityImports.js.map +1 -0
  15. package/dist/es/commands/identityVerifiableCredentialCreate.js +146 -0
  16. package/dist/es/commands/identityVerifiableCredentialCreate.js.map +1 -0
  17. package/dist/es/commands/identityVerificationMethodCreate.js +214 -0
  18. package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -0
  19. package/dist/es/commands/identityVerificationMethodImport.js +126 -0
  20. package/dist/es/commands/identityVerificationMethodImport.js.map +1 -0
  21. package/dist/es/commands/nodeSetIdentity.js +64 -0
  22. package/dist/es/commands/nodeSetIdentity.js.map +1 -0
  23. package/dist/es/commands/nodeSetTenant.js +68 -0
  24. package/dist/es/commands/nodeSetTenant.js.map +1 -0
  25. package/dist/es/commands/tenantCreate.js +139 -0
  26. package/dist/es/commands/tenantCreate.js.map +1 -0
  27. package/dist/es/commands/tenantImport.js +97 -0
  28. package/dist/es/commands/tenantImport.js.map +1 -0
  29. package/dist/es/commands/tenantUpdate.js +94 -0
  30. package/dist/es/commands/tenantUpdate.js.map +1 -0
  31. package/dist/es/commands/userCreate.js +212 -0
  32. package/dist/es/commands/userCreate.js.map +1 -0
  33. package/dist/es/commands/userUpdate.js +132 -0
  34. package/dist/es/commands/userUpdate.js.map +1 -0
  35. package/dist/es/commands/vaultKeyCreate.js +191 -0
  36. package/dist/es/commands/vaultKeyCreate.js.map +1 -0
  37. package/dist/es/commands/vaultKeyImport.js +104 -0
  38. package/dist/es/commands/vaultKeyImport.js.map +1 -0
  39. package/dist/es/defaults.js +19 -1
  40. package/dist/es/defaults.js.map +1 -1
  41. package/dist/es/index.js +7 -3
  42. package/dist/es/index.js.map +1 -1
  43. package/dist/es/models/ICliArgs.js +4 -0
  44. package/dist/es/models/ICliArgs.js.map +1 -0
  45. package/dist/es/models/ICliCommand.js +2 -0
  46. package/dist/es/models/ICliCommand.js.map +1 -0
  47. package/dist/es/models/ICliCommandDefinition.js +2 -0
  48. package/dist/es/models/ICliCommandDefinition.js.map +1 -0
  49. package/dist/es/models/ICliCommandDefinitionParam.js +2 -0
  50. package/dist/es/models/ICliCommandDefinitionParam.js.map +1 -0
  51. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
  52. package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
  53. package/dist/es/models/INodeEngineState.js.map +1 -1
  54. package/dist/es/models/INodeEnvironmentVariables.js.map +1 -1
  55. package/dist/es/models/INodeOptions.js.map +1 -1
  56. package/dist/es/models/cliCommandParamType.js +4 -0
  57. package/dist/es/models/cliCommandParamType.js.map +1 -0
  58. package/dist/es/node.js +78 -41
  59. package/dist/es/node.js.map +1 -1
  60. package/dist/es/start.js +139 -0
  61. package/dist/es/start.js.map +1 -0
  62. package/dist/es/utils.js +11 -21
  63. package/dist/es/utils.js.map +1 -1
  64. package/dist/types/builders/engineEnvBuilder.d.ts +4 -1
  65. package/dist/types/builders/engineServerEnvBuilder.d.ts +5 -2
  66. package/dist/types/cli.d.ts +56 -0
  67. package/dist/types/commands/bootstrapLegacy.d.ts +66 -0
  68. package/dist/types/commands/help.d.ts +23 -0
  69. package/dist/types/commands/identityCreate.d.ts +39 -0
  70. package/dist/types/commands/identityImports.d.ts +24 -0
  71. package/dist/types/commands/identityVerifiableCredentialCreate.d.ts +43 -0
  72. package/dist/types/commands/identityVerificationMethodCreate.d.ts +47 -0
  73. package/dist/types/commands/identityVerificationMethodImport.d.ts +31 -0
  74. package/dist/types/commands/nodeSetIdentity.d.ts +22 -0
  75. package/dist/types/commands/nodeSetTenant.d.ts +22 -0
  76. package/dist/types/commands/tenantCreate.d.ts +38 -0
  77. package/dist/types/commands/tenantImport.d.ts +26 -0
  78. package/dist/types/commands/tenantUpdate.d.ts +26 -0
  79. package/dist/types/commands/userCreate.d.ts +49 -0
  80. package/dist/types/commands/userUpdate.d.ts +38 -0
  81. package/dist/types/commands/vaultKeyCreate.d.ts +43 -0
  82. package/dist/types/commands/vaultKeyImport.d.ts +28 -0
  83. package/dist/types/defaults.d.ts +11 -1
  84. package/dist/types/index.d.ts +7 -3
  85. package/dist/types/models/ICliArgs.d.ts +20 -0
  86. package/dist/types/models/ICliCommand.d.ts +17 -0
  87. package/dist/types/models/ICliCommandDefinition.d.ts +46 -0
  88. package/dist/types/models/ICliCommandDefinitionParam.d.ts +35 -0
  89. package/dist/types/models/IEngineEnvironmentVariables.d.ts +62 -53
  90. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +4 -0
  91. package/dist/types/models/INodeEngineState.d.ts +0 -8
  92. package/dist/types/models/INodeEnvironmentVariables.d.ts +0 -38
  93. package/dist/types/models/INodeOptions.d.ts +6 -2
  94. package/dist/types/models/cliCommandParamType.d.ts +4 -0
  95. package/dist/types/node.d.ts +8 -4
  96. package/dist/types/{server.d.ts → start.d.ts} +7 -2
  97. package/dist/types/utils.d.ts +6 -8
  98. package/docs/changelog.md +136 -0
  99. package/docs/reference/functions/buildConfiguration.md +3 -3
  100. package/docs/reference/functions/buildEngineConfiguration.md +1 -1
  101. package/docs/reference/functions/buildEngineServerConfiguration.md +3 -3
  102. package/docs/reference/functions/constructCliCommand.md +27 -0
  103. package/docs/reference/functions/executeCommand.md +29 -0
  104. package/docs/reference/functions/getEnvDefaults.md +19 -0
  105. package/docs/reference/functions/getScriptDirectory.md +19 -0
  106. package/docs/reference/functions/parseCommandLineArgs.md +19 -0
  107. package/docs/reference/functions/processEnvOptions.md +27 -0
  108. package/docs/reference/functions/registerCommands.md +9 -0
  109. package/docs/reference/functions/run.md +8 -2
  110. package/docs/reference/functions/start.md +10 -4
  111. package/docs/reference/functions/substituteEnvOptions.md +25 -0
  112. package/docs/reference/index.md +16 -13
  113. package/docs/reference/interfaces/ICliArgs.md +35 -0
  114. package/docs/reference/interfaces/ICliCommand.md +23 -0
  115. package/docs/reference/interfaces/ICliCommandDefinition.md +101 -0
  116. package/docs/reference/interfaces/ICliCommandDefinitionParam.md +65 -0
  117. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +110 -85
  118. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +166 -117
  119. package/docs/reference/interfaces/INodeEngineState.md +0 -16
  120. package/docs/reference/interfaces/INodeEnvironmentVariables.md +170 -201
  121. package/docs/reference/interfaces/INodeOptions.md +10 -2
  122. package/docs/reference/type-aliases/CliCommandParamType.md +5 -0
  123. package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_DID.md +3 -0
  124. package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_TENANT.md +3 -0
  125. package/docs/reference/variables/TRUST_VERIFICATION_METHOD_ID.md +3 -0
  126. package/locales/en.json +589 -30
  127. package/package.json +3 -1
  128. package/dist/es/bootstrap.js +0 -374
  129. package/dist/es/bootstrap.js.map +0 -1
  130. package/dist/es/identity.js +0 -169
  131. package/dist/es/identity.js.map +0 -1
  132. package/dist/es/models/nodeFeatures.js +0 -21
  133. package/dist/es/models/nodeFeatures.js.map +0 -1
  134. package/dist/es/server.js +0 -78
  135. package/dist/es/server.js.map +0 -1
  136. package/dist/types/bootstrap.d.ts +0 -76
  137. package/dist/types/identity.d.ts +0 -14
  138. package/dist/types/models/nodeFeatures.d.ts +0 -21
  139. package/docs/reference/functions/bootstrap.md +0 -29
  140. package/docs/reference/functions/bootstrapAuth.md +0 -35
  141. package/docs/reference/functions/bootstrapBlobEncryption.md +0 -35
  142. package/docs/reference/functions/bootstrapContextIdHandlers.md +0 -35
  143. package/docs/reference/functions/bootstrapImmutableProofMethod.md +0 -35
  144. package/docs/reference/functions/bootstrapNodeAdminUser.md +0 -35
  145. package/docs/reference/functions/bootstrapNodeId.md +0 -35
  146. package/docs/reference/functions/bootstrapSynchronisedStorage.md +0 -35
  147. package/docs/reference/functions/bootstrapTenantId.md +0 -35
  148. package/docs/reference/functions/getFeatures.md +0 -19
  149. package/docs/reference/type-aliases/NodeFeatures.md +0 -5
  150. package/docs/reference/variables/NodeFeatures.md +0 -25
  151. package/docs/reference/variables/VC_AUTHENTICATION_VERIFICATION_METHOD_ID.md +0 -3
@@ -1 +0,0 @@
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,EAClC,UAA8B,EAC9B,YAA8C,E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C,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"]}
@@ -1,21 +0,0 @@
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
@@ -1 +0,0 @@
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"]}
package/dist/es/server.js DELETED
@@ -1,78 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- import { GeneralError, I18n, Is } from "@twin.org/core";
4
- import { Engine } from "@twin.org/engine";
5
- import { FileStateStorage } from "@twin.org/engine-core";
6
- import { EngineCoreFactory } from "@twin.org/engine-models";
7
- import { EngineServer } from "@twin.org/engine-server";
8
- import { BlobStorageConnectorType, EntityStorageConnectorType } from "@twin.org/engine-types";
9
- import { bootstrap } from "./bootstrap.js";
10
- import { extensionsInitialiseEngine, extensionsInitialiseEngineServer, shutdownExtensions } from "./builders/extensionsBuilder.js";
11
- let isStarted = false;
12
- /**
13
- * Start the engine server.
14
- * @param nodeOptions Optional run options for the engine server.
15
- * @param nodeEngineConfig The configuration for the engine server.
16
- * @param envVars The environment variables.
17
- * @param contextIdKeys The context ID keys.
18
- * @returns The engine server.
19
- */
20
- export async function start(nodeOptions, nodeEngineConfig, envVars, contextIdKeys) {
21
- const entityStorageConnectorType = envVars.entityStorageConnectorType?.split(",") ?? [];
22
- const blobStorageConnectorType = envVars.blobStorageConnectorType?.split(",") ?? [];
23
- // If the blob storage or entity storage is configured with file connectors
24
- // then we need to make sure the storageFileRoot is set
25
- if ((entityStorageConnectorType.includes(EntityStorageConnectorType.File) ||
26
- blobStorageConnectorType.includes(BlobStorageConnectorType.File) ||
27
- Is.empty(nodeOptions?.stateStorage)) &&
28
- !Is.stringValue(envVars.storageFileRoot)) {
29
- throw new GeneralError("node", "storageFileRootNotSet", {
30
- storageFileRoot: `${nodeOptions?.envPrefix ?? ""}STORAGE_FILE_ROOT`
31
- });
32
- }
33
- // Create the engine instance using file state storage unless one is configured in options
34
- const engine = new Engine({
35
- config: nodeEngineConfig,
36
- stateStorage: nodeOptions?.stateStorage ?? new FileStateStorage(envVars.stateFilename ?? ""),
37
- customBootstrap: async (core, engineContext) => bootstrap(core, engineContext, envVars)
38
- });
39
- if (Is.arrayValue(contextIdKeys)) {
40
- const uniqueContextIdKeys = Array.from(new Set(contextIdKeys));
41
- for (const contextIdKey of uniqueContextIdKeys) {
42
- engine.addContextIdKey(contextIdKey);
43
- }
44
- }
45
- // Construct the server with the engine.
46
- const server = new EngineServer({ engineCore: engine });
47
- // Extend the engine.
48
- if (Is.function(nodeOptions?.extendEngine)) {
49
- await engine.logInfo(I18n.formatMessage("node.extendingEngine"));
50
- await nodeOptions.extendEngine(engine);
51
- }
52
- await extensionsInitialiseEngine(envVars, engine);
53
- // Extend the engine server.
54
- if (Is.function(nodeOptions?.extendEngineServer)) {
55
- await engine.logInfo(I18n.formatMessage("node.extendingEngineServer"));
56
- await nodeOptions?.extendEngineServer(server);
57
- }
58
- await extensionsInitialiseEngineServer(envVars, engine, server);
59
- // Need to register the engine with the factory so that background tasks
60
- // can clone it to spawn new instances.
61
- EngineCoreFactory.register("engine", () => engine);
62
- // Start the server, which also starts the engine.
63
- isStarted = await server.start();
64
- if (isStarted) {
65
- return {
66
- engine,
67
- server,
68
- shutdown: async () => {
69
- if (isStarted) {
70
- isStarted = false;
71
- await shutdownExtensions(envVars, engine);
72
- await server.stop();
73
- }
74
- }
75
- };
76
- }
77
- }
78
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,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vC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAEnD,kDAAkD;IAClD,SAAS,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAEjC,IAAI,SAAS,EAAE,CAAC;QACf,OAAO;YACN,MAAM;YACN,MAAM;YACN,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACpB,IAAI,SAAS,EAAE,CAAC;oBACf,SAAS,GAAG,KAAK,CAAC;oBAClB,MAAM,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAC1C,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBACrB,CAAC;YACF,CAAC;SACD,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, I18n, Is } from \"@twin.org/core\";\nimport { Engine } from \"@twin.org/engine\";\nimport { FileStateStorage } from \"@twin.org/engine-core\";\nimport { EngineCoreFactory } from \"@twin.org/engine-models\";\nimport { EngineServer } from \"@twin.org/engine-server\";\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\nimport { BlobStorageConnectorType, EntityStorageConnectorType } from \"@twin.org/engine-types\";\nimport { bootstrap } from \"./bootstrap.js\";\nimport {\n\textensionsInitialiseEngine,\n\textensionsInitialiseEngineServer,\n\tshutdownExtensions\n} from \"./builders/extensionsBuilder.js\";\nimport type { INodeEngineConfig } from \"./models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\nimport type { INodeOptions } from \"./models/INodeOptions.js\";\n\nlet isStarted = false;\n\n/**\n * Start the engine server.\n * @param nodeOptions Optional run options for the engine server.\n * @param nodeEngineConfig The configuration for the engine server.\n * @param envVars The environment variables.\n * @param contextIdKeys The context ID keys.\n * @returns The engine server.\n */\nexport async function start(\n\tnodeOptions: INodeOptions | undefined,\n\tnodeEngineConfig: INodeEngineConfig,\n\tenvVars: INodeEnvironmentVariables,\n\tcontextIdKeys?: string[]\n): Promise<\n\t| {\n\t\t\tengine: Engine<IEngineServerConfig, INodeEngineState>;\n\t\t\tserver: EngineServer;\n\t\t\tshutdown: () => Promise<void>;\n\t }\n\t| undefined\n> {\n\tconst entityStorageConnectorType = envVars.entityStorageConnectorType?.split(\",\") ?? [];\n\tconst blobStorageConnectorType = envVars.blobStorageConnectorType?.split(\",\") ?? [];\n\n\t// If the blob storage or entity storage is configured with file connectors\n\t// then we need to make sure the storageFileRoot is set\n\tif (\n\t\t(entityStorageConnectorType.includes(EntityStorageConnectorType.File) ||\n\t\t\tblobStorageConnectorType.includes(BlobStorageConnectorType.File) ||\n\t\t\tIs.empty(nodeOptions?.stateStorage)) &&\n\t\t!Is.stringValue(envVars.storageFileRoot)\n\t) {\n\t\tthrow new GeneralError(\"node\", \"storageFileRootNotSet\", {\n\t\t\tstorageFileRoot: `${nodeOptions?.envPrefix ?? \"\"}STORAGE_FILE_ROOT`\n\t\t});\n\t}\n\n\t// Create the engine instance using file state storage unless one is configured in options\n\tconst engine = new Engine<IEngineServerConfig, INodeEngineState>({\n\t\tconfig: nodeEngineConfig,\n\t\tstateStorage: nodeOptions?.stateStorage ?? new FileStateStorage(envVars.stateFilename ?? \"\"),\n\t\tcustomBootstrap: async (core, engineContext) => bootstrap(core, engineContext, envVars)\n\t});\n\n\tif (Is.arrayValue(contextIdKeys)) {\n\t\tconst uniqueContextIdKeys = Array.from(new Set(contextIdKeys));\n\t\tfor (const contextIdKey of uniqueContextIdKeys) {\n\t\t\tengine.addContextIdKey(contextIdKey);\n\t\t}\n\t}\n\n\t// Construct the server with the engine.\n\tconst server = new EngineServer({ engineCore: engine });\n\n\t// Extend the engine.\n\tif (Is.function(nodeOptions?.extendEngine)) {\n\t\tawait engine.logInfo(I18n.formatMessage(\"node.extendingEngine\"));\n\t\tawait nodeOptions.extendEngine(engine);\n\t}\n\n\tawait extensionsInitialiseEngine(envVars, engine);\n\n\t// Extend the engine server.\n\tif (Is.function(nodeOptions?.extendEngineServer)) {\n\t\tawait engine.logInfo(I18n.formatMessage(\"node.extendingEngineServer\"));\n\t\tawait nodeOptions?.extendEngineServer(server);\n\t}\n\n\tawait extensionsInitialiseEngineServer(envVars, engine, server);\n\n\t// Need to register the engine with the factory so that background tasks\n\t// can clone it to spawn new instances.\n\tEngineCoreFactory.register(\"engine\", () => engine);\n\n\t// Start the server, which also starts the engine.\n\tisStarted = await server.start();\n\n\tif (isStarted) {\n\t\treturn {\n\t\t\tengine,\n\t\t\tserver,\n\t\t\tshutdown: async () => {\n\t\t\t\tif (isStarted) {\n\t\t\t\t\tisStarted = false;\n\t\t\t\t\tawait shutdownExtensions(envVars, engine);\n\t\t\t\t\tawait server.stop();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n}\n"]}
@@ -1,76 +0,0 @@
1
- import type { IEngineCore, IEngineCoreContext } from "@twin.org/engine-models";
2
- import { type IEngineServerConfig } from "@twin.org/engine-server-types";
3
- import type { INodeEngineState } from "./models/INodeEngineState.js";
4
- import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
5
- import { NodeFeatures } from "./models/nodeFeatures.js";
6
- /**
7
- * Bootstrap the application.
8
- * @param engineCore The engine core for the node.
9
- * @param context The context for the node.
10
- * @param envVars The environment variables for the node.
11
- */
12
- export declare function bootstrap(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables): Promise<void>;
13
- /**
14
- * Bootstrap the context id handlers creating any necessary resources.
15
- * @param engineCore The engine core for the node.
16
- * @param context The context for the node.
17
- * @param envVars The environment variables for the node.
18
- * @param features The features that are enabled on the node. The features that are enabled on the node.
19
- */
20
- export declare function bootstrapContextIdHandlers(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
21
- /**
22
- * Bootstrap the node creating any necessary resources.
23
- * @param engineCore The engine core for the node.
24
- * @param context The context for the node.
25
- * @param envVars The environment variables for the node.
26
- * @param features The features that are enabled on the node. The features that are enabled on the node.
27
- */
28
- export declare function bootstrapNodeId(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
29
- /**
30
- * Bootstrap the node creating any necessary resources.
31
- * @param engineCore The engine core for the node.
32
- * @param context The context for the node.
33
- * @param envVars The environment variables for the node.
34
- * @param features The features that are enabled on the node. The features that are enabled on the node.
35
- */
36
- export declare function bootstrapTenantId(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
37
- /**
38
- * Bootstrap the user.
39
- * @param engineCore The engine core for the node.
40
- * @param context The context for the node.
41
- * @param envVars The environment variables for the node.
42
- * @param features The features that are enabled on the node.
43
- */
44
- export declare function bootstrapNodeAdminUser(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
45
- /**
46
- * Bootstrap the immutable proof verification methods.
47
- * @param engineCore The engine core for the node.
48
- * @param context The context for the node.
49
- * @param envVars The environment variables for the node.
50
- * @param features The features that are enabled on the node.
51
- */
52
- export declare function bootstrapImmutableProofMethod(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
53
- /**
54
- * Bootstrap the keys for blob encryption.
55
- * @param engineCore The engine core for the node.
56
- * @param context The context for the node.
57
- * @param envVars The environment variables for the node.
58
- * @param features The features that are enabled on the node.
59
- */
60
- export declare function bootstrapBlobEncryption(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
61
- /**
62
- * Bootstrap the JWT signing key.
63
- * @param engineCore The engine core for the node.
64
- * @param context The context for the node.
65
- * @param envVars The environment variables for the node.
66
- * @param features The features that are enabled on the node.
67
- */
68
- export declare function bootstrapAuth(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
69
- /**
70
- * Bootstrap the synchronised storage blob encryption and verification methods.
71
- * @param engineCore The engine core for the node.
72
- * @param context The context for the node.
73
- * @param envVars The environment variables for the node.
74
- * @param features The features that are enabled on the node.
75
- */
76
- export declare function bootstrapSynchronisedStorage(engineCore: IEngineCore, context: IEngineCoreContext<IEngineServerConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, features: NodeFeatures[]): Promise<void>;
@@ -1,14 +0,0 @@
1
- import type { IEngineCore } from "@twin.org/engine-models";
2
- import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
3
- /**
4
- * Generate an identity and fund it.
5
- * @param engineCore The engine core for the node.
6
- * @param envVars The environment variables for the node.
7
- * @param configIdentity A identity from config to use.
8
- * @param configMnemonic A mnemonic from config to use.
9
- * @param controller The controller for the identity.
10
- * @param identityType The type of identity.
11
- * @param addWallet Whether to add a wallet for the identity.
12
- * @returns The identity that was generated.
13
- */
14
- export declare function createIdentity(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, configIdentity: string | undefined, configMnemonic: string | undefined, controller: string | undefined, identityType: "node" | "organization" | "user", addWallet: boolean): Promise<string>;
@@ -1,21 +0,0 @@
1
- /**
2
- * The features that can be enabled on the node.
3
- */
4
- export declare const NodeFeatures: {
5
- /**
6
- * NodeId - generates an identity for the node if not provided in config.
7
- */
8
- readonly NodeId: "node-identity";
9
- /**
10
- * NodeAdminUser - generates an admin user for the node if not provided in config.
11
- */
12
- readonly NodeAdminUser: "node-admin-user";
13
- /**
14
- * NodeWallet - generates wallets for any identities that need them.
15
- */
16
- readonly NodeWallet: "node-wallet";
17
- };
18
- /**
19
- * The features that can be enabled on the node.
20
- */
21
- export type NodeFeatures = (typeof NodeFeatures)[keyof typeof NodeFeatures];
@@ -1,29 +0,0 @@
1
- # Function: bootstrap()
2
-
3
- > **bootstrap**(`engineCore`, `context`, `envVars`): `Promise`\<`void`\>
4
-
5
- Bootstrap the application.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ## Returns
28
-
29
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapAuth()
2
-
3
- > **bootstrapAuth**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the JWT signing key.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapBlobEncryption()
2
-
3
- > **bootstrapBlobEncryption**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the keys for blob encryption.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapContextIdHandlers()
2
-
3
- > **bootstrapContextIdHandlers**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the context id handlers creating any necessary resources.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node. The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapImmutableProofMethod()
2
-
3
- > **bootstrapImmutableProofMethod**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the immutable proof verification methods.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapNodeAdminUser()
2
-
3
- > **bootstrapNodeAdminUser**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the user.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapNodeId()
2
-
3
- > **bootstrapNodeId**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the node creating any necessary resources.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node. The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapSynchronisedStorage()
2
-
3
- > **bootstrapSynchronisedStorage**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the synchronised storage blob encryption and verification methods.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,35 +0,0 @@
1
- # Function: bootstrapTenantId()
2
-
3
- > **bootstrapTenantId**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
-
5
- Bootstrap the node creating any necessary resources.
6
-
7
- ## Parameters
8
-
9
- ### engineCore
10
-
11
- `IEngineCore`
12
-
13
- The engine core for the node.
14
-
15
- ### context
16
-
17
- `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
-
19
- The context for the node.
20
-
21
- ### envVars
22
-
23
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
24
-
25
- The environment variables for the node.
26
-
27
- ### features
28
-
29
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
30
-
31
- The features that are enabled on the node. The features that are enabled on the node.
32
-
33
- ## Returns
34
-
35
- `Promise`\<`void`\>
@@ -1,19 +0,0 @@
1
- # Function: getFeatures()
2
-
3
- > **getFeatures**(`env`): [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
4
-
5
- Get the features that are enabled on the node.
6
-
7
- ## Parameters
8
-
9
- ### env
10
-
11
- [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md)
12
-
13
- The environment variables for the node.
14
-
15
- ## Returns
16
-
17
- [`NodeFeatures`](../type-aliases/NodeFeatures.md)[]
18
-
19
- The features that are enabled on the node.
@@ -1,5 +0,0 @@
1
- # Type Alias: NodeFeatures
2
-
3
- > **NodeFeatures** = *typeof* [`NodeFeatures`](../variables/NodeFeatures.md)\[keyof *typeof* [`NodeFeatures`](../variables/NodeFeatures.md)\]
4
-
5
- The features that can be enabled on the node.
@@ -1,25 +0,0 @@
1
- # Variable: NodeFeatures
2
-
3
- > `const` **NodeFeatures**: `object`
4
-
5
- The features that can be enabled on the node.
6
-
7
- ## Type Declaration
8
-
9
- ### NodeId
10
-
11
- > `readonly` **NodeId**: `"node-identity"` = `"node-identity"`
12
-
13
- NodeId - generates an identity for the node if not provided in config.
14
-
15
- ### NodeAdminUser
16
-
17
- > `readonly` **NodeAdminUser**: `"node-admin-user"` = `"node-admin-user"`
18
-
19
- NodeAdminUser - generates an admin user for the node if not provided in config.
20
-
21
- ### NodeWallet
22
-
23
- > `readonly` **NodeWallet**: `"node-wallet"` = `"node-wallet"`
24
-
25
- NodeWallet - generates wallets for any identities that need them.
@@ -1,3 +0,0 @@
1
- # Variable: VC\_AUTHENTICATION\_VERIFICATION\_METHOD\_ID
2
-
3
- > `const` **VC\_AUTHENTICATION\_VERIFICATION\_METHOD\_ID**: `"node-authentication-assertion"` = `"node-authentication-assertion"`