@twin.org/node-core 0.0.3-next.53 → 0.0.3-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/builders/engineEnvBuilder.js +52 -10
- package/dist/es/builders/engineEnvBuilder.js.map +1 -1
- package/dist/es/builders/engineServerEnvBuilder.js +32 -32
- package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
- package/dist/es/builders/extensionsBuilder.js +3 -3
- package/dist/es/builders/extensionsBuilder.js.map +1 -1
- package/dist/es/cli.js +6 -3
- package/dist/es/cli.js.map +1 -1
- package/dist/es/commands/bootstrapLegacy.js +173 -116
- package/dist/es/commands/bootstrapLegacy.js.map +1 -1
- package/dist/es/commands/help.js +1 -0
- package/dist/es/commands/help.js.map +1 -1
- package/dist/es/commands/identityCreate.js +38 -16
- package/dist/es/commands/identityCreate.js.map +1 -1
- package/dist/es/commands/identityImports.js +1 -0
- package/dist/es/commands/identityImports.js.map +1 -1
- package/dist/es/commands/identityVerificationMethodCreate.js +13 -11
- package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -1
- package/dist/es/commands/identityVerificationMethodImport.js +2 -1
- package/dist/es/commands/identityVerificationMethodImport.js.map +1 -1
- package/dist/es/commands/nodeSetIdentity.js +5 -0
- package/dist/es/commands/nodeSetIdentity.js.map +1 -1
- package/dist/es/commands/removeTenantOrgAlias.js +3 -1
- package/dist/es/commands/removeTenantOrgAlias.js.map +1 -1
- package/dist/es/commands/setNodeOrgId.js +2 -0
- package/dist/es/commands/setNodeOrgId.js.map +1 -1
- package/dist/es/commands/setTenantOrgId.js +7 -66
- package/dist/es/commands/setTenantOrgId.js.map +1 -1
- package/dist/es/commands/tenantCreate.js +1 -7
- package/dist/es/commands/tenantCreate.js.map +1 -1
- package/dist/es/commands/tenantImport.js +17 -4
- package/dist/es/commands/tenantImport.js.map +1 -1
- package/dist/es/commands/tenantUpdate.js +21 -6
- package/dist/es/commands/tenantUpdate.js.map +1 -1
- package/dist/es/commands/vaultKeyImport.js +4 -3
- package/dist/es/commands/vaultKeyImport.js.map +1 -1
- package/dist/es/defaults.js +21 -0
- package/dist/es/defaults.js.map +1 -1
- package/dist/es/models/ICliArgs.js.map +1 -1
- package/dist/es/models/ICliCommand.js.map +1 -1
- package/dist/es/models/ICliCommandDefinition.js.map +1 -1
- package/dist/es/models/ICliCommandDefinitionParam.js.map +1 -1
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
- package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
- package/dist/es/models/nodeExtensionInitialiseEngineMethod.js.map +1 -1
- package/dist/es/models/nodeExtensionInitialiseEngineServerMethod.js.map +1 -1
- package/dist/es/models/nodeExtensionInitialiseMethod.js.map +1 -1
- package/dist/es/models/nodeExtensionShutdownMethod.js.map +1 -1
- package/dist/es/node.js +1 -1
- package/dist/es/node.js.map +1 -1
- package/dist/es/start.js +11 -13
- package/dist/es/start.js.map +1 -1
- package/dist/es/utils.js +5 -4
- package/dist/es/utils.js.map +1 -1
- package/dist/types/builders/engineEnvBuilder.d.ts +4 -4
- package/dist/types/builders/extensionsBuilder.d.ts +3 -3
- package/dist/types/cli.d.ts +2 -2
- package/dist/types/commands/bootstrapLegacy.d.ts +8 -7
- package/dist/types/commands/help.d.ts +1 -0
- package/dist/types/commands/identityCreate.d.ts +2 -0
- package/dist/types/commands/identityImports.d.ts +1 -0
- package/dist/types/commands/identityVerificationMethodImport.d.ts +2 -1
- package/dist/types/commands/nodeSetIdentity.d.ts +1 -0
- package/dist/types/commands/removeTenantOrgAlias.d.ts +2 -0
- package/dist/types/commands/setNodeOrgId.d.ts +2 -0
- package/dist/types/commands/setTenantOrgId.d.ts +5 -22
- package/dist/types/commands/tenantImport.d.ts +7 -4
- package/dist/types/commands/tenantUpdate.d.ts +5 -2
- package/dist/types/commands/vaultKeyImport.d.ts +4 -3
- package/dist/types/defaults.d.ts +21 -0
- package/dist/types/models/ICliArgs.d.ts +1 -1
- package/dist/types/models/ICliCommand.d.ts +1 -1
- package/dist/types/models/ICliCommandDefinition.d.ts +2 -2
- package/dist/types/models/ICliCommandDefinitionParam.d.ts +1 -1
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +0 -4
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +4 -0
- package/dist/types/models/nodeExtensionInitialiseEngineMethod.d.ts +1 -0
- package/dist/types/models/nodeExtensionInitialiseEngineServerMethod.d.ts +1 -0
- package/dist/types/models/nodeExtensionInitialiseMethod.d.ts +1 -0
- package/dist/types/models/nodeExtensionShutdownMethod.d.ts +1 -0
- package/dist/types/utils.d.ts +4 -3
- package/docs/changelog.md +15 -0
- package/docs/reference/functions/extensionsInitialiseEngine.md +1 -1
- package/docs/reference/functions/extensionsInitialiseEngineServer.md +1 -1
- package/docs/reference/functions/getScriptDirectory.md +1 -1
- package/docs/reference/functions/initialiseLocales.md +2 -0
- package/docs/reference/functions/isFederatedCatalogueRequired.md +3 -3
- package/docs/reference/functions/isRightsManagementRequired.md +1 -1
- package/docs/reference/functions/loadJsonFile.md +1 -1
- package/docs/reference/functions/loadTextFile.md +1 -1
- package/docs/reference/functions/processEnvOptions.md +1 -1
- package/docs/reference/functions/registerCommands.md +1 -1
- package/docs/reference/functions/shutdownExtensions.md +1 -1
- package/docs/reference/interfaces/ICliArgs.md +1 -1
- package/docs/reference/interfaces/ICliCommand.md +1 -1
- package/docs/reference/interfaces/ICliCommandDefinition.md +2 -2
- package/docs/reference/interfaces/ICliCommandDefinitionParam.md +1 -1
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +0 -8
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +8 -12
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +12 -12
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineMethod.md +2 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseEngineServerMethod.md +2 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +2 -0
- package/docs/reference/type-aliases/NodeExtensionShutdownMethod.md +2 -0
- package/docs/reference/variables/ATTESTATION_VERIFICATION_METHOD_ID.md +2 -0
- package/docs/reference/variables/AUTH_SIGNING_KEY_ID.md +2 -0
- package/docs/reference/variables/BLOB_STORAGE_ENCRYPTION_KEY_ID.md +2 -0
- package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_DID.md +2 -0
- package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_TENANT.md +2 -0
- package/docs/reference/variables/IMMUTABLE_PROOF_VERIFICATION_METHOD_ID.md +2 -0
- package/docs/reference/variables/TRUST_VERIFICATION_METHOD_ID.md +2 -0
- package/locales/en.json +17 -9
- package/package.json +1 -1
package/dist/es/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACN,SAAS,EACT,SAAS,EACT,YAAY,EACZ,IAAI,EACJ,EAAE,EAEF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,gBAAwB;IAC/D,MAAM,WAAW,GAA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AAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC9D,OAAO,YAAY,IAAI,QAAQ,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACR,mEAAmE;QACnE,IAAI,CAAC;YACJ,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAC/D,MAAM,kBAAkB,GAAG,MAAM,YAAY,CAK1C,eAAe,CAAC,CAAC;YAEpB,kDAAkD;YAClD,OAAO,kBAAkB,CAAC,MAAM,IAAI,kBAAkB,CAAC,IAAI,IAAI,QAAQ,CAAC;QACzE,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,QAAQ,CAAC;QACjB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACrD,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { execSync } from \"node:child_process\";\nimport { mkdir, readdir, readFile, rename, stat, writeFile } from \"node:fs/promises\";\nimport { get as httpsGet } from \"node:https\";\nimport path from \"node:path\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport {\n\tBaseError,\n\tConverter,\n\tGeneralError,\n\tI18n,\n\tIs,\n\ttype ILocaleDictionary\n} from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport type { ICacheMetadata } from \"./models/ICacheMetadata.js\";\nimport type { IModuleProtocol } from \"./models/IModuleProtocol.js\";\nimport type { IProtocolHandlerResult } from \"./models/IProtocolHandlerResult.js\";\nimport { ModuleProtocol } from \"./models/moduleProtocol.js\";\n\n/**\n * Initialise the locales for the application.\n * @param localesDirectory The directory containing the locales.\n */\nexport async function initialiseLocales(localesDirectory: string): Promise<void> {\n\tconst localesFile = path.resolve(path.join(localesDirectory, \"en.json\"));\n\tCLIDisplay.value(\"Locales File\", localesFile);\n\tif (await fileExists(localesFile)) {\n\t\tconst enLangContent = await readFile(localesFile, \"utf8\");\n\t\tI18n.addDictionary(\"en\", JSON.parse(enLangContent) as ILocaleDictionary);\n\t} else {\n\t\tCLIDisplay.error(`Locales file not found: ${localesFile}`);\n\t}\n}\n\n/**\n * Get the directory where the application is being executed.\n * @returns The execution directory.\n */\nexport function getExecutionDirectory(): string {\n\treturn process.cwd();\n}\n\n/**\n * Get the directory where the script is located.\n * @param args The command line arguments.\n * @returns The execution directory.\n */\nexport function getScriptDirectory(args?: string[]): string {\n\tif (Is.array<string>(args) && args.length >= 2 && args[1].includes(\"index.js\")) {\n\t\treturn path.resolve(path.join(path.dirname(args[1]), \"..\"));\n\t}\n\treturn process.cwd();\n}\n\n/**\n * Does the specified file exist.\n * @param filename The filename to check for existence.\n * @returns True if the file exists.\n */\nexport async function fileExists(filename: string): Promise<boolean> {\n\ttry {\n\t\tconst stats = await stat(filename);\n\t\treturn stats.isFile();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Does the specified directory exist.\n * @param directory The directory to check for existence.\n * @returns True if the directory exists.\n */\nexport async function directoryExists(directory: string): Promise<boolean> {\n\ttry {\n\t\tconst stats = await stat(directory);\n\t\treturn stats.isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get the sub folders for the folder.\n * @param directory The directory to get the sub folders.\n * @returns The list of sub folders.\n */\nexport async function getSubFolders(directory: string): Promise<string[]> {\n\ttry {\n\t\tconst dir = await readdir(directory);\n\t\tconst folders: string[] = [];\n\t\tfor (const dirEntry of dir) {\n\t\t\tconst fullPath = path.join(directory, dirEntry);\n\t\t\tconst stats = await stat(fullPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tfolders.push(fullPath);\n\t\t\t}\n\t\t}\n\t\treturn folders;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Get the files in the directory.\n * @param directory The directory to get the files from.\n * @returns The list of files in the directory.\n */\nexport async function getFiles(directory: string): Promise<string[]> {\n\ttry {\n\t\tconst dir = await readdir(directory);\n\t\tconst files: string[] = [];\n\t\tfor (const dirEntry of dir) {\n\t\t\tconst fullPath = path.join(directory, dirEntry);\n\t\t\tconst stats = await stat(fullPath);\n\t\t\tif (stats.isFile()) {\n\t\t\t\tfiles.push(fullPath);\n\t\t\t}\n\t\t}\n\t\treturn files;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Load the text file.\n * @param filename The filename of the text file to load.\n * @returns The contents of the text file if it could not be loaded.\n */\nexport async function loadTextFile(filename: string): Promise<string> {\n\treturn readFile(filename, \"utf8\");\n}\n\n/**\n * Load the JSON file.\n * @param filename The filename of the JSON file to load.\n * @returns The contents of the JSON file or null if it could not be loaded.\n */\nexport async function loadJsonFile<T>(filename: string): Promise<T> {\n\tconst content = await loadTextFile(filename);\n\treturn JSON.parse(content) as T;\n}\n\n/**\n * Parse the protocol from a module name.\n * @param moduleName The module name to parse.\n * @returns The parsed protocol information.\n */\nexport function parseModuleProtocol(moduleName: string): IModuleProtocol {\n\tconst trimmed = moduleName.trim();\n\n\tif (trimmed.startsWith(\"npm:\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Npm,\n\t\t\tidentifier: trimmed.slice(4),\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (trimmed.startsWith(\"https://\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Https,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (trimmed.startsWith(\"http://\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Http,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (trimmed.startsWith(\"file://\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Local,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (ModuleHelper.isLocalModule(trimmed)) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Local,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\treturn {\n\t\tprotocol: ModuleProtocol.Default,\n\t\tidentifier: trimmed,\n\t\toriginal: trimmed\n\t};\n}\n\n/**\n * Hash a URL to create a safe filename.\n * @param url The URL to hash.\n * @returns A hashed filename safe for the filesystem.\n */\nexport function hashUrl(url: string): string {\n\tconst urlBytes = Converter.utf8ToBytes(url);\n\tconst hashBytes = Sha256.sum256(urlBytes);\n\tconst hash = Converter.bytesToHex(hashBytes);\n\tconst ext = path.extname(new URL(url).pathname);\n\treturn `${hash}${ext}`;\n}\n\n/**\n * Get the extensions cache directory.\n * @param executionDirectory The execution directory.\n * @param protocol The protocol type for subdirectory organization.\n * @param cacheDirectory The cache directory base path.\n * @returns The cache directory path.\n */\nexport function getExtensionsCacheDir(\n\texecutionDirectory: string,\n\tprotocol: ModuleProtocol,\n\tcacheDirectory?: string\n): string {\n\t// Resolve to absolute path to ensure consistent behavior\n\tconst absoluteDir = path.resolve(executionDirectory);\n\tconst baseDir = cacheDirectory ?? \".tmp\";\n\treturn path.join(absoluteDir, baseDir, \"extensions\", protocol);\n}\n\n/**\n * Handle the npm: protocol by installing the package if needed.\n * @param packageName The npm package name (without npm: prefix).\n * @param executionDirectory The execution directory.\n * @param cacheDirectory The cache directory base path.\n * @returns The resolved path to the installed module.\n */\nexport async function handleNpmProtocol(\n\tpackageName: string,\n\texecutionDirectory: string,\n\tcacheDirectory?: string\n): Promise<IProtocolHandlerResult> {\n\tconst cacheDir = getExtensionsCacheDir(executionDirectory, ModuleProtocol.Npm, cacheDirectory);\n\t// Strip the version suffix to get the bare package name. We use lastIndexOf\n\t// (not indexOf) so the leading \"@\" of a scoped package is preserved — for\n\t// \"@scope/pkg@1.0.0\" the last \"@\" is the version separator at the end, not\n\t// the scope prefix at position 0. The `> 0` (not `>= 0`) check then leaves\n\t// unversioned scoped names like \"@scope/pkg\" untouched, since their only \"@\"\n\t// sits at index 0.\n\t// e.g. \"picocolors@1.0.0\" → \"picocolors\"\n\t// e.g. \"@scope/pkg@1.0.0\" → \"@scope/pkg\"\n\t// e.g. \"@scope/pkg\" → \"@scope/pkg\" (unchanged)\n\tconst lastAtIndex = packageName.lastIndexOf(\"@\");\n\tconst packageNameOnly = lastAtIndex > 0 ? packageName.slice(0, lastAtIndex) : packageName;\n\tconst packageDir = path.join(cacheDir, \"node_modules\", packageNameOnly);\n\tconst packageJsonPath = path.join(packageDir, \"package.json\");\n\n\tconst exists = await fileExists(packageJsonPath);\n\tif (exists) {\n\t\tconst mainFile = await resolvePackageEntryPoint(packageDir, packageNameOnly);\n\t\tconst modulePath = path.join(packageDir, mainFile);\n\n\t\treturn {\n\t\t\tresolvedPath: modulePath,\n\t\t\tcached: true\n\t\t};\n\t}\n\n\tawait mkdir(cacheDir, { recursive: true });\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.extensionNpmInstalling\"), packageName);\n\n\ttry {\n\t\t// Always pipe stdio to comply with env access restrictions in tests/lint\n\t\tconst stdio: \"pipe\" | \"inherit\" | \"ignore\" = \"pipe\";\n\t\texecSync(\n\t\t\t`npm install ${packageName} --prefix \"${cacheDir}\" --omit=dev --no-save --no-package-lock`,\n\t\t\t{\n\t\t\t\tcwd: cacheDir,\n\t\t\t\tstdio\n\t\t\t}\n\t\t);\n\t} catch (err) {\n\t\tthrow new GeneralError(\n\t\t\t\"node\",\n\t\t\t\"extensionNpmInstallFailed\",\n\t\t\t{\n\t\t\t\tpackage: packageName\n\t\t\t},\n\t\t\tBaseError.fromError(err)\n\t\t);\n\t}\n\n\tconst mainFile = await resolvePackageEntryPoint(packageDir, packageNameOnly);\n\tconst modulePath = path.join(packageDir, mainFile);\n\n\treturn {\n\t\tresolvedPath: modulePath,\n\t\tcached: false\n\t};\n}\n\n/**\n * Check if a cached file has expired based on TTL and force refresh settings.\n * @param metadataPath Path to the cache metadata file.\n * @param ttlHours Time to live in hours.\n * @param forceRefresh Whether to force refresh regardless of TTL.\n * @returns True if the cache is expired or should be refreshed.\n */\nexport async function isCacheExpired(\n\tmetadataPath: string,\n\tttlHours: number,\n\tforceRefresh: boolean\n): Promise<boolean> {\n\tif (forceRefresh) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst metadata = await loadJsonFile<ICacheMetadata>(metadataPath);\n\t\tconst ttlMillis = ttlHours * 60 * 60 * 1000;\n\t\tconst expireTime = metadata.downloadedAt + ttlMillis;\n\t\treturn Date.now() > expireTime;\n\t} catch {\n\t\t// If metadata doesn't exist or is corrupted, consider expired\n\t\treturn true;\n\t}\n}\n\n/**\n * Handle the https: protocol by downloading the module if needed.\n * @param url The HTTPS URL to download from.\n * @param executionDirectory The execution directory.\n * @param maxSizeMb The maximum size in MB for the download.\n * @param cacheDirectory The cache directory base path.\n * @param ttlHours TTL in hours for cache expiration.\n * @param forceRefresh Whether to force refresh the cache.\n * @returns The resolved path to the downloaded module.\n */\nexport async function handleHttpsProtocol(\n\turl: string,\n\texecutionDirectory: string,\n\tmaxSizeMb: number,\n\tcacheDirectory?: string,\n\tttlHours?: number,\n\tforceRefresh?: boolean\n): Promise<IProtocolHandlerResult> {\n\tconst effectiveTtlHours = ttlHours ?? 24;\n\tconst effectiveForceRefresh = forceRefresh ?? false;\n\tconst cacheDir = getExtensionsCacheDir(executionDirectory, ModuleProtocol.Https, cacheDirectory);\n\tconst filename = hashUrl(url);\n\tconst cachedPath = path.join(cacheDir, filename);\n\tconst metadataPath = `${cachedPath}.meta`;\n\n\tconst exists = await fileExists(cachedPath);\n\tif (exists) {\n\t\tconst expired = await isCacheExpired(metadataPath, effectiveTtlHours, effectiveForceRefresh);\n\t\tif (!expired) {\n\t\t\treturn {\n\t\t\t\tresolvedPath: cachedPath,\n\t\t\t\tcached: true\n\t\t\t};\n\t\t}\n\n\t\tif (effectiveForceRefresh) {\n\t\t\tCLIDisplay.warning(I18n.formatMessage(\"node.extensionForceRefresh\", { url }));\n\t\t} else {\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.extensionCacheExpired\", { url }));\n\t\t}\n\t}\n\n\tCLIDisplay.warning(I18n.formatMessage(\"node.extensionSecurityWarning\", { url }));\n\tCLIDisplay.task(I18n.formatMessage(\"node.extensionHttpsDownloading\"), url);\n\n\tawait mkdir(cacheDir, { recursive: true });\n\n\tconst maxSizeBytes = maxSizeMb * 1024 * 1024;\n\tlet downloadedSize = 0;\n\tconst chunks: Buffer[] = [];\n\n\ttry {\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\thttpsGet(url, response => {\n\t\t\t\tif (response.statusCode !== 200) {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew GeneralError(\"node\", \"extensionDownloadFailed\", {\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tstatus: response.statusCode ?? 0\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresponse.on(\"data\", (chunk: Buffer) => {\n\t\t\t\t\tdownloadedSize += chunk.length;\n\n\t\t\t\t\tif (downloadedSize > maxSizeBytes) {\n\t\t\t\t\t\tresponse.destroy();\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew GeneralError(\"node\", \"extensionSizeLimitExceeded\", {\n\t\t\t\t\t\t\t\tsize: downloadedSize,\n\t\t\t\t\t\t\t\tlimit: maxSizeBytes\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tchunks.push(chunk);\n\t\t\t\t});\n\n\t\t\t\tresponse.on(\"end\", () => {\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\n\t\t\t\tresponse.on(\"error\", err => {\n\t\t\t\t\treject(BaseError.fromError(err));\n\t\t\t\t});\n\t\t\t}).on(\"error\", err => {\n\t\t\t\treject(BaseError.fromError(err));\n\t\t\t});\n\t\t});\n\t} catch (err) {\n\t\tthrow new GeneralError(\n\t\t\t\"node\",\n\t\t\t\"extensionDownloadFailed\",\n\t\t\t{\n\t\t\t\turl\n\t\t\t},\n\t\t\tBaseError.fromError(err)\n\t\t);\n\t}\n\n\tconst tempPath = `${cachedPath}.tmp`;\n\tawait writeFile(tempPath, Buffer.concat(chunks));\n\n\t// Atomic move from temp to final location\n\tawait rename(tempPath, cachedPath);\n\n\t// Save metadata for TTL tracking\n\tconst metadata: ICacheMetadata = {\n\t\tdownloadedAt: Date.now(),\n\t\turl,\n\t\tsize: Buffer.concat(chunks).length\n\t};\n\tawait writeFile(metadataPath, JSON.stringify(metadata, null, 2));\n\n\treturn {\n\t\tresolvedPath: cachedPath,\n\t\tcached: false\n\t};\n}\n\n/**\n * Resolve the main entry point from a package directory using Node.js resolution with fallback.\n * Uses require.resolve() when possible for standard Node.js behavior, with manual fallback.\n * @param packagePath The absolute path to the package directory.\n * @param packageName The package name for require.resolve().\n * @param fallback The fallback file name if no entry point is found.\n * @returns The resolved entry point file name (relative to package directory).\n */\nexport async function resolvePackageEntryPoint(\n\tpackagePath: string,\n\tpackageName: string,\n\tfallback = \"index.js\"\n): Promise<string> {\n\ttry {\n\t\t// Try require.resolve() first - handles exports, main, module automatically\n\t\tconst resolvedPath = require.resolve(packageName, { paths: [path.dirname(packagePath)] });\n\t\t// Convert absolute path back to relative filename within package\n\t\tconst relativePath = path.relative(packagePath, resolvedPath);\n\t\treturn relativePath ?? fallback;\n\t} catch {\n\t\t// Fallback to manual package.json parsing if require.resolve fails\n\t\ttry {\n\t\t\tconst packageJsonPath = path.join(packagePath, \"package.json\");\n\t\t\tconst packageJsonContent = await loadJsonFile<{\n\t\t\t\tmodule?: string;\n\t\t\t\tmain?: string;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\texports?: any;\n\t\t\t}>(packageJsonPath);\n\n\t\t\t// Future: Could expand exports field support here\n\t\t\treturn packageJsonContent.module ?? packageJsonContent.main ?? fallback;\n\t\t} catch {\n\t\t\treturn fallback;\n\t\t}\n\t}\n}\n\n/**\n * Convert a file path to an import-compatible URL for cross-platform module loading.\n * On Windows, adds the 'file://' protocol prefix required for dynamic imports.\n * On other platforms, returns the path unchanged.\n * @param filePath The absolute file path to convert.\n * @returns A URL string compatible with dynamic import().\n */\nexport function createModuleImportUrl(filePath: string): string {\n\treturn process.platform === \"win32\" ? `file://${filePath}` : filePath;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACN,SAAS,EACT,SAAS,EACT,YAAY,EACZ,IAAI,EACJ,EAAE,EAEF,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,gBAAwB;IAC/D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC;IACzE,UAAU,CAAC,KAAK,CAAC,cAAc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AAmE;QACnE,IAAI,CAAC;YACJ,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAC/D,MAAM,kBAAkB,GAAG,MAAM,YAAY,CAK1C,eAAe,CAAC,CAAC;YAEpB,kDAAkD;YAClD,OAAO,kBAAkB,CAAC,MAAM,IAAI,kBAAkB,CAAC,IAAI,IAAI,QAAQ,CAAC;QACzE,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,QAAQ,CAAC;QACjB,CAAC;IACF,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACrD,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { execSync } from \"node:child_process\";\nimport { mkdir, readdir, readFile, rename, stat, writeFile } from \"node:fs/promises\";\nimport { get as httpsGet } from \"node:https\";\nimport path from \"node:path\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport {\n\tBaseError,\n\tConverter,\n\tGeneralError,\n\tI18n,\n\tIs,\n\ttype ILocaleDictionary\n} from \"@twin.org/core\";\nimport { Sha256 } from \"@twin.org/crypto\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport type { ICacheMetadata } from \"./models/ICacheMetadata.js\";\nimport type { IModuleProtocol } from \"./models/IModuleProtocol.js\";\nimport type { IProtocolHandlerResult } from \"./models/IProtocolHandlerResult.js\";\nimport { ModuleProtocol } from \"./models/moduleProtocol.js\";\n\n/**\n * Initialise the locales for the application.\n * @param localesDirectory The directory containing the locales.\n * @returns A promise that resolves when the locale dictionary has been loaded.\n */\nexport async function initialiseLocales(localesDirectory: string): Promise<void> {\n\tconst localesFile = path.resolve(path.join(localesDirectory, \"en.json\"));\n\tCLIDisplay.value(\"Locales File\", localesFile);\n\tif (await fileExists(localesFile)) {\n\t\tconst enLangContent = await readFile(localesFile, \"utf8\");\n\t\tI18n.addDictionary(\"en\", JSON.parse(enLangContent) as ILocaleDictionary);\n\t} else {\n\t\tCLIDisplay.error(`Locales file not found: ${localesFile}`);\n\t}\n}\n\n/**\n * Get the directory where the application is being executed.\n * @returns The execution directory.\n */\nexport function getExecutionDirectory(): string {\n\treturn process.cwd();\n}\n\n/**\n * Get the directory where the script is located.\n * @param args The command line arguments.\n * @returns The directory containing the entry-point script, or the current working directory if not determinable.\n */\nexport function getScriptDirectory(args?: string[]): string {\n\tif (Is.array<string>(args) && args.length >= 2 && args[1].includes(\"index.js\")) {\n\t\treturn path.resolve(path.join(path.dirname(args[1]), \"..\"));\n\t}\n\treturn process.cwd();\n}\n\n/**\n * Does the specified file exist.\n * @param filename The filename to check for existence.\n * @returns True if the file exists.\n */\nexport async function fileExists(filename: string): Promise<boolean> {\n\ttry {\n\t\tconst stats = await stat(filename);\n\t\treturn stats.isFile();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Does the specified directory exist.\n * @param directory The directory to check for existence.\n * @returns True if the directory exists.\n */\nexport async function directoryExists(directory: string): Promise<boolean> {\n\ttry {\n\t\tconst stats = await stat(directory);\n\t\treturn stats.isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get the sub folders for the folder.\n * @param directory The directory to get the sub folders.\n * @returns The list of sub folders.\n */\nexport async function getSubFolders(directory: string): Promise<string[]> {\n\ttry {\n\t\tconst dir = await readdir(directory);\n\t\tconst folders: string[] = [];\n\t\tfor (const dirEntry of dir) {\n\t\t\tconst fullPath = path.join(directory, dirEntry);\n\t\t\tconst stats = await stat(fullPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tfolders.push(fullPath);\n\t\t\t}\n\t\t}\n\t\treturn folders;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Get the files in the directory.\n * @param directory The directory to get the files from.\n * @returns The list of files in the directory.\n */\nexport async function getFiles(directory: string): Promise<string[]> {\n\ttry {\n\t\tconst dir = await readdir(directory);\n\t\tconst files: string[] = [];\n\t\tfor (const dirEntry of dir) {\n\t\t\tconst fullPath = path.join(directory, dirEntry);\n\t\t\tconst stats = await stat(fullPath);\n\t\t\tif (stats.isFile()) {\n\t\t\t\tfiles.push(fullPath);\n\t\t\t}\n\t\t}\n\t\treturn files;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Load the text file.\n * @param filename The filename of the text file to load.\n * @returns The contents of the text file as a UTF-8 string.\n */\nexport async function loadTextFile(filename: string): Promise<string> {\n\treturn readFile(filename, \"utf8\");\n}\n\n/**\n * Load the JSON file.\n * @param filename The filename of the JSON file to load.\n * @returns The parsed JSON content of the file.\n */\nexport async function loadJsonFile<T>(filename: string): Promise<T> {\n\tconst content = await loadTextFile(filename);\n\treturn JSON.parse(content) as T;\n}\n\n/**\n * Parse the protocol from a module name.\n * @param moduleName The module name to parse.\n * @returns The parsed protocol information.\n */\nexport function parseModuleProtocol(moduleName: string): IModuleProtocol {\n\tconst trimmed = moduleName.trim();\n\n\tif (trimmed.startsWith(\"npm:\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Npm,\n\t\t\tidentifier: trimmed.slice(4),\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (trimmed.startsWith(\"https://\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Https,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (trimmed.startsWith(\"http://\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Http,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (trimmed.startsWith(\"file://\")) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Local,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\tif (ModuleHelper.isLocalModule(trimmed)) {\n\t\treturn {\n\t\t\tprotocol: ModuleProtocol.Local,\n\t\t\tidentifier: trimmed,\n\t\t\toriginal: trimmed\n\t\t};\n\t}\n\n\treturn {\n\t\tprotocol: ModuleProtocol.Default,\n\t\tidentifier: trimmed,\n\t\toriginal: trimmed\n\t};\n}\n\n/**\n * Hash a URL to create a safe filename.\n * @param url The URL to hash.\n * @returns A hashed filename safe for the filesystem.\n */\nexport function hashUrl(url: string): string {\n\tconst urlBytes = Converter.utf8ToBytes(url);\n\tconst hashBytes = Sha256.sum256(urlBytes);\n\tconst hash = Converter.bytesToHex(hashBytes);\n\tconst ext = path.extname(new URL(url).pathname);\n\treturn `${hash}${ext}`;\n}\n\n/**\n * Get the extensions cache directory.\n * @param executionDirectory The execution directory.\n * @param protocol The protocol type for subdirectory organization.\n * @param cacheDirectory The cache directory base path.\n * @returns The cache directory path.\n */\nexport function getExtensionsCacheDir(\n\texecutionDirectory: string,\n\tprotocol: ModuleProtocol,\n\tcacheDirectory?: string\n): string {\n\t// Resolve to absolute path to ensure consistent behavior\n\tconst absoluteDir = path.resolve(executionDirectory);\n\tconst baseDir = cacheDirectory ?? \".tmp\";\n\treturn path.join(absoluteDir, baseDir, \"extensions\", protocol);\n}\n\n/**\n * Handle the npm: protocol by installing the package if needed.\n * @param packageName The npm package name (without npm: prefix).\n * @param executionDirectory The execution directory.\n * @param cacheDirectory The cache directory base path.\n * @returns The resolved path to the installed module.\n */\nexport async function handleNpmProtocol(\n\tpackageName: string,\n\texecutionDirectory: string,\n\tcacheDirectory?: string\n): Promise<IProtocolHandlerResult> {\n\tconst cacheDir = getExtensionsCacheDir(executionDirectory, ModuleProtocol.Npm, cacheDirectory);\n\t// Strip the version suffix to get the bare package name. We use lastIndexOf\n\t// (not indexOf) so the leading \"@\" of a scoped package is preserved - for\n\t// \"@scope/pkg@1.0.0\" the last \"@\" is the version separator at the end, not\n\t// the scope prefix at position 0. The `> 0` (not `>= 0`) check then leaves\n\t// unversioned scoped names like \"@scope/pkg\" untouched, since their only \"@\"\n\t// sits at index 0.\n\t// e.g. \"picocolors@1.0.0\" → \"picocolors\"\n\t// e.g. \"@scope/pkg@1.0.0\" → \"@scope/pkg\"\n\t// e.g. \"@scope/pkg\" → \"@scope/pkg\" (unchanged)\n\tconst lastAtIndex = packageName.lastIndexOf(\"@\");\n\tconst packageNameOnly = lastAtIndex > 0 ? packageName.slice(0, lastAtIndex) : packageName;\n\tconst packageDir = path.join(cacheDir, \"node_modules\", packageNameOnly);\n\tconst packageJsonPath = path.join(packageDir, \"package.json\");\n\n\tconst exists = await fileExists(packageJsonPath);\n\tif (exists) {\n\t\tconst mainFile = await resolvePackageEntryPoint(packageDir, packageNameOnly);\n\t\tconst modulePath = path.join(packageDir, mainFile);\n\n\t\treturn {\n\t\t\tresolvedPath: modulePath,\n\t\t\tcached: true\n\t\t};\n\t}\n\n\tawait mkdir(cacheDir, { recursive: true });\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.extensionNpmInstalling\"), packageName);\n\n\ttry {\n\t\t// Always pipe stdio to comply with env access restrictions in tests/lint\n\t\tconst stdio: \"pipe\" | \"inherit\" | \"ignore\" = \"pipe\";\n\t\texecSync(\n\t\t\t`npm install ${packageName} --prefix \"${cacheDir}\" --omit=dev --no-save --no-package-lock`,\n\t\t\t{\n\t\t\t\tcwd: cacheDir,\n\t\t\t\tstdio\n\t\t\t}\n\t\t);\n\t} catch (err) {\n\t\tthrow new GeneralError(\n\t\t\t\"node\",\n\t\t\t\"extensionNpmInstallFailed\",\n\t\t\t{\n\t\t\t\tpackage: packageName\n\t\t\t},\n\t\t\tBaseError.fromError(err)\n\t\t);\n\t}\n\n\tconst mainFile = await resolvePackageEntryPoint(packageDir, packageNameOnly);\n\tconst modulePath = path.join(packageDir, mainFile);\n\n\treturn {\n\t\tresolvedPath: modulePath,\n\t\tcached: false\n\t};\n}\n\n/**\n * Check if a cached file has expired based on TTL and force refresh settings.\n * @param metadataPath Path to the cache metadata file.\n * @param ttlHours Time to live in hours.\n * @param forceRefresh Whether to force refresh regardless of TTL.\n * @returns True if the cache is expired or should be refreshed.\n */\nexport async function isCacheExpired(\n\tmetadataPath: string,\n\tttlHours: number,\n\tforceRefresh: boolean\n): Promise<boolean> {\n\tif (forceRefresh) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst metadata = await loadJsonFile<ICacheMetadata>(metadataPath);\n\t\tconst ttlMillis = ttlHours * 60 * 60 * 1000;\n\t\tconst expireTime = metadata.downloadedAt + ttlMillis;\n\t\treturn Date.now() > expireTime;\n\t} catch {\n\t\t// If metadata doesn't exist or is corrupted, consider expired\n\t\treturn true;\n\t}\n}\n\n/**\n * Handle the https: protocol by downloading the module if needed.\n * @param url The HTTPS URL to download from.\n * @param executionDirectory The execution directory.\n * @param maxSizeMb The maximum size in MB for the download.\n * @param cacheDirectory The cache directory base path.\n * @param ttlHours TTL in hours for cache expiration.\n * @param forceRefresh Whether to force refresh the cache.\n * @returns The resolved path to the downloaded module.\n */\nexport async function handleHttpsProtocol(\n\turl: string,\n\texecutionDirectory: string,\n\tmaxSizeMb: number,\n\tcacheDirectory?: string,\n\tttlHours?: number,\n\tforceRefresh?: boolean\n): Promise<IProtocolHandlerResult> {\n\tconst effectiveTtlHours = ttlHours ?? 24;\n\tconst effectiveForceRefresh = forceRefresh ?? false;\n\tconst cacheDir = getExtensionsCacheDir(executionDirectory, ModuleProtocol.Https, cacheDirectory);\n\tconst filename = hashUrl(url);\n\tconst cachedPath = path.join(cacheDir, filename);\n\tconst metadataPath = `${cachedPath}.meta`;\n\n\tconst exists = await fileExists(cachedPath);\n\tif (exists) {\n\t\tconst expired = await isCacheExpired(metadataPath, effectiveTtlHours, effectiveForceRefresh);\n\t\tif (!expired) {\n\t\t\treturn {\n\t\t\t\tresolvedPath: cachedPath,\n\t\t\t\tcached: true\n\t\t\t};\n\t\t}\n\n\t\tif (effectiveForceRefresh) {\n\t\t\tCLIDisplay.warning(I18n.formatMessage(\"node.extensionForceRefresh\", { url }));\n\t\t} else {\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.extensionCacheExpired\", { url }));\n\t\t}\n\t}\n\n\tCLIDisplay.warning(I18n.formatMessage(\"node.extensionSecurityWarning\", { url }));\n\tCLIDisplay.task(I18n.formatMessage(\"node.extensionHttpsDownloading\"), url);\n\n\tawait mkdir(cacheDir, { recursive: true });\n\n\tconst maxSizeBytes = maxSizeMb * 1024 * 1024;\n\tlet downloadedSize = 0;\n\tconst chunks: Buffer[] = [];\n\n\ttry {\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\thttpsGet(url, response => {\n\t\t\t\tif (response.statusCode !== 200) {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew GeneralError(\"node\", \"extensionDownloadFailed\", {\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tstatus: response.statusCode ?? 0\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresponse.on(\"data\", (chunk: Buffer) => {\n\t\t\t\t\tdownloadedSize += chunk.length;\n\n\t\t\t\t\tif (downloadedSize > maxSizeBytes) {\n\t\t\t\t\t\tresponse.destroy();\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew GeneralError(\"node\", \"extensionSizeLimitExceeded\", {\n\t\t\t\t\t\t\t\tsize: downloadedSize,\n\t\t\t\t\t\t\t\tlimit: maxSizeBytes\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tchunks.push(chunk);\n\t\t\t\t});\n\n\t\t\t\tresponse.on(\"end\", () => {\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\n\t\t\t\tresponse.on(\"error\", err => {\n\t\t\t\t\treject(BaseError.fromError(err));\n\t\t\t\t});\n\t\t\t}).on(\"error\", err => {\n\t\t\t\treject(BaseError.fromError(err));\n\t\t\t});\n\t\t});\n\t} catch (err) {\n\t\tthrow new GeneralError(\n\t\t\t\"node\",\n\t\t\t\"extensionDownloadFailed\",\n\t\t\t{\n\t\t\t\turl\n\t\t\t},\n\t\t\tBaseError.fromError(err)\n\t\t);\n\t}\n\n\tconst tempPath = `${cachedPath}.tmp`;\n\tawait writeFile(tempPath, Buffer.concat(chunks));\n\n\t// Atomic move from temp to final location\n\tawait rename(tempPath, cachedPath);\n\n\t// Save metadata for TTL tracking\n\tconst metadata: ICacheMetadata = {\n\t\tdownloadedAt: Date.now(),\n\t\turl,\n\t\tsize: Buffer.concat(chunks).length\n\t};\n\tawait writeFile(metadataPath, JSON.stringify(metadata, null, 2));\n\n\treturn {\n\t\tresolvedPath: cachedPath,\n\t\tcached: false\n\t};\n}\n\n/**\n * Resolve the main entry point from a package directory using Node.js resolution with fallback.\n * Uses require.resolve() when possible for standard Node.js behavior, with manual fallback.\n * @param packagePath The absolute path to the package directory.\n * @param packageName The package name for require.resolve().\n * @param fallback The fallback file name if no entry point is found.\n * @returns The resolved entry point file name (relative to package directory).\n */\nexport async function resolvePackageEntryPoint(\n\tpackagePath: string,\n\tpackageName: string,\n\tfallback = \"index.js\"\n): Promise<string> {\n\ttry {\n\t\t// Try require.resolve() first - handles exports, main, module automatically\n\t\tconst resolvedPath = require.resolve(packageName, { paths: [path.dirname(packagePath)] });\n\t\t// Convert absolute path back to relative filename within package\n\t\tconst relativePath = path.relative(packagePath, resolvedPath);\n\t\treturn relativePath ?? fallback;\n\t} catch {\n\t\t// Fallback to manual package.json parsing if require.resolve fails\n\t\ttry {\n\t\t\tconst packageJsonPath = path.join(packagePath, \"package.json\");\n\t\t\tconst packageJsonContent = await loadJsonFile<{\n\t\t\t\tmodule?: string;\n\t\t\t\tmain?: string;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\texports?: any;\n\t\t\t}>(packageJsonPath);\n\n\t\t\t// Future: Could expand exports field support here\n\t\t\treturn packageJsonContent.module ?? packageJsonContent.main ?? fallback;\n\t\t} catch {\n\t\t\treturn fallback;\n\t\t}\n\t}\n}\n\n/**\n * Convert a file path to an import-compatible URL for cross-platform module loading.\n * On Windows, adds the 'file://' protocol prefix required for dynamic imports.\n * On other platforms, returns the path unchanged.\n * @param filePath The absolute file path to convert.\n * @returns A URL string compatible with dynamic import().\n */\nexport function createModuleImportUrl(filePath: string): string {\n\treturn process.platform === \"win32\" ? `file://${filePath}` : filePath;\n}\n"]}
|
|
@@ -28,16 +28,16 @@ export declare function isBackgroundTasksRequired(envVars: IEngineEnvironmentVar
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function isImmutableProofRequired(envVars: IEngineEnvironmentVariables): boolean;
|
|
30
30
|
/**
|
|
31
|
-
* Checks if the
|
|
32
|
-
* Returns true when
|
|
31
|
+
* Checks if the federated catalogue subsystem is required.
|
|
32
|
+
* Returns true when the catalogue is explicitly enabled, a remote endpoint is configured, filters are set, or dataspace is enabled.
|
|
33
33
|
* @param envVars The environment variables.
|
|
34
|
-
* @returns True if
|
|
34
|
+
* @returns True if the federated catalogue is required.
|
|
35
35
|
*/
|
|
36
36
|
export declare function isFederatedCatalogueRequired(envVars: IEngineEnvironmentVariables): boolean;
|
|
37
37
|
/**
|
|
38
38
|
* Checks if the rights management subsystem is required.
|
|
39
39
|
* Returns true when any component that depends on the rights management subsystem is enabled.
|
|
40
|
-
* Note: rights management has no standalone enable flag
|
|
40
|
+
* Note: rights management has no standalone enable flag - it is gated entirely on
|
|
41
41
|
* `dataspaceEnabled`. Setting `TWIN_RIGHTS_MANAGEMENT_*` env var in isolation does not
|
|
42
42
|
* enable the subsystem; `TWIN_DATASPACE_ENABLED` must also be true.
|
|
43
43
|
* @param envVars The environment variables.
|
|
@@ -12,7 +12,7 @@ export declare function extensionsConfiguration(envVars: INodeEnvironmentVariabl
|
|
|
12
12
|
* Handles the initialisation of the extensions when the engine has been constructed.
|
|
13
13
|
* @param envVars The environment variables for the node.
|
|
14
14
|
* @param engineCore The engine core instance.
|
|
15
|
-
* @returns
|
|
15
|
+
* @returns A promise that resolves when all extension engine initialisation methods have completed.
|
|
16
16
|
*/
|
|
17
17
|
export declare function extensionsInitialiseEngine(envVars: INodeEnvironmentVariables, engineCore: IEngineCore): Promise<void>;
|
|
18
18
|
/**
|
|
@@ -20,13 +20,13 @@ export declare function extensionsInitialiseEngine(envVars: INodeEnvironmentVari
|
|
|
20
20
|
* @param envVars The environment variables for the node.
|
|
21
21
|
* @param engineCore The engine core instance.
|
|
22
22
|
* @param engineServer The engine server instance.
|
|
23
|
-
* @returns
|
|
23
|
+
* @returns A promise that resolves when all extension engine-server initialisation methods have completed.
|
|
24
24
|
*/
|
|
25
25
|
export declare function extensionsInitialiseEngineServer(envVars: INodeEnvironmentVariables, engineCore: IEngineCore, engineServer: IEngineServer): Promise<void>;
|
|
26
26
|
/**
|
|
27
27
|
* Handles the shutdown of the extensions.
|
|
28
28
|
* @param envVars The environment variables for the node.
|
|
29
29
|
* @param engineCore The engine core instance.
|
|
30
|
-
* @returns
|
|
30
|
+
* @returns A promise that resolves when all extension shutdown methods have completed.
|
|
31
31
|
*/
|
|
32
32
|
export declare function shutdownExtensions(envVars: INodeEnvironmentVariables, engineCore: IEngineCore): Promise<void>;
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function executeCommand(engineCore: IEngineCore, envVars: INodeEn
|
|
|
29
29
|
* Load the env files and process the options.
|
|
30
30
|
* @param processEnv The environment variables from the process.
|
|
31
31
|
* @param options The options.
|
|
32
|
-
* @returns The
|
|
32
|
+
* @returns The substituted options, mutated in place with env variable values resolved.
|
|
33
33
|
* @throws GeneralError if an env file has errors.
|
|
34
34
|
*/
|
|
35
35
|
export declare function processEnvOptions(processEnv: {
|
|
@@ -51,6 +51,6 @@ export declare function substituteEnvOptions(processEnv: {
|
|
|
51
51
|
value: string;
|
|
52
52
|
}[]): void;
|
|
53
53
|
/**
|
|
54
|
-
* Register
|
|
54
|
+
* Register all built-in CLI command definitions into the shared command map.
|
|
55
55
|
*/
|
|
56
56
|
export declare function registerCommands(): void;
|
|
@@ -15,6 +15,7 @@ export declare function getCommandDefinitionBootstrapLegacy(commandDefinitions:
|
|
|
15
15
|
* @param engineCore The engine core.
|
|
16
16
|
* @param envVars The environment variables for the node.
|
|
17
17
|
* @param params The parameters for the command.
|
|
18
|
+
* @returns A promise that resolves when the bootstrap sequence has completed.
|
|
18
19
|
*/
|
|
19
20
|
export declare function bootstrapLegacy(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: INodeEnvironmentVariables & {
|
|
20
21
|
/**
|
|
@@ -27,7 +28,7 @@ export declare function bootstrapLegacy(engineCore: IEngineCore<INodeEngineConfi
|
|
|
27
28
|
*/
|
|
28
29
|
nodeIdentity?: string;
|
|
29
30
|
/**
|
|
30
|
-
* The mnemonic for the identity, if empty
|
|
31
|
+
* The mnemonic for the node identity, if empty it will be randomly generated.
|
|
31
32
|
*/
|
|
32
33
|
nodeMnemonic?: string;
|
|
33
34
|
/**
|
|
@@ -39,28 +40,28 @@ export declare function bootstrapLegacy(engineCore: IEngineCore<INodeEngineConfi
|
|
|
39
40
|
*/
|
|
40
41
|
tenantApiKey?: string;
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* The organisation identity. If not provided it will be generated.
|
|
43
44
|
*/
|
|
44
45
|
organizationIdentity?: string;
|
|
45
46
|
/**
|
|
46
|
-
* The mnemonic for the organisation, if empty
|
|
47
|
+
* The mnemonic for the organisation identity, if empty it will be randomly generated.
|
|
47
48
|
*/
|
|
48
49
|
organizationMnemonic?: string;
|
|
49
50
|
/**
|
|
50
|
-
* If the
|
|
51
|
+
* If the admin-user feature is enabled, this will be the identity of the user. If not provided it will be generated.
|
|
51
52
|
*/
|
|
52
53
|
adminUserIdentity?: string;
|
|
53
54
|
/**
|
|
54
|
-
* The mnemonic for the admin user, if empty
|
|
55
|
+
* The mnemonic for the admin user, if empty it will be randomly generated.
|
|
55
56
|
*/
|
|
56
57
|
adminUserMnemonic?: string;
|
|
57
58
|
/**
|
|
58
|
-
* If the
|
|
59
|
+
* If the admin-user feature is enabled, this will be the name of the user.
|
|
59
60
|
* @default admin@node
|
|
60
61
|
*/
|
|
61
62
|
adminUserName?: string;
|
|
62
63
|
/**
|
|
63
|
-
* If the
|
|
64
|
+
* If the admin-user feature is enabled, this will be the password of the user. If empty it will be randomly generated.
|
|
64
65
|
*/
|
|
65
66
|
adminUserPassword?: string;
|
|
66
67
|
}, params: {}): Promise<void>;
|
|
@@ -15,6 +15,7 @@ export declare function getCommandDefinitionHelp(commandDefinitions: {
|
|
|
15
15
|
* @param params The command parameters.
|
|
16
16
|
* @param params.command The command to display help for.
|
|
17
17
|
* @param commandDefinitions The registered command definitions.
|
|
18
|
+
* @returns A promise that resolves when help output has been displayed.
|
|
18
19
|
*/
|
|
19
20
|
export declare function help(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
|
|
20
21
|
command?: string;
|
|
@@ -19,6 +19,7 @@ export declare function getCommandDefinitionIdentityCreate(commandDefinitions: {
|
|
|
19
19
|
* @param params.identity The DID of the identity to create.
|
|
20
20
|
* @param params.controller The controller DID for the identity.
|
|
21
21
|
* @param params.fundWallet Whether to fund the wallet associated with the identity from a faucet.
|
|
22
|
+
* @param params.nodeId If true, set the created DID as the node identity.
|
|
22
23
|
* @param params.nodeOrganizationId If true, set the created DID as the node organization ID.
|
|
23
24
|
* @param params.tenantOrganizationId The tenant ID to set the created DID as the organization ID for.
|
|
24
25
|
* @param params.outputJson The output .json file to store the command output.
|
|
@@ -31,6 +32,7 @@ export declare function identityCreate(engineCore: IEngineCore<INodeEngineConfig
|
|
|
31
32
|
identity?: string;
|
|
32
33
|
controller?: string;
|
|
33
34
|
fundWallet?: boolean;
|
|
35
|
+
nodeId?: boolean;
|
|
34
36
|
nodeOrganizationId?: boolean;
|
|
35
37
|
tenantOrganizationId?: string;
|
|
36
38
|
outputJson?: string;
|
|
@@ -17,6 +17,7 @@ export declare function getCommandDefinitionIdentityImport(commandDefinitions: {
|
|
|
17
17
|
* @param params The parameters for the command.
|
|
18
18
|
* @param params.identity The DID of the identity to import.
|
|
19
19
|
* @param params.mnemonic The mnemonic to use for the identity.
|
|
20
|
+
* @returns A promise that resolves when the identity mnemonic has been stored in the vault.
|
|
20
21
|
*/
|
|
21
22
|
export declare function identityImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, params: {
|
|
22
23
|
identity?: string;
|
|
@@ -12,7 +12,7 @@ export declare function getCommandDefinitionIdentityVerificationMethodImport(com
|
|
|
12
12
|
[id: string]: ICliCommandDefinition;
|
|
13
13
|
}): void;
|
|
14
14
|
/**
|
|
15
|
-
* Command for
|
|
15
|
+
* Command for importing an existing key as a verification method on an identity document.
|
|
16
16
|
* @param engineCore The engine core.
|
|
17
17
|
* @param envVars The environment variables for the node.
|
|
18
18
|
* @param params The parameters for the command.
|
|
@@ -21,6 +21,7 @@ export declare function getCommandDefinitionIdentityVerificationMethodImport(com
|
|
|
21
21
|
* @param params.verificationMethodId The ID of the verification method to create.
|
|
22
22
|
* @param params.controller The controller DID for the identity.
|
|
23
23
|
* @param params.privateKeyHex The private key in hex format.
|
|
24
|
+
* @returns A promise that resolves when the verification method has been imported.
|
|
24
25
|
*/
|
|
25
26
|
export declare function identityVerificationMethodImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, params: {
|
|
26
27
|
identity?: string;
|
|
@@ -16,6 +16,7 @@ export declare function getCommandDefinitionNodeSetIdentity(commandDefinitions:
|
|
|
16
16
|
* @param envVars The environment variables for the node.
|
|
17
17
|
* @param params The parameters for the command.
|
|
18
18
|
* @param params.identity The DID to set for the node.
|
|
19
|
+
* @returns A promise that resolves when the node identity has been persisted.
|
|
19
20
|
*/
|
|
20
21
|
export declare function nodeSetIdentity(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, params: {
|
|
21
22
|
identity?: string;
|
|
@@ -15,6 +15,8 @@ export declare function getCommandDefinitionRemoveTenantOrgAlias(commandDefiniti
|
|
|
15
15
|
* @param params The parameters for the command.
|
|
16
16
|
* @param params.tenantId The tenant ID to update.
|
|
17
17
|
* @param params.alias The alias to remove from the legacy list.
|
|
18
|
+
* @returns A promise that resolves when the alias has been removed.
|
|
19
|
+
* @throws GeneralError if the tenant admin component is not registered, or the alias is not found.
|
|
18
20
|
*/
|
|
19
21
|
export declare function removeTenantOrgAlias(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
|
|
20
22
|
tenantId?: string;
|
|
@@ -16,6 +16,8 @@ export declare function getCommandDefinitionSetNodeOrgId(commandDefinitions: {
|
|
|
16
16
|
* @param envVars The environment variables for the node.
|
|
17
17
|
* @param params The parameters for the command.
|
|
18
18
|
* @param params.organizationId The organization ID to set.
|
|
19
|
+
* @returns A promise that resolves when the node organization ID has been persisted.
|
|
20
|
+
* @throws GeneralError if called while multi-tenant mode is enabled.
|
|
19
21
|
*/
|
|
20
22
|
export declare function setNodeOrgId(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, params: {
|
|
21
23
|
organizationId?: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ITenantAdminComponent } from "@twin.org/api-models";
|
|
2
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
3
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
4
3
|
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
@@ -16,40 +15,24 @@ export declare function getCommandDefinitionSetTenantOrgId(commandDefinitions: {
|
|
|
16
15
|
* @param params The parameters for the command.
|
|
17
16
|
* @param params.tenantId The tenant ID to update.
|
|
18
17
|
* @param params.organizationId The organization ID to set.
|
|
18
|
+
* @returns A promise that resolves when the tenant organization ID has been stored.
|
|
19
19
|
*/
|
|
20
20
|
export declare function setTenantOrgId(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
|
|
21
21
|
tenantId?: string;
|
|
22
22
|
organizationId?: string;
|
|
23
23
|
}): Promise<void>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param tenantAdminComponent The tenant admin component to query.
|
|
27
|
-
* @param newOrganizationId The organization DID to check.
|
|
28
|
-
* @param excludeTenantId When set, the tenant with this ID is excluded from the check (used when updating an existing tenant).
|
|
29
|
-
*/
|
|
30
|
-
export declare function assertOrganizationIdUnique(tenantAdminComponent: ITenantAdminComponent, newOrganizationId: string, excludeTenantId?: string): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Look up the tenant admin component, apply a new organization ID (moving the existing value to the
|
|
33
|
-
* legacy list), and save. Optionally wraps the operation with a CLI section header and done marker.
|
|
25
|
+
* Apply a new organization ID to a tenant.
|
|
34
26
|
* @param engineCore The engine core used to look up the tenantAdminComponent.
|
|
35
27
|
* @param tenantId The ID of the tenant to update.
|
|
36
28
|
* @param newOrganizationId The new organization DID to set.
|
|
37
29
|
* @param options Optional display and behaviour overrides.
|
|
38
|
-
* @param options.sectionLabel When set, emits
|
|
30
|
+
* @param options.sectionLabel When set, emits a CLI section header before and done marker after.
|
|
39
31
|
* @param options.required When false, returns silently when the component is not registered (default true).
|
|
32
|
+
* @returns A promise that resolves when the tenant record has been updated.
|
|
33
|
+
* @throws GeneralError if the component is required but not registered.
|
|
40
34
|
*/
|
|
41
35
|
export declare function applyOrganizationIdToTenant(engineCore: IEngineCore, tenantId: string, newOrganizationId: string, options?: {
|
|
42
36
|
sectionLabel?: string;
|
|
43
37
|
required?: boolean;
|
|
44
38
|
}): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Update an organization ID, moving the current value to the legacy list.
|
|
47
|
-
* @param currentId The current organization ID.
|
|
48
|
-
* @param legacyIds The current list of legacy organization IDs.
|
|
49
|
-
* @param newId The new organization ID to set.
|
|
50
|
-
* @returns The updated id and legacy list.
|
|
51
|
-
*/
|
|
52
|
-
export declare function updateLegacyOrganizationId(currentId: string | undefined, legacyIds: string[] | undefined, newId: string): {
|
|
53
|
-
id: string;
|
|
54
|
-
legacy: string[];
|
|
55
|
-
};
|
|
@@ -9,18 +9,21 @@ export declare function getCommandDefinitionTenantImport(commandDefinitions: {
|
|
|
9
9
|
[id: string]: ICliCommandDefinition;
|
|
10
10
|
}): void;
|
|
11
11
|
/**
|
|
12
|
-
* Command for importing a tenant.
|
|
12
|
+
* Command for importing a tenant with a known tenant ID and API key.
|
|
13
13
|
* @param engineCore The engine core.
|
|
14
14
|
* @param envVars The environment variables for the node.
|
|
15
15
|
* @param params The parameters for the command.
|
|
16
|
-
* @param params.apiKey The
|
|
17
|
-
* @param params.tenantId The tenant ID to import
|
|
18
|
-
* @param params.
|
|
16
|
+
* @param params.apiKey The API key to import.
|
|
17
|
+
* @param params.tenantId The tenant ID to import.
|
|
18
|
+
* @param params.organizationId The organization DID to associate with the tenant.
|
|
19
|
+
* @param params.label The label for the tenant.
|
|
19
20
|
* @param params.publicOrigin The public URL origin for the tenant.
|
|
21
|
+
* @returns A promise that resolves when the tenant record has been created.
|
|
20
22
|
*/
|
|
21
23
|
export declare function tenantImport(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
|
|
22
24
|
apiKey?: string;
|
|
23
25
|
tenantId?: string;
|
|
26
|
+
organizationId?: string;
|
|
24
27
|
label?: string;
|
|
25
28
|
publicOrigin?: string;
|
|
26
29
|
}): Promise<void>;
|
|
@@ -14,13 +14,16 @@ export declare function getCommandDefinitionTenantUpdate(commandDefinitions: {
|
|
|
14
14
|
* @param envVars The environment variables for the node.
|
|
15
15
|
* @param params The parameters for the command.
|
|
16
16
|
* @param params.apiKey The api key to update.
|
|
17
|
-
* @param params.tenantId The tenant ID to update
|
|
18
|
-
* @param params.
|
|
17
|
+
* @param params.tenantId The tenant ID to update.
|
|
18
|
+
* @param params.organizationId The organization DID to associate with the tenant.
|
|
19
|
+
* @param params.label The label for the tenant.
|
|
19
20
|
* @param params.publicOrigin The public URL origin for the tenant.
|
|
21
|
+
* @returns A promise that resolves when the tenant record has been updated.
|
|
20
22
|
*/
|
|
21
23
|
export declare function tenantUpdate(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
|
|
22
24
|
apiKey?: string;
|
|
23
25
|
tenantId?: string;
|
|
26
|
+
organizationId?: string;
|
|
24
27
|
label?: string;
|
|
25
28
|
publicOrigin?: string;
|
|
26
29
|
}): Promise<void>;
|
|
@@ -15,10 +15,11 @@ export declare function getCommandDefinitionVaultKeyImport(commandDefinitions: {
|
|
|
15
15
|
* @param engineCore The engine core.
|
|
16
16
|
* @param envVars The environment variables for the node.
|
|
17
17
|
* @param params The parameters for the command.
|
|
18
|
-
* @param params.identity The DID to
|
|
19
|
-
* @param params.keyId The ID of the key to
|
|
20
|
-
* @param params.keyType The type of key to
|
|
18
|
+
* @param params.identity The DID to import the vault key for.
|
|
19
|
+
* @param params.keyId The ID of the key to import.
|
|
20
|
+
* @param params.keyType The type of key to import.
|
|
21
21
|
* @param params.privateKeyHex The private key in hexadecimal format.
|
|
22
|
+
* @returns A promise that resolves when the key has been imported into the vault.
|
|
22
23
|
*/
|
|
23
24
|
export declare function vaultKeyImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: INodeEnvironmentVariables, params: {
|
|
24
25
|
identity?: string;
|
package/dist/types/defaults.d.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default verification method fragment ID for attestation.
|
|
3
|
+
*/
|
|
1
4
|
export declare const ATTESTATION_VERIFICATION_METHOD_ID = "attestation-assertion";
|
|
5
|
+
/**
|
|
6
|
+
* Default verification method fragment ID for immutable proofs.
|
|
7
|
+
*/
|
|
2
8
|
export declare const IMMUTABLE_PROOF_VERIFICATION_METHOD_ID = "immutable-proof-assertion";
|
|
9
|
+
/**
|
|
10
|
+
* Default vault key ID for blob storage encryption.
|
|
11
|
+
*/
|
|
3
12
|
export declare const BLOB_STORAGE_ENCRYPTION_KEY_ID = "blob-encryption";
|
|
13
|
+
/**
|
|
14
|
+
* Default verification method fragment ID for trust assertions.
|
|
15
|
+
*/
|
|
4
16
|
export declare const TRUST_VERIFICATION_METHOD_ID = "trust-assertion";
|
|
17
|
+
/**
|
|
18
|
+
* Default vault key ID used for signing authentication tokens.
|
|
19
|
+
*/
|
|
5
20
|
export declare const AUTH_SIGNING_KEY_ID = "auth-signing";
|
|
21
|
+
/**
|
|
22
|
+
* Feature tag identifying the DID context ID handler.
|
|
23
|
+
*/
|
|
6
24
|
export declare const CONTEXT_ID_HANDLER_FEATURE_DID = "did";
|
|
25
|
+
/**
|
|
26
|
+
* Feature tag identifying the tenant context ID handler.
|
|
27
|
+
*/
|
|
7
28
|
export declare const CONTEXT_ID_HANDLER_FEATURE_TENANT = "tenant";
|
|
8
29
|
/**
|
|
9
30
|
* Get the default environment variables for the node.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CliCommandParamType } from "./cliCommandParamType.js";
|
|
2
2
|
import type { ICliCommandDefinition } from "./ICliCommandDefinition.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* A resolved CLI command ready for execution, pairing a definition with its populated parameters.
|
|
5
5
|
*/
|
|
6
6
|
export interface ICliCommand {
|
|
7
7
|
/**
|
|
@@ -3,7 +3,7 @@ import type { CliCommandParamType } from "./cliCommandParamType.js";
|
|
|
3
3
|
import type { ICliCommandDefinitionParam } from "./ICliCommandDefinitionParam.js";
|
|
4
4
|
import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Static definition of a CLI command including its name, parameters, and execution action.
|
|
7
7
|
*/
|
|
8
8
|
export interface ICliCommandDefinition {
|
|
9
9
|
/**
|
|
@@ -15,7 +15,7 @@ export interface ICliCommandDefinition {
|
|
|
15
15
|
*/
|
|
16
16
|
description: string;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* An example invocation string shown in help output.
|
|
19
19
|
*/
|
|
20
20
|
example: string;
|
|
21
21
|
/**
|
|
@@ -18,10 +18,6 @@ export interface IEngineEnvironmentVariables {
|
|
|
18
18
|
* The name of the state file.
|
|
19
19
|
*/
|
|
20
20
|
stateFilename?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Does the node have a unique ID, defaults to true.
|
|
23
|
-
*/
|
|
24
|
-
nodeIdentityEnabled?: string;
|
|
25
21
|
/**
|
|
26
22
|
* Is multi-tenant support enabled, defaults to false.
|
|
27
23
|
*/
|
|
@@ -43,6 +43,10 @@ export interface IEngineServerEnvironmentVariables extends IEngineEnvironmentVar
|
|
|
43
43
|
* The id of the key in the vault to use for signing in auth operations.
|
|
44
44
|
*/
|
|
45
45
|
authSigningKeyId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The HTTP header name used to pass the API key on requests, defaults to x-api-key.
|
|
48
|
+
*/
|
|
49
|
+
authApiKeyHeader?: string;
|
|
46
50
|
/**
|
|
47
51
|
* The id of the key in the vault to use for encrypting hosting parameters in auth operations.
|
|
48
52
|
*/
|
|
@@ -3,5 +3,6 @@ import type { IEngineCore } from "@twin.org/engine-models";
|
|
|
3
3
|
* The type for the initialise engine method of an extension module.
|
|
4
4
|
* This is called when the engine has been constructed but not yet started.
|
|
5
5
|
* @param engineCore The engine core instance.
|
|
6
|
+
* @returns A promise that resolves when the extension engine initialisation is complete.
|
|
6
7
|
*/
|
|
7
8
|
export type NodeExtensionInitialiseEngineMethod = (engineCore: IEngineCore) => Promise<void>;
|
|
@@ -4,5 +4,6 @@ import type { IEngineCore, IEngineServer } from "@twin.org/engine-models";
|
|
|
4
4
|
* This is called when the engine server has been constructed but not yet started.
|
|
5
5
|
* @param engineCore The engine core instance.
|
|
6
6
|
* @param engineServer The engine server instance.
|
|
7
|
+
* @returns A promise that resolves when the extension engine-server initialisation is complete.
|
|
7
8
|
*/
|
|
8
9
|
export type NodeExtensionInitialiseEngineServerMethod = (engineCore: IEngineCore, engineServer: IEngineServer) => Promise<void>;
|
|
@@ -4,5 +4,6 @@ import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
|
|
|
4
4
|
* The type for the initialise method of an extension module.
|
|
5
5
|
* @param envVars The environment variables for the node.
|
|
6
6
|
* @param nodeEngineConfig The node engine config.
|
|
7
|
+
* @returns A promise that resolves when the extension configuration initialisation is complete.
|
|
7
8
|
*/
|
|
8
9
|
export type NodeExtensionInitialiseMethod = (envVars: INodeEnvironmentVariables, nodeEngineConfig: INodeEngineConfig) => Promise<void>;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ModuleProtocol } from "./models/moduleProtocol.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Initialise the locales for the application.
|
|
6
6
|
* @param localesDirectory The directory containing the locales.
|
|
7
|
+
* @returns A promise that resolves when the locale dictionary has been loaded.
|
|
7
8
|
*/
|
|
8
9
|
export declare function initialiseLocales(localesDirectory: string): Promise<void>;
|
|
9
10
|
/**
|
|
@@ -14,7 +15,7 @@ export declare function getExecutionDirectory(): string;
|
|
|
14
15
|
/**
|
|
15
16
|
* Get the directory where the script is located.
|
|
16
17
|
* @param args The command line arguments.
|
|
17
|
-
* @returns The
|
|
18
|
+
* @returns The directory containing the entry-point script, or the current working directory if not determinable.
|
|
18
19
|
*/
|
|
19
20
|
export declare function getScriptDirectory(args?: string[]): string;
|
|
20
21
|
/**
|
|
@@ -44,13 +45,13 @@ export declare function getFiles(directory: string): Promise<string[]>;
|
|
|
44
45
|
/**
|
|
45
46
|
* Load the text file.
|
|
46
47
|
* @param filename The filename of the text file to load.
|
|
47
|
-
* @returns The contents of the text file
|
|
48
|
+
* @returns The contents of the text file as a UTF-8 string.
|
|
48
49
|
*/
|
|
49
50
|
export declare function loadTextFile(filename: string): Promise<string>;
|
|
50
51
|
/**
|
|
51
52
|
* Load the JSON file.
|
|
52
53
|
* @param filename The filename of the JSON file to load.
|
|
53
|
-
* @returns The
|
|
54
|
+
* @returns The parsed JSON content of the file.
|
|
54
55
|
*/
|
|
55
56
|
export declare function loadJsonFile<T>(filename: string): Promise<T>;
|
|
56
57
|
/**
|