RegistryClient
Class: RegistryClient
Defined in: packages/oci/src/registry.ts:70
Client of the OCI distribution API (/v2/) for one registry
Handles the registry token authentication: a request without token gets a 401 with a
WWW-Authenticate challenge, the client then asks the token service for the needed scopes
and retries. Tokens are cached per scope.
Constructors
Constructor
new RegistryClient(
registry,options?):RegistryClient
Defined in: packages/oci/src/registry.ts:92
Parameters
registry
string
registry from the image reference
options?
the options
Returns
RegistryClient
Properties
baseUrl
readonlybaseUrl:string
Defined in: packages/oci/src/registry.ts:74
Base URL of the API
challenge?
protectedoptionalchallenge?:AuthChallenge
Defined in: packages/oci/src/registry.ts:82
Last challenge, to request tokens without a failing request first
fetch
protectedfetch: {(input,init?):Promise<Response>; (input,init?):Promise<Response>; }
Defined in: packages/oci/src/registry.ts:86
fetch implementation
Call Signature
(
input,init?):Promise<Response>
Parameters
input
RequestInfo | URL
init?
RequestInit
Returns
Promise<Response>
Call Signature
(
input,init?):Promise<Response>
Parameters
input
string | Request | URL
init?
RequestInit
Returns
Promise<Response>
options
protectedoptions:RegistryClientOptions={}
Defined in: packages/oci/src/registry.ts:94
the options
registry
readonlyregistry:string
Defined in: packages/oci/src/registry.ts:93
registry from the image reference
tokens
protectedtokens:Map<string,string>
Defined in: packages/oci/src/registry.ts:78
Tokens per scope
Methods
authorization()
protectedauthorization(scopes):Promise<string>
Defined in: packages/oci/src/registry.ts:164
Authorization header for scopes, from the last challenge
Parameters
scopes
string[]
the scopes
Returns
Promise<string>
the header value, undefined before any challenge
fail()
protectedfail(response,action):Promise<never>
Defined in: packages/oci/src/registry.ts:234
Throw a RegistryError for an unexpected response
Parameters
response
Response
the response
action
string
what was attempted
Returns
Promise<never>
getBlob()
getBlob(
repository,digest):Promise<Response>
Defined in: packages/oci/src/registry.ts:279
Fetch a blob
Parameters
repository
string
the repository
digest
string
the blob digest
Returns
Promise<Response>
the response with the content as body
getManifest()
getManifest(
repository,reference):Promise<FetchedManifest>
Defined in: packages/oci/src/registry.ts:246
Fetch a manifest or index
Parameters
repository
string
the repository
reference
string
tag or digest
Returns
Promise<FetchedManifest>
the manifest
getToken()
protectedgetToken(challenge,scopes):Promise<string>
Defined in: packages/oci/src/registry.ts:109
Get a bearer token for scopes from the challenge realm
Parameters
challenge
the bearer challenge
scopes
string[]
the scopes, repository:<name>:pull,push
Returns
Promise<string>
the token
hasBlob()
hasBlob(
repository,digest):Promise<boolean>
Defined in: packages/oci/src/registry.ts:294
Check whether a blob exists in a repository
Parameters
repository
string
the repository
digest
string
the blob digest
Returns
Promise<boolean>
true if present
mountBlob()
mountBlob(
repository,digest,from):Promise<boolean>
Defined in: packages/oci/src/registry.ts:309
Mount a blob from another repository of the same registry
Parameters
repository
string
the target repository
digest
string
the blob digest
from
string
the source repository
Returns
Promise<boolean>
true when mounted, false when the registry does not support it or the blob is missing
putManifest()
putManifest(
repository,reference,bytes,mediaType):Promise<string>
Defined in: packages/oci/src/registry.ts:365
Put a manifest or index
Parameters
repository
string
the repository
reference
string
tag or digest
bytes
Buffer
the exact bytes
mediaType
string
its media type
Returns
Promise<string>
the digest returned by the registry
request()
request(
method,path,scopes,init?):Promise<Response>
Defined in: packages/oci/src/registry.ts:193
Send an API request, authenticating on challenge
Parameters
method
string
HTTP method
path
string
path or absolute URL (upload locations)
scopes
string[]
scopes the request needs
init?
additional request options
body?
() => any
factory of the body, called again when the request is replayed
headers?
Record<string, string>
request headers
redirect?
RequestRedirect
redirect mode
Returns
Promise<Response>
the response
uploadBlob()
uploadBlob(
repository,digest,size,body):Promise<void>
Defined in: packages/oci/src/registry.ts:337
Upload a blob in one request
Parameters
repository
string
the repository
digest
string
the blob digest
size
number
its size
body
() => Buffer<ArrayBufferLike> | Readable
factory of the content, called again if the request is replayed
Returns
Promise<void>