@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.
Files changed (126) hide show
  1. package/README.md +1 -1
  2. package/dist/es/bootstrap.js +374 -0
  3. package/dist/es/bootstrap.js.map +1 -0
  4. package/dist/es/builders/engineEnvBuilder.js +1051 -0
  5. package/dist/es/builders/engineEnvBuilder.js.map +1 -0
  6. package/dist/es/builders/engineServerEnvBuilder.js +197 -0
  7. package/dist/es/builders/engineServerEnvBuilder.js.map +1 -0
  8. package/dist/es/builders/extensionsBuilder.js +109 -0
  9. package/dist/es/builders/extensionsBuilder.js.map +1 -0
  10. package/dist/es/defaults.js +9 -0
  11. package/dist/es/defaults.js.map +1 -0
  12. package/dist/es/identity.js +169 -0
  13. package/dist/es/identity.js.map +1 -0
  14. package/dist/es/index.js +23 -0
  15. package/dist/es/index.js.map +1 -0
  16. package/dist/es/models/ICacheMetadata.js +4 -0
  17. package/dist/es/models/ICacheMetadata.js.map +1 -0
  18. package/dist/es/models/IEngineEnvironmentVariables.js +4 -0
  19. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -0
  20. package/dist/es/models/IEngineServerEnvironmentVariables.js +2 -0
  21. package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -0
  22. package/dist/es/models/IModuleProtocol.js +2 -0
  23. package/dist/es/models/IModuleProtocol.js.map +1 -0
  24. package/dist/es/models/INodeEngineConfig.js +2 -0
  25. package/dist/es/models/INodeEngineConfig.js.map +1 -0
  26. package/dist/es/models/INodeEngineState.js +2 -0
  27. package/dist/es/models/INodeEngineState.js.map +1 -0
  28. package/dist/es/models/INodeEnvironmentVariables.js +2 -0
  29. package/dist/es/models/INodeEnvironmentVariables.js.map +1 -0
  30. package/dist/es/models/INodeOptions.js +2 -0
  31. package/dist/es/models/INodeOptions.js.map +1 -0
  32. package/dist/es/models/IProtocolHandlerResult.js +4 -0
  33. package/dist/es/models/IProtocolHandlerResult.js.map +1 -0
  34. package/dist/es/models/moduleProtocol.js +29 -0
  35. package/dist/es/models/moduleProtocol.js.map +1 -0
  36. package/dist/es/models/nodeExtensionMethods.js +2 -0
  37. package/dist/es/models/nodeExtensionMethods.js.map +1 -0
  38. package/dist/es/models/nodeFeatures.js +21 -0
  39. package/dist/es/models/nodeFeatures.js.map +1 -0
  40. package/dist/es/node.js +265 -0
  41. package/dist/es/node.js.map +1 -0
  42. package/dist/es/server.js +78 -0
  43. package/dist/es/server.js.map +1 -0
  44. package/dist/es/utils.js +418 -0
  45. package/dist/es/utils.js.map +1 -0
  46. package/dist/types/bootstrap.d.ts +27 -10
  47. package/dist/types/builders/engineEnvBuilder.d.ts +3 -2
  48. package/dist/types/builders/engineServerEnvBuilder.d.ts +4 -3
  49. package/dist/types/builders/extensionsBuilder.d.ts +32 -0
  50. package/dist/types/defaults.d.ts +6 -0
  51. package/dist/types/identity.d.ts +14 -0
  52. package/dist/types/index.d.ts +20 -11
  53. package/dist/types/models/ICacheMetadata.d.ts +17 -0
  54. package/dist/types/models/IEngineEnvironmentVariables.d.ts +132 -24
  55. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +12 -3
  56. package/dist/types/models/IModuleProtocol.d.ts +18 -0
  57. package/dist/types/models/INodeEngineConfig.d.ts +6 -0
  58. package/dist/types/models/INodeEngineState.d.ts +22 -0
  59. package/dist/types/models/INodeEnvironmentVariables.d.ts +50 -10
  60. package/dist/types/models/INodeOptions.d.ts +14 -3
  61. package/dist/types/models/IProtocolHandlerResult.d.ts +13 -0
  62. package/dist/types/models/moduleProtocol.d.ts +29 -0
  63. package/dist/types/models/nodeExtensionMethods.d.ts +27 -0
  64. package/dist/types/models/nodeFeatures.d.ts +5 -5
  65. package/dist/types/node.d.ts +17 -7
  66. package/dist/types/server.d.ts +9 -6
  67. package/dist/types/utils.d.ts +87 -2
  68. package/docs/changelog.md +185 -0
  69. package/docs/detailed-guide.md +129 -0
  70. package/docs/reference/functions/bootstrap.md +1 -1
  71. package/docs/reference/functions/bootstrapAuth.md +1 -1
  72. package/docs/reference/functions/bootstrapBlobEncryption.md +1 -1
  73. package/docs/reference/functions/bootstrapContextIdHandlers.md +35 -0
  74. package/docs/reference/functions/bootstrapImmutableProofMethod.md +1 -1
  75. package/docs/reference/functions/{bootstrapNodeUser.md → bootstrapNodeAdminUser.md} +3 -3
  76. package/docs/reference/functions/{bootstrapNodeIdentity.md → bootstrapNodeId.md} +3 -3
  77. package/docs/reference/functions/bootstrapSynchronisedStorage.md +1 -1
  78. package/docs/reference/functions/bootstrapTenantId.md +35 -0
  79. package/docs/reference/functions/buildConfiguration.md +2 -2
  80. package/docs/reference/functions/buildEngineConfiguration.md +8 -2
  81. package/docs/reference/functions/buildEngineServerConfiguration.md +9 -3
  82. package/docs/reference/functions/createModuleImportUrl.md +21 -0
  83. package/docs/reference/functions/directoryExists.md +19 -0
  84. package/docs/reference/functions/extensionsConfiguration.md +25 -0
  85. package/docs/reference/functions/extensionsInitialiseEngine.md +25 -0
  86. package/docs/reference/functions/extensionsInitialiseEngineServer.md +31 -0
  87. package/docs/reference/functions/getExtensionsCacheDir.md +31 -0
  88. package/docs/reference/functions/getFiles.md +19 -0
  89. package/docs/reference/functions/getSubFolders.md +19 -0
  90. package/docs/reference/functions/handleHttpsProtocol.md +49 -0
  91. package/docs/reference/functions/handleNpmProtocol.md +31 -0
  92. package/docs/reference/functions/hashUrl.md +19 -0
  93. package/docs/reference/functions/isCacheExpired.md +31 -0
  94. package/docs/reference/functions/overrideModuleImport.md +8 -2
  95. package/docs/reference/functions/parseModuleProtocol.md +19 -0
  96. package/docs/reference/functions/resolvePackageEntryPoint.md +32 -0
  97. package/docs/reference/functions/run.md +3 -3
  98. package/docs/reference/functions/shutdownExtensions.md +25 -0
  99. package/docs/reference/functions/start.md +11 -5
  100. package/docs/reference/index.md +36 -2
  101. package/docs/reference/interfaces/ICacheMetadata.md +27 -0
  102. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +255 -37
  103. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +1696 -5
  104. package/docs/reference/interfaces/IModuleProtocol.md +27 -0
  105. package/docs/reference/interfaces/INodeEngineConfig.md +7 -0
  106. package/docs/reference/interfaces/INodeEngineState.md +39 -0
  107. package/docs/reference/interfaces/INodeEnvironmentVariables.md +609 -165
  108. package/docs/reference/interfaces/INodeOptions.md +27 -3
  109. package/docs/reference/interfaces/IProtocolHandlerResult.md +19 -0
  110. package/docs/reference/type-aliases/ModuleProtocol.md +5 -0
  111. package/docs/reference/type-aliases/NodeExtensionInitialiseEngineMethod.md +18 -0
  112. package/docs/reference/type-aliases/NodeExtensionInitialiseEngineServerMethod.md +24 -0
  113. package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +23 -0
  114. package/docs/reference/type-aliases/NodeExtensionShutdownMethod.md +10 -0
  115. package/docs/reference/variables/ATTESTATION_VERIFICATION_METHOD_ID.md +3 -0
  116. package/docs/reference/variables/AUTH_SIGNING_KEY_ID.md +3 -0
  117. package/docs/reference/variables/BLOB_STORAGE_ENCRYPTION_KEY_ID.md +3 -0
  118. package/docs/reference/variables/IMMUTABLE_PROOF_VERIFICATION_METHOD_ID.md +3 -0
  119. package/docs/reference/variables/ModuleProtocol.md +37 -0
  120. package/docs/reference/variables/NodeFeatures.md +7 -7
  121. package/docs/reference/variables/SYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID.md +3 -0
  122. package/docs/reference/variables/VC_AUTHENTICATION_VERIFICATION_METHOD_ID.md +3 -0
  123. package/locales/en.json +27 -9
  124. package/package.json +27 -9
  125. package/dist/cjs/index.cjs +0 -1910
  126. package/dist/esm/index.mjs +0 -1870
@@ -1,5 +1,8 @@
1
- import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
2
- import { NodeFeatures } from "./models/nodeFeatures";
1
+ import type { IModuleProtocol } from "./models/IModuleProtocol.js";
2
+ import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
3
+ import type { IProtocolHandlerResult } from "./models/IProtocolHandlerResult.js";
4
+ import { ModuleProtocol } from "./models/moduleProtocol.js";
5
+ import { NodeFeatures } from "./models/nodeFeatures.js";
3
6
  /**
4
7
  * Initialise the locales for the application.
5
8
  * @param localesDirectory The directory containing the locales.
@@ -16,6 +19,24 @@ export declare function getExecutionDirectory(): string;
16
19
  * @returns True if the file exists.
17
20
  */
18
21
  export declare function fileExists(filename: string): Promise<boolean>;
22
+ /**
23
+ * Does the specified directory exist.
24
+ * @param directory The directory to check for existence.
25
+ * @returns True if the directory exists.
26
+ */
27
+ export declare function directoryExists(directory: string): Promise<boolean>;
28
+ /**
29
+ * Get the sub folders for the folder.
30
+ * @param directory The directory to get the sub folders.
31
+ * @returns The list of sub folders.
32
+ */
33
+ export declare function getSubFolders(directory: string): Promise<string[]>;
34
+ /**
35
+ * Get the files in the directory.
36
+ * @param directory The directory to get the files from.
37
+ * @returns The list of files in the directory.
38
+ */
39
+ export declare function getFiles(directory: string): Promise<string[]>;
19
40
  /**
20
41
  * Load the text file.
21
42
  * @param filename The filename of the text file to load.
@@ -34,3 +55,67 @@ export declare function loadJsonFile<T>(filename: string): Promise<T>;
34
55
  * @returns The features that are enabled on the node.
35
56
  */
36
57
  export declare function getFeatures(env: INodeEnvironmentVariables): NodeFeatures[];
58
+ /**
59
+ * Parse the protocol from a module name.
60
+ * @param moduleName The module name to parse.
61
+ * @returns The parsed protocol information.
62
+ */
63
+ export declare function parseModuleProtocol(moduleName: string): IModuleProtocol;
64
+ /**
65
+ * Hash a URL to create a safe filename.
66
+ * @param url The URL to hash.
67
+ * @returns A hashed filename safe for the filesystem.
68
+ */
69
+ export declare function hashUrl(url: string): string;
70
+ /**
71
+ * Get the extensions cache directory.
72
+ * @param executionDirectory The execution directory.
73
+ * @param protocol The protocol type for subdirectory organization.
74
+ * @param cacheDirectory The cache directory base path.
75
+ * @returns The cache directory path.
76
+ */
77
+ export declare function getExtensionsCacheDir(executionDirectory: string, protocol: ModuleProtocol, cacheDirectory?: string): string;
78
+ /**
79
+ * Handle the npm: protocol by installing the package if needed.
80
+ * @param packageName The npm package name (without npm: prefix).
81
+ * @param executionDirectory The execution directory.
82
+ * @param cacheDirectory The cache directory base path.
83
+ * @returns The resolved path to the installed module.
84
+ */
85
+ export declare function handleNpmProtocol(packageName: string, executionDirectory: string, cacheDirectory?: string): Promise<IProtocolHandlerResult>;
86
+ /**
87
+ * Check if a cached file has expired based on TTL and force refresh settings.
88
+ * @param metadataPath Path to the cache metadata file.
89
+ * @param ttlHours Time to live in hours.
90
+ * @param forceRefresh Whether to force refresh regardless of TTL.
91
+ * @returns True if the cache is expired or should be refreshed.
92
+ */
93
+ export declare function isCacheExpired(metadataPath: string, ttlHours: number, forceRefresh: boolean): Promise<boolean>;
94
+ /**
95
+ * Handle the https: protocol by downloading the module if needed.
96
+ * @param url The HTTPS URL to download from.
97
+ * @param executionDirectory The execution directory.
98
+ * @param maxSizeMb The maximum size in MB for the download.
99
+ * @param cacheDirectory The cache directory base path.
100
+ * @param ttlHours TTL in hours for cache expiration.
101
+ * @param forceRefresh Whether to force refresh the cache.
102
+ * @returns The resolved path to the downloaded module.
103
+ */
104
+ export declare function handleHttpsProtocol(url: string, executionDirectory: string, maxSizeMb: number, cacheDirectory?: string, ttlHours?: number, forceRefresh?: boolean): Promise<IProtocolHandlerResult>;
105
+ /**
106
+ * Resolve the main entry point from a package directory using Node.js resolution with fallback.
107
+ * Uses require.resolve() when possible for standard Node.js behavior, with manual fallback.
108
+ * @param packagePath The absolute path to the package directory.
109
+ * @param packageName The package name for require.resolve().
110
+ * @param fallback The fallback file name if no entry point is found.
111
+ * @returns The resolved entry point file name (relative to package directory).
112
+ */
113
+ export declare function resolvePackageEntryPoint(packagePath: string, packageName: string, fallback?: string): Promise<string>;
114
+ /**
115
+ * Convert a file path to an import-compatible URL for cross-platform module loading.
116
+ * On Windows, adds the 'file://' protocol prefix required for dynamic imports.
117
+ * On other platforms, returns the path unchanged.
118
+ * @param filePath The absolute file path to convert.
119
+ * @returns A URL string compatible with dynamic import().
120
+ */
121
+ export declare function createModuleImportUrl(filePath: string): string;
package/docs/changelog.md CHANGED
@@ -1,5 +1,190 @@
1
1
  # @twin.org/node-core - Changelog
2
2
 
3
+ ## [0.0.3-next.2](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.1...node-core-v0.0.3-next.2) (2025-11-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * additional stop interlock ([b3a2757](https://github.com/twinfoundation/node/commit/b3a2757325af0e7b258a9f97f1b52e86087e6301))
9
+
10
+ ## [0.0.3-next.1](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.0...node-core-v0.0.3-next.1) (2025-11-13)
11
+
12
+
13
+ ### Features
14
+
15
+ * add auth admin component ([1661e57](https://github.com/twinfoundation/node/commit/1661e57a699d5cf9ebde333e3cbc3aaea89d7c9c))
16
+ * add context id features ([#53](https://github.com/twinfoundation/node/issues/53)) ([827adf5](https://github.com/twinfoundation/node/commit/827adf52cb87fca53cec52b27e67f7a9dba2c088))
17
+ * add data space connector ([5a57087](https://github.com/twinfoundation/node/commit/5a57087d938265d3a4a812ff7c83d130ea4e103c))
18
+ * add data space connector ([f7a3644](https://github.com/twinfoundation/node/commit/f7a364477ec664e333e5ad018795acec6ee61edc))
19
+ * add data space connector ([157e8b0](https://github.com/twinfoundation/node/commit/157e8b0a76e3a8a63c1991924f7f963eb83e27ae))
20
+ * add extend engine and server methods ([ec09c7e](https://github.com/twinfoundation/node/commit/ec09c7eb882d9f5797f2fd372e96cad1a3716f59))
21
+ * add extend engine and server methods ([0136a6f](https://github.com/twinfoundation/node/commit/0136a6f3f4e1a82b1427ee9618b8a17c79bc7fda))
22
+ * add extensions support ([476d5a8](https://github.com/twinfoundation/node/commit/476d5a864026a2f78e5b02bc9eb81359777a4a45))
23
+ * add isDefault flag to logging connectors ([358e839](https://github.com/twinfoundation/node/commit/358e8394819dab9832d3a9ebfac74b897b7d5f40))
24
+ * add missing export ([e8eb621](https://github.com/twinfoundation/node/commit/e8eb6213937a202520b164a9970a891004122b61))
25
+ * add module cache and improve resolution ([482be05](https://github.com/twinfoundation/node/commit/482be056c37a598033250ea8a7288a33cf3470b4))
26
+ * add module override for better local import resolution ([ba00d17](https://github.com/twinfoundation/node/commit/ba00d17beea0a9a1851c89ad7c6a33256051c818))
27
+ * add rights management ([78fba62](https://github.com/twinfoundation/node/commit/78fba62f82afdbe615d55dd90eca8ee70ea62fc0))
28
+ * add rights management components ([0fc6293](https://github.com/twinfoundation/node/commit/0fc629332db24494bd73003625c7bf3f939a2597))
29
+ * add synchronised storage config ([e315869](https://github.com/twinfoundation/node/commit/e315869adbffcd7fe5d3ce151dd35f662f6134a9))
30
+ * add validate-locales ([1a19dcb](https://github.com/twinfoundation/node/commit/1a19dcb005c2f0e3103e290db28c48a3464094cb))
31
+ * adding npm and https protocols to load extensions ([#45](https://github.com/twinfoundation/node/issues/45)) ([33940b7](https://github.com/twinfoundation/node/commit/33940b7e771a0c5af32c18d442deb26a8631fd02))
32
+ * additional options for enabling components ([e13d772](https://github.com/twinfoundation/node/commit/e13d7721a0dd7143d456fff246622cbe63dbd0f1))
33
+ * additional route logging env vars ([7152c88](https://github.com/twinfoundation/node/commit/7152c887c3ba76778e2d9e68ba57198b8d81d802))
34
+ * additional run options ([c35e5bb](https://github.com/twinfoundation/node/commit/c35e5bbb8a80fe6a36628d41f64585b3723d9ad7))
35
+ * additional startup logging ([0740293](https://github.com/twinfoundation/node/commit/0740293b366032f2907046603abf587c9c324aff))
36
+ * eslint migration to flat config ([080db74](https://github.com/twinfoundation/node/commit/080db746390230f78725d214bc957da2efee9eb1))
37
+ * improve default options and spec ([b538721](https://github.com/twinfoundation/node/commit/b538721902e7f65021d2715148ba59409ccce035))
38
+ * improve error handling for extensions and logging ([bd84fde](https://github.com/twinfoundation/node/commit/bd84fde67e5a9db6ac66730397992401ca52e88c))
39
+ * improve error reporting ([fcd39a1](https://github.com/twinfoundation/node/commit/fcd39a18da2a6ce33965a99ca5f2f36f4aba712f))
40
+ * improve node logging ([63d6ea6](https://github.com/twinfoundation/node/commit/63d6ea661c2c76985d98addb8d905ad6f0c7f164))
41
+ * improve node logging ([c25b9c6](https://github.com/twinfoundation/node/commit/c25b9c6779bdb76f341df072c39b4c2fae4565a3))
42
+ * initial commit ([522f1e5](https://github.com/twinfoundation/node/commit/522f1e515348f9b1dd1eeb3170b1249e2b0b5371))
43
+ * migrate env config from engine to node ([5da29b8](https://github.com/twinfoundation/node/commit/5da29b8d714495308320d237a68e84355bba2b47))
44
+ * node app use JavaScript ([14fe08c](https://github.com/twinfoundation/node/commit/14fe08cb760dd885a5dac9056a4d5dbc3d61df64))
45
+ * remove unused properties ([d8344b5](https://github.com/twinfoundation/node/commit/d8344b5aee5dc1c8104d75fad5093097f6530168))
46
+ * support multiple entity and blob storage connectors ([a489f79](https://github.com/twinfoundation/node/commit/a489f7907544aef5708d5111e9f72985e1377bae))
47
+ * update dependencies ([9d25f16](https://github.com/twinfoundation/node/commit/9d25f16f1d554cd38f3bec28fdf7f8fff892ceaf))
48
+ * update engine dependency ([db290df](https://github.com/twinfoundation/node/commit/db290df3b18374f7d86da575c6048657b98c355b))
49
+ * update engine dependency ([3494c31](https://github.com/twinfoundation/node/commit/3494c3144fd5ce6d3a9f2936c7890ab36795aeaa))
50
+ * update framework components ([4bee2b9](https://github.com/twinfoundation/node/commit/4bee2b9d3651df09b8550a9ed226be1b46031854))
51
+ * update framework core ([8bd769a](https://github.com/twinfoundation/node/commit/8bd769a4451f5f1f6be3f115a5e94eeb05bce7f1))
52
+ * update rights management components ([176a0d6](https://github.com/twinfoundation/node/commit/176a0d611f88360fc845ae233b26ee0b43d7cb23))
53
+ * update rights management dependencies ([97ad02e](https://github.com/twinfoundation/node/commit/97ad02e4b74cfe5e722f74da2fc2229bbf004c0a))
54
+ * update to latest engine ([00d4974](https://github.com/twinfoundation/node/commit/00d4974f9cfb02bf48505cfb4af4a7aba1df4b3d))
55
+ * update to latest engine config ([347386c](https://github.com/twinfoundation/node/commit/347386c0609e717dc20c456ad2264c83df793c59))
56
+ * updating linting ([feacd17](https://github.com/twinfoundation/node/commit/feacd178bb025bcd29a0ae6e4b8e79f23a989169))
57
+ * use features instead of disableNodeIdentity ([2e6109b](https://github.com/twinfoundation/node/commit/2e6109bd1de825e0f5396fc120d99ad7b3929852))
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * adding a condition to verify if the password exists when bootstrapping ([6030a42](https://github.com/twinfoundation/node/commit/6030a42bdaf581678d96932fd0b809396bf7b8b0))
63
+ * adding a condition to verify if the password exists when bootstrapping ([c66f396](https://github.com/twinfoundation/node/commit/c66f396717394161a7647d1f08b3d87729d96e96))
64
+ * broken docs ([61479fd](https://github.com/twinfoundation/node/commit/61479fd618f766d22c5aafec5277e1a89e22b453))
65
+ * pr comments [#1](https://github.com/twinfoundation/node/issues/1) ([66e795b](https://github.com/twinfoundation/node/commit/66e795b16c372ab131ec1de30085aee90e4dbbd0))
66
+
67
+ ## [0.0.2-next.26](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.25...node-core-v0.0.2-next.26) (2025-10-10)
68
+
69
+
70
+ ### Features
71
+
72
+ * adding npm and https protocols to load extensions ([#45](https://github.com/twinfoundation/node/issues/45)) ([33940b7](https://github.com/twinfoundation/node/commit/33940b7e771a0c5af32c18d442deb26a8631fd02))
73
+
74
+ ## [0.0.2-next.25](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.24...node-core-v0.0.2-next.25) (2025-10-09)
75
+
76
+
77
+ ### Features
78
+
79
+ * add validate-locales ([1a19dcb](https://github.com/twinfoundation/node/commit/1a19dcb005c2f0e3103e290db28c48a3464094cb))
80
+
81
+ ## [0.0.2-next.24](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.23...node-core-v0.0.2-next.24) (2025-10-08)
82
+
83
+
84
+ ### Features
85
+
86
+ * add isDefault flag to logging connectors ([358e839](https://github.com/twinfoundation/node/commit/358e8394819dab9832d3a9ebfac74b897b7d5f40))
87
+
88
+ ## [0.0.2-next.23](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.22...node-core-v0.0.2-next.23) (2025-10-07)
89
+
90
+
91
+ ### Features
92
+
93
+ * add module cache and improve resolution ([482be05](https://github.com/twinfoundation/node/commit/482be056c37a598033250ea8a7288a33cf3470b4))
94
+
95
+ ## [0.0.2-next.22](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.21...node-core-v0.0.2-next.22) (2025-10-07)
96
+
97
+
98
+ ### Features
99
+
100
+ * update engine dependency ([db290df](https://github.com/twinfoundation/node/commit/db290df3b18374f7d86da575c6048657b98c355b))
101
+
102
+ ## [0.0.2-next.21](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.20...node-core-v0.0.2-next.21) (2025-10-07)
103
+
104
+
105
+ ### Features
106
+
107
+ * update engine dependency ([3494c31](https://github.com/twinfoundation/node/commit/3494c3144fd5ce6d3a9f2936c7890ab36795aeaa))
108
+
109
+ ## [0.0.2-next.20](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.19...node-core-v0.0.2-next.20) (2025-10-06)
110
+
111
+
112
+ ### Features
113
+
114
+ * improve node logging ([63d6ea6](https://github.com/twinfoundation/node/commit/63d6ea661c2c76985d98addb8d905ad6f0c7f164))
115
+ * improve node logging ([c25b9c6](https://github.com/twinfoundation/node/commit/c25b9c6779bdb76f341df072c39b4c2fae4565a3))
116
+
117
+ ## [0.0.2-next.19](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.18...node-core-v0.0.2-next.19) (2025-10-03)
118
+
119
+
120
+ ### Features
121
+
122
+ * use features instead of disableNodeIdentity ([2e6109b](https://github.com/twinfoundation/node/commit/2e6109bd1de825e0f5396fc120d99ad7b3929852))
123
+
124
+ ## [0.0.2-next.18](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.17...node-core-v0.0.2-next.18) (2025-10-03)
125
+
126
+
127
+ ### Features
128
+
129
+ * improve error handling for extensions and logging ([bd84fde](https://github.com/twinfoundation/node/commit/bd84fde67e5a9db6ac66730397992401ca52e88c))
130
+
131
+ ## [0.0.2-next.17](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.16...node-core-v0.0.2-next.17) (2025-10-02)
132
+
133
+
134
+ ### Features
135
+
136
+ * add extensions support ([476d5a8](https://github.com/twinfoundation/node/commit/476d5a864026a2f78e5b02bc9eb81359777a4a45))
137
+ * updating linting ([feacd17](https://github.com/twinfoundation/node/commit/feacd178bb025bcd29a0ae6e4b8e79f23a989169))
138
+
139
+ ## [0.0.2-next.16](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.15...node-core-v0.0.2-next.16) (2025-09-29)
140
+
141
+
142
+ ### Features
143
+
144
+ * update framework components ([4bee2b9](https://github.com/twinfoundation/node/commit/4bee2b9d3651df09b8550a9ed226be1b46031854))
145
+
146
+ ## [0.0.2-next.15](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.14...node-core-v0.0.2-next.15) (2025-09-26)
147
+
148
+
149
+ ### Features
150
+
151
+ * additional options for enabling components ([e13d772](https://github.com/twinfoundation/node/commit/e13d7721a0dd7143d456fff246622cbe63dbd0f1))
152
+
153
+ ## [0.0.2-next.14](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.13...node-core-v0.0.2-next.14) (2025-09-25)
154
+
155
+
156
+ ### Features
157
+
158
+ * additional route logging env vars ([7152c88](https://github.com/twinfoundation/node/commit/7152c887c3ba76778e2d9e68ba57198b8d81d802))
159
+
160
+ ## [0.0.2-next.13](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.12...node-core-v0.0.2-next.13) (2025-09-24)
161
+
162
+
163
+ ### Features
164
+
165
+ * update to latest engine ([00d4974](https://github.com/twinfoundation/node/commit/00d4974f9cfb02bf48505cfb4af4a7aba1df4b3d))
166
+
167
+ ## [0.0.2-next.12](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.11...node-core-v0.0.2-next.12) (2025-09-19)
168
+
169
+
170
+ ### Features
171
+
172
+ * update rights management components ([176a0d6](https://github.com/twinfoundation/node/commit/176a0d611f88360fc845ae233b26ee0b43d7cb23))
173
+
174
+ ## [0.0.2-next.11](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.10...node-core-v0.0.2-next.11) (2025-09-08)
175
+
176
+
177
+ ### Features
178
+
179
+ * update rights management dependencies ([97ad02e](https://github.com/twinfoundation/node/commit/97ad02e4b74cfe5e722f74da2fc2229bbf004c0a))
180
+
181
+ ## [0.0.2-next.10](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.9...node-core-v0.0.2-next.10) (2025-09-05)
182
+
183
+
184
+ ### Features
185
+
186
+ * add rights management components ([0fc6293](https://github.com/twinfoundation/node/commit/0fc629332db24494bd73003625c7bf3f939a2597))
187
+
3
188
  ## [0.0.2-next.9](https://github.com/twinfoundation/node/compare/node-core-v0.0.2-next.8...node-core-v0.0.2-next.9) (2025-08-31)
4
189
 
5
190
 
@@ -0,0 +1,129 @@
1
+ # TWIN Node - Detailed Documentation
2
+
3
+ ## Overview
4
+
5
+ TWIN Node provides the foundational components for running TWIN nodes, including dynamic extension loading, protocol-based module resolution, and lifecycle management.
6
+
7
+ ## Protocol-Based Extension Loading
8
+
9
+ The TWIN Node supports dynamic extension loading from multiple sources:
10
+
11
+ ### Local Files
12
+
13
+ Load extensions from your filesystem:
14
+
15
+ ```bash
16
+ TWIN_EXTENSIONS="./my-extension.mjs"
17
+ ```
18
+
19
+ ### NPM Packages
20
+
21
+ Automatically install and load npm packages:
22
+
23
+ ```bash
24
+ TWIN_EXTENSIONS="npm:@twin.org/package"
25
+ ```
26
+
27
+ ### HTTPS URLs
28
+
29
+ Download and cache remote extensions:
30
+
31
+ ```bash
32
+ TWIN_EXTENSIONS="https://example.com/extension.mjs"
33
+ ```
34
+
35
+ ## Extension Lifecycle Hooks
36
+
37
+ Extensions can implement lifecycle hooks to customize node behavior at different stages:
38
+
39
+ - **`extensionInitialise`** - Called before engine initialization
40
+ - **`extensionInitialiseEngine`** - Called during engine initialization
41
+ - **`extensionInitialiseEngineServer`** - Called during server initialization
42
+ - **`extensionShutdown`** - Called during graceful shutdown
43
+
44
+ ### Example Extension
45
+
46
+ ```javascript
47
+ // my-extension.mjs
48
+ export function extensionInitialise() {
49
+ console.log('Extension initializing...');
50
+ }
51
+
52
+ export function extensionInitialiseEngine(engine) {
53
+ console.log('Configuring engine...');
54
+ // Add custom components, routes, etc.
55
+ }
56
+
57
+ export function extensionInitialiseEngineServer(server) {
58
+ console.log('Configuring server...');
59
+ // Add middleware, routes, etc.
60
+ }
61
+
62
+ export function extensionShutdown() {
63
+ console.log('Extension shutting down...');
64
+ // Cleanup resources
65
+ }
66
+ ```
67
+
68
+ ## Configuration Options
69
+
70
+ ### Cache Management
71
+
72
+ - `TWIN_EXTENSIONS_CACHE_TTL_HOURS` - TTL for HTTPS extensions cache (default: 24)
73
+ - `TWIN_EXTENSIONS_FORCE_REFRESH` - Force refresh all cached extensions (default: false)
74
+ - `TWIN_EXTENSIONS_CACHE_DIRECTORY` - Custom cache directory (default: ".tmp")
75
+
76
+ ### Security
77
+
78
+ - `TWIN_EXTENSIONS_MAX_SIZE_MB` - Maximum size for HTTPS downloads (default: 10)
79
+ - `TWIN_EXTENSIONS_CLEAR_CACHE` - Clear cache on startup (default: false)
80
+
81
+ ## API Reference
82
+
83
+ ### Core Functions
84
+
85
+ #### `overrideModuleImport(executionDirectory, envVars)`
86
+
87
+ Sets up protocol-based module resolution for extensions.
88
+
89
+ #### `buildConfiguration(options)`
90
+
91
+ Builds node configuration from environment variables and options.
92
+
93
+ #### `start(options)`
94
+
95
+ Starts the TWIN node with the specified configuration.
96
+
97
+ ### Utility Functions
98
+
99
+ #### `parseModuleProtocol(moduleName)`
100
+
101
+ Parses module name to determine protocol type (npm, https, local, etc.).
102
+
103
+ #### `handleNpmProtocol(packageName, executionDirectory, cacheDirectory)`
104
+
105
+ Handles installation and resolution of npm packages.
106
+
107
+ #### `handleHttpsProtocol(url, executionDirectory, maxSizeMb, cacheDirectory, ttlHours, forceRefresh)`
108
+
109
+ Handles download and caching of HTTPS extensions.
110
+
111
+ ## Security Considerations
112
+
113
+ - **HTTPS Only**: Remote extensions must use HTTPS protocol
114
+ - **Size Limits**: Downloads are limited by `TWIN_EXTENSIONS_MAX_SIZE_MB`
115
+ - **Cache TTL**: Extensions are automatically refreshed based on TTL
116
+ - **Security Warnings**: Warnings are displayed when loading remote extensions
117
+
118
+ ## Troubleshooting
119
+
120
+ ### Common Issues
121
+
122
+ 1. **Extension not found**: Check that the path/URL is correct and accessible
123
+ 2. **Cache issues**: Use `TWIN_EXTENSIONS_FORCE_REFRESH=true` to force refresh
124
+ 3. **Size limit exceeded**: Increase `TWIN_EXTENSIONS_MAX_SIZE_MB` if needed
125
+ 4. **Network issues**: Ensure HTTPS URLs are accessible and not blocked by firewall
126
+
127
+ ### Debug Mode
128
+
129
+ Set `NODE_ENV=development` for additional debug output during extension loading.
@@ -14,7 +14,7 @@ The engine core for the node.
14
14
 
15
15
  ### context
16
16
 
17
- `IEngineCoreContext`\<`IEngineServerConfig`, `IEngineState`\>
17
+ `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
18
 
19
19
  The context for the node.
20
20
 
@@ -14,7 +14,7 @@ The engine core for the node.
14
14
 
15
15
  ### context
16
16
 
17
- `IEngineCoreContext`\<`IEngineServerConfig`, `IEngineState`\>
17
+ `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
18
 
19
19
  The context for the node.
20
20
 
@@ -14,7 +14,7 @@ The engine core for the node.
14
14
 
15
15
  ### context
16
16
 
17
- `IEngineCoreContext`\<`IEngineServerConfig`, `IEngineState`\>
17
+ `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
18
 
19
19
  The context for the node.
20
20
 
@@ -0,0 +1,35 @@
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`\>
@@ -14,7 +14,7 @@ The engine core for the node.
14
14
 
15
15
  ### context
16
16
 
17
- `IEngineCoreContext`\<`IEngineServerConfig`, `IEngineState`\>
17
+ `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
18
 
19
19
  The context for the node.
20
20
 
@@ -1,6 +1,6 @@
1
- # Function: bootstrapNodeUser()
1
+ # Function: bootstrapNodeAdminUser()
2
2
 
3
- > **bootstrapNodeUser**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
3
+ > **bootstrapNodeAdminUser**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
4
 
5
5
  Bootstrap the user.
6
6
 
@@ -14,7 +14,7 @@ The engine core for the node.
14
14
 
15
15
  ### context
16
16
 
17
- `IEngineCoreContext`\<`IEngineServerConfig`, `IEngineState`\>
17
+ `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
18
 
19
19
  The context for the node.
20
20
 
@@ -1,6 +1,6 @@
1
- # Function: bootstrapNodeIdentity()
1
+ # Function: bootstrapNodeId()
2
2
 
3
- > **bootstrapNodeIdentity**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
3
+ > **bootstrapNodeId**(`engineCore`, `context`, `envVars`, `features`): `Promise`\<`void`\>
4
4
 
5
5
  Bootstrap the node creating any necessary resources.
6
6
 
@@ -14,7 +14,7 @@ The engine core for the node.
14
14
 
15
15
  ### context
16
16
 
17
- `IEngineCoreContext`\<`IEngineServerConfig`, `IEngineState`\>
17
+ `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
18
 
19
19
  The context for the node.
20
20
 
@@ -14,7 +14,7 @@ The engine core for the node.
14
14
 
15
15
  ### context
16
16
 
17
- `IEngineCoreContext`\<`IEngineServerConfig`, `IEngineState`\>
17
+ `IEngineCoreContext`\<`IEngineServerConfig`, [`INodeEngineState`](../interfaces/INodeEngineState.md)\>
18
18
 
19
19
  The context for the node.
20
20
 
@@ -0,0 +1,35 @@
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,6 +1,6 @@
1
1
  # Function: buildConfiguration()
2
2
 
3
- > **buildConfiguration**(`processEnv`, `options`, `serverInfo`): `Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `engineServerConfig`: `IEngineServerConfig`; \}\>
3
+ > **buildConfiguration**(`processEnv`, `options`, `serverInfo`): `Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `nodeEngineConfig`: [`INodeEngineConfig`](../interfaces/INodeEngineConfig.md); `contextIdKeys`: `string`[]; \}\>
4
4
 
5
5
  Build the configuration for the TWIN Node server.
6
6
 
@@ -24,7 +24,7 @@ The server information.
24
24
 
25
25
  ## Returns
26
26
 
27
- `Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `engineServerConfig`: `IEngineServerConfig`; \}\>
27
+ `Promise`\<\{ `nodeEnvVars`: [`INodeEnvironmentVariables`](../interfaces/INodeEnvironmentVariables.md) & `object`; `nodeEngineConfig`: [`INodeEngineConfig`](../interfaces/INodeEngineConfig.md); `contextIdKeys`: `string`[]; \}\>
28
28
 
29
29
  A promise that resolves to the engine server configuration, environment prefix, environment variables,
30
30
  and options.
@@ -1,6 +1,6 @@
1
1
  # Function: buildEngineConfiguration()
2
2
 
3
- > **buildEngineConfiguration**(`envVars`): `IEngineConfig`
3
+ > **buildEngineConfiguration**(`envVars`, `contextIdKeys`): `Promise`\<`IEngineConfig`\>
4
4
 
5
5
  Build the engine core configuration from environment variables.
6
6
 
@@ -12,8 +12,14 @@ Build the engine core configuration from environment variables.
12
12
 
13
13
  The environment variables.
14
14
 
15
+ ### contextIdKeys
16
+
17
+ `string`[]
18
+
19
+ The context ID keys.
20
+
15
21
  ## Returns
16
22
 
17
- `IEngineConfig`
23
+ `Promise`\<`IEngineConfig`\>
18
24
 
19
25
  The config for the core.
@@ -1,6 +1,6 @@
1
1
  # Function: buildEngineServerConfiguration()
2
2
 
3
- > **buildEngineServerConfiguration**(`envVars`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath?`, `favIconPath?`): `IEngineServerConfig`
3
+ > **buildEngineServerConfiguration**(`envVars`, `contextIdKeys`, `coreEngineConfig`, `serverInfo`, `openApiSpecPath?`, `favIconPath?`): `Promise`\<`IEngineServerConfig`\>
4
4
 
5
5
  Handles the configuration of the server.
6
6
 
@@ -12,6 +12,12 @@ Handles the configuration of the server.
12
12
 
13
13
  The environment variables for the engine server.
14
14
 
15
+ ### contextIdKeys
16
+
17
+ `string`[]
18
+
19
+ The context ID keys.
20
+
15
21
  ### coreEngineConfig
16
22
 
17
23
  `IEngineCoreConfig`
@@ -38,6 +44,6 @@ The path to the favicon.
38
44
 
39
45
  ## Returns
40
46
 
41
- `IEngineServerConfig`
47
+ `Promise`\<`IEngineServerConfig`\>
42
48
 
43
- The the config for the core and the server.
49
+ The config for the core and the server.