@oniroproject/core 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -321,6 +321,23 @@ type Apl = 'normal' | 'system_basic' | 'system_core';
321
321
  type AppFeature = 'hos_normal_app' | 'hos_system_app';
322
322
  declare const APL_VALUES: readonly Apl[];
323
323
  declare const APP_FEATURE_VALUES: readonly AppFeature[];
324
+ /**
325
+ * Which signing key pairs with the chosen `apl`.
326
+ *
327
+ * - `'profile-release'` — the **OpenHarmony Application Profile Release** key.
328
+ * Default for apl=normal. Matches the cert chain that ships with the SDK
329
+ * (`OpenHarmonyProfileRelease.pem`). What `hvigor` uses for ordinary apps.
330
+ *
331
+ * - `'application-release'` — the **OpenHarmony Application Release** key.
332
+ * Required for apl=system_basic|system_core. BMS's parse-profile-prop check
333
+ * rejects HAPs whose `distribution-certificate` subject is "Application
334
+ * Profile Release" when the HAP requests permissions above its apl. The
335
+ * matching cert chain (`OpenHarmonyApplication.cer`) is not shipped in the
336
+ * SDK, so we ship it ourselves under `applicationCert.ts`.
337
+ */
338
+ type SigningKind = 'profile-release' | 'application-release';
339
+ /** @internal exposed for tests. */
340
+ declare function pickSigningKind(apl: Apl): SigningKind;
324
341
  interface GenerateSigningConfigsOptions {
325
342
  /** Absolute path to the OpenHarmony project (the folder containing build-profile.json5). */
326
343
  projectDir: string;
@@ -338,9 +355,23 @@ interface GenerateSigningConfigsOptions {
338
355
  * when `apl='normal'`, otherwise `'hos_system_app'`.
339
356
  */
340
357
  appFeature?: AppFeature;
358
+ /**
359
+ * Permission names to write into the profile's `acls.allowed-acls`. Required for
360
+ * apps that request permissions above their `apl` (e.g. a system_basic app
361
+ * requesting `ohos.permission.CAPTURE_SCREEN`). When omitted, the template's
362
+ * existing `allowed-acls` is left alone.
363
+ */
364
+ acls?: string[];
341
365
  /** Optional logger; defaults to no-op. */
342
366
  logger?: Logger;
343
367
  }
368
+ /**
369
+ * Read all `products[*].signingConfig` names from the project's build-profile.json5.
370
+ * Returns the unique names in declaration order. Falls back to `['default']` when
371
+ * the file is missing or has no products.
372
+ * @internal exposed for tests.
373
+ */
374
+ declare function detectSigningConfigNames(projectDir: string): string[];
344
375
  /**
345
376
  * Generate signing configs for an OpenHarmony project: copies certs, signs the profile,
346
377
  * generates the signing material, and writes the resulting `signingConfigs` entry into
@@ -590,4 +621,4 @@ declare function writeJsonFile(filePath: string, value: unknown): void;
590
621
 
591
622
  declare const VERSION: string;
592
623
 
593
- export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type Apl, type AppFeature, CancelledError, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DownloadOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type HilogEntry, type HilogLevel, type InstallAppOptions, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallSdkOptions, type LaunchAppOptions, type Logger, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type ProgressReporter, type ProgressUpdate, type Prompter, type RunHvigorwOptions, type RunHvigorwResult, type RunningProcess, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SetHilogLevelOptions, type StartEmulatorOptions, type StreamHilogOptions, type TemplateOption, UnsupportedPlatformError, VERSION, attemptHdcConnection, consoleLogger, createMaterial, createScaffold, decryptPwd, defaultContext, defaultPaths, detectProjectSdkVersion, downloadAndInstallSdk, downloadFile, encryptPwd, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getEmulatorDir, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isValidBundleName, isValidProjectName, launchApp, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, parseHilogLine, readJson5File, readJsonFile, removeCmdTools, removeEmulator, removeSdk, runHvigorw, setHilogLevel, startEmulator, staticConfig, stopEmulator, streamHilog, validateTemplateLayout, verifySha256, writeJson5File, writeJsonFile };
624
+ export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type Apl, type AppFeature, CancelledError, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DownloadOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type HilogEntry, type HilogLevel, type InstallAppOptions, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallSdkOptions, type LaunchAppOptions, type Logger, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type ProgressReporter, type ProgressUpdate, type Prompter, type RunHvigorwOptions, type RunHvigorwResult, type RunningProcess, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SetHilogLevelOptions, type SigningKind, type StartEmulatorOptions, type StreamHilogOptions, type TemplateOption, UnsupportedPlatformError, VERSION, attemptHdcConnection, consoleLogger, createMaterial, createScaffold, decryptPwd, defaultContext, defaultPaths, detectProjectSdkVersion, detectSigningConfigNames, downloadAndInstallSdk, downloadFile, encryptPwd, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getEmulatorDir, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isValidBundleName, isValidProjectName, launchApp, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, parseHilogLine, pickSigningKind, readJson5File, readJsonFile, removeCmdTools, removeEmulator, removeSdk, runHvigorw, setHilogLevel, startEmulator, staticConfig, stopEmulator, streamHilog, validateTemplateLayout, verifySha256, writeJson5File, writeJsonFile };
package/dist/index.d.ts CHANGED
@@ -321,6 +321,23 @@ type Apl = 'normal' | 'system_basic' | 'system_core';
321
321
  type AppFeature = 'hos_normal_app' | 'hos_system_app';
322
322
  declare const APL_VALUES: readonly Apl[];
323
323
  declare const APP_FEATURE_VALUES: readonly AppFeature[];
324
+ /**
325
+ * Which signing key pairs with the chosen `apl`.
326
+ *
327
+ * - `'profile-release'` — the **OpenHarmony Application Profile Release** key.
328
+ * Default for apl=normal. Matches the cert chain that ships with the SDK
329
+ * (`OpenHarmonyProfileRelease.pem`). What `hvigor` uses for ordinary apps.
330
+ *
331
+ * - `'application-release'` — the **OpenHarmony Application Release** key.
332
+ * Required for apl=system_basic|system_core. BMS's parse-profile-prop check
333
+ * rejects HAPs whose `distribution-certificate` subject is "Application
334
+ * Profile Release" when the HAP requests permissions above its apl. The
335
+ * matching cert chain (`OpenHarmonyApplication.cer`) is not shipped in the
336
+ * SDK, so we ship it ourselves under `applicationCert.ts`.
337
+ */
338
+ type SigningKind = 'profile-release' | 'application-release';
339
+ /** @internal exposed for tests. */
340
+ declare function pickSigningKind(apl: Apl): SigningKind;
324
341
  interface GenerateSigningConfigsOptions {
325
342
  /** Absolute path to the OpenHarmony project (the folder containing build-profile.json5). */
326
343
  projectDir: string;
@@ -338,9 +355,23 @@ interface GenerateSigningConfigsOptions {
338
355
  * when `apl='normal'`, otherwise `'hos_system_app'`.
339
356
  */
340
357
  appFeature?: AppFeature;
358
+ /**
359
+ * Permission names to write into the profile's `acls.allowed-acls`. Required for
360
+ * apps that request permissions above their `apl` (e.g. a system_basic app
361
+ * requesting `ohos.permission.CAPTURE_SCREEN`). When omitted, the template's
362
+ * existing `allowed-acls` is left alone.
363
+ */
364
+ acls?: string[];
341
365
  /** Optional logger; defaults to no-op. */
342
366
  logger?: Logger;
343
367
  }
368
+ /**
369
+ * Read all `products[*].signingConfig` names from the project's build-profile.json5.
370
+ * Returns the unique names in declaration order. Falls back to `['default']` when
371
+ * the file is missing or has no products.
372
+ * @internal exposed for tests.
373
+ */
374
+ declare function detectSigningConfigNames(projectDir: string): string[];
344
375
  /**
345
376
  * Generate signing configs for an OpenHarmony project: copies certs, signs the profile,
346
377
  * generates the signing material, and writes the resulting `signingConfigs` entry into
@@ -590,4 +621,4 @@ declare function writeJsonFile(filePath: string, value: unknown): void;
590
621
 
591
622
  declare const VERSION: string;
592
623
 
593
- export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type Apl, type AppFeature, CancelledError, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DownloadOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type HilogEntry, type HilogLevel, type InstallAppOptions, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallSdkOptions, type LaunchAppOptions, type Logger, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type ProgressReporter, type ProgressUpdate, type Prompter, type RunHvigorwOptions, type RunHvigorwResult, type RunningProcess, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SetHilogLevelOptions, type StartEmulatorOptions, type StreamHilogOptions, type TemplateOption, UnsupportedPlatformError, VERSION, attemptHdcConnection, consoleLogger, createMaterial, createScaffold, decryptPwd, defaultContext, defaultPaths, detectProjectSdkVersion, downloadAndInstallSdk, downloadFile, encryptPwd, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getEmulatorDir, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isValidBundleName, isValidProjectName, launchApp, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, parseHilogLine, readJson5File, readJsonFile, removeCmdTools, removeEmulator, removeSdk, runHvigorw, setHilogLevel, startEmulator, staticConfig, stopEmulator, streamHilog, validateTemplateLayout, verifySha256, writeJson5File, writeJsonFile };
624
+ export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type Apl, type AppFeature, CancelledError, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DownloadOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type HilogEntry, type HilogLevel, type InstallAppOptions, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallSdkOptions, type LaunchAppOptions, type Logger, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type ProgressReporter, type ProgressUpdate, type Prompter, type RunHvigorwOptions, type RunHvigorwResult, type RunningProcess, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SetHilogLevelOptions, type SigningKind, type StartEmulatorOptions, type StreamHilogOptions, type TemplateOption, UnsupportedPlatformError, VERSION, attemptHdcConnection, consoleLogger, createMaterial, createScaffold, decryptPwd, defaultContext, defaultPaths, detectProjectSdkVersion, detectSigningConfigNames, downloadAndInstallSdk, downloadFile, encryptPwd, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getEmulatorDir, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isValidBundleName, isValidProjectName, launchApp, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, parseHilogLine, pickSigningKind, readJson5File, readJsonFile, removeCmdTools, removeEmulator, removeSdk, runHvigorw, setHilogLevel, startEmulator, staticConfig, stopEmulator, streamHilog, validateTemplateLayout, verifySha256, writeJson5File, writeJsonFile };
package/dist/index.js CHANGED
@@ -822,25 +822,101 @@ import * as fs10 from "fs";
822
822
  import * as path10 from "path";
823
823
  import { execFileSync as execFileSync2 } from "child_process";
824
824
  import JSON52 from "json5";
825
+
826
+ // src/sign/applicationCert.ts
827
+ var OPEN_HARMONY_APPLICATION_CERT = `-----BEGIN CERTIFICATE-----
828
+ MIICRDCCAcmgAwIBAgIED+E4izAMBggqhkjOPQQDAwUAMGgxCzAJBgNVBAYTAkNO
829
+ MRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh
830
+ bTEoMCYGA1UEAxMfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUm9vdCBDQTAeFw0y
831
+ MTAyMDIxMjE0MThaFw00OTEyMzExMjE0MThaMGgxCzAJBgNVBAYTAkNOMRQwEgYD
832
+ VQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVhbTEoMCYG
833
+ A1UEAxMfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUm9vdCBDQTB2MBAGByqGSM49
834
+ AgEGBSuBBAAiA2IABE023XmRaw2DnO8NSsb+KG/uY0FtS3u5LQucdr3qWVnRW5ui
835
+ QIL6ttNZBEeLTUeYcJZCpayg9Llf+1SmDA7dY4iP2EcRo4UN3rilovtfFfsmH4ty
836
+ 3SApHVFzWUl+NwdH8KNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
837
+ AQYwHQYDVR0OBBYEFBc6EKGrGXzlAE+s0Zgnsphadw7NMAwGCCqGSM49BAMDBQAD
838
+ ZwAwZAIwd1p3JzHN93eoPped1li0j64npgqNzwy4OrkehYAqNXpcpaEcLZ7UxW8E
839
+ I2lZJ3SbAjAkqySHb12sIwdSFKSN9KCMMEo/eUT5dUXlcKR2nZz0MJdxT5F51qcX
840
+ 1CumzkcYhgU=
841
+ -----END CERTIFICATE-----
842
+ -----BEGIN CERTIFICATE-----
843
+ MIICYTCCAeWgAwIBAgIEHmXAPTAMBggqhkjOPQQDAwUAMGgxCzAJBgNVBAYTAkNO
844
+ MRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh
845
+ bTEoMCYGA1UEAxMfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUm9vdCBDQTAeFw0y
846
+ MTAyMDIxMjE1MzJaFw00OTEyMzExMjE1MzJaMGMxCzAJBgNVBAYTAkNOMRQwEgYD
847
+ VQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVhbTEjMCEG
848
+ A1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwdjAQBgcqhkjOPQIBBgUr
849
+ gQQAIgNiAAQhnu7Hna8XNa2KyqRf5+lBJScE4xqf89N0g0OuqAb2re8nGsvWkw26
850
+ uDekfnBYicd+G3Cydqa2zFIwV7Talyg2ULW3r8KbGpyl84mJEPPRmCGJ+H9gtCsf
851
+ +OrJ4Y76LVWjYzBhMB8GA1UdIwQYMBaAFBc6EKGrGXzlAE+s0Zgnsphadw7NMA8G
852
+ A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTbhrciFtUL
853
+ oUu33SV7ufEFfaItRzAMBggqhkjOPQQDAwUAA2gAMGUCMG3cXjiDmXTvf7D4Omhf
854
+ qcc2nuO+EMfWE+N9ZhBP5UhV34mAGWi3SfLU6rcV0urWEQIxAMYIb3epOnKhUrcm
855
+ Lfu1WKzFlpYQwmw73RaCHP2I3k6NcuWOYeNwWXSNZ8o0nzvaLg==
856
+ -----END CERTIFICATE-----
857
+ -----BEGIN CERTIFICATE-----
858
+ MIICMzCCAbegAwIBAgIEaOC/zDAMBggqhkjOPQQDAwUAMGMxCzAJBgNVBAYTAkNO
859
+ MRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh
860
+ bTEjMCEGA1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwHhcNMjEwMjAy
861
+ MTIxOTMxWhcNNDkxMjMxMTIxOTMxWjBoMQswCQYDVQQGEwJDTjEUMBIGA1UEChML
862
+ T3Blbkhhcm1vbnkxGTAXBgNVBAsTEE9wZW5IYXJtb255IFRlYW0xKDAmBgNVBAMT
863
+ H09wZW5IYXJtb255IEFwcGxpY2F0aW9uIFJlbGVhc2UwWTATBgcqhkjOPQIBBggq
864
+ hkjOPQMBBwNCAATbYOCQQpW5fdkYHN45v0X3AHax12jPBdEDosFRIZ1eXmxOYzSG
865
+ JwMfsHhUU90E8lI0TXYZnNmgM1sovubeQqATo1IwUDAfBgNVHSMEGDAWgBTbhrci
866
+ FtULoUu33SV7ufEFfaItRzAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFPtxruhl
867
+ cRBQsJdwcZqLu9oNUVgaMAwGCCqGSM49BAMDBQADaAAwZQIxAJta0PQ2p4DIu/ps
868
+ LMdLCDgQ5UH1l0B4PGhBlMgdi2zf8nk9spazEQI/0XNwpft8QAIwHSuA2WelVi/o
869
+ zAlF08DnbJrOOtOnQq5wHOPlDYB4OtUzOYJk9scotrEnJxJzGsh/
870
+ -----END CERTIFICATE-----
871
+ `;
872
+
873
+ // src/sign/generateSigningConfigs.ts
825
874
  var APL_VALUES = ["normal", "system_basic", "system_core"];
826
875
  var APP_FEATURE_VALUES = ["hos_normal_app", "hos_system_app"];
827
- function copyFilesToProject(projectDir, paths, logger) {
876
+ function pickSigningKind(apl) {
877
+ return apl === "normal" ? "profile-release" : "application-release";
878
+ }
879
+ var SIGNING_KIND_CONFIG = {
880
+ "profile-release": {
881
+ hapKeyAlias: "openharmony application profile release",
882
+ certBasename: "OpenHarmonyProfileRelease.pem"
883
+ },
884
+ "application-release": {
885
+ hapKeyAlias: "OpenHarmony Application Release",
886
+ certBasename: "OpenHarmonyApplication.cer"
887
+ }
888
+ };
889
+ function copyFilesToProject(projectDir, paths, kind, logger) {
828
890
  logger.info("[sign] Copying signing material into project...");
829
891
  const signaturesDir = path10.join(projectDir, "signatures");
830
892
  fs10.mkdirSync(signaturesDir, { recursive: true });
831
893
  fs10.copyFileSync(paths.keystore, path10.join(signaturesDir, "OpenHarmony.p12"));
832
894
  fs10.copyFileSync(paths.profileCert, path10.join(signaturesDir, "OpenHarmonyProfileRelease.pem"));
833
895
  fs10.copyFileSync(paths.unsignedProfileTemplate, path10.join(signaturesDir, "UnsgnedReleasedProfileTemplate.json"));
896
+ if (kind === "application-release") {
897
+ fs10.writeFileSync(
898
+ path10.join(signaturesDir, "OpenHarmonyApplication.cer"),
899
+ OPEN_HARMONY_APPLICATION_CERT
900
+ );
901
+ }
834
902
  }
835
903
  function resolveAppFeature(apl, override) {
836
904
  if (override) return override;
837
905
  return apl === "normal" ? "hos_normal_app" : "hos_system_app";
838
906
  }
839
- function modifyProfileTemplate(projectDir, apl, appFeature, logger) {
840
- logger.info(`[sign] Modifying profile template (apl=${apl}, app-feature=${appFeature})...`);
907
+ function extractLeafCertificate(chainPath) {
908
+ const certContent = fs10.readFileSync(chainPath, "utf-8");
909
+ const parts = certContent.split("-----END CERTIFICATE-----");
910
+ if (parts.length < 3) {
911
+ throw new OniroError(`${chainPath} does not contain enough certificates.`);
912
+ }
913
+ return parts[2].trim() + "\n-----END CERTIFICATE-----\n";
914
+ }
915
+ function modifyProfileTemplate(projectDir, apl, appFeature, logger, options = {}) {
916
+ const kind = options.kind ?? pickSigningKind(apl);
917
+ logger.info(`[sign] Modifying profile template (apl=${apl}, app-feature=${appFeature}, kind=${kind})...`);
841
918
  const appJsonPath = path10.join(projectDir, "AppScope/app.json5");
842
919
  const profileTemplatePath = path10.join(projectDir, "signatures/UnsgnedReleasedProfileTemplate.json");
843
- const profileCertFilePath = path10.join(projectDir, "signatures/OpenHarmonyProfileRelease.pem");
844
920
  if (!fs10.existsSync(appJsonPath)) {
845
921
  throw new OniroError(`${appJsonPath} does not exist.`);
846
922
  }
@@ -865,13 +941,16 @@ function modifyProfileTemplate(projectDir, apl, appFeature, logger) {
865
941
  profileTemplate["bundle-info"]["bundle-name"] = appJson.app.bundleName;
866
942
  profileTemplate["bundle-info"]["apl"] = apl;
867
943
  profileTemplate["bundle-info"]["app-feature"] = appFeature;
868
- const certContent = fs10.readFileSync(profileCertFilePath, "utf-8");
869
- const certs = certContent.split("-----END CERTIFICATE-----");
870
- if (certs.length < 3) {
871
- throw new OniroError(`${profileCertFilePath} does not contain enough certificates.`);
944
+ const distCertChainPath = path10.join(
945
+ projectDir,
946
+ "signatures",
947
+ SIGNING_KIND_CONFIG[kind].certBasename
948
+ );
949
+ profileTemplate["bundle-info"]["distribution-certificate"] = extractLeafCertificate(distCertChainPath);
950
+ if (options.acls !== void 0) {
951
+ profileTemplate.acls = profileTemplate.acls ?? {};
952
+ profileTemplate.acls["allowed-acls"] = options.acls;
872
953
  }
873
- const thirdCert = certs[2].trim() + "\n-----END CERTIFICATE-----\n";
874
- profileTemplate["bundle-info"]["distribution-certificate"] = thirdCert;
875
954
  fs10.writeFileSync(profileTemplatePath, JSON.stringify(profileTemplate, null, 2));
876
955
  }
877
956
  function generateP7bFile(projectDir, paths, logger) {
@@ -911,7 +990,27 @@ function generateP7bFile(projectDir, paths, logger) {
911
990
  );
912
991
  }
913
992
  }
914
- function updateBuildProfile(projectDir, logger) {
993
+ function detectSigningConfigNames(projectDir) {
994
+ const buildProfilePath = path10.join(projectDir, "build-profile.json5");
995
+ if (!fs10.existsSync(buildProfilePath)) return ["default"];
996
+ let parsed;
997
+ try {
998
+ parsed = JSON52.parse(fs10.readFileSync(buildProfilePath, "utf-8"));
999
+ } catch {
1000
+ return ["default"];
1001
+ }
1002
+ const products = parsed.app?.products;
1003
+ if (!Array.isArray(products) || products.length === 0) return ["default"];
1004
+ const names = [];
1005
+ for (const product of products) {
1006
+ const name = product.signingConfig;
1007
+ if (typeof name === "string" && name.length > 0 && !names.includes(name)) {
1008
+ names.push(name);
1009
+ }
1010
+ }
1011
+ return names.length > 0 ? names : ["default"];
1012
+ }
1013
+ function updateBuildProfile(projectDir, kind, logger) {
915
1014
  logger.info("[sign] Writing signing configs into build-profile.json5...");
916
1015
  const materialDir = path10.join(projectDir, "signatures", "material");
917
1016
  const buildProfilePath = path10.join(projectDir, "build-profile.json5");
@@ -925,21 +1024,22 @@ function updateBuildProfile(projectDir, logger) {
925
1024
  throw new OniroError(`Error parsing ${buildProfilePath}: ${e.message}`, e);
926
1025
  }
927
1026
  }
1027
+ const { hapKeyAlias, certBasename } = SIGNING_KIND_CONFIG[kind];
1028
+ const configNames = detectSigningConfigNames(projectDir);
1029
+ logger.info(`[sign] Writing signingConfigs entries: ${configNames.join(", ")}`);
928
1030
  buildProfile.app = buildProfile.app ?? {};
929
- buildProfile.app.signingConfigs = [
930
- {
931
- name: "default",
932
- material: {
933
- certpath: "./signatures/OpenHarmonyProfileRelease.pem",
934
- storePassword: encryptedStorePassword,
935
- keyAlias: "openharmony application profile release",
936
- keyPassword: encryptedKeyPassword,
937
- profile: "./signatures/app1-profile.p7b",
938
- signAlg: "SHA256withECDSA",
939
- storeFile: "./signatures/OpenHarmony.p12"
940
- }
1031
+ buildProfile.app.signingConfigs = configNames.map((name) => ({
1032
+ name,
1033
+ material: {
1034
+ certpath: `./signatures/${certBasename}`,
1035
+ storePassword: encryptedStorePassword,
1036
+ keyAlias: hapKeyAlias,
1037
+ keyPassword: encryptedKeyPassword,
1038
+ profile: "./signatures/app1-profile.p7b",
1039
+ signAlg: "SHA256withECDSA",
1040
+ storeFile: "./signatures/OpenHarmony.p12"
941
1041
  }
942
- ];
1042
+ }));
943
1043
  fs10.writeFileSync(buildProfilePath, JSON.stringify(buildProfile, null, 2));
944
1044
  }
945
1045
  function prepareMaterialDirectory(projectDir, logger) {
@@ -979,12 +1079,13 @@ function generateSigningConfigs(options) {
979
1079
  profileCert: path10.join(sdkPath, "toolchains/lib/OpenHarmonyProfileRelease.pem"),
980
1080
  unsignedProfileTemplate: path10.join(sdkPath, "toolchains/lib/UnsgnedReleasedProfileTemplate.json")
981
1081
  };
1082
+ const kind = pickSigningKind(apl);
982
1083
  logger.info("[sign] Starting signing configuration generation...");
983
- copyFilesToProject(projectDir, paths, logger);
984
- modifyProfileTemplate(projectDir, apl, appFeature, logger);
1084
+ copyFilesToProject(projectDir, paths, kind, logger);
1085
+ modifyProfileTemplate(projectDir, apl, appFeature, logger, { kind, acls: options.acls });
985
1086
  generateP7bFile(projectDir, paths, logger);
986
1087
  prepareMaterialDirectory(projectDir, logger);
987
- updateBuildProfile(projectDir, logger);
1088
+ updateBuildProfile(projectDir, kind, logger);
988
1089
  logger.info("[sign] Signing configuration generated successfully.");
989
1090
  }
990
1091
 
@@ -1670,7 +1771,7 @@ async function createScaffold(opts) {
1670
1771
  }
1671
1772
 
1672
1773
  // src/index.ts
1673
- var VERSION = "0.6.0";
1774
+ var VERSION = "0.6.2";
1674
1775
  export {
1675
1776
  ALL_SDKS,
1676
1777
  APL_VALUES,
@@ -1691,6 +1792,7 @@ export {
1691
1792
  defaultContext,
1692
1793
  defaultPaths,
1693
1794
  detectProjectSdkVersion,
1795
+ detectSigningConfigNames,
1694
1796
  downloadAndInstallSdk,
1695
1797
  downloadFile,
1696
1798
  encryptPwd,
@@ -1729,6 +1831,7 @@ export {
1729
1831
  noopLogger,
1730
1832
  noopProgress,
1731
1833
  parseHilogLine,
1834
+ pickSigningKind,
1732
1835
  readJson5File,
1733
1836
  readJsonFile,
1734
1837
  removeCmdTools,