@lakutata/containerd 0.0.0-stage → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +409 -2
- package/THIRD_PARTY_NOTICES.md +310 -0
- package/dist/cjs/client/BuildKit.d.ts +176 -0
- package/dist/cjs/client/BuildKit.js +536 -0
- package/dist/cjs/client/BuildKitMessages.d.ts +35 -0
- package/dist/cjs/client/BuildKitMessages.js +123 -0
- package/dist/cjs/client/ContainerStore.d.ts +558 -0
- package/dist/cjs/client/ContainerStore.js +1384 -0
- package/dist/cjs/client/ContainerdClient.d.ts +244 -0
- package/dist/cjs/client/ContainerdClient.js +455 -0
- package/dist/cjs/client/DockerIgnore.d.ts +44 -0
- package/dist/cjs/client/DockerIgnore.js +186 -0
- package/dist/cjs/client/Fifo.d.ts +31 -0
- package/dist/cjs/client/Fifo.js +66 -0
- package/dist/cjs/client/ImageStore.d.ts +258 -0
- package/dist/cjs/client/ImageStore.js +636 -0
- package/dist/cjs/client/Messages.d.ts +103 -0
- package/dist/cjs/client/Messages.js +397 -0
- package/dist/cjs/client/Networks.d.ts +221 -0
- package/dist/cjs/client/Networks.js +630 -0
- package/dist/cjs/client/Platforms.d.ts +53 -0
- package/dist/cjs/client/Platforms.js +169 -0
- package/dist/cjs/client/Reference.d.ts +33 -0
- package/dist/cjs/client/Reference.js +70 -0
- package/dist/cjs/client/Registry.d.ts +145 -0
- package/dist/cjs/client/Registry.js +272 -0
- package/dist/cjs/client/Rootfs.d.ts +83 -0
- package/dist/cjs/client/Rootfs.js +245 -0
- package/dist/cjs/client/Seccomp.d.ts +36 -0
- package/dist/cjs/client/Seccomp.js +156 -0
- package/dist/cjs/client/Spec.d.ts +151 -0
- package/dist/cjs/client/Spec.js +227 -0
- package/dist/cjs/client/Volumes.d.ts +42 -0
- package/dist/cjs/client/Volumes.js +80 -0
- package/dist/cjs/containerd/Containerd.d.ts +442 -0
- package/dist/cjs/containerd/Containerd.js +929 -0
- package/dist/cjs/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdConnectionException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.js +17 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageExportException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageImportException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePullException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePushException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdPlatformException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.js +15 -0
- package/dist/cjs/containerd/lib/ContainerdContainer.d.ts +292 -0
- package/dist/cjs/containerd/lib/ContainerdContainer.js +536 -0
- package/dist/cjs/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
- package/dist/cjs/containerd/lib/ContainerdContainerTTY.js +178 -0
- package/dist/cjs/containerd/lib/ContainerdErrors.d.ts +6 -0
- package/dist/cjs/containerd/lib/ContainerdErrors.js +37 -0
- package/dist/cjs/containerd/lib/ContainerdImage.d.ts +149 -0
- package/dist/cjs/containerd/lib/ContainerdImage.js +222 -0
- package/dist/cjs/containerd/options/ContainerdPruneOptions.d.ts +44 -0
- package/dist/cjs/containerd/options/ContainerdPruneOptions.js +51 -0
- package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
- package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.js +45 -0
- package/dist/cjs/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
- package/dist/cjs/containerd/options/container/ContainerCommitOptions.js +66 -0
- package/dist/cjs/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
- package/dist/cjs/containerd/options/container/ContainerCreateOptions.js +239 -0
- package/dist/cjs/containerd/options/container/ContainerExecOptions.d.ts +53 -0
- package/dist/cjs/containerd/options/container/ContainerExecOptions.js +63 -0
- package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
- package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.js +45 -0
- package/dist/cjs/containerd/options/container/ContainerKillOptions.d.ts +30 -0
- package/dist/cjs/containerd/options/container/ContainerKillOptions.js +41 -0
- package/dist/cjs/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
- package/dist/cjs/containerd/options/container/ContainerLogsOptions.js +44 -0
- package/dist/cjs/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/cjs/containerd/options/container/ContainerRemoveOptions.js +34 -0
- package/dist/cjs/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
- package/dist/cjs/containerd/options/container/ContainerResourceOptions.js +67 -0
- package/dist/cjs/containerd/options/container/ContainerStopOptions.d.ts +30 -0
- package/dist/cjs/containerd/options/container/ContainerStopOptions.js +41 -0
- package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
- package/dist/cjs/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
- package/dist/cjs/containerd/options/container/ContainerTTYOptions.js +63 -0
- package/dist/cjs/containerd/options/image/ImageBuildOptions.d.ts +88 -0
- package/dist/cjs/containerd/options/image/ImageBuildOptions.js +95 -0
- package/dist/cjs/containerd/options/image/ImageExportOptions.d.ts +25 -0
- package/dist/cjs/containerd/options/image/ImageExportOptions.js +39 -0
- package/dist/cjs/containerd/options/image/ImageImportOptions.d.ts +38 -0
- package/dist/cjs/containerd/options/image/ImageImportOptions.js +47 -0
- package/dist/cjs/containerd/options/image/ImagePullOptions.d.ts +53 -0
- package/dist/cjs/containerd/options/image/ImagePullOptions.js +66 -0
- package/dist/cjs/containerd/options/image/ImagePushOptions.d.ts +44 -0
- package/dist/cjs/containerd/options/image/ImagePushOptions.js +58 -0
- package/dist/cjs/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
- package/dist/cjs/containerd/options/network/NetworkCreateOptions.js +83 -0
- package/dist/cjs/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
- package/dist/cjs/containerd/options/volume/VolumeCreateOptions.js +40 -0
- package/dist/cjs/containerd/types/ContainerdBind.d.ts +28 -0
- package/dist/cjs/containerd/types/ContainerdBind.js +2 -0
- package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
- package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
- package/dist/cjs/containerd/types/ContainerdContainerNetwork.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerPort.d.ts +22 -0
- package/dist/cjs/containerd/types/ContainerdContainerPort.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerState.d.ts +42 -0
- package/dist/cjs/containerd/types/ContainerdContainerState.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerStats.d.ts +107 -0
- package/dist/cjs/containerd/types/ContainerdContainerStats.js +2 -0
- package/dist/cjs/containerd/types/ContainerdDevice.d.ts +25 -0
- package/dist/cjs/containerd/types/ContainerdDevice.js +2 -0
- package/dist/cjs/containerd/types/ContainerdExecResult.d.ts +18 -0
- package/dist/cjs/containerd/types/ContainerdExecResult.js +2 -0
- package/dist/cjs/containerd/types/ContainerdImageConfig.d.ts +46 -0
- package/dist/cjs/containerd/types/ContainerdImageConfig.js +2 -0
- package/dist/cjs/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
- package/dist/cjs/containerd/types/ContainerdNetworkInfo.js +2 -0
- package/dist/cjs/containerd/types/ContainerdProgressCallback.d.ts +29 -0
- package/dist/cjs/containerd/types/ContainerdProgressCallback.js +2 -0
- package/dist/cjs/containerd/types/ContainerdPruneResult.d.ts +21 -0
- package/dist/cjs/containerd/types/ContainerdPruneResult.js +2 -0
- package/dist/cjs/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
- package/dist/cjs/containerd/types/ContainerdRestartPolicy.js +2 -0
- package/dist/cjs/containerd/types/ContainerdTmpfs.d.ts +20 -0
- package/dist/cjs/containerd/types/ContainerdTmpfs.js +2 -0
- package/dist/cjs/containerd/types/ContainerdVolume.d.ts +19 -0
- package/dist/cjs/containerd/types/ContainerdVolume.js +2 -0
- package/dist/cjs/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
- package/dist/cjs/containerd/types/ContainerdVolumeInfo.js +2 -0
- package/dist/cjs/exports/Containerd.d.ts +69 -0
- package/dist/cjs/exports/Containerd.js +87 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/client/BuildKit.js +488 -0
- package/dist/esm/client/BuildKitMessages.js +120 -0
- package/dist/esm/client/ContainerStore.js +1339 -0
- package/dist/esm/client/ContainerdClient.js +416 -0
- package/dist/esm/client/DockerIgnore.js +179 -0
- package/dist/esm/client/Fifo.js +59 -0
- package/dist/esm/client/ImageStore.js +628 -0
- package/dist/esm/client/Messages.js +393 -0
- package/dist/esm/client/Networks.js +621 -0
- package/dist/esm/client/Platforms.js +156 -0
- package/dist/esm/client/Reference.js +66 -0
- package/dist/esm/client/Registry.js +263 -0
- package/dist/esm/client/Rootfs.js +234 -0
- package/dist/esm/client/Seccomp.js +152 -0
- package/dist/esm/client/Spec.js +220 -0
- package/dist/esm/client/Volumes.js +73 -0
- package/dist/esm/containerd/Containerd.js +923 -0
- package/dist/esm/containerd/exceptions/ContainerdConnectionException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdContainerNameConflictException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdContainerNotFoundException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdContainerStateException.js +13 -0
- package/dist/esm/containerd/exceptions/ContainerdImageBuildException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImageExportException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImageImportException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImageNotFoundException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImagePullException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImagePushException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdNetworkConflictException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdNetworkNotFoundException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdPathNotFoundException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdPlatformException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdVolumeInUseException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdVolumeNotFoundException.js +11 -0
- package/dist/esm/containerd/lib/ContainerdContainer.js +533 -0
- package/dist/esm/containerd/lib/ContainerdContainerTTY.js +175 -0
- package/dist/esm/containerd/lib/ContainerdErrors.js +34 -0
- package/dist/esm/containerd/lib/ContainerdImage.js +219 -0
- package/dist/esm/containerd/options/ContainerdPruneOptions.js +47 -0
- package/dist/esm/containerd/options/ContainerdRegistryAuthOptions.js +41 -0
- package/dist/esm/containerd/options/container/ContainerCommitOptions.js +62 -0
- package/dist/esm/containerd/options/container/ContainerCreateOptions.js +235 -0
- package/dist/esm/containerd/options/container/ContainerExecOptions.js +59 -0
- package/dist/esm/containerd/options/container/ContainerExportDirectoryOptions.js +41 -0
- package/dist/esm/containerd/options/container/ContainerKillOptions.js +37 -0
- package/dist/esm/containerd/options/container/ContainerLogsOptions.js +40 -0
- package/dist/esm/containerd/options/container/ContainerRemoveOptions.js +30 -0
- package/dist/esm/containerd/options/container/ContainerResourceOptions.js +63 -0
- package/dist/esm/containerd/options/container/ContainerStopOptions.js +37 -0
- package/dist/esm/containerd/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
- package/dist/esm/containerd/options/container/ContainerTTYOptions.js +59 -0
- package/dist/esm/containerd/options/image/ImageBuildOptions.js +91 -0
- package/dist/esm/containerd/options/image/ImageExportOptions.js +35 -0
- package/dist/esm/containerd/options/image/ImageImportOptions.js +43 -0
- package/dist/esm/containerd/options/image/ImagePullOptions.js +62 -0
- package/dist/esm/containerd/options/image/ImagePushOptions.js +54 -0
- package/dist/esm/containerd/options/network/NetworkCreateOptions.js +79 -0
- package/dist/esm/containerd/options/volume/VolumeCreateOptions.js +36 -0
- package/dist/esm/containerd/types/ContainerdBind.js +1 -0
- package/dist/esm/containerd/types/ContainerdBuildOutputCallback.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerNetwork.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerPort.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerState.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerStats.js +1 -0
- package/dist/esm/containerd/types/ContainerdDevice.js +1 -0
- package/dist/esm/containerd/types/ContainerdExecResult.js +1 -0
- package/dist/esm/containerd/types/ContainerdImageConfig.js +1 -0
- package/dist/esm/containerd/types/ContainerdNetworkInfo.js +1 -0
- package/dist/esm/containerd/types/ContainerdProgressCallback.js +1 -0
- package/dist/esm/containerd/types/ContainerdPruneResult.js +1 -0
- package/dist/esm/containerd/types/ContainerdRestartPolicy.js +1 -0
- package/dist/esm/containerd/types/ContainerdTmpfs.js +1 -0
- package/dist/esm/containerd/types/ContainerdVolume.js +1 -0
- package/dist/esm/containerd/types/ContainerdVolumeInfo.js +1 -0
- package/dist/esm/exports/Containerd.js +68 -0
- package/dist/types/client/BuildKit.d.ts +176 -0
- package/dist/types/client/BuildKitMessages.d.ts +35 -0
- package/dist/types/client/ContainerStore.d.ts +558 -0
- package/dist/types/client/ContainerdClient.d.ts +244 -0
- package/dist/types/client/DockerIgnore.d.ts +44 -0
- package/dist/types/client/Fifo.d.ts +31 -0
- package/dist/types/client/ImageStore.d.ts +258 -0
- package/dist/types/client/Messages.d.ts +103 -0
- package/dist/types/client/Networks.d.ts +221 -0
- package/dist/types/client/Platforms.d.ts +53 -0
- package/dist/types/client/Reference.d.ts +33 -0
- package/dist/types/client/Registry.d.ts +145 -0
- package/dist/types/client/Rootfs.d.ts +83 -0
- package/dist/types/client/Seccomp.d.ts +36 -0
- package/dist/types/client/Spec.d.ts +151 -0
- package/dist/types/client/Volumes.d.ts +42 -0
- package/dist/types/containerd/Containerd.d.ts +442 -0
- package/dist/types/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
- package/dist/types/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
- package/dist/types/containerd/lib/ContainerdContainer.d.ts +292 -0
- package/dist/types/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
- package/dist/types/containerd/lib/ContainerdErrors.d.ts +6 -0
- package/dist/types/containerd/lib/ContainerdImage.d.ts +149 -0
- package/dist/types/containerd/options/ContainerdPruneOptions.d.ts +44 -0
- package/dist/types/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
- package/dist/types/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
- package/dist/types/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
- package/dist/types/containerd/options/container/ContainerExecOptions.d.ts +53 -0
- package/dist/types/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
- package/dist/types/containerd/options/container/ContainerKillOptions.d.ts +30 -0
- package/dist/types/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
- package/dist/types/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/types/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
- package/dist/types/containerd/options/container/ContainerStopOptions.d.ts +30 -0
- package/dist/types/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/types/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
- package/dist/types/containerd/options/image/ImageBuildOptions.d.ts +88 -0
- package/dist/types/containerd/options/image/ImageExportOptions.d.ts +25 -0
- package/dist/types/containerd/options/image/ImageImportOptions.d.ts +38 -0
- package/dist/types/containerd/options/image/ImagePullOptions.d.ts +53 -0
- package/dist/types/containerd/options/image/ImagePushOptions.d.ts +44 -0
- package/dist/types/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
- package/dist/types/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
- package/dist/types/containerd/types/ContainerdBind.d.ts +28 -0
- package/dist/types/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
- package/dist/types/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
- package/dist/types/containerd/types/ContainerdContainerPort.d.ts +22 -0
- package/dist/types/containerd/types/ContainerdContainerState.d.ts +42 -0
- package/dist/types/containerd/types/ContainerdContainerStats.d.ts +107 -0
- package/dist/types/containerd/types/ContainerdDevice.d.ts +25 -0
- package/dist/types/containerd/types/ContainerdExecResult.d.ts +18 -0
- package/dist/types/containerd/types/ContainerdImageConfig.d.ts +46 -0
- package/dist/types/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
- package/dist/types/containerd/types/ContainerdProgressCallback.d.ts +29 -0
- package/dist/types/containerd/types/ContainerdPruneResult.d.ts +21 -0
- package/dist/types/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
- package/dist/types/containerd/types/ContainerdTmpfs.d.ts +20 -0
- package/dist/types/containerd/types/ContainerdVolume.d.ts +19 -0
- package/dist/types/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
- package/dist/types/exports/Containerd.d.ts +69 -0
- package/package.json +51 -4
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.binfmtPlatforms = binfmtPlatforms;
|
|
7
|
+
exports.formatPlatform = formatPlatform;
|
|
8
|
+
exports.normalizePlatform = normalizePlatform;
|
|
9
|
+
exports.parsePlatform = parsePlatform;
|
|
10
|
+
exports.hostPlatform = hostPlatform;
|
|
11
|
+
exports.matchPlatform = matchPlatform;
|
|
12
|
+
exports.platformRank = platformRank;
|
|
13
|
+
exports.supportedPlatforms = supportedPlatforms;
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
+
/**
|
|
17
|
+
* The architectures of OCI of the ones of Node.js
|
|
18
|
+
*/
|
|
19
|
+
const ARCHITECTURES = {
|
|
20
|
+
x64: 'amd64',
|
|
21
|
+
arm64: 'arm64',
|
|
22
|
+
arm: 'arm',
|
|
23
|
+
ia32: '386',
|
|
24
|
+
ppc64: 'ppc64le',
|
|
25
|
+
s390x: 's390x',
|
|
26
|
+
riscv64: 'riscv64',
|
|
27
|
+
loong64: 'loong64',
|
|
28
|
+
mips64el: 'mips64le'
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The platforms of the ELF binaries an entry of binfmt_misc runs (by the machine of the ELF header of its magic): the
|
|
32
|
+
* emulators of QEMU, Rosetta, whatever their names
|
|
33
|
+
* @param entry the content of the entry
|
|
34
|
+
*/
|
|
35
|
+
function binfmtPlatforms(entry) {
|
|
36
|
+
if (!/^enabled$/m.test(entry))
|
|
37
|
+
return [];
|
|
38
|
+
const offset = entry.match(/^offset (\d+)$/m)?.[1];
|
|
39
|
+
const magic = entry.match(/^magic ([0-9a-f]+)$/m)?.[1];
|
|
40
|
+
if (!magic || (offset && offset !== '0'))
|
|
41
|
+
return [];
|
|
42
|
+
const bytes = Buffer.from(magic, 'hex');
|
|
43
|
+
if (bytes.length < 20 || bytes.readUInt32BE(0) !== 0x7f454c46)
|
|
44
|
+
return [];
|
|
45
|
+
const bits64 = bytes[4] === 2;
|
|
46
|
+
const little = bytes[5] === 1;
|
|
47
|
+
const machine = little ? bytes.readUInt16LE(18) : bytes.readUInt16BE(18);
|
|
48
|
+
const linux = (architecture, variant) => ({ os: 'linux', architecture: architecture, variant: variant });
|
|
49
|
+
switch (machine) {
|
|
50
|
+
case 0x3e:
|
|
51
|
+
return [linux('amd64')];
|
|
52
|
+
case 0x03:
|
|
53
|
+
return [linux('386')];
|
|
54
|
+
case 0xb7:
|
|
55
|
+
return [linux('arm64', 'v8')];
|
|
56
|
+
case 0x28:
|
|
57
|
+
return little ? [linux('arm', 'v7'), linux('arm', 'v6'), linux('arm', 'v5')] : [];
|
|
58
|
+
case 0xf3:
|
|
59
|
+
return bits64 ? [linux('riscv64')] : [];
|
|
60
|
+
case 0x15:
|
|
61
|
+
return bits64 ? [linux(little ? 'ppc64le' : 'ppc64')] : [];
|
|
62
|
+
case 0x16:
|
|
63
|
+
return [linux('s390x')];
|
|
64
|
+
case 0x08:
|
|
65
|
+
return [linux(bits64 ? (little ? 'mips64le' : 'mips64') : (little ? 'mipsle' : 'mips'))];
|
|
66
|
+
case 0x102:
|
|
67
|
+
return [linux('loong64')];
|
|
68
|
+
default:
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A platform written as OCI writes it (linux/arm64/v8)
|
|
74
|
+
* @param platform
|
|
75
|
+
*/
|
|
76
|
+
function formatPlatform(platform) {
|
|
77
|
+
return [platform.os, platform.architecture, platform.variant].filter(Boolean).join('/');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The variant of an architecture given without it: the one its images are matched to (arm64 is v8, arm v7)
|
|
81
|
+
* @param platform
|
|
82
|
+
*/
|
|
83
|
+
function normalizePlatform(platform) {
|
|
84
|
+
const architecture = { x86_64: 'amd64', aarch64: 'arm64', armhf: 'arm', armel: 'arm', i386: '386' }[platform.architecture] ?? platform.architecture;
|
|
85
|
+
let variant = platform.variant || undefined;
|
|
86
|
+
if (architecture === 'arm64' && !variant)
|
|
87
|
+
variant = 'v8';
|
|
88
|
+
if (architecture === 'arm' && !variant)
|
|
89
|
+
variant = 'v7';
|
|
90
|
+
return { os: platform.os || 'linux', architecture: architecture, variant: variant };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Parse a platform: linux/arm64, linux/arm/v7, or an architecture (arm64), on Linux
|
|
94
|
+
* @param value
|
|
95
|
+
*/
|
|
96
|
+
function parsePlatform(value) {
|
|
97
|
+
const parts = value.trim().toLowerCase().split('/').filter(Boolean);
|
|
98
|
+
if (!parts.length || parts.length > 3)
|
|
99
|
+
throw new Error(`The platform "${value}" is not valid (linux/arm64, linux/arm/v7)`);
|
|
100
|
+
const [os, architecture, variant] = parts.length === 1 ? ['linux', parts[0], undefined] : parts;
|
|
101
|
+
return normalizePlatform({ os: os, architecture: architecture, variant: variant });
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The platform of the machine running Node.js
|
|
105
|
+
*/
|
|
106
|
+
function hostPlatform() {
|
|
107
|
+
const architecture = ARCHITECTURES[process.arch] ?? process.arch;
|
|
108
|
+
const arm = process.config.variables.arm_version;
|
|
109
|
+
return normalizePlatform({ os: process.platform === 'win32' ? 'windows' : process.platform, architecture: architecture, variant: architecture === 'arm' && arm ? `v${arm}` : undefined });
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether a platform of an image runs on a platform: the same system and architecture, a variant up to the one of the
|
|
113
|
+
* platform (an arm/v7 runs the images of arm/v6 and arm/v5)
|
|
114
|
+
* @param image
|
|
115
|
+
* @param platform
|
|
116
|
+
*/
|
|
117
|
+
function matchPlatform(image, platform) {
|
|
118
|
+
const [a, b] = [normalizePlatform(image), normalizePlatform(platform)];
|
|
119
|
+
if (a.os !== b.os || a.architecture !== b.architecture)
|
|
120
|
+
return false;
|
|
121
|
+
if (a.architecture === 'arm')
|
|
122
|
+
return Number(a.variant?.slice(1) ?? 7) <= Number(b.variant?.slice(1) ?? 7);
|
|
123
|
+
return (a.variant ?? '') === (b.variant ?? '');
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* How much a platform of an image suits a platform: the exact one first (lower is better), undefined when it does not
|
|
127
|
+
* run there
|
|
128
|
+
* @param image
|
|
129
|
+
* @param platform
|
|
130
|
+
*/
|
|
131
|
+
function platformRank(image, platform) {
|
|
132
|
+
if (!matchPlatform(image, platform))
|
|
133
|
+
return undefined;
|
|
134
|
+
const [a, b] = [normalizePlatform(image), normalizePlatform(platform)];
|
|
135
|
+
return a.architecture === 'arm' ? Number(b.variant?.slice(1) ?? 7) - Number(a.variant?.slice(1) ?? 7) : 0;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The platforms the machine runs the containers of: its own one, and the ones of the emulators registered in
|
|
139
|
+
* binfmt_misc (enabled)
|
|
140
|
+
* @param binfmt the directory of binfmt_misc
|
|
141
|
+
*/
|
|
142
|
+
function supportedPlatforms(binfmt = '/proc/sys/fs/binfmt_misc') {
|
|
143
|
+
const platforms = [hostPlatform()];
|
|
144
|
+
//The machines of x64 run the ones of 386
|
|
145
|
+
if (platforms[0].architecture === 'amd64')
|
|
146
|
+
platforms.push({ os: 'linux', architecture: '386' });
|
|
147
|
+
let entries = [];
|
|
148
|
+
try {
|
|
149
|
+
entries = (0, node_fs_1.readdirSync)(binfmt);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
//No binfmt_misc
|
|
153
|
+
}
|
|
154
|
+
for (const entry of entries) {
|
|
155
|
+
if (entry === 'status' || entry === 'register')
|
|
156
|
+
continue;
|
|
157
|
+
let emulated;
|
|
158
|
+
try {
|
|
159
|
+
emulated = binfmtPlatforms((0, node_fs_1.readFileSync)(node_path_1.default.join(binfmt, entry), 'utf8'));
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
for (const platform of emulated)
|
|
165
|
+
if (!platforms.some((known) => formatPlatform(known) === formatPlatform(platform)))
|
|
166
|
+
platforms.push(platform);
|
|
167
|
+
}
|
|
168
|
+
return platforms;
|
|
169
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reference of an image: its registry, its repository, its tag or its digest
|
|
3
|
+
*/
|
|
4
|
+
export type ImageReference = {
|
|
5
|
+
/**
|
|
6
|
+
* The registry, as named by the references (docker.io)
|
|
7
|
+
*/
|
|
8
|
+
registry: string;
|
|
9
|
+
/**
|
|
10
|
+
* The host of the API of the registry (registry-1.docker.io for docker.io)
|
|
11
|
+
*/
|
|
12
|
+
host: string;
|
|
13
|
+
repository: string;
|
|
14
|
+
tag?: string;
|
|
15
|
+
digest?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The name of the image in containerd, the one of ctr and nerdctl (docker.io/library/busybox:latest)
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Parse a reference of an image as Docker (and containerd) normalize it: busybox is docker.io/library/busybox:latest,
|
|
23
|
+
* user/app docker.io/user/app:latest, the first part of a reference is its registry when it has a dot, a port or is
|
|
24
|
+
* localhost
|
|
25
|
+
* @param reference
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseReference(reference: string): ImageReference;
|
|
28
|
+
/**
|
|
29
|
+
* The name of an image in containerd of a reference given by the users (busybox → docker.io/library/busybox:latest),
|
|
30
|
+
* the reference itself when it is not one
|
|
31
|
+
* @param reference
|
|
32
|
+
*/
|
|
33
|
+
export declare function imageName(reference: string): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseReference = parseReference;
|
|
4
|
+
exports.imageName = imageName;
|
|
5
|
+
/**
|
|
6
|
+
* The registry of the references without registry
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_REGISTRY = 'docker.io';
|
|
9
|
+
/**
|
|
10
|
+
* Parse a reference of an image as Docker (and containerd) normalize it: busybox is docker.io/library/busybox:latest,
|
|
11
|
+
* user/app docker.io/user/app:latest, the first part of a reference is its registry when it has a dot, a port or is
|
|
12
|
+
* localhost
|
|
13
|
+
* @param reference
|
|
14
|
+
*/
|
|
15
|
+
function parseReference(reference) {
|
|
16
|
+
const raw = reference.trim();
|
|
17
|
+
if (!raw || /\s/.test(raw))
|
|
18
|
+
throw new Error(`The reference of an image "${reference}" is not valid`);
|
|
19
|
+
let rest = raw;
|
|
20
|
+
let digest;
|
|
21
|
+
const at = rest.indexOf('@');
|
|
22
|
+
if (at >= 0) {
|
|
23
|
+
digest = rest.slice(at + 1);
|
|
24
|
+
rest = rest.slice(0, at);
|
|
25
|
+
if (!/^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$/.test(digest))
|
|
26
|
+
throw new Error(`The digest of the reference "${reference}" is not valid`);
|
|
27
|
+
}
|
|
28
|
+
let tag;
|
|
29
|
+
const colon = rest.lastIndexOf(':');
|
|
30
|
+
if (colon > rest.lastIndexOf('/')) {
|
|
31
|
+
tag = rest.slice(colon + 1);
|
|
32
|
+
rest = rest.slice(0, colon);
|
|
33
|
+
if (!/^[\w][\w.-]{0,127}$/.test(tag))
|
|
34
|
+
throw new Error(`The tag of the reference "${reference}" is not valid`);
|
|
35
|
+
}
|
|
36
|
+
const parts = rest.split('/');
|
|
37
|
+
let registry = DEFAULT_REGISTRY;
|
|
38
|
+
if (parts.length > 1 && (parts[0].includes('.') || parts[0].includes(':') || parts[0] === 'localhost'))
|
|
39
|
+
registry = parts.shift();
|
|
40
|
+
if (registry === 'index.docker.io' || registry === 'registry-1.docker.io')
|
|
41
|
+
registry = DEFAULT_REGISTRY;
|
|
42
|
+
let repository = parts.join('/');
|
|
43
|
+
if (registry === DEFAULT_REGISTRY && parts.length === 1)
|
|
44
|
+
repository = `library/${repository}`;
|
|
45
|
+
if (!/^[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*)*$/.test(repository))
|
|
46
|
+
throw new Error(`The repository of the reference "${reference}" is not valid (lower case letters, digits, separators)`);
|
|
47
|
+
if (!tag && !digest)
|
|
48
|
+
tag = 'latest';
|
|
49
|
+
return {
|
|
50
|
+
registry: registry,
|
|
51
|
+
host: registry === DEFAULT_REGISTRY ? 'registry-1.docker.io' : registry,
|
|
52
|
+
repository: repository,
|
|
53
|
+
tag: tag,
|
|
54
|
+
digest: digest,
|
|
55
|
+
name: `${registry}/${repository}${tag ? `:${tag}` : ''}${digest ? `@${digest}` : ''}`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The name of an image in containerd of a reference given by the users (busybox → docker.io/library/busybox:latest),
|
|
60
|
+
* the reference itself when it is not one
|
|
61
|
+
* @param reference
|
|
62
|
+
*/
|
|
63
|
+
function imageName(reference) {
|
|
64
|
+
try {
|
|
65
|
+
return parseReference(reference).name;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return reference;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { ContentDescriptor } from './ContainerdClient.js';
|
|
2
|
+
import type { ImageReference } from './Reference.js';
|
|
3
|
+
/**
|
|
4
|
+
* The credentials of a registry: a user and its password (or its token), or an identity token
|
|
5
|
+
*/
|
|
6
|
+
export type RegistryCredentials = {
|
|
7
|
+
username?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
identityToken?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The options of the registries: their credentials by their hosts (docker.io, registry.example.com:5000), the ones
|
|
13
|
+
* served over HTTP
|
|
14
|
+
*/
|
|
15
|
+
export type RegistryOptions = {
|
|
16
|
+
credentials?: Record<string, RegistryCredentials>;
|
|
17
|
+
insecure?: string[];
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The media types of the manifests and of the indexes (OCI, Docker)
|
|
22
|
+
*/
|
|
23
|
+
export declare const MediaTypes: {
|
|
24
|
+
readonly OCI_INDEX: "application/vnd.oci.image.index.v1+json";
|
|
25
|
+
readonly OCI_MANIFEST: "application/vnd.oci.image.manifest.v1+json";
|
|
26
|
+
readonly OCI_CONFIG: "application/vnd.oci.image.config.v1+json";
|
|
27
|
+
readonly OCI_LAYER: "application/vnd.oci.image.layer.v1.tar";
|
|
28
|
+
readonly OCI_LAYER_GZIP: "application/vnd.oci.image.layer.v1.tar+gzip";
|
|
29
|
+
readonly DOCKER_LIST: "application/vnd.docker.distribution.manifest.list.v2+json";
|
|
30
|
+
readonly DOCKER_MANIFEST: "application/vnd.docker.distribution.manifest.v2+json";
|
|
31
|
+
readonly DOCKER_CONFIG: "application/vnd.docker.container.image.v1+json";
|
|
32
|
+
readonly DOCKER_LAYER: "application/vnd.docker.image.rootfs.diff.tar";
|
|
33
|
+
readonly DOCKER_LAYER_GZIP: "application/vnd.docker.image.rootfs.diff.tar.gzip";
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Whether a media type is the one of an index (of the manifests of the platforms)
|
|
37
|
+
* @param mediaType
|
|
38
|
+
*/
|
|
39
|
+
export declare function isIndex(mediaType: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a media type is the one of a manifest (of an image of a platform)
|
|
42
|
+
* @param mediaType
|
|
43
|
+
*/
|
|
44
|
+
export declare function isManifest(mediaType: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The digest of bytes
|
|
47
|
+
* @param data
|
|
48
|
+
*/
|
|
49
|
+
export declare function digestOf(data: Uint8Array): string;
|
|
50
|
+
/**
|
|
51
|
+
* The token of a registry for scopes, from its token service (its realm): with the credentials (an identity token by
|
|
52
|
+
* OAuth2, a user and its password by the basic authentication), or anonymous
|
|
53
|
+
* @param params
|
|
54
|
+
* @param credentials
|
|
55
|
+
* @param signal
|
|
56
|
+
*/
|
|
57
|
+
export declare function fetchRegistryToken(params: {
|
|
58
|
+
realm: string;
|
|
59
|
+
service?: string;
|
|
60
|
+
scopes: string[];
|
|
61
|
+
}, credentials?: RegistryCredentials, signal?: AbortSignal): Promise<{
|
|
62
|
+
token: string;
|
|
63
|
+
expiresIn?: number;
|
|
64
|
+
issuedAt?: number;
|
|
65
|
+
} | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* An error of a registry
|
|
68
|
+
*/
|
|
69
|
+
export declare class RegistryError extends Error {
|
|
70
|
+
readonly status: number;
|
|
71
|
+
constructor(message: string, status: number);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The client of a repository of a registry (the distribution API of OCI): its manifests and its blobs, the tokens of
|
|
75
|
+
* its authentication requested as its challenges ask (Bearer, Basic), with its credentials or anonymously
|
|
76
|
+
*/
|
|
77
|
+
export declare class RegistryClient {
|
|
78
|
+
#private;
|
|
79
|
+
protected readonly reference: ImageReference;
|
|
80
|
+
protected readonly options: RegistryOptions;
|
|
81
|
+
constructor(reference: ImageReference, options?: RegistryOptions);
|
|
82
|
+
/**
|
|
83
|
+
* The credentials of the registry (by its name or by its host)
|
|
84
|
+
*/
|
|
85
|
+
protected credentials(): RegistryCredentials | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* The base URL of the repository
|
|
88
|
+
*/
|
|
89
|
+
protected base(): string;
|
|
90
|
+
/**
|
|
91
|
+
* The authorization of a challenge: a token of its realm (with the credentials when there are), or the credentials
|
|
92
|
+
* @param challenge
|
|
93
|
+
* @param scope
|
|
94
|
+
*/
|
|
95
|
+
protected authorize(challenge: string, scope: string): Promise<string | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* A request to the repository, authenticated as its registry asks
|
|
98
|
+
* @param path the path under the repository (/manifests/latest), or a URL (the location of an upload)
|
|
99
|
+
* @param init
|
|
100
|
+
* @param actions the actions of its scope: pull, or push and pull
|
|
101
|
+
*/
|
|
102
|
+
request(path: string, init?: RequestInit, actions?: string): Promise<Response>;
|
|
103
|
+
/**
|
|
104
|
+
* Fail on an error response
|
|
105
|
+
* @param response
|
|
106
|
+
* @param what
|
|
107
|
+
*/
|
|
108
|
+
protected check(response: Response, what: string): Promise<Response>;
|
|
109
|
+
/**
|
|
110
|
+
* Resolve a reference (a tag or a digest): the descriptor of its manifest or of its index, and its bytes
|
|
111
|
+
* @param reference
|
|
112
|
+
*/
|
|
113
|
+
resolve(reference: string): Promise<{
|
|
114
|
+
descriptor: ContentDescriptor;
|
|
115
|
+
data: Buffer;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Fetch a manifest (or an index) by its descriptor, checked by its digest
|
|
119
|
+
* @param descriptor
|
|
120
|
+
*/
|
|
121
|
+
fetchManifest(descriptor: ContentDescriptor): Promise<Buffer>;
|
|
122
|
+
/**
|
|
123
|
+
* Fetch a blob: its bytes streamed (the redirections of the registry to its storage followed)
|
|
124
|
+
* @param descriptor
|
|
125
|
+
*/
|
|
126
|
+
fetchBlob(descriptor: ContentDescriptor): Promise<AsyncIterable<Uint8Array>>;
|
|
127
|
+
/**
|
|
128
|
+
* Whether the repository has a blob
|
|
129
|
+
* @param digest
|
|
130
|
+
*/
|
|
131
|
+
hasBlob(digest: string): Promise<boolean>;
|
|
132
|
+
/**
|
|
133
|
+
* Push a blob, unless the repository has it: uploaded at once
|
|
134
|
+
* @param descriptor
|
|
135
|
+
* @param data its bytes, or the function giving their stream
|
|
136
|
+
*/
|
|
137
|
+
pushBlob(descriptor: ContentDescriptor, data: Uint8Array | (() => AsyncIterable<Uint8Array>)): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Push a manifest (or an index), by a tag or by its digest
|
|
140
|
+
* @param reference
|
|
141
|
+
* @param mediaType
|
|
142
|
+
* @param data
|
|
143
|
+
*/
|
|
144
|
+
pushManifest(reference: string, mediaType: string, data: Uint8Array): Promise<void>;
|
|
145
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegistryClient = exports.RegistryError = exports.MediaTypes = void 0;
|
|
4
|
+
exports.isIndex = isIndex;
|
|
5
|
+
exports.isManifest = isManifest;
|
|
6
|
+
exports.digestOf = digestOf;
|
|
7
|
+
exports.fetchRegistryToken = fetchRegistryToken;
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
|
+
/**
|
|
10
|
+
* The media types of the manifests and of the indexes (OCI, Docker)
|
|
11
|
+
*/
|
|
12
|
+
exports.MediaTypes = {
|
|
13
|
+
OCI_INDEX: 'application/vnd.oci.image.index.v1+json',
|
|
14
|
+
OCI_MANIFEST: 'application/vnd.oci.image.manifest.v1+json',
|
|
15
|
+
OCI_CONFIG: 'application/vnd.oci.image.config.v1+json',
|
|
16
|
+
OCI_LAYER: 'application/vnd.oci.image.layer.v1.tar',
|
|
17
|
+
OCI_LAYER_GZIP: 'application/vnd.oci.image.layer.v1.tar+gzip',
|
|
18
|
+
DOCKER_LIST: 'application/vnd.docker.distribution.manifest.list.v2+json',
|
|
19
|
+
DOCKER_MANIFEST: 'application/vnd.docker.distribution.manifest.v2+json',
|
|
20
|
+
DOCKER_CONFIG: 'application/vnd.docker.container.image.v1+json',
|
|
21
|
+
DOCKER_LAYER: 'application/vnd.docker.image.rootfs.diff.tar',
|
|
22
|
+
DOCKER_LAYER_GZIP: 'application/vnd.docker.image.rootfs.diff.tar.gzip'
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Whether a media type is the one of an index (of the manifests of the platforms)
|
|
26
|
+
* @param mediaType
|
|
27
|
+
*/
|
|
28
|
+
function isIndex(mediaType) {
|
|
29
|
+
return mediaType === exports.MediaTypes.OCI_INDEX || mediaType === exports.MediaTypes.DOCKER_LIST;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether a media type is the one of a manifest (of an image of a platform)
|
|
33
|
+
* @param mediaType
|
|
34
|
+
*/
|
|
35
|
+
function isManifest(mediaType) {
|
|
36
|
+
return mediaType === exports.MediaTypes.OCI_MANIFEST || mediaType === exports.MediaTypes.DOCKER_MANIFEST;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The digest of bytes
|
|
40
|
+
* @param data
|
|
41
|
+
*/
|
|
42
|
+
function digestOf(data) {
|
|
43
|
+
return `sha256:${(0, node_crypto_1.createHash)('sha256').update(data).digest('hex')}`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The parameters of a challenge of WWW-Authenticate (Bearer realm="…",service="…",scope="…")
|
|
47
|
+
* @param header
|
|
48
|
+
*/
|
|
49
|
+
function parseChallenge(header) {
|
|
50
|
+
const space = header.indexOf(' ');
|
|
51
|
+
const scheme = (space < 0 ? header : header.slice(0, space)).toLowerCase();
|
|
52
|
+
const params = {};
|
|
53
|
+
for (const match of header.slice(space + 1).matchAll(/(\w+)="([^"]*)"/g))
|
|
54
|
+
params[match[1].toLowerCase()] = match[2];
|
|
55
|
+
return { scheme: scheme, params: params };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The basic authorization of credentials
|
|
59
|
+
* @param credentials
|
|
60
|
+
*/
|
|
61
|
+
function basicAuthorization(credentials) {
|
|
62
|
+
return credentials?.username !== undefined ? `Basic ${Buffer.from(`${credentials.username}:${credentials.password ?? ''}`).toString('base64')}` : undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The token of a registry for scopes, from its token service (its realm): with the credentials (an identity token by
|
|
66
|
+
* OAuth2, a user and its password by the basic authentication), or anonymous
|
|
67
|
+
* @param params
|
|
68
|
+
* @param credentials
|
|
69
|
+
* @param signal
|
|
70
|
+
*/
|
|
71
|
+
async function fetchRegistryToken(params, credentials, signal) {
|
|
72
|
+
const url = new URL(params.realm);
|
|
73
|
+
if (params.service)
|
|
74
|
+
url.searchParams.set('service', params.service);
|
|
75
|
+
for (const scope of params.scopes)
|
|
76
|
+
url.searchParams.append('scope', scope);
|
|
77
|
+
let response;
|
|
78
|
+
if (credentials?.identityToken) {
|
|
79
|
+
//The refresh token of the registries (Docker Hub, ECR…): OAuth2
|
|
80
|
+
response = await fetch(url.origin + url.pathname, {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
83
|
+
body: new URLSearchParams({ grant_type: 'refresh_token', refresh_token: credentials.identityToken, service: params.service ?? '', scope: params.scopes.join(' '), client_id: 'lakutata' }),
|
|
84
|
+
signal: signal
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const basic = basicAuthorization(credentials);
|
|
89
|
+
response = await fetch(url, { headers: basic ? { Authorization: basic } : {}, signal: signal });
|
|
90
|
+
}
|
|
91
|
+
if (!response.ok)
|
|
92
|
+
throw new RegistryError(`The registry ${url.host} refuses the authentication (${response.status}): ${(await response.text()).slice(0, 200)}`, response.status);
|
|
93
|
+
const body = await response.json();
|
|
94
|
+
const token = body.token ?? body.access_token;
|
|
95
|
+
if (!token)
|
|
96
|
+
return undefined;
|
|
97
|
+
const issued = body.issued_at ? Date.parse(body.issued_at) : NaN;
|
|
98
|
+
return { token: token, expiresIn: body.expires_in, issuedAt: Number.isNaN(issued) ? undefined : Math.floor(issued / 1000) };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* An error of a registry
|
|
102
|
+
*/
|
|
103
|
+
class RegistryError extends Error {
|
|
104
|
+
constructor(message, status) {
|
|
105
|
+
super(message);
|
|
106
|
+
this.status = status;
|
|
107
|
+
this.name = 'RegistryError';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.RegistryError = RegistryError;
|
|
111
|
+
/**
|
|
112
|
+
* The client of a repository of a registry (the distribution API of OCI): its manifests and its blobs, the tokens of
|
|
113
|
+
* its authentication requested as its challenges ask (Bearer, Basic), with its credentials or anonymously
|
|
114
|
+
*/
|
|
115
|
+
class RegistryClient {
|
|
116
|
+
#tokens = new Map();
|
|
117
|
+
constructor(reference, options = {}) {
|
|
118
|
+
this.reference = reference;
|
|
119
|
+
this.options = options;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The credentials of the registry (by its name or by its host)
|
|
123
|
+
*/
|
|
124
|
+
credentials() {
|
|
125
|
+
const all = this.options.credentials ?? {};
|
|
126
|
+
return all[this.reference.registry] ?? all[this.reference.host] ?? (this.reference.registry === 'docker.io' ? all['https://index.docker.io/v1/'] ?? all['index.docker.io'] : undefined);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The base URL of the repository
|
|
130
|
+
*/
|
|
131
|
+
base() {
|
|
132
|
+
const insecure = (this.options.insecure ?? []).some((host) => host === this.reference.registry || host === this.reference.host);
|
|
133
|
+
return `${insecure ? 'http' : 'https'}://${this.reference.host}/v2/${this.reference.repository}`;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The authorization of a challenge: a token of its realm (with the credentials when there are), or the credentials
|
|
137
|
+
* @param challenge
|
|
138
|
+
* @param scope
|
|
139
|
+
*/
|
|
140
|
+
async authorize(challenge, scope) {
|
|
141
|
+
const { scheme, params } = parseChallenge(challenge);
|
|
142
|
+
const credentials = this.credentials();
|
|
143
|
+
if (scheme === 'basic')
|
|
144
|
+
return basicAuthorization(credentials);
|
|
145
|
+
if (scheme !== 'bearer' || !params.realm)
|
|
146
|
+
return undefined;
|
|
147
|
+
const token = await fetchRegistryToken({ realm: params.realm, service: params.service, scopes: [scope] }, credentials, this.options.signal);
|
|
148
|
+
return token ? `Bearer ${token.token}` : undefined;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A request to the repository, authenticated as its registry asks
|
|
152
|
+
* @param path the path under the repository (/manifests/latest), or a URL (the location of an upload)
|
|
153
|
+
* @param init
|
|
154
|
+
* @param actions the actions of its scope: pull, or push and pull
|
|
155
|
+
*/
|
|
156
|
+
async request(path, init = {}, actions = 'pull') {
|
|
157
|
+
const scope = `repository:${this.reference.repository}:${actions}`;
|
|
158
|
+
const url = /^https?:\/\//.test(path) ? path : `${this.base()}${path}`;
|
|
159
|
+
const send = (authorization) => fetch(url, {
|
|
160
|
+
...init,
|
|
161
|
+
headers: { ...init.headers, ...authorization ? { Authorization: authorization } : {} },
|
|
162
|
+
signal: this.options.signal,
|
|
163
|
+
//The bodies of the streams (the blobs pushed)
|
|
164
|
+
...init.body && typeof init.body.getReader === 'function' ? { duplex: 'half' } : {}
|
|
165
|
+
});
|
|
166
|
+
let response = await send(this.#tokens.get(scope));
|
|
167
|
+
if (response.status === 401) {
|
|
168
|
+
const challenge = response.headers.get('www-authenticate');
|
|
169
|
+
await response.body?.cancel();
|
|
170
|
+
const authorization = challenge ? await this.authorize(challenge, scope) : undefined;
|
|
171
|
+
if (!authorization)
|
|
172
|
+
throw new RegistryError(`The registry ${this.reference.registry} refuses the request of ${this.reference.repository} without authentication: give its credentials`, 401);
|
|
173
|
+
this.#tokens.set(scope, authorization);
|
|
174
|
+
response = await send(authorization);
|
|
175
|
+
}
|
|
176
|
+
return response;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Fail on an error response
|
|
180
|
+
* @param response
|
|
181
|
+
* @param what
|
|
182
|
+
*/
|
|
183
|
+
async check(response, what) {
|
|
184
|
+
if (response.ok)
|
|
185
|
+
return response;
|
|
186
|
+
const text = await response.text().catch(() => '');
|
|
187
|
+
let message = text.slice(0, 300);
|
|
188
|
+
try {
|
|
189
|
+
const errors = JSON.parse(text).errors;
|
|
190
|
+
if (errors?.length)
|
|
191
|
+
message = errors.map(({ code, message }) => `${code}: ${message}`).join(', ');
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
//Not JSON
|
|
195
|
+
}
|
|
196
|
+
throw new RegistryError(`${what} of ${this.reference.registry}/${this.reference.repository} failed (${response.status}): ${message}`, response.status);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Resolve a reference (a tag or a digest): the descriptor of its manifest or of its index, and its bytes
|
|
200
|
+
* @param reference
|
|
201
|
+
*/
|
|
202
|
+
async resolve(reference) {
|
|
203
|
+
const accept = [exports.MediaTypes.OCI_INDEX, exports.MediaTypes.DOCKER_LIST, exports.MediaTypes.OCI_MANIFEST, exports.MediaTypes.DOCKER_MANIFEST].join(', ');
|
|
204
|
+
const response = await this.check(await this.request(`/manifests/${reference}`, { headers: { Accept: accept } }), `The manifest ${reference}`);
|
|
205
|
+
const data = Buffer.from(await response.arrayBuffer());
|
|
206
|
+
const digest = digestOf(data);
|
|
207
|
+
if (reference.startsWith('sha256:') && reference !== digest)
|
|
208
|
+
throw new RegistryError(`The manifest ${reference} has the digest ${digest}`, 0);
|
|
209
|
+
const mediaType = response.headers.get('content-type')?.split(';')[0].trim() || JSON.parse(data.toString('utf8')).mediaType || exports.MediaTypes.OCI_MANIFEST;
|
|
210
|
+
return { descriptor: { mediaType: mediaType, digest: digest, size: data.length }, data: data };
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Fetch a manifest (or an index) by its descriptor, checked by its digest
|
|
214
|
+
* @param descriptor
|
|
215
|
+
*/
|
|
216
|
+
async fetchManifest(descriptor) {
|
|
217
|
+
const response = await this.check(await this.request(`/manifests/${descriptor.digest}`, { headers: { Accept: descriptor.mediaType } }), `The manifest ${descriptor.digest}`);
|
|
218
|
+
const data = Buffer.from(await response.arrayBuffer());
|
|
219
|
+
if (digestOf(data) !== descriptor.digest)
|
|
220
|
+
throw new RegistryError(`The manifest ${descriptor.digest} has the digest ${digestOf(data)}`, 0);
|
|
221
|
+
return data;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Fetch a blob: its bytes streamed (the redirections of the registry to its storage followed)
|
|
225
|
+
* @param descriptor
|
|
226
|
+
*/
|
|
227
|
+
async fetchBlob(descriptor) {
|
|
228
|
+
const response = await this.check(await this.request(`/blobs/${descriptor.digest}`), `The blob ${descriptor.digest}`);
|
|
229
|
+
if (!response.body)
|
|
230
|
+
throw new RegistryError(`The blob ${descriptor.digest} has no body`, response.status);
|
|
231
|
+
return response.body;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Whether the repository has a blob
|
|
235
|
+
* @param digest
|
|
236
|
+
*/
|
|
237
|
+
async hasBlob(digest) {
|
|
238
|
+
const response = await this.request(`/blobs/${digest}`, { method: 'HEAD' }, 'push,pull');
|
|
239
|
+
await response.body?.cancel();
|
|
240
|
+
return response.ok;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Push a blob, unless the repository has it: uploaded at once
|
|
244
|
+
* @param descriptor
|
|
245
|
+
* @param data its bytes, or the function giving their stream
|
|
246
|
+
*/
|
|
247
|
+
async pushBlob(descriptor, data) {
|
|
248
|
+
if (await this.hasBlob(descriptor.digest))
|
|
249
|
+
return;
|
|
250
|
+
const started = await this.check(await this.request('/blobs/uploads/', { method: 'POST', headers: { 'Content-Length': '0' } }, 'push,pull'), `The upload of ${descriptor.digest}`);
|
|
251
|
+
await started.body?.cancel();
|
|
252
|
+
const location = started.headers.get('location');
|
|
253
|
+
if (!location)
|
|
254
|
+
throw new RegistryError(`The upload of ${descriptor.digest} has no location`, started.status);
|
|
255
|
+
const url = new URL(location, this.base());
|
|
256
|
+
url.searchParams.set('digest', descriptor.digest);
|
|
257
|
+
const body = data instanceof Uint8Array ? data : ReadableStream.from(data());
|
|
258
|
+
const put = await this.check(await this.request(url.toString(), { method: 'PUT', headers: { 'Content-Type': 'application/octet-stream', 'Content-Length': String(descriptor.size) }, body: body }, 'push,pull'), `The upload of ${descriptor.digest}`);
|
|
259
|
+
await put.body?.cancel();
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Push a manifest (or an index), by a tag or by its digest
|
|
263
|
+
* @param reference
|
|
264
|
+
* @param mediaType
|
|
265
|
+
* @param data
|
|
266
|
+
*/
|
|
267
|
+
async pushManifest(reference, mediaType, data) {
|
|
268
|
+
const response = await this.check(await this.request(`/manifests/${reference}`, { method: 'PUT', headers: { 'Content-Type': mediaType }, body: data }, 'push,pull'), `The push of the manifest ${reference}`);
|
|
269
|
+
await response.body?.cancel();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.RegistryClient = RegistryClient;
|