@twin.org/node-core 0.0.3-next.53 → 0.0.3-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/builders/engineEnvBuilder.js +52 -10
- package/dist/es/builders/engineEnvBuilder.js.map +1 -1
- package/dist/es/builders/engineServerEnvBuilder.js +32 -32
- package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
- package/dist/es/builders/extensionsBuilder.js +3 -3
- package/dist/es/builders/extensionsBuilder.js.map +1 -1
- package/dist/es/cli.js +6 -3
- package/dist/es/cli.js.map +1 -1
- package/dist/es/commands/bootstrapLegacy.js +173 -116
- package/dist/es/commands/bootstrapLegacy.js.map +1 -1
- package/dist/es/commands/help.js +1 -0
- package/dist/es/commands/help.js.map +1 -1
- package/dist/es/commands/identityCreate.js +38 -16
- package/dist/es/commands/identityCreate.js.map +1 -1
- package/dist/es/commands/identityImports.js +1 -0
- package/dist/es/commands/identityImports.js.map +1 -1
- package/dist/es/commands/identityVerificationMethodCreate.js +13 -11
- package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -1
- package/dist/es/commands/identityVerificationMethodImport.js +2 -1
- package/dist/es/commands/identityVerificationMethodImport.js.map +1 -1
- package/dist/es/commands/nodeSetIdentity.js +5 -0
- package/dist/es/commands/nodeSetIdentity.js.map +1 -1
- package/dist/es/commands/removeTenantOrgAlias.js +3 -1
- package/dist/es/commands/removeTenantOrgAlias.js.map +1 -1
- package/dist/es/commands/setNodeOrgId.js +2 -0
- package/dist/es/commands/setNodeOrgId.js.map +1 -1
- package/dist/es/commands/setTenantOrgId.js +7 -66
- package/dist/es/commands/setTenantOrgId.js.map +1 -1
- package/dist/es/commands/tenantCreate.js +1 -7
- package/dist/es/commands/tenantCreate.js.map +1 -1
- package/dist/es/commands/tenantImport.js +17 -4
- package/dist/es/commands/tenantImport.js.map +1 -1
- package/dist/es/commands/tenantUpdate.js +21 -6
- package/dist/es/commands/tenantUpdate.js.map +1 -1
- package/dist/es/commands/vaultKeyImport.js +4 -3
- package/dist/es/commands/vaultKeyImport.js.map +1 -1
- package/dist/es/defaults.js +21 -0
- package/dist/es/defaults.js.map +1 -1
- package/dist/es/models/ICliArgs.js.map +1 -1
- package/dist/es/models/ICliCommand.js.map +1 -1
- package/dist/es/models/ICliCommandDefinition.js.map +1 -1
- package/dist/es/models/ICliCommandDefinitionParam.js.map +1 -1
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
- package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
- package/dist/es/models/nodeExtensionInitialiseEngineMethod.js.map +1 -1
- package/dist/es/models/nodeExtensionInitialiseEngineServerMethod.js.map +1 -1
- package/dist/es/models/nodeExtensionInitialiseMethod.js.map +1 -1
- package/dist/es/models/nodeExtensionShutdownMethod.js.map +1 -1
- package/dist/es/node.js +1 -1
- package/dist/es/node.js.map +1 -1
- package/dist/es/start.js +11 -13
- package/dist/es/start.js.map +1 -1
- package/dist/es/utils.js +5 -4
- package/dist/es/utils.js.map +1 -1
- package/dist/types/builders/engineEnvBuilder.d.ts +4 -4
- package/dist/types/builders/extensionsBuilder.d.ts +3 -3
- package/dist/types/cli.d.ts +2 -2
- package/dist/types/commands/bootstrapLegacy.d.ts +8 -7
- package/dist/types/commands/help.d.ts +1 -0
- package/dist/types/commands/identityCreate.d.ts +2 -0
- package/dist/types/commands/identityImports.d.ts +1 -0
- package/dist/types/commands/identityVerificationMethodImport.d.ts +2 -1
- package/dist/types/commands/nodeSetIdentity.d.ts +1 -0
- package/dist/types/commands/removeTenantOrgAlias.d.ts +2 -0
- package/dist/types/commands/setNodeOrgId.d.ts +2 -0
- package/dist/types/commands/setTenantOrgId.d.ts +5 -22
- package/dist/types/commands/tenantImport.d.ts +7 -4
- package/dist/types/commands/tenantUpdate.d.ts +5 -2
- package/dist/types/commands/vaultKeyImport.d.ts +4 -3
- package/dist/types/defaults.d.ts +21 -0
- package/dist/types/models/ICliArgs.d.ts +1 -1
- package/dist/types/models/ICliCommand.d.ts +1 -1
- package/dist/types/models/ICliCommandDefinition.d.ts +2 -2
- package/dist/types/models/ICliCommandDefinitionParam.d.ts +1 -1
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +0 -4
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +4 -0
- package/dist/types/models/nodeExtensionInitialiseEngineMethod.d.ts +1 -0
- package/dist/types/models/nodeExtensionInitialiseEngineServerMethod.d.ts +1 -0
- package/dist/types/models/nodeExtensionInitialiseMethod.d.ts +1 -0
- package/dist/types/models/nodeExtensionShutdownMethod.d.ts +1 -0
- package/dist/types/utils.d.ts +4 -3
- package/docs/changelog.md +15 -0
- package/docs/reference/functions/extensionsInitialiseEngine.md +1 -1
- package/docs/reference/functions/extensionsInitialiseEngineServer.md +1 -1
- package/docs/reference/functions/getScriptDirectory.md +1 -1
- package/docs/reference/functions/initialiseLocales.md +2 -0
- package/docs/reference/functions/isFederatedCatalogueRequired.md +3 -3
- package/docs/reference/functions/isRightsManagementRequired.md +1 -1
- package/docs/reference/functions/loadJsonFile.md +1 -1
- package/docs/reference/functions/loadTextFile.md +1 -1
- package/docs/reference/functions/processEnvOptions.md +1 -1
- package/docs/reference/functions/registerCommands.md +1 -1
- package/docs/reference/functions/shutdownExtensions.md +1 -1
- package/docs/reference/interfaces/ICliArgs.md +1 -1
- package/docs/reference/interfaces/ICliCommand.md +1 -1
- package/docs/reference/interfaces/ICliCommandDefinition.md +2 -2
- package/docs/reference/interfaces/ICliCommandDefinitionParam.md +1 -1
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +0 -8
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +8 -12
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +12 -12
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineMethod.md +2 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineServerMethod.md +2 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +2 -0
- package/docs/reference/type-aliases/NodeExtensionShutdownMethod.md +2 -0
- package/docs/reference/variables/ATTESTATION_VERIFICATION_METHOD_ID.md +2 -0
- package/docs/reference/variables/AUTH_SIGNING_KEY_ID.md +2 -0
- package/docs/reference/variables/BLOB_STORAGE_ENCRYPTION_KEY_ID.md +2 -0
- package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_DID.md +2 -0
- package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_TENANT.md +2 -0
- package/docs/reference/variables/IMMUTABLE_PROOF_VERIFICATION_METHOD_ID.md +2 -0
- package/docs/reference/variables/TRUST_VERIFICATION_METHOD_ID.md +2 -0
- package/locales/en.json +17 -9
- package/package.json +1 -1
|
@@ -3,8 +3,6 @@ import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
|
|
|
3
3
|
import { Coerce, ComponentFactory, GeneralError, I18n, Is } from "@twin.org/core";
|
|
4
4
|
import { identityCreate } from "./identityCreate.js";
|
|
5
5
|
import { identityVerificationMethodCreate } from "./identityVerificationMethodCreate.js";
|
|
6
|
-
import { nodeSetIdentity } from "./nodeSetIdentity.js";
|
|
7
|
-
import { applyOrganizationIdToTenant } from "./setTenantOrgId.js";
|
|
8
6
|
import { tenantCreate } from "./tenantCreate.js";
|
|
9
7
|
import { userCreate } from "./userCreate.js";
|
|
10
8
|
import { vaultKeyCreate } from "./vaultKeyCreate.js";
|
|
@@ -42,149 +40,161 @@ export function getCommandDefinitionBootstrapLegacy(commandDefinitions) {
|
|
|
42
40
|
* @param engineCore The engine core.
|
|
43
41
|
* @param envVars The environment variables for the node.
|
|
44
42
|
* @param params The parameters for the command.
|
|
43
|
+
* @returns A promise that resolves when the bootstrap sequence has completed.
|
|
45
44
|
*/
|
|
46
45
|
export async function bootstrapLegacy(engineCore, envVars, params) {
|
|
47
|
-
const features = (envVars.features ?? "")
|
|
46
|
+
const features = (envVars.features ?? "admin-user,wallet")
|
|
48
47
|
.split(",")
|
|
49
48
|
.map(f => f.trim())
|
|
50
49
|
.filter(f => f.length > 0);
|
|
51
50
|
const state = engineCore.getState();
|
|
52
|
-
const requireWallet = features.includes("
|
|
51
|
+
const requireWallet = features.includes("wallet");
|
|
53
52
|
const tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;
|
|
54
|
-
let nodeId = state.nodeId;
|
|
55
|
-
let
|
|
53
|
+
let nodeId = state.nodeId ?? envVars.nodeIdentity;
|
|
54
|
+
let organizationId = tenantEnabled ? undefined : state.nodeOrganizationId;
|
|
55
|
+
let tenant;
|
|
56
56
|
if (features.length === 0) {
|
|
57
57
|
throw new GeneralError("bootstrapLegacy", "noFeaturesEnabled");
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
CLIDisplay.break();
|
|
60
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeIdentityCreate"));
|
|
61
|
+
const nodeIdentity = await identityCreate(engineCore, envVars, {
|
|
62
|
+
identity: nodeId,
|
|
63
|
+
mnemonic: envVars.nodeMnemonic,
|
|
64
|
+
fundWallet: requireWallet,
|
|
65
|
+
nodeId: true
|
|
66
|
+
});
|
|
67
|
+
nodeId = nodeIdentity.did;
|
|
68
|
+
CLIDisplay.break();
|
|
69
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeAuthKeyCreate"));
|
|
70
|
+
await vaultKeyCreate(engineCore, envVars, {
|
|
71
|
+
identity: nodeId,
|
|
72
|
+
keyType: "Ed25519",
|
|
73
|
+
keyId: envVars.authSigningKeyId,
|
|
74
|
+
overwriteMode: "skip"
|
|
75
|
+
});
|
|
76
|
+
// Always create the organisation identity first so it can be associated with
|
|
77
|
+
// the tenant (multi-tenant) or the node (single-tenant) immediately after.
|
|
78
|
+
// The trust verification method is always added to the organisation identity.
|
|
79
|
+
await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {
|
|
60
80
|
CLIDisplay.break();
|
|
61
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.organisationCreate"));
|
|
82
|
+
if (tenantEnabled) {
|
|
83
|
+
const existingTenant = Is.stringValue(envVars.tenantId)
|
|
84
|
+
? await resolveTenantById(engineCore, envVars.tenantId)
|
|
85
|
+
: await resolveDefaultTenant(engineCore);
|
|
86
|
+
organizationId = existingTenant?.organizationId;
|
|
87
|
+
}
|
|
88
|
+
const organisation = await identityCreate(engineCore, envVars, {
|
|
89
|
+
identity: organizationId ?? envVars.organizationIdentity,
|
|
90
|
+
mnemonic: envVars.organizationMnemonic,
|
|
65
91
|
fundWallet: requireWallet
|
|
66
92
|
});
|
|
67
|
-
|
|
93
|
+
organizationId = organisation.did;
|
|
68
94
|
CLIDisplay.break();
|
|
69
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.
|
|
70
|
-
await
|
|
71
|
-
identity:
|
|
72
|
-
|
|
73
|
-
|
|
95
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.trustVerificationMethodCreate"));
|
|
96
|
+
await identityVerificationMethodCreate(engineCore, envVars, {
|
|
97
|
+
identity: organisation.did,
|
|
98
|
+
verificationMethodType: "assertionMethod",
|
|
99
|
+
verificationMethodId: envVars.trustVerificationMethodId,
|
|
74
100
|
overwriteMode: "skip"
|
|
75
101
|
});
|
|
76
|
-
|
|
77
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeIdentitySet"));
|
|
78
|
-
await nodeSetIdentity(engineCore, envVars, {
|
|
79
|
-
identity: nodeId
|
|
80
|
-
});
|
|
81
|
-
// Always create the organisation identity first so it can be associated with
|
|
82
|
-
// the tenant (multi-tenant) or the node (single-tenant) immediately after.
|
|
83
|
-
// The trust verification method is always added to the organisation identity.
|
|
84
|
-
let orgDid;
|
|
85
|
-
await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {
|
|
102
|
+
if (Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) {
|
|
86
103
|
CLIDisplay.break();
|
|
87
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.
|
|
88
|
-
|
|
89
|
-
identity:
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.blobStorageKeyCreate"));
|
|
105
|
+
await vaultKeyCreate(engineCore, envVars, {
|
|
106
|
+
identity: organizationId,
|
|
107
|
+
keyType: "ChaCha20Poly1305",
|
|
108
|
+
keyId: envVars.blobStorageEncryptionKeyId,
|
|
109
|
+
overwriteMode: "skip"
|
|
92
110
|
});
|
|
93
|
-
|
|
111
|
+
}
|
|
112
|
+
const defaultAttestationConnectorType = engineCore.getRegisteredInstanceTypeOptional("attestationConnector");
|
|
113
|
+
if (!Is.empty(defaultAttestationConnectorType)) {
|
|
94
114
|
CLIDisplay.break();
|
|
95
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.
|
|
115
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate"));
|
|
96
116
|
await identityVerificationMethodCreate(engineCore, envVars, {
|
|
97
|
-
identity:
|
|
117
|
+
identity: organizationId,
|
|
98
118
|
verificationMethodType: "assertionMethod",
|
|
99
|
-
verificationMethodId: envVars.
|
|
119
|
+
verificationMethodId: envVars.attestationVerificationMethodId,
|
|
100
120
|
overwriteMode: "skip"
|
|
101
121
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
}
|
|
123
|
+
const defaultImmutableProofComponentType = engineCore.getRegisteredInstanceTypeOptional("immutableProofComponent");
|
|
124
|
+
if (!Is.empty(defaultImmutableProofComponentType)) {
|
|
125
|
+
CLIDisplay.break();
|
|
126
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate"));
|
|
127
|
+
await identityVerificationMethodCreate(engineCore, envVars, {
|
|
128
|
+
identity: organizationId,
|
|
129
|
+
verificationMethodType: "assertionMethod",
|
|
130
|
+
verificationMethodId: envVars.immutableProofVerificationMethodId,
|
|
131
|
+
overwriteMode: "skip"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// In single-tenant mode, record the org DID in state so the node can resolve its
|
|
135
|
+
// organisation without a tenant lookup.
|
|
136
|
+
if (!tenantEnabled && !Is.stringValue(state.nodeOrganizationId)) {
|
|
137
|
+
CLIDisplay.break();
|
|
138
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeOrganizationIdSet"));
|
|
139
|
+
state.nodeOrganizationId = organisation.did;
|
|
140
|
+
engineCore.setStateDirty();
|
|
141
|
+
CLIDisplay.done();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
if (tenantEnabled) {
|
|
145
|
+
await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {
|
|
146
|
+
// Resolve an existing tenant so a re-run does not create a duplicate.
|
|
147
|
+
// When a specific tenant ID is configured, look it up directly;
|
|
148
|
+
// otherwise search for the first tenant labelled "Tenant".
|
|
149
|
+
if (Is.stringValue(envVars.tenantId)) {
|
|
150
|
+
tenant = await resolveTenantById(engineCore, envVars.tenantId);
|
|
109
151
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
152
|
+
else {
|
|
153
|
+
tenant = await resolveDefaultTenant(engineCore);
|
|
154
|
+
}
|
|
155
|
+
// Still empty so create a new tenant for the node and associate it with the organisation.
|
|
156
|
+
if (Is.empty(tenant)) {
|
|
113
157
|
CLIDisplay.break();
|
|
114
158
|
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeTenantCreate"));
|
|
115
159
|
const tenantDetails = await tenantCreate(engineCore, envVars, {
|
|
116
160
|
tenantId: envVars.tenantId,
|
|
117
161
|
apiKey: envVars.tenantApiKey,
|
|
118
|
-
label: "
|
|
162
|
+
label: "Tenant",
|
|
163
|
+
organizationId
|
|
119
164
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else if (tenantEnabled && Is.empty(tenantId) && Is.stringValue(nodeId)) {
|
|
131
|
-
await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {
|
|
132
|
-
tenantId = await resolveBootstrapTenantId(engineCore);
|
|
165
|
+
tenant = {
|
|
166
|
+
id: tenantDetails.tenantId,
|
|
167
|
+
organizationId: organizationId ?? tenantDetails.organizationId ?? ""
|
|
168
|
+
};
|
|
169
|
+
}
|
|
133
170
|
});
|
|
134
171
|
}
|
|
135
|
-
if (features.includes("
|
|
136
|
-
await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]:
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
172
|
+
if (features.includes("admin-user")) {
|
|
173
|
+
await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]: tenant?.id }, async () => {
|
|
174
|
+
const orgDid = await resolveOrganizationDid(engineCore, tenantEnabled, tenant?.id);
|
|
175
|
+
const effectiveAdminEmail = envVars.adminUserName ?? `admin@${tenantEnabled ? "tenant" : "node"}`;
|
|
176
|
+
const adminUser = await resolveDefaultAdminUser(engineCore, effectiveAdminEmail);
|
|
177
|
+
let userDid = adminUser?.userIdentity;
|
|
178
|
+
if (Is.empty(adminUser)) {
|
|
140
179
|
CLIDisplay.break();
|
|
141
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.
|
|
142
|
-
await
|
|
143
|
-
identity:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
overwriteMode: "skip"
|
|
180
|
+
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate"));
|
|
181
|
+
const result = await identityCreate(engineCore, envVars, {
|
|
182
|
+
identity: envVars.adminUserIdentity,
|
|
183
|
+
mnemonic: envVars.adminUserMnemonic,
|
|
184
|
+
controller: orgDid
|
|
147
185
|
});
|
|
186
|
+
userDid = result.did;
|
|
148
187
|
}
|
|
149
|
-
const defaultAttestationConnectorType = engineCore.getRegisteredInstanceTypeOptional("attestationConnector");
|
|
150
|
-
if (!Is.empty(defaultAttestationConnectorType)) {
|
|
151
|
-
CLIDisplay.break();
|
|
152
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate"));
|
|
153
|
-
await identityVerificationMethodCreate(engineCore, envVars, {
|
|
154
|
-
identity: orgDid,
|
|
155
|
-
verificationMethodType: "assertionMethod",
|
|
156
|
-
verificationMethodId: envVars.attestationVerificationMethodId,
|
|
157
|
-
overwriteMode: "skip"
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
const defaultImmutableProofComponentType = engineCore.getRegisteredInstanceTypeOptional("immutableProofComponent");
|
|
161
|
-
if (!Is.empty(defaultImmutableProofComponentType)) {
|
|
162
|
-
CLIDisplay.break();
|
|
163
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate"));
|
|
164
|
-
await identityVerificationMethodCreate(engineCore, envVars, {
|
|
165
|
-
identity: orgDid,
|
|
166
|
-
verificationMethodType: "assertionMethod",
|
|
167
|
-
verificationMethodId: envVars.immutableProofVerificationMethodId,
|
|
168
|
-
overwriteMode: "skip"
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
CLIDisplay.break();
|
|
172
|
-
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate"));
|
|
173
|
-
const adminUserIdentity = await identityCreate(engineCore, envVars, {
|
|
174
|
-
identity: envVars.adminUserIdentity,
|
|
175
|
-
mnemonic: envVars.adminUserMnemonic,
|
|
176
|
-
controller: orgDid
|
|
177
|
-
});
|
|
178
188
|
CLIDisplay.break();
|
|
179
189
|
CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.adminUserCreate"));
|
|
180
190
|
await userCreate(engineCore, envVars, {
|
|
181
|
-
userIdentity:
|
|
191
|
+
userIdentity: userDid,
|
|
182
192
|
organizationIdentity: orgDid,
|
|
183
|
-
tenantId,
|
|
184
|
-
email: envVars.adminUserName ?? "
|
|
193
|
+
tenantId: tenant?.id,
|
|
194
|
+
email: envVars.adminUserName ?? `admin@${tenantEnabled ? "tenant" : "node"}`,
|
|
185
195
|
password: envVars.adminUserPassword,
|
|
186
|
-
scope: ["tenant-admin", "user-admin"].join(","),
|
|
187
|
-
givenName: "Node",
|
|
196
|
+
scope: (tenantEnabled ? ["tenant-admin", "user-admin"] : ["user-admin"]).join(","),
|
|
197
|
+
givenName: tenantEnabled ? "Tenant" : "Node",
|
|
188
198
|
familyName: "Admin",
|
|
189
199
|
overwriteMode: "skip"
|
|
190
200
|
});
|
|
@@ -222,33 +232,80 @@ async function resolveOrganizationDid(engineCore, tenantEnabled, tenantId) {
|
|
|
222
232
|
throw new GeneralError("bootstrapLegacy", "organizationNotSet");
|
|
223
233
|
}
|
|
224
234
|
/**
|
|
225
|
-
* Resolve
|
|
235
|
+
* Resolve the default tenant id for re-bootstrap when multi-tenancy is enabled.
|
|
226
236
|
* @param engineCore The engine core.
|
|
227
237
|
* @returns The tenant id if one exists in storage.
|
|
228
238
|
* @internal
|
|
229
239
|
*/
|
|
230
|
-
async function
|
|
240
|
+
async function resolveDefaultTenant(engineCore) {
|
|
231
241
|
const tenantAdminServiceComponentType = engineCore.getRegisteredInstanceTypeOptional("tenantAdminComponent");
|
|
232
242
|
if (!Is.stringValue(tenantAdminServiceComponentType)) {
|
|
233
243
|
return undefined;
|
|
234
244
|
}
|
|
235
245
|
const tenantAdminService = ComponentFactory.get(tenantAdminServiceComponentType);
|
|
236
246
|
let cursor;
|
|
237
|
-
let
|
|
247
|
+
let firstTenant;
|
|
238
248
|
do {
|
|
239
|
-
const result = await tenantAdminService.query(undefined, ["id", "label"], cursor);
|
|
240
|
-
const nodeTenant = result.tenants.find(tenant => tenant.label === "
|
|
249
|
+
const result = await tenantAdminService.query(undefined, ["id", "organizationId", "label"], cursor);
|
|
250
|
+
const nodeTenant = result.tenants.find(tenant => tenant.label === "Tenant");
|
|
241
251
|
if (nodeTenant) {
|
|
242
|
-
return
|
|
252
|
+
return {
|
|
253
|
+
id: nodeTenant.id,
|
|
254
|
+
organizationId: nodeTenant.organizationId ?? ""
|
|
255
|
+
};
|
|
243
256
|
}
|
|
244
|
-
if (Is.empty(
|
|
245
|
-
|
|
257
|
+
if (Is.empty(firstTenant) && Is.arrayValue(result.tenants)) {
|
|
258
|
+
firstTenant = {
|
|
259
|
+
id: result.tenants[0].id,
|
|
260
|
+
organizationId: result.tenants[0].organizationId ?? ""
|
|
261
|
+
};
|
|
246
262
|
}
|
|
247
263
|
cursor = result.cursor;
|
|
248
264
|
} while (Is.stringValue(cursor));
|
|
249
|
-
if (Is.
|
|
250
|
-
CLIDisplay.value(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.tenantFallback"),
|
|
265
|
+
if (!Is.empty(firstTenant)) {
|
|
266
|
+
CLIDisplay.value(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.tenantFallback"), firstTenant.id);
|
|
267
|
+
}
|
|
268
|
+
return firstTenant;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Resolve the admin user by email for idempotent re-bootstrap.
|
|
272
|
+
* @param engineCore The engine core.
|
|
273
|
+
* @param email The email address of the admin user to look up.
|
|
274
|
+
* @returns The admin user if one exists in storage.
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
async function resolveDefaultAdminUser(engineCore, email) {
|
|
278
|
+
const defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType("authenticationAdminComponent");
|
|
279
|
+
const authenticationAdminComponent = ComponentFactory.get(defaultAuthenticationAdminComponentType);
|
|
280
|
+
try {
|
|
281
|
+
return await authenticationAdminComponent.get(email);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Resolve a tenant by its specific ID for idempotent re-bootstrap.
|
|
289
|
+
* @param engineCore The engine core.
|
|
290
|
+
* @param tenantId The tenant ID to look up.
|
|
291
|
+
* @returns The tenant if found, otherwise undefined.
|
|
292
|
+
* @internal
|
|
293
|
+
*/
|
|
294
|
+
async function resolveTenantById(engineCore, tenantId) {
|
|
295
|
+
const tenantAdminServiceComponentType = engineCore.getRegisteredInstanceTypeOptional("tenantAdminComponent");
|
|
296
|
+
if (!Is.stringValue(tenantAdminServiceComponentType)) {
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
const tenantAdminService = ComponentFactory.get(tenantAdminServiceComponentType);
|
|
300
|
+
try {
|
|
301
|
+
const found = await tenantAdminService.get(tenantId);
|
|
302
|
+
return {
|
|
303
|
+
id: found.id,
|
|
304
|
+
organizationId: found.organizationId ?? ""
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
return undefined;
|
|
251
309
|
}
|
|
252
|
-
return firstTenantId;
|
|
253
310
|
}
|
|
254
311
|
//# sourceMappingURL=bootstrapLegacy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrapLegacy.js","sourceRoot":"","sources":["../../../src/commands/bootstrapLegacy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EA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EjC,IAAI,EAAE,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;QACnC,UAAU,CAAC,KAAK,CACf,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,EAC9E,aAAa,CACb,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITenantAdminComponent } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { identityCreate } from \"./identityCreate.js\";\nimport { identityVerificationMethodCreate } from \"./identityVerificationMethodCreate.js\";\nimport { nodeSetIdentity } from \"./nodeSetIdentity.js\";\nimport { applyOrganizationIdToTenant } from \"./setTenantOrgId.js\";\nimport { tenantCreate } from \"./tenantCreate.js\";\nimport { userCreate } from \"./userCreate.js\";\nimport { vaultKeyCreate } from \"./vaultKeyCreate.js\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"bootstrap-legacy\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionBootstrapLegacy(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.env-prefix.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.load-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) => bootstrapLegacy(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for legacy bootstrap.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n */\nexport async function bootstrapLegacy(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables & {\n\t\t/**\n\t\t * The features that are enabled on the node.\n\t\t * @default []\n\t\t */\n\t\tfeatures?: string;\n\n\t\t/**\n\t\t * The identity of the node which, if empty and node-identity feature is enabled it will be generated.\n\t\t */\n\t\tnodeIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.\n\t\t */\n\t\tnodeMnemonic?: string;\n\n\t\t/**\n\t\t * A tenant id to use as a default for the node.\n\t\t */\n\t\ttenantId?: string;\n\n\t\t/**\n\t\t * A tenant api key to use as a default for the node.\n\t\t */\n\t\ttenantApiKey?: string;\n\n\t\t/**\n\t\t * If the node-identity feature is enabled, this will be the organisation identity. If not provided it will be generated.\n\t\t */\n\t\torganizationIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the organisation, if empty and node-identity feature is enabled it will be randomly generated.\n\t\t */\n\t\torganizationMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the identity of the user, if one is not provided it will be generated\n\t\t */\n\t\tadminUserIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the admin user, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t\t */\n\t\tadminUserMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the name of the user.\n\t\t * @default admin@node\n\t\t */\n\t\tadminUserName?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.\n\t\t */\n\t\tadminUserPassword?: string;\n\t},\n\tparams: {}\n): Promise<void> {\n\tconst features = (envVars.features ?? \"\")\n\t\t.split(\",\")\n\t\t.map(f => f.trim())\n\t\t.filter(f => f.length > 0);\n\n\tconst state = engineCore.getState();\n\tconst requireWallet = features.includes(\"node-wallet\");\n\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\tlet nodeId = state.nodeId;\n\tlet tenantId = tenantEnabled ? envVars.tenantId : undefined;\n\n\tif (features.length === 0) {\n\t\tthrow new GeneralError(\"bootstrapLegacy\", \"noFeaturesEnabled\");\n\t}\n\n\tif (features.includes(\"node-identity\") && Is.empty(nodeId)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentityCreate\")\n\t\t);\n\n\t\tconst nodeIdentity = await identityCreate(engineCore, envVars, {\n\t\t\tidentity: envVars.nodeIdentity,\n\t\t\tmnemonic: envVars.nodeMnemonic,\n\t\t\tfundWallet: requireWallet\n\t\t});\n\n\t\tnodeId = nodeIdentity.did;\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeAuthKeyCreate\")\n\t\t);\n\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\tidentity: nodeIdentity.did,\n\t\t\tkeyType: \"Ed25519\",\n\t\t\tkeyId: envVars.authSigningKeyId,\n\t\t\toverwriteMode: \"skip\"\n\t\t});\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentitySet\")\n\t\t);\n\t\tawait nodeSetIdentity(engineCore, envVars, {\n\t\t\tidentity: nodeId\n\t\t});\n\n\t\t// Always create the organisation identity first so it can be associated with\n\t\t// the tenant (multi-tenant) or the node (single-tenant) immediately after.\n\t\t// The trust verification method is always added to the organisation identity.\n\t\tlet orgDid: string | undefined;\n\t\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.organisationCreate\")\n\t\t\t);\n\t\t\tconst organisation = await identityCreate(engineCore, envVars, {\n\t\t\t\tidentity: envVars.organizationIdentity,\n\t\t\t\tmnemonic: envVars.organizationMnemonic,\n\t\t\t\tfundWallet: requireWallet\n\t\t\t});\n\t\t\torgDid = organisation.did;\n\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.trustVerificationMethodCreate\"\n\t\t\t\t)\n\t\t\t);\n\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\tidentity: organisation.did,\n\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\tverificationMethodId: envVars.trustVerificationMethodId,\n\t\t\t\toverwriteMode: \"skip\"\n\t\t\t});\n\n\t\t\t// Always record the bootstrapped org DID in state so callers can reference it.\n\t\t\tif (!Is.stringValue(state.nodeOrganizationId)) {\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeOrganizationIdSet\")\n\t\t\t\t);\n\t\t\t\tstate.nodeOrganizationId = organisation.did;\n\t\t\t\tengineCore.setStateDirty();\n\t\t\t\tCLIDisplay.done();\n\t\t\t}\n\t\t});\n\n\t\tif (tenantEnabled) {\n\t\t\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantCreate\")\n\t\t\t\t);\n\t\t\t\tconst tenantDetails = await tenantCreate(engineCore, envVars, {\n\t\t\t\t\ttenantId: envVars.tenantId,\n\t\t\t\t\tapiKey: envVars.tenantApiKey,\n\t\t\t\t\tlabel: \"Node\"\n\t\t\t\t});\n\n\t\t\t\ttenantId = tenantDetails.tenantId;\n\n\t\t\t\tif (Is.stringValue(orgDid)) {\n\t\t\t\t\tawait applyOrganizationIdToTenant(engineCore, tenantId, orgDid, {\n\t\t\t\t\t\tsectionLabel: I18n.formatMessage(\n\t\t\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.tenantOrganizationIdSet\"\n\t\t\t\t\t\t),\n\t\t\t\t\t\trequired: false\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t} else if (tenantEnabled && Is.empty(tenantId) && Is.stringValue(nodeId)) {\n\t\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\t\ttenantId = await resolveBootstrapTenantId(engineCore);\n\t\t});\n\t}\n\n\tif (features.includes(\"node-admin-user\")) {\n\t\tawait ContextIdStore.run(\n\t\t\t{ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]: tenantId },\n\t\t\tasync () => {\n\t\t\t\t// Resolve the organisation DID that was created during node-identity bootstrap.\n\t\t\t\tconst orgDid = await resolveOrganizationDid(engineCore, tenantEnabled, tenantId);\n\n\t\t\t\tif (Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.blobStorageKeyCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: orgDid,\n\t\t\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\t\t\tkeyId: envVars.blobStorageEncryptionKeyId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultAttestationConnectorType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"attestationConnector\");\n\t\t\t\tif (!Is.empty(defaultAttestationConnectorType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: orgDid,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.attestationVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultImmutableProofComponentType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"immutableProofComponent\");\n\n\t\t\t\tif (!Is.empty(defaultImmutableProofComponentType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate\"\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: orgDid,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.immutableProofVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate\")\n\t\t\t\t);\n\t\t\t\tconst adminUserIdentity = await identityCreate(engineCore, envVars, {\n\t\t\t\t\tidentity: envVars.adminUserIdentity,\n\t\t\t\t\tmnemonic: envVars.adminUserMnemonic,\n\t\t\t\t\tcontroller: orgDid\n\t\t\t\t});\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminUserCreate\")\n\t\t\t\t);\n\t\t\t\tawait userCreate(engineCore, envVars, {\n\t\t\t\t\tuserIdentity: adminUserIdentity.did,\n\t\t\t\t\torganizationIdentity: orgDid,\n\t\t\t\t\ttenantId,\n\t\t\t\t\temail: envVars.adminUserName ?? \"admin@node\",\n\t\t\t\t\tpassword: envVars.adminUserPassword,\n\t\t\t\t\tscope: [\"tenant-admin\", \"user-admin\"].join(\",\"),\n\t\t\t\t\tgivenName: \"Node\",\n\t\t\t\t\tfamilyName: \"Admin\",\n\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\t}\n}\n\n/**\n * Resolve the organisation DID from node state (single-tenant) or the tenant entry (multi-tenant).\n * @param engineCore The engine core.\n * @param tenantEnabled Whether multi-tenancy is enabled.\n * @param tenantId The active tenant ID (multi-tenant only).\n * @returns The organisation DID.\n * @throws GeneralError if the organisation has not been associated yet.\n * @internal\n */\nasync function resolveOrganizationDid(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\ttenantEnabled: boolean,\n\ttenantId: string | undefined\n): Promise<string> {\n\tif (tenantEnabled) {\n\t\tif (Is.stringValue(tenantId)) {\n\t\t\tconst tenantAdminComponentType =\n\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\t\t\tif (Is.stringValue(tenantAdminComponentType)) {\n\t\t\t\tconst tenantAdminComponent =\n\t\t\t\t\tComponentFactory.get<ITenantAdminComponent>(tenantAdminComponentType);\n\t\t\t\tconst tenant = await tenantAdminComponent.get(tenantId);\n\t\t\t\tif (Is.stringValue(tenant.organizationId)) {\n\t\t\t\t\treturn tenant.organizationId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst state = engineCore.getState();\n\t\tif (Is.stringValue(state.nodeOrganizationId)) {\n\t\t\treturn state.nodeOrganizationId;\n\t\t}\n\t}\n\n\tthrow new GeneralError(\"bootstrapLegacy\", \"organizationNotSet\");\n}\n\n/**\n * Resolve an existing tenant id for re-bootstrap when multi-tenancy is enabled.\n * @param engineCore The engine core.\n * @returns The tenant id if one exists in storage.\n * @internal\n */\nasync function resolveBootstrapTenantId(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>\n): Promise<string | undefined> {\n\tconst tenantAdminServiceComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(tenantAdminServiceComponentType)) {\n\t\treturn undefined;\n\t}\n\n\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\ttenantAdminServiceComponentType\n\t);\n\n\tlet cursor: string | undefined;\n\tlet firstTenantId: string | undefined;\n\n\tdo {\n\t\tconst result = await tenantAdminService.query(undefined, [\"id\", \"label\"], cursor);\n\t\tconst nodeTenant = result.tenants.find(tenant => tenant.label === \"Node\");\n\t\tif (nodeTenant) {\n\t\t\treturn nodeTenant.id;\n\t\t}\n\n\t\tif (Is.empty(firstTenantId) && !Is.empty(result.tenants)) {\n\t\t\tfirstTenantId = result.tenants[0]?.id;\n\t\t}\n\n\t\tcursor = result.cursor;\n\t} while (Is.stringValue(cursor));\n\n\tif (Is.stringValue(firstTenantId)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.tenantFallback\"),\n\t\t\tfirstTenantId\n\t\t);\n\t}\n\n\treturn firstTenantId;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bootstrapLegacy.js","sourceRoot":"","sources":["../../../src/commands/bootstrapLegacy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAAC,kBAEnD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC;QACjF,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,4CAA4C,CAAC;QACzE,oBAAoB,EAAE,KAAK;QAC3B,mBAAmB,EAAE,KAAK;QAC1B,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,kEAAkE,CAClE;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,UAAU;gBACf,IAAI,EAAE,QAAQ;gB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,yBAAyB,CACnF,8BAA8B,CAC9B,CAAC;IACF,MAAM,4BAA4B,GAAG,gBAAgB,CAAC,GAAG,CACxD,uCAAuC,CACvC,CAAC;IAEF,IAAI,CAAC;QACJ,OAAO,MAAM,4BAA4B,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,iBAAiB,CAC/B,UAA4D,EAC5D,QAAgB;IAEhB,MAAM,+BAA+B,GACpC,UAAU,CAAC,iCAAiC,CAAC,sBAAsB,CAAC,CAAC;IAEtE,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,+BAA+B,CAAC,EAAE,CAAC;QACtD,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,GAAG,CAC9C,+BAA+B,CAC/B,CAAC;IAEF,IAAI,CAAC;QACJ,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACrD,OAAO;YACN,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,EAAE;SAC1C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IAuthenticationAdminComponent } from \"@twin.org/api-auth-entity-storage-models\";\nimport type { ITenantAdminComponent } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { identityCreate } from \"./identityCreate.js\";\nimport { identityVerificationMethodCreate } from \"./identityVerificationMethodCreate.js\";\nimport { tenantCreate } from \"./tenantCreate.js\";\nimport { userCreate } from \"./userCreate.js\";\nimport { vaultKeyCreate } from \"./vaultKeyCreate.js\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"bootstrap-legacy\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionBootstrapLegacy(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.env-prefix.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.load-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) => bootstrapLegacy(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for legacy bootstrap.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @returns A promise that resolves when the bootstrap sequence has completed.\n */\nexport async function bootstrapLegacy(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables & {\n\t\t/**\n\t\t * The features that are enabled on the node.\n\t\t * @default []\n\t\t */\n\t\tfeatures?: string;\n\n\t\t/**\n\t\t * The identity of the node which, if empty and node-identity feature is enabled it will be generated.\n\t\t */\n\t\tnodeIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the node identity, if empty it will be randomly generated.\n\t\t */\n\t\tnodeMnemonic?: string;\n\n\t\t/**\n\t\t * A tenant id to use as a default for the node.\n\t\t */\n\t\ttenantId?: string;\n\n\t\t/**\n\t\t * A tenant api key to use as a default for the node.\n\t\t */\n\t\ttenantApiKey?: string;\n\n\t\t/**\n\t\t * The organisation identity. If not provided it will be generated.\n\t\t */\n\t\torganizationIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the organisation identity, if empty it will be randomly generated.\n\t\t */\n\t\torganizationMnemonic?: string;\n\n\t\t/**\n\t\t * If the admin-user feature is enabled, this will be the identity of the user. If not provided it will be generated.\n\t\t */\n\t\tadminUserIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the admin user, if empty it will be randomly generated.\n\t\t */\n\t\tadminUserMnemonic?: string;\n\n\t\t/**\n\t\t * If the admin-user feature is enabled, this will be the name of the user.\n\t\t * @default admin@node\n\t\t */\n\t\tadminUserName?: string;\n\n\t\t/**\n\t\t * If the admin-user feature is enabled, this will be the password of the user. If empty it will be randomly generated.\n\t\t */\n\t\tadminUserPassword?: string;\n\t},\n\tparams: {}\n): Promise<void> {\n\tconst features = (envVars.features ?? \"admin-user,wallet\")\n\t\t.split(\",\")\n\t\t.map(f => f.trim())\n\t\t.filter(f => f.length > 0);\n\n\tconst state = engineCore.getState();\n\tconst requireWallet = features.includes(\"wallet\");\n\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\tlet nodeId = state.nodeId ?? envVars.nodeIdentity;\n\tlet organizationId = tenantEnabled ? undefined : state.nodeOrganizationId;\n\tlet tenant: { id: string; organizationId: string } | undefined;\n\n\tif (features.length === 0) {\n\t\tthrow new GeneralError(\"bootstrapLegacy\", \"noFeaturesEnabled\");\n\t}\n\n\tCLIDisplay.break();\n\tCLIDisplay.section(\n\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentityCreate\")\n\t);\n\n\tconst nodeIdentity = await identityCreate(engineCore, envVars, {\n\t\tidentity: nodeId,\n\t\tmnemonic: envVars.nodeMnemonic,\n\t\tfundWallet: requireWallet,\n\t\tnodeId: true\n\t});\n\n\tnodeId = nodeIdentity.did;\n\n\tCLIDisplay.break();\n\tCLIDisplay.section(\n\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeAuthKeyCreate\")\n\t);\n\tawait vaultKeyCreate(engineCore, envVars, {\n\t\tidentity: nodeId,\n\t\tkeyType: \"Ed25519\",\n\t\tkeyId: envVars.authSigningKeyId,\n\t\toverwriteMode: \"skip\"\n\t});\n\n\t// Always create the organisation identity first so it can be associated with\n\t// the tenant (multi-tenant) or the node (single-tenant) immediately after.\n\t// The trust verification method is always added to the organisation identity.\n\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.organisationCreate\")\n\t\t);\n\n\t\tif (tenantEnabled) {\n\t\t\tconst existingTenant = Is.stringValue(envVars.tenantId)\n\t\t\t\t? await resolveTenantById(engineCore, envVars.tenantId)\n\t\t\t\t: await resolveDefaultTenant(engineCore);\n\t\t\torganizationId = existingTenant?.organizationId;\n\t\t}\n\n\t\tconst organisation = await identityCreate(engineCore, envVars, {\n\t\t\tidentity: organizationId ?? envVars.organizationIdentity,\n\t\t\tmnemonic: envVars.organizationMnemonic,\n\t\t\tfundWallet: requireWallet\n\t\t});\n\t\torganizationId = organisation.did;\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.trustVerificationMethodCreate\")\n\t\t);\n\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\tidentity: organisation.did,\n\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\tverificationMethodId: envVars.trustVerificationMethodId,\n\t\t\toverwriteMode: \"skip\"\n\t\t});\n\n\t\tif (Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.blobStorageKeyCreate\")\n\t\t\t);\n\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\tidentity: organizationId,\n\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\tkeyId: envVars.blobStorageEncryptionKeyId,\n\t\t\t\toverwriteMode: \"skip\"\n\t\t\t});\n\t\t}\n\n\t\tconst defaultAttestationConnectorType =\n\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"attestationConnector\");\n\t\tif (!Is.empty(defaultAttestationConnectorType)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate\")\n\t\t\t);\n\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\tidentity: organizationId,\n\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\tverificationMethodId: envVars.attestationVerificationMethodId,\n\t\t\t\toverwriteMode: \"skip\"\n\t\t\t});\n\t\t}\n\n\t\tconst defaultImmutableProofComponentType =\n\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"immutableProofComponent\");\n\n\t\tif (!Is.empty(defaultImmutableProofComponentType)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate\")\n\t\t\t);\n\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\tidentity: organizationId,\n\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\tverificationMethodId: envVars.immutableProofVerificationMethodId,\n\t\t\t\toverwriteMode: \"skip\"\n\t\t\t});\n\t\t}\n\n\t\t// In single-tenant mode, record the org DID in state so the node can resolve its\n\t\t// organisation without a tenant lookup.\n\t\tif (!tenantEnabled && !Is.stringValue(state.nodeOrganizationId)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeOrganizationIdSet\")\n\t\t\t);\n\t\t\tstate.nodeOrganizationId = organisation.did;\n\t\t\tengineCore.setStateDirty();\n\t\t\tCLIDisplay.done();\n\t\t}\n\t});\n\n\tif (tenantEnabled) {\n\t\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\t\t// Resolve an existing tenant so a re-run does not create a duplicate.\n\t\t\t// When a specific tenant ID is configured, look it up directly;\n\t\t\t// otherwise search for the first tenant labelled \"Tenant\".\n\t\t\tif (Is.stringValue(envVars.tenantId)) {\n\t\t\t\ttenant = await resolveTenantById(engineCore, envVars.tenantId);\n\t\t\t} else {\n\t\t\t\ttenant = await resolveDefaultTenant(engineCore);\n\t\t\t}\n\n\t\t\t// Still empty so create a new tenant for the node and associate it with the organisation.\n\t\t\tif (Is.empty(tenant)) {\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantCreate\")\n\t\t\t\t);\n\t\t\t\tconst tenantDetails = await tenantCreate(engineCore, envVars, {\n\t\t\t\t\ttenantId: envVars.tenantId,\n\t\t\t\t\tapiKey: envVars.tenantApiKey,\n\t\t\t\t\tlabel: \"Tenant\",\n\t\t\t\t\torganizationId\n\t\t\t\t});\n\n\t\t\t\ttenant = {\n\t\t\t\t\tid: tenantDetails.tenantId,\n\t\t\t\t\torganizationId: organizationId ?? tenantDetails.organizationId ?? \"\"\n\t\t\t\t};\n\t\t\t}\n\t\t});\n\t}\n\n\tif (features.includes(\"admin-user\")) {\n\t\tawait ContextIdStore.run(\n\t\t\t{ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]: tenant?.id },\n\t\t\tasync () => {\n\t\t\t\tconst orgDid = await resolveOrganizationDid(engineCore, tenantEnabled, tenant?.id);\n\t\t\t\tconst effectiveAdminEmail =\n\t\t\t\t\tenvVars.adminUserName ?? `admin@${tenantEnabled ? \"tenant\" : \"node\"}`;\n\t\t\t\tconst adminUser = await resolveDefaultAdminUser(engineCore, effectiveAdminEmail);\n\t\t\t\tlet userDid = adminUser?.userIdentity;\n\n\t\t\t\tif (Is.empty(adminUser)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tconst result = await identityCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: envVars.adminUserIdentity,\n\t\t\t\t\t\tmnemonic: envVars.adminUserMnemonic,\n\t\t\t\t\t\tcontroller: orgDid\n\t\t\t\t\t});\n\n\t\t\t\t\tuserDid = result.did;\n\t\t\t\t}\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminUserCreate\")\n\t\t\t\t);\n\t\t\t\tawait userCreate(engineCore, envVars, {\n\t\t\t\t\tuserIdentity: userDid,\n\t\t\t\t\torganizationIdentity: orgDid,\n\t\t\t\t\ttenantId: tenant?.id,\n\t\t\t\t\temail: envVars.adminUserName ?? `admin@${tenantEnabled ? \"tenant\" : \"node\"}`,\n\t\t\t\t\tpassword: envVars.adminUserPassword,\n\t\t\t\t\tscope: (tenantEnabled ? [\"tenant-admin\", \"user-admin\"] : [\"user-admin\"]).join(\",\"),\n\t\t\t\t\tgivenName: tenantEnabled ? \"Tenant\" : \"Node\",\n\t\t\t\t\tfamilyName: \"Admin\",\n\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\t}\n}\n\n/**\n * Resolve the organisation DID from node state (single-tenant) or the tenant entry (multi-tenant).\n * @param engineCore The engine core.\n * @param tenantEnabled Whether multi-tenancy is enabled.\n * @param tenantId The active tenant ID (multi-tenant only).\n * @returns The organisation DID.\n * @throws GeneralError if the organisation has not been associated yet.\n * @internal\n */\nasync function resolveOrganizationDid(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\ttenantEnabled: boolean,\n\ttenantId: string | undefined\n): Promise<string> {\n\tif (tenantEnabled) {\n\t\tif (Is.stringValue(tenantId)) {\n\t\t\tconst tenantAdminComponentType =\n\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\t\t\tif (Is.stringValue(tenantAdminComponentType)) {\n\t\t\t\tconst tenantAdminComponent =\n\t\t\t\t\tComponentFactory.get<ITenantAdminComponent>(tenantAdminComponentType);\n\t\t\t\tconst tenant = await tenantAdminComponent.get(tenantId);\n\t\t\t\tif (Is.stringValue(tenant.organizationId)) {\n\t\t\t\t\treturn tenant.organizationId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tconst state = engineCore.getState();\n\t\tif (Is.stringValue(state.nodeOrganizationId)) {\n\t\t\treturn state.nodeOrganizationId;\n\t\t}\n\t}\n\n\tthrow new GeneralError(\"bootstrapLegacy\", \"organizationNotSet\");\n}\n\n/**\n * Resolve the default tenant id for re-bootstrap when multi-tenancy is enabled.\n * @param engineCore The engine core.\n * @returns The tenant id if one exists in storage.\n * @internal\n */\nasync function resolveDefaultTenant(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>\n): Promise<{ id: string; organizationId: string } | undefined> {\n\tconst tenantAdminServiceComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(tenantAdminServiceComponentType)) {\n\t\treturn undefined;\n\t}\n\n\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\ttenantAdminServiceComponentType\n\t);\n\n\tlet cursor: string | undefined;\n\tlet firstTenant: { id: string; organizationId: string } | undefined;\n\n\tdo {\n\t\tconst result = await tenantAdminService.query(\n\t\t\tundefined,\n\t\t\t[\"id\", \"organizationId\", \"label\"],\n\t\t\tcursor\n\t\t);\n\t\tconst nodeTenant = result.tenants.find(tenant => tenant.label === \"Tenant\");\n\t\tif (nodeTenant) {\n\t\t\treturn {\n\t\t\t\tid: nodeTenant.id,\n\t\t\t\torganizationId: nodeTenant.organizationId ?? \"\"\n\t\t\t};\n\t\t}\n\n\t\tif (Is.empty(firstTenant) && Is.arrayValue(result.tenants)) {\n\t\t\tfirstTenant = {\n\t\t\t\tid: result.tenants[0].id,\n\t\t\t\torganizationId: result.tenants[0].organizationId ?? \"\"\n\t\t\t};\n\t\t}\n\n\t\tcursor = result.cursor;\n\t} while (Is.stringValue(cursor));\n\n\tif (!Is.empty(firstTenant)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.tenantFallback\"),\n\t\t\tfirstTenant.id\n\t\t);\n\t}\n\n\treturn firstTenant;\n}\n\n/**\n * Resolve the admin user by email for idempotent re-bootstrap.\n * @param engineCore The engine core.\n * @param email The email address of the admin user to look up.\n * @returns The admin user if one exists in storage.\n * @internal\n */\nasync function resolveDefaultAdminUser(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\temail: string\n): Promise<{ email: string; userIdentity: string; organizationIdentity: string } | undefined> {\n\tconst defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"authenticationAdminComponent\"\n\t);\n\tconst authenticationAdminComponent = ComponentFactory.get<IAuthenticationAdminComponent>(\n\t\tdefaultAuthenticationAdminComponentType\n\t);\n\n\ttry {\n\t\treturn await authenticationAdminComponent.get(email);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Resolve a tenant by its specific ID for idempotent re-bootstrap.\n * @param engineCore The engine core.\n * @param tenantId The tenant ID to look up.\n * @returns The tenant if found, otherwise undefined.\n * @internal\n */\nasync function resolveTenantById(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\ttenantId: string\n): Promise<{ id: string; organizationId: string } | undefined> {\n\tconst tenantAdminServiceComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(tenantAdminServiceComponentType)) {\n\t\treturn undefined;\n\t}\n\n\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\ttenantAdminServiceComponentType\n\t);\n\n\ttry {\n\t\tconst found = await tenantAdminService.get(tenantId);\n\t\treturn {\n\t\t\tid: found.id,\n\t\t\torganizationId: found.organizationId ?? \"\"\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"]}
|
package/dist/es/commands/help.js
CHANGED
|
@@ -24,6 +24,7 @@ export function getCommandDefinitionHelp(commandDefinitions) {
|
|
|
24
24
|
* @param params The command parameters.
|
|
25
25
|
* @param params.command The command to display help for.
|
|
26
26
|
* @param commandDefinitions The registered command definitions.
|
|
27
|
+
* @returns A promise that resolves when help output has been displayed.
|
|
27
28
|
*/
|
|
28
29
|
export async function help(engineCore, envVars, params, commandDefinitions) {
|
|
29
30
|
if (Is.stringValue(params.command)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,g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,IAAI,CAAC,aAAa,CAAC,uCAAuC,CAAC,EAC3D,iBAAiB,CAAC,OAAO,CACzB,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"help\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionHelp(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.help.description\"),\n\t\texample: \"\",\n\t\tparams: [],\n\t\taction: async (engineCore, envVars, params) =>\n\t\t\thelp(engineCore, envVars, params, commandDefinitions),\n\t\trequiresEngineStarted: false\n\t};\n}\n\n/**\n * Command for displaying help information.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The command parameters.\n * @param params.command The command to display help for.\n * @param commandDefinitions The registered command definitions.\n * @returns A promise that resolves when help output has been displayed.\n */\nexport async function help(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: { command?: string },\n\tcommandDefinitions: { [id: string]: ICliCommandDefinition }\n): Promise<void> {\n\tif (Is.stringValue(params.command)) {\n\t\tconst commandDefinition = commandDefinitions[params.command];\n\t\tif (commandDefinition) {\n\t\t\tdisplayCommandHelp(commandDefinition);\n\t\t}\n\t} else {\n\t\tCLIDisplay.value(\"\", I18n.formatMessage(\"node.cli.commands.help.labels.commands\"));\n\t\tCLIDisplay.break();\n\n\t\tfor (const commandId in commandDefinitions) {\n\t\t\tconst commandDef = commandDefinitions[commandId];\n\t\t\tif (commandId !== \"help\") {\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tcommandDef.command,\n\t\t\t\t\tI18n.formatMessage(`node.cli.commands.${commandDef.command}.description`)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Display help for a specific command.\n * @param commandDefinition The command definition.\n */\nfunction displayCommandHelp(commandDefinition: ICliCommandDefinition): void {\n\tCLIDisplay.value(commandDefinition.command, commandDefinition.description);\n\tCLIDisplay.break();\n\n\tconst defaultLabel = I18n.formatMessage(\"node.cli.commands.help.labels.default\");\n\tconst optionsLabel = I18n.formatMessage(\"node.cli.commands.help.labels.options\");\n\tconst requiredLabel = I18n.formatMessage(\"node.cli.commands.help.labels.required\");\n\tconst optionalLabel = I18n.formatMessage(\"node.cli.commands.help.labels.optional\");\n\n\tif (commandDefinition.params.length > 0) {\n\t\tfor (const param of commandDefinition.params) {\n\t\t\tconst typeParts: string[] = [param.type];\n\t\t\tif (Is.stringValue(param.extendedType)) {\n\t\t\t\ttypeParts.push(param.extendedType);\n\t\t\t}\n\t\t\tif (!Is.empty(param.defaultValue)) {\n\t\t\t\ttypeParts.push(`${defaultLabel}: '${param.defaultValue}'`);\n\t\t\t}\n\t\t\tif (param.required) {\n\t\t\t\ttypeParts.push(requiredLabel);\n\t\t\t} else {\n\t\t\t\ttypeParts.push(optionalLabel);\n\t\t\t}\n\n\t\t\tif (Is.arrayValue(param.options)) {\n\t\t\t\ttypeParts.push(`${optionsLabel}: [${param.options.join(\", \")}]`);\n\t\t\t}\n\n\t\t\tCLIDisplay.value(param.key, `(${typeParts.join(\", \")})`, 1);\n\n\t\t\tCLIDisplay.value(\"\", param.description, 1);\n\n\t\t\tCLIDisplay.break();\n\t\t}\n\t}\n\n\tif (Is.stringValue(commandDefinition.example)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.help.labels.example\"),\n\t\t\tcommandDefinition.example\n\t\t);\n\t}\n}\n"]}
|