@dfatwork/oci-client 0.16.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.
Files changed (4) hide show
  1. package/README.md +212 -0
  2. package/index.d.ts +462 -0
  3. package/index.js +610 -0
  4. package/package.json +90 -0
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # Node.js Bindings for rust-oci-client
2
+
3
+ Node.js bindings for the [rust-oci-client](https://github.com/oras-project/rust-oci-client) library, providing high-performance OCI Distribution client functionality.
4
+
5
+ **Version**: These bindings are versioned in sync with the parent `oci-client` crate.
6
+
7
+ ## Features
8
+
9
+ - **Pure API Mirror**: Function signatures match the native Rust functions exactly
10
+ - **High Performance**: Uses NAPI-RS for zero-copy data transfer where possible
11
+ - **Full Auth Support**: Anonymous, Basic (username/password), and Bearer token authentication
12
+ - **Complete ClientConfig**: All native configuration options exposed
13
+ - **TypeScript Support**: Full type definitions included
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @oras-project/oci-client
19
+ # or
20
+ yarn add @oras-project/oci-client
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```typescript
26
+ import { OciClient, ClientProtocol, anonymousAuth, basicAuth } from '@oras-project/oci-client';
27
+
28
+ // Create a client with default configuration
29
+ const client = new OciClient();
30
+
31
+ // Or with custom configuration
32
+ const clientWithConfig = OciClient.withConfig({
33
+ protocol: ClientProtocol.Https,
34
+ acceptInvalidCertificates: false,
35
+ maxConcurrentDownload: 8,
36
+ maxConcurrentUpload: 8,
37
+ });
38
+
39
+ // Create a client targeting a specific platform (for multi-arch images)
40
+ const armClient = OciClient.withConfig({
41
+ platform: {
42
+ os: 'linux',
43
+ architecture: 'arm64',
44
+ variant: 'v8' // optional
45
+ }
46
+ });
47
+
48
+ // Pull an image
49
+ const imageData = await client.pull(
50
+ 'ghcr.io/example/image:latest',
51
+ anonymousAuth(),
52
+ ['application/vnd.oci.image.layer.v1.tar+gzip']
53
+ );
54
+
55
+ console.log(`Pulled ${imageData.layers.length} layers`);
56
+ console.log(`Digest: ${imageData.digest}`);
57
+
58
+ // Push an image
59
+ const response = await client.push(
60
+ 'registry.example.com/myimage:v1',
61
+ layers,
62
+ config,
63
+ basicAuth('username', 'password'),
64
+ null // Let the client generate the manifest
65
+ );
66
+
67
+ console.log(`Manifest URL: ${response.manifestUrl}`);
68
+
69
+ // Pull image manifest
70
+ const { manifest, digest } = await client.pullImageManifest(
71
+ 'ghcr.io/example/image:latest',
72
+ anonymousAuth()
73
+ );
74
+
75
+ // Push a manifest list (multi-platform image)
76
+ const manifestUrl = await client.pushManifestList(
77
+ 'registry.example.com/myimage:v1',
78
+ basicAuth('username', 'password'),
79
+ imageIndex
80
+ );
81
+
82
+ // Pull referrers (OCI 1.1)
83
+ const referrers = await client.pullReferrers(
84
+ 'ghcr.io/example/image@sha256:abc123...',
85
+ 'application/vnd.example.sbom'
86
+ );
87
+ ```
88
+
89
+ ## API Reference
90
+
91
+ ### Client
92
+
93
+ #### `new OciClient()`
94
+ Create a client with default configuration.
95
+
96
+ #### `OciClient.withConfig(config: ClientConfig)`
97
+ Create a client with custom configuration.
98
+
99
+ ### Platform Selection
100
+
101
+ For multi-platform images (Image Index/Manifest List), you can specify the target platform:
102
+
103
+ ```typescript
104
+ const client = OciClient.withConfig({
105
+ platform: {
106
+ os: 'linux', // Required: linux, windows, darwin, etc.
107
+ architecture: 'arm64', // Required: amd64, arm64, arm, etc.
108
+ variant: 'v8' // Optional: v7, v8, etc. for ARM
109
+ }
110
+ });
111
+ ```
112
+
113
+ When pulling an image that references an Image Index, the client will automatically select the manifest matching the specified platform.
114
+
115
+ ### Authentication
116
+
117
+ #### `anonymousAuth()`
118
+ Create anonymous authentication.
119
+
120
+ #### `basicAuth(username: string, password: string)`
121
+ Create HTTP Basic authentication.
122
+
123
+ #### `bearerAuth(token: string)`
124
+ Create Bearer token authentication.
125
+
126
+ ### Main Functions
127
+
128
+ #### `pull(image, auth, acceptedMediaTypes)`
129
+ Pull an image from the registry. Returns `ImageData` with layers as Buffers.
130
+
131
+ #### `push(imageRef, layers, config, auth, manifest?)`
132
+ Push an image to the registry. Returns `PushResponse`.
133
+
134
+ #### `pullImageManifest(image, auth)`
135
+ Pull an image manifest. Returns `{ manifest, digest }`. If a multi-platform Image Index is encountered, automatically selects the platform-specific manifest.
136
+
137
+ #### `pullManifest(image, auth)`
138
+ Pull a manifest (either image or image index) from the registry. Returns `{ manifest, digest }`.
139
+
140
+ #### `pullManifestRaw(image, auth, acceptedMediaTypes)`
141
+ Pull a manifest as raw bytes. Returns a `Buffer`.
142
+
143
+ #### `pushManifest(image, manifest)`
144
+ Push a manifest (image or image index) to the registry. Returns the manifest URL.
145
+
146
+ #### `pushManifestList(reference, auth, manifest)`
147
+ Push a manifest list (image index). Returns manifest URL.
148
+
149
+ #### `pullReferrers(image, artifactType?)`
150
+ Pull referrers for an artifact (OCI 1.1 Referrers API). Returns `ImageIndex`.
151
+
152
+ #### `pullBlob(image, digest)`
153
+ Pull a blob from the registry. Returns a `Buffer`.
154
+
155
+ #### `pushBlob(image, data, digest)`
156
+ Push a blob to the registry. Returns the blob digest.
157
+
158
+ #### `blobExists(image, digest)`
159
+ Check if a blob exists in the registry. Returns `boolean`.
160
+
161
+ #### `mountBlob(target, source, digest)`
162
+ Mount a blob from one repository to another (cross-repository blob mounting).
163
+
164
+ #### `listTags(image, auth, n?, last?)`
165
+ List tags for a repository. Supports pagination via `n` (page size) and `last` (last tag from previous page). Returns `string[]`.
166
+
167
+ #### `fetchManifestDigest(image, auth)`
168
+ Fetch a manifest's digest without downloading the full manifest content. Returns the digest string.
169
+
170
+ #### `storeAuth(registry, auth)`
171
+ Pre-authenticate with a registry. Useful for storing credentials before performing multiple operations.
172
+
173
+ ### Types
174
+
175
+ See the TypeScript definitions for complete type information.
176
+
177
+ ## Building from Source
178
+
179
+ ```bash
180
+ # Install dependencies
181
+ yarn install
182
+
183
+ # Build native module (release)
184
+ yarn build
185
+
186
+ # Build debug version
187
+ yarn build:debug
188
+
189
+ # Run tests
190
+ yarn test
191
+
192
+ # Lint
193
+ yarn lint
194
+ ```
195
+
196
+ ## Supported Platforms
197
+
198
+ - Windows x64 (MSVC)
199
+ - macOS x64 (Intel)
200
+ - macOS ARM64 (Apple Silicon)
201
+ - Linux x64 (glibc)
202
+ - Linux ARM64 (glibc)
203
+ - Linux x64 (musl/Alpine)
204
+ - Linux ARM64 (musl/Alpine)
205
+
206
+ ## Contributing
207
+
208
+ See the [CONTRIBUTING.md](../../CONTRIBUTING.md) file in the repository root for contribution guidelines.
209
+
210
+ ## License
211
+
212
+ Apache-2.0
package/index.d.ts ADDED
@@ -0,0 +1,462 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ /**
4
+ * OCI Distribution client for interacting with OCI registries.
5
+ * Provides pull, push, and manifest operations.
6
+ */
7
+ export declare class OciClient {
8
+ /** Create a new OCI client with default configuration. */
9
+ constructor()
10
+ /** Create a new OCI client with custom configuration. */
11
+ static withConfig(config: ClientConfig): OciClient
12
+ /**
13
+ * Pull an image from the registry.
14
+ *
15
+ * Arguments match native: `pull(image: &Reference, auth: &RegistryAuth, accepted_media_types: Vec<&str>)`
16
+ *
17
+ * Returns ImageData containing layers (as Buffers), config, and manifest.
18
+ */
19
+ pull(image: string, auth: RegistryAuth, acceptedMediaTypes: Array<string>): Promise<ImageData>
20
+ /**
21
+ * Push an image to the registry.
22
+ *
23
+ * Arguments match native: `push(image_ref: &Reference, layers: &[ImageLayer], config: Config, auth: &RegistryAuth, manifest: Option<OciImageManifest>)`
24
+ *
25
+ * Returns PushResponse with config and manifest URLs.
26
+ */
27
+ push(imageRef: string, layers: Array<ImageLayer>, config: Config, auth: RegistryAuth, manifest?: ImageManifest | undefined | null): Promise<PushResponse>
28
+ /**
29
+ * Pull referrers for an artifact (OCI 1.1 Referrers API).
30
+ *
31
+ * Arguments match native: `pull_referrers(image: &Reference, artifact_type: Option<&str>)`
32
+ *
33
+ * Returns an ImageIndex containing the referrers.
34
+ */
35
+ pullReferrers(image: string, artifactType?: string | undefined | null): Promise<ImageIndex>
36
+ /**
37
+ * Push a manifest list (image index) to the registry.
38
+ *
39
+ * Arguments match native: `push_manifest_list(reference: &Reference, auth: &RegistryAuth, manifest: OciImageIndex)`
40
+ *
41
+ * Returns the manifest URL.
42
+ */
43
+ pushManifestList(reference: string, auth: RegistryAuth, manifest: ImageIndex): Promise<string>
44
+ /**
45
+ * Pull an image manifest from the registry.
46
+ *
47
+ * Arguments match native: `pull_image_manifest(image: &Reference, auth: &RegistryAuth)`
48
+ *
49
+ * If a multi-platform Image Index manifest is encountered, a platform-specific
50
+ * Image manifest will be selected using the client's default platform resolution.
51
+ *
52
+ * Returns both the manifest and its digest.
53
+ */
54
+ pullImageManifest(image: string, auth: RegistryAuth): Promise<PullImageManifestResult>
55
+ /**
56
+ * Store authentication credentials for a registry.
57
+ * This is useful for pre-authenticating before multiple operations.
58
+ */
59
+ storeAuth(registry: string, auth: RegistryAuth): Promise<void>
60
+ /**
61
+ * Pull a manifest (either image or index) from the registry.
62
+ * Returns the manifest and its digest.
63
+ */
64
+ pullManifest(image: string, auth: RegistryAuth): Promise<PullManifestResult>
65
+ /** Pull a manifest as raw bytes. */
66
+ pullManifestRaw(image: string, auth: RegistryAuth, acceptedMediaTypes: Array<string>): Promise<Buffer>
67
+ /**
68
+ * Push a manifest to the registry.
69
+ * Returns the manifest URL.
70
+ */
71
+ pushManifest(image: string, manifest: Manifest): Promise<string>
72
+ /**
73
+ * Push a blob to the registry.
74
+ * Returns the blob digest.
75
+ */
76
+ pushBlob(image: string, data: Buffer, digest: string): Promise<string>
77
+ /**
78
+ * Pull a blob from the registry.
79
+ * Returns the blob data.
80
+ */
81
+ pullBlob(image: string, digest: string): Promise<Buffer>
82
+ /** Check if a blob exists in the registry. */
83
+ blobExists(image: string, digest: string): Promise<boolean>
84
+ /** Mount a blob from another repository. */
85
+ mountBlob(target: string, source: string, digest: string): Promise<void>
86
+ /** List tags for a repository. */
87
+ listTags(image: string, auth: RegistryAuth, n?: number | undefined | null, last?: string | undefined | null): Promise<Array<string>>
88
+ /** Fetch manifest digest without downloading the full manifest. */
89
+ fetchManifestDigest(image: string, auth: RegistryAuth): Promise<string>
90
+ }
91
+
92
+ /** Create an anonymous authentication object. */
93
+ export declare function anonymousAuth(): RegistryAuth
94
+
95
+ /** Create a basic authentication object. */
96
+ export declare function basicAuth(username: string, password: string): RegistryAuth
97
+
98
+ /** Create a bearer token authentication object. */
99
+ export declare function bearerAuth(token: string): RegistryAuth
100
+
101
+ /**
102
+ * A x509 certificate for TLS.
103
+ * Mirrors the native Certificate struct.
104
+ */
105
+ export interface Certificate {
106
+ /** Which encoding is used by the certificate */
107
+ encoding: CertificateEncoding
108
+ /** Certificate data as bytes */
109
+ data: Buffer
110
+ }
111
+
112
+ /**
113
+ * Certificate encoding format.
114
+ * Mirrors the native CertificateEncoding enum.
115
+ */
116
+ export enum CertificateEncoding {
117
+ /** DER encoded certificate */
118
+ Der = 'Der',
119
+ /** PEM encoded certificate */
120
+ Pem = 'Pem'
121
+ }
122
+
123
+ /**
124
+ * Client configuration options.
125
+ * Mirrors the native ClientConfig struct with all available options.
126
+ */
127
+ export interface ClientConfig {
128
+ /** Which protocol the client should use (default: Https) */
129
+ protocol?: ClientProtocol
130
+ /** List of registries to exclude from HTTPS (used with HttpsExcept protocol) */
131
+ httpsExceptRegistries?: Array<string>
132
+ /** Accept invalid certificates (default: false) */
133
+ acceptInvalidCertificates?: boolean
134
+ /** Use monolithic push for pushing blobs (default: false) */
135
+ useMonolithicPush?: boolean
136
+ /** Extra root certificates to trust (for self-signed certificates) */
137
+ extraRootCertificates?: Array<Certificate>
138
+ /** Maximum number of concurrent uploads during push (default: 16) */
139
+ maxConcurrentUpload?: number
140
+ /** Maximum number of concurrent downloads during pull (default: 16) */
141
+ maxConcurrentDownload?: number
142
+ /** Default token expiration in seconds (default: 60) */
143
+ defaultTokenExpirationSecs?: number
144
+ /** Read timeout in milliseconds */
145
+ readTimeoutMs?: number
146
+ /** Connect timeout in milliseconds */
147
+ connectTimeoutMs?: number
148
+ /** HTTPS proxy URL */
149
+ httpsProxy?: string
150
+ /** HTTP proxy URL */
151
+ httpProxy?: string
152
+ /** No proxy list (comma-separated) */
153
+ noProxy?: string
154
+ /**
155
+ * Platform filter for multi-platform image selection.
156
+ * When set, automatically selects the matching platform from Image Index manifests.
157
+ */
158
+ platform?: PlatformFilter
159
+ }
160
+
161
+ /**
162
+ * Protocol configuration for the client.
163
+ * Mirrors the native ClientProtocol enum.
164
+ */
165
+ export enum ClientProtocol {
166
+ /** Use HTTP (insecure) */
167
+ Http = 'Http',
168
+ /** Use HTTPS (secure, default) */
169
+ Https = 'Https',
170
+ /** Use HTTPS except for specified registries */
171
+ HttpsExcept = 'HttpsExcept'
172
+ }
173
+
174
+ /**
175
+ * Configuration object for an image.
176
+ * Mirrors the native Config struct.
177
+ */
178
+ export interface Config {
179
+ /** The config data as raw bytes */
180
+ data: Buffer
181
+ /** The media type of this config */
182
+ mediaType: string
183
+ /** Optional annotations for this config */
184
+ annotations?: Record<string, string>
185
+ }
186
+
187
+ /** OCI Descriptor - describes a content addressable resource. */
188
+ export interface Descriptor {
189
+ /** The media type of the referenced content */
190
+ mediaType: string
191
+ /** The digest of the targeted content */
192
+ digest: string
193
+ /** The size in bytes of the targeted content */
194
+ size: number
195
+ /** Optional list of URLs from which this object may be downloaded */
196
+ urls?: Array<string>
197
+ /** Optional annotations for this descriptor */
198
+ annotations?: Record<string, string>
199
+ }
200
+
201
+ /** The mediatype for an image config (manifest) */
202
+ export const IMAGE_CONFIG_MEDIA_TYPE: string
203
+
204
+ /** The mediatype that Docker uses for image configs */
205
+ export const IMAGE_DOCKER_CONFIG_MEDIA_TYPE: string
206
+
207
+ /** The mediatype that Docker uses for a layer that is gzipped */
208
+ export const IMAGE_DOCKER_LAYER_GZIP_MEDIA_TYPE: string
209
+
210
+ /** The mediatype that Docker uses for a layer that is tarred */
211
+ export const IMAGE_DOCKER_LAYER_TAR_MEDIA_TYPE: string
212
+
213
+ /** The mediatype for a layer that is gzipped */
214
+ export const IMAGE_LAYER_GZIP_MEDIA_TYPE: string
215
+
216
+ /** The mediatype for a layer */
217
+ export const IMAGE_LAYER_MEDIA_TYPE: string
218
+
219
+ /** The mediatype for a layer that is nondistributable and gzipped */
220
+ export const IMAGE_LAYER_NONDISTRIBUTABLE_GZIP_MEDIA_TYPE: string
221
+
222
+ /** The mediatype for a layer that is nondistributable */
223
+ export const IMAGE_LAYER_NONDISTRIBUTABLE_MEDIA_TYPE: string
224
+
225
+ /** The mediatype for a Docker v2 schema 2 manifest list */
226
+ export const IMAGE_MANIFEST_LIST_MEDIA_TYPE: string
227
+
228
+ /** The mediatype for a Docker v2 schema 2 manifest */
229
+ export const IMAGE_MANIFEST_MEDIA_TYPE: string
230
+
231
+ /**
232
+ * Data returned from pulling an image.
233
+ * Mirrors the native ImageData struct.
234
+ */
235
+ export interface ImageData {
236
+ /** The layers of the image */
237
+ layers: Array<ImageLayer>
238
+ /** The digest of the image (if available) */
239
+ digest?: string
240
+ /** The configuration object of the image */
241
+ config: Config
242
+ /** The manifest (if available) */
243
+ manifest?: ImageManifest
244
+ }
245
+
246
+ /** OCI Image Index (manifest list). */
247
+ export interface ImageIndex {
248
+ /** Schema version (always 2) */
249
+ schemaVersion: number
250
+ /** Media type of this manifest */
251
+ mediaType?: string
252
+ /** List of manifests for specific platforms */
253
+ manifests: Array<ManifestEntry>
254
+ /** Artifact type */
255
+ artifactType?: string
256
+ /** Annotations */
257
+ annotations?: Record<string, string>
258
+ }
259
+
260
+ /**
261
+ * An image layer with data and metadata.
262
+ * Mirrors the native ImageLayer struct.
263
+ */
264
+ export interface ImageLayer {
265
+ /** The layer data as raw bytes */
266
+ data: Buffer
267
+ /** The media type of this layer */
268
+ mediaType: string
269
+ /** Optional annotations for this layer */
270
+ annotations?: Record<string, string>
271
+ }
272
+
273
+ /** OCI Image Manifest. */
274
+ export interface ImageManifest {
275
+ /** Schema version (always 2) */
276
+ schemaVersion: number
277
+ /** Media type of this manifest */
278
+ mediaType?: string
279
+ /** The image configuration descriptor */
280
+ config: Descriptor
281
+ /** The image layers */
282
+ layers: Array<Descriptor>
283
+ /** Subject descriptor (for referrers) */
284
+ subject?: Descriptor
285
+ /** Artifact type */
286
+ artifactType?: string
287
+ /** Annotations */
288
+ annotations?: Record<string, string>
289
+ }
290
+
291
+ /**
292
+ * OCI Manifest - can be either an Image manifest or an ImageIndex.
293
+ * Check `manifest_type` to determine which field is populated.
294
+ */
295
+ export interface Manifest {
296
+ /** The type of manifest */
297
+ manifestType: ManifestType
298
+ /** The image manifest (populated when manifest_type is Image) */
299
+ image?: ImageManifest
300
+ /** The image index (populated when manifest_type is ImageIndex) */
301
+ imageIndex?: ImageIndex
302
+ }
303
+
304
+ /** An entry in an image index manifest. */
305
+ export interface ManifestEntry {
306
+ /** Media type of the manifest */
307
+ mediaType: string
308
+ /** Digest of the manifest */
309
+ digest: string
310
+ /** Size in bytes */
311
+ size: number
312
+ /** Platform specification */
313
+ platform?: PlatformSpec
314
+ /** Annotations */
315
+ annotations?: Record<string, string>
316
+ }
317
+
318
+ /** Manifest type discriminator. */
319
+ export enum ManifestType {
320
+ /** An OCI image manifest */
321
+ Image = 'Image',
322
+ /** An OCI image index (manifest list) */
323
+ ImageIndex = 'ImageIndex'
324
+ }
325
+
326
+ /** The mediatype for an OCI image index manifest */
327
+ export const OCI_IMAGE_INDEX_MEDIA_TYPE: string
328
+
329
+ /** The mediatype for an OCI image manifest */
330
+ export const OCI_IMAGE_MEDIA_TYPE: string
331
+
332
+ /** Contact details of the people or organization responsible for the image (freeform string) */
333
+ export const ORG_OPENCONTAINERS_IMAGE_AUTHORS: string
334
+
335
+ /** Digest of the image this image is based on (string) */
336
+ export const ORG_OPENCONTAINERS_IMAGE_BASE_DIGEST: string
337
+
338
+ /** Image reference of the image this image is based on (string) */
339
+ export const ORG_OPENCONTAINERS_IMAGE_BASE_NAME: string
340
+
341
+ /** Date and time on which the image was built (string, date-time as defined by RFC 3339) */
342
+ export const ORG_OPENCONTAINERS_IMAGE_CREATED: string
343
+
344
+ /** Human-readable description of the software packaged in the image (string) */
345
+ export const ORG_OPENCONTAINERS_IMAGE_DESCRIPTION: string
346
+
347
+ /** URL to get documentation on the image (string) */
348
+ export const ORG_OPENCONTAINERS_IMAGE_DOCUMENTATION: string
349
+
350
+ /** License(s) under which contained software is distributed as an SPDX License Expression */
351
+ export const ORG_OPENCONTAINERS_IMAGE_LICENSES: string
352
+
353
+ /** Name of the reference for a target (string) */
354
+ export const ORG_OPENCONTAINERS_IMAGE_REF_NAME: string
355
+
356
+ /** Source control revision identifier for the packaged software */
357
+ export const ORG_OPENCONTAINERS_IMAGE_REVISION: string
358
+
359
+ /** URL to get source code for building the image (string) */
360
+ export const ORG_OPENCONTAINERS_IMAGE_SOURCE: string
361
+
362
+ /** Human-readable title of the image (string) */
363
+ export const ORG_OPENCONTAINERS_IMAGE_TITLE: string
364
+
365
+ /** URL to find more information on the image (string) */
366
+ export const ORG_OPENCONTAINERS_IMAGE_URL: string
367
+
368
+ /** Name of the distributing entity, organization or individual */
369
+ export const ORG_OPENCONTAINERS_IMAGE_VENDOR: string
370
+
371
+ /** Version of the packaged software */
372
+ export const ORG_OPENCONTAINERS_IMAGE_VERSION: string
373
+
374
+ /**
375
+ * Platform filter for selecting a specific platform from multi-platform images.
376
+ * When set, the client will automatically select the matching platform from Image Index manifests.
377
+ */
378
+ export interface PlatformFilter {
379
+ /** Operating system (e.g., "linux", "windows", "darwin") */
380
+ os: string
381
+ /** CPU architecture (e.g., "amd64", "arm64", "arm") */
382
+ architecture: string
383
+ /** Optional variant (e.g., "v7" for arm/v7) */
384
+ variant?: string
385
+ }
386
+
387
+ /** Platform specification for an image. */
388
+ export interface PlatformSpec {
389
+ /** CPU architecture */
390
+ architecture: string
391
+ /** Operating system */
392
+ os: string
393
+ /** OS version */
394
+ osVersion?: string
395
+ /** OS features */
396
+ osFeatures?: Array<string>
397
+ /** CPU variant */
398
+ variant?: string
399
+ /** Additional features */
400
+ features?: Array<string>
401
+ }
402
+
403
+ /** Result from pull_image_manifest containing both manifest and digest. */
404
+ export interface PullImageManifestResult {
405
+ /** The pulled image manifest */
406
+ manifest: ImageManifest
407
+ /** The digest of the manifest */
408
+ digest: string
409
+ }
410
+
411
+ /** Result from pull_manifest containing both manifest and digest. */
412
+ export interface PullManifestResult {
413
+ /** The pulled manifest */
414
+ manifest: Manifest
415
+ /** The digest of the manifest */
416
+ digest: string
417
+ }
418
+
419
+ /**
420
+ * Response from pushing an image.
421
+ * Mirrors the native PushResponse struct.
422
+ */
423
+ export interface PushResponse {
424
+ /** Pullable URL for the config */
425
+ configUrl: string
426
+ /** Pullable URL for the manifest */
427
+ manifestUrl: string
428
+ }
429
+
430
+ /**
431
+ * Registry authentication configuration.
432
+ * Use `auth_type` to specify the authentication method.
433
+ */
434
+ export interface RegistryAuth {
435
+ /** The type of authentication to use */
436
+ authType: RegistryAuthType
437
+ /** Username for Basic auth (required when auth_type is Basic) */
438
+ username?: string
439
+ /** Password for Basic auth (required when auth_type is Basic) */
440
+ password?: string
441
+ /** Token for Bearer auth (required when auth_type is Bearer) */
442
+ token?: string
443
+ }
444
+
445
+ /**
446
+ * Authentication method for registry access.
447
+ * Mirrors the native RegistryAuth enum exactly.
448
+ */
449
+ export enum RegistryAuthType {
450
+ /** Access the registry anonymously */
451
+ Anonymous = 'Anonymous',
452
+ /** Access the registry using HTTP Basic authentication */
453
+ Basic = 'Basic',
454
+ /** Access the registry using Bearer token authentication */
455
+ Bearer = 'Bearer'
456
+ }
457
+
458
+ /** The mediatype for a WASM image config */
459
+ export const WASM_CONFIG_MEDIA_TYPE: string
460
+
461
+ /** The mediatype for WASM layers */
462
+ export const WASM_LAYER_MEDIA_TYPE: string
package/index.js ADDED
@@ -0,0 +1,610 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ const { readFileSync } = require('node:fs')
7
+ let nativeBinding = null
8
+ const loadErrors = []
9
+
10
+ const isMusl = () => {
11
+ let musl = false
12
+ if (process.platform === 'linux') {
13
+ musl = isMuslFromFilesystem()
14
+ if (musl === null) {
15
+ musl = isMuslFromReport()
16
+ }
17
+ if (musl === null) {
18
+ musl = isMuslFromChildProcess()
19
+ }
20
+ }
21
+ return musl
22
+ }
23
+
24
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
25
+
26
+ const isMuslFromFilesystem = () => {
27
+ try {
28
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
29
+ } catch {
30
+ return null
31
+ }
32
+ }
33
+
34
+ const isMuslFromReport = () => {
35
+ let report = null
36
+ if (typeof process.report?.getReport === 'function') {
37
+ process.report.excludeNetwork = true
38
+ report = process.report.getReport()
39
+ }
40
+ if (!report) {
41
+ return null
42
+ }
43
+ if (report.header && report.header.glibcVersionRuntime) {
44
+ return false
45
+ }
46
+ if (Array.isArray(report.sharedObjects)) {
47
+ if (report.sharedObjects.some(isFileMusl)) {
48
+ return true
49
+ }
50
+ }
51
+ return false
52
+ }
53
+
54
+ const isMuslFromChildProcess = () => {
55
+ try {
56
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
57
+ } catch (e) {
58
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
59
+ return false
60
+ }
61
+ }
62
+
63
+ function requireNative() {
64
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
65
+ try {
66
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
67
+ } catch (err) {
68
+ loadErrors.push(err)
69
+ }
70
+ } else if (process.platform === 'android') {
71
+ if (process.arch === 'arm64') {
72
+ try {
73
+ return require('./oci-client.android-arm64.node')
74
+ } catch (e) {
75
+ loadErrors.push(e)
76
+ }
77
+ try {
78
+ const binding = require('@dfatwork/oci-client-android-arm64')
79
+ const bindingPackageVersion = require('@dfatwork/oci-client-android-arm64/package.json').version
80
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
+ }
83
+ return binding
84
+ } catch (e) {
85
+ loadErrors.push(e)
86
+ }
87
+ } else if (process.arch === 'arm') {
88
+ try {
89
+ return require('./oci-client.android-arm-eabi.node')
90
+ } catch (e) {
91
+ loadErrors.push(e)
92
+ }
93
+ try {
94
+ const binding = require('@dfatwork/oci-client-android-arm-eabi')
95
+ const bindingPackageVersion = require('@dfatwork/oci-client-android-arm-eabi/package.json').version
96
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
+ }
99
+ return binding
100
+ } catch (e) {
101
+ loadErrors.push(e)
102
+ }
103
+ } else {
104
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
105
+ }
106
+ } else if (process.platform === 'win32') {
107
+ if (process.arch === 'x64') {
108
+ if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
109
+ try {
110
+ return require('./oci-client.win32-x64-gnu.node')
111
+ } catch (e) {
112
+ loadErrors.push(e)
113
+ }
114
+ try {
115
+ const binding = require('@dfatwork/oci-client-win32-x64-gnu')
116
+ const bindingPackageVersion = require('@dfatwork/oci-client-win32-x64-gnu/package.json').version
117
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
+ }
120
+ return binding
121
+ } catch (e) {
122
+ loadErrors.push(e)
123
+ }
124
+ } else {
125
+ try {
126
+ return require('./oci-client.win32-x64-msvc.node')
127
+ } catch (e) {
128
+ loadErrors.push(e)
129
+ }
130
+ try {
131
+ const binding = require('@dfatwork/oci-client-win32-x64-msvc')
132
+ const bindingPackageVersion = require('@dfatwork/oci-client-win32-x64-msvc/package.json').version
133
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
+ }
136
+ return binding
137
+ } catch (e) {
138
+ loadErrors.push(e)
139
+ }
140
+ }
141
+ } else if (process.arch === 'ia32') {
142
+ try {
143
+ return require('./oci-client.win32-ia32-msvc.node')
144
+ } catch (e) {
145
+ loadErrors.push(e)
146
+ }
147
+ try {
148
+ const binding = require('@dfatwork/oci-client-win32-ia32-msvc')
149
+ const bindingPackageVersion = require('@dfatwork/oci-client-win32-ia32-msvc/package.json').version
150
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
+ }
153
+ return binding
154
+ } catch (e) {
155
+ loadErrors.push(e)
156
+ }
157
+ } else if (process.arch === 'arm64') {
158
+ try {
159
+ return require('./oci-client.win32-arm64-msvc.node')
160
+ } catch (e) {
161
+ loadErrors.push(e)
162
+ }
163
+ try {
164
+ const binding = require('@dfatwork/oci-client-win32-arm64-msvc')
165
+ const bindingPackageVersion = require('@dfatwork/oci-client-win32-arm64-msvc/package.json').version
166
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
+ }
169
+ return binding
170
+ } catch (e) {
171
+ loadErrors.push(e)
172
+ }
173
+ } else {
174
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
175
+ }
176
+ } else if (process.platform === 'darwin') {
177
+ try {
178
+ return require('./oci-client.darwin-universal.node')
179
+ } catch (e) {
180
+ loadErrors.push(e)
181
+ }
182
+ try {
183
+ const binding = require('@dfatwork/oci-client-darwin-universal')
184
+ const bindingPackageVersion = require('@dfatwork/oci-client-darwin-universal/package.json').version
185
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
+ }
188
+ return binding
189
+ } catch (e) {
190
+ loadErrors.push(e)
191
+ }
192
+ if (process.arch === 'x64') {
193
+ try {
194
+ return require('./oci-client.darwin-x64.node')
195
+ } catch (e) {
196
+ loadErrors.push(e)
197
+ }
198
+ try {
199
+ const binding = require('@dfatwork/oci-client-darwin-x64')
200
+ const bindingPackageVersion = require('@dfatwork/oci-client-darwin-x64/package.json').version
201
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
+ }
204
+ return binding
205
+ } catch (e) {
206
+ loadErrors.push(e)
207
+ }
208
+ } else if (process.arch === 'arm64') {
209
+ try {
210
+ return require('./oci-client.darwin-arm64.node')
211
+ } catch (e) {
212
+ loadErrors.push(e)
213
+ }
214
+ try {
215
+ const binding = require('@dfatwork/oci-client-darwin-arm64')
216
+ const bindingPackageVersion = require('@dfatwork/oci-client-darwin-arm64/package.json').version
217
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
+ }
220
+ return binding
221
+ } catch (e) {
222
+ loadErrors.push(e)
223
+ }
224
+ } else {
225
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
226
+ }
227
+ } else if (process.platform === 'freebsd') {
228
+ if (process.arch === 'x64') {
229
+ try {
230
+ return require('./oci-client.freebsd-x64.node')
231
+ } catch (e) {
232
+ loadErrors.push(e)
233
+ }
234
+ try {
235
+ const binding = require('@dfatwork/oci-client-freebsd-x64')
236
+ const bindingPackageVersion = require('@dfatwork/oci-client-freebsd-x64/package.json').version
237
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
+ }
240
+ return binding
241
+ } catch (e) {
242
+ loadErrors.push(e)
243
+ }
244
+ } else if (process.arch === 'arm64') {
245
+ try {
246
+ return require('./oci-client.freebsd-arm64.node')
247
+ } catch (e) {
248
+ loadErrors.push(e)
249
+ }
250
+ try {
251
+ const binding = require('@dfatwork/oci-client-freebsd-arm64')
252
+ const bindingPackageVersion = require('@dfatwork/oci-client-freebsd-arm64/package.json').version
253
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
+ }
256
+ return binding
257
+ } catch (e) {
258
+ loadErrors.push(e)
259
+ }
260
+ } else {
261
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
262
+ }
263
+ } else if (process.platform === 'linux') {
264
+ if (process.arch === 'x64') {
265
+ if (isMusl()) {
266
+ try {
267
+ return require('./oci-client.linux-x64-musl.node')
268
+ } catch (e) {
269
+ loadErrors.push(e)
270
+ }
271
+ try {
272
+ const binding = require('@dfatwork/oci-client-linux-x64-musl')
273
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-x64-musl/package.json').version
274
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
+ }
277
+ return binding
278
+ } catch (e) {
279
+ loadErrors.push(e)
280
+ }
281
+ } else {
282
+ try {
283
+ return require('./oci-client.linux-x64-gnu.node')
284
+ } catch (e) {
285
+ loadErrors.push(e)
286
+ }
287
+ try {
288
+ const binding = require('@dfatwork/oci-client-linux-x64-gnu')
289
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-x64-gnu/package.json').version
290
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
+ }
293
+ return binding
294
+ } catch (e) {
295
+ loadErrors.push(e)
296
+ }
297
+ }
298
+ } else if (process.arch === 'arm64') {
299
+ if (isMusl()) {
300
+ try {
301
+ return require('./oci-client.linux-arm64-musl.node')
302
+ } catch (e) {
303
+ loadErrors.push(e)
304
+ }
305
+ try {
306
+ const binding = require('@dfatwork/oci-client-linux-arm64-musl')
307
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-arm64-musl/package.json').version
308
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
+ }
311
+ return binding
312
+ } catch (e) {
313
+ loadErrors.push(e)
314
+ }
315
+ } else {
316
+ try {
317
+ return require('./oci-client.linux-arm64-gnu.node')
318
+ } catch (e) {
319
+ loadErrors.push(e)
320
+ }
321
+ try {
322
+ const binding = require('@dfatwork/oci-client-linux-arm64-gnu')
323
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-arm64-gnu/package.json').version
324
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
+ }
327
+ return binding
328
+ } catch (e) {
329
+ loadErrors.push(e)
330
+ }
331
+ }
332
+ } else if (process.arch === 'arm') {
333
+ if (isMusl()) {
334
+ try {
335
+ return require('./oci-client.linux-arm-musleabihf.node')
336
+ } catch (e) {
337
+ loadErrors.push(e)
338
+ }
339
+ try {
340
+ const binding = require('@dfatwork/oci-client-linux-arm-musleabihf')
341
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-arm-musleabihf/package.json').version
342
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
+ }
345
+ return binding
346
+ } catch (e) {
347
+ loadErrors.push(e)
348
+ }
349
+ } else {
350
+ try {
351
+ return require('./oci-client.linux-arm-gnueabihf.node')
352
+ } catch (e) {
353
+ loadErrors.push(e)
354
+ }
355
+ try {
356
+ const binding = require('@dfatwork/oci-client-linux-arm-gnueabihf')
357
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-arm-gnueabihf/package.json').version
358
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
+ }
361
+ return binding
362
+ } catch (e) {
363
+ loadErrors.push(e)
364
+ }
365
+ }
366
+ } else if (process.arch === 'loong64') {
367
+ if (isMusl()) {
368
+ try {
369
+ return require('./oci-client.linux-loong64-musl.node')
370
+ } catch (e) {
371
+ loadErrors.push(e)
372
+ }
373
+ try {
374
+ const binding = require('@dfatwork/oci-client-linux-loong64-musl')
375
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-loong64-musl/package.json').version
376
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
+ }
379
+ return binding
380
+ } catch (e) {
381
+ loadErrors.push(e)
382
+ }
383
+ } else {
384
+ try {
385
+ return require('./oci-client.linux-loong64-gnu.node')
386
+ } catch (e) {
387
+ loadErrors.push(e)
388
+ }
389
+ try {
390
+ const binding = require('@dfatwork/oci-client-linux-loong64-gnu')
391
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-loong64-gnu/package.json').version
392
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
+ }
395
+ return binding
396
+ } catch (e) {
397
+ loadErrors.push(e)
398
+ }
399
+ }
400
+ } else if (process.arch === 'riscv64') {
401
+ if (isMusl()) {
402
+ try {
403
+ return require('./oci-client.linux-riscv64-musl.node')
404
+ } catch (e) {
405
+ loadErrors.push(e)
406
+ }
407
+ try {
408
+ const binding = require('@dfatwork/oci-client-linux-riscv64-musl')
409
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-riscv64-musl/package.json').version
410
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
+ }
413
+ return binding
414
+ } catch (e) {
415
+ loadErrors.push(e)
416
+ }
417
+ } else {
418
+ try {
419
+ return require('./oci-client.linux-riscv64-gnu.node')
420
+ } catch (e) {
421
+ loadErrors.push(e)
422
+ }
423
+ try {
424
+ const binding = require('@dfatwork/oci-client-linux-riscv64-gnu')
425
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-riscv64-gnu/package.json').version
426
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
+ }
429
+ return binding
430
+ } catch (e) {
431
+ loadErrors.push(e)
432
+ }
433
+ }
434
+ } else if (process.arch === 'ppc64') {
435
+ try {
436
+ return require('./oci-client.linux-ppc64-gnu.node')
437
+ } catch (e) {
438
+ loadErrors.push(e)
439
+ }
440
+ try {
441
+ const binding = require('@dfatwork/oci-client-linux-ppc64-gnu')
442
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-ppc64-gnu/package.json').version
443
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
+ }
446
+ return binding
447
+ } catch (e) {
448
+ loadErrors.push(e)
449
+ }
450
+ } else if (process.arch === 's390x') {
451
+ try {
452
+ return require('./oci-client.linux-s390x-gnu.node')
453
+ } catch (e) {
454
+ loadErrors.push(e)
455
+ }
456
+ try {
457
+ const binding = require('@dfatwork/oci-client-linux-s390x-gnu')
458
+ const bindingPackageVersion = require('@dfatwork/oci-client-linux-s390x-gnu/package.json').version
459
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
+ }
462
+ return binding
463
+ } catch (e) {
464
+ loadErrors.push(e)
465
+ }
466
+ } else {
467
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
468
+ }
469
+ } else if (process.platform === 'openharmony') {
470
+ if (process.arch === 'arm64') {
471
+ try {
472
+ return require('./oci-client.openharmony-arm64.node')
473
+ } catch (e) {
474
+ loadErrors.push(e)
475
+ }
476
+ try {
477
+ const binding = require('@dfatwork/oci-client-openharmony-arm64')
478
+ const bindingPackageVersion = require('@dfatwork/oci-client-openharmony-arm64/package.json').version
479
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
+ }
482
+ return binding
483
+ } catch (e) {
484
+ loadErrors.push(e)
485
+ }
486
+ } else if (process.arch === 'x64') {
487
+ try {
488
+ return require('./oci-client.openharmony-x64.node')
489
+ } catch (e) {
490
+ loadErrors.push(e)
491
+ }
492
+ try {
493
+ const binding = require('@dfatwork/oci-client-openharmony-x64')
494
+ const bindingPackageVersion = require('@dfatwork/oci-client-openharmony-x64/package.json').version
495
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
+ }
498
+ return binding
499
+ } catch (e) {
500
+ loadErrors.push(e)
501
+ }
502
+ } else if (process.arch === 'arm') {
503
+ try {
504
+ return require('./oci-client.openharmony-arm.node')
505
+ } catch (e) {
506
+ loadErrors.push(e)
507
+ }
508
+ try {
509
+ const binding = require('@dfatwork/oci-client-openharmony-arm')
510
+ const bindingPackageVersion = require('@dfatwork/oci-client-openharmony-arm/package.json').version
511
+ if (bindingPackageVersion !== '0.16.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.16.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
+ }
514
+ return binding
515
+ } catch (e) {
516
+ loadErrors.push(e)
517
+ }
518
+ } else {
519
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
520
+ }
521
+ } else {
522
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
523
+ }
524
+ }
525
+
526
+ nativeBinding = requireNative()
527
+
528
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
529
+ let wasiBinding = null
530
+ let wasiBindingError = null
531
+ try {
532
+ wasiBinding = require('./oci-client.wasi.cjs')
533
+ nativeBinding = wasiBinding
534
+ } catch (err) {
535
+ if (process.env.NAPI_RS_FORCE_WASI) {
536
+ wasiBindingError = err
537
+ }
538
+ }
539
+ if (!nativeBinding) {
540
+ try {
541
+ wasiBinding = require('@dfatwork/oci-client-wasm32-wasi')
542
+ nativeBinding = wasiBinding
543
+ } catch (err) {
544
+ if (process.env.NAPI_RS_FORCE_WASI) {
545
+ wasiBindingError.cause = err
546
+ loadErrors.push(err)
547
+ }
548
+ }
549
+ }
550
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
551
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
552
+ error.cause = wasiBindingError
553
+ throw error
554
+ }
555
+ }
556
+
557
+ if (!nativeBinding) {
558
+ if (loadErrors.length > 0) {
559
+ throw new Error(
560
+ `Cannot find native binding. ` +
561
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
562
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
563
+ {
564
+ cause: loadErrors.reduce((err, cur) => {
565
+ cur.cause = err
566
+ return cur
567
+ }),
568
+ },
569
+ )
570
+ }
571
+ throw new Error(`Failed to load native binding`)
572
+ }
573
+
574
+ module.exports = nativeBinding
575
+ module.exports.OciClient = nativeBinding.OciClient
576
+ module.exports.anonymousAuth = nativeBinding.anonymousAuth
577
+ module.exports.basicAuth = nativeBinding.basicAuth
578
+ module.exports.bearerAuth = nativeBinding.bearerAuth
579
+ module.exports.CertificateEncoding = nativeBinding.CertificateEncoding
580
+ module.exports.ClientProtocol = nativeBinding.ClientProtocol
581
+ module.exports.IMAGE_CONFIG_MEDIA_TYPE = nativeBinding.IMAGE_CONFIG_MEDIA_TYPE
582
+ module.exports.IMAGE_DOCKER_CONFIG_MEDIA_TYPE = nativeBinding.IMAGE_DOCKER_CONFIG_MEDIA_TYPE
583
+ module.exports.IMAGE_DOCKER_LAYER_GZIP_MEDIA_TYPE = nativeBinding.IMAGE_DOCKER_LAYER_GZIP_MEDIA_TYPE
584
+ module.exports.IMAGE_DOCKER_LAYER_TAR_MEDIA_TYPE = nativeBinding.IMAGE_DOCKER_LAYER_TAR_MEDIA_TYPE
585
+ module.exports.IMAGE_LAYER_GZIP_MEDIA_TYPE = nativeBinding.IMAGE_LAYER_GZIP_MEDIA_TYPE
586
+ module.exports.IMAGE_LAYER_MEDIA_TYPE = nativeBinding.IMAGE_LAYER_MEDIA_TYPE
587
+ module.exports.IMAGE_LAYER_NONDISTRIBUTABLE_GZIP_MEDIA_TYPE = nativeBinding.IMAGE_LAYER_NONDISTRIBUTABLE_GZIP_MEDIA_TYPE
588
+ module.exports.IMAGE_LAYER_NONDISTRIBUTABLE_MEDIA_TYPE = nativeBinding.IMAGE_LAYER_NONDISTRIBUTABLE_MEDIA_TYPE
589
+ module.exports.IMAGE_MANIFEST_LIST_MEDIA_TYPE = nativeBinding.IMAGE_MANIFEST_LIST_MEDIA_TYPE
590
+ module.exports.IMAGE_MANIFEST_MEDIA_TYPE = nativeBinding.IMAGE_MANIFEST_MEDIA_TYPE
591
+ module.exports.ManifestType = nativeBinding.ManifestType
592
+ module.exports.OCI_IMAGE_INDEX_MEDIA_TYPE = nativeBinding.OCI_IMAGE_INDEX_MEDIA_TYPE
593
+ module.exports.OCI_IMAGE_MEDIA_TYPE = nativeBinding.OCI_IMAGE_MEDIA_TYPE
594
+ module.exports.ORG_OPENCONTAINERS_IMAGE_AUTHORS = nativeBinding.ORG_OPENCONTAINERS_IMAGE_AUTHORS
595
+ module.exports.ORG_OPENCONTAINERS_IMAGE_BASE_DIGEST = nativeBinding.ORG_OPENCONTAINERS_IMAGE_BASE_DIGEST
596
+ module.exports.ORG_OPENCONTAINERS_IMAGE_BASE_NAME = nativeBinding.ORG_OPENCONTAINERS_IMAGE_BASE_NAME
597
+ module.exports.ORG_OPENCONTAINERS_IMAGE_CREATED = nativeBinding.ORG_OPENCONTAINERS_IMAGE_CREATED
598
+ module.exports.ORG_OPENCONTAINERS_IMAGE_DESCRIPTION = nativeBinding.ORG_OPENCONTAINERS_IMAGE_DESCRIPTION
599
+ module.exports.ORG_OPENCONTAINERS_IMAGE_DOCUMENTATION = nativeBinding.ORG_OPENCONTAINERS_IMAGE_DOCUMENTATION
600
+ module.exports.ORG_OPENCONTAINERS_IMAGE_LICENSES = nativeBinding.ORG_OPENCONTAINERS_IMAGE_LICENSES
601
+ module.exports.ORG_OPENCONTAINERS_IMAGE_REF_NAME = nativeBinding.ORG_OPENCONTAINERS_IMAGE_REF_NAME
602
+ module.exports.ORG_OPENCONTAINERS_IMAGE_REVISION = nativeBinding.ORG_OPENCONTAINERS_IMAGE_REVISION
603
+ module.exports.ORG_OPENCONTAINERS_IMAGE_SOURCE = nativeBinding.ORG_OPENCONTAINERS_IMAGE_SOURCE
604
+ module.exports.ORG_OPENCONTAINERS_IMAGE_TITLE = nativeBinding.ORG_OPENCONTAINERS_IMAGE_TITLE
605
+ module.exports.ORG_OPENCONTAINERS_IMAGE_URL = nativeBinding.ORG_OPENCONTAINERS_IMAGE_URL
606
+ module.exports.ORG_OPENCONTAINERS_IMAGE_VENDOR = nativeBinding.ORG_OPENCONTAINERS_IMAGE_VENDOR
607
+ module.exports.ORG_OPENCONTAINERS_IMAGE_VERSION = nativeBinding.ORG_OPENCONTAINERS_IMAGE_VERSION
608
+ module.exports.RegistryAuthType = nativeBinding.RegistryAuthType
609
+ module.exports.WASM_CONFIG_MEDIA_TYPE = nativeBinding.WASM_CONFIG_MEDIA_TYPE
610
+ module.exports.WASM_LAYER_MEDIA_TYPE = nativeBinding.WASM_LAYER_MEDIA_TYPE
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@dfatwork/oci-client",
3
+ "version": "0.16.1",
4
+ "description": "Node.js bindings for rust-oci-client - OCI Distribution client",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "index.d.ts",
9
+ "index.js"
10
+ ],
11
+ "napi": {
12
+ "binaryName": "oci-client",
13
+ "targets": [
14
+ "x86_64-pc-windows-msvc",
15
+ "x86_64-apple-darwin",
16
+ "x86_64-unknown-linux-gnu",
17
+ "x86_64-unknown-linux-musl",
18
+ "aarch64-unknown-linux-gnu",
19
+ "aarch64-apple-darwin",
20
+ "aarch64-unknown-linux-musl"
21
+ ]
22
+ },
23
+ "engines": {
24
+ "node": ">= 22"
25
+ },
26
+ "publishConfig": {
27
+ "registry": "https://registry.npmjs.org/",
28
+ "access": "public"
29
+ },
30
+ "scripts": {
31
+ "artifacts": "napi artifacts",
32
+ "build": "yarn sync-version && napi build --platform --release && yarn fix-const-enums",
33
+ "build:debug": "yarn sync-version && napi build --platform && yarn fix-const-enums",
34
+ "fix-const-enums": "node scripts/fix-const-enums.js",
35
+ "lint": "oxlint .",
36
+ "prepublishOnly": "napi prepublish -t npm --no-gh-release",
37
+ "test": "ava",
38
+ "version": "napi version",
39
+ "sync-version": "node scripts/sync-version.js"
40
+ },
41
+ "devDependencies": {
42
+ "@napi-rs/cli": "^3.2.0",
43
+ "@oxc-node/core": "^0.0.35",
44
+ "@types/node": "^20.0.0",
45
+ "ava": "^6.4.1",
46
+ "oxlint": "^1.14.0",
47
+ "typescript": "^5.9.2"
48
+ },
49
+ "ava": {
50
+ "extensions": {
51
+ "ts": "module"
52
+ },
53
+ "timeout": "2m",
54
+ "workerThreads": false,
55
+ "environmentVariables": {
56
+ "OXC_TSCONFIG_PATH": "./__test__/tsconfig.json"
57
+ },
58
+ "nodeArguments": [
59
+ "--import",
60
+ "@oxc-node/core/register"
61
+ ]
62
+ },
63
+ "keywords": [
64
+ "oci",
65
+ "registry",
66
+ "container",
67
+ "docker",
68
+ "distribution",
69
+ "napi",
70
+ "rust",
71
+ "bindings"
72
+ ],
73
+ "author": "dfestal@redhat.com",
74
+ "license": "Apache-2.0",
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "git+https://github.com/davidfestal/rust-oci-client.git",
78
+ "directory": "bindings/nodejs"
79
+ },
80
+ "packageManager": "yarn@4.12.0",
81
+ "optionalDependencies": {
82
+ "@dfatwork/oci-client-win32-x64-msvc": "0.16.1",
83
+ "@dfatwork/oci-client-darwin-x64": "0.16.1",
84
+ "@dfatwork/oci-client-linux-x64-gnu": "0.16.1",
85
+ "@dfatwork/oci-client-linux-x64-musl": "0.16.1",
86
+ "@dfatwork/oci-client-linux-arm64-gnu": "0.16.1",
87
+ "@dfatwork/oci-client-darwin-arm64": "0.16.1",
88
+ "@dfatwork/oci-client-linux-arm64-musl": "0.16.1"
89
+ }
90
+ }