@hot-updater/protocol 1.2.0-rc.50 → 1.2.0-rc.51
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.cjs +13 -0
- package/dist/index.d.cts +27 -1
- package/dist/index.d.mts +27 -1
- package/dist/index.mjs +13 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -493,6 +493,17 @@ const getUtf8ByteLength = (value) => {
|
|
|
493
493
|
}
|
|
494
494
|
return bytes;
|
|
495
495
|
};
|
|
496
|
+
/**
|
|
497
|
+
* A release label as it crosses the device boundary: a positive safe
|
|
498
|
+
* integer, or null for anything else, such as a server before labels or a
|
|
499
|
+
* label in a form a later release may send. A label is for display only, so
|
|
500
|
+
* one in another form never makes a catalog or a receipt invalid.
|
|
501
|
+
*/
|
|
502
|
+
const readReleaseLabel = (value) => Number.isSafeInteger(value) && value >= 1 ? value : null;
|
|
503
|
+
/** Drops a descriptor's label that `readReleaseLabel` reads as none. */
|
|
504
|
+
const keepValidLabel = (descriptor) => {
|
|
505
|
+
if ("label" in descriptor && readReleaseLabel(descriptor.label) === null) delete descriptor.label;
|
|
506
|
+
};
|
|
496
507
|
const isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
497
508
|
const isValidReleaseDescriptor = (value) => {
|
|
498
509
|
if (value === null || typeof value !== "object") return false;
|
|
@@ -520,6 +531,7 @@ const parseReleaseCatalog = (body, expectedScope) => {
|
|
|
520
531
|
const catalog = JSON.parse(body);
|
|
521
532
|
if (catalog.schemaVersion !== 1 || typeof catalog.catalogId !== "string" || catalog.catalogId.length === 0 || typeof catalog.scopeKey !== "string" || !Number.isSafeInteger(catalog.generation) || (catalog.generation ?? 0) < 1 || typeof catalog.catalogHash !== "string" || !/^sha256:[0-9a-f]{64}$/.test(catalog.catalogHash) || catalog.fallbackPolicy !== "BUILTIN_IF_ACTIVE_INELIGIBLE" || !Array.isArray(catalog.releases) || !catalog.releases.every(isValidReleaseDescriptor) || !Array.isArray(catalog.rollbackReleases) || !catalog.rollbackReleases.every(isValidReleaseDescriptor)) return null;
|
|
522
533
|
if (!hasExpectedReleaseCatalogScope(catalog, expectedScope)) return null;
|
|
534
|
+
for (const descriptor of [...catalog.releases, ...catalog.rollbackReleases]) keepValidLabel(descriptor);
|
|
523
535
|
if (new Set([...catalog.releases, ...catalog.rollbackReleases].flatMap((release) => release.targetCohorts)).size > 512) return null;
|
|
524
536
|
return catalog;
|
|
525
537
|
} catch {
|
|
@@ -589,5 +601,6 @@ exports.normalizeRolloutCohortCount = normalizeRolloutCohortCount;
|
|
|
589
601
|
exports.parseReleaseCatalog = parseReleaseCatalog;
|
|
590
602
|
exports.parseReleaseCatalogScopeKey = require_uuid.parseReleaseCatalogScopeKey;
|
|
591
603
|
exports.pluginStorageKey = pluginStorageKey;
|
|
604
|
+
exports.readReleaseLabel = readReleaseLabel;
|
|
592
605
|
exports.resolveBaseURL = resolveBaseURL;
|
|
593
606
|
exports.selectDesiredRelease = selectDesiredRelease;
|
package/dist/index.d.cts
CHANGED
|
@@ -494,6 +494,12 @@ interface Release {
|
|
|
494
494
|
readonly sourceReleaseId: string | null;
|
|
495
495
|
readonly createdAtMs: number;
|
|
496
496
|
readonly updatedAtMs: number;
|
|
497
|
+
/**
|
|
498
|
+
* The release's label, `v<label>` in the CLI and the Console: sequential
|
|
499
|
+
* per channel and platform, never changed or reused. Null or left out
|
|
500
|
+
* until the database assigns one.
|
|
501
|
+
*/
|
|
502
|
+
readonly label?: number | null;
|
|
497
503
|
}
|
|
498
504
|
interface ReleaseCatalogDescriptor {
|
|
499
505
|
readonly releaseId: string;
|
|
@@ -503,6 +509,12 @@ interface ReleaseCatalogDescriptor {
|
|
|
503
509
|
readonly targetCohorts: readonly string[];
|
|
504
510
|
readonly shouldForceUpdate: boolean;
|
|
505
511
|
readonly message: string | null;
|
|
512
|
+
/**
|
|
513
|
+
* The release's label, when it has one. Optional on the wire: a server
|
|
514
|
+
* before labels, or a catalog too large to carry them, leaves it out, and
|
|
515
|
+
* clients read a missing or malformed one as none.
|
|
516
|
+
*/
|
|
517
|
+
readonly label?: number;
|
|
506
518
|
}
|
|
507
519
|
interface ReleaseCatalog {
|
|
508
520
|
readonly schemaVersion: typeof RELEASE_CATALOG_SCHEMA_VERSION;
|
|
@@ -533,6 +545,13 @@ interface PersistedSelectionReceipt {
|
|
|
533
545
|
readonly catalogHash: string | null;
|
|
534
546
|
readonly channel: string;
|
|
535
547
|
readonly selectionContextHash: string | null;
|
|
548
|
+
/**
|
|
549
|
+
* The selected release's label, which native keeps with the receipt so the
|
|
550
|
+
* app reads it after a restart and offline. Left out or null for the
|
|
551
|
+
* built-in bundle, a release without one, and native built from an SDK
|
|
552
|
+
* before labels, which drops it.
|
|
553
|
+
*/
|
|
554
|
+
readonly label?: number | null;
|
|
536
555
|
}
|
|
537
556
|
interface ReleaseSelectionInput {
|
|
538
557
|
readonly builtInBundleId: string;
|
|
@@ -630,6 +649,13 @@ type ExpectedReleaseCatalogScope = {
|
|
|
630
649
|
});
|
|
631
650
|
/** The length of `value` in UTF-8 bytes, without an encoder the device may lack. */
|
|
632
651
|
declare const getUtf8ByteLength: (value: string) => number;
|
|
652
|
+
/**
|
|
653
|
+
* A release label as it crosses the device boundary: a positive safe
|
|
654
|
+
* integer, or null for anything else, such as a server before labels or a
|
|
655
|
+
* label in a form a later release may send. A label is for display only, so
|
|
656
|
+
* one in another form never makes a catalog or a receipt invalid.
|
|
657
|
+
*/
|
|
658
|
+
declare const readReleaseLabel: (value: unknown) => number | null;
|
|
633
659
|
/** Whether the catalog is the expected scope's. */
|
|
634
660
|
declare const hasExpectedReleaseCatalogScope: (catalog: Pick<ReleaseCatalog, "scopeKey">, expected: ExpectedReleaseCatalogScope) => boolean;
|
|
635
661
|
/**
|
|
@@ -660,4 +686,4 @@ declare function isCohortEligibleForUpdate(bundleId: string, cohort: string | nu
|
|
|
660
686
|
declare const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
661
687
|
declare const isUUIDv7: (value: unknown) => value is string;
|
|
662
688
|
//#endregion
|
|
663
|
-
export { ARTIFACT_FILES_PROTOCOL_VERSION, ARTIFACT_FILES_REQUEST_LIMIT, ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactFiles, ArtifactFilesRequest, ArtifactInfo, ArtifactInfoV2, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, ClientPluginApi, ClientPluginApis, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientSetup, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateHttpResponse, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, resolveBaseURL, selectDesiredRelease };
|
|
689
|
+
export { ARTIFACT_FILES_PROTOCOL_VERSION, ARTIFACT_FILES_REQUEST_LIMIT, ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactFiles, ArtifactFilesRequest, ArtifactInfo, ArtifactInfoV2, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, ClientPluginApi, ClientPluginApis, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientSetup, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateHttpResponse, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, readReleaseLabel, resolveBaseURL, selectDesiredRelease };
|
package/dist/index.d.mts
CHANGED
|
@@ -494,6 +494,12 @@ interface Release {
|
|
|
494
494
|
readonly sourceReleaseId: string | null;
|
|
495
495
|
readonly createdAtMs: number;
|
|
496
496
|
readonly updatedAtMs: number;
|
|
497
|
+
/**
|
|
498
|
+
* The release's label, `v<label>` in the CLI and the Console: sequential
|
|
499
|
+
* per channel and platform, never changed or reused. Null or left out
|
|
500
|
+
* until the database assigns one.
|
|
501
|
+
*/
|
|
502
|
+
readonly label?: number | null;
|
|
497
503
|
}
|
|
498
504
|
interface ReleaseCatalogDescriptor {
|
|
499
505
|
readonly releaseId: string;
|
|
@@ -503,6 +509,12 @@ interface ReleaseCatalogDescriptor {
|
|
|
503
509
|
readonly targetCohorts: readonly string[];
|
|
504
510
|
readonly shouldForceUpdate: boolean;
|
|
505
511
|
readonly message: string | null;
|
|
512
|
+
/**
|
|
513
|
+
* The release's label, when it has one. Optional on the wire: a server
|
|
514
|
+
* before labels, or a catalog too large to carry them, leaves it out, and
|
|
515
|
+
* clients read a missing or malformed one as none.
|
|
516
|
+
*/
|
|
517
|
+
readonly label?: number;
|
|
506
518
|
}
|
|
507
519
|
interface ReleaseCatalog {
|
|
508
520
|
readonly schemaVersion: typeof RELEASE_CATALOG_SCHEMA_VERSION;
|
|
@@ -533,6 +545,13 @@ interface PersistedSelectionReceipt {
|
|
|
533
545
|
readonly catalogHash: string | null;
|
|
534
546
|
readonly channel: string;
|
|
535
547
|
readonly selectionContextHash: string | null;
|
|
548
|
+
/**
|
|
549
|
+
* The selected release's label, which native keeps with the receipt so the
|
|
550
|
+
* app reads it after a restart and offline. Left out or null for the
|
|
551
|
+
* built-in bundle, a release without one, and native built from an SDK
|
|
552
|
+
* before labels, which drops it.
|
|
553
|
+
*/
|
|
554
|
+
readonly label?: number | null;
|
|
536
555
|
}
|
|
537
556
|
interface ReleaseSelectionInput {
|
|
538
557
|
readonly builtInBundleId: string;
|
|
@@ -630,6 +649,13 @@ type ExpectedReleaseCatalogScope = {
|
|
|
630
649
|
});
|
|
631
650
|
/** The length of `value` in UTF-8 bytes, without an encoder the device may lack. */
|
|
632
651
|
declare const getUtf8ByteLength: (value: string) => number;
|
|
652
|
+
/**
|
|
653
|
+
* A release label as it crosses the device boundary: a positive safe
|
|
654
|
+
* integer, or null for anything else, such as a server before labels or a
|
|
655
|
+
* label in a form a later release may send. A label is for display only, so
|
|
656
|
+
* one in another form never makes a catalog or a receipt invalid.
|
|
657
|
+
*/
|
|
658
|
+
declare const readReleaseLabel: (value: unknown) => number | null;
|
|
633
659
|
/** Whether the catalog is the expected scope's. */
|
|
634
660
|
declare const hasExpectedReleaseCatalogScope: (catalog: Pick<ReleaseCatalog, "scopeKey">, expected: ExpectedReleaseCatalogScope) => boolean;
|
|
635
661
|
/**
|
|
@@ -660,4 +686,4 @@ declare function isCohortEligibleForUpdate(bundleId: string, cohort: string | nu
|
|
|
660
686
|
declare const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
661
687
|
declare const isUUIDv7: (value: unknown) => value is string;
|
|
662
688
|
//#endregion
|
|
663
|
-
export { ARTIFACT_FILES_PROTOCOL_VERSION, ARTIFACT_FILES_REQUEST_LIMIT, ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactFiles, ArtifactFilesRequest, ArtifactInfo, ArtifactInfoV2, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, ClientPluginApi, ClientPluginApis, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientSetup, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateHttpResponse, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, resolveBaseURL, selectDesiredRelease };
|
|
689
|
+
export { ARTIFACT_FILES_PROTOCOL_VERSION, ARTIFACT_FILES_REQUEST_LIMIT, ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactFiles, ArtifactFilesRequest, ArtifactInfo, ArtifactInfoV2, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, ClientPluginApi, ClientPluginApis, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientSetup, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateHttpResponse, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, readReleaseLabel, resolveBaseURL, selectDesiredRelease };
|
package/dist/index.mjs
CHANGED
|
@@ -492,6 +492,17 @@ const getUtf8ByteLength = (value) => {
|
|
|
492
492
|
}
|
|
493
493
|
return bytes;
|
|
494
494
|
};
|
|
495
|
+
/**
|
|
496
|
+
* A release label as it crosses the device boundary: a positive safe
|
|
497
|
+
* integer, or null for anything else, such as a server before labels or a
|
|
498
|
+
* label in a form a later release may send. A label is for display only, so
|
|
499
|
+
* one in another form never makes a catalog or a receipt invalid.
|
|
500
|
+
*/
|
|
501
|
+
const readReleaseLabel = (value) => Number.isSafeInteger(value) && value >= 1 ? value : null;
|
|
502
|
+
/** Drops a descriptor's label that `readReleaseLabel` reads as none. */
|
|
503
|
+
const keepValidLabel = (descriptor) => {
|
|
504
|
+
if ("label" in descriptor && readReleaseLabel(descriptor.label) === null) delete descriptor.label;
|
|
505
|
+
};
|
|
495
506
|
const isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
496
507
|
const isValidReleaseDescriptor = (value) => {
|
|
497
508
|
if (value === null || typeof value !== "object") return false;
|
|
@@ -519,6 +530,7 @@ const parseReleaseCatalog = (body, expectedScope) => {
|
|
|
519
530
|
const catalog = JSON.parse(body);
|
|
520
531
|
if (catalog.schemaVersion !== 1 || typeof catalog.catalogId !== "string" || catalog.catalogId.length === 0 || typeof catalog.scopeKey !== "string" || !Number.isSafeInteger(catalog.generation) || (catalog.generation ?? 0) < 1 || typeof catalog.catalogHash !== "string" || !/^sha256:[0-9a-f]{64}$/.test(catalog.catalogHash) || catalog.fallbackPolicy !== "BUILTIN_IF_ACTIVE_INELIGIBLE" || !Array.isArray(catalog.releases) || !catalog.releases.every(isValidReleaseDescriptor) || !Array.isArray(catalog.rollbackReleases) || !catalog.rollbackReleases.every(isValidReleaseDescriptor)) return null;
|
|
521
532
|
if (!hasExpectedReleaseCatalogScope(catalog, expectedScope)) return null;
|
|
533
|
+
for (const descriptor of [...catalog.releases, ...catalog.rollbackReleases]) keepValidLabel(descriptor);
|
|
522
534
|
if (new Set([...catalog.releases, ...catalog.rollbackReleases].flatMap((release) => release.targetCohorts)).size > 512) return null;
|
|
523
535
|
return catalog;
|
|
524
536
|
} catch {
|
|
@@ -536,4 +548,4 @@ const ARTIFACT_FILES_PROTOCOL_VERSION = 2;
|
|
|
536
548
|
/** Paths one artifact files request may resolve; a device splits more. */
|
|
537
549
|
const ARTIFACT_FILES_REQUEST_LIMIT = 100;
|
|
538
550
|
//#endregion
|
|
539
|
-
export { ARTIFACT_FILES_PROTOCOL_VERSION, ARTIFACT_FILES_REQUEST_LIMIT, ARTIFACT_PROTOCOL_VERSION, DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, NIL_UUID, NUMERIC_COHORT_SIZE, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, resolveBaseURL, selectDesiredRelease };
|
|
551
|
+
export { ARTIFACT_FILES_PROTOCOL_VERSION, ARTIFACT_FILES_REQUEST_LIMIT, ARTIFACT_PROTOCOL_VERSION, DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, NIL_UUID, NUMERIC_COHORT_SIZE, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, readReleaseLabel, resolveBaseURL, selectDesiredRelease };
|