@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,11 +1,20 @@
1
- export * from "./bootstrap";
2
- export * from "./builders/engineEnvBuilder";
3
- export * from "./builders/engineServerEnvBuilder";
4
- export * from "./models/IEngineEnvironmentVariables";
5
- export * from "./models/IEngineServerEnvironmentVariables";
6
- export * from "./models/INodeEnvironmentVariables";
7
- export * from "./models/INodeOptions";
8
- export * from "./models/nodeFeatures";
9
- export * from "./node";
10
- export * from "./server";
11
- export * from "./utils";
1
+ export * from "./bootstrap.js";
2
+ export * from "./builders/engineEnvBuilder.js";
3
+ export * from "./builders/engineServerEnvBuilder.js";
4
+ export * from "./builders/extensionsBuilder.js";
5
+ export * from "./defaults.js";
6
+ export * from "./models/ICacheMetadata.js";
7
+ export * from "./models/IEngineEnvironmentVariables.js";
8
+ export * from "./models/IEngineServerEnvironmentVariables.js";
9
+ export * from "./models/IModuleProtocol.js";
10
+ export * from "./models/INodeEngineConfig.js";
11
+ export * from "./models/INodeEngineState.js";
12
+ export * from "./models/INodeEnvironmentVariables.js";
13
+ export * from "./models/INodeOptions.js";
14
+ export * from "./models/IProtocolHandlerResult.js";
15
+ export * from "./models/moduleProtocol.js";
16
+ export * from "./models/nodeExtensionMethods.js";
17
+ export * from "./models/nodeFeatures.js";
18
+ export * from "./node.js";
19
+ export * from "./server.js";
20
+ export * from "./utils.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Metadata for cached HTTPS extensions.
3
+ */
4
+ export interface ICacheMetadata {
5
+ /**
6
+ * Timestamp when the file was downloaded.
7
+ */
8
+ downloadedAt: number;
9
+ /**
10
+ * Original URL of the cached file.
11
+ */
12
+ url: string;
13
+ /**
14
+ * Size of the cached file in bytes.
15
+ */
16
+ size: number;
17
+ }
@@ -14,6 +14,18 @@ export interface IEngineEnvironmentVariables {
14
14
  * The name of the state file.
15
15
  */
16
16
  stateFilename?: string;
17
+ /**
18
+ * Is multi-tenant support enabled, defaults to false.
19
+ */
20
+ tenantEnabled?: string;
21
+ /**
22
+ * A tenant id to use as a default for the node.
23
+ */
24
+ tenantId?: string;
25
+ /**
26
+ * A tenant api key to use as a default for the node.
27
+ */
28
+ tenantApiKey?: string;
17
29
  /**
18
30
  * The type of the entity storage to create, comma separate for more than one connector.
19
31
  * values: file, memory, aws-dynamodb, azure-cosmosdb, gcp-firestoredb, scylladb, mysql, mongodb, postgresql
@@ -27,6 +39,10 @@ export interface IEngineEnvironmentVariables {
27
39
  * A prefix for all the table in entity-storage, can be empty.
28
40
  */
29
41
  entityStorageTablePrefix?: string;
42
+ /**
43
+ * AWS DynamoDB auth mode, either credentials or pod.
44
+ */
45
+ awsDynamodbAuthMode?: string;
30
46
  /**
31
47
  * AWS Dynamo DB access key id.
32
48
  */
@@ -194,25 +210,29 @@ export interface IEngineEnvironmentVariables {
194
210
  */
195
211
  blobStoragePrefix?: string;
196
212
  /**
197
- * AWS S3 access key id.
213
+ * AWS S3 region.
198
214
  */
199
- awsS3AccessKeyId?: string;
215
+ awsS3Region?: string;
200
216
  /**
201
217
  * AWS S3 bucket name.
202
218
  */
203
219
  awsS3BucketName?: string;
204
220
  /**
205
- * AWS S3 endpoint.
221
+ * AWS S3 auth mode, either credentials or pod, defaults to credentials.
206
222
  */
207
- awsS3Endpoint?: string;
223
+ awsS3AuthMode?: string;
208
224
  /**
209
- * AWS S3 region.
225
+ * AWS S3 access key id.
210
226
  */
211
- awsS3Region?: string;
227
+ awsS3AccessKeyId?: string;
212
228
  /**
213
229
  * AWS S3 secret access key.
214
230
  */
215
231
  awsS3SecretAccessKey?: string;
232
+ /**
233
+ * AWS S3 endpoint.
234
+ */
235
+ awsS3Endpoint?: string;
216
236
  /**
217
237
  * Azure Storage account key.
218
238
  */
@@ -258,7 +278,7 @@ export interface IEngineEnvironmentVariables {
258
278
  */
259
279
  hashicorpVaultEndpoint?: string;
260
280
  /**
261
- * The type of background task connector, can be a comma separated list: console, entity-storage.
281
+ * The type of logging task connector, can be a comma separated list: console, entity-storage.
262
282
  */
263
283
  loggingConnector?: string;
264
284
  /**
@@ -274,25 +294,45 @@ export interface IEngineEnvironmentVariables {
274
294
  */
275
295
  eventBusComponent?: string;
276
296
  /**
277
- * The type of messaging email connector: entity-storage, aws.
297
+ * Are the messaging components enabled, defaults to false.
278
298
  */
279
- messagingEmailConnector?: string;
299
+ messagingEnabled?: string;
280
300
  /**
281
- * The type of messaging sms connector: entity-storage, aws.
301
+ * AWS SES region.
282
302
  */
283
- messagingSmsConnector?: string;
303
+ awsSesRegion?: string;
284
304
  /**
285
- * The type of messaging push notification connector: entity-storage, aws.
305
+ * AWS SES auth mode, either credentials or pod, defaults to credentials.
286
306
  */
287
- messagingPushNotificationConnector?: string;
307
+ awsSesAuthMode?: string;
308
+ /**
309
+ * AWS SES secret access key.
310
+ */
311
+ awsSesSecretAccessKey?: string;
312
+ /**
313
+ * AWS SES access key id.
314
+ */
315
+ awsSesAccessKeyId?: string;
316
+ /**
317
+ * AWS SES endpoint.
318
+ */
319
+ awsSesEndpoint?: string;
288
320
  /**
289
321
  * The applications for the push notifications JSON stringified array of IAwsApplicationSettings.
290
322
  */
291
323
  awsMessagingPushNotificationApplications?: string;
292
324
  /**
293
- * The type of messaging component: service.
325
+ * The type of messaging email connector: entity-storage, aws.
326
+ */
327
+ messagingEmailConnector?: string;
328
+ /**
329
+ * The type of messaging sms connector: entity-storage, aws.
294
330
  */
295
- messagingComponent?: string;
331
+ messagingSmsConnector?: string;
332
+ /**
333
+ * The type of messaging push notification connector: entity-storage, aws.
334
+ */
335
+ messagingPushNotificationConnector?: string;
296
336
  /**
297
337
  * The type of telemetry connector: entity-storage.
298
338
  */
@@ -369,6 +409,10 @@ export interface IEngineEnvironmentVariables {
369
409
  * The identity verification method id to use with attestation.
370
410
  */
371
411
  attestationVerificationMethodId?: string;
412
+ /**
413
+ * Is the data processing enabled, defaults to false.
414
+ */
415
+ dataProcessingEnabled?: string;
372
416
  /**
373
417
  * The type of the default data converters, can be a comma separated list: json, xml.
374
418
  */
@@ -377,6 +421,18 @@ export interface IEngineEnvironmentVariables {
377
421
  * The type of the default data extractor, can be a comma separated list: json-path.
378
422
  */
379
423
  dataExtractorConnectors?: string;
424
+ /**
425
+ * Is the auditable item graph enabled, defaults to false.
426
+ */
427
+ auditableItemGraphEnabled?: string;
428
+ /**
429
+ * Is the auditable item stream enabled, defaults to false.
430
+ */
431
+ auditableItemStreamEnabled?: string;
432
+ /**
433
+ * Is the document management enabled, defaults to false.
434
+ */
435
+ documentManagementEnabled?: string;
380
436
  /**
381
437
  * Is the synchronised storage enabled, defaults to false.
382
438
  */
@@ -387,14 +443,9 @@ export interface IEngineEnvironmentVariables {
387
443
  synchronisedStorageTrustedUrl?: string;
388
444
  /**
389
445
  * The key for the smart contract which contains the verifiable storage pointer store for synchronised storage.
390
- * This only required if using a custom verifiable storage item, otherwise it will default the the network name.
446
+ * This only required if using a custom verifiable storage item, otherwise it will default to the network name.
391
447
  */
392
448
  synchronisedStorageVerifiableStorageKeyId?: string;
393
- /**
394
- * The identity verification method id to use with synchronised storage for signing/verifying changesets.
395
- * Defaults to synchronised-storage-assertion.
396
- */
397
- synchronisedStorageVerificationMethodId?: string;
398
449
  /**
399
450
  * The key from the vault which is used to encrypt the synchronised storage blobs.
400
451
  * Only required for trusted nodes, as regular nodes will request from the trusted nodes.
@@ -442,6 +493,45 @@ export interface IEngineEnvironmentVariables {
442
493
  * Is the rights management enabled, defaults to false.
443
494
  */
444
495
  rightsManagementEnabled?: string;
496
+ /**
497
+ * What is the base callback url for rights management negotiations e.g. https://my-node/rights-management.
498
+ */
499
+ rightsManagementBaseCallbackUrl?: string;
500
+ /**
501
+ * The rights management configuration which includes the information sources modules to load.
502
+ * Use the @json: prefix to specify the path to the JSON configuration file.
503
+ */
504
+ rightsManagementInformationSources?: string;
505
+ /**
506
+ * The rights management configuration which includes the negotiator modules to load.
507
+ * Use the @json: prefix to specify the path to the JSON configuration file.
508
+ */
509
+ rightsManagementNegotiators?: string;
510
+ /**
511
+ * The rights management configuration which includes the requester modules to load.
512
+ * Use the @json: prefix to specify the path to the JSON configuration file.
513
+ */
514
+ rightsManagementRequesters?: string;
515
+ /**
516
+ * The rights management configuration which includes the execution actions modules to load.
517
+ * Use the @json: prefix to specify the path to the JSON configuration file.
518
+ */
519
+ rightsManagementExecutionActions?: string;
520
+ /**
521
+ * The rights management configuration which includes the enforcement processor modules to load.
522
+ * Use the @json: prefix to specify the path to the JSON configuration file.
523
+ */
524
+ rightsManagementEnforcementProcessors?: string;
525
+ /**
526
+ * The rights management configuration which includes the arbiter modules to load.
527
+ * Use the @json: prefix to specify the path to the JSON configuration file.
528
+ */
529
+ rightsManagementArbiters?: string;
530
+ /**
531
+ * The rights management configuration which includes the offer modules to load.
532
+ * Use the @json: prefix to specify the path to the JSON configuration file.
533
+ */
534
+ rightsManagementOffers?: string;
445
535
  /**
446
536
  * Is the task scheduler enabled, defaults to false.
447
537
  */
@@ -451,8 +541,26 @@ export interface IEngineEnvironmentVariables {
451
541
  */
452
542
  dataSpaceConnectorEnabled?: string;
453
543
  /**
454
- * The application configuration for the data space connector.
455
- * Use the @json: prefix to specify the path to the JSON configuration file.
544
+ * The length of time to retain the activity logs for in minutes, set to -1 to keep forever.
545
+ * @default 10
546
+ */
547
+ dataSpaceConnectorRetainActivityLogsFor?: string;
548
+ /**
549
+ * The interval for cleaning up the activity logs.
550
+ * @default 60
551
+ */
552
+ dataSpaceConnectorActivityLogsCleanUpInterval?: string;
553
+ /**
554
+ * Enable verifiable credential authentication for the API.
555
+ */
556
+ vcAuthenticationEnabled?: string;
557
+ /**
558
+ * Verifiable credential assertion for node to node communication.
559
+ * Defaults to node-authentication-assertion.
560
+ */
561
+ vcAuthenticationVerificationMethodId?: string;
562
+ /**
563
+ * A comma separated list of additional node extensions to load, the initialiseExtension method will be called for each extension.
456
564
  */
457
- dataSpaceConnectorApps?: string;
565
+ extensions?: string;
458
566
  }
@@ -1,7 +1,8 @@
1
+ import type { IEngineEnvironmentVariables } from "./IEngineEnvironmentVariables.js";
1
2
  /**
2
3
  * The engine server environment variables.
3
4
  */
4
- export interface IEngineServerEnvironmentVariables {
5
+ export interface IEngineServerEnvironmentVariables extends IEngineEnvironmentVariables {
5
6
  /**
6
7
  * The port to serve the API from.
7
8
  */
@@ -43,7 +44,15 @@ export interface IEngineServerEnvironmentVariables {
43
44
  */
44
45
  mimeTypeProcessors?: string;
45
46
  /**
46
- * Disable Node Identity route processors.
47
+ * Include the body in the REST logging output, useful for debugging.
47
48
  */
48
- disableNodeIdentity?: string;
49
+ routeLoggingIncludeBody?: string;
50
+ /**
51
+ * Include the full base 64 output in the REST logging output, useful for debugging.
52
+ */
53
+ routeLoggingFullBase64?: string;
54
+ /**
55
+ * List of properties to obfuscate in the REST logging output, comma separated.
56
+ */
57
+ routeLoggingObfuscateProperties?: string;
49
58
  }
@@ -0,0 +1,18 @@
1
+ import type { ModuleProtocol } from "./moduleProtocol.js";
2
+ /**
3
+ * The parsed module protocol information.
4
+ */
5
+ export interface IModuleProtocol {
6
+ /**
7
+ * The protocol type.
8
+ */
9
+ protocol: ModuleProtocol;
10
+ /**
11
+ * The identifier after the protocol (or the original if no protocol).
12
+ */
13
+ identifier: string;
14
+ /**
15
+ * The original module string.
16
+ */
17
+ original: string;
18
+ }
@@ -0,0 +1,6 @@
1
+ import type { IEngineServerConfig } from "@twin.org/engine-server-types";
2
+ /**
3
+ * The config for the node.
4
+ */
5
+ export interface INodeEngineConfig extends IEngineServerConfig {
6
+ }
@@ -0,0 +1,22 @@
1
+ import type { IEngineState } from "@twin.org/engine-models";
2
+ /**
3
+ * The engine state for the node.
4
+ */
5
+ export interface INodeEngineState extends IEngineState {
6
+ /**
7
+ * The identity for the node.
8
+ */
9
+ nodeId?: string;
10
+ /**
11
+ * The tenant id for the node.
12
+ */
13
+ nodeTenantId?: string;
14
+ /**
15
+ * The identity for the organization.
16
+ */
17
+ nodeOrganizationId?: string;
18
+ /**
19
+ * The identity for the admin user.
20
+ */
21
+ nodeAdminUserId?: string;
22
+ }
@@ -1,29 +1,69 @@
1
- import type { IEngineEnvironmentVariables } from "./IEngineEnvironmentVariables";
2
- import type { IEngineServerEnvironmentVariables } from "./IEngineServerEnvironmentVariables";
1
+ import type { IEngineServerEnvironmentVariables } from "./IEngineServerEnvironmentVariables.js";
3
2
  /**
4
3
  * The environment variables for the node.
5
4
  */
6
- export interface INodeEnvironmentVariables extends IEngineEnvironmentVariables, IEngineServerEnvironmentVariables {
5
+ export interface INodeEnvironmentVariables extends IEngineServerEnvironmentVariables {
7
6
  /**
8
7
  * The features that are enabled on the node.
9
- * @default [NodeFeatures.NodeIdentity]
8
+ * @default []
10
9
  */
11
10
  features?: string;
12
11
  /**
13
12
  * The identity of the node which, if empty and node-identity feature is enabled it will be generated.
14
13
  */
15
- identity?: string;
14
+ nodeIdentity?: string;
16
15
  /**
17
16
  * The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.
18
17
  */
19
- mnemonic?: string;
18
+ nodeMnemonic?: string;
20
19
  /**
21
- * If the node-user feature is enabled, this will be the name of the user.
20
+ * 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
21
+ */
22
+ organizationIdentity?: string;
23
+ /**
24
+ * The mnemonic for the organization, if empty and node-admin-user feature is enabled it will be randomly generated.
25
+ */
26
+ organizationMnemonic?: string;
27
+ /**
28
+ * 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
29
+ */
30
+ adminUserIdentity?: string;
31
+ /**
32
+ * The mnemonic for the admin user, if empty and node-admin-user feature is enabled it will be randomly generated.
33
+ */
34
+ adminUserMnemonic?: string;
35
+ /**
36
+ * If the node-admin-user feature is enabled, this will be the name of the user.
22
37
  * @default admin@node
23
38
  */
24
- username?: string;
39
+ adminUserName?: string;
40
+ /**
41
+ * If the node-admin-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.
42
+ */
43
+ adminUserPassword?: string;
44
+ /**
45
+ * Maximum size in MB for HTTPS extensions downloads.
46
+ * @default 10
47
+ */
48
+ extensionsMaxSizeMb?: number;
49
+ /**
50
+ * Whether to clear the extensions cache on startup.
51
+ * @default false
52
+ */
53
+ extensionsClearCache?: boolean;
54
+ /**
55
+ * Custom directory for extensions cache storage.
56
+ * @default ".tmp"
57
+ */
58
+ extensionsCacheDirectory?: string;
59
+ /**
60
+ * TTL in hours for HTTPS extensions cache.
61
+ * @default 24
62
+ */
63
+ extensionsCacheTtlHours?: number;
25
64
  /**
26
- * If the node-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.
65
+ * Force refresh of all cached extensions.
66
+ * @default false
27
67
  */
28
- password?: string;
68
+ extensionsForceRefresh?: boolean;
29
69
  }
@@ -1,6 +1,7 @@
1
1
  import type { IEngineCore, IEngineServer, IEngineStateStorage } from "@twin.org/engine-models";
2
2
  import type { IEngineConfig } from "@twin.org/engine-types";
3
- import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables";
3
+ import type { INodeEngineConfig } from "./INodeEngineConfig.js";
4
+ import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
4
5
  /**
5
6
  * The options when running the node.
6
7
  */
@@ -14,12 +15,18 @@ export interface INodeOptions {
14
15
  * The version of the server, defaults to the current version.
15
16
  */
16
17
  serverVersion?: string;
18
+ /**
19
+ * Additional environment variables to set.
20
+ */
21
+ envVars?: {
22
+ [key: string]: string;
23
+ };
17
24
  /**
18
25
  * Additional environment variable filenames to load, defaults to .env.
19
26
  */
20
27
  envFilenames?: string[];
21
28
  /**
22
- * The prefix for environment variables, defaults to "TWIN_NODE_".
29
+ * The prefix for environment variables, defaults to "TWIN_".
23
30
  */
24
31
  envPrefix?: string;
25
32
  /**
@@ -56,7 +63,7 @@ export interface INodeOptions {
56
63
  /**
57
64
  * Method to extend the engine configuration with any additional custom configuration.
58
65
  */
59
- extendConfig?: (config: IEngineConfig) => Promise<void>;
66
+ extendConfig?: (envVars: INodeEnvironmentVariables, config: INodeEngineConfig) => Promise<void>;
60
67
  /**
61
68
  * Method to extend the engine with any additional options.
62
69
  */
@@ -70,4 +77,8 @@ export interface INodeOptions {
70
77
  * If not provided, a default file-based state storage will be used.
71
78
  */
72
79
  stateStorage?: IEngineStateStorage;
80
+ /**
81
+ * Disables process.exit calls on fatal errors and throws instead.
82
+ */
83
+ disableProcessExitOnFailure?: boolean;
73
84
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The result from a protocol handler.
3
+ */
4
+ export interface IProtocolHandlerResult {
5
+ /**
6
+ * The resolved path to the module file.
7
+ */
8
+ resolvedPath: string;
9
+ /**
10
+ * Whether the module was cached.
11
+ */
12
+ cached: boolean;
13
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The protocol types for modules.
3
+ */
4
+ export declare const ModuleProtocol: {
5
+ /**
6
+ * Local module (starts with . or / or file://).
7
+ */
8
+ readonly Local: "local";
9
+ /**
10
+ * NPM package (starts with npm:).
11
+ */
12
+ readonly Npm: "npm";
13
+ /**
14
+ * HTTPS URL (starts with https://).
15
+ */
16
+ readonly Https: "https";
17
+ /**
18
+ * HTTP URL (starts with http://).
19
+ */
20
+ readonly Http: "http";
21
+ /**
22
+ * Default/standard module resolution.
23
+ */
24
+ readonly Default: "default";
25
+ };
26
+ /**
27
+ * The protocol type for a module.
28
+ */
29
+ export type ModuleProtocol = (typeof ModuleProtocol)[keyof typeof ModuleProtocol];
@@ -0,0 +1,27 @@
1
+ import type { IEngineCore, IEngineServer } from "@twin.org/engine-models";
2
+ import type { INodeEngineConfig } from "./INodeEngineConfig.js";
3
+ import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
4
+ /**
5
+ * The type for the initialise method of an extension module.
6
+ * @param envVars The environment variables for the node.
7
+ * @param nodeEngineConfig The node engine config.
8
+ */
9
+ export type NodeExtensionInitialiseMethod = (envVars: INodeEnvironmentVariables, nodeEngineConfig: INodeEngineConfig) => Promise<void>;
10
+ /**
11
+ * The type for the initialise engine method of an extension module.
12
+ * This is called when the engine has been constructed but not yet started.
13
+ * @param engineCore The engine core instance.
14
+ */
15
+ export type NodeExtensionInitialiseEngineMethod = (engineCore: IEngineCore) => Promise<void>;
16
+ /**
17
+ * The type for the initialise engine server method of an extension module.
18
+ * This is called when the engine server has been constructed but not yet started.
19
+ * @param engineCore The engine core instance.
20
+ * @param engineServer The engine server instance.
21
+ */
22
+ export type NodeExtensionInitialiseEngineServerMethod = (engineCore: IEngineCore, engineServer: IEngineServer) => Promise<void>;
23
+ /**
24
+ * The type for the shutdown method of an extension module.
25
+ * This is called when the engine is shutting down.
26
+ */
27
+ export type NodeExtensionShutdownMethod = () => Promise<void>;
@@ -3,15 +3,15 @@
3
3
  */
4
4
  export declare const NodeFeatures: {
5
5
  /**
6
- * NodeIdentity - generates an identity for the node if not provided in config.
6
+ * NodeId - generates an identity for the node if not provided in config.
7
7
  */
8
- readonly NodeIdentity: "node-identity";
8
+ readonly NodeId: "node-identity";
9
9
  /**
10
- * NodeUser - generates a user for the node if not provided in config.
10
+ * NodeAdminUser - generates an admin user for the node if not provided in config.
11
11
  */
12
- readonly NodeUser: "node-user";
12
+ readonly NodeAdminUser: "node-admin-user";
13
13
  /**
14
- * NodeWallet - generates a wallet for the node and funds it when there is a faucet available.
14
+ * NodeWallet - generates wallets for any identities that need them.
15
15
  */
16
16
  readonly NodeWallet: "node-wallet";
17
17
  };
@@ -1,13 +1,21 @@
1
1
  import type { IServerInfo } from "@twin.org/api-models";
2
+ import type { Engine } from "@twin.org/engine";
3
+ import type { EngineServer } from "@twin.org/engine-server";
2
4
  import type { IEngineServerConfig } from "@twin.org/engine-server-types";
3
- import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
4
- import type { INodeOptions } from "./models/INodeOptions";
5
+ import type { INodeEngineConfig } from "./models/INodeEngineConfig.js";
6
+ import type { INodeEngineState } from "./models/INodeEngineState.js";
7
+ import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
8
+ import type { INodeOptions } from "./models/INodeOptions.js";
5
9
  /**
6
10
  * Run the TWIN Node server.
7
11
  * @param nodeOptions Optional configuration options for running the server.
8
- * @returns A promise that resolves when the server is started.
12
+ * @returns A promise that resolves when the server is started containing a shutdown method.
9
13
  */
10
- export declare function run(nodeOptions?: INodeOptions): Promise<void>;
14
+ export declare function run(nodeOptions?: INodeOptions): Promise<{
15
+ engine: Engine<IEngineServerConfig, INodeEngineState>;
16
+ server: EngineServer;
17
+ shutdown: () => Promise<void>;
18
+ } | undefined>;
11
19
  /**
12
20
  * Build the configuration for the TWIN Node server.
13
21
  * @param processEnv The environment variables from the process.
@@ -22,10 +30,12 @@ export declare function buildConfiguration(processEnv: {
22
30
  nodeEnvVars: INodeEnvironmentVariables & {
23
31
  [id: string]: string | unknown;
24
32
  };
25
- engineServerConfig: IEngineServerConfig;
33
+ nodeEngineConfig: INodeEngineConfig;
34
+ contextIdKeys: string[];
26
35
  }>;
27
36
  /**
28
- * Override module imports to use local files where possible.
37
+ * Override module imports to support protocol-based loading (npm:, https:) and local files.
29
38
  * @param executionDirectory The execution directory for resolving local module paths.
39
+ * @param envVars The environment variables containing extension configuration (optional, uses defaults if not provided).
30
40
  */
31
- export declare function overrideModuleImport(executionDirectory: string): void;
41
+ export declare function overrideModuleImport(executionDirectory: string, envVars?: INodeEnvironmentVariables): void;
@@ -1,17 +1,20 @@
1
1
  import { Engine } from "@twin.org/engine";
2
- import { type IEngineState } from "@twin.org/engine-models";
3
2
  import { EngineServer } from "@twin.org/engine-server";
4
3
  import type { IEngineServerConfig } from "@twin.org/engine-server-types";
5
- import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables";
6
- import type { INodeOptions } from "./models/INodeOptions";
4
+ import type { INodeEngineConfig } from "./models/INodeEngineConfig.js";
5
+ import type { INodeEngineState } from "./models/INodeEngineState.js";
6
+ import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
7
+ import type { INodeOptions } from "./models/INodeOptions.js";
7
8
  /**
8
9
  * Start the engine server.
9
10
  * @param nodeOptions Optional run options for the engine server.
10
- * @param engineServerConfig The configuration for the engine server.
11
+ * @param nodeEngineConfig The configuration for the engine server.
11
12
  * @param envVars The environment variables.
13
+ * @param contextIdKeys The context ID keys.
12
14
  * @returns The engine server.
13
15
  */
14
- export declare function start(nodeOptions: INodeOptions | undefined, engineServerConfig: IEngineServerConfig, envVars: INodeEnvironmentVariables): Promise<{
15
- engine: Engine<IEngineServerConfig, IEngineState>;
16
+ export declare function start(nodeOptions: INodeOptions | undefined, nodeEngineConfig: INodeEngineConfig, envVars: INodeEnvironmentVariables, contextIdKeys?: string[]): Promise<{
17
+ engine: Engine<IEngineServerConfig, INodeEngineState>;
16
18
  server: EngineServer;
19
+ shutdown: () => Promise<void>;
17
20
  } | undefined>;