@twin.org/node-core 0.0.3-next.65 → 0.0.3-next.67

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 (108) hide show
  1. package/dist/es/builders/engineEnvBuilder.js +21 -19
  2. package/dist/es/builders/engineEnvBuilder.js.map +1 -1
  3. package/dist/es/builders/engineServerEnvBuilder.js +1 -0
  4. package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
  5. package/dist/es/builders/extensionsBuilder.js.map +1 -1
  6. package/dist/es/cli.js.map +1 -1
  7. package/dist/es/commands/bootstrapLegacy.js +2 -1
  8. package/dist/es/commands/bootstrapLegacy.js.map +1 -1
  9. package/dist/es/commands/help.js.map +1 -1
  10. package/dist/es/commands/identityCreate.js.map +1 -1
  11. package/dist/es/commands/identityImports.js.map +1 -1
  12. package/dist/es/commands/identityVerifiableCredentialCreate.js.map +1 -1
  13. package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -1
  14. package/dist/es/commands/identityVerificationMethodImport.js.map +1 -1
  15. package/dist/es/commands/nodeSetIdentity.js.map +1 -1
  16. package/dist/es/commands/removeTenantOrgAlias.js.map +1 -1
  17. package/dist/es/commands/setNodeOrgId.js.map +1 -1
  18. package/dist/es/commands/setTenantOrgId.js.map +1 -1
  19. package/dist/es/commands/tenantCreate.js.map +1 -1
  20. package/dist/es/commands/tenantImport.js.map +1 -1
  21. package/dist/es/commands/tenantUpdate.js.map +1 -1
  22. package/dist/es/commands/userCreate.js.map +1 -1
  23. package/dist/es/commands/userUpdate.js.map +1 -1
  24. package/dist/es/commands/vaultKeyCreate.js.map +1 -1
  25. package/dist/es/commands/vaultKeyImport.js.map +1 -1
  26. package/dist/es/index.js +2 -0
  27. package/dist/es/index.js.map +1 -1
  28. package/dist/es/models/IBootstrapLegacyEnvironmentVariables.js +4 -0
  29. package/dist/es/models/IBootstrapLegacyEnvironmentVariables.js.map +1 -0
  30. package/dist/es/models/ICliCommandDefinition.js.map +1 -1
  31. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
  32. package/dist/es/models/IEngineServerEnvironmentVariables.js +2 -0
  33. package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
  34. package/dist/es/models/IEnvironmentVariables.js +2 -0
  35. package/dist/es/models/IEnvironmentVariables.js.map +1 -0
  36. package/dist/es/models/INodeEnvironmentVariables.js +2 -0
  37. package/dist/es/models/INodeEnvironmentVariables.js.map +1 -1
  38. package/dist/es/models/INodeOptions.js.map +1 -1
  39. package/dist/es/models/bootstrapLegacyEnvironmentVariableKeys.js +24 -0
  40. package/dist/es/models/bootstrapLegacyEnvironmentVariableKeys.js.map +1 -0
  41. package/dist/es/models/engineEnvironmentVariableKeys.js +202 -0
  42. package/dist/es/models/engineEnvironmentVariableKeys.js.map +1 -0
  43. package/dist/es/models/engineServerEnvironmentVariableKeys.js +35 -0
  44. package/dist/es/models/engineServerEnvironmentVariableKeys.js.map +1 -0
  45. package/dist/es/models/nodeEnvironmentVariableKeys.js +18 -0
  46. package/dist/es/models/nodeEnvironmentVariableKeys.js.map +1 -0
  47. package/dist/es/models/nodeExtensionInitialiseMethod.js.map +1 -1
  48. package/dist/es/node.js +94 -2
  49. package/dist/es/node.js.map +1 -1
  50. package/dist/es/start.js.map +1 -1
  51. package/dist/types/builders/engineServerEnvBuilder.d.ts +3 -3
  52. package/dist/types/builders/extensionsBuilder.d.ts +5 -5
  53. package/dist/types/cli.d.ts +2 -2
  54. package/dist/types/commands/bootstrapLegacy.d.ts +2 -49
  55. package/dist/types/commands/help.d.ts +2 -2
  56. package/dist/types/commands/identityCreate.d.ts +2 -2
  57. package/dist/types/commands/identityImports.d.ts +2 -2
  58. package/dist/types/commands/identityVerifiableCredentialCreate.d.ts +2 -2
  59. package/dist/types/commands/identityVerificationMethodCreate.d.ts +2 -2
  60. package/dist/types/commands/identityVerificationMethodImport.d.ts +2 -2
  61. package/dist/types/commands/nodeSetIdentity.d.ts +2 -2
  62. package/dist/types/commands/removeTenantOrgAlias.d.ts +2 -2
  63. package/dist/types/commands/setNodeOrgId.d.ts +2 -2
  64. package/dist/types/commands/setTenantOrgId.d.ts +2 -2
  65. package/dist/types/commands/tenantCreate.d.ts +2 -2
  66. package/dist/types/commands/tenantImport.d.ts +2 -2
  67. package/dist/types/commands/tenantUpdate.d.ts +2 -2
  68. package/dist/types/commands/userCreate.d.ts +2 -2
  69. package/dist/types/commands/userUpdate.d.ts +2 -2
  70. package/dist/types/commands/vaultKeyCreate.d.ts +2 -2
  71. package/dist/types/commands/vaultKeyImport.d.ts +2 -2
  72. package/dist/types/index.d.ts +2 -0
  73. package/dist/types/models/IBootstrapLegacyEnvironmentVariables.d.ts +56 -0
  74. package/dist/types/models/ICliCommandDefinition.d.ts +2 -2
  75. package/dist/types/models/IEngineEnvironmentVariables.d.ts +39 -22
  76. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +1 -2
  77. package/dist/types/models/IEnvironmentVariables.d.ts +8 -0
  78. package/dist/types/models/INodeEnvironmentVariables.d.ts +1 -2
  79. package/dist/types/models/INodeOptions.d.ts +3 -3
  80. package/dist/types/models/bootstrapLegacyEnvironmentVariableKeys.d.ts +4 -0
  81. package/dist/types/models/engineEnvironmentVariableKeys.d.ts +4 -0
  82. package/dist/types/models/engineServerEnvironmentVariableKeys.d.ts +7 -0
  83. package/dist/types/models/nodeEnvironmentVariableKeys.d.ts +5 -0
  84. package/dist/types/models/nodeExtensionInitialiseMethod.d.ts +2 -2
  85. package/dist/types/node.d.ts +3 -3
  86. package/dist/types/start.d.ts +3 -2
  87. package/docs/changelog.md +19 -0
  88. package/docs/reference/functions/buildConfiguration.md +2 -2
  89. package/docs/reference/functions/buildEngineServerConfiguration.md +1 -1
  90. package/docs/reference/functions/executeCommand.md +1 -1
  91. package/docs/reference/functions/extensionsConfiguration.md +1 -1
  92. package/docs/reference/functions/extensionsInitialiseEngine.md +1 -1
  93. package/docs/reference/functions/extensionsInitialiseEngineServer.md +1 -1
  94. package/docs/reference/functions/isAuthEntityStorageRequired.md +1 -1
  95. package/docs/reference/functions/overrideModuleImport.md +1 -1
  96. package/docs/reference/functions/shutdownExtensions.md +1 -1
  97. package/docs/reference/functions/start.md +1 -1
  98. package/docs/reference/index.md +2 -0
  99. package/docs/reference/interfaces/IBootstrapLegacyEnvironmentVariables.md +117 -0
  100. package/docs/reference/interfaces/ICliCommandDefinition.md +1 -1
  101. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +71 -40
  102. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +0 -1954
  103. package/docs/reference/interfaces/INodeEnvironmentVariables.md +0 -2130
  104. package/docs/reference/interfaces/INodeOptions.md +2 -2
  105. package/docs/reference/type-aliases/IEnvironmentVariables.md +5 -0
  106. package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +1 -1
  107. package/locales/en.json +7 -1
  108. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"identityVerificationMethodCreate.js","sourceRoot":"","sources":["../../../src/commands/identityVerificationMethodCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EACN,GAAG,EACH,cAAc,EACd,wBAAwB,EAExB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAa,GAAG,EAAE,MAAM,eAAe,CAAC;AAM/C,MAAM,YAAY,GAAG,qCAAqC,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,oDAAoD,CAAC,kBAEpE;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OA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ay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ComponentFactory, Converter, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport {\n\tDid,\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\ttype IIdentityResolverComponent\n} from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport { type IJwk, Jwk } from \"@twin.org/web\";\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 = \"identity-verification-method-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionIdentityVerificationMethodCreate(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-create.description\"\n\t\t),\n\t\texample: I18n.formatMessage(\"node.cli.commands.identity-verification-method-create.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.identity-verification-method-create.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"controller\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.controller.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-type\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.verification-method-type.description\"\n\t\t\t\t),\n\t\t\t\toptions: Object.values(DidVerificationMethodType),\n\t\t\t\trequired: false,\n\t\t\t\tdefaultValue: \"assertionMethod\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.verification-method-id.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: \"overwrite-mode\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.overwrite-mode.description\"\n\t\t\t\t),\n\t\t\t\toptions: [\"skip\", \"overwrite\", \"error\"],\n\t\t\t\tdefaultValue: \"skip\",\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.identity-verification-method-create.params.load-env.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: \"output-json\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-json.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: \"output-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-env.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: \"output-env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-env-prefix.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) =>\n\t\t\tidentityVerificationMethodCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating an identity verification method.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID of the identity to create.\n * @param params.verificationMethodType The type of verification method to create.\n * @param params.verificationMethodId The ID of the verification method to create.\n * @param params.controller The controller DID for the identity.\n * @param params.overwriteMode The mode to use when a verification method with the same ID already exists.\n * @param params.outputJson The output .json file to store the command output.\n * @param params.outputEnv The output .env file to store the command output.\n * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.\n * @returns The created verification method details or undefined if skipped.\n */\nexport async function identityVerificationMethodCreate(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t\tverificationMethodType?: DidVerificationMethodType;\n\t\tverificationMethodId?: string;\n\t\tcontroller?: string;\n\t\toverwriteMode?: \"skip\" | \"overwrite\" | \"error\";\n\t\toutputJson?: string;\n\t\toutputEnv?: string;\n\t\toutputEnvPrefix?: string;\n\t}\n): Promise<\n\t| {\n\t\t\tverificationMethodId: string;\n\t\t\tverificationMethodType: string;\n\t\t\tprivateKeyJwk: IJwk;\n\t\t\tprivateKeyHex: string;\n\t\t\tpublicKeyHex: string;\n\t\t\tprivateKeyBase64: string;\n\t\t\tpublicKeyBase64: string;\n\t }\n\t| undefined\n> {\n\tDid.guard(\"identityVerificationMethodCreate\", \"identity\", params.identity);\n\tGuards.arrayOneOf(\n\t\t\"identityVerificationMethodCreate\",\n\t\t\"verificationMethodType\",\n\t\tparams.verificationMethodType,\n\t\tObject.values(DidVerificationMethodType)\n\t);\n\tGuards.arrayOneOf(\"identityVerificationMethodCreate\", \"overwrite-mode\", params.overwriteMode, [\n\t\t\"skip\",\n\t\t\"overwrite\",\n\t\t\"error\"\n\t]);\n\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tconst defaultIdentityResolverComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverComponent\"\n\t);\n\tconst identityResolverComponent = ComponentFactory.get<IIdentityResolverComponent>(\n\t\tdefaultIdentityResolverComponentType\n\t);\n\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tlet createMethod = true;\n\tlet verificationMethod;\n\n\t// We only need to perform the overwrite check if a verification method ID was provided\n\t// otherwise a new ID will be generated\n\tif (Is.stringValue(params.verificationMethodId)) {\n\t\tif (params.overwriteMode === \"skip\" || params.overwriteMode === \"error\") {\n\t\t\tCLIDisplay.task(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.resolvingIdentity\"\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tconst identityDoc = await identityResolverComponent.identityResolve(params.identity);\n\t\t\ttry {\n\t\t\t\tverificationMethod = DocumentHelper.getVerificationMethod(\n\t\t\t\t\tidentityDoc,\n\t\t\t\t\tDocumentHelper.joinId(params.identity, params.verificationMethodId),\n\t\t\t\t\tparams.verificationMethodType\n\t\t\t\t);\n\t\t\t} catch {}\n\n\t\t\tif (!Is.empty(verificationMethod)) {\n\t\t\t\tif (params.overwriteMode === \"error\") {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\t\"identityVerificationMethodCreate\",\n\t\t\t\t\t\t\"verificationMethodAlreadyExists\"\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Verify the vault key also exists before skipping.\n\t\t\t\t// The verification method may exist in the identity document while the\n\t\t\t\t// vault key is missing (e.g. database wipe, renameKey partial failure).\n\t\t\t\t// In that case we must NOT skip the addVerificationMethod will re-create\n\t\t\t\t// the vault key and update the method.\n\t\t\t\tlet vaultKeyExists = false;\n\t\t\t\ttry {\n\t\t\t\t\tconst keyParts = DocumentHelper.parseId(verificationMethod.id);\n\t\t\t\t\tawait vaultConnector.getKey(`${params.identity}/${keyParts.fragment}`);\n\t\t\t\t\tvaultKeyExists = true;\n\t\t\t\t} catch {}\n\n\t\t\t\tif (vaultKeyExists) {\n\t\t\t\t\tcreateMethod = false;\n\t\t\t\t\tCLIDisplay.task(\n\t\t\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.skipping\"\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (createMethod) {\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.creatingVerificationMethod\"\n\t\t\t)\n\t\t);\n\t\tCLIDisplay.spinnerStart();\n\n\t\tverificationMethod = await identityConnector.addVerificationMethod(\n\t\t\tparams.controller ?? params.identity,\n\t\t\tparams.identity,\n\t\t\tparams.verificationMethodType as DidVerificationMethodType,\n\t\t\tparams.verificationMethodId\n\t\t);\n\n\t\tCLIDisplay.spinnerStop();\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.createdVerificationMethod\"\n\t\t\t)\n\t\t);\n\t}\n\n\tlet json;\n\n\tif (!Is.empty(verificationMethod)) {\n\t\tconst keyParts = DocumentHelper.parseId(verificationMethod.id);\n\n\t\tconst keyPair = await vaultConnector.getKey(`${params.identity}/${keyParts.fragment}`);\n\t\tGuards.uint8Array(\"identityVerificationMethodCreate\", \"privateKey\", keyPair.privateKey);\n\n\t\tconst privateKeyBase64Url = Converter.bytesToBase64Url(keyPair.privateKey);\n\t\tconst publicKeyBase64Url = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToBase64Url(keyPair.publicKey)\n\t\t\t: \"\";\n\t\tconst privateKeyBase64 = Converter.bytesToBase64(keyPair.privateKey);\n\t\tconst publicKeyBase64 = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToBase64(keyPair.publicKey)\n\t\t\t: \"\";\n\n\t\tconst privateKeyHex = Converter.bytesToHex(keyPair.privateKey, true);\n\t\tconst publicKeyHex = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToHex(keyPair.publicKey, true)\n\t\t\t: \"\";\n\n\t\tconst jwk = await Jwk.fromEd25519Private(keyPair.privateKey);\n\t\tconst kid = await Jwk.generateKid(jwk);\n\n\t\tif (createMethod) {\n\t\t\tCLIDisplay.break();\n\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.verificationMethodId\"\n\t\t\t\t),\n\t\t\t\tverificationMethod.id\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.verificationMethodType\"\n\t\t\t\t),\n\t\t\t\tverificationMethod.type\n\t\t\t);\n\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-create.labels.kid\"),\n\t\t\t\tkid\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyBase64Url\"\n\t\t\t\t),\n\t\t\t\tprivateKeyBase64Url\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyBase64Url\"\n\t\t\t\t),\n\t\t\t\tpublicKeyBase64Url\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyBase64\"\n\t\t\t\t),\n\t\t\t\tprivateKeyBase64\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyBase64\"\n\t\t\t\t),\n\t\t\t\tpublicKeyBase64\n\t\t\t);\n\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyHex\"\n\t\t\t\t),\n\t\t\t\tprivateKeyHex\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyHex\"\n\t\t\t\t),\n\t\t\t\tpublicKeyHex\n\t\t\t);\n\n\t\t\tCLIDisplay.break();\n\t\t}\n\n\t\tjson = {\n\t\t\tverificationMethodId: verificationMethod.id,\n\t\t\tverificationMethodType: verificationMethod.type,\n\t\t\tprivateKeyJwk: {\n\t\t\t\tkid,\n\t\t\t\t...jwk\n\t\t\t},\n\t\t\tprivateKeyHex,\n\t\t\tpublicKeyHex,\n\t\t\tprivateKeyBase64,\n\t\t\tpublicKeyBase64\n\t\t};\n\n\t\tif (Is.stringValue(params.outputJson)) {\n\t\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t\t}\n\n\t\tif (Is.stringValue(params.outputEnv)) {\n\t\t\tconst output = [\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_ID=\"${verificationMethod.id}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_TYPE=\"${verificationMethod.type}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KID=\"${kid}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KTY=\"${jwk.kty}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_USE=\"${jwk.use}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_ALG=\"${jwk.alg}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_CRV=\"${jwk.crv}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_X=\"${jwk.x}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_D=\"${jwk.d}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_HEX=\"${privateKeyHex}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_HEX=\"${publicKeyHex}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_BASE64=\"${privateKeyBase64}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_BASE64=\"${publicKeyBase64}\"`\n\t\t\t];\n\t\t\tawait CLIUtils.writeEnvFile(params.outputEnv, output, false);\n\t\t}\n\t}\n\n\tCLIDisplay.done();\n\n\treturn json;\n}\n"]}
1
+ {"version":3,"file":"identityVerificationMethodCreate.js","sourceRoot":"","sources":["../../../src/commands/identityVerificationMethodCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,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,MAAM,CAAC,eAAe,kCAAkC,GAAG,CAAC,CAAC,GAAG;gBACnE,GAAG,MAAM,CAAC,eAAe,4CAA4C,aAAa,GAAG;gBACrF,GAAG,MAAM,CAAC,eAAe,2CAA2C,YAAY,GAAG;gBACnF,GAAG,MAAM,CAAC,eAAe,+CAA+C,gBAAgB,GAAG;gBAC3F,GAAG,MAAM,CAAC,eAAe,8CAA8C,eAAe,GAAG;aACzF,CAAC;YACF,MAAM,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ComponentFactory, Converter, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport {\n\tDid,\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\ttype IIdentityResolverComponent\n} from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport { type IJwk, Jwk } from \"@twin.org/web\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"identity-verification-method-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionIdentityVerificationMethodCreate(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-create.description\"\n\t\t),\n\t\texample: I18n.formatMessage(\"node.cli.commands.identity-verification-method-create.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.identity-verification-method-create.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"controller\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.controller.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-type\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.verification-method-type.description\"\n\t\t\t\t),\n\t\t\t\toptions: Object.values(DidVerificationMethodType),\n\t\t\t\trequired: false,\n\t\t\t\tdefaultValue: \"assertionMethod\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.verification-method-id.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: \"overwrite-mode\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.overwrite-mode.description\"\n\t\t\t\t),\n\t\t\t\toptions: [\"skip\", \"overwrite\", \"error\"],\n\t\t\t\tdefaultValue: \"skip\",\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.identity-verification-method-create.params.load-env.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: \"output-json\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-json.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: \"output-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-env.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: \"output-env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-env-prefix.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) =>\n\t\t\tidentityVerificationMethodCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating an identity verification method.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID of the identity to create.\n * @param params.verificationMethodType The type of verification method to create.\n * @param params.verificationMethodId The ID of the verification method to create.\n * @param params.controller The controller DID for the identity.\n * @param params.overwriteMode The mode to use when a verification method with the same ID already exists.\n * @param params.outputJson The output .json file to store the command output.\n * @param params.outputEnv The output .env file to store the command output.\n * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.\n * @returns The created verification method details or undefined if skipped.\n */\nexport async function identityVerificationMethodCreate(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t\tverificationMethodType?: DidVerificationMethodType;\n\t\tverificationMethodId?: string;\n\t\tcontroller?: string;\n\t\toverwriteMode?: \"skip\" | \"overwrite\" | \"error\";\n\t\toutputJson?: string;\n\t\toutputEnv?: string;\n\t\toutputEnvPrefix?: string;\n\t}\n): Promise<\n\t| {\n\t\t\tverificationMethodId: string;\n\t\t\tverificationMethodType: string;\n\t\t\tprivateKeyJwk: IJwk;\n\t\t\tprivateKeyHex: string;\n\t\t\tpublicKeyHex: string;\n\t\t\tprivateKeyBase64: string;\n\t\t\tpublicKeyBase64: string;\n\t }\n\t| undefined\n> {\n\tDid.guard(\"identityVerificationMethodCreate\", \"identity\", params.identity);\n\tGuards.arrayOneOf(\n\t\t\"identityVerificationMethodCreate\",\n\t\t\"verificationMethodType\",\n\t\tparams.verificationMethodType,\n\t\tObject.values(DidVerificationMethodType)\n\t);\n\tGuards.arrayOneOf(\"identityVerificationMethodCreate\", \"overwrite-mode\", params.overwriteMode, [\n\t\t\"skip\",\n\t\t\"overwrite\",\n\t\t\"error\"\n\t]);\n\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tconst defaultIdentityResolverComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverComponent\"\n\t);\n\tconst identityResolverComponent = ComponentFactory.get<IIdentityResolverComponent>(\n\t\tdefaultIdentityResolverComponentType\n\t);\n\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tlet createMethod = true;\n\tlet verificationMethod;\n\n\t// We only need to perform the overwrite check if a verification method ID was provided\n\t// otherwise a new ID will be generated\n\tif (Is.stringValue(params.verificationMethodId)) {\n\t\tif (params.overwriteMode === \"skip\" || params.overwriteMode === \"error\") {\n\t\t\tCLIDisplay.task(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.resolvingIdentity\"\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tconst identityDoc = await identityResolverComponent.identityResolve(params.identity);\n\t\t\ttry {\n\t\t\t\tverificationMethod = DocumentHelper.getVerificationMethod(\n\t\t\t\t\tidentityDoc,\n\t\t\t\t\tDocumentHelper.joinId(params.identity, params.verificationMethodId),\n\t\t\t\t\tparams.verificationMethodType\n\t\t\t\t);\n\t\t\t} catch {}\n\n\t\t\tif (!Is.empty(verificationMethod)) {\n\t\t\t\tif (params.overwriteMode === \"error\") {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\t\"identityVerificationMethodCreate\",\n\t\t\t\t\t\t\"verificationMethodAlreadyExists\"\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Verify the vault key also exists before skipping.\n\t\t\t\t// The verification method may exist in the identity document while the\n\t\t\t\t// vault key is missing (e.g. database wipe, renameKey partial failure).\n\t\t\t\t// In that case we must NOT skip the addVerificationMethod will re-create\n\t\t\t\t// the vault key and update the method.\n\t\t\t\tlet vaultKeyExists = false;\n\t\t\t\ttry {\n\t\t\t\t\tconst keyParts = DocumentHelper.parseId(verificationMethod.id);\n\t\t\t\t\tawait vaultConnector.getKey(`${params.identity}/${keyParts.fragment}`);\n\t\t\t\t\tvaultKeyExists = true;\n\t\t\t\t} catch {}\n\n\t\t\t\tif (vaultKeyExists) {\n\t\t\t\t\tcreateMethod = false;\n\t\t\t\t\tCLIDisplay.task(\n\t\t\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.skipping\"\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (createMethod) {\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.creatingVerificationMethod\"\n\t\t\t)\n\t\t);\n\t\tCLIDisplay.spinnerStart();\n\n\t\tverificationMethod = await identityConnector.addVerificationMethod(\n\t\t\tparams.controller ?? params.identity,\n\t\t\tparams.identity,\n\t\t\tparams.verificationMethodType as DidVerificationMethodType,\n\t\t\tparams.verificationMethodId\n\t\t);\n\n\t\tCLIDisplay.spinnerStop();\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.createdVerificationMethod\"\n\t\t\t)\n\t\t);\n\t}\n\n\tlet json;\n\n\tif (!Is.empty(verificationMethod)) {\n\t\tconst keyParts = DocumentHelper.parseId(verificationMethod.id);\n\n\t\tconst keyPair = await vaultConnector.getKey(`${params.identity}/${keyParts.fragment}`);\n\t\tGuards.uint8Array(\"identityVerificationMethodCreate\", \"privateKey\", keyPair.privateKey);\n\n\t\tconst privateKeyBase64Url = Converter.bytesToBase64Url(keyPair.privateKey);\n\t\tconst publicKeyBase64Url = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToBase64Url(keyPair.publicKey)\n\t\t\t: \"\";\n\t\tconst privateKeyBase64 = Converter.bytesToBase64(keyPair.privateKey);\n\t\tconst publicKeyBase64 = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToBase64(keyPair.publicKey)\n\t\t\t: \"\";\n\n\t\tconst privateKeyHex = Converter.bytesToHex(keyPair.privateKey, true);\n\t\tconst publicKeyHex = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToHex(keyPair.publicKey, true)\n\t\t\t: \"\";\n\n\t\tconst jwk = await Jwk.fromEd25519Private(keyPair.privateKey);\n\t\tconst kid = await Jwk.generateKid(jwk);\n\n\t\tif (createMethod) {\n\t\t\tCLIDisplay.break();\n\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.verificationMethodId\"\n\t\t\t\t),\n\t\t\t\tverificationMethod.id\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.verificationMethodType\"\n\t\t\t\t),\n\t\t\t\tverificationMethod.type\n\t\t\t);\n\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-create.labels.kid\"),\n\t\t\t\tkid\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyBase64Url\"\n\t\t\t\t),\n\t\t\t\tprivateKeyBase64Url\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyBase64Url\"\n\t\t\t\t),\n\t\t\t\tpublicKeyBase64Url\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyBase64\"\n\t\t\t\t),\n\t\t\t\tprivateKeyBase64\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyBase64\"\n\t\t\t\t),\n\t\t\t\tpublicKeyBase64\n\t\t\t);\n\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyHex\"\n\t\t\t\t),\n\t\t\t\tprivateKeyHex\n\t\t\t);\n\t\t\tCLIDisplay.value(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyHex\"\n\t\t\t\t),\n\t\t\t\tpublicKeyHex\n\t\t\t);\n\n\t\t\tCLIDisplay.break();\n\t\t}\n\n\t\tjson = {\n\t\t\tverificationMethodId: verificationMethod.id,\n\t\t\tverificationMethodType: verificationMethod.type,\n\t\t\tprivateKeyJwk: {\n\t\t\t\tkid,\n\t\t\t\t...jwk\n\t\t\t},\n\t\t\tprivateKeyHex,\n\t\t\tpublicKeyHex,\n\t\t\tprivateKeyBase64,\n\t\t\tpublicKeyBase64\n\t\t};\n\n\t\tif (Is.stringValue(params.outputJson)) {\n\t\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t\t}\n\n\t\tif (Is.stringValue(params.outputEnv)) {\n\t\t\tconst output = [\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_ID=\"${verificationMethod.id}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_TYPE=\"${verificationMethod.type}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KID=\"${kid}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KTY=\"${jwk.kty}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_USE=\"${jwk.use}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_ALG=\"${jwk.alg}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_CRV=\"${jwk.crv}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_X=\"${jwk.x}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_D=\"${jwk.d}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_HEX=\"${privateKeyHex}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_HEX=\"${publicKeyHex}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_BASE64=\"${privateKeyBase64}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_BASE64=\"${publicKeyBase64}\"`\n\t\t\t];\n\t\t\tawait CLIUtils.writeEnvFile(params.outputEnv, output, false);\n\t\t}\n\t}\n\n\tCLIDisplay.done();\n\n\treturn json;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"identityVerificationMethodImport.js","sourceRoot":"","sources":["../../../src/commands/identityVerificationMethodImport.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EACN,GAAG,EACH,cAAc,EACd,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM7E,MAAM,YAAY,GAAG,qCAAqC,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,oDAAoD,CAAC,kBAEpE;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,mEAAmE,CACnE;QACD,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,+DAA+D,CAAC;QAC5F,oBAAoB,EAAE,KAAK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BAAqB,CAC5C,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,QAAQ,EACpC,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,sBAAmD,EAC1D,oBAAoB,CACpB,CAAC;IAEF,UAAU,CAAC,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,IAAI,CACd,IAAI,CAAC,aAAa,CAAC,uEAAuE,CAAC,CAC3F,CAAC;IACF,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Converter, GeneralError, Guards, HexHelper, I18n, Is } from \"@twin.org/core\";\nimport { Ed25519 } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport {\n\tDid,\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\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 = \"identity-verification-method-import\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionIdentityVerificationMethodImport(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-import.description\"\n\t\t),\n\t\texample: I18n.formatMessage(\"node.cli.commands.identity-verification-method-import.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.identity-verification-method-import.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"controller\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.controller.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-type\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.verification-method-type.description\"\n\t\t\t\t),\n\t\t\t\toptions: Object.values(DidVerificationMethodType),\n\t\t\t\trequired: true,\n\t\t\t\tdefaultValue: \"assertionMethod\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.verification-method-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"private-key-hex\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.private-key-hex.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.identity-verification-method-import.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) =>\n\t\t\tidentityVerificationMethodImport(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for importing an existing key as a verification method on an identity document.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID of the identity to create.\n * @param params.verificationMethodType The type of verification method to create.\n * @param params.verificationMethodId The ID of the verification method to create.\n * @param params.controller The controller DID for the identity.\n * @param params.privateKeyHex The private key in hex format.\n * @returns A promise that resolves when the verification method has been imported.\n */\nexport async function identityVerificationMethodImport(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t\tverificationMethodType?: DidVerificationMethodType;\n\t\tverificationMethodId?: string;\n\t\tcontroller?: string;\n\t\tprivateKeyHex?: string;\n\t}\n): Promise<void> {\n\tDid.guard(\"identityVerificationMethodImport\", \"identity\", params.identity);\n\tGuards.arrayOneOf(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"verification-method-type\",\n\t\tparams.verificationMethodType,\n\t\tObject.values(DidVerificationMethodType)\n\t);\n\tGuards.stringValue(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"verification-method-id\",\n\t\tparams.verificationMethodId\n\t);\n\tGuards.stringHex(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"private-key-hex\",\n\t\tparams.privateKeyHex,\n\t\ttrue\n\t);\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-import.labels.resolvingIdentity\"\n\t\t)\n\t);\n\tconst identityDocument = await identityResolverConnector.resolveDocument(params.identity);\n\n\tif (Is.empty(identityDocument)) {\n\t\tthrow new GeneralError(\"identityImport\", \"identityNotFound\", {\n\t\t\tidentity: params.identity\n\t\t});\n\t}\n\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-import.labels.importing\")\n\t);\n\tCLIDisplay.spinnerStart();\n\n\tlet verificationMethodId = params.verificationMethodId;\n\tif (verificationMethodId.includes(\"#\")) {\n\t\tconst parts = DocumentHelper.parseId(verificationMethodId);\n\t\tif (Is.stringValue(parts.fragment)) {\n\t\t\tverificationMethodId = parts.fragment;\n\t\t}\n\t}\n\n\tlet vaultKey;\n\tconst vaultKeyId = `${params.identity}/${verificationMethodId}`;\n\n\ttry {\n\t\tvaultKey = await vaultConnector.getKey(vaultKeyId);\n\t} catch {}\n\n\tif (Is.empty(vaultKey)) {\n\t\tconst privateKeyBytes = Converter.hexToBytes(HexHelper.stripPrefix(params.privateKeyHex));\n\t\tconst publicKeyBytes = Ed25519.publicKeyFromPrivateKey(privateKeyBytes);\n\t\tawait vaultConnector.addKey(vaultKeyId, VaultKeyType.Ed25519, privateKeyBytes, publicKeyBytes);\n\t}\n\n\tawait identityConnector.addVerificationMethod(\n\t\tparams.controller ?? params.identity,\n\t\tparams.identity,\n\t\tparams.verificationMethodType as DidVerificationMethodType,\n\t\tverificationMethodId\n\t);\n\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-import.labels.imported\")\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"identityVerificationMethodImport.js","sourceRoot":"","sources":["../../../src/commands/identityVerificationMethodImport.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EACN,GAAG,EACH,cAAc,EACd,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM7E,MAAM,YAAY,GAAG,qCAAqC,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,oDAAoD,CAAC,kBAEpE;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,mEAAmE,CACnE;QACD,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,+DAA+D,CAAC;QAC5F,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,qFAAqF,CACrF;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,UAAU;gBACf,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,mFAAmF,CACnF;gB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C,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Converter, GeneralError, Guards, HexHelper, I18n, Is } from \"@twin.org/core\";\nimport { Ed25519 } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport {\n\tDid,\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"identity-verification-method-import\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionIdentityVerificationMethodImport(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-import.description\"\n\t\t),\n\t\texample: I18n.formatMessage(\"node.cli.commands.identity-verification-method-import.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.identity-verification-method-import.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"controller\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.controller.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-type\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.verification-method-type.description\"\n\t\t\t\t),\n\t\t\t\toptions: Object.values(DidVerificationMethodType),\n\t\t\t\trequired: true,\n\t\t\t\tdefaultValue: \"assertionMethod\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.verification-method-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"private-key-hex\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.private-key-hex.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.identity-verification-method-import.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) =>\n\t\t\tidentityVerificationMethodImport(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for importing an existing key as a verification method on an identity document.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID of the identity to create.\n * @param params.verificationMethodType The type of verification method to create.\n * @param params.verificationMethodId The ID of the verification method to create.\n * @param params.controller The controller DID for the identity.\n * @param params.privateKeyHex The private key in hex format.\n * @returns A promise that resolves when the verification method has been imported.\n */\nexport async function identityVerificationMethodImport(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t\tverificationMethodType?: DidVerificationMethodType;\n\t\tverificationMethodId?: string;\n\t\tcontroller?: string;\n\t\tprivateKeyHex?: string;\n\t}\n): Promise<void> {\n\tDid.guard(\"identityVerificationMethodImport\", \"identity\", params.identity);\n\tGuards.arrayOneOf(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"verification-method-type\",\n\t\tparams.verificationMethodType,\n\t\tObject.values(DidVerificationMethodType)\n\t);\n\tGuards.stringValue(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"verification-method-id\",\n\t\tparams.verificationMethodId\n\t);\n\tGuards.stringHex(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"private-key-hex\",\n\t\tparams.privateKeyHex,\n\t\ttrue\n\t);\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-import.labels.resolvingIdentity\"\n\t\t)\n\t);\n\tconst identityDocument = await identityResolverConnector.resolveDocument(params.identity);\n\n\tif (Is.empty(identityDocument)) {\n\t\tthrow new GeneralError(\"identityImport\", \"identityNotFound\", {\n\t\t\tidentity: params.identity\n\t\t});\n\t}\n\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-import.labels.importing\")\n\t);\n\tCLIDisplay.spinnerStart();\n\n\tlet verificationMethodId = params.verificationMethodId;\n\tif (verificationMethodId.includes(\"#\")) {\n\t\tconst parts = DocumentHelper.parseId(verificationMethodId);\n\t\tif (Is.stringValue(parts.fragment)) {\n\t\t\tverificationMethodId = parts.fragment;\n\t\t}\n\t}\n\n\tlet vaultKey;\n\tconst vaultKeyId = `${params.identity}/${verificationMethodId}`;\n\n\ttry {\n\t\tvaultKey = await vaultConnector.getKey(vaultKeyId);\n\t} catch {}\n\n\tif (Is.empty(vaultKey)) {\n\t\tconst privateKeyBytes = Converter.hexToBytes(HexHelper.stripPrefix(params.privateKeyHex));\n\t\tconst publicKeyBytes = Ed25519.publicKeyFromPrivateKey(privateKeyBytes);\n\t\tawait vaultConnector.addKey(vaultKeyId, VaultKeyType.Ed25519, privateKeyBytes, publicKeyBytes);\n\t}\n\n\tawait identityConnector.addVerificationMethod(\n\t\tparams.controller ?? params.identity,\n\t\tparams.identity,\n\t\tparams.verificationMethodType as DidVerificationMethodType,\n\t\tverificationMethodId\n\t);\n\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-import.labels.imported\")\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"nodeSetIdentity.js","sourceRoot":"","sources":["../../../src/commands/nodeSetIdentity.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE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E1D,UAAU,CAAC,IAAI,CACd,IAAI,CAAC,aAAa,CAAC,8DAA8D,CAAC,CAClF,CAAC;IACF,MAAM,oCAAoC,GAAG,UAAU,CAAC,yBAAyB,CAChF,2BAA2B,CAC3B,CAAC;IAEF,MAAM,yBAAyB,GAAG,gCAAgC,CAAC,GAAG,CACrE,oCAAoC,CACpC,CAAC;IAEF,MAAM,gBAAgB,GAAG,MAAM,yBAAyB,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1F,IAAI,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,aAAa,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IAEpC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,CAAC,CAAC;QAC3F,OAAO;IACR,CAAC;IAED,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,UAAU,CAAC,aAAa,EAAE,CAAC;IAE3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAEzF,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { I18n, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityResolverConnectorFactory } from \"@twin.org/identity-models\";\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 = \"node-set-identity\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeSetIdentity(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.node-set-identity.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-set-identity.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.node-set-identity.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-set-identity.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: true\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.node-set-identity.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) => nodeSetIdentity(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting a node identity.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID to set for the node.\n * @returns A promise that resolves when the node identity has been persisted.\n */\nexport async function nodeSetIdentity(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t}\n): Promise<void> {\n\tDid.guard(\"nodeSetIdentity\", \"identity\", params.identity);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.node-set-identity.labels.resolvingIdentity\")\n\t);\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tconst identityDocument = await identityResolverConnector.resolveDocument(params.identity);\n\tif (Is.empty(identityDocument)) {\n\t\tthrow new NotFoundError(\"nodeSetIdentity\", \"identityNotFound\", params.identity);\n\t}\n\n\tconst state = engineCore.getState();\n\n\tif (state.nodeId === params.identity) {\n\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-set-identity.labels.skipping\"));\n\t\treturn;\n\t}\n\n\tstate.nodeId = params.identity;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-set-identity.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"nodeSetIdentity.js","sourceRoot":"","sources":["../../../src/commands/nodeSetIdentity.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,GAAG,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAMlF,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAAC,kBAEnD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,C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AC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1F,IAAI,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,aAAa,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IAEpC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,CAAC,CAAC;QAC3F,OAAO;IACR,CAAC;IAED,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,UAAU,CAAC,aAAa,EAAE,CAAC;IAE3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAEzF,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { I18n, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityResolverConnectorFactory } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"node-set-identity\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeSetIdentity(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.node-set-identity.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-set-identity.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.node-set-identity.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-set-identity.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: true\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.node-set-identity.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) => nodeSetIdentity(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting a node identity.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID to set for the node.\n * @returns A promise that resolves when the node identity has been persisted.\n */\nexport async function nodeSetIdentity(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t}\n): Promise<void> {\n\tDid.guard(\"nodeSetIdentity\", \"identity\", params.identity);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.node-set-identity.labels.resolvingIdentity\")\n\t);\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tconst identityDocument = await identityResolverConnector.resolveDocument(params.identity);\n\tif (Is.empty(identityDocument)) {\n\t\tthrow new NotFoundError(\"nodeSetIdentity\", \"identityNotFound\", params.identity);\n\t}\n\n\tconst state = engineCore.getState();\n\n\tif (state.nodeId === params.identity) {\n\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-set-identity.labels.skipping\"));\n\t\treturn;\n\t}\n\n\tstate.nodeId = params.identity;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-set-identity.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"removeTenantOrgAlias.js","sourceRoot":"","sources":["../../../src/commands/removeTenantOrgAlias.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,wCAAwC,CAAC,kBAExD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,uDAAuD,CAAC;QACxF,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,mDAAmD,CAAC;QAChF,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,yEAAyE,CACzE;gBACD,QAAQ,E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UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,CAAC,CAAC;IAEhG,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE3C,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,YAAY,CAAC,sBAAsB,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAExB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,2DAA2D,CAAC,CAAC,CAAC;IACjG,UAAU,CAAC,YAAY,EAAE,CAAC;IAE1B,MAAM,oBAAoB,CAAC,MAAM,CAAC;QACjC,GAAG,MAAM;QACT,oBAAoB,EAAE,MAAM;KAC5B,CAAC,CAAC;IAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,CAAC,CAAC;IAEhG,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,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 { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"remove-tenant-org-alias\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionRemoveTenantOrgAlias(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.remove-tenant-org-alias.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.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.remove-tenant-org-alias.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.remove-tenant-org-alias.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"alias\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.remove-tenant-org-alias.params.alias.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.remove-tenant-org-alias.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) => removeTenantOrgAlias(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for removing an alias from the tenant organization ID legacy list.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.tenantId The tenant ID to update.\n * @param params.alias The alias to remove from the legacy list.\n * @returns A promise that resolves when the alias has been removed.\n * @throws GeneralError if the tenant admin component is not registered, or the alias is not found.\n */\nexport async function removeTenantOrgAlias(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\ttenantId?: string;\n\t\talias?: string;\n\t}\n): Promise<void> {\n\tconst defaultTenantAdminComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(defaultTenantAdminComponentType)) {\n\t\tthrow new GeneralError(\"removeTenantOrgAlias\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tGuards.stringHexLength(\"removeTenantOrgAlias\", \"tenant-id\", params.tenantId, 32);\n\n\tDid.guard(\"removeTenantOrgAlias\", \"alias\", params.alias);\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(\n\t\tdefaultTenantAdminComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.labels.reading\"));\n\n\tconst tenant = await tenantAdminComponent.get(params.tenantId);\n\tconst legacy = [...(tenant.organizationIdLegacy ?? [])];\n\tconst index = legacy.indexOf(params.alias);\n\n\tif (index < 0) {\n\t\tthrow new GeneralError(\"removeTenantOrgAlias\", \"aliasNotFound\", { alias: params.alias });\n\t}\n\n\tlegacy.splice(index, 1);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.labels.updating\"));\n\tCLIDisplay.spinnerStart();\n\n\tawait tenantAdminComponent.update({\n\t\t...tenant,\n\t\torganizationIdLegacy: legacy\n\t});\n\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.labels.removed\"));\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"removeTenantOrgAlias.js","sourceRoot":"","sources":["../../../src/commands/removeTenantOrgAlias.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,wCAAwC,CAAC,kBAExD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,uDAAuD,CAAC;QACxF,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,mDAAmD,CAAC;QAChF,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,yEAAyE,CACzE;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,WAAW;gBAChB,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,SAAS;gBACvB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,wEAAwE,CACxE;gBACD,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,GAAG,EAAE,OAAO;gBACZ,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,oEAAoE,CACpE;gBACD,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,GAAG,EAAE,UAAU;gBACf,IAAI,EAAE,Q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Y,CAAC,sBAAsB,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAExB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,2DAA2D,CAAC,CAAC,CAAC;IACjG,UAAU,CAAC,YAAY,EAAE,CAAC;IAE1B,MAAM,oBAAoB,CAAC,MAAM,CAAC;QACjC,GAAG,MAAM;QACT,oBAAoB,EAAE,MAAM;KAC5B,CAAC,CAAC;IAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,CAAC,CAAC;IAEhG,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,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 { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"remove-tenant-org-alias\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionRemoveTenantOrgAlias(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.remove-tenant-org-alias.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.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.remove-tenant-org-alias.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.remove-tenant-org-alias.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"alias\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.remove-tenant-org-alias.params.alias.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.remove-tenant-org-alias.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) => removeTenantOrgAlias(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for removing an alias from the tenant organization ID legacy list.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.tenantId The tenant ID to update.\n * @param params.alias The alias to remove from the legacy list.\n * @returns A promise that resolves when the alias has been removed.\n * @throws GeneralError if the tenant admin component is not registered, or the alias is not found.\n */\nexport async function removeTenantOrgAlias(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\ttenantId?: string;\n\t\talias?: string;\n\t}\n): Promise<void> {\n\tconst defaultTenantAdminComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(defaultTenantAdminComponentType)) {\n\t\tthrow new GeneralError(\"removeTenantOrgAlias\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tGuards.stringHexLength(\"removeTenantOrgAlias\", \"tenant-id\", params.tenantId, 32);\n\n\tDid.guard(\"removeTenantOrgAlias\", \"alias\", params.alias);\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(\n\t\tdefaultTenantAdminComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.labels.reading\"));\n\n\tconst tenant = await tenantAdminComponent.get(params.tenantId);\n\tconst legacy = [...(tenant.organizationIdLegacy ?? [])];\n\tconst index = legacy.indexOf(params.alias);\n\n\tif (index < 0) {\n\t\tthrow new GeneralError(\"removeTenantOrgAlias\", \"aliasNotFound\", { alias: params.alias });\n\t}\n\n\tlegacy.splice(index, 1);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.labels.updating\"));\n\tCLIDisplay.spinnerStart();\n\n\tawait tenantAdminComponent.update({\n\t\t...tenant,\n\t\torganizationIdLegacy: legacy\n\t});\n\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.remove-tenant-org-alias.labels.removed\"));\n\n\tCLIDisplay.done();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"setNodeOrgId.js","sourceRoot":"","sources":["../../../src/commands/setNodeOrgId.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAMhD,MAAM,YAAY,GAAG,iBAAiB,C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AAC,cAAc,CAAC,CAAC;IAEnE,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,KAAK,CAAC,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC;IACjD,UAAU,CAAC,aAAa,EAAE,CAAC;IAE3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC,CAAC;IAEvF,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Coerce, GeneralError, I18n } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\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 = \"set-node-org-id\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionSetNodeOrgId(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.set-node-org-id.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.set-node-org-id.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.set-node-org-id.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: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.set-node-org-id.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.set-node-org-id.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) => setNodeOrgId(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting the node organization ID.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.organizationId The organization ID to set.\n * @returns A promise that resolves when the node organization ID has been persisted.\n * @throws GeneralError if called while multi-tenant mode is enabled.\n */\nexport async function setNodeOrgId(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\torganizationId?: string;\n\t}\n): Promise<void> {\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tthrow new GeneralError(\"setNodeOrgId\", \"notAvailableInMultiTenantMode\");\n\t}\n\n\tDid.guard(\"setNodeOrgId\", \"organizationId\", params.organizationId);\n\n\tconst state = engineCore.getState();\n\tstate.nodeOrganizationId = params.organizationId;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.set-node-org-id.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"setNodeOrgId.js","sourceRoot":"","sources":["../../../src/commands/setNodeOrgId.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,YAAY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M,IAAI,YAAY,CAAC,cAAc,EAAE,+BAA+B,CAAC,CAAC;IACzE,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,gBAAgB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IAEnE,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,KAAK,CAAC,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC;IACjD,UAAU,CAAC,aAAa,EAAE,CAAC;IAE3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC,CAAC;IAEvF,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Coerce, GeneralError, I18n } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"set-node-org-id\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionSetNodeOrgId(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.set-node-org-id.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.set-node-org-id.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.set-node-org-id.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: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.set-node-org-id.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.set-node-org-id.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) => setNodeOrgId(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting the node organization ID.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.organizationId The organization ID to set.\n * @returns A promise that resolves when the node organization ID has been persisted.\n * @throws GeneralError if called while multi-tenant mode is enabled.\n */\nexport async function setNodeOrgId(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\torganizationId?: string;\n\t}\n): Promise<void> {\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tthrow new GeneralError(\"setNodeOrgId\", \"notAvailableInMultiTenantMode\");\n\t}\n\n\tDid.guard(\"setNodeOrgId\", \"organizationId\", params.organizationId);\n\n\tconst state = engineCore.getState();\n\tstate.nodeOrganizationId = params.organizationId;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.set-node-org-id.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"setTenantOrgId.js","sourceRoot":"","sources":["../../../src/commands/setTenantOrgId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Y,CAAC,EAAE,CAAC;QAC3C,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,GAAG,CAAwB,IAAI,CAAC,CAAC;IAE/E,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,oBAAoB,CAAC,MAAM,CAAC;QACjC,GAAG,MAAM;QACT,cAAc,EAAE,iBAAiB;KACjC,CAAC,CAAC;IAEH,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC;QAC3C,UAAU,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;AACF,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 { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"set-tenant-org-id\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionSetTenantOrgId(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.set-tenant-org-id.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.set-tenant-org-id.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.set-tenant-org-id.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.set-tenant-org-id.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.set-tenant-org-id.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.set-tenant-org-id.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) => setTenantOrgId(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting the organization ID on a tenant.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.tenantId The tenant ID to update.\n * @param params.organizationId The organization ID to set.\n * @returns A promise that resolves when the tenant organization ID has been stored.\n */\nexport async function setTenantOrgId(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t}\n): Promise<void> {\n\tGuards.stringHexLength(\"setTenantOrgId\", \"tenant-id\", params.tenantId, 32);\n\n\tDid.guard(\"setTenantOrgId\", \"organizationId\", params.organizationId);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.set-tenant-org-id.labels.updating\"));\n\tCLIDisplay.spinnerStart();\n\n\tawait applyOrganizationIdToTenant(engineCore, params.tenantId, params.organizationId);\n\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.set-tenant-org-id.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n\n/**\n * Apply a new organization ID to a tenant.\n * @param engineCore The engine core used to look up the tenantAdminComponent.\n * @param tenantId The ID of the tenant to update.\n * @param newOrganizationId The new organization DID to set.\n * @param options Optional display and behaviour overrides.\n * @param options.sectionLabel When set, emits a CLI section header before and done marker after.\n * @param options.required When false, returns silently when the component is not registered (default true).\n * @returns A promise that resolves when the tenant record has been updated.\n * @throws GeneralError if the component is required but not registered.\n */\nexport async function applyOrganizationIdToTenant(\n\tengineCore: IEngineCore,\n\ttenantId: string,\n\tnewOrganizationId: string,\n\toptions?: { sectionLabel?: string; required?: boolean }\n): Promise<void> {\n\tconst type = engineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(type)) {\n\t\tif (options?.required ?? true) {\n\t\t\tthrow new GeneralError(\"applyOrganizationIdToTenant\", \"tenantAdminComponentNotRegistered\");\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.stringValue(options?.sectionLabel)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(options.sectionLabel);\n\t}\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(type);\n\n\tconst tenant = await tenantAdminComponent.get(tenantId);\n\tawait tenantAdminComponent.update({\n\t\t...tenant,\n\t\torganizationId: newOrganizationId\n\t});\n\n\tif (Is.stringValue(options?.sectionLabel)) {\n\t\tCLIDisplay.done();\n\t}\n}\n"]}
1
+ {"version":3,"file":"setTenantOrgId.js","sourceRoot":"","sources":["../../../src/commands/setTenantOrgId.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oB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;QACnB,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,oBAAoB,GAAG,gBAAgB,CAAC,GAAG,CAAwB,IAAI,CAAC,CAAC;IAE/E,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,oBAAoB,CAAC,MAAM,CAAC;QACjC,GAAG,MAAM;QACT,cAAc,EAAE,iBAAiB;KACjC,CAAC,CAAC;IAEH,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC;QAC3C,UAAU,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;AACF,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 { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"set-tenant-org-id\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionSetTenantOrgId(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.set-tenant-org-id.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.set-tenant-org-id.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.set-tenant-org-id.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.set-tenant-org-id.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.set-tenant-org-id.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.set-tenant-org-id.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) => setTenantOrgId(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting the organization ID on a tenant.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.tenantId The tenant ID to update.\n * @param params.organizationId The organization ID to set.\n * @returns A promise that resolves when the tenant organization ID has been stored.\n */\nexport async function setTenantOrgId(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t}\n): Promise<void> {\n\tGuards.stringHexLength(\"setTenantOrgId\", \"tenant-id\", params.tenantId, 32);\n\n\tDid.guard(\"setTenantOrgId\", \"organizationId\", params.organizationId);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.set-tenant-org-id.labels.updating\"));\n\tCLIDisplay.spinnerStart();\n\n\tawait applyOrganizationIdToTenant(engineCore, params.tenantId, params.organizationId);\n\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.set-tenant-org-id.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n\n/**\n * Apply a new organization ID to a tenant.\n * @param engineCore The engine core used to look up the tenantAdminComponent.\n * @param tenantId The ID of the tenant to update.\n * @param newOrganizationId The new organization DID to set.\n * @param options Optional display and behaviour overrides.\n * @param options.sectionLabel When set, emits a CLI section header before and done marker after.\n * @param options.required When false, returns silently when the component is not registered (default true).\n * @returns A promise that resolves when the tenant record has been updated.\n * @throws GeneralError if the component is required but not registered.\n */\nexport async function applyOrganizationIdToTenant(\n\tengineCore: IEngineCore,\n\ttenantId: string,\n\tnewOrganizationId: string,\n\toptions?: { sectionLabel?: string; required?: boolean }\n): Promise<void> {\n\tconst type = engineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(type)) {\n\t\tif (options?.required ?? true) {\n\t\t\tthrow new GeneralError(\"applyOrganizationIdToTenant\", \"tenantAdminComponentNotRegistered\");\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.stringValue(options?.sectionLabel)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(options.sectionLabel);\n\t}\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(type);\n\n\tconst tenant = await tenantAdminComponent.get(tenantId);\n\tawait tenantAdminComponent.update({\n\t\t...tenant,\n\t\torganizationId: newOrganizationId\n\t});\n\n\tif (Is.stringValue(options?.sectionLabel)) {\n\t\tCLIDisplay.done();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tenantCreate.js","sourceRoot":"","sources":["../../../src/commands/tenantCreate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,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ClC,GAAG,MAAM,UAAU,KAAK,GAAG;YAC3B,GAAG,MAAM,kBAAkB,YAAY,GAAG;SAC1C,CAAC;QACF,IAAI,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;YACpC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,MAAM,oBAAoB,cAAc,GAAG,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITenantAdminComponent } from \"@twin.org/api-models\";\nimport { TenantIdHelper } from \"@twin.org/api-tenant-processor\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ComponentFactory, GeneralError, Guards, I18n, Is, Url } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"tenant-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionTenantCreate(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.tenant-create.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.tenant-create.example\"),\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.tenant-create.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.tenant-id.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: \"api-key\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.api-key.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: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"public-origin\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"url\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.public-origin.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: \"label\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.tenant-create.params.label.description\"),\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.tenant-create.params.load-env.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: \"output-json\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.output-json.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: \"output-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.output-env.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: \"output-env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.output-env-prefix.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) => tenantCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating a tenant.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.apiKey The api key to add.\n * @param params.tenantId The tenant ID to add the api key to.\n * @param params.organizationId The organization DID to associate with the tenant.\n * @param params.label The label for the api key.\n * @param params.publicOrigin The public URL origin for the tenant.\n * @param params.outputJson The output .json file to store the command output.\n * @param params.outputEnv The output .env file to store the command output.\n * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.\n * @returns The created tenant details.\n */\nexport async function tenantCreate(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tapiKey?: string;\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t\tlabel?: string;\n\t\tpublicOrigin?: string;\n\t\toutputJson?: string;\n\t\toutputEnv?: string;\n\t\toutputEnvPrefix?: string;\n\t}\n): Promise<{\n\tapiKey: string;\n\ttenantId: string;\n\torganizationId?: string;\n\tlabel: string;\n\tpublicOrigin: string;\n}> {\n\tif (Is.stringValue(params.tenantId)) {\n\t\tGuards.stringHexLength(\"tenantCreate\", \"tenant-id\", params.tenantId, 32);\n\t}\n\n\tif (Is.stringValue(params.apiKey)) {\n\t\tGuards.stringHexLength(\"tenantCreate\", \"api-key\", params.apiKey, 32);\n\t}\n\n\tDid.guard(\"tenantCreate\", \"organization-id\", params.organizationId);\n\n\tif (Is.stringValue(params.publicOrigin)) {\n\t\tUrl.guard(\"tenantCreate\", \"public-origin\", params.publicOrigin);\n\t}\n\n\tconst tenantAdminServiceComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(tenantAdminServiceComponentType)) {\n\t\tthrow new GeneralError(\"tenantCreate\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\ttenantAdminServiceComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.creating\"));\n\n\tconst apiKey = params.apiKey ?? TenantIdHelper.generateApiKey();\n\tconst tenantId = params.tenantId ?? TenantIdHelper.generateTenantId();\n\tconst organizationId = params.organizationId;\n\tconst label = params.label ?? \"\";\n\tconst publicOrigin = params.publicOrigin ?? \"\";\n\tawait tenantAdminService.create({\n\t\tid: tenantId,\n\t\tapiKey,\n\t\torganizationId,\n\t\tlabel,\n\t\tpublicOrigin\n\t});\n\n\tCLIDisplay.break();\n\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.tenantId\"), tenantId);\n\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.apiKey\"), apiKey);\n\tif (Is.stringValue(organizationId)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.tenant-create.labels.organizationId\"),\n\t\t\torganizationId\n\t\t);\n\t}\n\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.label\"), label);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-create.labels.publicOrigin\"),\n\t\tpublicOrigin\n\t);\n\tCLIDisplay.break();\n\n\tconst json: {\n\t\tapiKey: string;\n\t\ttenantId: string;\n\t\torganizationId?: string;\n\t\tlabel: string;\n\t\tpublicOrigin: string;\n\t} = {\n\t\tapiKey,\n\t\ttenantId,\n\t\tlabel,\n\t\tpublicOrigin\n\t};\n\tif (Is.stringValue(organizationId)) {\n\t\tjson.organizationId = organizationId;\n\t}\n\tif (Is.stringValue(params.outputJson)) {\n\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t}\n\n\tif (Is.stringValue(params.outputEnv)) {\n\t\tconst prefix = params.outputEnvPrefix ?? \"\";\n\t\tconst envLines = [\n\t\t\t`${prefix}API_KEY=\"${apiKey}\"`,\n\t\t\t`${prefix}TENANT_ID=\"${tenantId}\"`,\n\t\t\t`${prefix}LABEL=\"${label}\"`,\n\t\t\t`${prefix}PUBLIC_ORIGIN=\"${publicOrigin}\"`\n\t\t];\n\t\tif (Is.stringValue(organizationId)) {\n\t\t\tenvLines.splice(2, 0, `${prefix}ORGANIZATION_ID=\"${organizationId}\"`);\n\t\t}\n\t\tawait CLIUtils.writeEnvFile(params.outputEnv, envLines, false);\n\t}\n\n\tCLIDisplay.done();\n\n\treturn json;\n}\n"]}
1
+ {"version":3,"file":"tenantCreate.js","sourceRoot":"","sources":["../../../src/commands/tenantCreate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,MAAM,YAAY,GAAG,eAAe,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,kBAEhD;IACA,kBAAkB,CAAC,YAAY,C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C,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITenantAdminComponent } from \"@twin.org/api-models\";\nimport { TenantIdHelper } from \"@twin.org/api-tenant-processor\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ComponentFactory, GeneralError, Guards, I18n, Is, Url } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"tenant-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionTenantCreate(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.tenant-create.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.tenant-create.example\"),\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.tenant-create.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.tenant-id.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: \"api-key\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.api-key.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: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"public-origin\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"url\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.public-origin.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: \"label\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.tenant-create.params.label.description\"),\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.tenant-create.params.load-env.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: \"output-json\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.output-json.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: \"output-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.output-env.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: \"output-env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-create.params.output-env-prefix.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) => tenantCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating a tenant.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.apiKey The api key to add.\n * @param params.tenantId The tenant ID to add the api key to.\n * @param params.organizationId The organization DID to associate with the tenant.\n * @param params.label The label for the api key.\n * @param params.publicOrigin The public URL origin for the tenant.\n * @param params.outputJson The output .json file to store the command output.\n * @param params.outputEnv The output .env file to store the command output.\n * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.\n * @returns The created tenant details.\n */\nexport async function tenantCreate(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tapiKey?: string;\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t\tlabel?: string;\n\t\tpublicOrigin?: string;\n\t\toutputJson?: string;\n\t\toutputEnv?: string;\n\t\toutputEnvPrefix?: string;\n\t}\n): Promise<{\n\tapiKey: string;\n\ttenantId: string;\n\torganizationId?: string;\n\tlabel: string;\n\tpublicOrigin: string;\n}> {\n\tif (Is.stringValue(params.tenantId)) {\n\t\tGuards.stringHexLength(\"tenantCreate\", \"tenant-id\", params.tenantId, 32);\n\t}\n\n\tif (Is.stringValue(params.apiKey)) {\n\t\tGuards.stringHexLength(\"tenantCreate\", \"api-key\", params.apiKey, 32);\n\t}\n\n\tDid.guard(\"tenantCreate\", \"organization-id\", params.organizationId);\n\n\tif (Is.stringValue(params.publicOrigin)) {\n\t\tUrl.guard(\"tenantCreate\", \"public-origin\", params.publicOrigin);\n\t}\n\n\tconst tenantAdminServiceComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(tenantAdminServiceComponentType)) {\n\t\tthrow new GeneralError(\"tenantCreate\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\ttenantAdminServiceComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.creating\"));\n\n\tconst apiKey = params.apiKey ?? TenantIdHelper.generateApiKey();\n\tconst tenantId = params.tenantId ?? TenantIdHelper.generateTenantId();\n\tconst organizationId = params.organizationId;\n\tconst label = params.label ?? \"\";\n\tconst publicOrigin = params.publicOrigin ?? \"\";\n\tawait tenantAdminService.create({\n\t\tid: tenantId,\n\t\tapiKey,\n\t\torganizationId,\n\t\tlabel,\n\t\tpublicOrigin\n\t});\n\n\tCLIDisplay.break();\n\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.tenantId\"), tenantId);\n\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.apiKey\"), apiKey);\n\tif (Is.stringValue(organizationId)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.tenant-create.labels.organizationId\"),\n\t\t\torganizationId\n\t\t);\n\t}\n\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.tenant-create.labels.label\"), label);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-create.labels.publicOrigin\"),\n\t\tpublicOrigin\n\t);\n\tCLIDisplay.break();\n\n\tconst json: {\n\t\tapiKey: string;\n\t\ttenantId: string;\n\t\torganizationId?: string;\n\t\tlabel: string;\n\t\tpublicOrigin: string;\n\t} = {\n\t\tapiKey,\n\t\ttenantId,\n\t\tlabel,\n\t\tpublicOrigin\n\t};\n\tif (Is.stringValue(organizationId)) {\n\t\tjson.organizationId = organizationId;\n\t}\n\tif (Is.stringValue(params.outputJson)) {\n\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t}\n\n\tif (Is.stringValue(params.outputEnv)) {\n\t\tconst prefix = params.outputEnvPrefix ?? \"\";\n\t\tconst envLines = [\n\t\t\t`${prefix}API_KEY=\"${apiKey}\"`,\n\t\t\t`${prefix}TENANT_ID=\"${tenantId}\"`,\n\t\t\t`${prefix}LABEL=\"${label}\"`,\n\t\t\t`${prefix}PUBLIC_ORIGIN=\"${publicOrigin}\"`\n\t\t];\n\t\tif (Is.stringValue(organizationId)) {\n\t\t\tenvLines.splice(2, 0, `${prefix}ORGANIZATION_ID=\"${organizationId}\"`);\n\t\t}\n\t\tawait CLIUtils.writeEnvFile(params.outputEnv, envLines, false);\n\t}\n\n\tCLIDisplay.done();\n\n\treturn json;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tenantImport.js","sourceRoot":"","sources":["../../../src/commands/tenantImport.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,MAAM,YAAY,GAAG,eAAe,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,kBAEhD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,6CAA6C,CAAC;QAC9E,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,yCAAyC,CAAC;QACtE,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,+DAA+D,CAC/D;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,WAAW;gBAChB,IAAI,EAAE,QAAQ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,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC,CAAC;IAEvF,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,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 { ComponentFactory, GeneralError, Guards, I18n, Is, Url } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"tenant-import\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionTenantImport(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.tenant-import.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.tenant-import.example\"),\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.tenant-import.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"api-key\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.api-key.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"label\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.tenant-import.params.label.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"public-origin\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"url\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.public-origin.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.tenant-import.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) => tenantImport(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for importing a tenant with a known tenant ID and API key.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.apiKey The API key to import.\n * @param params.tenantId The tenant ID to import.\n * @param params.organizationId The organization DID to associate with the tenant.\n * @param params.label The label for the tenant.\n * @param params.publicOrigin The public URL origin for the tenant.\n * @returns A promise that resolves when the tenant record has been created.\n */\nexport async function tenantImport(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tapiKey?: string;\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t\tlabel?: string;\n\t\tpublicOrigin?: string;\n\t}\n): Promise<void> {\n\tGuards.stringHexLength(\"tenantImport\", \"tenant-id\", params.tenantId, 32);\n\tGuards.stringHexLength(\"tenantImport\", \"api-key\", params.apiKey, 32);\n\n\tDid.guard(\"tenantImport\", \"organization-id\", params.organizationId);\n\n\tif (Is.stringValue(params.publicOrigin)) {\n\t\tUrl.guard(\"tenantImport\", \"public-origin\", params.publicOrigin);\n\t}\n\n\tconst tenantAdminServiceComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(tenantAdminServiceComponentType)) {\n\t\tthrow new GeneralError(\"tenantImport\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\ttenantAdminServiceComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-import.labels.importing\"));\n\tCLIDisplay.spinnerStart();\n\n\tconst apiKey = params.apiKey;\n\tconst tenantId = params.tenantId;\n\tconst organizationId = params.organizationId;\n\tconst label = params.label ?? \"\";\n\tconst publicOrigin = params.publicOrigin ?? \"\";\n\tawait tenantAdminService.create({\n\t\tid: tenantId,\n\t\tapiKey,\n\t\torganizationId,\n\t\tlabel,\n\t\tpublicOrigin\n\t});\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-import.labels.imported\"));\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"tenantImport.js","sourceRoot":"","sources":["../../../src/commands/tenantImport.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EA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EF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kDAAkD,CAAC,CAAC,CAAC;IACxF,UAAU,CAAC,YAAY,EAAE,CAAC;IAE1B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;IAC/C,MAAM,kBAAkB,CAAC,MAAM,CAAC;QAC/B,EAAE,EAAE,QAAQ;QACZ,MAAM;QACN,cAAc;QACd,KAAK;QACL,YAAY;KACZ,CAAC,CAAC;IACH,UAAU,CAAC,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC,CAAC;IAEvF,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,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 { ComponentFactory, GeneralError, Guards, I18n, Is, Url } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"tenant-import\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionTenantImport(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.tenant-import.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.tenant-import.example\"),\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.tenant-import.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"api-key\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.api-key.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"label\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.tenant-import.params.label.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"public-origin\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"url\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-import.params.public-origin.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.tenant-import.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) => tenantImport(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for importing a tenant with a known tenant ID and API key.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.apiKey The API key to import.\n * @param params.tenantId The tenant ID to import.\n * @param params.organizationId The organization DID to associate with the tenant.\n * @param params.label The label for the tenant.\n * @param params.publicOrigin The public URL origin for the tenant.\n * @returns A promise that resolves when the tenant record has been created.\n */\nexport async function tenantImport(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tapiKey?: string;\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t\tlabel?: string;\n\t\tpublicOrigin?: string;\n\t}\n): Promise<void> {\n\tGuards.stringHexLength(\"tenantImport\", \"tenant-id\", params.tenantId, 32);\n\tGuards.stringHexLength(\"tenantImport\", \"api-key\", params.apiKey, 32);\n\n\tDid.guard(\"tenantImport\", \"organization-id\", params.organizationId);\n\n\tif (Is.stringValue(params.publicOrigin)) {\n\t\tUrl.guard(\"tenantImport\", \"public-origin\", params.publicOrigin);\n\t}\n\n\tconst tenantAdminServiceComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(tenantAdminServiceComponentType)) {\n\t\tthrow new GeneralError(\"tenantImport\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\ttenantAdminServiceComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-import.labels.importing\"));\n\tCLIDisplay.spinnerStart();\n\n\tconst apiKey = params.apiKey;\n\tconst tenantId = params.tenantId;\n\tconst organizationId = params.organizationId;\n\tconst label = params.label ?? \"\";\n\tconst publicOrigin = params.publicOrigin ?? \"\";\n\tawait tenantAdminService.create({\n\t\tid: tenantId,\n\t\tapiKey,\n\t\torganizationId,\n\t\tlabel,\n\t\tpublicOrigin\n\t});\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-import.labels.imported\"));\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tenantUpdate.js","sourceRoot":"","sources":["../../../src/commands/tenantUpdate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,MAAM,YAAY,GAAG,eAAe,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,kBAEhD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,6CAA6C,CAAC;QAC9E,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,yCAAyC,CAAC;QACtE,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,+DAA+D,CAC/D;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,WAAW;gBAChB,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,SAAS;gBACvB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,8DAA8D,CAC9D;gBACD,QAAQ,EAA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AAC;QACvF,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;QAC5D,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;KACjF,CAAC,CAAC;IACH,UAAU,CAAC,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC,CAAC,CAAC;IAEtF,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,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 { ComponentFactory, GeneralError, Guards, I18n, Is, Url } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"tenant-update\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionTenantUpdate(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.tenant-update.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.tenant-update.example\"),\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.tenant-update.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"api-key\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.api-key.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: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.organization-id.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: \"label\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.tenant-update.params.label.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"public-origin\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"url\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.public-origin.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.tenant-update.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) => tenantUpdate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for updating a tenant.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.apiKey The api key to update.\n * @param params.tenantId The tenant ID to update.\n * @param params.organizationId The organization DID to associate with the tenant.\n * @param params.label The label for the tenant.\n * @param params.publicOrigin The public URL origin for the tenant.\n * @returns A promise that resolves when the tenant record has been updated.\n */\nexport async function tenantUpdate(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tapiKey?: string;\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t\tlabel?: string;\n\t\tpublicOrigin?: string;\n\t}\n): Promise<void> {\n\tGuards.stringHexLength(\"tenantUpdate\", \"tenant-id\", params.tenantId, 32);\n\n\tif (Is.stringValue(params.apiKey)) {\n\t\tGuards.stringHexLength(\"tenantUpdate\", \"api-key\", params.apiKey, 32);\n\t}\n\n\tif (Is.stringValue(params.organizationId)) {\n\t\tDid.guard(\"tenantUpdate\", \"organization-id\", params.organizationId);\n\t}\n\n\tif (Is.stringValue(params.publicOrigin)) {\n\t\tUrl.guard(\"tenantUpdate\", \"public-origin\", params.publicOrigin);\n\t}\n\n\tconst defaultTenantAdminComponentType =\n\t\tengineCore.getRegisteredInstanceType(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(defaultTenantAdminComponentType)) {\n\t\tthrow new GeneralError(\"tenantUpdate\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(\n\t\tdefaultTenantAdminComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-update.labels.updating\"));\n\tCLIDisplay.spinnerStart();\n\n\tconst tenant = await tenantAdminComponent.get(params.tenantId);\n\tawait tenantAdminComponent.update({\n\t\t...tenant,\n\t\t...(Is.stringValue(params.apiKey) && { apiKey: params.apiKey }),\n\t\t...(Is.stringValue(params.organizationId) && { organizationId: params.organizationId }),\n\t\t...(Is.stringValue(params.label) && { label: params.label }),\n\t\t...(Is.stringValue(params.publicOrigin) && { publicOrigin: params.publicOrigin })\n\t});\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-update.labels.updated\"));\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"tenantUpdate.js","sourceRoot":"","sources":["../../../src/commands/tenantUpdate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEvF,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAIhD,MAAM,YAAY,GAAG,eAAe,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,kBAEhD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,6CAA6C,CAAC;QAC9E,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,yCAAyC,CAAC;QACtE,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,+DAA+D,CAC/D;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,WAAW;gBAChB,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,SAAS;gBACvB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,8DAA8D,CAC9D;gBACD,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,SAAS;gBACvB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,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AG,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;KACjF,CAAC,CAAC;IACH,UAAU,CAAC,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,gDAAgD,CAAC,CAAC,CAAC;IAEtF,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,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 { ComponentFactory, GeneralError, Guards, I18n, Is, Url } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"tenant-update\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionTenantUpdate(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.tenant-update.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.tenant-update.example\"),\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.tenant-update.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"api-key\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.api-key.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: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.organization-id.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: \"label\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.tenant-update.params.label.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"public-origin\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"url\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-update.params.public-origin.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.tenant-update.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) => tenantUpdate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for updating a tenant.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.apiKey The api key to update.\n * @param params.tenantId The tenant ID to update.\n * @param params.organizationId The organization DID to associate with the tenant.\n * @param params.label The label for the tenant.\n * @param params.publicOrigin The public URL origin for the tenant.\n * @returns A promise that resolves when the tenant record has been updated.\n */\nexport async function tenantUpdate(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tapiKey?: string;\n\t\ttenantId?: string;\n\t\torganizationId?: string;\n\t\tlabel?: string;\n\t\tpublicOrigin?: string;\n\t}\n): Promise<void> {\n\tGuards.stringHexLength(\"tenantUpdate\", \"tenant-id\", params.tenantId, 32);\n\n\tif (Is.stringValue(params.apiKey)) {\n\t\tGuards.stringHexLength(\"tenantUpdate\", \"api-key\", params.apiKey, 32);\n\t}\n\n\tif (Is.stringValue(params.organizationId)) {\n\t\tDid.guard(\"tenantUpdate\", \"organization-id\", params.organizationId);\n\t}\n\n\tif (Is.stringValue(params.publicOrigin)) {\n\t\tUrl.guard(\"tenantUpdate\", \"public-origin\", params.publicOrigin);\n\t}\n\n\tconst defaultTenantAdminComponentType =\n\t\tengineCore.getRegisteredInstanceType(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(defaultTenantAdminComponentType)) {\n\t\tthrow new GeneralError(\"tenantUpdate\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(\n\t\tdefaultTenantAdminComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-update.labels.updating\"));\n\tCLIDisplay.spinnerStart();\n\n\tconst tenant = await tenantAdminComponent.get(params.tenantId);\n\tawait tenantAdminComponent.update({\n\t\t...tenant,\n\t\t...(Is.stringValue(params.apiKey) && { apiKey: params.apiKey }),\n\t\t...(Is.stringValue(params.organizationId) && { organizationId: params.organizationId }),\n\t\t...(Is.stringValue(params.label) && { label: params.label }),\n\t\t...(Is.stringValue(params.publicOrigin) && { publicOrigin: params.publicOrigin })\n\t});\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-update.labels.updated\"));\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"userCreate.js","sourceRoot":"","sources":["../../../src/commands/userCreate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,GAAG,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAKjF,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,kBAE9C;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,2CAA2C,CAAC;QAC5E,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,uCAAuC,CAAC;QACpE,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,6DAA6D,CAC7D;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,eAAe;gBACpB,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,gEAAgE,CAChE;aACD;YACD;gBACC,GAAG,EAAE,uBAAuB;gBAC5B,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,wEAAwE,CACx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,CAAC,eAAe,aAAa,IAAI,CAAC,QAAQ,GAAG;oBACtD,GAAG,MAAM,CAAC,eAAe,UAAU,MAAM,CAAC,KAAK,IAAI,EAAE,GAAG;oBACxD,GAAG,MAAM,CAAC,eAAe,eAAe,MAAM,CAAC,SAAS,IAAI,EAAE,GAAG;oBACjE,GAAG,MAAM,CAAC,eAAe,gBAAgB,MAAM,CAAC,UAAU,IAAI,EAAE,GAAG;iBACnE,EACD,KAAK,CACL,CAAC;YACH,CAAC;QACF,CAAC;QAED,UAAU,CAAC,IAAI,EAAE,CAAC;QAElB,OAAO,IAAI,CAAC;IACb,CAAC,CACD,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationAdminComponent,\n\tIAuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport { PasswordGenerator } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityProfileConnectorFactory } from \"@twin.org/identity-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"user-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionUserCreate(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.user-create.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.user-create.example\"),\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.user-create.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: \"user-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.user-identity.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.organization-identity.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.tenant-id.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"email\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"email\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.email.description\")\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"password\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.password.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: \"scope\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.scope.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"given-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.given-name.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: \"family-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.family-name.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: \"overwrite-mode\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.overwrite-mode.description\"\n\t\t\t\t),\n\t\t\t\toptions: [\"skip\", \"overwrite\", \"error\"],\n\t\t\t\tdefaultValue: \"skip\",\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.user-create.params.load-env.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: \"output-json\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.output-json.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: \"output-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.output-env.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: \"output-env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.output-env-prefix.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) => userCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating a user.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.userIdentity The DID for the user.\n * @param params.organizationIdentity The organization DID for the user.\n * @param params.tenantId The tenant ID for the user.\n * @param params.email The email for the user.\n * @param params.password The password for the user.\n * @param params.scope The scope for the user.\n * @param params.givenName The given name for the user.\n * @param params.familyName The family name for the user.\n * @param params.overwriteMode The mode to use when a user with the same identity already exists.\n * @param params.outputJson The output .json file to store the command output.\n * @param params.outputEnv The output .env file to store the command output.\n * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.\n * @returns The created user details or undefined if skipped.\n */\nexport async function userCreate(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tuserIdentity?: string;\n\t\torganizationIdentity?: string;\n\t\ttenantId?: string;\n\t\temail?: string;\n\t\tpassword?: string;\n\t\tscope?: string;\n\t\tgivenName?: string;\n\t\tfamilyName?: string;\n\t\toverwriteMode?: \"skip\" | \"overwrite\" | \"error\";\n\t\toutputJson?: string;\n\t\toutputEnv?: string;\n\t\toutputEnvPrefix?: string;\n\t}\n): Promise<\n\t| {\n\t\t\tdid: string;\n\t\t\torganizationDid: string;\n\t\t\temail: string;\n\t\t\tpassword: string;\n\t\t\tscope: string[];\n\t\t\tgivenName: string;\n\t\t\tfamilyName: string;\n\t }\n\t| undefined\n> {\n\tconst paramsEmail = params.email;\n\tconst paramsUserIdentity = params.userIdentity;\n\tconst paramsOrganizationIdentity = params.organizationIdentity;\n\tGuards.email(\"userCreate\", \"email\", paramsEmail);\n\tDid.guard(\"userCreate\", \"user-identity\", paramsUserIdentity);\n\tDid.guard(\"userCreate\", \"organization-identity\", paramsOrganizationIdentity);\n\tif (Is.stringValue(params.tenantId)) {\n\t\tGuards.stringHexLength(\"userCreate\", \"tenant-id\", params.tenantId, 32);\n\t} else if (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tthrow new GeneralError(\"userCreate\", \"tenantIdRequired\");\n\t}\n\n\tif (Is.stringValue(params.password) && params.password.length < 16) {\n\t\tthrow new GeneralError(\"userCreate\", \"passwordTooShort\", { minLength: 16 });\n\t}\n\n\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityProfileConnector\"\n\t);\n\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\tdefaultIdentityProfileConnectorType\n\t);\n\n\tconst defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"authenticationAdminComponent\"\n\t);\n\tconst authenticationAdminComponent = ComponentFactory.get<IAuthenticationAdminComponent>(\n\t\tdefaultAuthenticationAdminComponentType\n\t);\n\n\tlet createUser = true;\n\n\tconst currentContextIds = (await ContextIdStore.getContextIds()) ?? {};\n\tconst returnJson = await ContextIdStore.run(\n\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\tasync () => {\n\t\t\tlet existingUser: IAuthenticationUser | undefined;\n\t\t\ttry {\n\t\t\t\texistingUser = await authenticationAdminComponent.get(paramsEmail);\n\t\t\t} catch {}\n\n\t\t\tif (!Is.empty(existingUser)) {\n\t\t\t\tif (params.overwriteMode === \"error\") {\n\t\t\t\t\tthrow new GeneralError(\"userCreate\", \"userAlreadyExists\");\n\t\t\t\t} else if (params.overwriteMode === \"skip\") {\n\t\t\t\t\tcreateUser = false;\n\t\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.skipping\"));\n\t\t\t\t} else if (params.overwriteMode === \"overwrite\") {\n\t\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.overwriting\"));\n\t\t\t\t\tconst userToRemove = existingUser;\n\t\t\t\t\tawait ContextIdStore.run(\n\t\t\t\t\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.remove(userToRemove.email);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tawait identityProfileConnector.remove(userToRemove.userIdentity);\n\t\t\t\t\texistingUser = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet json;\n\t\t\tif (createUser) {\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.creating\"));\n\n\t\t\t\tconst user: IAuthenticationUser & { password: string } = {\n\t\t\t\t\temail: paramsEmail,\n\t\t\t\t\tpassword: params.password ?? PasswordGenerator.generate(16),\n\t\t\t\t\tuserIdentity: paramsUserIdentity,\n\t\t\t\t\torganizationIdentity: paramsOrganizationIdentity,\n\t\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? []\n\t\t\t\t};\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingUser\"));\n\n\t\t\t\tawait ContextIdStore.run(\n\t\t\t\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (existingUser) {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.update(user);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.create(user);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst name = `${params.givenName ?? \"\"} ${params.familyName ?? \"\"}`.trim();\n\t\t\t\tconst publicProfile: WithContext<Person> = {\n\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tname: name.length > 0 ? name : undefined\n\t\t\t\t};\n\t\t\t\tconst privateProfile: WithContext<Person> = {\n\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tgivenName: params.givenName,\n\t\t\t\t\tfamilyName: params.familyName,\n\t\t\t\t\temail: paramsEmail\n\t\t\t\t};\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingProfile\"));\n\t\t\t\tawait identityProfileConnector.create(paramsUserIdentity, publicProfile, privateProfile);\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.userCreated\"));\n\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.user-create.labels.email\"),\n\t\t\t\t\tuser.email\n\t\t\t\t);\n\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.user-create.labels.password\"),\n\t\t\t\t\tuser.password\n\t\t\t\t);\n\n\t\t\t\tCLIDisplay.break();\n\n\t\t\t\tjson = {\n\t\t\t\t\tdid: paramsUserIdentity,\n\t\t\t\t\torganizationDid: paramsOrganizationIdentity,\n\t\t\t\t\temail: paramsEmail,\n\t\t\t\t\tpassword: user.password,\n\t\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? [],\n\t\t\t\t\tgivenName: params.givenName ?? \"\",\n\t\t\t\t\tfamilyName: params.familyName ?? \"\"\n\t\t\t\t};\n\n\t\t\t\tif (Is.stringValue(params.outputJson)) {\n\t\t\t\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t\t\t\t}\n\n\t\t\t\tif (Is.stringValue(params.outputEnv)) {\n\t\t\t\t\tawait CLIUtils.writeEnvFile(\n\t\t\t\t\t\tparams.outputEnv,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}DID=\"${params.userIdentity}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}ORGANIZATION_DID=\"${params.organizationIdentity}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}EMAIL=\"${paramsEmail}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}PASSWORD=\"${user.password}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}SCOPE=\"${params.scope ?? \"\"}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}GIVEN_NAME=\"${params.givenName ?? \"\"}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}FAMILY_NAME=\"${params.familyName ?? \"\"}\"`\n\t\t\t\t\t\t],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tCLIDisplay.done();\n\n\t\t\treturn json;\n\t\t}\n\t);\n\n\treturn returnJson;\n}\n"]}
1
+ {"version":3,"file":"userCreate.js","sourceRoot":"","sources":["../../../src/commands/userCreate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,GAAG,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAKjF,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,kBAE9C;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,2CAA2C,CAAC;QAC5E,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,uCAAuC,CAAC;QACpE,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,6DAA6D,CAC7D;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,eAAe;gBACpB,IAAI,EAAE,QA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YAAY,CAC1B,MAAM,CAAC,SAAS,EAChB;oBACC,GAAG,MAAM,CAAC,eAAe,QAAQ,MAAM,CAAC,YAAY,GAAG;oBACvD,GAAG,MAAM,CAAC,eAAe,qBAAqB,MAAM,CAAC,oBAAoB,GAAG;oBAC5E,GAAG,MAAM,CAAC,eAAe,UAAU,WAAW,GAAG;oBACjD,GAAG,MAAM,CAAC,eAAe,aAAa,IAAI,CAAC,QAAQ,GAAG;oBACtD,GAAG,MAAM,CAAC,eAAe,UAAU,MAAM,CAAC,KAAK,IAAI,EAAE,GAAG;oBACxD,GAAG,MAAM,CAAC,eAAe,eAAe,MAAM,CAAC,SAAS,IAAI,EAAE,GAAG;oBACjE,GAAG,MAAM,CAAC,eAAe,gBAAgB,MAAM,CAAC,UAAU,IAAI,EAAE,GAAG;iBACnE,EACD,KAAK,CACL,CAAC;YACH,CAAC;QACF,CAAC;QAED,UAAU,CAAC,IAAI,EAAE,CAAC;QAElB,OAAO,IAAI,CAAC;IACb,CAAC,CACD,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationAdminComponent,\n\tIAuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport { PasswordGenerator } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityProfileConnectorFactory } from \"@twin.org/identity-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"user-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionUserCreate(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.user-create.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.user-create.example\"),\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.user-create.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: \"user-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.user-identity.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.organization-identity.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.tenant-id.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"email\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"email\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.email.description\")\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"password\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.password.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: \"scope\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.scope.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"given-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.given-name.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: \"family-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.family-name.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: \"overwrite-mode\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.overwrite-mode.description\"\n\t\t\t\t),\n\t\t\t\toptions: [\"skip\", \"overwrite\", \"error\"],\n\t\t\t\tdefaultValue: \"skip\",\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.user-create.params.load-env.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: \"output-json\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.output-json.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: \"output-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.output-env.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: \"output-env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.output-env-prefix.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) => userCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating a user.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.userIdentity The DID for the user.\n * @param params.organizationIdentity The organization DID for the user.\n * @param params.tenantId The tenant ID for the user.\n * @param params.email The email for the user.\n * @param params.password The password for the user.\n * @param params.scope The scope for the user.\n * @param params.givenName The given name for the user.\n * @param params.familyName The family name for the user.\n * @param params.overwriteMode The mode to use when a user with the same identity already exists.\n * @param params.outputJson The output .json file to store the command output.\n * @param params.outputEnv The output .env file to store the command output.\n * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.\n * @returns The created user details or undefined if skipped.\n */\nexport async function userCreate(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tuserIdentity?: string;\n\t\torganizationIdentity?: string;\n\t\ttenantId?: string;\n\t\temail?: string;\n\t\tpassword?: string;\n\t\tscope?: string;\n\t\tgivenName?: string;\n\t\tfamilyName?: string;\n\t\toverwriteMode?: \"skip\" | \"overwrite\" | \"error\";\n\t\toutputJson?: string;\n\t\toutputEnv?: string;\n\t\toutputEnvPrefix?: string;\n\t}\n): Promise<\n\t| {\n\t\t\tdid: string;\n\t\t\torganizationDid: string;\n\t\t\temail: string;\n\t\t\tpassword: string;\n\t\t\tscope: string[];\n\t\t\tgivenName: string;\n\t\t\tfamilyName: string;\n\t }\n\t| undefined\n> {\n\tconst paramsEmail = params.email;\n\tconst paramsUserIdentity = params.userIdentity;\n\tconst paramsOrganizationIdentity = params.organizationIdentity;\n\tGuards.email(\"userCreate\", \"email\", paramsEmail);\n\tDid.guard(\"userCreate\", \"user-identity\", paramsUserIdentity);\n\tDid.guard(\"userCreate\", \"organization-identity\", paramsOrganizationIdentity);\n\tif (Is.stringValue(params.tenantId)) {\n\t\tGuards.stringHexLength(\"userCreate\", \"tenant-id\", params.tenantId, 32);\n\t} else if (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tthrow new GeneralError(\"userCreate\", \"tenantIdRequired\");\n\t}\n\n\tif (Is.stringValue(params.password) && params.password.length < 16) {\n\t\tthrow new GeneralError(\"userCreate\", \"passwordTooShort\", { minLength: 16 });\n\t}\n\n\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityProfileConnector\"\n\t);\n\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\tdefaultIdentityProfileConnectorType\n\t);\n\n\tconst defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"authenticationAdminComponent\"\n\t);\n\tconst authenticationAdminComponent = ComponentFactory.get<IAuthenticationAdminComponent>(\n\t\tdefaultAuthenticationAdminComponentType\n\t);\n\n\tlet createUser = true;\n\n\tconst currentContextIds = (await ContextIdStore.getContextIds()) ?? {};\n\tconst returnJson = await ContextIdStore.run(\n\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\tasync () => {\n\t\t\tlet existingUser: IAuthenticationUser | undefined;\n\t\t\ttry {\n\t\t\t\texistingUser = await authenticationAdminComponent.get(paramsEmail);\n\t\t\t} catch {}\n\n\t\t\tif (!Is.empty(existingUser)) {\n\t\t\t\tif (params.overwriteMode === \"error\") {\n\t\t\t\t\tthrow new GeneralError(\"userCreate\", \"userAlreadyExists\");\n\t\t\t\t} else if (params.overwriteMode === \"skip\") {\n\t\t\t\t\tcreateUser = false;\n\t\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.skipping\"));\n\t\t\t\t} else if (params.overwriteMode === \"overwrite\") {\n\t\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.overwriting\"));\n\t\t\t\t\tconst userToRemove = existingUser;\n\t\t\t\t\tawait ContextIdStore.run(\n\t\t\t\t\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.remove(userToRemove.email);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tawait identityProfileConnector.remove(userToRemove.userIdentity);\n\t\t\t\t\texistingUser = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet json;\n\t\t\tif (createUser) {\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.creating\"));\n\n\t\t\t\tconst user: IAuthenticationUser & { password: string } = {\n\t\t\t\t\temail: paramsEmail,\n\t\t\t\t\tpassword: params.password ?? PasswordGenerator.generate(16),\n\t\t\t\t\tuserIdentity: paramsUserIdentity,\n\t\t\t\t\torganizationIdentity: paramsOrganizationIdentity,\n\t\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? []\n\t\t\t\t};\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingUser\"));\n\n\t\t\t\tawait ContextIdStore.run(\n\t\t\t\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (existingUser) {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.update(user);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.create(user);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst name = `${params.givenName ?? \"\"} ${params.familyName ?? \"\"}`.trim();\n\t\t\t\tconst publicProfile: WithContext<Person> = {\n\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tname: name.length > 0 ? name : undefined\n\t\t\t\t};\n\t\t\t\tconst privateProfile: WithContext<Person> = {\n\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tgivenName: params.givenName,\n\t\t\t\t\tfamilyName: params.familyName,\n\t\t\t\t\temail: paramsEmail\n\t\t\t\t};\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingProfile\"));\n\t\t\t\tawait identityProfileConnector.create(paramsUserIdentity, publicProfile, privateProfile);\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.userCreated\"));\n\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.user-create.labels.email\"),\n\t\t\t\t\tuser.email\n\t\t\t\t);\n\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.user-create.labels.password\"),\n\t\t\t\t\tuser.password\n\t\t\t\t);\n\n\t\t\t\tCLIDisplay.break();\n\n\t\t\t\tjson = {\n\t\t\t\t\tdid: paramsUserIdentity,\n\t\t\t\t\torganizationDid: paramsOrganizationIdentity,\n\t\t\t\t\temail: paramsEmail,\n\t\t\t\t\tpassword: user.password,\n\t\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? [],\n\t\t\t\t\tgivenName: params.givenName ?? \"\",\n\t\t\t\t\tfamilyName: params.familyName ?? \"\"\n\t\t\t\t};\n\n\t\t\t\tif (Is.stringValue(params.outputJson)) {\n\t\t\t\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t\t\t\t}\n\n\t\t\t\tif (Is.stringValue(params.outputEnv)) {\n\t\t\t\t\tawait CLIUtils.writeEnvFile(\n\t\t\t\t\t\tparams.outputEnv,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}DID=\"${params.userIdentity}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}ORGANIZATION_DID=\"${params.organizationIdentity}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}EMAIL=\"${paramsEmail}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}PASSWORD=\"${user.password}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}SCOPE=\"${params.scope ?? \"\"}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}GIVEN_NAME=\"${params.givenName ?? \"\"}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}FAMILY_NAME=\"${params.familyName ?? \"\"}\"`\n\t\t\t\t\t\t],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tCLIDisplay.done();\n\n\t\t\treturn json;\n\t\t}\n\t);\n\n\treturn returnJson;\n}\n"]}