@junobuild/admin 2.2.2-next-2025-09-24 → 2.2.2-next-2025-09-25

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/upgrade.errors.ts", "../../src/errors/version.errors.ts", "../../src/helpers/crypto.helpers.ts", "../../src/helpers/package.helpers.ts", "../../src/helpers/version.helpers.ts", "../../src/helpers/wasm.helpers.ts", "../../src/schemas/build.ts", "../../src/schemas/releases.ts", "../../src/api/mission-control.api.ts", "../../src/utils/controllers.utils.ts", "../../src/services/mission-control.controllers.services.ts", "../../src/services/mission-control.upgrade.services.ts", "../../src/constants/upgrade.constants.ts", "../../src/handlers/upgrade.handlers.ts", "../../src/api/ic.api.ts", "../../src/types/upgrade.ts", "../../src/handlers/upgrade.chunks.handlers.ts", "../../src/handlers/upgrade.single.handlers.ts", "../../src/utils/idl.utils.ts", "../../src/services/mission-control.version.services.ts", "../../src/services/package.services.ts", "../../src/services/module.upgrade.services.ts", "../../src/api/orbiter.api.ts", "../../src/services/orbiter.controllers.services.ts", "../../src/services/orbiter.memory.services.ts", "../../src/services/orbiter.upgrade.services.ts", "../../src/services/orbiter.version.services.ts", "../../src/api/satellite.api.ts", "../../src/services/satellite.assets.services.ts", "../../src/services/satellite.config.services.ts", "../../src/utils/config.utils.ts", "../../src/utils/memory.utils.ts", "../../src/services/satellite.controllers.services.ts", "../../src/services/satellite.docs.services.ts", "../../src/services/satellite.domains.services.ts", "../../src/services/satellite.memory.services.ts", "../../src/utils/rule.utils.ts", "../../src/constants/rules.constants.ts", "../../src/services/satellite.rules.services.ts", "../../src/services/satellite.upgrade.services.ts", "../../src/services/satellite.version.services.ts"],
4
- "sourcesContent": ["export class UpgradeCodeUnchangedError extends Error {\n constructor() {\n super(\n 'The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.'\n );\n }\n}\n", "import {\n JUNO_PACKAGE_MISSION_CONTROL_ID,\n JUNO_PACKAGE_ORBITER_ID,\n JUNO_PACKAGE_SATELLITE_ID\n} from '@junobuild/config';\n\nexport class SatelliteMissingDependencyError extends Error {\n constructor() {\n super(`Invalid dependency tree: required module ${JUNO_PACKAGE_SATELLITE_ID} is missing.`);\n }\n}\n\nexport class MissionControlVersionError extends Error {\n constructor() {\n super(`Invalid package: the provided module name is not ${JUNO_PACKAGE_MISSION_CONTROL_ID}.`);\n }\n}\n\nexport class OrbiterVersionError extends Error {\n constructor() {\n super(`Invalid package: the provided module name is not ${JUNO_PACKAGE_ORBITER_ID}.`);\n }\n}\n", "// Sources:\n// https://stackoverflow.com/a/70891826/5404186\n// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest\n\nconst digestSha256 = (data: ArrayBuffer | Uint8Array<ArrayBufferLike>): Promise<ArrayBuffer> =>\n crypto.subtle.digest('SHA-256', data);\n\nconst sha256ToHex = (hashBuffer: ArrayBuffer): string => {\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');\n};\n\nexport const blobSha256 = async (blob: Blob): Promise<string> => {\n const hashBuffer = await digestSha256(await blob.arrayBuffer());\n return sha256ToHex(hashBuffer);\n};\n\nexport const uint8ArraySha256 = async (data: Uint8Array): Promise<string> => {\n const hashBuffer = await digestSha256(data);\n return sha256ToHex(hashBuffer);\n};\n", "import type {JunoPackageDependencies} from '@junobuild/config';\n\n/**\n * Finds a specific dependency in a `JunoPackageDependencies` map.\n *\n * @param {Object} params - The parameters for the search.\n * @param {string} params.dependencyId - The ID of the dependency to look for.\n * @param {JunoPackageDependencies | undefined} params.dependencies - The full list of dependencies, or `undefined`.\n *\n * @returns {[string, string] | undefined} A tuple containing the dependency ID and version if found, or `undefined` if not found or no dependencies are present.\n */\nexport const findJunoPackageDependency = ({\n dependencyId,\n dependencies\n}: {\n dependencyId: string;\n dependencies: JunoPackageDependencies | undefined;\n}): [string, string] | undefined =>\n Object.entries(dependencies ?? {}).find(([key, _]) => key === dependencyId);\n", "import {major, minor, patch} from 'semver';\n\n/**\n * Checks if the selected version can be upgraded from the current version.\n * @param {Object} params - The parameters for the version check.\n * @param {string} params.currentVersion - The current version.\n * @param {string} params.selectedVersion - The selected version.\n * @returns {Object} An object indicating whether the upgrade can proceed.\n * @returns {boolean} returns.canUpgrade - Whether the selected version can be upgraded from the current version.\n */\nexport const checkUpgradeVersion = ({\n currentVersion,\n selectedVersion\n}: {\n currentVersion: string;\n selectedVersion: string;\n}): {canUpgrade: boolean} => {\n const currentMajor = major(currentVersion);\n const selectedMajor = major(selectedVersion);\n const currentMinor = minor(currentVersion);\n const selectedMinor = minor(selectedVersion);\n const currentPath = patch(currentVersion);\n const selectedPath = patch(selectedVersion);\n\n if (\n currentMajor < selectedMajor - 1 ||\n currentMinor < selectedMinor - 1 ||\n currentPath < selectedPath - 1\n ) {\n return {canUpgrade: false};\n }\n\n return {canUpgrade: true};\n};\n", "import {isNullish, nonNullish} from '@dfinity/utils';\nimport {type JunoPackage, JUNO_PACKAGE_SATELLITE_ID, JunoPackageSchema} from '@junobuild/config';\nimport type {BuildType} from '../schemas/build';\nimport {findJunoPackageDependency} from './package.helpers';\n\n/**\n * Extracts the build type from a provided Juno package or falls back to a deprecated detection method.\n *\n * @param {Object} params\n * @param {JunoPackage | undefined} params.junoPackage - The parsed Juno package metadata.\n * @param {Uint8Array} params.wasm - The WASM binary to inspect if no package is provided.\n * @returns {Promise<BuildType | undefined>} The build type (`'stock'` or `'extended'`) or `undefined` if undetermined.\n */\nexport const extractBuildType = async ({\n junoPackage,\n wasm\n}: {\n junoPackage: JunoPackage | undefined;\n wasm: Uint8Array;\n}): Promise<BuildType | undefined> => {\n if (isNullish(junoPackage)) {\n return await readDeprecatedBuildType({wasm});\n }\n\n const {name, dependencies} = junoPackage;\n\n if (name === JUNO_PACKAGE_SATELLITE_ID) {\n return 'stock';\n }\n\n const satelliteDependency = findJunoPackageDependency({\n dependencies,\n dependencyId: JUNO_PACKAGE_SATELLITE_ID\n });\n\n return nonNullish(satelliteDependency) ? 'extended' : undefined;\n};\n\n/**\n * @deprecated Modern WASM build use JunoPackage.\n */\nconst readDeprecatedBuildType = async ({\n wasm\n}: {\n wasm: Uint8Array;\n}): Promise<BuildType | undefined> => {\n const buildType = await customSection({wasm, sectionName: 'icp:public juno:build'});\n\n return nonNullish(buildType) && ['stock', 'extended'].includes(buildType)\n ? (buildType as BuildType)\n : undefined;\n};\n\n/**\n * Reads and parses the Juno package from the custom section of a WASM binary.\n *\n * @param {Object} params\n * @param {Uint8Array} params.wasm - The WASM binary containing the embedded custom section.\n * @returns {Promise<JunoPackage | undefined>} The parsed Juno package if present and valid, otherwise `undefined`.\n */\nexport const readCustomSectionJunoPackage = async ({\n wasm\n}: {\n wasm: Uint8Array;\n}): Promise<JunoPackage | undefined> => {\n const section = await customSection({wasm, sectionName: 'icp:public juno:package'});\n\n if (isNullish(section)) {\n return undefined;\n }\n\n const pkg = JSON.parse(section);\n\n const {success, data} = JunoPackageSchema.safeParse(pkg);\n return success ? data : undefined;\n};\n\nconst customSection = async ({\n sectionName,\n wasm\n}: {\n sectionName: string;\n wasm: Uint8Array;\n}): Promise<string | undefined> => {\n const wasmModule = await WebAssembly.compile(wasm);\n\n const pkgSections = WebAssembly.Module.customSections(wasmModule, sectionName);\n\n const [pkgBuffer] = pkgSections;\n\n return nonNullish(pkgBuffer) ? new TextDecoder().decode(pkgBuffer) : undefined;\n};\n", "import * as z from 'zod/v4';\n\n/**\n * Represents the type of build, stock or extended.\n */\nexport const BuildTypeSchema = z.enum(['stock', 'extended']);\n\n/**\n * Represents the type of build.\n * @typedef {'stock' | 'extended'} BuildType\n */\nexport type BuildType = z.infer<typeof BuildTypeSchema>;\n", "import * as z from 'zod/v4';\n\n/**\n * A schema for validating a version string in `x.y.z` format.\n *\n * Examples of valid versions:\n * - 0.1.0\"\n * - 2.3.4\n */\nexport const MetadataVersionSchema = z.string().refine((val) => /^\\d+\\.\\d+\\.\\d+$/.test(val), {\n message: 'Version does not match x.y.z format'\n});\n\n/**\n * A version string in `x.y.z` format.\n */\nexport type MetadataVersion = z.infer<typeof MetadataVersionSchema>;\n\n/**\n * A schema representing the metadata of a single release.\n *\n * Includes the version of the release itself (tag) and the versions\n * of all modules bundled with it.\n */\nexport const ReleaseMetadataSchema = z.strictObject({\n /**\n * Unique version identifier for the release, following the `x.y.z` format.\n * @type {MetadataVersion}\n */\n tag: MetadataVersionSchema,\n\n /**\n * The version of the console included in the release.\n * @type {MetadataVersion}\n */\n console: MetadataVersionSchema,\n\n /**\n * Version of the Observatory module included in the release.\n * This field is optional because it was introduced in Juno v0.0.10.\n *\n * @type {MetadataVersion | undefined}\n */\n observatory: MetadataVersionSchema.optional(),\n\n /**\n * Version of the Mission Control module included in the release.\n * @type {MetadataVersion}\n */\n mission_control: MetadataVersionSchema,\n\n /**\n * Version of the Satellite module included in the release.\n * @type {MetadataVersion}\n */\n satellite: MetadataVersionSchema,\n\n /**\n * Version of the Orbiter module included in the release.\n * This field is optional because it was introduced in Juno v0.0.17.\n *\n * @type {MetadataVersion | undefined}\n */\n orbiter: MetadataVersionSchema.optional(),\n\n /**\n * Version of the Sputnik module included in the release.\n * This field is optional because it was introduced in Juno v0.0.47.\n *\n * @type {MetadataVersion | undefined}\n */\n sputnik: MetadataVersionSchema.optional()\n});\n\n/**\n * The metadata for a release provided by Juno.\n */\nexport type ReleaseMetadata = z.infer<typeof ReleaseMetadataSchema>;\n\n/**\n * A schema representing the list of releases provided by Juno.\n *\n * Rules:\n * - The list must contain at least one release.\n * - Each release must have a unique `tag` (version identifier).\n * - The same module version can appear in multiple releases, as not every release\n * necessarily publishes a new version of each module.\n *\n * Validation:\n * - Ensures no duplicate `tag` values across the list of releases.\n */\nexport const ReleasesSchema = z\n .array(ReleaseMetadataSchema)\n .min(1)\n .refine((releases) => new Set(releases.map(({tag}) => tag)).size === releases.length, {\n message: 'A release tag appears multiple times but must be unique'\n });\n\n/**\n * The list of releases provided by Juno.\n */\nexport type Releases = z.infer<typeof ReleasesSchema>;\n\n/**\n * A schema for the list of all versions across releases.\n *\n * Rules:\n * - The list must contain at least one release.\n */\nexport const MetadataVersionsSchema = z.array(MetadataVersionSchema).min(1);\n\n/**\n * List of all versions across releases.\n */\nexport type MetadataVersions = z.infer<typeof MetadataVersionsSchema>;\n\n/**\n * A schema representing the metadata for multiple releases provided by Juno.\n */\nexport const ReleasesMetadataSchema = z.strictObject({\n /**\n * List of all Mission Control versions across releases.\n * @type {MetadataVersion}\n */\n mission_controls: MetadataVersionsSchema,\n\n /**\n * List of all Satellite versions across releases.\n * @type {MetadataVersion}\n */\n satellites: MetadataVersionsSchema,\n\n /**\n * List of all Orbiter versions across releases.\n * @type {MetadataVersion}\n */\n orbiters: MetadataVersionsSchema,\n\n /**\n * List of release metadata objects, each representing one release.\n */\n releases: ReleasesSchema\n});\n\n/**\n * The metadata for multiple releases provided by Juno.\n */\nexport type ReleasesMetadata = z.infer<typeof ReleasesMetadataSchema>;\n", "import type {Principal} from '@dfinity/principal';\nimport {\n type MissionControlDid,\n type MissionControlParameters,\n getDeprecatedMissionControlVersionActor,\n getMissionControlActor\n} from '@junobuild/ic-client/actor';\n\n/**\n * @deprecated - Replaced in Mission Control > v0.0.14 with public custom section juno:package\n */\nexport const version = async ({\n missionControl\n}: {\n missionControl: MissionControlParameters;\n}): Promise<string> => {\n const {version} = await getDeprecatedMissionControlVersionActor(missionControl);\n return version();\n};\n\nexport const getUser = async ({\n missionControl\n}: {\n missionControl: MissionControlParameters;\n}): Promise<Principal> => {\n const {get_user} = await getMissionControlActor(missionControl);\n return get_user();\n};\n\nexport const listControllers = async ({\n missionControl\n}: {\n missionControl: MissionControlParameters;\n}): Promise<[Principal, MissionControlDid.Controller][]> => {\n const {list_mission_control_controllers} = await getMissionControlActor(missionControl);\n return list_mission_control_controllers();\n};\n\nexport const setSatellitesController = async ({\n missionControl,\n satelliteIds,\n controllerIds,\n controller\n}: {\n missionControl: MissionControlParameters;\n satelliteIds: Principal[];\n controllerIds: Principal[];\n controller: MissionControlDid.SetController;\n}) => {\n const {set_satellites_controllers} = await getMissionControlActor(missionControl);\n return set_satellites_controllers(satelliteIds, controllerIds, controller);\n};\n\nexport const setMissionControlController = async ({\n missionControl,\n controllerIds,\n controller\n}: {\n missionControl: MissionControlParameters;\n controllerIds: Principal[];\n controller: MissionControlDid.SetController;\n}) => {\n const {set_mission_control_controllers} = await getMissionControlActor(missionControl);\n return set_mission_control_controllers(controllerIds, controller);\n};\n", "import {Principal} from '@dfinity/principal';\nimport {nonNullish, toNullable} from '@dfinity/utils';\nimport type {MissionControlDid} from '@junobuild/ic-client/actor';\nimport type {SetControllerParams} from '../types/controllers';\n\nexport const mapSetControllerParams = ({\n controllerId,\n profile\n}: SetControllerParams): {\n controllerIds: Principal[];\n controller: MissionControlDid.SetController;\n} => ({\n controllerIds: [Principal.fromText(controllerId)],\n controller: toSetController(profile)\n});\n\nconst toSetController = (profile: string | null | undefined): MissionControlDid.SetController => ({\n metadata: nonNullish(profile) && profile !== '' ? [['profile', profile]] : [],\n expires_at: toNullable<bigint>(undefined),\n scope: {Admin: null}\n});\n", "import type {Principal} from '@dfinity/principal';\nimport type {MissionControlDid, MissionControlParameters} from '@junobuild/ic-client/actor';\nimport {\n listControllers,\n setMissionControlController as setMissionControlControllerApi,\n setSatellitesController as setSatellitesControllerApi\n} from '../api/mission-control.api';\nimport type {SetControllerParams} from '../types/controllers';\nimport {mapSetControllerParams} from '../utils/controllers.utils';\n\n/**\n * Sets the controller for the specified satellites.\n * @param {Object} params - The parameters for setting the satellites controller.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @param {Principal[]} params.satelliteIds - The IDs of the satellites.\n * @param {SetControllerParams} params - Additional parameters for setting the controller.\n * @returns {Promise<void>} A promise that resolves when the controller is set.\n */\nexport const setSatellitesController = ({\n controllerId,\n profile,\n ...rest\n}: {\n missionControl: MissionControlParameters;\n satelliteIds: Principal[];\n} & SetControllerParams): Promise<void> =>\n setSatellitesControllerApi({\n ...rest,\n ...mapSetControllerParams({controllerId, profile})\n });\n\n/**\n * Sets the controller for Mission Control.\n * @param {Object} params - The parameters for setting the Mission Control controller.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @param {SetControllerParams} params - Additional parameters for setting the controller.\n * @returns {Promise<void>} A promise that resolves when the controller is set.\n */\nexport const setMissionControlController = ({\n controllerId,\n profile,\n ...rest\n}: {\n missionControl: MissionControlParameters;\n} & SetControllerParams): Promise<void> =>\n setMissionControlControllerApi({\n ...rest,\n ...mapSetControllerParams({controllerId, profile})\n });\n\n/**\n * Lists the controllers of Mission Control.\n * @param {Object} params - The parameters for listing the controllers.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const listMissionControlControllers = (params: {\n missionControl: MissionControlParameters;\n}): Promise<[Principal, MissionControlDid.Controller][]> => listControllers(params);\n", "import type {MissionControlParameters} from '@junobuild/ic-client/actor';\nimport {toPrincipal} from '@junobuild/ic-client/utils';\nimport {getUser} from '../api/mission-control.api';\nimport {INSTALL_MODE_UPGRADE} from '../constants/upgrade.constants';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\nimport {encoreIDLUser} from '../utils/idl.utils';\n\n/**\n * Upgrades the Mission Control with the provided WASM module.\n * @param {Object} params - The parameters for upgrading the Mission Control.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters, including the actor and mission control ID.\n * @param {Uint8Array} params.wasmModule - The WASM module to be installed during the upgrade.\n * @param {boolean} [params.preClearChunks] - Optional. Whether to force clearing chunks before uploading a chunked WASM module. Recommended if the WASM exceeds 2MB.\n * @param {boolean} [params.takeSnapshot=true] - Optional. Whether to take a snapshot before performing the upgrade. Defaults to true.\n * @param {function} [params.onProgress] - Optional. Callback function to report progress during the upgrade process.\n * @throws {Error} Will throw an error if the mission control principal is not defined.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\nexport const upgradeMissionControl = async ({\n missionControl,\n ...rest\n}: {\n missionControl: MissionControlParameters;\n} & Pick<\n UpgradeCodeParams,\n 'wasmModule' | 'preClearChunks' | 'takeSnapshot' | 'onProgress'\n>): Promise<void> => {\n const user = await getUser({missionControl});\n\n const {missionControlId, ...actor} = missionControl;\n\n if (!missionControlId) {\n throw new Error('No mission control principal defined.');\n }\n\n const arg = encoreIDLUser(user);\n\n await upgrade({\n actor,\n canisterId: toPrincipal(missionControlId),\n arg,\n mode: INSTALL_MODE_UPGRADE,\n ...rest\n });\n};\n", "import type {canister_install_mode} from '@dfinity/ic-management';\n\nexport const SIMPLE_INSTALL_MAX_WASM_SIZE = 2_000_000;\nexport const INSTALL_MAX_CHUNK_SIZE = 1_000_000;\n\nexport const INSTALL_MODE_RESET: canister_install_mode = {reinstall: null};\n\nexport const INSTALL_MODE_UPGRADE: canister_install_mode = {\n upgrade: [{skip_pre_upgrade: [false], wasm_memory_persistence: [{replace: null}]}]\n};\n", "import {fromNullable, isNullish, uint8ArrayToHexString} from '@dfinity/utils';\nimport {\n canisterStart,\n canisterStatus,\n canisterStop,\n listCanisterSnapshots,\n takeCanisterSnapshot\n} from '../api/ic.api';\nimport {SIMPLE_INSTALL_MAX_WASM_SIZE} from '../constants/upgrade.constants';\nimport {UpgradeCodeUnchangedError} from '../errors/upgrade.errors';\nimport {uint8ArraySha256} from '../helpers/crypto.helpers';\nimport {type UpgradeCodeParams, UpgradeCodeProgressStep} from '../types/upgrade';\nimport {upgradeChunkedCode} from './upgrade.chunks.handlers';\nimport {upgradeSingleChunkCode} from './upgrade.single.handlers';\n\nexport const upgrade = async ({\n wasmModule,\n canisterId,\n actor,\n onProgress,\n takeSnapshot = true,\n ...rest\n}: UpgradeCodeParams & {reset?: boolean}) => {\n // 1. We verify that the code to be installed is different from the code already deployed. If the codes are identical, we skip the installation.\n // TODO: unless mode is reinstall\n const assert = async () => await assertExistingCode({wasmModule, canisterId, actor, ...rest});\n await execute({fn: assert, onProgress, step: UpgradeCodeProgressStep.AssertingExistingCode});\n\n // 2. We stop the canister to prepare for the upgrade.\n const stop = async () => await canisterStop({canisterId, actor});\n await execute({fn: stop, onProgress, step: UpgradeCodeProgressStep.StoppingCanister});\n\n try {\n // 3. We take a snapshot - create a backup - unless the dev opted-out\n const snapshot = async () =>\n takeSnapshot ? await createSnapshot({canisterId, actor}) : Promise.resolve();\n await execute({fn: snapshot, onProgress, step: UpgradeCodeProgressStep.TakingSnapshot});\n\n // 4. Upgrading code: If the WASM is > 2MB we proceed with the chunked installation otherwise we use the original single chunk installation method.\n const upgrade = async () => await upgradeCode({wasmModule, canisterId, actor, ...rest});\n await execute({fn: upgrade, onProgress, step: UpgradeCodeProgressStep.UpgradingCode});\n } finally {\n // 5. We restart the canister to finalize the process.\n const restart = async () => await canisterStart({canisterId, actor});\n await execute({fn: restart, onProgress, step: UpgradeCodeProgressStep.RestartingCanister});\n }\n};\n\nconst execute = async ({\n fn,\n step,\n onProgress\n}: {fn: () => Promise<void>; step: UpgradeCodeProgressStep} & Pick<\n UpgradeCodeParams,\n 'onProgress'\n>) => {\n onProgress?.({\n step,\n state: 'in_progress'\n });\n\n try {\n await fn();\n\n onProgress?.({\n step,\n state: 'success'\n });\n } catch (err: unknown) {\n onProgress?.({\n step,\n state: 'error'\n });\n\n throw err;\n }\n};\n\nconst assertExistingCode = async ({\n actor,\n canisterId,\n wasmModule,\n reset\n}: Pick<UpgradeCodeParams, 'actor' | 'canisterId' | 'wasmModule'> & {reset?: boolean}) => {\n // If we want to reinstall the module we are fine reinstalling the same version of the code\n if (reset === true) {\n return;\n }\n\n const {module_hash} = await canisterStatus({\n actor,\n canisterId\n });\n\n const installedHash = fromNullable(module_hash);\n\n if (isNullish(installedHash)) {\n return;\n }\n\n const newWasmModuleHash = await uint8ArraySha256(wasmModule);\n const existingWasmModuleHash = uint8ArrayToHexString(installedHash);\n\n if (newWasmModuleHash !== existingWasmModuleHash) {\n return;\n }\n\n throw new UpgradeCodeUnchangedError();\n};\n\nconst upgradeCode = async ({\n wasmModule,\n canisterId,\n actor,\n ...rest\n}: Omit<UpgradeCodeParams, 'onProgress'>) => {\n const upgradeType = (): 'chunked' | 'single' => {\n const blob = new Blob([wasmModule]);\n return blob.size > SIMPLE_INSTALL_MAX_WASM_SIZE ? 'chunked' : 'single';\n };\n\n const fn = upgradeType() === 'chunked' ? upgradeChunkedCode : upgradeSingleChunkCode;\n await fn({wasmModule, canisterId, actor, ...rest});\n};\n\nconst createSnapshot = async (params: Pick<UpgradeCodeParams, 'canisterId' | 'actor'>) => {\n const snapshots = await listCanisterSnapshots(params);\n\n // TODO: currently only one snapshot per canister is supported on the IC\n await takeCanisterSnapshot({\n ...params,\n snapshotId: snapshots?.[0]?.id\n });\n};\n", "import {CanisterStatus} from '@dfinity/agent';\nimport {\n type chunk_hash,\n type InstallChunkedCodeParams,\n type InstallCodeParams,\n type list_canister_snapshots_result,\n type snapshot_id,\n type UploadChunkParams,\n ICManagementCanister\n} from '@dfinity/ic-management';\nimport type {take_canister_snapshot_result} from '@dfinity/ic-management/dist/candid/ic-management';\nimport type {CanisterStatusResponse} from '@dfinity/ic-management/dist/types/types/ic-management.responses';\nimport {Principal} from '@dfinity/principal';\nimport {type ActorParameters, useOrInitAgent} from '@junobuild/ic-client/actor';\n\nexport const canisterStop = async ({\n canisterId,\n actor\n}: {\n canisterId: Principal;\n actor: ActorParameters;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {stopCanister} = ICManagementCanister.create({\n agent\n });\n\n await stopCanister(canisterId);\n};\n\nexport const canisterStart = async ({\n canisterId,\n actor\n}: {\n canisterId: Principal;\n actor: ActorParameters;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {startCanister} = ICManagementCanister.create({\n agent\n });\n\n await startCanister(canisterId);\n};\n\nexport const installCode = async ({\n actor,\n code\n}: {\n actor: ActorParameters;\n code: InstallCodeParams;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {installCode} = ICManagementCanister.create({\n agent\n });\n\n return installCode(code);\n};\n\nexport const storedChunks = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<chunk_hash[]> => {\n const agent = await useOrInitAgent(actor);\n\n const {storedChunks} = ICManagementCanister.create({\n agent\n });\n\n return storedChunks({canisterId});\n};\n\nexport const clearChunkStore = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {clearChunkStore} = ICManagementCanister.create({\n agent\n });\n\n return clearChunkStore({canisterId});\n};\n\nexport const uploadChunk = async ({\n actor,\n chunk\n}: {\n actor: ActorParameters;\n chunk: UploadChunkParams;\n}): Promise<chunk_hash> => {\n const agent = await useOrInitAgent(actor);\n\n const {uploadChunk} = ICManagementCanister.create({\n agent\n });\n\n return uploadChunk(chunk);\n};\n\nexport const installChunkedCode = async ({\n actor,\n code\n}: {\n actor: ActorParameters;\n code: InstallChunkedCodeParams;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {installChunkedCode} = ICManagementCanister.create({\n agent\n });\n\n return installChunkedCode(code);\n};\n\nexport const canisterStatus = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<CanisterStatusResponse> => {\n const agent = await useOrInitAgent(actor);\n\n const {canisterStatus} = ICManagementCanister.create({\n agent\n });\n\n return canisterStatus(canisterId);\n};\n\nexport const canisterMetadata = async ({\n canisterId,\n path,\n ...rest\n}: ActorParameters & {\n canisterId: Principal | string;\n path: string;\n}): Promise<CanisterStatus.Status | undefined> => {\n const agent = await useOrInitAgent(rest);\n\n // TODO: Workaround for agent-js. Disable console.warn.\n // See https://github.com/dfinity/agent-js/issues/843\n const hideAgentJsConsoleWarn = globalThis.console.warn;\n globalThis.console.warn = (): null => null;\n\n const result = await CanisterStatus.request({\n canisterId: canisterId instanceof Principal ? canisterId : Principal.from(canisterId),\n agent,\n paths: [\n {\n kind: 'metadata',\n key: path,\n path,\n decodeStrategy: 'utf-8'\n }\n ]\n });\n\n // Redo console.warn\n globalThis.console.warn = hideAgentJsConsoleWarn;\n\n return result.get(path);\n};\n\nexport const listCanisterSnapshots = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<list_canister_snapshots_result> => {\n const agent = await useOrInitAgent(actor);\n\n const {listCanisterSnapshots} = ICManagementCanister.create({\n agent\n });\n\n return listCanisterSnapshots({canisterId});\n};\n\nexport const takeCanisterSnapshot = async ({\n actor,\n ...rest\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n snapshotId?: snapshot_id;\n}): Promise<take_canister_snapshot_result> => {\n const agent = await useOrInitAgent(actor);\n\n const {takeCanisterSnapshot} = ICManagementCanister.create({\n agent\n });\n\n return takeCanisterSnapshot(rest);\n};\n", "import type {canister_install_mode} from '@dfinity/ic-management';\nimport type {Principal} from '@dfinity/principal';\nimport type {ActorParameters} from '@junobuild/ic-client/actor';\n\nexport enum UpgradeCodeProgressStep {\n AssertingExistingCode,\n StoppingCanister,\n TakingSnapshot,\n UpgradingCode,\n RestartingCanister\n}\n\nexport type UpgradeCodeProgressState = 'in_progress' | 'success' | 'error';\n\nexport interface UpgradeCodeProgress {\n step: UpgradeCodeProgressStep;\n state: UpgradeCodeProgressState;\n}\n\nexport interface UpgradeCodeParams {\n actor: ActorParameters;\n canisterId: Principal;\n missionControlId?: Principal;\n wasmModule: Uint8Array;\n arg: Uint8Array;\n mode: canister_install_mode;\n preClearChunks?: boolean;\n takeSnapshot?: boolean;\n onProgress?: (progress: UpgradeCodeProgress) => void;\n}\n", "import type {chunk_hash} from '@dfinity/ic-management';\nimport {isNullish, nonNullish, uint8ArrayToHexString} from '@dfinity/utils';\nimport {\n clearChunkStore,\n installChunkedCode,\n storedChunks as storedChunksApi,\n uploadChunk as uploadChunkApi\n} from '../api/ic.api';\nimport {INSTALL_MAX_CHUNK_SIZE} from '../constants/upgrade.constants';\nimport {blobSha256, uint8ArraySha256} from '../helpers/crypto.helpers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\n\ninterface UploadChunkOrderId {\n orderId: number;\n}\n\ninterface UploadChunkParams extends UploadChunkOrderId {\n chunk: Blob;\n sha256: string;\n}\n\ninterface UploadChunkResult extends UploadChunkOrderId {\n chunkHash: chunk_hash;\n}\n\nexport const upgradeChunkedCode = async ({\n actor,\n canisterId,\n missionControlId,\n wasmModule,\n preClearChunks: userPreClearChunks,\n ...rest\n}: UpgradeCodeParams) => {\n // If the user want to clear - reset - any chunks that have been uploaded before we start by removing those.\n if (userPreClearChunks) {\n await clearChunkStore({actor, canisterId});\n }\n\n const wasmChunks = await wasmToChunks({wasmModule});\n\n const {uploadChunks, storedChunks, preClearChunks, postClearChunks} = await prepareUpload({\n actor,\n wasmChunks,\n canisterId,\n missionControlId\n });\n\n // Alright, let's start by clearing existing chunks if there are already stored chunks but, none are matching those we want to upload.\n if (preClearChunks) {\n await clearChunkStore({actor, canisterId});\n }\n\n // Upload chunks to the IC in batch - i.e. 12 chunks uploaded at a time.\n let chunkIds: UploadChunkResult[] = [];\n for await (const results of batchUploadChunks({\n uploadChunks,\n actor,\n canisterId,\n missionControlId\n })) {\n chunkIds = [...chunkIds, ...results];\n }\n\n // Install the chunked code.\n // \u26A0\uFE0F The order of the chunks is really important! \u26A0\uFE0F\n await installChunkedCode({\n actor,\n code: {\n ...rest,\n chunkHashesList: [...chunkIds, ...storedChunks]\n .sort(({orderId: orderIdA}, {orderId: orderIdB}) => orderIdA - orderIdB)\n .map(({chunkHash}) => chunkHash),\n targetCanisterId: canisterId,\n storeCanisterId: missionControlId,\n wasmModuleHash: await uint8ArraySha256(wasmModule)\n }\n });\n\n // Finally let's clear only if no mission control is provided, as the chunks might be reused in that case.\n if (postClearChunks) {\n await clearChunkStore({actor, canisterId});\n }\n};\n\nconst wasmToChunks = async ({\n wasmModule\n}: Pick<UpgradeCodeParams, 'wasmModule'>): Promise<UploadChunkParams[]> => {\n const blob = new Blob([wasmModule]);\n\n const uploadChunks: UploadChunkParams[] = [];\n\n const chunkSize = INSTALL_MAX_CHUNK_SIZE;\n\n // Split data into chunks\n let orderId = 0;\n for (let start = 0; start < blob.size; start += chunkSize) {\n const chunk = blob.slice(start, start + chunkSize);\n uploadChunks.push({\n chunk,\n orderId,\n sha256: await blobSha256(chunk)\n });\n\n orderId++;\n }\n\n return uploadChunks;\n};\n\ninterface PrepareUpload {\n uploadChunks: UploadChunkParams[];\n storedChunks: UploadChunkResult[];\n preClearChunks: boolean;\n postClearChunks: boolean;\n}\n\n/**\n * Prepares the upload of WASM chunks by determining which chunks need to be uploaded\n * and which are already stored. Additionally, it provides flags for pre-clear and post-clear operations.\n *\n * If a `missionControlId` is provided, the function fetches the already stored chunks\n * for the given mission control canister. Otherwise, it fetches them from the `canisterId`.\n *\n * In the response, `preClearChunks` is set to `true` if no stored chunks matching the one we are looking to upload are detected.\n * `postClearChunks` is set to `true` if no `missionControlId` is given, as the chunks might be reused for other installations.\n *\n * @param {Object} params - The input parameters.\n * @param {string} params.canisterId - The ID of the target canister.\n * @param {string} [params.missionControlId] - The ID of the mission control canister, if provided.\n * @param {Object} params.actor - The actor instance for interacting with the canister.\n * @param {UploadChunkParams[]} params.wasmChunks - The WASM chunks to be uploaded, including their hashes and metadata.\n *\n * @returns {Promise<PrepareUpload>} Resolves to an object containing:\n */\nconst prepareUpload = async ({\n canisterId,\n missionControlId,\n actor,\n wasmChunks\n}: Pick<UpgradeCodeParams, 'canisterId' | 'missionControlId' | 'actor'> & {\n wasmChunks: UploadChunkParams[];\n}): Promise<PrepareUpload> => {\n const stored = await storedChunksApi({\n actor,\n canisterId: missionControlId ?? canisterId\n });\n\n // We convert existing hash to extend with an easily comparable sha256 as hex value\n const existingStoredChunks: (Pick<UploadChunkResult, 'chunkHash'> &\n Pick<UploadChunkParams, 'sha256'>)[] = stored.map(({hash}) => ({\n chunkHash: {hash},\n sha256: uint8ArrayToHexString(hash)\n }));\n\n const {storedChunks, uploadChunks} = wasmChunks.reduce<\n Omit<PrepareUpload, 'preClearChunks' | 'postClearChunks'>\n >(\n ({uploadChunks, storedChunks}, {sha256, ...rest}) => {\n const existingStoredChunk = existingStoredChunks.find(\n ({sha256: storedSha256}) => storedSha256 === sha256\n );\n\n return {\n uploadChunks: [\n ...uploadChunks,\n ...(nonNullish(existingStoredChunk) ? [] : [{sha256, ...rest}])\n ],\n storedChunks: [\n ...storedChunks,\n ...(nonNullish(existingStoredChunk) ? [{...rest, ...existingStoredChunk}] : [])\n ]\n };\n },\n {\n uploadChunks: [],\n storedChunks: []\n }\n );\n\n return {\n uploadChunks,\n storedChunks,\n preClearChunks: stored.length > 0 && storedChunks.length === 0,\n postClearChunks: isNullish(missionControlId)\n };\n};\n\nasync function* batchUploadChunks({\n uploadChunks,\n limit = 12,\n ...rest\n}: Pick<UpgradeCodeParams, 'actor' | 'canisterId' | 'missionControlId'> & {\n uploadChunks: UploadChunkParams[];\n limit?: number;\n}): AsyncGenerator<UploadChunkResult[], void> {\n for (let i = 0; i < uploadChunks.length; i = i + limit) {\n const batch = uploadChunks.slice(i, i + limit);\n const result = await Promise.all(\n batch.map((uploadChunkParams) =>\n uploadChunk({\n uploadChunk: uploadChunkParams,\n ...rest\n })\n )\n );\n yield result;\n }\n}\n\nconst uploadChunk = async ({\n actor,\n canisterId,\n missionControlId,\n uploadChunk: {chunk, ...rest}\n}: Pick<UpgradeCodeParams, 'actor' | 'canisterId' | 'missionControlId'> & {\n uploadChunk: UploadChunkParams;\n}): Promise<UploadChunkResult> => {\n const chunkHash = await uploadChunkApi({\n actor,\n chunk: {\n canisterId: missionControlId ?? canisterId,\n chunk: new Uint8Array(await chunk.arrayBuffer())\n }\n });\n\n return {\n chunkHash,\n ...rest\n };\n};\n", "import {installCode} from '../api/ic.api';\nimport type {UpgradeCodeParams} from '../types/upgrade';\n\nexport const upgradeSingleChunkCode = async ({actor, ...rest}: UpgradeCodeParams) => {\n await installCode({\n actor,\n code: rest\n });\n};\n", "import {IDL} from '@dfinity/candid';\nimport type {Principal} from '@dfinity/principal';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\n\nexport const encoreIDLUser = (user: Principal): Uint8Array =>\n IDL.encode(\n [\n IDL.Record({\n user: IDL.Principal\n })\n ],\n [{user}]\n );\n\nexport const encodeAdminAccessKeysToIDL = (\n controllers: [Principal, SatelliteDid.Controller][]\n): Uint8Array =>\n IDL.encode(\n [\n IDL.Record({\n controllers: IDL.Vec(IDL.Principal)\n })\n ],\n [\n {\n controllers: controllers\n .filter(([_, {scope}]) => 'Admin' in scope)\n .map(([controller, _]) => controller)\n }\n ]\n );\n", "import {assertNonNullish, isNullish} from '@dfinity/utils';\nimport {JUNO_PACKAGE_MISSION_CONTROL_ID} from '@junobuild/config';\nimport type {MissionControlParameters} from '@junobuild/ic-client/actor';\nimport {version} from '../api/mission-control.api';\nimport {MissionControlVersionError} from '../errors/version.errors';\nimport {getJunoPackage} from './package.services';\n\n/**\n * Retrieves the version of Mission Control.\n * @param {Object} params - The parameters for Mission Control.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @returns {Promise<string>} A promise that resolves to the version of Mission Control.\n */\nexport const missionControlVersion = async ({\n missionControl: {missionControlId, ...rest}\n}: {\n missionControl: MissionControlParameters;\n}): Promise<string> => {\n assertNonNullish(\n missionControlId,\n 'A Mission Control ID must be provided to request its version.'\n );\n\n const pkg = await getJunoPackage({\n moduleId: missionControlId,\n ...rest\n });\n\n // For backwards compatibility with legacy. Function version() was deprecated in Mission Control > v0.0.14\n if (isNullish(pkg)) {\n return await version({missionControl: {missionControlId, ...rest}});\n }\n\n const {name, version: missionControlVersion} = pkg;\n\n if (name === JUNO_PACKAGE_MISSION_CONTROL_ID) {\n return missionControlVersion;\n }\n\n throw new MissionControlVersionError();\n};\n", "import type {Principal} from '@dfinity/principal';\nimport {isNullish} from '@dfinity/utils';\nimport {type JunoPackage, JunoPackageSchema} from '@junobuild/config';\nimport type {ActorParameters} from '@junobuild/ic-client/actor';\nimport * as z from 'zod/v4';\nimport {canisterMetadata} from '../api/ic.api';\n\n/**\n * Parameters required to retrieve a `juno:package` metadata section.\n *\n * @typedef {Object} GetJunoPackageParams\n * @property {Principal | string} moduleId - The ID of the canister module (as a Principal or string).\n * @property {ActorParameters} [ActorParameters] - Additional actor parameters for making the canister call.\n */\nexport type GetJunoPackageParams = {moduleId: Principal | string} & ActorParameters;\n\n/**\n * Get the `juno:package` metadata from the public custom section of a given module.\n *\n * @param {Object} params - The parameters to fetch the metadata.\n * @param {Principal | string} params.moduleId - The canister ID (as a `Principal` or string) from which to retrieve the metadata.\n * @param {ActorParameters} params - Additional actor parameters required for the call.\n *\n * @returns {Promise<JunoPackage | undefined>} A promise that resolves to the parsed `JunoPackage` metadata, or `undefined` if not found.\n *\n * @throws {ZodError} If the metadata exists but does not conform to the expected `JunoPackage` schema.\n */\nexport const getJunoPackage = async ({\n moduleId,\n ...rest\n}: GetJunoPackageParams): Promise<JunoPackage | undefined> => {\n const status = await canisterMetadata({...rest, canisterId: moduleId, path: 'juno:package'});\n\n if (isNullish(status)) {\n return undefined;\n }\n\n if (typeof status !== 'string') {\n throw new Error('Unexpected metadata type to parse public custom section juno:package');\n }\n\n // https://stackoverflow.com/a/75881231/5404186\n // https://github.com/colinhacks/zod/discussions/2215#discussioncomment-5356286\n const createPackageFromJson = (content: string): JunoPackage =>\n z\n .string()\n // eslint-disable-next-line local-rules/prefer-object-params\n .transform((str, ctx) => {\n try {\n return JSON.parse(str);\n } catch (_err: unknown) {\n ctx.addIssue({\n code: 'custom',\n message: 'Invalid JSON'\n });\n return z.never;\n }\n })\n .pipe(JunoPackageSchema)\n .parse(content);\n\n return createPackageFromJson(status);\n};\n\n/**\n * Retrieves only the `version` field from the `juno:package` metadata.\n *\n * @param {GetJunoPackageParams} params - The parameters to fetch the package version.\n *\n * @returns {Promise<string | undefined>} A promise that resolves to the version string or `undefined` if not found.\n *\n * @throws {ZodError} If the metadata exists but does not conform to the expected `JunoPackage` schema.\n */\nexport const getJunoPackageVersion = async (\n params: GetJunoPackageParams\n): Promise<JunoPackage['version'] | undefined> => {\n const pkg = await getJunoPackage(params);\n return pkg?.version;\n};\n\n/**\n * Retrieves the `dependencies` field from the `juno:package` metadata.\n *\n * @param {GetJunoPackageParams} params - The parameters to fetch the package metadata.\n *\n * @returns {Promise<JunoPackage['dependencies'] | undefined>} A promise that resolves to the dependencies object or `undefined` if not found.\n *\n * @throws {ZodError} If the metadata exists but does not conform to the expected `JunoPackage` schema.\n */\nexport const getJunoPackageDependencies = async (\n params: GetJunoPackageParams\n): Promise<JunoPackage['dependencies'] | undefined> => {\n const pkg = await getJunoPackage(params);\n return pkg?.dependencies;\n};\n", "import type {ActorParameters} from '@junobuild/ic-client/actor';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\n\n/**\n * Upgrades a module with the provided WASM code and arguments. This generic is notably useful for Juno Docker.\n *\n * @param {Object} params - Parameters for upgrading the module.\n * @param {ActorParameters} params.actor - The actor parameters associated with the module.\n * @param {Principal} params.canisterId - The ID of the canister being upgraded.\n * @param {Principal} [params.missionControlId] - Optional. An ID to store and reuse WASM chunks across installations.\n * @param {Uint8Array} params.wasmModule - The WASM code to be installed during the upgrade.\n * @param {Uint8Array} params.arg - The initialization argument for the module upgrade.\n * @param {canister_install_mode} params.mode - The installation mode, e.g., `upgrade` or `reinstall`.\n * @param {boolean} [params.preClearChunks] - Optional. Forces clearing existing chunks before uploading a chunked WASM module. Recommended for WASM modules larger than 2MB.\n * @param {function} [params.onProgress] - Optional. Callback function to track progress during the upgrade process.\n * @param {boolean} [params.reset=false] - Optional. Specifies whether to reset the module (reinstall) instead of performing an upgrade. Defaults to `false`.\n * @throws {Error} Will throw an error if the parameters are invalid or if the upgrade process fails.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\nexport const upgradeModule = async (\n params: {\n actor: ActorParameters;\n reset?: boolean;\n } & UpgradeCodeParams\n): Promise<void> => {\n await upgrade(params);\n};\n", "import type {Principal} from '@dfinity/principal';\nimport {\n type OrbiterDid,\n type OrbiterParameters,\n getDeprecatedOrbiterVersionActor,\n getOrbiterActor\n} from '@junobuild/ic-client/actor';\n\n/**\n * @deprecated - Replaced in Orbiter > v0.0.8 with public custom section juno:package\n */\nexport const version = async ({orbiter}: {orbiter: OrbiterParameters}): Promise<string> => {\n const {version} = await getDeprecatedOrbiterVersionActor(orbiter);\n return version();\n};\n\nexport const listControllers = async ({\n orbiter,\n certified\n}: {\n orbiter: OrbiterParameters;\n certified?: boolean;\n}): Promise<[Principal, OrbiterDid.Controller][]> => {\n const {list_controllers} = await getOrbiterActor({...orbiter, certified});\n return list_controllers();\n};\n\nexport const memorySize = async ({\n orbiter\n}: {\n orbiter: OrbiterParameters;\n}): Promise<OrbiterDid.MemorySize> => {\n const {memory_size} = await getOrbiterActor(orbiter);\n return memory_size();\n};\n", "import type {Principal} from '@dfinity/principal';\nimport type {MissionControlDid, OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {listControllers} from '../api/orbiter.api';\n\n/**\n * Lists the controllers of the Orbiter.\n * @param {Object} params - The parameters for listing the controllers.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const listOrbiterControllers = (params: {\n orbiter: OrbiterParameters;\n}): Promise<[Principal, MissionControlDid.Controller][]> => listControllers(params);\n", "import type {OrbiterDid, OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {memorySize} from '../api/orbiter.api';\n\n/**\n * Retrieves the stable and heap memory size of the Orbiter.\n * @param {Object} params - The parameters for the Orbiter.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters.\n * @returns {Promise<MemorySize>} A promise that resolves to the memory size of the Orbiter.\n */\nexport const orbiterMemorySize = (params: {\n orbiter: OrbiterParameters;\n}): Promise<OrbiterDid.MemorySize> => memorySize(params);\n", "import type {OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {toPrincipal} from '@junobuild/ic-client/utils';\nimport {listControllers} from '../api/orbiter.api';\nimport {INSTALL_MODE_RESET, INSTALL_MODE_UPGRADE} from '../constants/upgrade.constants';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\nimport {encodeAdminAccessKeysToIDL} from '../utils/idl.utils';\n\n/**\n * Upgrades the Orbiter with the provided WASM module.\n * @param {Object} params - The parameters for upgrading the Orbiter.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters, including the actor and orbiter ID.\n * @param {Principal} [params.missionControlId] - Optional. The Mission Control ID to potentially store WASM chunks, enabling reuse across installations.\n * @param {Uint8Array} params.wasmModule - The WASM module to be installed during the upgrade.\n * @param {boolean} [params.reset=false] - Optional. Indicates whether to reset the Orbiter (reinstall) instead of performing an upgrade. Defaults to `false`.\n * @param {boolean} [params.preClearChunks] - Optional. Forces clearing existing chunks before uploading a chunked WASM module. Recommended if the WASM exceeds 2MB.\n * @param {boolean} [params.takeSnapshot=true] - Optional. Whether to take a snapshot before performing the upgrade. Defaults to true.\n * @param {function} [params.onProgress] - Optional. Callback function to track progress during the upgrade process.\n * @throws {Error} Will throw an error if the Orbiter principal is not defined.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\n\nexport const upgradeOrbiter = async ({\n orbiter,\n reset = false,\n ...rest\n}: {\n orbiter: OrbiterParameters;\n reset?: boolean;\n} & Pick<\n UpgradeCodeParams,\n 'wasmModule' | 'missionControlId' | 'preClearChunks' | 'takeSnapshot' | 'onProgress'\n>): Promise<void> => {\n const {orbiterId, ...actor} = orbiter;\n\n if (!orbiterId) {\n throw new Error('No orbiter principal defined.');\n }\n\n const controllers = await listControllers({orbiter, certified: reset});\n\n // Only really use in case of --reset\n const arg = encodeAdminAccessKeysToIDL(controllers);\n\n await upgrade({\n actor,\n canisterId: toPrincipal(orbiterId),\n arg,\n mode: reset ? INSTALL_MODE_RESET : INSTALL_MODE_UPGRADE,\n reset,\n ...rest\n });\n};\n", "import {assertNonNullish, isNullish} from '@dfinity/utils';\nimport {JUNO_PACKAGE_ORBITER_ID} from '@junobuild/config';\nimport type {OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {version} from '../api/orbiter.api';\nimport {OrbiterVersionError} from '../errors/version.errors';\nimport {getJunoPackage} from './package.services';\n\n/**\n * Retrieves the version of the Orbiter.\n * @param {Object} params - The parameters for the Orbiter.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters.\n * @returns {Promise<string>} A promise that resolves to the version of the Orbiter.\n */\nexport const orbiterVersion = async ({\n orbiter: {orbiterId, ...rest}\n}: {\n orbiter: OrbiterParameters;\n}): Promise<string> => {\n assertNonNullish(orbiterId, 'An Orbiter ID must be provided to request its version.');\n\n const pkg = await getJunoPackage({\n moduleId: orbiterId,\n ...rest\n });\n\n // For backwards compatibility with legacy. Function version() was deprecated in Mission Control > v0.0.8\n if (isNullish(pkg)) {\n return await version({orbiter: {orbiterId, ...rest}});\n }\n\n const {name, version: missionControlVersion} = pkg;\n\n if (name === JUNO_PACKAGE_ORBITER_ID) {\n return missionControlVersion;\n }\n\n throw new OrbiterVersionError();\n};\n", "import type {Principal} from '@dfinity/principal';\nimport {toNullable} from '@dfinity/utils';\nimport {\n type SatelliteDid,\n type SatelliteParameters,\n getDeprecatedSatelliteActor,\n getDeprecatedSatelliteNoScopeActor,\n getDeprecatedSatelliteVersionActor,\n getSatelliteActor\n} from '@junobuild/ic-client/actor';\n\nexport const setStorageConfig = async ({\n config,\n satellite\n}: {\n config: SatelliteDid.SetStorageConfig;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.StorageConfig> => {\n const {set_storage_config} = await getSatelliteActor(satellite);\n return set_storage_config(config);\n};\n\nexport const setDatastoreConfig = async ({\n config,\n satellite\n}: {\n config: SatelliteDid.SetDbConfig;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.DbConfig> => {\n const {set_db_config} = await getSatelliteActor(satellite);\n return set_db_config(config);\n};\n\nexport const setAuthConfig = async ({\n config,\n satellite\n}: {\n config: SatelliteDid.SetAuthenticationConfig;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.AuthenticationConfig> => {\n const {set_auth_config} = await getSatelliteActor(satellite);\n return set_auth_config(config);\n};\n\nexport const getStorageConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.StorageConfig> => {\n const {get_storage_config} = await getSatelliteActor(satellite);\n return get_storage_config();\n};\n\nexport const getDatastoreConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[] | [SatelliteDid.DbConfig]> => {\n const {get_db_config} = await getSatelliteActor(satellite);\n return get_db_config();\n};\n\nexport const getAuthConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[] | [SatelliteDid.AuthenticationConfig]> => {\n const {get_auth_config} = await getSatelliteActor(satellite);\n return get_auth_config();\n};\n\nexport const getConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.Config> => {\n const {get_config} = await getSatelliteActor(satellite);\n return get_config();\n};\n\nexport const listRules = async ({\n satellite,\n type,\n filter\n}: {\n satellite: SatelliteParameters;\n type: SatelliteDid.CollectionType;\n filter: SatelliteDid.ListRulesParams;\n}): Promise<SatelliteDid.ListRulesResults> => {\n const {list_rules} = await getSatelliteActor(satellite);\n return list_rules(type, filter);\n};\n\nexport const setRule = async ({\n type,\n collection,\n rule,\n satellite\n}: {\n type: SatelliteDid.CollectionType;\n collection: string;\n rule: SatelliteDid.SetRule;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.Rule> => {\n const {set_rule} = await getSatelliteActor(satellite);\n return set_rule(type, collection, rule);\n};\n\n/**\n * @deprecated - Replaced in Satellite > v0.0.22 with public custom section juno:package\n */\nexport const version = async ({satellite}: {satellite: SatelliteParameters}): Promise<string> => {\n const {version} = await getDeprecatedSatelliteVersionActor(satellite);\n return version();\n};\n\n/**\n * @deprecated TODO: for backwards compatibility - to be removed\n */\nexport const listDeprecatedControllers = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<Principal[]> => {\n const {list_controllers} = await getDeprecatedSatelliteActor(satellite);\n return list_controllers();\n};\n\n/**\n * @deprecated TODO: for backwards compatibility - to be removed\n */\nexport const listDeprecatedNoScopeControllers = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const {list_controllers} = await getDeprecatedSatelliteNoScopeActor(satellite);\n return list_controllers() as Promise<[Principal, SatelliteDid.Controller][]>;\n};\n\nexport const listControllers = async ({\n satellite,\n certified\n}: {\n satellite: SatelliteParameters;\n certified?: boolean;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const {list_controllers} = await getSatelliteActor({...satellite, certified});\n return list_controllers();\n};\n\nexport const listCustomDomains = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[string, SatelliteDid.CustomDomain][]> => {\n const {list_custom_domains} = await getSatelliteActor(satellite);\n return list_custom_domains();\n};\n\nexport const setCustomDomain = async ({\n satellite,\n domainName,\n boundaryNodesId\n}: {\n satellite: SatelliteParameters;\n domainName: string;\n boundaryNodesId: string | undefined;\n}): Promise<void> => {\n const {set_custom_domain} = await getSatelliteActor(satellite);\n await set_custom_domain(domainName, toNullable(boundaryNodesId));\n};\n\nexport const memorySize = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.MemorySize> => {\n const {memory_size} = await getSatelliteActor(satellite);\n return memory_size();\n};\n\nexport const countDocs = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => {\n const {count_collection_docs} = await getSatelliteActor(satellite);\n return count_collection_docs(collection);\n};\n\nexport const countAssets = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => {\n const {count_collection_assets} = await getSatelliteActor(satellite);\n return count_collection_assets(collection);\n};\n\nexport const deleteDocs = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => {\n const {del_docs} = await getSatelliteActor(satellite);\n return del_docs(collection);\n};\n\nexport const deleteAssets = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => {\n const {del_assets} = await getSatelliteActor(satellite);\n return del_assets(collection);\n};\n\nexport const setControllers = async ({\n args,\n satellite\n}: {\n args: SatelliteDid.SetControllersArgs;\n satellite: SatelliteParameters;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const {set_controllers} = await getSatelliteActor(satellite);\n return set_controllers(args);\n};\n", "import type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {countAssets as countAssetsApi, deleteAssets as deleteAssetsApi} from '../api/satellite.api';\n\n/**\n * Counts the assets in a collection.\n * @param {Object} params - The parameters for counting the assets.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<bigint>} A promise that resolves to the number of assets in the collection.\n */\nexport const countAssets = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => countAssetsApi(params);\n\n/**\n * Deletes the assets in a collection.\n * @param {Object} params - The parameters for deleting the assets.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the assets are deleted.\n */\nexport const deleteAssets = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => deleteAssetsApi(params);\n", "import {fromNullable, isNullish, nonNullish} from '@dfinity/utils';\nimport type {AuthenticationConfig, DatastoreConfig, StorageConfig} from '@junobuild/config';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {\n getAuthConfig as getAuthConfigApi,\n getConfig as getConfigApi,\n getDatastoreConfig as getDatastoreConfigApi,\n getStorageConfig as getStorageConfigApi,\n setAuthConfig as setAuthConfigApi,\n setDatastoreConfig as setDatastoreConfigApi,\n setStorageConfig as setStorageConfigApi\n} from '../api/satellite.api';\nimport {\n fromAuthenticationConfig,\n fromDatastoreConfig,\n fromStorageConfig,\n toAuthenticationConfig,\n toDatastoreConfig,\n toStorageConfig\n} from '../utils/config.utils';\n\n/**\n * Sets the configuration for the Storage of a Satellite.\n * @param {Object} params - The parameters for setting the configuration.\n * @param {Object} params.config - The storage configuration.\n * @param {Array<StorageConfigHeader>} params.config.headers - The headers configuration.\n * @param {Array<StorageConfigRewrite>} params.config.rewrites - The rewrites configuration.\n * @param {Array<StorageConfigRedirect>} params.config.redirects - The redirects configuration.\n * @param {string} params.config.iframe - The iframe configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves with the applied configuration when set.\n */\nexport const setStorageConfig = async ({\n config,\n satellite\n}: {\n config: Omit<StorageConfig, 'createdAt' | 'updatedAt'>;\n satellite: SatelliteParameters;\n}): Promise<StorageConfig> => {\n const result = await setStorageConfigApi({\n satellite,\n config: fromStorageConfig(config)\n });\n\n return toStorageConfig(result);\n};\n\n/**\n * Sets the datastore configuration for a satellite.\n * @param {Object} params - The parameters for setting the authentication configuration.\n * @param {Object} params.config - The datastore configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves with the config when the datastore configuration is set.\n */\nexport const setDatastoreConfig = async ({\n config,\n ...rest\n}: {\n config: Omit<DatastoreConfig, 'createdAt' | 'updatedAt'>;\n satellite: SatelliteParameters;\n}): Promise<DatastoreConfig> => {\n const result = await setDatastoreConfigApi({\n config: fromDatastoreConfig(config),\n ...rest\n });\n\n return toDatastoreConfig(result);\n};\n\n/**\n * Sets the authentication configuration for a satellite.\n * @param {Object} params - The parameters for setting the authentication configuration.\n * @param {Object} params.config - The authentication configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the authentication configuration is set.\n */\nexport const setAuthConfig = async ({\n config,\n ...rest\n}: {\n config: Omit<AuthenticationConfig, 'createdAt' | 'updatedAt'>;\n satellite: SatelliteParameters;\n}): Promise<AuthenticationConfig> => {\n const result = await setAuthConfigApi({\n config: fromAuthenticationConfig(config),\n ...rest\n });\n\n return toAuthenticationConfig(result);\n};\n\n/**\n * Gets the authentication configuration for a satellite.\n * @param {Object} params - The parameters for getting the authentication configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<AuthenticationConfig | undefined>} A promise that resolves to the authentication configuration or undefined if not found.\n */\nexport const getAuthConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<AuthenticationConfig | undefined> => {\n const result = await getAuthConfigApi({\n satellite\n });\n\n const config = fromNullable(result);\n\n if (isNullish(config)) {\n return undefined;\n }\n\n return toAuthenticationConfig(config);\n};\n\n/**\n * Gets the storage configuration for a satellite.\n * @param {Object} params - The parameters for getting the storage configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<StorageConfig | undefined>} A promise that resolves to the storage configuration or undefined if not found.\n */\nexport const getStorageConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<StorageConfig> => {\n const config = await getStorageConfigApi({\n satellite\n });\n\n return toStorageConfig(config);\n};\n\n/**\n * Gets the datastore configuration for a satellite.\n * @param {Object} params - The parameters for getting the datastore configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<AuthenticationConfig | undefined>} A promise that resolves to the datastore configuration or undefined if not found.\n */\nexport const getDatastoreConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<DatastoreConfig | undefined> => {\n const result = await getDatastoreConfigApi({\n satellite\n });\n\n const config = fromNullable(result);\n\n if (isNullish(config)) {\n return undefined;\n }\n\n return toDatastoreConfig(config);\n};\n\n/**\n * Gets all the configuration for a satellite.\n * @param {Object} params - The parameters for getting the configurations.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<{storage: StorageConfig; datastore?: DatastoreConfig; auth?: AuthenticationConfig;}>} A promise that resolves to the configuration.\n */\nexport const getConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<{\n storage: StorageConfig;\n datastore?: DatastoreConfig;\n auth?: AuthenticationConfig;\n}> => {\n const {storage, db, authentication} = await getConfigApi({\n satellite\n });\n\n const datastore = fromNullable(db);\n const auth = fromNullable(authentication);\n\n return {\n storage: toStorageConfig(storage),\n ...(nonNullish(datastore) && {datastore: toDatastoreConfig(datastore)}),\n ...(nonNullish(auth) && {auth: toAuthenticationConfig(auth)})\n };\n};\n", "import {Principal} from '@dfinity/principal';\nimport {fromNullable, isNullish, nonNullish, toNullable} from '@dfinity/utils';\nimport type {\n AuthenticationConfig,\n DatastoreConfig,\n StorageConfig,\n StorageConfigHeader,\n StorageConfigRedirect,\n StorageConfigRewrite\n} from '@junobuild/config';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\nimport {fromMaxMemorySize, toMaxMemorySize} from './memory.utils';\n\nexport const fromStorageConfig = ({\n headers: configHeaders,\n rewrites: configRewrites,\n redirects: configRedirects,\n iframe: configIFrame,\n rawAccess: configRawAccess,\n maxMemorySize: configMaxMemorySize,\n version: configVersion\n}: StorageConfig): SatelliteDid.SetStorageConfig => {\n const headers: [string, [string, string][]][] = (configHeaders ?? []).map(\n ({source, headers}: StorageConfigHeader) => [source, headers]\n );\n\n const rewrites: [string, string][] = (configRewrites ?? []).map(\n ({source, destination}: StorageConfigRewrite) => [source, destination]\n );\n\n const redirects: [string, SatelliteDid.StorageConfigRedirect][] = (configRedirects ?? []).map(\n ({source, location, code}: StorageConfigRedirect) => [source, {status_code: code, location}]\n );\n\n const iframe: SatelliteDid.StorageConfigIFrame =\n configIFrame === 'same-origin'\n ? {SameOrigin: null}\n : configIFrame === 'allow-any'\n ? {AllowAny: null}\n : {Deny: null};\n\n const rawAccess: SatelliteDid.StorageConfigRawAccess =\n configRawAccess === true ? {Allow: null} : {Deny: null};\n\n return {\n headers,\n rewrites,\n redirects: [redirects],\n iframe: [iframe],\n raw_access: [rawAccess],\n max_memory_size: toMaxMemorySize(configMaxMemorySize),\n version: toNullable(configVersion)\n };\n};\n\nexport const toStorageConfig = ({\n redirects: redirectsDid,\n iframe: iframeDid,\n version,\n raw_access: rawAccessDid,\n max_memory_size,\n headers: headersDid,\n rewrites: rewritesDid\n}: SatelliteDid.StorageConfig): StorageConfig => {\n const redirects = fromNullable(redirectsDid)?.map<StorageConfigRedirect>(\n ([source, {status_code: code, ...rest}]) => ({\n ...rest,\n code: code as 301 | 302,\n source\n })\n );\n\n const access = fromNullable(rawAccessDid);\n const rawAccess = nonNullish(access) ? 'Allow' in access : undefined;\n\n const frame = fromNullable(iframeDid);\n const iframe = nonNullish(frame)\n ? 'SameOrigin' in frame\n ? 'same-origin'\n : 'AllowAny' in frame\n ? 'allow-any'\n : 'deny'\n : undefined;\n\n const maxMemorySize = fromMaxMemorySize(max_memory_size);\n\n const headers = headersDid.map<StorageConfigHeader>(([source, headers]) => ({source, headers}));\n\n const rewrites = rewritesDid.map<StorageConfigRewrite>(([source, destination]) => ({\n source,\n destination\n }));\n\n return {\n ...(headers.length > 0 && {headers}),\n ...(rewrites.length > 0 && {rewrites}),\n ...(nonNullish(redirects) && {redirects}),\n ...(nonNullish(iframe) && {\n iframe\n }),\n version: fromNullable(version),\n ...(nonNullish(rawAccess) && {rawAccess}),\n ...maxMemorySize\n };\n};\n\nexport const fromDatastoreConfig = ({\n maxMemorySize,\n version\n}: DatastoreConfig): SatelliteDid.SetDbConfig => ({\n max_memory_size: toMaxMemorySize(maxMemorySize),\n version: toNullable(version)\n});\n\nexport const toDatastoreConfig = ({\n version,\n max_memory_size\n}: SatelliteDid.DbConfig): DatastoreConfig => ({\n ...fromMaxMemorySize(max_memory_size),\n version: fromNullable(version)\n});\n\nexport const fromAuthenticationConfig = ({\n internetIdentity,\n rules,\n version\n}: AuthenticationConfig): SatelliteDid.SetAuthenticationConfig => ({\n internet_identity: isNullish(internetIdentity)\n ? []\n : [\n {\n derivation_origin: toNullable(internetIdentity?.derivationOrigin),\n external_alternative_origins: toNullable(internetIdentity?.externalAlternativeOrigins)\n }\n ],\n rules: isNullish(rules)\n ? []\n : [\n {\n allowed_callers: rules.allowedCallers.map((caller) => Principal.fromText(caller))\n }\n ],\n version: toNullable(version)\n});\n\nexport const toAuthenticationConfig = ({\n version,\n internet_identity,\n rules: rulesDid\n}: SatelliteDid.AuthenticationConfig): AuthenticationConfig => {\n const internetIdentity = fromNullable(internet_identity);\n const derivationOrigin = fromNullable(internetIdentity?.derivation_origin ?? []);\n const externalAlternativeOrigins = fromNullable(\n internetIdentity?.external_alternative_origins ?? []\n );\n\n const rules = fromNullable(rulesDid);\n\n return {\n ...(nonNullish(internetIdentity) && {\n internetIdentity: {\n ...(nonNullish(derivationOrigin) && {derivationOrigin}),\n ...(nonNullish(externalAlternativeOrigins) && {externalAlternativeOrigins})\n }\n }),\n ...(nonNullish(rules) && {\n rules: {\n allowedCallers: rules.allowed_callers.map((caller) => caller.toText())\n }\n }),\n version: fromNullable(version)\n };\n};\n", "import {fromNullable, nonNullish, toNullable} from '@dfinity/utils';\nimport type {MaxMemorySizeConfig} from '@junobuild/config';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\n\nexport const toMaxMemorySize = (\n configMaxMemorySize?: MaxMemorySizeConfig\n): [] | [SatelliteDid.ConfigMaxMemorySize] =>\n toNullable(\n nonNullish(configMaxMemorySize) &&\n (nonNullish(toNullable(configMaxMemorySize.heap)) ||\n nonNullish(toNullable(configMaxMemorySize.stable)))\n ? {\n heap: toNullable(configMaxMemorySize.heap),\n stable: toNullable(configMaxMemorySize.stable)\n }\n : undefined\n );\n\nexport const fromMaxMemorySize = (\n configMaxMemorySize: [] | [SatelliteDid.ConfigMaxMemorySize]\n): {maxMemorySize?: MaxMemorySizeConfig} => {\n const memorySize = fromNullable(configMaxMemorySize);\n const heap = fromNullable(memorySize?.heap ?? []);\n const stable = fromNullable(memorySize?.stable ?? []);\n\n return {\n ...(nonNullish(memorySize) &&\n (nonNullish(heap) || nonNullish(stable)) && {\n maxMemorySize: {\n ...(nonNullish(heap) && {heap}),\n ...(nonNullish(stable) && {stable})\n }\n })\n };\n};\n", "import type {Principal} from '@dfinity/principal';\nimport type {SatelliteDid, SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {\n listControllers,\n listDeprecatedNoScopeControllers,\n setControllers\n} from '../api/satellite.api';\n/**\n * Lists the controllers of a satellite.\n * @param {Object} params - The parameters for listing the controllers.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {boolean} [params.deprecatedNoScope] - Whether to list deprecated no-scope controllers.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const listSatelliteControllers = ({\n deprecatedNoScope,\n ...params\n}: {\n satellite: SatelliteParameters;\n deprecatedNoScope?: boolean;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const list = deprecatedNoScope === true ? listDeprecatedNoScopeControllers : listControllers;\n return list(params);\n};\n\n/**\n * Sets the controllers of a satellite.\n * @param {Object} params - The parameters for setting the controllers.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {SetControllersArgs} params.args - The arguments for setting the controllers.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const setSatelliteControllers = (params: {\n satellite: SatelliteParameters;\n args: SatelliteDid.SetControllersArgs;\n}): Promise<[Principal, SatelliteDid.Controller][]> => setControllers(params);\n", "import type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {countDocs as countDocsApi, deleteDocs as deleteDocsApi} from '../api/satellite.api';\n\n/**\n * Counts the documents in a collection.\n * @param {Object} params - The parameters for counting the documents.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<bigint>} A promise that resolves to the number of documents in the collection.\n */\nexport const countDocs = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => countDocsApi(params);\n\n/**\n * Deletes the documents in a collection.\n * @param {Object} params - The parameters for deleting the documents.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the documents are deleted.\n */\nexport const deleteDocs = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => deleteDocsApi(params);\n", "import {fromNullable, nonNullish} from '@dfinity/utils';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {\n listCustomDomains as listCustomDomainsApi,\n setCustomDomain as setCustomDomainApi\n} from '../api/satellite.api';\nimport type {CustomDomain} from '../types/customdomain';\n\n/**\n * Lists the custom domains for a satellite.\n * @param {Object} params - The parameters for listing the custom domains.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<CustomDomain[]>} A promise that resolves to an array of custom domains.\n */\nexport const listCustomDomains = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<CustomDomain[]> => {\n const domains = await listCustomDomainsApi({\n satellite\n });\n\n return domains.map(([domain, details]) => {\n const domainVersion = fromNullable(details.version);\n\n return {\n domain,\n bn_id: fromNullable(details.bn_id),\n created_at: details.created_at,\n updated_at: details.updated_at,\n ...(nonNullish(domainVersion) && {version: domainVersion})\n };\n });\n};\n\n/**\n * Sets some custom domains for a satellite.\n * @param {Object} params - The parameters for setting the custom domains.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {Pick<CustomDomain, \"domain\" | \"bn_id\">}[] params.domains - The custom domains - name and optional BN ID - to set.\n * @returns {Promise<void[]>} A promise that resolves when the custom domains are set.\n */\nexport const setCustomDomains = ({\n satellite,\n domains\n}: {\n satellite: SatelliteParameters;\n domains: Pick<CustomDomain, 'domain' | 'bn_id'>[];\n}): Promise<void[]> =>\n Promise.all(\n domains.map(({domain: domainName, bn_id: boundaryNodesId}) =>\n setCustomDomainApi({\n satellite,\n domainName,\n boundaryNodesId\n })\n )\n );\n\n/**\n * Sets a custom domain for a satellite.\n * @param {Object} params - The parameters for setting the custom domain.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {Pick<CustomDomain, \"domain\" | \"bn_id\">} params.domain - The custom domain name and optional BN ID to set.\n * @returns {Promise<void>} A promise that resolves when the custom domain is set.\n */\nexport const setCustomDomain = ({\n satellite,\n domain\n}: {\n satellite: SatelliteParameters;\n domain: Pick<CustomDomain, 'domain' | 'bn_id'>;\n}): Promise<void> =>\n setCustomDomainApi({\n satellite,\n domainName: domain.domain,\n boundaryNodesId: domain.bn_id\n });\n", "import type {SatelliteDid, SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {memorySize} from '../api/satellite.api';\n\n/**\n * Retrieves the stable and heap memory size of a satellite.\n * @param {Object} params - The parameters for retrieving the memory size.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<MemorySize>} A promise that resolves to the memory size of the satellite.\n */\nexport const satelliteMemorySize = (params: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.MemorySize> => memorySize(params);\n", "import {fromNullable, isNullish, nonNullish, toNullable} from '@dfinity/utils';\nimport type {MemoryText, PermissionText, Rule, RulesType} from '@junobuild/config';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\nimport {\n DbRulesType,\n DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS,\n MemoryHeap,\n MemoryStable,\n PermissionControllers,\n PermissionManaged,\n PermissionPrivate,\n PermissionPublic,\n StorageRulesType\n} from '../constants/rules.constants';\nimport type {ListRulesMatcher} from '../types/list';\n\nexport const fromRuleType = (type: RulesType): SatelliteDid.CollectionType =>\n type === 'storage' ? StorageRulesType : DbRulesType;\n\nexport const fromRulesFilter = (filter?: ListRulesMatcher): SatelliteDid.ListRulesParams => ({\n matcher: isNullish(filter)\n ? toNullable()\n : toNullable({\n include_system: filter.include_system\n })\n});\n\nexport const fromRule = ({\n read,\n write,\n memory,\n maxSize,\n maxChangesPerUser,\n maxCapacity,\n version,\n mutablePermissions,\n maxTokens\n}: Pick<\n Rule,\n | 'read'\n | 'write'\n | 'maxSize'\n | 'maxChangesPerUser'\n | 'maxCapacity'\n | 'version'\n | 'memory'\n | 'mutablePermissions'\n | 'maxTokens'\n>): SatelliteDid.SetRule => ({\n read: permissionFromText(read),\n write: permissionFromText(write),\n memory: nonNullish(memory) ? [memoryFromText(memory)] : [],\n version: toNullable(version),\n max_size: toNullable(nonNullish(maxSize) && maxSize > 0n ? maxSize : undefined),\n max_capacity: toNullable(nonNullish(maxCapacity) && maxCapacity > 0 ? maxCapacity : undefined),\n max_changes_per_user: toNullable(\n nonNullish(maxChangesPerUser) && maxChangesPerUser > 0 ? maxChangesPerUser : undefined\n ),\n mutable_permissions: toNullable(mutablePermissions ?? true),\n rate_config:\n nonNullish(maxTokens) && maxTokens > 0n\n ? [\n {\n max_tokens: maxTokens,\n time_per_token_ns: DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS\n }\n ]\n : []\n});\n\nexport const toRule = ([collection, rule]: [string, SatelliteDid.Rule]): Rule => {\n const {\n read,\n write,\n updated_at,\n created_at,\n max_size,\n max_changes_per_user,\n max_capacity,\n memory,\n mutable_permissions,\n version,\n rate_config\n } = rule;\n\n const maxSize = (max_size?.[0] ?? 0n > 0n) ? fromNullable(max_size) : undefined;\n const maxChangesPerUser =\n (max_changes_per_user?.[0] ?? 0 > 0) ? fromNullable(max_changes_per_user) : undefined;\n const maxCapacity = (max_capacity?.[0] ?? 0 > 0) ? fromNullable(max_capacity) : undefined;\n\n const ruleVersion = fromNullable(version);\n\n const maxTokens =\n (rate_config?.[0]?.max_tokens ?? 0n > 0n) ? fromNullable(rate_config)?.max_tokens : undefined;\n\n return {\n collection,\n read: permissionToText(read),\n write: permissionToText(write),\n memory: memoryToText(fromNullable(memory) ?? MemoryHeap),\n updatedAt: updated_at,\n createdAt: created_at,\n ...(nonNullish(ruleVersion) && {version: ruleVersion}),\n ...(nonNullish(maxChangesPerUser) && {maxChangesPerUser}),\n ...(nonNullish(maxSize) && {maxSize}),\n ...(nonNullish(maxCapacity) && {maxCapacity}),\n mutablePermissions: fromNullable(mutable_permissions) ?? true,\n ...(nonNullish(maxTokens) && {maxTokens})\n };\n};\n\nexport const permissionToText = (permission: SatelliteDid.Permission): PermissionText => {\n if ('Public' in permission) {\n return 'public';\n }\n\n if ('Private' in permission) {\n return 'private';\n }\n\n if ('Managed' in permission) {\n return 'managed';\n }\n\n return 'controllers';\n};\n\nconst permissionFromText = (text: PermissionText): SatelliteDid.Permission => {\n switch (text) {\n case 'public':\n return PermissionPublic;\n case 'private':\n return PermissionPrivate;\n case 'managed':\n return PermissionManaged;\n default:\n return PermissionControllers;\n }\n};\n\nexport const memoryFromText = (text: MemoryText): SatelliteDid.Memory => {\n switch (text.toLowerCase()) {\n case 'heap':\n return MemoryHeap;\n default:\n return MemoryStable;\n }\n};\n\nexport const memoryToText = (memory: SatelliteDid.Memory): MemoryText => {\n if ('Heap' in memory) {\n return 'heap';\n }\n\n return 'stable';\n};\n", "import type {SatelliteDid} from '@junobuild/ic-client/actor';\n\nexport const DbRulesType: SatelliteDid.CollectionType = {Db: null};\nexport const StorageRulesType: SatelliteDid.CollectionType = {Storage: null};\n\nexport const PermissionPublic: SatelliteDid.Permission = {Public: null};\nexport const PermissionPrivate: SatelliteDid.Permission = {Private: null};\nexport const PermissionManaged: SatelliteDid.Permission = {Managed: null};\nexport const PermissionControllers: SatelliteDid.Permission = {Controllers: null};\n\nexport const MemoryHeap: SatelliteDid.Memory = {Heap: null};\nexport const MemoryStable: SatelliteDid.Memory = {Stable: null};\n\nexport const DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS = 600_000_000n;\n", "import type {Rule, RulesType} from '@junobuild/config';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {listRules as listRulesApi, setRule as setRuleApi} from '../api/satellite.api';\nimport type {ListRulesMatcher, ListRulesResults} from '../types/list';\nimport {fromRule, fromRulesFilter, fromRuleType, toRule} from '../utils/rule.utils';\n\n/**\n * Lists the rules for a satellite.\n * @param {Object} params - The parameters for listing the rules.\n * @param {RulesType} params.type - The type of rules to list.\n * @param {ListRulesMatcher} params.filter - The optional filter for the query.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<ListRulesResults>} A promise that resolves to the resolved rules.\n */\nexport const listRules = async ({\n type,\n satellite,\n filter\n}: {\n type: RulesType;\n filter?: ListRulesMatcher;\n satellite: SatelliteParameters;\n}): Promise<ListRulesResults> => {\n const {items, ...rest} = await listRulesApi({\n satellite,\n type: fromRuleType(type),\n filter: fromRulesFilter(filter)\n });\n\n return {\n ...rest,\n items: items.map((rule) => toRule(rule))\n };\n};\n\n/**\n * Sets a rule for a satellite.\n * @param {Object} params - The parameters for setting the rule.\n * @param {Rule} params.rule - The rule to set.\n * @param {RulesType} params.type - The type of rule.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the rule is set.\n */\nexport const setRule = async ({\n rule: {collection, ...rest},\n type,\n satellite\n}: {\n rule: Rule;\n type: RulesType;\n satellite: SatelliteParameters;\n}): Promise<Rule> => {\n const result = await setRuleApi({\n type: fromRuleType(type),\n rule: fromRule(rest),\n satellite,\n collection\n });\n\n return toRule([collection, result]);\n};\n", "import {IDL} from '@dfinity/candid';\nimport {isNullish} from '@dfinity/utils';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {toPrincipal} from '@junobuild/ic-client/utils';\nimport {\n listControllers,\n listDeprecatedControllers,\n listDeprecatedNoScopeControllers\n} from '../api/satellite.api';\nimport {INSTALL_MODE_RESET, INSTALL_MODE_UPGRADE} from '../constants/upgrade.constants';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\nimport {encodeAdminAccessKeysToIDL} from '../utils/idl.utils';\n\n/**\n * Upgrades a satellite with the provided WASM module.\n * @param {Object} params - The parameters for upgrading the satellite.\n * @param {SatelliteParameters} params.satellite - The satellite parameters, including the actor and satellite ID.\n * @param {Principal} [params.missionControlId] - Optional. The Mission Control ID to potentially store WASM chunks, enabling reuse across installations.\n * @param {Uint8Array} params.wasmModule - The WASM module to be installed during the upgrade.\n * @param {boolean} params.deprecated - Indicates whether the upgrade is deprecated.\n * @param {boolean} params.deprecatedNoScope - Indicates whether the upgrade is deprecated and has no scope.\n * @param {boolean} [params.reset=false] - Optional. Specifies whether to reset the satellite (reinstall) instead of performing an upgrade. Defaults to `false`.\n * @param {boolean} [params.preClearChunks] - Optional. Forces clearing existing chunks before uploading a chunked WASM module. Recommended if the WASM exceeds 2MB.\n * @param {boolean} [params.takeSnapshot=true] - Optional. Whether to take a snapshot before performing the upgrade. Defaults to true.\n * @param {function} [params.onProgress] - Optional. Callback function to track progress during the upgrade process.\n * @throws {Error} Will throw an error if the satellite parameters are invalid or missing required fields.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\nexport const upgradeSatellite = async ({\n satellite,\n deprecated,\n deprecatedNoScope,\n reset = false,\n ...rest\n}: {\n satellite: SatelliteParameters;\n deprecated: boolean;\n deprecatedNoScope: boolean;\n reset?: boolean;\n} & Pick<\n UpgradeCodeParams,\n 'wasmModule' | 'missionControlId' | 'preClearChunks' | 'takeSnapshot' | 'onProgress'\n>): Promise<void> => {\n const {satelliteId, ...actor} = satellite;\n\n if (isNullish(satelliteId)) {\n throw new Error('No satellite principal defined.');\n }\n\n // TODO: remove agent-js \"type mismatch: type on the wire principal\"\n if (deprecated) {\n const controllers = await listDeprecatedControllers({satellite});\n\n const arg = IDL.encode(\n [\n IDL.Record({\n controllers: IDL.Vec(IDL.Principal)\n })\n ],\n [{controllers}]\n );\n\n await upgrade({\n actor,\n canisterId: toPrincipal(satelliteId),\n arg: new Uint8Array(arg),\n mode: reset ? INSTALL_MODE_RESET : INSTALL_MODE_UPGRADE,\n reset,\n ...rest\n });\n\n return;\n }\n\n const list = deprecatedNoScope ? listDeprecatedNoScopeControllers : listControllers;\n\n // We pass the controllers to the upgrade but, it's just for the state of the art when upgrading because I don't want to call the install without passing args. The module's post_upgrade do not consider the init parameters.\n // On the contrary those are useful on --reset\n const controllers = await list({satellite, certified: reset});\n\n const arg = encodeAdminAccessKeysToIDL(controllers);\n\n await upgrade({\n actor,\n canisterId: toPrincipal(satelliteId),\n arg,\n mode: reset ? INSTALL_MODE_RESET : INSTALL_MODE_UPGRADE,\n reset,\n ...rest\n });\n};\n", "import {assertNonNullish, isNullish, nonNullish} from '@dfinity/utils';\nimport {JUNO_PACKAGE_SATELLITE_ID} from '@junobuild/config';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {canisterMetadata} from '../api/ic.api';\nimport {version} from '../api/satellite.api';\nimport {SatelliteMissingDependencyError} from '../errors/version.errors';\nimport {findJunoPackageDependency} from '../helpers/package.helpers';\nimport type {BuildType} from '../schemas/build';\nimport {getJunoPackage} from './package.services';\n\n/**\n * Retrieves the version of the satellite.\n * @param {Object} params - The parameters for retrieving the version.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<string>} A promise that resolves to the version of the satellite.\n */\nexport const satelliteVersion = async ({\n satellite: {satelliteId, ...rest}\n}: {\n satellite: SatelliteParameters;\n}): Promise<string> => {\n assertNonNullish(satelliteId, 'A Satellite ID must be provided to request its version.');\n\n const pkg = await getJunoPackage({\n moduleId: satelliteId,\n ...rest\n });\n\n // For backwards compatibility with legacy. Function version() was deprecated in Satellite > v0.0.22\n if (isNullish(pkg)) {\n return await version({satellite: {satelliteId, ...rest}});\n }\n\n const {name, version: satelliteVersion, dependencies} = pkg;\n\n if (name === JUNO_PACKAGE_SATELLITE_ID) {\n return satelliteVersion;\n }\n\n const satelliteDependency = findJunoPackageDependency({\n dependencies,\n dependencyId: JUNO_PACKAGE_SATELLITE_ID\n });\n\n if (nonNullish(satelliteDependency)) {\n const [_, satelliteVersion] = satelliteDependency;\n return satelliteVersion;\n }\n\n throw new SatelliteMissingDependencyError();\n};\n\n/**\n * Retrieves the build type of the satellite.\n * @param {Object} params - The parameters for retrieving the build type.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<BuildType | undefined>} A promise that resolves to the build type of the satellite or undefined if not found.\n */\nexport const satelliteBuildType = async ({\n satellite: {satelliteId, ...rest}\n}: {\n satellite: SatelliteParameters;\n}): Promise<BuildType | undefined> => {\n assertNonNullish(satelliteId, 'A Satellite ID must be provided to request its version.');\n\n const pkg = await getJunoPackage({\n moduleId: satelliteId,\n ...rest\n });\n\n if (isNullish(pkg)) {\n return await satelliteDeprecatedBuildType({satellite: {satelliteId, ...rest}});\n }\n\n const {name, dependencies} = pkg;\n\n if (name === JUNO_PACKAGE_SATELLITE_ID) {\n return 'stock';\n }\n\n const satelliteDependency = findJunoPackageDependency({\n dependencies,\n dependencyId: JUNO_PACKAGE_SATELLITE_ID\n });\n\n if (nonNullish(satelliteDependency)) {\n return 'extended';\n }\n\n throw new SatelliteMissingDependencyError();\n};\n\n/**\n * @deprecated Replaced in Satellite > v0.0.22\n */\nconst satelliteDeprecatedBuildType = async ({\n satellite: {satelliteId, ...rest}\n}: {\n satellite: Omit<SatelliteParameters, 'satelliteId'> &\n Required<Pick<SatelliteParameters, 'satelliteId'>>;\n}): Promise<BuildType | undefined> => {\n const status = await canisterMetadata({...rest, canisterId: satelliteId, path: 'juno:build'});\n\n return nonNullish(status) && ['stock', 'extended'].includes(status as string)\n ? (status as BuildType)\n : undefined;\n};\n"],
5
- "mappings": "AAAO,IAAMA,EAAN,cAAwC,KAAM,CACnD,aAAc,CACZ,MACE,sGACF,CACF,CACF,ECNA,OACE,mCAAAC,GACA,2BAAAC,GACA,6BAAAC,OACK,oBAEA,IAAMC,EAAN,cAA8C,KAAM,CACzD,aAAc,CACZ,MAAM,4CAA4CD,EAAyB,cAAc,CAC3F,CACF,EAEaE,EAAN,cAAyC,KAAM,CACpD,aAAc,CACZ,MA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GAAUF,CAAG,EACf,OAAO,MAAMa,GAA6B,CAAC,UAAW,CAAC,YAAAhB,EAAa,GAAGC,CAAI,CAAC,CAAC,EAG/E,GAAM,CAAC,KAAAM,EAAM,aAAAC,CAAY,EAAIL,EAE7B,GAAII,IAASE,GACX,MAAO,QAGT,IAAMC,EAAsBC,EAA0B,CACpD,aAAAH,EACA,aAAcC,EAChB,CAAC,EAED,GAAIG,GAAWF,CAAmB,EAChC,MAAO,WAGT,MAAM,IAAII,CACZ,EAKME,GAA+B,MAAO,CAC1C,UAAW,CAAC,YAAAhB,EAAa,GAAGC,CAAI,CAClC,IAGsC,CACpC,IAAMgB,EAAS,MAAMC,EAAiB,CAAC,GAAGjB,EAAM,WAAYD,EAAa,KAAM,YAAY,CAAC,EAE5F,OAAOY,GAAWK,CAAM,GAAK,CAAC,QAAS,UAAU,EAAE,SAASA,CAAgB,EACvEA,EACD,MACN",
4
+ "sourcesContent": ["export class UpgradeCodeUnchangedError extends Error {\n constructor() {\n super(\n 'The Wasm code for the upgrade is identical to the code currently installed. No upgrade is necessary.'\n );\n }\n}\n", "import {\n JUNO_PACKAGE_MISSION_CONTROL_ID,\n JUNO_PACKAGE_ORBITER_ID,\n JUNO_PACKAGE_SATELLITE_ID\n} from '@junobuild/config';\n\nexport class SatelliteMissingDependencyError extends Error {\n constructor() {\n super(`Invalid dependency tree: required module ${JUNO_PACKAGE_SATELLITE_ID} is missing.`);\n }\n}\n\nexport class MissionControlVersionError extends Error {\n constructor() {\n super(`Invalid package: the provided module name is not ${JUNO_PACKAGE_MISSION_CONTROL_ID}.`);\n }\n}\n\nexport class OrbiterVersionError extends Error {\n constructor() {\n super(`Invalid package: the provided module name is not ${JUNO_PACKAGE_ORBITER_ID}.`);\n }\n}\n", "// Sources:\n// https://stackoverflow.com/a/70891826/5404186\n// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest\n\nconst digestSha256 = (data: ArrayBuffer | Uint8Array<ArrayBufferLike>): Promise<ArrayBuffer> =>\n crypto.subtle.digest('SHA-256', data);\n\nconst sha256ToHex = (hashBuffer: ArrayBuffer): string => {\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');\n};\n\nexport const blobSha256 = async (blob: Blob): Promise<string> => {\n const hashBuffer = await digestSha256(await blob.arrayBuffer());\n return sha256ToHex(hashBuffer);\n};\n\nexport const uint8ArraySha256 = async (data: Uint8Array): Promise<string> => {\n const hashBuffer = await digestSha256(data);\n return sha256ToHex(hashBuffer);\n};\n", "import type {JunoPackageDependencies} from '@junobuild/config';\n\n/**\n * Finds a specific dependency in a `JunoPackageDependencies` map.\n *\n * @param {Object} params - The parameters for the search.\n * @param {string} params.dependencyId - The ID of the dependency to look for.\n * @param {JunoPackageDependencies | undefined} params.dependencies - The full list of dependencies, or `undefined`.\n *\n * @returns {[string, string] | undefined} A tuple containing the dependency ID and version if found, or `undefined` if not found or no dependencies are present.\n */\nexport const findJunoPackageDependency = ({\n dependencyId,\n dependencies\n}: {\n dependencyId: string;\n dependencies: JunoPackageDependencies | undefined;\n}): [string, string] | undefined =>\n Object.entries(dependencies ?? {}).find(([key, _]) => key === dependencyId);\n", "import {major, minor, patch} from 'semver';\n\n/**\n * Checks if the selected version can be upgraded from the current version.\n * @param {Object} params - The parameters for the version check.\n * @param {string} params.currentVersion - The current version.\n * @param {string} params.selectedVersion - The selected version.\n * @returns {Object} An object indicating whether the upgrade can proceed.\n * @returns {boolean} returns.canUpgrade - Whether the selected version can be upgraded from the current version.\n */\nexport const checkUpgradeVersion = ({\n currentVersion,\n selectedVersion\n}: {\n currentVersion: string;\n selectedVersion: string;\n}): {canUpgrade: boolean} => {\n const currentMajor = major(currentVersion);\n const selectedMajor = major(selectedVersion);\n const currentMinor = minor(currentVersion);\n const selectedMinor = minor(selectedVersion);\n const currentPath = patch(currentVersion);\n const selectedPath = patch(selectedVersion);\n\n if (\n currentMajor < selectedMajor - 1 ||\n currentMinor < selectedMinor - 1 ||\n currentPath < selectedPath - 1\n ) {\n return {canUpgrade: false};\n }\n\n return {canUpgrade: true};\n};\n", "import {isNullish, nonNullish} from '@dfinity/utils';\nimport {type JunoPackage, JUNO_PACKAGE_SATELLITE_ID, JunoPackageSchema} from '@junobuild/config';\nimport type {BuildType} from '../schemas/build';\nimport {findJunoPackageDependency} from './package.helpers';\n\n/**\n * Extracts the build type from a provided Juno package or falls back to a deprecated detection method.\n *\n * @param {Object} params\n * @param {JunoPackage | undefined} params.junoPackage - The parsed Juno package metadata.\n * @param {Uint8Array} params.wasm - The WASM binary to inspect if no package is provided.\n * @returns {Promise<BuildType | undefined>} The build type (`'stock'` or `'extended'`) or `undefined` if undetermined.\n */\nexport const extractBuildType = async ({\n junoPackage,\n wasm\n}: {\n junoPackage: JunoPackage | undefined;\n wasm: Uint8Array;\n}): Promise<BuildType | undefined> => {\n if (isNullish(junoPackage)) {\n return await readDeprecatedBuildType({wasm});\n }\n\n const {name, dependencies} = junoPackage;\n\n if (name === JUNO_PACKAGE_SATELLITE_ID) {\n return 'stock';\n }\n\n const satelliteDependency = findJunoPackageDependency({\n dependencies,\n dependencyId: JUNO_PACKAGE_SATELLITE_ID\n });\n\n return nonNullish(satelliteDependency) ? 'extended' : undefined;\n};\n\n/**\n * @deprecated Modern WASM build use JunoPackage.\n */\nconst readDeprecatedBuildType = async ({\n wasm\n}: {\n wasm: Uint8Array;\n}): Promise<BuildType | undefined> => {\n const buildType = await customSection({wasm, sectionName: 'icp:public juno:build'});\n\n return nonNullish(buildType) && ['stock', 'extended'].includes(buildType)\n ? (buildType as BuildType)\n : undefined;\n};\n\n/**\n * Reads and parses the Juno package from the custom section of a WASM binary.\n *\n * @param {Object} params\n * @param {Uint8Array} params.wasm - The WASM binary containing the embedded custom section.\n * @returns {Promise<JunoPackage | undefined>} The parsed Juno package if present and valid, otherwise `undefined`.\n */\nexport const readCustomSectionJunoPackage = async ({\n wasm\n}: {\n wasm: Uint8Array;\n}): Promise<JunoPackage | undefined> => {\n const section = await customSection({wasm, sectionName: 'icp:public juno:package'});\n\n if (isNullish(section)) {\n return undefined;\n }\n\n const pkg = JSON.parse(section);\n\n const {success, data} = JunoPackageSchema.safeParse(pkg);\n return success ? data : undefined;\n};\n\nconst customSection = async ({\n sectionName,\n wasm\n}: {\n sectionName: string;\n wasm: Uint8Array;\n}): Promise<string | undefined> => {\n const wasmModule = await WebAssembly.compile(wasm);\n\n const pkgSections = WebAssembly.Module.customSections(wasmModule, sectionName);\n\n const [pkgBuffer] = pkgSections;\n\n return nonNullish(pkgBuffer) ? new TextDecoder().decode(pkgBuffer) : undefined;\n};\n", "import * as z from 'zod/v4';\n\n/**\n * Represents the type of build, stock or extended.\n */\nexport const BuildTypeSchema = z.enum(['stock', 'extended']);\n\n/**\n * Represents the type of build.\n * @typedef {'stock' | 'extended'} BuildType\n */\nexport type BuildType = z.infer<typeof BuildTypeSchema>;\n", "import * as z from 'zod/v4';\n\n/**\n * A schema for validating a version string in `x.y.z` format.\n *\n * Examples of valid versions:\n * - 0.1.0\"\n * - 2.3.4\n */\nexport const MetadataVersionSchema = z.string().refine((val) => /^\\d+\\.\\d+\\.\\d+$/.test(val), {\n message: 'Version does not match x.y.z format'\n});\n\n/**\n * A version string in `x.y.z` format.\n */\nexport type MetadataVersion = z.infer<typeof MetadataVersionSchema>;\n\n/**\n * A schema representing the metadata of a single release.\n *\n * Includes the version of the release itself (tag) and the versions\n * of all modules bundled with it.\n */\nexport const ReleaseMetadataSchema = z.strictObject({\n /**\n * Unique version identifier for the release, following the `x.y.z` format.\n * @type {MetadataVersion}\n */\n tag: MetadataVersionSchema,\n\n /**\n * The version of the console included in the release.\n * @type {MetadataVersion}\n */\n console: MetadataVersionSchema,\n\n /**\n * Version of the Observatory module included in the release.\n * This field is optional because it was introduced in Juno v0.0.10.\n *\n * @type {MetadataVersion | undefined}\n */\n observatory: MetadataVersionSchema.optional(),\n\n /**\n * Version of the Mission Control module included in the release.\n * @type {MetadataVersion}\n */\n mission_control: MetadataVersionSchema,\n\n /**\n * Version of the Satellite module included in the release.\n * @type {MetadataVersion}\n */\n satellite: MetadataVersionSchema,\n\n /**\n * Version of the Orbiter module included in the release.\n * This field is optional because it was introduced in Juno v0.0.17.\n *\n * @type {MetadataVersion | undefined}\n */\n orbiter: MetadataVersionSchema.optional(),\n\n /**\n * Version of the Sputnik module included in the release.\n * This field is optional because it was introduced in Juno v0.0.47.\n *\n * @type {MetadataVersion | undefined}\n */\n sputnik: MetadataVersionSchema.optional()\n});\n\n/**\n * The metadata for a release provided by Juno.\n */\nexport type ReleaseMetadata = z.infer<typeof ReleaseMetadataSchema>;\n\n/**\n * A schema representing the list of releases provided by Juno.\n *\n * Rules:\n * - The list must contain at least one release.\n * - Each release must have a unique `tag` (version identifier).\n * - The same module version can appear in multiple releases, as not every release\n * necessarily publishes a new version of each module.\n *\n * Validation:\n * - Ensures no duplicate `tag` values across the list of releases.\n */\nexport const ReleasesSchema = z\n .array(ReleaseMetadataSchema)\n .min(1)\n .refine((releases) => new Set(releases.map(({tag}) => tag)).size === releases.length, {\n message: 'A release tag appears multiple times but must be unique'\n });\n\n/**\n * The list of releases provided by Juno.\n */\nexport type Releases = z.infer<typeof ReleasesSchema>;\n\n/**\n * A schema for the list of all versions across releases.\n *\n * Rules:\n * - The list must contain at least one release.\n */\nexport const MetadataVersionsSchema = z.array(MetadataVersionSchema).min(1);\n\n/**\n * List of all versions across releases.\n */\nexport type MetadataVersions = z.infer<typeof MetadataVersionsSchema>;\n\n/**\n * A schema representing the metadata for multiple releases provided by Juno.\n */\nexport const ReleasesMetadataSchema = z.strictObject({\n /**\n * List of all Mission Control versions across releases.\n * @type {MetadataVersion}\n */\n mission_controls: MetadataVersionsSchema,\n\n /**\n * List of all Satellite versions across releases.\n * @type {MetadataVersion}\n */\n satellites: MetadataVersionsSchema,\n\n /**\n * List of all Orbiter versions across releases.\n * @type {MetadataVersion}\n */\n orbiters: MetadataVersionsSchema,\n\n /**\n * List of release metadata objects, each representing one release.\n */\n releases: ReleasesSchema\n});\n\n/**\n * The metadata for multiple releases provided by Juno.\n */\nexport type ReleasesMetadata = z.infer<typeof ReleasesMetadataSchema>;\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport {\n type MissionControlDid,\n type MissionControlParameters,\n getDeprecatedMissionControlVersionActor,\n getMissionControlActor\n} from '@junobuild/ic-client/actor';\n\n/**\n * @deprecated - Replaced in Mission Control > v0.0.14 with public custom section juno:package\n */\nexport const version = async ({\n missionControl\n}: {\n missionControl: MissionControlParameters;\n}): Promise<string> => {\n const {version} = await getDeprecatedMissionControlVersionActor(missionControl);\n return version();\n};\n\nexport const getUser = async ({\n missionControl\n}: {\n missionControl: MissionControlParameters;\n}): Promise<Principal> => {\n const {get_user} = await getMissionControlActor(missionControl);\n return get_user();\n};\n\nexport const listControllers = async ({\n missionControl\n}: {\n missionControl: MissionControlParameters;\n}): Promise<[Principal, MissionControlDid.Controller][]> => {\n const {list_mission_control_controllers} = await getMissionControlActor(missionControl);\n return list_mission_control_controllers();\n};\n\nexport const setSatellitesController = async ({\n missionControl,\n satelliteIds,\n controllerIds,\n controller\n}: {\n missionControl: MissionControlParameters;\n satelliteIds: Principal[];\n controllerIds: Principal[];\n controller: MissionControlDid.SetController;\n}) => {\n const {set_satellites_controllers} = await getMissionControlActor(missionControl);\n return set_satellites_controllers(satelliteIds, controllerIds, controller);\n};\n\nexport const setMissionControlController = async ({\n missionControl,\n controllerIds,\n controller\n}: {\n missionControl: MissionControlParameters;\n controllerIds: Principal[];\n controller: MissionControlDid.SetController;\n}) => {\n const {set_mission_control_controllers} = await getMissionControlActor(missionControl);\n return set_mission_control_controllers(controllerIds, controller);\n};\n", "import {Principal} from '@icp-sdk/core/principal';\nimport {nonNullish, toNullable} from '@dfinity/utils';\nimport type {MissionControlDid} from '@junobuild/ic-client/actor';\nimport type {SetControllerParams} from '../types/controllers';\n\nexport const mapSetControllerParams = ({\n controllerId,\n profile\n}: SetControllerParams): {\n controllerIds: Principal[];\n controller: MissionControlDid.SetController;\n} => ({\n controllerIds: [Principal.fromText(controllerId)],\n controller: toSetController(profile)\n});\n\nconst toSetController = (profile: string | null | undefined): MissionControlDid.SetController => ({\n metadata: nonNullish(profile) && profile !== '' ? [['profile', profile]] : [],\n expires_at: toNullable<bigint>(undefined),\n scope: {Admin: null}\n});\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport type {MissionControlDid, MissionControlParameters} from '@junobuild/ic-client/actor';\nimport {\n listControllers,\n setMissionControlController as setMissionControlControllerApi,\n setSatellitesController as setSatellitesControllerApi\n} from '../api/mission-control.api';\nimport type {SetControllerParams} from '../types/controllers';\nimport {mapSetControllerParams} from '../utils/controllers.utils';\n\n/**\n * Sets the controller for the specified satellites.\n * @param {Object} params - The parameters for setting the satellites controller.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @param {Principal[]} params.satelliteIds - The IDs of the satellites.\n * @param {SetControllerParams} params - Additional parameters for setting the controller.\n * @returns {Promise<void>} A promise that resolves when the controller is set.\n */\nexport const setSatellitesController = ({\n controllerId,\n profile,\n ...rest\n}: {\n missionControl: MissionControlParameters;\n satelliteIds: Principal[];\n} & SetControllerParams): Promise<void> =>\n setSatellitesControllerApi({\n ...rest,\n ...mapSetControllerParams({controllerId, profile})\n });\n\n/**\n * Sets the controller for Mission Control.\n * @param {Object} params - The parameters for setting the Mission Control controller.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @param {SetControllerParams} params - Additional parameters for setting the controller.\n * @returns {Promise<void>} A promise that resolves when the controller is set.\n */\nexport const setMissionControlController = ({\n controllerId,\n profile,\n ...rest\n}: {\n missionControl: MissionControlParameters;\n} & SetControllerParams): Promise<void> =>\n setMissionControlControllerApi({\n ...rest,\n ...mapSetControllerParams({controllerId, profile})\n });\n\n/**\n * Lists the controllers of Mission Control.\n * @param {Object} params - The parameters for listing the controllers.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const listMissionControlControllers = (params: {\n missionControl: MissionControlParameters;\n}): Promise<[Principal, MissionControlDid.Controller][]> => listControllers(params);\n", "import type {MissionControlParameters} from '@junobuild/ic-client/actor';\nimport {toPrincipal} from '@junobuild/ic-client/utils';\nimport {getUser} from '../api/mission-control.api';\nimport {INSTALL_MODE_UPGRADE} from '../constants/upgrade.constants';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\nimport {encoreIDLUser} from '../utils/idl.utils';\n\n/**\n * Upgrades the Mission Control with the provided WASM module.\n * @param {Object} params - The parameters for upgrading the Mission Control.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters, including the actor and mission control ID.\n * @param {Uint8Array} params.wasmModule - The WASM module to be installed during the upgrade.\n * @param {boolean} [params.preClearChunks] - Optional. Whether to force clearing chunks before uploading a chunked WASM module. Recommended if the WASM exceeds 2MB.\n * @param {boolean} [params.takeSnapshot=true] - Optional. Whether to take a snapshot before performing the upgrade. Defaults to true.\n * @param {function} [params.onProgress] - Optional. Callback function to report progress during the upgrade process.\n * @throws {Error} Will throw an error if the mission control principal is not defined.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\nexport const upgradeMissionControl = async ({\n missionControl,\n ...rest\n}: {\n missionControl: MissionControlParameters;\n} & Pick<\n UpgradeCodeParams,\n 'wasmModule' | 'preClearChunks' | 'takeSnapshot' | 'onProgress'\n>): Promise<void> => {\n const user = await getUser({missionControl});\n\n const {missionControlId, ...actor} = missionControl;\n\n if (!missionControlId) {\n throw new Error('No mission control principal defined.');\n }\n\n const arg = encoreIDLUser(user);\n\n await upgrade({\n actor,\n canisterId: toPrincipal(missionControlId),\n arg,\n mode: INSTALL_MODE_UPGRADE,\n ...rest\n });\n};\n", "import type {canister_install_mode} from '@dfinity/ic-management';\n\nexport const SIMPLE_INSTALL_MAX_WASM_SIZE = 2_000_000;\nexport const INSTALL_MAX_CHUNK_SIZE = 1_000_000;\n\nexport const INSTALL_MODE_RESET: canister_install_mode = {reinstall: null};\n\nexport const INSTALL_MODE_UPGRADE: canister_install_mode = {\n upgrade: [{skip_pre_upgrade: [false], wasm_memory_persistence: [{replace: null}]}]\n};\n", "import {fromNullable, isNullish, uint8ArrayToHexString} from '@dfinity/utils';\nimport {\n canisterStart,\n canisterStatus,\n canisterStop,\n listCanisterSnapshots,\n takeCanisterSnapshot\n} from '../api/ic.api';\nimport {SIMPLE_INSTALL_MAX_WASM_SIZE} from '../constants/upgrade.constants';\nimport {UpgradeCodeUnchangedError} from '../errors/upgrade.errors';\nimport {uint8ArraySha256} from '../helpers/crypto.helpers';\nimport {type UpgradeCodeParams, UpgradeCodeProgressStep} from '../types/upgrade';\nimport {upgradeChunkedCode} from './upgrade.chunks.handlers';\nimport {upgradeSingleChunkCode} from './upgrade.single.handlers';\n\nexport const upgrade = async ({\n wasmModule,\n canisterId,\n actor,\n onProgress,\n takeSnapshot = true,\n ...rest\n}: UpgradeCodeParams & {reset?: boolean}) => {\n // 1. We verify that the code to be installed is different from the code already deployed. If the codes are identical, we skip the installation.\n // TODO: unless mode is reinstall\n const assert = async () => await assertExistingCode({wasmModule, canisterId, actor, ...rest});\n await execute({fn: assert, onProgress, step: UpgradeCodeProgressStep.AssertingExistingCode});\n\n // 2. We stop the canister to prepare for the upgrade.\n const stop = async () => await canisterStop({canisterId, actor});\n await execute({fn: stop, onProgress, step: UpgradeCodeProgressStep.StoppingCanister});\n\n try {\n // 3. We take a snapshot - create a backup - unless the dev opted-out\n const snapshot = async () =>\n takeSnapshot ? await createSnapshot({canisterId, actor}) : Promise.resolve();\n await execute({fn: snapshot, onProgress, step: UpgradeCodeProgressStep.TakingSnapshot});\n\n // 4. Upgrading code: If the WASM is > 2MB we proceed with the chunked installation otherwise we use the original single chunk installation method.\n const upgrade = async () => await upgradeCode({wasmModule, canisterId, actor, ...rest});\n await execute({fn: upgrade, onProgress, step: UpgradeCodeProgressStep.UpgradingCode});\n } finally {\n // 5. We restart the canister to finalize the process.\n const restart = async () => await canisterStart({canisterId, actor});\n await execute({fn: restart, onProgress, step: UpgradeCodeProgressStep.RestartingCanister});\n }\n};\n\nconst execute = async ({\n fn,\n step,\n onProgress\n}: {fn: () => Promise<void>; step: UpgradeCodeProgressStep} & Pick<\n UpgradeCodeParams,\n 'onProgress'\n>) => {\n onProgress?.({\n step,\n state: 'in_progress'\n });\n\n try {\n await fn();\n\n onProgress?.({\n step,\n state: 'success'\n });\n } catch (err: unknown) {\n onProgress?.({\n step,\n state: 'error'\n });\n\n throw err;\n }\n};\n\nconst assertExistingCode = async ({\n actor,\n canisterId,\n wasmModule,\n reset\n}: Pick<UpgradeCodeParams, 'actor' | 'canisterId' | 'wasmModule'> & {reset?: boolean}) => {\n // If we want to reinstall the module we are fine reinstalling the same version of the code\n if (reset === true) {\n return;\n }\n\n const {module_hash} = await canisterStatus({\n actor,\n canisterId\n });\n\n const installedHash = fromNullable(module_hash);\n\n if (isNullish(installedHash)) {\n return;\n }\n\n const newWasmModuleHash = await uint8ArraySha256(wasmModule);\n const existingWasmModuleHash = uint8ArrayToHexString(installedHash);\n\n if (newWasmModuleHash !== existingWasmModuleHash) {\n return;\n }\n\n throw new UpgradeCodeUnchangedError();\n};\n\nconst upgradeCode = async ({\n wasmModule,\n canisterId,\n actor,\n ...rest\n}: Omit<UpgradeCodeParams, 'onProgress'>) => {\n const upgradeType = (): 'chunked' | 'single' => {\n const blob = new Blob([wasmModule]);\n return blob.size > SIMPLE_INSTALL_MAX_WASM_SIZE ? 'chunked' : 'single';\n };\n\n const fn = upgradeType() === 'chunked' ? upgradeChunkedCode : upgradeSingleChunkCode;\n await fn({wasmModule, canisterId, actor, ...rest});\n};\n\nconst createSnapshot = async (params: Pick<UpgradeCodeParams, 'canisterId' | 'actor'>) => {\n const snapshots = await listCanisterSnapshots(params);\n\n // TODO: currently only one snapshot per canister is supported on the IC\n await takeCanisterSnapshot({\n ...params,\n snapshotId: snapshots?.[0]?.id\n });\n};\n", "import {CanisterStatus} from '@icp-sdk/core/agent';\nimport {\n type chunk_hash,\n type InstallChunkedCodeParams,\n type InstallCodeParams,\n type list_canister_snapshots_result,\n type snapshot_id,\n type UploadChunkParams,\n ICManagementCanister\n} from '@dfinity/ic-management';\nimport type {take_canister_snapshot_result} from '@dfinity/ic-management/dist/candid/ic-management';\nimport type {CanisterStatusResponse} from '@dfinity/ic-management/dist/types/types/ic-management.responses';\nimport {Principal} from '@icp-sdk/core/principal';\nimport {type ActorParameters, useOrInitAgent} from '@junobuild/ic-client/actor';\n\nexport const canisterStop = async ({\n canisterId,\n actor\n}: {\n canisterId: Principal;\n actor: ActorParameters;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {stopCanister} = ICManagementCanister.create({\n agent\n });\n\n await stopCanister(canisterId);\n};\n\nexport const canisterStart = async ({\n canisterId,\n actor\n}: {\n canisterId: Principal;\n actor: ActorParameters;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {startCanister} = ICManagementCanister.create({\n agent\n });\n\n await startCanister(canisterId);\n};\n\nexport const installCode = async ({\n actor,\n code\n}: {\n actor: ActorParameters;\n code: InstallCodeParams;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {installCode} = ICManagementCanister.create({\n agent\n });\n\n return installCode(code);\n};\n\nexport const storedChunks = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<chunk_hash[]> => {\n const agent = await useOrInitAgent(actor);\n\n const {storedChunks} = ICManagementCanister.create({\n agent\n });\n\n return storedChunks({canisterId});\n};\n\nexport const clearChunkStore = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {clearChunkStore} = ICManagementCanister.create({\n agent\n });\n\n return clearChunkStore({canisterId});\n};\n\nexport const uploadChunk = async ({\n actor,\n chunk\n}: {\n actor: ActorParameters;\n chunk: UploadChunkParams;\n}): Promise<chunk_hash> => {\n const agent = await useOrInitAgent(actor);\n\n const {uploadChunk} = ICManagementCanister.create({\n agent\n });\n\n return uploadChunk(chunk);\n};\n\nexport const installChunkedCode = async ({\n actor,\n code\n}: {\n actor: ActorParameters;\n code: InstallChunkedCodeParams;\n}): Promise<void> => {\n const agent = await useOrInitAgent(actor);\n\n const {installChunkedCode} = ICManagementCanister.create({\n agent\n });\n\n return installChunkedCode(code);\n};\n\nexport const canisterStatus = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<CanisterStatusResponse> => {\n const agent = await useOrInitAgent(actor);\n\n const {canisterStatus} = ICManagementCanister.create({\n agent\n });\n\n return canisterStatus(canisterId);\n};\n\nexport const canisterMetadata = async ({\n canisterId,\n path,\n ...rest\n}: ActorParameters & {\n canisterId: Principal | string;\n path: string;\n}): Promise<CanisterStatus.Status | undefined> => {\n const agent = await useOrInitAgent(rest);\n\n // TODO: Workaround for agent-js. Disable console.warn.\n // See https://github.com/dfinity/agent-js/issues/843\n const hideAgentJsConsoleWarn = globalThis.console.warn;\n globalThis.console.warn = (): null => null;\n\n const result = await CanisterStatus.request({\n canisterId: canisterId instanceof Principal ? canisterId : Principal.from(canisterId),\n agent,\n paths: [\n {\n kind: 'metadata',\n key: path,\n path,\n decodeStrategy: 'utf-8'\n }\n ]\n });\n\n // Redo console.warn\n globalThis.console.warn = hideAgentJsConsoleWarn;\n\n return result.get(path);\n};\n\nexport const listCanisterSnapshots = async ({\n actor,\n canisterId\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n}): Promise<list_canister_snapshots_result> => {\n const agent = await useOrInitAgent(actor);\n\n const {listCanisterSnapshots} = ICManagementCanister.create({\n agent\n });\n\n return listCanisterSnapshots({canisterId});\n};\n\nexport const takeCanisterSnapshot = async ({\n actor,\n ...rest\n}: {\n actor: ActorParameters;\n canisterId: Principal;\n snapshotId?: snapshot_id;\n}): Promise<take_canister_snapshot_result> => {\n const agent = await useOrInitAgent(actor);\n\n const {takeCanisterSnapshot} = ICManagementCanister.create({\n agent\n });\n\n return takeCanisterSnapshot(rest);\n};\n", "import type {canister_install_mode} from '@dfinity/ic-management';\nimport type {Principal} from '@icp-sdk/core/principal';\nimport type {ActorParameters} from '@junobuild/ic-client/actor';\n\nexport enum UpgradeCodeProgressStep {\n AssertingExistingCode,\n StoppingCanister,\n TakingSnapshot,\n UpgradingCode,\n RestartingCanister\n}\n\nexport type UpgradeCodeProgressState = 'in_progress' | 'success' | 'error';\n\nexport interface UpgradeCodeProgress {\n step: UpgradeCodeProgressStep;\n state: UpgradeCodeProgressState;\n}\n\nexport interface UpgradeCodeParams {\n actor: ActorParameters;\n canisterId: Principal;\n missionControlId?: Principal;\n wasmModule: Uint8Array;\n arg: Uint8Array;\n mode: canister_install_mode;\n preClearChunks?: boolean;\n takeSnapshot?: boolean;\n onProgress?: (progress: UpgradeCodeProgress) => void;\n}\n", "import type {chunk_hash} from '@dfinity/ic-management';\nimport {isNullish, nonNullish, uint8ArrayToHexString} from '@dfinity/utils';\nimport {\n clearChunkStore,\n installChunkedCode,\n storedChunks as storedChunksApi,\n uploadChunk as uploadChunkApi\n} from '../api/ic.api';\nimport {INSTALL_MAX_CHUNK_SIZE} from '../constants/upgrade.constants';\nimport {blobSha256, uint8ArraySha256} from '../helpers/crypto.helpers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\n\ninterface UploadChunkOrderId {\n orderId: number;\n}\n\ninterface UploadChunkParams extends UploadChunkOrderId {\n chunk: Blob;\n sha256: string;\n}\n\ninterface UploadChunkResult extends UploadChunkOrderId {\n chunkHash: chunk_hash;\n}\n\nexport const upgradeChunkedCode = async ({\n actor,\n canisterId,\n missionControlId,\n wasmModule,\n preClearChunks: userPreClearChunks,\n ...rest\n}: UpgradeCodeParams) => {\n // If the user want to clear - reset - any chunks that have been uploaded before we start by removing those.\n if (userPreClearChunks) {\n await clearChunkStore({actor, canisterId});\n }\n\n const wasmChunks = await wasmToChunks({wasmModule});\n\n const {uploadChunks, storedChunks, preClearChunks, postClearChunks} = await prepareUpload({\n actor,\n wasmChunks,\n canisterId,\n missionControlId\n });\n\n // Alright, let's start by clearing existing chunks if there are already stored chunks but, none are matching those we want to upload.\n if (preClearChunks) {\n await clearChunkStore({actor, canisterId});\n }\n\n // Upload chunks to the IC in batch - i.e. 12 chunks uploaded at a time.\n let chunkIds: UploadChunkResult[] = [];\n for await (const results of batchUploadChunks({\n uploadChunks,\n actor,\n canisterId,\n missionControlId\n })) {\n chunkIds = [...chunkIds, ...results];\n }\n\n // Install the chunked code.\n // \u26A0\uFE0F The order of the chunks is really important! \u26A0\uFE0F\n await installChunkedCode({\n actor,\n code: {\n ...rest,\n chunkHashesList: [...chunkIds, ...storedChunks]\n .sort(({orderId: orderIdA}, {orderId: orderIdB}) => orderIdA - orderIdB)\n .map(({chunkHash}) => chunkHash),\n targetCanisterId: canisterId,\n storeCanisterId: missionControlId,\n wasmModuleHash: await uint8ArraySha256(wasmModule)\n }\n });\n\n // Finally let's clear only if no mission control is provided, as the chunks might be reused in that case.\n if (postClearChunks) {\n await clearChunkStore({actor, canisterId});\n }\n};\n\nconst wasmToChunks = async ({\n wasmModule\n}: Pick<UpgradeCodeParams, 'wasmModule'>): Promise<UploadChunkParams[]> => {\n const blob = new Blob([wasmModule]);\n\n const uploadChunks: UploadChunkParams[] = [];\n\n const chunkSize = INSTALL_MAX_CHUNK_SIZE;\n\n // Split data into chunks\n let orderId = 0;\n for (let start = 0; start < blob.size; start += chunkSize) {\n const chunk = blob.slice(start, start + chunkSize);\n uploadChunks.push({\n chunk,\n orderId,\n sha256: await blobSha256(chunk)\n });\n\n orderId++;\n }\n\n return uploadChunks;\n};\n\ninterface PrepareUpload {\n uploadChunks: UploadChunkParams[];\n storedChunks: UploadChunkResult[];\n preClearChunks: boolean;\n postClearChunks: boolean;\n}\n\n/**\n * Prepares the upload of WASM chunks by determining which chunks need to be uploaded\n * and which are already stored. Additionally, it provides flags for pre-clear and post-clear operations.\n *\n * If a `missionControlId` is provided, the function fetches the already stored chunks\n * for the given mission control canister. Otherwise, it fetches them from the `canisterId`.\n *\n * In the response, `preClearChunks` is set to `true` if no stored chunks matching the one we are looking to upload are detected.\n * `postClearChunks` is set to `true` if no `missionControlId` is given, as the chunks might be reused for other installations.\n *\n * @param {Object} params - The input parameters.\n * @param {string} params.canisterId - The ID of the target canister.\n * @param {string} [params.missionControlId] - The ID of the mission control canister, if provided.\n * @param {Object} params.actor - The actor instance for interacting with the canister.\n * @param {UploadChunkParams[]} params.wasmChunks - The WASM chunks to be uploaded, including their hashes and metadata.\n *\n * @returns {Promise<PrepareUpload>} Resolves to an object containing:\n */\nconst prepareUpload = async ({\n canisterId,\n missionControlId,\n actor,\n wasmChunks\n}: Pick<UpgradeCodeParams, 'canisterId' | 'missionControlId' | 'actor'> & {\n wasmChunks: UploadChunkParams[];\n}): Promise<PrepareUpload> => {\n const stored = await storedChunksApi({\n actor,\n canisterId: missionControlId ?? canisterId\n });\n\n // We convert existing hash to extend with an easily comparable sha256 as hex value\n const existingStoredChunks: (Pick<UploadChunkResult, 'chunkHash'> &\n Pick<UploadChunkParams, 'sha256'>)[] = stored.map(({hash}) => ({\n chunkHash: {hash},\n sha256: uint8ArrayToHexString(hash)\n }));\n\n const {storedChunks, uploadChunks} = wasmChunks.reduce<\n Omit<PrepareUpload, 'preClearChunks' | 'postClearChunks'>\n >(\n ({uploadChunks, storedChunks}, {sha256, ...rest}) => {\n const existingStoredChunk = existingStoredChunks.find(\n ({sha256: storedSha256}) => storedSha256 === sha256\n );\n\n return {\n uploadChunks: [\n ...uploadChunks,\n ...(nonNullish(existingStoredChunk) ? [] : [{sha256, ...rest}])\n ],\n storedChunks: [\n ...storedChunks,\n ...(nonNullish(existingStoredChunk) ? [{...rest, ...existingStoredChunk}] : [])\n ]\n };\n },\n {\n uploadChunks: [],\n storedChunks: []\n }\n );\n\n return {\n uploadChunks,\n storedChunks,\n preClearChunks: stored.length > 0 && storedChunks.length === 0,\n postClearChunks: isNullish(missionControlId)\n };\n};\n\nasync function* batchUploadChunks({\n uploadChunks,\n limit = 12,\n ...rest\n}: Pick<UpgradeCodeParams, 'actor' | 'canisterId' | 'missionControlId'> & {\n uploadChunks: UploadChunkParams[];\n limit?: number;\n}): AsyncGenerator<UploadChunkResult[], void> {\n for (let i = 0; i < uploadChunks.length; i = i + limit) {\n const batch = uploadChunks.slice(i, i + limit);\n const result = await Promise.all(\n batch.map((uploadChunkParams) =>\n uploadChunk({\n uploadChunk: uploadChunkParams,\n ...rest\n })\n )\n );\n yield result;\n }\n}\n\nconst uploadChunk = async ({\n actor,\n canisterId,\n missionControlId,\n uploadChunk: {chunk, ...rest}\n}: Pick<UpgradeCodeParams, 'actor' | 'canisterId' | 'missionControlId'> & {\n uploadChunk: UploadChunkParams;\n}): Promise<UploadChunkResult> => {\n const chunkHash = await uploadChunkApi({\n actor,\n chunk: {\n canisterId: missionControlId ?? canisterId,\n chunk: new Uint8Array(await chunk.arrayBuffer())\n }\n });\n\n return {\n chunkHash,\n ...rest\n };\n};\n", "import {installCode} from '../api/ic.api';\nimport type {UpgradeCodeParams} from '../types/upgrade';\n\nexport const upgradeSingleChunkCode = async ({actor, ...rest}: UpgradeCodeParams) => {\n await installCode({\n actor,\n code: rest\n });\n};\n", "import {IDL} from '@icp-sdk/core/candid';\nimport type {Principal} from '@icp-sdk/core/principal';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\n\nexport const encoreIDLUser = (user: Principal): Uint8Array =>\n IDL.encode(\n [\n IDL.Record({\n user: IDL.Principal\n })\n ],\n [{user}]\n );\n\nexport const encodeAdminAccessKeysToIDL = (\n controllers: [Principal, SatelliteDid.Controller][]\n): Uint8Array =>\n IDL.encode(\n [\n IDL.Record({\n controllers: IDL.Vec(IDL.Principal)\n })\n ],\n [\n {\n controllers: controllers\n .filter(([_, {scope}]) => 'Admin' in scope)\n .map(([controller, _]) => controller)\n }\n ]\n );\n", "import {assertNonNullish, isNullish} from '@dfinity/utils';\nimport {JUNO_PACKAGE_MISSION_CONTROL_ID} from '@junobuild/config';\nimport type {MissionControlParameters} from '@junobuild/ic-client/actor';\nimport {version} from '../api/mission-control.api';\nimport {MissionControlVersionError} from '../errors/version.errors';\nimport {getJunoPackage} from './package.services';\n\n/**\n * Retrieves the version of Mission Control.\n * @param {Object} params - The parameters for Mission Control.\n * @param {MissionControlParameters} params.missionControl - The Mission Control parameters.\n * @returns {Promise<string>} A promise that resolves to the version of Mission Control.\n */\nexport const missionControlVersion = async ({\n missionControl: {missionControlId, ...rest}\n}: {\n missionControl: MissionControlParameters;\n}): Promise<string> => {\n assertNonNullish(\n missionControlId,\n 'A Mission Control ID must be provided to request its version.'\n );\n\n const pkg = await getJunoPackage({\n moduleId: missionControlId,\n ...rest\n });\n\n // For backwards compatibility with legacy. Function version() was deprecated in Mission Control > v0.0.14\n if (isNullish(pkg)) {\n return await version({missionControl: {missionControlId, ...rest}});\n }\n\n const {name, version: missionControlVersion} = pkg;\n\n if (name === JUNO_PACKAGE_MISSION_CONTROL_ID) {\n return missionControlVersion;\n }\n\n throw new MissionControlVersionError();\n};\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport {isNullish} from '@dfinity/utils';\nimport {type JunoPackage, JunoPackageSchema} from '@junobuild/config';\nimport type {ActorParameters} from '@junobuild/ic-client/actor';\nimport * as z from 'zod/v4';\nimport {canisterMetadata} from '../api/ic.api';\n\n/**\n * Parameters required to retrieve a `juno:package` metadata section.\n *\n * @typedef {Object} GetJunoPackageParams\n * @property {Principal | string} moduleId - The ID of the canister module (as a Principal or string).\n * @property {ActorParameters} [ActorParameters] - Additional actor parameters for making the canister call.\n */\nexport type GetJunoPackageParams = {moduleId: Principal | string} & ActorParameters;\n\n/**\n * Get the `juno:package` metadata from the public custom section of a given module.\n *\n * @param {Object} params - The parameters to fetch the metadata.\n * @param {Principal | string} params.moduleId - The canister ID (as a `Principal` or string) from which to retrieve the metadata.\n * @param {ActorParameters} params - Additional actor parameters required for the call.\n *\n * @returns {Promise<JunoPackage | undefined>} A promise that resolves to the parsed `JunoPackage` metadata, or `undefined` if not found.\n *\n * @throws {ZodError} If the metadata exists but does not conform to the expected `JunoPackage` schema.\n */\nexport const getJunoPackage = async ({\n moduleId,\n ...rest\n}: GetJunoPackageParams): Promise<JunoPackage | undefined> => {\n const status = await canisterMetadata({...rest, canisterId: moduleId, path: 'juno:package'});\n\n if (isNullish(status)) {\n return undefined;\n }\n\n if (typeof status !== 'string') {\n throw new Error('Unexpected metadata type to parse public custom section juno:package');\n }\n\n // https://stackoverflow.com/a/75881231/5404186\n // https://github.com/colinhacks/zod/discussions/2215#discussioncomment-5356286\n const createPackageFromJson = (content: string): JunoPackage =>\n z\n .string()\n // eslint-disable-next-line local-rules/prefer-object-params\n .transform((str, ctx) => {\n try {\n return JSON.parse(str);\n } catch (_err: unknown) {\n ctx.addIssue({\n code: 'custom',\n message: 'Invalid JSON'\n });\n return z.never;\n }\n })\n .pipe(JunoPackageSchema)\n .parse(content);\n\n return createPackageFromJson(status);\n};\n\n/**\n * Retrieves only the `version` field from the `juno:package` metadata.\n *\n * @param {GetJunoPackageParams} params - The parameters to fetch the package version.\n *\n * @returns {Promise<string | undefined>} A promise that resolves to the version string or `undefined` if not found.\n *\n * @throws {ZodError} If the metadata exists but does not conform to the expected `JunoPackage` schema.\n */\nexport const getJunoPackageVersion = async (\n params: GetJunoPackageParams\n): Promise<JunoPackage['version'] | undefined> => {\n const pkg = await getJunoPackage(params);\n return pkg?.version;\n};\n\n/**\n * Retrieves the `dependencies` field from the `juno:package` metadata.\n *\n * @param {GetJunoPackageParams} params - The parameters to fetch the package metadata.\n *\n * @returns {Promise<JunoPackage['dependencies'] | undefined>} A promise that resolves to the dependencies object or `undefined` if not found.\n *\n * @throws {ZodError} If the metadata exists but does not conform to the expected `JunoPackage` schema.\n */\nexport const getJunoPackageDependencies = async (\n params: GetJunoPackageParams\n): Promise<JunoPackage['dependencies'] | undefined> => {\n const pkg = await getJunoPackage(params);\n return pkg?.dependencies;\n};\n", "import type {ActorParameters} from '@junobuild/ic-client/actor';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\n\n/**\n * Upgrades a module with the provided WASM code and arguments. This generic is notably useful for Juno Docker.\n *\n * @param {Object} params - Parameters for upgrading the module.\n * @param {ActorParameters} params.actor - The actor parameters associated with the module.\n * @param {Principal} params.canisterId - The ID of the canister being upgraded.\n * @param {Principal} [params.missionControlId] - Optional. An ID to store and reuse WASM chunks across installations.\n * @param {Uint8Array} params.wasmModule - The WASM code to be installed during the upgrade.\n * @param {Uint8Array} params.arg - The initialization argument for the module upgrade.\n * @param {canister_install_mode} params.mode - The installation mode, e.g., `upgrade` or `reinstall`.\n * @param {boolean} [params.preClearChunks] - Optional. Forces clearing existing chunks before uploading a chunked WASM module. Recommended for WASM modules larger than 2MB.\n * @param {function} [params.onProgress] - Optional. Callback function to track progress during the upgrade process.\n * @param {boolean} [params.reset=false] - Optional. Specifies whether to reset the module (reinstall) instead of performing an upgrade. Defaults to `false`.\n * @throws {Error} Will throw an error if the parameters are invalid or if the upgrade process fails.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\nexport const upgradeModule = async (\n params: {\n actor: ActorParameters;\n reset?: boolean;\n } & UpgradeCodeParams\n): Promise<void> => {\n await upgrade(params);\n};\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport {\n type OrbiterDid,\n type OrbiterParameters,\n getDeprecatedOrbiterVersionActor,\n getOrbiterActor\n} from '@junobuild/ic-client/actor';\n\n/**\n * @deprecated - Replaced in Orbiter > v0.0.8 with public custom section juno:package\n */\nexport const version = async ({orbiter}: {orbiter: OrbiterParameters}): Promise<string> => {\n const {version} = await getDeprecatedOrbiterVersionActor(orbiter);\n return version();\n};\n\nexport const listControllers = async ({\n orbiter,\n certified\n}: {\n orbiter: OrbiterParameters;\n certified?: boolean;\n}): Promise<[Principal, OrbiterDid.Controller][]> => {\n const {list_controllers} = await getOrbiterActor({...orbiter, certified});\n return list_controllers();\n};\n\nexport const memorySize = async ({\n orbiter\n}: {\n orbiter: OrbiterParameters;\n}): Promise<OrbiterDid.MemorySize> => {\n const {memory_size} = await getOrbiterActor(orbiter);\n return memory_size();\n};\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport type {MissionControlDid, OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {listControllers} from '../api/orbiter.api';\n\n/**\n * Lists the controllers of the Orbiter.\n * @param {Object} params - The parameters for listing the controllers.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const listOrbiterControllers = (params: {\n orbiter: OrbiterParameters;\n}): Promise<[Principal, MissionControlDid.Controller][]> => listControllers(params);\n", "import type {OrbiterDid, OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {memorySize} from '../api/orbiter.api';\n\n/**\n * Retrieves the stable and heap memory size of the Orbiter.\n * @param {Object} params - The parameters for the Orbiter.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters.\n * @returns {Promise<MemorySize>} A promise that resolves to the memory size of the Orbiter.\n */\nexport const orbiterMemorySize = (params: {\n orbiter: OrbiterParameters;\n}): Promise<OrbiterDid.MemorySize> => memorySize(params);\n", "import type {OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {toPrincipal} from '@junobuild/ic-client/utils';\nimport {listControllers} from '../api/orbiter.api';\nimport {INSTALL_MODE_RESET, INSTALL_MODE_UPGRADE} from '../constants/upgrade.constants';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\nimport {encodeAdminAccessKeysToIDL} from '../utils/idl.utils';\n\n/**\n * Upgrades the Orbiter with the provided WASM module.\n * @param {Object} params - The parameters for upgrading the Orbiter.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters, including the actor and orbiter ID.\n * @param {Principal} [params.missionControlId] - Optional. The Mission Control ID to potentially store WASM chunks, enabling reuse across installations.\n * @param {Uint8Array} params.wasmModule - The WASM module to be installed during the upgrade.\n * @param {boolean} [params.reset=false] - Optional. Indicates whether to reset the Orbiter (reinstall) instead of performing an upgrade. Defaults to `false`.\n * @param {boolean} [params.preClearChunks] - Optional. Forces clearing existing chunks before uploading a chunked WASM module. Recommended if the WASM exceeds 2MB.\n * @param {boolean} [params.takeSnapshot=true] - Optional. Whether to take a snapshot before performing the upgrade. Defaults to true.\n * @param {function} [params.onProgress] - Optional. Callback function to track progress during the upgrade process.\n * @throws {Error} Will throw an error if the Orbiter principal is not defined.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\n\nexport const upgradeOrbiter = async ({\n orbiter,\n reset = false,\n ...rest\n}: {\n orbiter: OrbiterParameters;\n reset?: boolean;\n} & Pick<\n UpgradeCodeParams,\n 'wasmModule' | 'missionControlId' | 'preClearChunks' | 'takeSnapshot' | 'onProgress'\n>): Promise<void> => {\n const {orbiterId, ...actor} = orbiter;\n\n if (!orbiterId) {\n throw new Error('No orbiter principal defined.');\n }\n\n const controllers = await listControllers({orbiter, certified: reset});\n\n // Only really use in case of --reset\n const arg = encodeAdminAccessKeysToIDL(controllers);\n\n await upgrade({\n actor,\n canisterId: toPrincipal(orbiterId),\n arg,\n mode: reset ? INSTALL_MODE_RESET : INSTALL_MODE_UPGRADE,\n reset,\n ...rest\n });\n};\n", "import {assertNonNullish, isNullish} from '@dfinity/utils';\nimport {JUNO_PACKAGE_ORBITER_ID} from '@junobuild/config';\nimport type {OrbiterParameters} from '@junobuild/ic-client/actor';\nimport {version} from '../api/orbiter.api';\nimport {OrbiterVersionError} from '../errors/version.errors';\nimport {getJunoPackage} from './package.services';\n\n/**\n * Retrieves the version of the Orbiter.\n * @param {Object} params - The parameters for the Orbiter.\n * @param {OrbiterParameters} params.orbiter - The Orbiter parameters.\n * @returns {Promise<string>} A promise that resolves to the version of the Orbiter.\n */\nexport const orbiterVersion = async ({\n orbiter: {orbiterId, ...rest}\n}: {\n orbiter: OrbiterParameters;\n}): Promise<string> => {\n assertNonNullish(orbiterId, 'An Orbiter ID must be provided to request its version.');\n\n const pkg = await getJunoPackage({\n moduleId: orbiterId,\n ...rest\n });\n\n // For backwards compatibility with legacy. Function version() was deprecated in Mission Control > v0.0.8\n if (isNullish(pkg)) {\n return await version({orbiter: {orbiterId, ...rest}});\n }\n\n const {name, version: missionControlVersion} = pkg;\n\n if (name === JUNO_PACKAGE_ORBITER_ID) {\n return missionControlVersion;\n }\n\n throw new OrbiterVersionError();\n};\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport {toNullable} from '@dfinity/utils';\nimport {\n type SatelliteDid,\n type SatelliteParameters,\n getDeprecatedSatelliteActor,\n getDeprecatedSatelliteNoScopeActor,\n getDeprecatedSatelliteVersionActor,\n getSatelliteActor\n} from '@junobuild/ic-client/actor';\n\nexport const setStorageConfig = async ({\n config,\n satellite\n}: {\n config: SatelliteDid.SetStorageConfig;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.StorageConfig> => {\n const {set_storage_config} = await getSatelliteActor(satellite);\n return set_storage_config(config);\n};\n\nexport const setDatastoreConfig = async ({\n config,\n satellite\n}: {\n config: SatelliteDid.SetDbConfig;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.DbConfig> => {\n const {set_db_config} = await getSatelliteActor(satellite);\n return set_db_config(config);\n};\n\nexport const setAuthConfig = async ({\n config,\n satellite\n}: {\n config: SatelliteDid.SetAuthenticationConfig;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.AuthenticationConfig> => {\n const {set_auth_config} = await getSatelliteActor(satellite);\n return set_auth_config(config);\n};\n\nexport const getStorageConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.StorageConfig> => {\n const {get_storage_config} = await getSatelliteActor(satellite);\n return get_storage_config();\n};\n\nexport const getDatastoreConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[] | [SatelliteDid.DbConfig]> => {\n const {get_db_config} = await getSatelliteActor(satellite);\n return get_db_config();\n};\n\nexport const getAuthConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[] | [SatelliteDid.AuthenticationConfig]> => {\n const {get_auth_config} = await getSatelliteActor(satellite);\n return get_auth_config();\n};\n\nexport const getConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.Config> => {\n const {get_config} = await getSatelliteActor(satellite);\n return get_config();\n};\n\nexport const listRules = async ({\n satellite,\n type,\n filter\n}: {\n satellite: SatelliteParameters;\n type: SatelliteDid.CollectionType;\n filter: SatelliteDid.ListRulesParams;\n}): Promise<SatelliteDid.ListRulesResults> => {\n const {list_rules} = await getSatelliteActor(satellite);\n return list_rules(type, filter);\n};\n\nexport const setRule = async ({\n type,\n collection,\n rule,\n satellite\n}: {\n type: SatelliteDid.CollectionType;\n collection: string;\n rule: SatelliteDid.SetRule;\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.Rule> => {\n const {set_rule} = await getSatelliteActor(satellite);\n return set_rule(type, collection, rule);\n};\n\n/**\n * @deprecated - Replaced in Satellite > v0.0.22 with public custom section juno:package\n */\nexport const version = async ({satellite}: {satellite: SatelliteParameters}): Promise<string> => {\n const {version} = await getDeprecatedSatelliteVersionActor(satellite);\n return version();\n};\n\n/**\n * @deprecated TODO: for backwards compatibility - to be removed\n */\nexport const listDeprecatedControllers = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<Principal[]> => {\n const {list_controllers} = await getDeprecatedSatelliteActor(satellite);\n return list_controllers();\n};\n\n/**\n * @deprecated TODO: for backwards compatibility - to be removed\n */\nexport const listDeprecatedNoScopeControllers = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const {list_controllers} = await getDeprecatedSatelliteNoScopeActor(satellite);\n return list_controllers() as Promise<[Principal, SatelliteDid.Controller][]>;\n};\n\nexport const listControllers = async ({\n satellite,\n certified\n}: {\n satellite: SatelliteParameters;\n certified?: boolean;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const {list_controllers} = await getSatelliteActor({...satellite, certified});\n return list_controllers();\n};\n\nexport const listCustomDomains = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<[string, SatelliteDid.CustomDomain][]> => {\n const {list_custom_domains} = await getSatelliteActor(satellite);\n return list_custom_domains();\n};\n\nexport const setCustomDomain = async ({\n satellite,\n domainName,\n boundaryNodesId\n}: {\n satellite: SatelliteParameters;\n domainName: string;\n boundaryNodesId: string | undefined;\n}): Promise<void> => {\n const {set_custom_domain} = await getSatelliteActor(satellite);\n await set_custom_domain(domainName, toNullable(boundaryNodesId));\n};\n\nexport const memorySize = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.MemorySize> => {\n const {memory_size} = await getSatelliteActor(satellite);\n return memory_size();\n};\n\nexport const countDocs = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => {\n const {count_collection_docs} = await getSatelliteActor(satellite);\n return count_collection_docs(collection);\n};\n\nexport const countAssets = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => {\n const {count_collection_assets} = await getSatelliteActor(satellite);\n return count_collection_assets(collection);\n};\n\nexport const deleteDocs = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => {\n const {del_docs} = await getSatelliteActor(satellite);\n return del_docs(collection);\n};\n\nexport const deleteAssets = async ({\n collection,\n satellite\n}: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => {\n const {del_assets} = await getSatelliteActor(satellite);\n return del_assets(collection);\n};\n\nexport const setControllers = async ({\n args,\n satellite\n}: {\n args: SatelliteDid.SetControllersArgs;\n satellite: SatelliteParameters;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const {set_controllers} = await getSatelliteActor(satellite);\n return set_controllers(args);\n};\n", "import type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {countAssets as countAssetsApi, deleteAssets as deleteAssetsApi} from '../api/satellite.api';\n\n/**\n * Counts the assets in a collection.\n * @param {Object} params - The parameters for counting the assets.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<bigint>} A promise that resolves to the number of assets in the collection.\n */\nexport const countAssets = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => countAssetsApi(params);\n\n/**\n * Deletes the assets in a collection.\n * @param {Object} params - The parameters for deleting the assets.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the assets are deleted.\n */\nexport const deleteAssets = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => deleteAssetsApi(params);\n", "import {fromNullable, isNullish, nonNullish} from '@dfinity/utils';\nimport type {AuthenticationConfig, DatastoreConfig, StorageConfig} from '@junobuild/config';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {\n getAuthConfig as getAuthConfigApi,\n getConfig as getConfigApi,\n getDatastoreConfig as getDatastoreConfigApi,\n getStorageConfig as getStorageConfigApi,\n setAuthConfig as setAuthConfigApi,\n setDatastoreConfig as setDatastoreConfigApi,\n setStorageConfig as setStorageConfigApi\n} from '../api/satellite.api';\nimport {\n fromAuthenticationConfig,\n fromDatastoreConfig,\n fromStorageConfig,\n toAuthenticationConfig,\n toDatastoreConfig,\n toStorageConfig\n} from '../utils/config.utils';\n\n/**\n * Sets the configuration for the Storage of a Satellite.\n * @param {Object} params - The parameters for setting the configuration.\n * @param {Object} params.config - The storage configuration.\n * @param {Array<StorageConfigHeader>} params.config.headers - The headers configuration.\n * @param {Array<StorageConfigRewrite>} params.config.rewrites - The rewrites configuration.\n * @param {Array<StorageConfigRedirect>} params.config.redirects - The redirects configuration.\n * @param {string} params.config.iframe - The iframe configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves with the applied configuration when set.\n */\nexport const setStorageConfig = async ({\n config,\n satellite\n}: {\n config: Omit<StorageConfig, 'createdAt' | 'updatedAt'>;\n satellite: SatelliteParameters;\n}): Promise<StorageConfig> => {\n const result = await setStorageConfigApi({\n satellite,\n config: fromStorageConfig(config)\n });\n\n return toStorageConfig(result);\n};\n\n/**\n * Sets the datastore configuration for a satellite.\n * @param {Object} params - The parameters for setting the authentication configuration.\n * @param {Object} params.config - The datastore configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves with the config when the datastore configuration is set.\n */\nexport const setDatastoreConfig = async ({\n config,\n ...rest\n}: {\n config: Omit<DatastoreConfig, 'createdAt' | 'updatedAt'>;\n satellite: SatelliteParameters;\n}): Promise<DatastoreConfig> => {\n const result = await setDatastoreConfigApi({\n config: fromDatastoreConfig(config),\n ...rest\n });\n\n return toDatastoreConfig(result);\n};\n\n/**\n * Sets the authentication configuration for a satellite.\n * @param {Object} params - The parameters for setting the authentication configuration.\n * @param {Object} params.config - The authentication configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the authentication configuration is set.\n */\nexport const setAuthConfig = async ({\n config,\n ...rest\n}: {\n config: Omit<AuthenticationConfig, 'createdAt' | 'updatedAt'>;\n satellite: SatelliteParameters;\n}): Promise<AuthenticationConfig> => {\n const result = await setAuthConfigApi({\n config: fromAuthenticationConfig(config),\n ...rest\n });\n\n return toAuthenticationConfig(result);\n};\n\n/**\n * Gets the authentication configuration for a satellite.\n * @param {Object} params - The parameters for getting the authentication configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<AuthenticationConfig | undefined>} A promise that resolves to the authentication configuration or undefined if not found.\n */\nexport const getAuthConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<AuthenticationConfig | undefined> => {\n const result = await getAuthConfigApi({\n satellite\n });\n\n const config = fromNullable(result);\n\n if (isNullish(config)) {\n return undefined;\n }\n\n return toAuthenticationConfig(config);\n};\n\n/**\n * Gets the storage configuration for a satellite.\n * @param {Object} params - The parameters for getting the storage configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<StorageConfig | undefined>} A promise that resolves to the storage configuration or undefined if not found.\n */\nexport const getStorageConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<StorageConfig> => {\n const config = await getStorageConfigApi({\n satellite\n });\n\n return toStorageConfig(config);\n};\n\n/**\n * Gets the datastore configuration for a satellite.\n * @param {Object} params - The parameters for getting the datastore configuration.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<AuthenticationConfig | undefined>} A promise that resolves to the datastore configuration or undefined if not found.\n */\nexport const getDatastoreConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<DatastoreConfig | undefined> => {\n const result = await getDatastoreConfigApi({\n satellite\n });\n\n const config = fromNullable(result);\n\n if (isNullish(config)) {\n return undefined;\n }\n\n return toDatastoreConfig(config);\n};\n\n/**\n * Gets all the configuration for a satellite.\n * @param {Object} params - The parameters for getting the configurations.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<{storage: StorageConfig; datastore?: DatastoreConfig; auth?: AuthenticationConfig;}>} A promise that resolves to the configuration.\n */\nexport const getConfig = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<{\n storage: StorageConfig;\n datastore?: DatastoreConfig;\n auth?: AuthenticationConfig;\n}> => {\n const {storage, db, authentication} = await getConfigApi({\n satellite\n });\n\n const datastore = fromNullable(db);\n const auth = fromNullable(authentication);\n\n return {\n storage: toStorageConfig(storage),\n ...(nonNullish(datastore) && {datastore: toDatastoreConfig(datastore)}),\n ...(nonNullish(auth) && {auth: toAuthenticationConfig(auth)})\n };\n};\n", "import {Principal} from '@icp-sdk/core/principal';\nimport {fromNullable, isNullish, nonNullish, toNullable} from '@dfinity/utils';\nimport type {\n AuthenticationConfig,\n DatastoreConfig,\n StorageConfig,\n StorageConfigHeader,\n StorageConfigRedirect,\n StorageConfigRewrite\n} from '@junobuild/config';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\nimport {fromMaxMemorySize, toMaxMemorySize} from './memory.utils';\n\nexport const fromStorageConfig = ({\n headers: configHeaders,\n rewrites: configRewrites,\n redirects: configRedirects,\n iframe: configIFrame,\n rawAccess: configRawAccess,\n maxMemorySize: configMaxMemorySize,\n version: configVersion\n}: StorageConfig): SatelliteDid.SetStorageConfig => {\n const headers: [string, [string, string][]][] = (configHeaders ?? []).map(\n ({source, headers}: StorageConfigHeader) => [source, headers]\n );\n\n const rewrites: [string, string][] = (configRewrites ?? []).map(\n ({source, destination}: StorageConfigRewrite) => [source, destination]\n );\n\n const redirects: [string, SatelliteDid.StorageConfigRedirect][] = (configRedirects ?? []).map(\n ({source, location, code}: StorageConfigRedirect) => [source, {status_code: code, location}]\n );\n\n const iframe: SatelliteDid.StorageConfigIFrame =\n configIFrame === 'same-origin'\n ? {SameOrigin: null}\n : configIFrame === 'allow-any'\n ? {AllowAny: null}\n : {Deny: null};\n\n const rawAccess: SatelliteDid.StorageConfigRawAccess =\n configRawAccess === true ? {Allow: null} : {Deny: null};\n\n return {\n headers,\n rewrites,\n redirects: [redirects],\n iframe: [iframe],\n raw_access: [rawAccess],\n max_memory_size: toMaxMemorySize(configMaxMemorySize),\n version: toNullable(configVersion)\n };\n};\n\nexport const toStorageConfig = ({\n redirects: redirectsDid,\n iframe: iframeDid,\n version,\n raw_access: rawAccessDid,\n max_memory_size,\n headers: headersDid,\n rewrites: rewritesDid\n}: SatelliteDid.StorageConfig): StorageConfig => {\n const redirects = fromNullable(redirectsDid)?.map<StorageConfigRedirect>(\n ([source, {status_code: code, ...rest}]) => ({\n ...rest,\n code: code as 301 | 302,\n source\n })\n );\n\n const access = fromNullable(rawAccessDid);\n const rawAccess = nonNullish(access) ? 'Allow' in access : undefined;\n\n const frame = fromNullable(iframeDid);\n const iframe = nonNullish(frame)\n ? 'SameOrigin' in frame\n ? 'same-origin'\n : 'AllowAny' in frame\n ? 'allow-any'\n : 'deny'\n : undefined;\n\n const maxMemorySize = fromMaxMemorySize(max_memory_size);\n\n const headers = headersDid.map<StorageConfigHeader>(([source, headers]) => ({source, headers}));\n\n const rewrites = rewritesDid.map<StorageConfigRewrite>(([source, destination]) => ({\n source,\n destination\n }));\n\n return {\n ...(headers.length > 0 && {headers}),\n ...(rewrites.length > 0 && {rewrites}),\n ...(nonNullish(redirects) && {redirects}),\n ...(nonNullish(iframe) && {\n iframe\n }),\n version: fromNullable(version),\n ...(nonNullish(rawAccess) && {rawAccess}),\n ...maxMemorySize\n };\n};\n\nexport const fromDatastoreConfig = ({\n maxMemorySize,\n version\n}: DatastoreConfig): SatelliteDid.SetDbConfig => ({\n max_memory_size: toMaxMemorySize(maxMemorySize),\n version: toNullable(version)\n});\n\nexport const toDatastoreConfig = ({\n version,\n max_memory_size\n}: SatelliteDid.DbConfig): DatastoreConfig => ({\n ...fromMaxMemorySize(max_memory_size),\n version: fromNullable(version)\n});\n\nexport const fromAuthenticationConfig = ({\n internetIdentity,\n rules,\n version\n}: AuthenticationConfig): SatelliteDid.SetAuthenticationConfig => ({\n internet_identity: isNullish(internetIdentity)\n ? []\n : [\n {\n derivation_origin: toNullable(internetIdentity?.derivationOrigin),\n external_alternative_origins: toNullable(internetIdentity?.externalAlternativeOrigins)\n }\n ],\n rules: isNullish(rules)\n ? []\n : [\n {\n allowed_callers: rules.allowedCallers.map((caller) => Principal.fromText(caller))\n }\n ],\n version: toNullable(version)\n});\n\nexport const toAuthenticationConfig = ({\n version,\n internet_identity,\n rules: rulesDid\n}: SatelliteDid.AuthenticationConfig): AuthenticationConfig => {\n const internetIdentity = fromNullable(internet_identity);\n const derivationOrigin = fromNullable(internetIdentity?.derivation_origin ?? []);\n const externalAlternativeOrigins = fromNullable(\n internetIdentity?.external_alternative_origins ?? []\n );\n\n const rules = fromNullable(rulesDid);\n\n return {\n ...(nonNullish(internetIdentity) && {\n internetIdentity: {\n ...(nonNullish(derivationOrigin) && {derivationOrigin}),\n ...(nonNullish(externalAlternativeOrigins) && {externalAlternativeOrigins})\n }\n }),\n ...(nonNullish(rules) && {\n rules: {\n allowedCallers: rules.allowed_callers.map((caller) => caller.toText())\n }\n }),\n version: fromNullable(version)\n };\n};\n", "import {fromNullable, nonNullish, toNullable} from '@dfinity/utils';\nimport type {MaxMemorySizeConfig} from '@junobuild/config';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\n\nexport const toMaxMemorySize = (\n configMaxMemorySize?: MaxMemorySizeConfig\n): [] | [SatelliteDid.ConfigMaxMemorySize] =>\n toNullable(\n nonNullish(configMaxMemorySize) &&\n (nonNullish(toNullable(configMaxMemorySize.heap)) ||\n nonNullish(toNullable(configMaxMemorySize.stable)))\n ? {\n heap: toNullable(configMaxMemorySize.heap),\n stable: toNullable(configMaxMemorySize.stable)\n }\n : undefined\n );\n\nexport const fromMaxMemorySize = (\n configMaxMemorySize: [] | [SatelliteDid.ConfigMaxMemorySize]\n): {maxMemorySize?: MaxMemorySizeConfig} => {\n const memorySize = fromNullable(configMaxMemorySize);\n const heap = fromNullable(memorySize?.heap ?? []);\n const stable = fromNullable(memorySize?.stable ?? []);\n\n return {\n ...(nonNullish(memorySize) &&\n (nonNullish(heap) || nonNullish(stable)) && {\n maxMemorySize: {\n ...(nonNullish(heap) && {heap}),\n ...(nonNullish(stable) && {stable})\n }\n })\n };\n};\n", "import type {Principal} from '@icp-sdk/core/principal';\nimport type {SatelliteDid, SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {\n listControllers,\n listDeprecatedNoScopeControllers,\n setControllers\n} from '../api/satellite.api';\n/**\n * Lists the controllers of a satellite.\n * @param {Object} params - The parameters for listing the controllers.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {boolean} [params.deprecatedNoScope] - Whether to list deprecated no-scope controllers.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const listSatelliteControllers = ({\n deprecatedNoScope,\n ...params\n}: {\n satellite: SatelliteParameters;\n deprecatedNoScope?: boolean;\n}): Promise<[Principal, SatelliteDid.Controller][]> => {\n const list = deprecatedNoScope === true ? listDeprecatedNoScopeControllers : listControllers;\n return list(params);\n};\n\n/**\n * Sets the controllers of a satellite.\n * @param {Object} params - The parameters for setting the controllers.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {SetControllersArgs} params.args - The arguments for setting the controllers.\n * @returns {Promise<[Principal, Controller][]>} A promise that resolves to a list of controllers.\n */\nexport const setSatelliteControllers = (params: {\n satellite: SatelliteParameters;\n args: SatelliteDid.SetControllersArgs;\n}): Promise<[Principal, SatelliteDid.Controller][]> => setControllers(params);\n", "import type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {countDocs as countDocsApi, deleteDocs as deleteDocsApi} from '../api/satellite.api';\n\n/**\n * Counts the documents in a collection.\n * @param {Object} params - The parameters for counting the documents.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<bigint>} A promise that resolves to the number of documents in the collection.\n */\nexport const countDocs = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<bigint> => countDocsApi(params);\n\n/**\n * Deletes the documents in a collection.\n * @param {Object} params - The parameters for deleting the documents.\n * @param {string} params.collection - The name of the collection.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the documents are deleted.\n */\nexport const deleteDocs = (params: {\n collection: string;\n satellite: SatelliteParameters;\n}): Promise<void> => deleteDocsApi(params);\n", "import {fromNullable, nonNullish} from '@dfinity/utils';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {\n listCustomDomains as listCustomDomainsApi,\n setCustomDomain as setCustomDomainApi\n} from '../api/satellite.api';\nimport type {CustomDomain} from '../types/customdomain';\n\n/**\n * Lists the custom domains for a satellite.\n * @param {Object} params - The parameters for listing the custom domains.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<CustomDomain[]>} A promise that resolves to an array of custom domains.\n */\nexport const listCustomDomains = async ({\n satellite\n}: {\n satellite: SatelliteParameters;\n}): Promise<CustomDomain[]> => {\n const domains = await listCustomDomainsApi({\n satellite\n });\n\n return domains.map(([domain, details]) => {\n const domainVersion = fromNullable(details.version);\n\n return {\n domain,\n bn_id: fromNullable(details.bn_id),\n created_at: details.created_at,\n updated_at: details.updated_at,\n ...(nonNullish(domainVersion) && {version: domainVersion})\n };\n });\n};\n\n/**\n * Sets some custom domains for a satellite.\n * @param {Object} params - The parameters for setting the custom domains.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {Pick<CustomDomain, \"domain\" | \"bn_id\">}[] params.domains - The custom domains - name and optional BN ID - to set.\n * @returns {Promise<void[]>} A promise that resolves when the custom domains are set.\n */\nexport const setCustomDomains = ({\n satellite,\n domains\n}: {\n satellite: SatelliteParameters;\n domains: Pick<CustomDomain, 'domain' | 'bn_id'>[];\n}): Promise<void[]> =>\n Promise.all(\n domains.map(({domain: domainName, bn_id: boundaryNodesId}) =>\n setCustomDomainApi({\n satellite,\n domainName,\n boundaryNodesId\n })\n )\n );\n\n/**\n * Sets a custom domain for a satellite.\n * @param {Object} params - The parameters for setting the custom domain.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @param {Pick<CustomDomain, \"domain\" | \"bn_id\">} params.domain - The custom domain name and optional BN ID to set.\n * @returns {Promise<void>} A promise that resolves when the custom domain is set.\n */\nexport const setCustomDomain = ({\n satellite,\n domain\n}: {\n satellite: SatelliteParameters;\n domain: Pick<CustomDomain, 'domain' | 'bn_id'>;\n}): Promise<void> =>\n setCustomDomainApi({\n satellite,\n domainName: domain.domain,\n boundaryNodesId: domain.bn_id\n });\n", "import type {SatelliteDid, SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {memorySize} from '../api/satellite.api';\n\n/**\n * Retrieves the stable and heap memory size of a satellite.\n * @param {Object} params - The parameters for retrieving the memory size.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<MemorySize>} A promise that resolves to the memory size of the satellite.\n */\nexport const satelliteMemorySize = (params: {\n satellite: SatelliteParameters;\n}): Promise<SatelliteDid.MemorySize> => memorySize(params);\n", "import {fromNullable, isNullish, nonNullish, toNullable} from '@dfinity/utils';\nimport type {MemoryText, PermissionText, Rule, RulesType} from '@junobuild/config';\nimport type {SatelliteDid} from '@junobuild/ic-client/actor';\nimport {\n DbRulesType,\n DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS,\n MemoryHeap,\n MemoryStable,\n PermissionControllers,\n PermissionManaged,\n PermissionPrivate,\n PermissionPublic,\n StorageRulesType\n} from '../constants/rules.constants';\nimport type {ListRulesMatcher} from '../types/list';\n\nexport const fromRuleType = (type: RulesType): SatelliteDid.CollectionType =>\n type === 'storage' ? StorageRulesType : DbRulesType;\n\nexport const fromRulesFilter = (filter?: ListRulesMatcher): SatelliteDid.ListRulesParams => ({\n matcher: isNullish(filter)\n ? toNullable()\n : toNullable({\n include_system: filter.include_system\n })\n});\n\nexport const fromRule = ({\n read,\n write,\n memory,\n maxSize,\n maxChangesPerUser,\n maxCapacity,\n version,\n mutablePermissions,\n maxTokens\n}: Pick<\n Rule,\n | 'read'\n | 'write'\n | 'maxSize'\n | 'maxChangesPerUser'\n | 'maxCapacity'\n | 'version'\n | 'memory'\n | 'mutablePermissions'\n | 'maxTokens'\n>): SatelliteDid.SetRule => ({\n read: permissionFromText(read),\n write: permissionFromText(write),\n memory: nonNullish(memory) ? [memoryFromText(memory)] : [],\n version: toNullable(version),\n max_size: toNullable(nonNullish(maxSize) && maxSize > 0n ? maxSize : undefined),\n max_capacity: toNullable(nonNullish(maxCapacity) && maxCapacity > 0 ? maxCapacity : undefined),\n max_changes_per_user: toNullable(\n nonNullish(maxChangesPerUser) && maxChangesPerUser > 0 ? maxChangesPerUser : undefined\n ),\n mutable_permissions: toNullable(mutablePermissions ?? true),\n rate_config:\n nonNullish(maxTokens) && maxTokens > 0n\n ? [\n {\n max_tokens: maxTokens,\n time_per_token_ns: DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS\n }\n ]\n : []\n});\n\nexport const toRule = ([collection, rule]: [string, SatelliteDid.Rule]): Rule => {\n const {\n read,\n write,\n updated_at,\n created_at,\n max_size,\n max_changes_per_user,\n max_capacity,\n memory,\n mutable_permissions,\n version,\n rate_config\n } = rule;\n\n const maxSize = (max_size?.[0] ?? 0n > 0n) ? fromNullable(max_size) : undefined;\n const maxChangesPerUser =\n (max_changes_per_user?.[0] ?? 0 > 0) ? fromNullable(max_changes_per_user) : undefined;\n const maxCapacity = (max_capacity?.[0] ?? 0 > 0) ? fromNullable(max_capacity) : undefined;\n\n const ruleVersion = fromNullable(version);\n\n const maxTokens =\n (rate_config?.[0]?.max_tokens ?? 0n > 0n) ? fromNullable(rate_config)?.max_tokens : undefined;\n\n return {\n collection,\n read: permissionToText(read),\n write: permissionToText(write),\n memory: memoryToText(fromNullable(memory) ?? MemoryHeap),\n updatedAt: updated_at,\n createdAt: created_at,\n ...(nonNullish(ruleVersion) && {version: ruleVersion}),\n ...(nonNullish(maxChangesPerUser) && {maxChangesPerUser}),\n ...(nonNullish(maxSize) && {maxSize}),\n ...(nonNullish(maxCapacity) && {maxCapacity}),\n mutablePermissions: fromNullable(mutable_permissions) ?? true,\n ...(nonNullish(maxTokens) && {maxTokens})\n };\n};\n\nexport const permissionToText = (permission: SatelliteDid.Permission): PermissionText => {\n if ('Public' in permission) {\n return 'public';\n }\n\n if ('Private' in permission) {\n return 'private';\n }\n\n if ('Managed' in permission) {\n return 'managed';\n }\n\n return 'controllers';\n};\n\nconst permissionFromText = (text: PermissionText): SatelliteDid.Permission => {\n switch (text) {\n case 'public':\n return PermissionPublic;\n case 'private':\n return PermissionPrivate;\n case 'managed':\n return PermissionManaged;\n default:\n return PermissionControllers;\n }\n};\n\nexport const memoryFromText = (text: MemoryText): SatelliteDid.Memory => {\n switch (text.toLowerCase()) {\n case 'heap':\n return MemoryHeap;\n default:\n return MemoryStable;\n }\n};\n\nexport const memoryToText = (memory: SatelliteDid.Memory): MemoryText => {\n if ('Heap' in memory) {\n return 'heap';\n }\n\n return 'stable';\n};\n", "import type {SatelliteDid} from '@junobuild/ic-client/actor';\n\nexport const DbRulesType: SatelliteDid.CollectionType = {Db: null};\nexport const StorageRulesType: SatelliteDid.CollectionType = {Storage: null};\n\nexport const PermissionPublic: SatelliteDid.Permission = {Public: null};\nexport const PermissionPrivate: SatelliteDid.Permission = {Private: null};\nexport const PermissionManaged: SatelliteDid.Permission = {Managed: null};\nexport const PermissionControllers: SatelliteDid.Permission = {Controllers: null};\n\nexport const MemoryHeap: SatelliteDid.Memory = {Heap: null};\nexport const MemoryStable: SatelliteDid.Memory = {Stable: null};\n\nexport const DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS = 600_000_000n;\n", "import type {Rule, RulesType} from '@junobuild/config';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {listRules as listRulesApi, setRule as setRuleApi} from '../api/satellite.api';\nimport type {ListRulesMatcher, ListRulesResults} from '../types/list';\nimport {fromRule, fromRulesFilter, fromRuleType, toRule} from '../utils/rule.utils';\n\n/**\n * Lists the rules for a satellite.\n * @param {Object} params - The parameters for listing the rules.\n * @param {RulesType} params.type - The type of rules to list.\n * @param {ListRulesMatcher} params.filter - The optional filter for the query.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<ListRulesResults>} A promise that resolves to the resolved rules.\n */\nexport const listRules = async ({\n type,\n satellite,\n filter\n}: {\n type: RulesType;\n filter?: ListRulesMatcher;\n satellite: SatelliteParameters;\n}): Promise<ListRulesResults> => {\n const {items, ...rest} = await listRulesApi({\n satellite,\n type: fromRuleType(type),\n filter: fromRulesFilter(filter)\n });\n\n return {\n ...rest,\n items: items.map((rule) => toRule(rule))\n };\n};\n\n/**\n * Sets a rule for a satellite.\n * @param {Object} params - The parameters for setting the rule.\n * @param {Rule} params.rule - The rule to set.\n * @param {RulesType} params.type - The type of rule.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<void>} A promise that resolves when the rule is set.\n */\nexport const setRule = async ({\n rule: {collection, ...rest},\n type,\n satellite\n}: {\n rule: Rule;\n type: RulesType;\n satellite: SatelliteParameters;\n}): Promise<Rule> => {\n const result = await setRuleApi({\n type: fromRuleType(type),\n rule: fromRule(rest),\n satellite,\n collection\n });\n\n return toRule([collection, result]);\n};\n", "import {IDL} from '@icp-sdk/core/candid';\nimport {isNullish} from '@dfinity/utils';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {toPrincipal} from '@junobuild/ic-client/utils';\nimport {\n listControllers,\n listDeprecatedControllers,\n listDeprecatedNoScopeControllers\n} from '../api/satellite.api';\nimport {INSTALL_MODE_RESET, INSTALL_MODE_UPGRADE} from '../constants/upgrade.constants';\nimport {upgrade} from '../handlers/upgrade.handlers';\nimport type {UpgradeCodeParams} from '../types/upgrade';\nimport {encodeAdminAccessKeysToIDL} from '../utils/idl.utils';\n\n/**\n * Upgrades a satellite with the provided WASM module.\n * @param {Object} params - The parameters for upgrading the satellite.\n * @param {SatelliteParameters} params.satellite - The satellite parameters, including the actor and satellite ID.\n * @param {Principal} [params.missionControlId] - Optional. The Mission Control ID to potentially store WASM chunks, enabling reuse across installations.\n * @param {Uint8Array} params.wasmModule - The WASM module to be installed during the upgrade.\n * @param {boolean} params.deprecated - Indicates whether the upgrade is deprecated.\n * @param {boolean} params.deprecatedNoScope - Indicates whether the upgrade is deprecated and has no scope.\n * @param {boolean} [params.reset=false] - Optional. Specifies whether to reset the satellite (reinstall) instead of performing an upgrade. Defaults to `false`.\n * @param {boolean} [params.preClearChunks] - Optional. Forces clearing existing chunks before uploading a chunked WASM module. Recommended if the WASM exceeds 2MB.\n * @param {boolean} [params.takeSnapshot=true] - Optional. Whether to take a snapshot before performing the upgrade. Defaults to true.\n * @param {function} [params.onProgress] - Optional. Callback function to track progress during the upgrade process.\n * @throws {Error} Will throw an error if the satellite parameters are invalid or missing required fields.\n * @returns {Promise<void>} Resolves when the upgrade process is complete.\n */\nexport const upgradeSatellite = async ({\n satellite,\n deprecated,\n deprecatedNoScope,\n reset = false,\n ...rest\n}: {\n satellite: SatelliteParameters;\n deprecated: boolean;\n deprecatedNoScope: boolean;\n reset?: boolean;\n} & Pick<\n UpgradeCodeParams,\n 'wasmModule' | 'missionControlId' | 'preClearChunks' | 'takeSnapshot' | 'onProgress'\n>): Promise<void> => {\n const {satelliteId, ...actor} = satellite;\n\n if (isNullish(satelliteId)) {\n throw new Error('No satellite principal defined.');\n }\n\n // TODO: remove agent-js \"type mismatch: type on the wire principal\"\n if (deprecated) {\n const controllers = await listDeprecatedControllers({satellite});\n\n const arg = IDL.encode(\n [\n IDL.Record({\n controllers: IDL.Vec(IDL.Principal)\n })\n ],\n [{controllers}]\n );\n\n await upgrade({\n actor,\n canisterId: toPrincipal(satelliteId),\n arg: new Uint8Array(arg),\n mode: reset ? INSTALL_MODE_RESET : INSTALL_MODE_UPGRADE,\n reset,\n ...rest\n });\n\n return;\n }\n\n const list = deprecatedNoScope ? listDeprecatedNoScopeControllers : listControllers;\n\n // We pass the controllers to the upgrade but, it's just for the state of the art when upgrading because I don't want to call the install without passing args. The module's post_upgrade do not consider the init parameters.\n // On the contrary those are useful on --reset\n const controllers = await list({satellite, certified: reset});\n\n const arg = encodeAdminAccessKeysToIDL(controllers);\n\n await upgrade({\n actor,\n canisterId: toPrincipal(satelliteId),\n arg,\n mode: reset ? INSTALL_MODE_RESET : INSTALL_MODE_UPGRADE,\n reset,\n ...rest\n });\n};\n", "import {assertNonNullish, isNullish, nonNullish} from '@dfinity/utils';\nimport {JUNO_PACKAGE_SATELLITE_ID} from '@junobuild/config';\nimport type {SatelliteParameters} from '@junobuild/ic-client/actor';\nimport {canisterMetadata} from '../api/ic.api';\nimport {version} from '../api/satellite.api';\nimport {SatelliteMissingDependencyError} from '../errors/version.errors';\nimport {findJunoPackageDependency} from '../helpers/package.helpers';\nimport type {BuildType} from '../schemas/build';\nimport {getJunoPackage} from './package.services';\n\n/**\n * Retrieves the version of the satellite.\n * @param {Object} params - The parameters for retrieving the version.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<string>} A promise that resolves to the version of the satellite.\n */\nexport const satelliteVersion = async ({\n satellite: {satelliteId, ...rest}\n}: {\n satellite: SatelliteParameters;\n}): Promise<string> => {\n assertNonNullish(satelliteId, 'A Satellite ID must be provided to request its version.');\n\n const pkg = await getJunoPackage({\n moduleId: satelliteId,\n ...rest\n });\n\n // For backwards compatibility with legacy. Function version() was deprecated in Satellite > v0.0.22\n if (isNullish(pkg)) {\n return await version({satellite: {satelliteId, ...rest}});\n }\n\n const {name, version: satelliteVersion, dependencies} = pkg;\n\n if (name === JUNO_PACKAGE_SATELLITE_ID) {\n return satelliteVersion;\n }\n\n const satelliteDependency = findJunoPackageDependency({\n dependencies,\n dependencyId: JUNO_PACKAGE_SATELLITE_ID\n });\n\n if (nonNullish(satelliteDependency)) {\n const [_, satelliteVersion] = satelliteDependency;\n return satelliteVersion;\n }\n\n throw new SatelliteMissingDependencyError();\n};\n\n/**\n * Retrieves the build type of the satellite.\n * @param {Object} params - The parameters for retrieving the build type.\n * @param {SatelliteParameters} params.satellite - The satellite parameters.\n * @returns {Promise<BuildType | undefined>} A promise that resolves to the build type of the satellite or undefined if not found.\n */\nexport const satelliteBuildType = async ({\n satellite: {satelliteId, ...rest}\n}: {\n satellite: SatelliteParameters;\n}): Promise<BuildType | undefined> => {\n assertNonNullish(satelliteId, 'A Satellite ID must be provided to request its version.');\n\n const pkg = await getJunoPackage({\n moduleId: satelliteId,\n ...rest\n });\n\n if (isNullish(pkg)) {\n return await satelliteDeprecatedBuildType({satellite: {satelliteId, ...rest}});\n }\n\n const {name, dependencies} = pkg;\n\n if (name === JUNO_PACKAGE_SATELLITE_ID) {\n return 'stock';\n }\n\n const satelliteDependency = findJunoPackageDependency({\n dependencies,\n dependencyId: JUNO_PACKAGE_SATELLITE_ID\n });\n\n if (nonNullish(satelliteDependency)) {\n return 'extended';\n }\n\n throw new SatelliteMissingDependencyError();\n};\n\n/**\n * @deprecated Replaced in Satellite > v0.0.22\n */\nconst satelliteDeprecatedBuildType = async ({\n satellite: {satelliteId, ...rest}\n}: {\n satellite: Omit<SatelliteParameters, 'satelliteId'> &\n Required<Pick<SatelliteParameters, 'satelliteId'>>;\n}): Promise<BuildType | undefined> => {\n const status = await canisterMetadata({...rest, canisterId: satelliteId, path: 'juno:build'});\n\n return nonNullish(status) && ['stock', 'extended'].includes(status as string)\n ? (status as BuildType)\n : undefined;\n};\n"],
5
+ "mappings": "AAAO,IAAMA,EAAN,cAAwC,KAAM,CACnD,aAAc,CACZ,MACE,sGACF,CACF,CACF,ECNA,OACE,mCAAAC,GACA,2BAAAC,GACA,6BAAAC,OACK,oBAEA,IAAMC,EAAN,cAA8C,KAAM,CACzD,aAAc,CACZ,MAAM,4CAA4CD,EAAyB,cAAc,CAC3F,CACF,EAEaE,EAAN,cAAyC,KAAM,CACpD,aAAc,CACZ,MAAM,oDAAoDJ,EAA+B,GAAG,CAC9F,CACF,EAEaK,EAAN,cAAkC,KAAM,CAC7C,aAAc,CACZ,MAAM,oDAAoDJ,EAAuB,GAAG,CACtF,CACF,EClBA,IAAMK,GAAgBC,GACpB,OAAO,OAAO,OAAO,UAAWA,CAAI,EAEhCC,GAAeC,GACD,MAAM,KAAK,IAAI,WAAWA,CAAU,CAAC,EACtC,IAAKC,GAAMA,EAAE,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAAE,KAAK,EAAE,EAGzDC,GAAa,MAAOC,GAAgC,CAC/D,IAAMH,EAAa,MAAMH,GAAa,MAAMM,EAAK,YAAY,CAAC,EAC9D,OAAOJ,GAAYC,CAAU,CAC/B,EAEaI,EAA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AY,CAAC,EAE5F,OAAOY,GAAWK,CAAM,GAAK,CAAC,QAAS,UAAU,EAAE,SAASA,CAAgB,EACvEA,EACD,MACN",
6
6
  "names": ["UpgradeCodeUnchangedError", "JUNO_PACKAGE_MISSION_CONTROL_ID", "JUNO_PACKAGE_ORBITER_ID", "JUNO_PACKAGE_SATELLITE_ID", "SatelliteMissingDependencyError", "MissionControlVersionError", "OrbiterVersionError", "digestSha256", "data", "sha256ToHex", "hashBuffer", "b", "blobSha256", "blob", "uint8ArraySha256", "findJunoPackageDependency", "dependencyId", "dependencies", "key", "_", "major", "minor", "patch", "checkUpgradeVersion", "currentVersion", "selectedVersion", "currentMajor", "selectedMajor", "currentMinor", "selectedMinor", "currentPath", "selectedPath", "isNullish", "nonNullish", "JUNO_PACKAGE_SATELLITE_ID", "JunoPackageSchema", "extractBuildType", "junoPackage", "wasm", "isNullish", "readDeprecatedBuildType", "name", "dependencies", "JUNO_PACKAGE_SATELLITE_ID", "satelliteDependency", "findJunoPackageDependency", "nonNullish", "buildType", "customSection", "readCustomSectionJunoPackage", "section", "pkg", "success", "data", "JunoPackageSchema", "sectionName", "wasmModule", "pkgSections", "pkgBuffer", "z", "BuildTypeSchema", "z", "MetadataVersionSchema", "val", "ReleaseMetadataSchema", "ReleasesSchema", "releases", "tag", "MetadataVersionsSchema", "ReleasesMetadataSchema", "getDeprecatedMissionControlVersionActor", "getMissionControlActor", "version", "missionControl", "getUser", "get_user", "listControllers", "list_mission_control_controllers", "setSatellitesController", "satelliteIds", "controllerIds", "controller", "set_satellites_controllers", "setMissionControlController", "set_mission_control_controllers", "Principal", "nonNullish", "toNullable", "mapSetControllerParams", "controllerId", "profile", "toSetController", "setSatellitesController", "controllerId", "profile", "rest", "mapSetControllerParams", "setMissionControlController", "listMissionControlControllers", "params", "listControllers", "toPrincipal", "INSTALL_MODE_RESET", "INSTALL_MODE_UPGRADE", "fromNullable", "isNullish", "uint8ArrayToHexString", "CanisterStatus", "ICManagementCanister", "Principal", "useOrInitAgent", "canisterStop", "canisterId", "actor", "agent", "stopCanister", "canisterStart", "startCanister", "installCode", "code", "storedChunks", "clearChunkStore", "uploadChunk", "chunk", "installChunkedCode", "canisterStatus", "canisterMetadata", "path", "rest", "hideAgentJsConsoleWarn", "result", "listCanisterSnapshots", "takeCanisterSnapshot", "UpgradeCodeProgressStep", "isNullish", "nonNullish", "uint8ArrayToHexString", "upgradeChunkedCode", "actor", "canisterId", "missionControlId", "wasmModule", "userPreClearChunks", "rest", "clearChunkStore", "wasmChunks", "wasmToChunks", "uploadChunks", "storedChunks", "preClearChunks", "postClearChunks", "prepareUpload", "chunkIds", "results", "batchUploadChunks", "installChunkedCode", "orderIdA", "orderIdB", "chunkHash", "uint8ArraySha256", "blob", "chunkSize", "orderId", "start", "chunk", "blobSha256", "stored", "existingStoredChunks", "hash", "uint8ArrayToHexString", "sha256", "existingStoredChunk", "storedSha256", "nonNullish", "isNullish", "limit", "i", "batch", "uploadChunkParams", "uploadChunk", "upgradeSingleChunkCode", "actor", "rest", "installCode", "upgrade", "wasmModule", "canisterId", "actor", "onProgress", "takeSnapshot", "rest", "execute", "assertExistingCode", "canisterStop", "createSnapshot", "upgradeCode", "canisterStart", "fn", "step", "err", "reset", "module_hash", "canisterStatus", "installedHash", "fromNullable", "isNullish", "newWasmModuleHash", "uint8ArraySha256", "existingWasmModuleHash", "uint8ArrayToHexString", "UpgradeCodeUnchangedError", "upgradeChunkedCode", "upgradeSingleChunkCode", "params", "snapshots", "listCanisterSnapshots", "takeCanisterSnapshot", "IDL", "encoreIDLUser", "user", "encodeAdminAccessKeysToIDL", "controllers", "_", "scope", "controller", "upgradeMissionControl", "missionControl", "rest", "user", "getUser", "missionControlId", "actor", "arg", "encoreIDLUser", "upgrade", "toPrincipal", "INSTALL_MODE_UPGRADE", "assertNonNullish", "isNullish", "JUNO_PACKAGE_MISSION_CONTROL_ID", "isNullish", "JunoPackageSchema", "z", "getJunoPackage", "moduleId", "rest", "status", "canisterMetadata", "isNullish", "content", "str", "ctx", "JunoPackageSchema", "getJunoPackageVersion", "params", "getJunoPackageDependencies", "missionControlVersion", "missionControlId", "rest", "assertNonNullish", "pkg", "getJunoPackage", "isNullish", "version", "name", "JUNO_PACKAGE_MISSION_CONTROL_ID", "MissionControlVersionError", "upgradeModule", "params", "upgrade", "getDeprecatedOrbiterVersionActor", "getOrbiterActor", "version", "orbiter", "listControllers", "certified", "list_controllers", "memorySize", "memory_size", "listOrbiterControllers", "params", "listControllers", "orbiterMemorySize", "params", "memorySize", "toPrincipal", "upgradeOrbiter", "orbiter", "reset", "rest", "orbiterId", "actor", "controllers", "listControllers", "arg", "encodeAdminAccessKeysToIDL", "upgrade", "toPrincipal", "INSTALL_MODE_RESET", "INSTALL_MODE_UPGRADE", "assertNonNullish", "isNullish", "JUNO_PACKAGE_ORBITER_ID", "orbiterVersion", "orbiterId", "rest", "assertNonNullish", "pkg", "getJunoPackage", "isNullish", "version", "name", "missionControlVersion", "JUNO_PACKAGE_ORBITER_ID", "OrbiterVersionError", "toNullable", "getDeprecatedSatelliteActor", "getDeprecatedSatelliteNoScopeActor", "getDeprecatedSatelliteVersionActor", "getSatelliteActor", "setStorageConfig", "config", "satellite", "set_storage_config", "setDatastoreConfig", "set_db_config", "setAuthConfig", "set_auth_config", "getStorageConfig", "get_storage_config", "getDatastoreConfig", "get_db_config", "getAuthConfig", "get_auth_config", "getConfig", "get_config", "listRules", "type", "filter", "list_rules", "setRule", "collection", "rule", "set_rule", "version", "listDeprecatedControllers", "list_controllers", "listDeprecatedNoScopeControllers", "listControllers", "certified", "listCustomDomains", "list_custom_domains", "setCustomDomain", "domainName", "boundaryNodesId", "set_custom_domain", "memorySize", "memory_size", "countDocs", "count_collection_docs", "countAssets", "count_collection_assets", "deleteDocs", "del_docs", "deleteAssets", "del_assets", "setControllers", "args", "set_controllers", "countAssets", "params", "deleteAssets", "fromNullable", "isNullish", "nonNullish", "Principal", "fromNullable", "isNullish", "nonNullish", "toNullable", "fromNullable", "nonNullish", "toNullable", "toMaxMemorySize", "configMaxMemorySize", "fromMaxMemorySize", "memorySize", "heap", "stable", "fromStorageConfig", "configHeaders", "configRewrites", "configRedirects", "configIFrame", "configRawAccess", "configMaxMemorySize", "configVersion", "headers", "source", "rewrites", "destination", "redirects", "location", "code", "toMaxMemorySize", "toNullable", "toStorageConfig", "redirectsDid", "iframeDid", "version", "rawAccessDid", "max_memory_size", "headersDid", "rewritesDid", "fromNullable", "rest", "access", "rawAccess", "nonNullish", "frame", "iframe", "maxMemorySize", "fromMaxMemorySize", "fromDatastoreConfig", "toDatastoreConfig", "fromAuthenticationConfig", "internetIdentity", "rules", "isNullish", "caller", "Principal", "toAuthenticationConfig", "internet_identity", "rulesDid", "derivationOrigin", "externalAlternativeOrigins", "setStorageConfig", "config", "satellite", "result", "fromStorageConfig", "toStorageConfig", "setDatastoreConfig", "rest", "fromDatastoreConfig", "toDatastoreConfig", "setAuthConfig", "fromAuthenticationConfig", "toAuthenticationConfig", "getAuthConfig", "fromNullable", "isNullish", "getStorageConfig", "getDatastoreConfig", "getConfig", "storage", "db", "authentication", "datastore", "auth", "nonNullish", "listSatelliteControllers", "deprecatedNoScope", "params", "listDeprecatedNoScopeControllers", "listControllers", "setSatelliteControllers", "setControllers", "countDocs", "params", "deleteDocs", "fromNullable", "nonNullish", "listCustomDomains", "satellite", "domain", "details", "domainVersion", "fromNullable", "nonNullish", "setCustomDomains", "domains", "domainName", "boundaryNodesId", "setCustomDomain", "satelliteMemorySize", "params", "memorySize", "fromNullable", "isNullish", "nonNullish", "toNullable", "DbRulesType", "StorageRulesType", "PermissionPublic", "PermissionPrivate", "PermissionManaged", "PermissionControllers", "MemoryHeap", "MemoryStable", "DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS", "fromRuleType", "type", "StorageRulesType", "DbRulesType", "fromRulesFilter", "filter", "isNullish", "toNullable", "fromRule", "read", "write", "memory", "maxSize", "maxChangesPerUser", "maxCapacity", "version", "mutablePermissions", "maxTokens", "permissionFromText", "nonNullish", "memoryFromText", "DEFAULT_RATE_CONFIG_TIME_PER_TOKEN_NS", "toRule", "collection", "rule", "updated_at", "created_at", "max_size", "max_changes_per_user", "max_capacity", "mutable_permissions", "rate_config", "fromNullable", "ruleVersion", "permissionToText", "memoryToText", "MemoryHeap", "permission", "text", "PermissionPublic", "PermissionPrivate", "PermissionManaged", "PermissionControllers", "MemoryStable", "listRules", "type", "satellite", "filter", "items", "rest", "fromRuleType", "fromRulesFilter", "rule", "toRule", "setRule", "collection", "result", "fromRule", "IDL", "isNullish", "toPrincipal", "upgradeSatellite", "satellite", "deprecated", "deprecatedNoScope", "reset", "rest", "satelliteId", "actor", "isNullish", "controllers", "listDeprecatedControllers", "arg", "IDL", "upgrade", "toPrincipal", "INSTALL_MODE_RESET", "INSTALL_MODE_UPGRADE", "listDeprecatedNoScopeControllers", "listControllers", "encodeAdminAccessKeysToIDL", "assertNonNullish", "isNullish", "nonNullish", "JUNO_PACKAGE_SATELLITE_ID", "satelliteVersion", "satelliteId", "rest", "assertNonNullish", "pkg", "getJunoPackage", "isNullish", "version", "name", "dependencies", "JUNO_PACKAGE_SATELLITE_ID", "satelliteDependency", "findJunoPackageDependency", "nonNullish", "_", "SatelliteMissingDependencyError", "satelliteBuildType", "satelliteDeprecatedBuildType", "status", "canisterMetadata"]
7
7
  }