https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
@@ -0,0 +1,86 @@
/// <reference types="node" />
import * as http from 'node:http';
import { CredentialProvider } from "./CredentialProvider.mjs";
import { Credentials } from "./Credentials.mjs";
/**
* @see https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
*/
type CredentialResponse = {
ErrorResponse?: {
Error?: {
Code?: string;
Message?: string;
};
};
AssumeRoleResponse: {
AssumeRoleResult: {
Credentials: {
AccessKeyId: string;
SecretAccessKey: string;
SessionToken: string;
Expiration: string;
};
};
};
};
export interface AssumeRoleProviderOptions {
stsEndpoint: string;
accessKey: string;
secretKey: string;
durationSeconds?: number;
sessionToken?: string;
policy?: string;
region?: string;
roleArn?: string;
roleSessionName?: string;
externalId?: string;
token?: string;
webIdentityToken?: string;
action?: string;
transportAgent?: http.Agent;
}
export declare class AssumeRoleProvider extends CredentialProvider {
private readonly stsEndpoint;
private readonly accessKey;
private readonly secretKey;
private readonly durationSeconds;
private readonly policy?;
private readonly region;
private readonly roleArn?;
private readonly roleSessionName?;
private readonly externalId?;
private readonly token?;
private readonly webIdentityToken?;
private readonly action;
private _credentials;
private readonly expirySeconds;
private accessExpiresAt;
private readonly transportAgent?;
private readonly transport;
constructor({
stsEndpoint,
accessKey,
secretKey,
durationSeconds,
sessionToken,
policy,
region,
roleArn,
roleSessionName,
externalId,
token,
webIdentityToken,
action,
transportAgent
}: AssumeRoleProviderOptions);
getRequestConfig(): {
requestOptions: http.RequestOptions;
requestData: string;
};
performRequest(): Promise<CredentialResponse>;
parseCredentials(respObj: CredentialResponse): Credentials;
refreshCredentials(): Promise<Credentials>;
getCredentials(): Promise<Credentials>;
isAboutToExpire(): boolean;
}
export default AssumeRoleProvider;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,22 @@
import { Credentials } from "./Credentials.mjs";
export declare class CredentialProvider {
private credentials;
constructor({
accessKey,
secretKey,
sessionToken
}: {
accessKey: string;
secretKey: string;
sessionToken?: string;
});
getCredentials(): Promise<Credentials>;
setCredentials(credentials: Credentials): void;
setAccessKey(accessKey: string): void;
getAccessKey(): string;
setSecretKey(secretKey: string): void;
getSecretKey(): string;
setSessionToken(sessionToken: string): void;
getSessionToken(): string | undefined;
}
export default CredentialProvider;
+48
View File
@@ -0,0 +1,48 @@
import { Credentials } from "./Credentials.mjs";
export class CredentialProvider {
constructor({
accessKey,
secretKey,
sessionToken
}) {
this.credentials = new Credentials({
accessKey,
secretKey,
sessionToken
});
}
async getCredentials() {
return this.credentials.get();
}
setCredentials(credentials) {
if (credentials instanceof Credentials) {
this.credentials = credentials;
} else {
throw new Error('Unable to set Credentials. it should be an instance of Credentials class');
}
}
setAccessKey(accessKey) {
this.credentials.setAccessKey(accessKey);
}
getAccessKey() {
return this.credentials.getAccessKey();
}
setSecretKey(secretKey) {
this.credentials.setSecretKey(secretKey);
}
getSecretKey() {
return this.credentials.getSecretKey();
}
setSessionToken(sessionToken) {
this.credentials.setSessionToken(sessionToken);
}
getSessionToken() {
return this.credentials.getSessionToken();
}
}
// deprecated default export, please use named exports.
// keep for backward compatibility.
// eslint-disable-next-line import/no-default-export
export default CredentialProvider;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDcmVkZW50aWFscyIsIkNyZWRlbnRpYWxQcm92aWRlciIsImNvbnN0cnVjdG9yIiwiYWNjZXNzS2V5Iiwic2VjcmV0S2V5Iiwic2Vzc2lvblRva2VuIiwiY3JlZGVudGlhbHMiLCJnZXRDcmVkZW50aWFscyIsImdldCIsInNldENyZWRlbnRpYWxzIiwiRXJyb3IiLCJzZXRBY2Nlc3NLZXkiLCJnZXRBY2Nlc3NLZXkiLCJzZXRTZWNyZXRLZXkiLCJnZXRTZWNyZXRLZXkiLCJzZXRTZXNzaW9uVG9rZW4iLCJnZXRTZXNzaW9uVG9rZW4iXSw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FQUMzQztBQUNGOztBQUVBO0FBQ0E7QUFDQTtBQUNBLGVBQWVmLGtCQUFrQiJ9
+22
View File
@@ -0,0 +1,22 @@
export declare class Credentials {
accessKey: string;
secretKey: string;
sessionToken?: string;
constructor({
accessKey,
secretKey,
sessionToken
}: {
accessKey: string;
secretKey: string;
sessionToken?: string;
});
setAccessKey(accessKey: string): void;
getAccessKey(): string;
setSecretKey(secretKey: string): void;
getSecretKey(): string;
setSessionToken(sessionToken: string): void;
getSessionToken(): string | undefined;
get(): Credentials;
}
export default Credentials;
+38
View File
@@ -0,0 +1,38 @@
export class Credentials {
constructor({
accessKey,
secretKey,
sessionToken
}) {
this.accessKey = accessKey;
this.secretKey = secretKey;
this.sessionToken = sessionToken;
}
setAccessKey(accessKey) {
this.accessKey = accessKey;
}
getAccessKey() {
return this.accessKey;
}
setSecretKey(secretKey) {
this.secretKey = secretKey;
}
getSecretKey() {
return this.secretKey;
}
setSessionToken(sessionToken) {
this.sessionToken = sessionToken;
}
getSessionToken() {
return this.sessionToken;
}
get() {
return this;
}
}
// deprecated default export, please use named exports.
// keep for backward compatibility.
// eslint-disable-next-line import/no-default-export
export default Credentials;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDcmVkZW50aWFscyIsImNvbnN0cnVjdG9yIiwiYWNjZXNzS2V5Iiwic2VjcmV0S2V5Iiwic2Vzc2lvblRva2VuIiwic2V0QWNjZXNzS2V5IiwiZ2V0QWNjZXNzS2V5Iiwic2V0U2VjcmV0S2V5IiwiZ2V0U2VjcmV0S2V5Iiwic2V0U2Vzc2lvblRva2VuIiwiZ2V0U2Vzc2lvblRva2VuIiwiZ2V0Il0sInNvdXJjZXMiOlsiQ3JlZGVudGlhbHMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGNsYXNzIENyZWRlbnRpYWxzIHtcbiAgcHVibGljIGFjY2Vzc0tleTogc3RyaW5nXG4gIHB1YmxpYyB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+27
View File
@@ -0,0 +1,27 @@
/// <reference types="node" />
import * as http from 'node:http';
import { CredentialProvider } from "./CredentialProvider.mjs";
import { Credentials } from "./Credentials.mjs";
export interface IamAwsProviderOptions {
customEndpoint?: string;
transportAgent?: http.Agent;
}
export declare class IamAwsProvider extends CredentialProvider {
private readonly customEndpoint?;
private _credentials;
private readonly transportAgent?;
private accessExpiresAt;
constructor({
customEndpoint,
transportAgent
}: IamAwsProviderOptions);
getCredentials(): Promise<Credentials>;
private fetchCredentials;
private fetchCredentialsUsingTokenFile;
private fetchImdsToken;
private getIamRoleNamedUrl;
private getIamRoleName;
private requestCredentials;
private isAboutToExpire;
}
export default IamAwsProvider;
File diff suppressed because one or more lines are too long
+82
View File
@@ -0,0 +1,82 @@
/// <reference lib="es2022.error" />
declare class ExtendableError extends Error {
constructor(message?: string, opt?: ErrorOptions);
}
/**
* AnonymousRequestError is generated for anonymous keys on specific
* APIs. NOTE: PresignedURL generation always requires access keys.
*/
export declare class AnonymousRequestError extends ExtendableError {}
/**
* InvalidArgumentError is generated for all invalid arguments.
*/
export declare class InvalidArgumentError extends ExtendableError {}
/**
* InvalidPortError is generated when a non integer value is provided
* for ports.
*/
export declare class InvalidPortError extends ExtendableError {}
/**
* InvalidEndpointError is generated when an invalid end point value is
* provided which does not follow domain standards.
*/
export declare class InvalidEndpointError extends ExtendableError {}
/**
* InvalidBucketNameError is generated when an invalid bucket name is
* provided which does not follow AWS S3 specifications.
* http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
*/
export declare class InvalidBucketNameError extends ExtendableError {}
/**
* InvalidObjectNameError is generated when an invalid object name is
* provided which does not follow AWS S3 specifications.
* http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
*/
export declare class InvalidObjectNameError extends ExtendableError {}
/**
* AccessKeyRequiredError generated by signature methods when access
* key is not found.
*/
export declare class AccessKeyRequiredError extends ExtendableError {}
/**
* SecretKeyRequiredError generated by signature methods when secret
* key is not found.
*/
export declare class SecretKeyRequiredError extends ExtendableError {}
/**
* ExpiresParamError generated when expires parameter value is not
* well within stipulated limits.
*/
export declare class ExpiresParamError extends ExtendableError {}
/**
* InvalidDateError generated when invalid date is found.
*/
export declare class InvalidDateError extends ExtendableError {}
/**
* InvalidPrefixError generated when object prefix provided is invalid
* or does not conform to AWS S3 object key restrictions.
*/
export declare class InvalidPrefixError extends ExtendableError {}
/**
* InvalidBucketPolicyError generated when the given bucket policy is invalid.
*/
export declare class InvalidBucketPolicyError extends ExtendableError {}
/**
* IncorrectSizeError generated when total data read mismatches with
* the input size.
*/
export declare class IncorrectSizeError extends ExtendableError {}
/**
* InvalidXMLError generated when an unknown XML is found.
*/
export declare class InvalidXMLError extends ExtendableError {}
/**
* S3Error is generated for errors returned from S3 server.
* see getErrorTransformer for details
*/
export declare class S3Error extends ExtendableError {
code?: string;
region?: string;
}
export declare class IsValidBucketNameError extends ExtendableError {}
export {};
File diff suppressed because one or more lines are too long
+156
View File
@@ -0,0 +1,156 @@
import type { Encryption, ObjectMetaData, RequestHeaders } from "./internal/type.mjs";
import { RETENTION_MODES } from "./internal/type.mjs";
export { ENCRYPTION_TYPES, LEGAL_HOLD_STATUS, RETENTION_MODES, RETENTION_VALIDITY_UNITS } from "./internal/type.mjs";
export declare const DEFAULT_REGION = "us-east-1";
export declare const PRESIGN_EXPIRY_DAYS_MAX: number;
export interface ICopySourceOptions {
Bucket: string;
Object: string;
/**
* Valid versionId
*/
VersionID?: string;
/**
* Etag to match
*/
MatchETag?: string;
/**
* Etag to exclude
*/
NoMatchETag?: string;
/**
* Modified Date of the object/part. UTC Date in string format
*/
MatchModifiedSince?: string | null;
/**
* Modified Date of the object/part to exclude UTC Date in string format
*/
MatchUnmodifiedSince?: string | null;
/**
* true or false Object range to match
*/
MatchRange?: boolean;
Start?: number;
End?: number;
Encryption?: Encryption;
}
export declare class CopySourceOptions {
readonly Bucket: string;
readonly Object: string;
readonly VersionID: string;
MatchETag: string;
private readonly NoMatchETag;
private readonly MatchModifiedSince;
private readonly MatchUnmodifiedSince;
readonly MatchRange: boolean;
readonly Start: number;
readonly End: number;
private readonly Encryption?;
constructor({
Bucket,
Object,
VersionID,
MatchETag,
NoMatchETag,
MatchModifiedSince,
MatchUnmodifiedSince,
MatchRange,
Start,
End,
Encryption
}: ICopySourceOptions);
validate(): boolean;
getHeaders(): RequestHeaders;
}
/**
* @deprecated use nodejs fs module
*/
export declare function removeDirAndFiles(dirPath: string, removeSelf?: boolean): void;
export interface ICopyDestinationOptions {
/**
* Bucket name
*/
Bucket: string;
/**
* Object Name for the destination (composed/copied) object defaults
*/
Object: string;
/**
* Encryption configuration defaults to {}
* @default {}
*/
Encryption?: Encryption;
UserMetadata?: ObjectMetaData;
/**
* query-string encoded string or Record<string, string> Object
*/
UserTags?: Record<string, string> | string;
LegalHold?: 'on' | 'off';
/**
* UTC Date String
*/
RetainUntilDate?: string;
Mode?: RETENTION_MODES;
MetadataDirective?: 'COPY' | 'REPLACE';
/**
* Extra headers for the target object
*/
Headers?: Record<string, string>;
}
export declare class CopyDestinationOptions {
readonly Bucket: string;
readonly Object: string;
private readonly Encryption?;
private readonly UserMetadata?;
private readonly UserTags?;
private readonly LegalHold?;
private readonly RetainUntilDate?;
private readonly Mode?;
private readonly MetadataDirective?;
private readonly Headers?;
constructor({
Bucket,
Object,
Encryption,
UserMetadata,
UserTags,
LegalHold,
RetainUntilDate,
Mode,
MetadataDirective,
Headers
}: ICopyDestinationOptions);
getHeaders(): RequestHeaders;
validate(): boolean;
}
/**
* maybe this should be a generic type for Records, leave it for later refactor
*/
export declare class SelectResults {
private records?;
private response?;
private stats?;
private progress?;
constructor({
records,
// parsed data as stream
response,
// original response stream
stats,
// stats as xml
progress
}: {
records?: unknown;
response?: unknown;
stats?: string;
progress?: unknown;
});
setStats(stats: string): void;
getStats(): string | undefined;
setProgress(progress: unknown): void;
getProgress(): unknown;
setResponse(response: unknown): void;
getResponse(): unknown;
setRecords(records: unknown): void;
getRecords(): unknown;
}
File diff suppressed because one or more lines are too long
+9
View File
@@ -0,0 +1,9 @@
/// <reference types="node" />
/// <reference types="node" />
import * as fs from 'node:fs';
import * as stream from 'node:stream';
export { promises as fsp } from 'node:fs';
export declare const streamPromise: {
pipeline: typeof stream.pipeline.__promisify__;
};
export declare const fstat: typeof fs.fstat.__promisify__;
+14
View File
@@ -0,0 +1,14 @@
// promise helper for stdlib
import * as fs from "fs";
import * as stream from "stream";
import { promisify } from "util";
// TODO: use "node:fs/promise" directly after we stop testing on nodejs 12
export { promises as fsp } from 'node:fs';
export const streamPromise = {
// node:stream/promises Added in: v15.0.0
pipeline: promisify(stream.pipeline)
};
export const fstat = promisify(fs.fstat);
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJmcyIsInN0cmVhbSIsInByb21pc2lmeSIsInByb21pc2VzIiwiZnNwIiwic3RyZWFtUHJvbWlzZSIsInBpcGVsaW5lIiwiZnN0YXQiXSwic291cmNlcyI6WyJhc3luYy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyBwcm9taXNlIGhlbHBlciBmb3Igc3RkbGliXG5cbmltcG9ydCAqIGFzIGZzIGZyb20gJ25vZGU6ZnMnXG5pbXBvcnQgKiBhcyBzdHJlYW0gZnJvbSAnbm9kZTpzdHJlYW0nXG5pbXBvcnQgeyBwcm9taXNpZnkgfSBmcm9tICdub2RlOnV0aWwnXG5cbi8vIFRPRE86IHVzZSBcIm5vZGU6ZnMvcHJvbWlzZVwiIGRpcmVjdGx5IGFmdGVyIHdlIHN0b3AgdGVzdGluZyBvbiBub2RlanMgMTJcbmV4cG9ydCB7IHByb21pc2VzIGFzIGZzcCB9IGZyb20gJ25vZGU6ZnMnXG5leHBvcnQgY29uc3Qgc3RyZWFtUHJvbWlzZSA9IHtcbiAgLy8gbm9kZTpzdHJlYW0vcHJvbWlzZXMgQWRkZWQgaW46IHYxNS4wLjBcbiAgcGlwZWxpbmU6IHByb21pc2lmeShzdHJlYW0ucGlwZWxpbmUpLFxufVxuXG5leHBvcnQgY29uc3QgZnN0YXQgPSBwcm9taXNpZnkoZnMuZnN0YXQpXG4iXSwibWFwcGluZ3MiOiJBQUFBOztBQUVBLE9BQU8sS0FBS0EsRUFBRTtBQUNkLE9BQU8sS0FBS0MsTUFBTTtBQUNsQixTQUFTQyxTQUFTOztBQUVsQjtBQUNBLFNBQVNDLFFBQVEsSUFBSUMsR0FBRyxRQUFRLFNBQVM7QUFDekMsT0FBTyxNQUFNQyxhQUFhLEdBQUc7RUFDM0I7RUFDQUMsUUFBUSxFQUFFSixTQUFTLENBQUNELE1BQU0sQ0FBQ0ssUUFBUTtBQUNyQyxDQUFDO0FBRUQsT0FBTyxNQUFNQyxLQUFLLEdBQUdMLFNBQVMsQ0FBQ0YsRUFBRSxDQUFDTyxLQUFLLENBQUMifQ==
@@ -0,0 +1,15 @@
// wrapper an async function that support callback style API.
// It will preserve 'this'.
export function callbackify(fn) {
return function () {
const args = [...arguments];
const callback = args.pop();
// If the last argument is a function, assume it's the callback.
if (typeof callback === 'function') {
return fn.apply(this, args).then(result => callback(null, result), err => callback(err));
}
return fn.apply(this, arguments);
};
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJjYWxsYmFja2lmeSIsImZuIiwiYXJncyIsImFyZ3VtZW50cyIsImNhbGxiYWNrIiwicG9wIiwiYXBwbHkiLCJ0aGVuIiwicmVzdWx0IiwiZXJyIl0sInNvdXJjZXMiOlsiY2FsbGJhY2tpZnkuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gd3JhcHBlciBhbiBhc3luYyBmdW5jdGlvbiB0aGF0IHN1cHBvcnQgY2FsbGJhY2sgc3R5bGUgQVBJLlxuLy8gSXQgd2lsbCBwcmVzZXJ2ZSAndGhpcycuXG5leHBvcnQgZnVuY3Rpb24gY2FsbGJhY2tpZnkoZm4pIHtcbiAgcmV0dXJuIGZ1bmN0aW9uICgp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QUM7QUFDSCJ9
+359
View File
@@ -0,0 +1,359 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'node:http';
import * as https from 'node:https';
import * as stream from 'node:stream';
import { CredentialProvider } from "../CredentialProvider.mjs";
import type { SelectResults } from "../helpers.mjs";
import { CopyDestinationOptions, CopySourceOptions, LEGAL_HOLD_STATUS } from "../helpers.mjs";
import type { PostPolicyResult } from "../minio.mjs";
import { CopyConditions } from "./copy-conditions.mjs";
import { Extensions } from "./extensions.mjs";
import { PostPolicy } from "./post-policy.mjs";
import type { Region } from "./s3-endpoints.mjs";
import type { Binary, BucketItemFromList, BucketItemStat, BucketStream, BucketVersioningConfiguration, CopyObjectResult, EncryptionConfig, GetObjectLegalHoldOptions, GetObjectOpts, GetObjectRetentionOpts, IncompleteUploadedBucketItem, IRequest, ItemBucketMetadata, LifecycleConfig, LifeCycleConfigParam, ListObjectQueryOpts, ObjectInfo, ObjectLockInfo, ObjectMetaData, ObjectRetentionInfo, PreSignRequestParams, PutObjectLegalHoldOptions, RemoveObjectsParam, RemoveObjectsResponse, ReplicationConfig, ReplicationConfigOpts, RequestHeaders, ResultCallback, Retention, SelectOptions, StatObjectOpts, Tag, TaggingOpts, Tags, Transport, UploadedObjectInfo } from "./type.mjs";
import type { ListMultipartResult, UploadedPart } from "./xml-parser.mjs";
declare const requestOptionProperties: readonly ["agent", "ca", "cert", "ciphers", "clientCertEngine", "crl", "dhparam", "ecdhCurve", "family", "honorCipherOrder", "key", "passphrase", "pfx", "rejectUnauthorized", "secureOptions", "secureProtocol", "servername", "sessionIdContext"];
export interface ClientOptions {
endPoint: string;
accessKey?: string;
secretKey?: string;
useSSL?: boolean;
port?: number;
region?: Region;
transport?: Transport;
sessionToken?: string;
partSize?: number;
pathStyle?: boolean;
credentialsProvider?: CredentialProvider;
s3AccelerateEndpoint?: string;
transportAgent?: http.Agent;
}
export type RequestOption = Partial<IRequest> & {
method: string;
bucketName?: string;
objectName?: string;
query?: string;
pathStyle?: boolean;
};
export type NoResultCallback = (error: unknown) => void;
export interface MakeBucketOpt {
ObjectLocking?: boolean;
}
export interface RemoveOptions {
versionId?: string;
governanceBypass?: boolean;
forceDelete?: boolean;
}
export declare class TypedClient {
protected transport: Transport;
protected host: string;
protected port: number;
protected protocol: string;
protected accessKey: string;
protected secretKey: string;
protected sessionToken?: string;
protected userAgent: string;
protected anonymous: boolean;
protected pathStyle: boolean;
protected regionMap: Record<string, string>;
region?: string;
protected credentialsProvider?: CredentialProvider;
partSize: number;
protected overRidePartSize?: boolean;
protected maximumPartSize: number;
protected maxObjectSize: number;
enableSHA256: boolean;
protected s3AccelerateEndpoint?: string;
protected reqOptions: Record<string, unknown>;
protected transportAgent: http.Agent;
private readonly clientExtensions;
constructor(params: ClientOptions);
/**
* Minio extensions that aren't necessary present for Amazon S3 compatible storage servers
*/
get extensions(): Extensions;
/**
* @param endPoint - valid S3 acceleration end point
*/
setS3TransferAccelerate(endPoint: string): void;
/**
* Sets the supported request options.
*/
setRequestOptions(options: Pick<https.RequestOptions, (typeof requestOptionProperties)[number]>): void;
/**
* This is s3 Specific and does not hold validity in any other Object storage.
*/
private getAccelerateEndPointIfSet;
/**
* Set application specific information.
* Generates User-Agent in the following style.
* MinIO (OS; ARCH) LIB/VER APP/VER
*/
setAppInfo(appName: string, appVersion: string): void;
/**
* returns options object that can be used with http.request()
* Takes care of constructing virtual-host-style or path-style hostname
*/
protected getRequestOptions(opts: RequestOption & {
region: string;
}): IRequest & {
host: string;
headers: Record<string, string>;
};
setCredentialsProvider(credentialsProvider: CredentialProvider): Promise<void>;
private checkAndRefreshCreds;
private logStream?;
/**
* log the request, response, error
*/
private logHTTP;
/**
* Enable tracing
*/
traceOn(stream?: stream.Writable): void;
/**
* Disable tracing
*/
traceOff(): void;
/**
* makeRequest is the primitive used by the apis for making S3 requests.
* payload can be empty string in case of no payload.
* statusCode is the expected statusCode. If response.statusCode does not match
* we parse the XML error and call the callback with the error message.
*
* A valid region is passed by the calls - listBuckets, makeBucket and getBucketRegion.
*
* @internal
*/
makeRequestAsync(options: RequestOption, payload?: Binary, expectedCodes?: number[], region?: string): Promise<http.IncomingMessage>;
/**
* new request with promise
*
* No need to drain response, response body is not valid
*/
makeRequestAsyncOmit(options: RequestOption, payload?: Binary, statusCodes?: number[], region?: string): Promise<Omit<http.IncomingMessage, 'on'>>;
/**
* makeRequestStream will be used directly instead of makeRequest in case the payload
* is available as a stream. for ex. putObject
*
* @internal
*/
makeRequestStreamAsync(options: RequestOption, body: stream.Readable | Binary, sha256sum: string, statusCodes: number[], region: string): Promise<http.IncomingMessage>;
/**
* gets the region of the bucket
*
* @param bucketName
*
* @internal
*/
protected getBucketRegionAsync(bucketName: string): Promise<string>;
/**
* makeRequest is the primitive used by the apis for making S3 requests.
* payload can be empty string in case of no payload.
* statusCode is the expected statusCode. If response.statusCode does not match
* we parse the XML error and call the callback with the error message.
* A valid region is passed by the calls - listBuckets, makeBucket and
* getBucketRegion.
*
* @deprecated use `makeRequestAsync` instead
*/
makeRequest(options: RequestOption, payload: Binary | undefined, expectedCodes: number[] | undefined, region: string | undefined, returnResponse: boolean, cb: (cb: unknown, result: http.IncomingMessage) => void): void;
/**
* makeRequestStream will be used directly instead of makeRequest in case the payload
* is available as a stream. for ex. putObject
*
* @deprecated use `makeRequestStreamAsync` instead
*/
makeRequestStream(options: RequestOption, stream: stream.Readable | Buffer, sha256sum: string, statusCodes: number[], region: string, returnResponse: boolean, cb: (cb: unknown, result: http.IncomingMessage) => void): void;
/**
* @deprecated use `getBucketRegionAsync` instead
*/
getBucketRegion(bucketName: string, cb: (err: unknown, region: string) => void): Promise<void>;
/**
* Creates the bucket `bucketName`.
*
*/
makeBucket(bucketName: string, region?: Region, makeOpts?: MakeBucketOpt): Promise<void>;
/**
* To check if a bucket already exists.
*/
bucketExists(bucketName: string): Promise<boolean>;
removeBucket(bucketName: string): Promise<void>;
/**
* @deprecated use promise style API
*/
removeBucket(bucketName: string, callback: NoResultCallback): void;
/**
* Callback is called with readable stream of the object content.
*/
getObject(bucketName: string, objectName: string, getOpts?: GetObjectOpts): Promise<stream.Readable>;
/**
* Callback is called with readable stream of the partial object content.
* @param bucketName
* @param objectName
* @param offset
* @param length - length of the object that will be read in the stream (optional, if not specified we read the rest of the file from the offset)
* @param getOpts
*/
getPartialObject(bucketName: string, objectName: string, offset: number, length?: number, getOpts?: GetObjectOpts): Promise<stream.Readable>;
/**
* download object content to a file.
* This method will create a temp file named `${filename}.${base64(etag)}.part.minio` when downloading.
*
* @param bucketName - name of the bucket
* @param objectName - name of the object
* @param filePath - path to which the object data will be written to
* @param getOpts - Optional object get option
*/
fGetObject(bucketName: string, objectName: string, filePath: string, getOpts?: GetObjectOpts): Promise<void>;
/**
* Stat information of the object.
*/
statObject(bucketName: string, objectName: string, statOpts?: StatObjectOpts): Promise<BucketItemStat>;
removeObject(bucketName: string, objectName: string, removeOpts?: RemoveOptions): Promise<void>;
listIncompleteUploads(bucket: string, prefix: string, recursive: boolean): BucketStream<IncompleteUploadedBucketItem>;
/**
* Called by listIncompleteUploads to fetch a batch of incomplete uploads.
*/
listIncompleteUploadsQuery(bucketName: string, prefix: string, keyMarker: string, uploadIdMarker: string, delimiter: string): Promise<ListMultipartResult>;
/**
* Initiate a new multipart upload.
* @internal
*/
initiateNewMultipartUpload(bucketName: string, objectName: string, headers: RequestHeaders): Promise<string>;
/**
* Internal Method to abort a multipart upload request in case of any errors.
*
* @param bucketName - Bucket Name
* @param objectName - Object Name
* @param uploadId - id of a multipart upload to cancel during compose object sequence.
*/
abortMultipartUpload(bucketName: string, objectName: string, uploadId: string): Promise<void>;
findUploadId(bucketName: string, objectName: string): Promise<string | undefined>;
/**
* this call will aggregate the parts on the server into a single object.
*/
completeMultipartUpload(bucketName: string, objectName: string, uploadId: string, etags: {
part: number;
etag?: string;
}[]): Promise<{
etag: string;
versionId: string | null;
}>;
/**
* Get part-info of all parts of an incomplete upload specified by uploadId.
*/
protected listParts(bucketName: string, objectName: string, uploadId: string): Promise<UploadedPart[]>;
/**
* Called by listParts to fetch a batch of part-info
*/
private listPartsQuery;
listBuckets(): Promise<BucketItemFromList[]>;
/**
* Calculate part size given the object size. Part size will be atleast this.partSize
*/
calculatePartSize(size: number): number;
/**
* Uploads the object using contents from a file
*/
fPutObject(bucketName: string, objectName: string, filePath: string, metaData?: ObjectMetaData): Promise<UploadedObjectInfo>;
/**
* Uploading a stream, "Buffer" or "string".
* It's recommended to pass `size` argument with stream.
*/
putObject(bucketName: string, objectName: string, stream: stream.Readable | Buffer | string, size?: number, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo>;
/**
* method to upload buffer in one call
* @private
*/
private uploadBuffer;
/**
* upload stream with MultipartUpload
* @private
*/
private uploadStream;
removeBucketReplication(bucketName: string): Promise<void>;
removeBucketReplication(bucketName: string, callback: NoResultCallback): void;
setBucketReplication(bucketName: string, replicationConfig: ReplicationConfigOpts): void;
setBucketReplication(bucketName: string, replicationConfig: ReplicationConfigOpts): Promise<void>;
getBucketReplication(bucketName: string): void;
getBucketReplication(bucketName: string): Promise<ReplicationConfig>;
getObjectLegalHold(bucketName: string, objectName: string, getOpts?: GetObjectLegalHoldOptions, callback?: ResultCallback<LEGAL_HOLD_STATUS>): Promise<LEGAL_HOLD_STATUS>;
setObjectLegalHold(bucketName: string, objectName: string, setOpts?: PutObjectLegalHoldOptions): void;
/**
* Get Tags associated with a Bucket
*/
getBucketTagging(bucketName: string): Promise<Tag[]>;
/**
* Get the tags associated with a bucket OR an object
*/
getObjectTagging(bucketName: string, objectName: string, getOpts?: GetObjectOpts): Promise<Tag[]>;
/**
* Set the policy on a bucket or an object prefix.
*/
setBucketPolicy(bucketName: string, policy: string): Promise<void>;
/**
* Get the policy on a bucket or an object prefix.
*/
getBucketPolicy(bucketName: string): Promise<string>;
putObjectRetention(bucketName: string, objectName: string, retentionOpts?: Retention): Promise<void>;
getObjectLockConfig(bucketName: string, callback: ResultCallback<ObjectLockInfo>): void;
getObjectLockConfig(bucketName: string): void;
getObjectLockConfig(bucketName: string): Promise<ObjectLockInfo>;
setObjectLockConfig(bucketName: string, lockConfigOpts: Omit<ObjectLockInfo, 'objectLockEnabled'>): void;
setObjectLockConfig(bucketName: string, lockConfigOpts: Omit<ObjectLockInfo, 'objectLockEnabled'>): Promise<void>;
getBucketVersioning(bucketName: string): Promise<BucketVersioningConfiguration>;
setBucketVersioning(bucketName: string, versionConfig: BucketVersioningConfiguration): Promise<void>;
private setTagging;
private removeTagging;
setBucketTagging(bucketName: string, tags: Tags): Promise<void>;
removeBucketTagging(bucketName: string): Promise<void>;
setObjectTagging(bucketName: string, objectName: string, tags: Tags, putOpts?: TaggingOpts): Promise<void>;
removeObjectTagging(bucketName: string, objectName: string, removeOpts: TaggingOpts): Promise<void>;
selectObjectContent(bucketName: string, objectName: string, selectOpts: SelectOptions): Promise<SelectResults | undefined>;
private applyBucketLifecycle;
removeBucketLifecycle(bucketName: string): Promise<void>;
setBucketLifecycle(bucketName: string, lifeCycleConfig: LifeCycleConfigParam): Promise<void>;
getBucketLifecycle(bucketName: string): Promise<LifecycleConfig | null>;
setBucketEncryption(bucketName: string, encryptionConfig?: EncryptionConfig): Promise<void>;
getBucketEncryption(bucketName: string): Promise<any>;
removeBucketEncryption(bucketName: string): Promise<void>;
getObjectRetention(bucketName: string, objectName: string, getOpts?: GetObjectRetentionOpts): Promise<ObjectRetentionInfo | null | undefined>;
removeObjects(bucketName: string, objectsList: RemoveObjectsParam): Promise<RemoveObjectsResponse[]>;
removeIncompleteUpload(bucketName: string, objectName: string): Promise<void>;
private copyObjectV1;
private copyObjectV2;
copyObject(source: CopySourceOptions, dest: CopyDestinationOptions): Promise<CopyObjectResult>;
copyObject(targetBucketName: string, targetObjectName: string, sourceBucketNameAndObjectName: string, conditions?: CopyConditions): Promise<CopyObjectResult>;
uploadPart(partConfig: {
bucketName: string;
objectName: string;
uploadID: string;
partNumber: number;
headers: RequestHeaders;
}, payload?: Binary): Promise<{
etag: string;
key: string;
part: number;
}>;
composeObject(destObjConfig: CopyDestinationOptions, sourceObjList: CopySourceOptions[]): Promise<boolean | {
etag: string;
versionId: string | null;
} | Promise<void> | CopyObjectResult>;
presignedUrl(method: string, bucketName: string, objectName: string, expires?: number | PreSignRequestParams | undefined, reqParams?: PreSignRequestParams | Date, requestDate?: Date): Promise<string>;
presignedGetObject(bucketName: string, objectName: string, expires?: number, respHeaders?: PreSignRequestParams | Date, requestDate?: Date): Promise<string>;
presignedPutObject(bucketName: string, objectName: string, expires?: number): Promise<string>;
newPostPolicy(): PostPolicy;
presignedPostPolicy(postPolicy: PostPolicy): Promise<PostPolicyResult>;
listObjectsQuery(bucketName: string, prefix?: string, marker?: string, listQueryOpts?: ListObjectQueryOpts): Promise<{
objects: ObjectInfo[];
isTruncated?: boolean | undefined;
nextMarker?: string | undefined;
versionIdMarker?: string | undefined;
}>;
listObjects(bucketName: string, prefix?: string, recursive?: boolean, listOpts?: ListObjectQueryOpts | undefined): BucketStream<ObjectInfo>;
}
export {};
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
export declare class CopyConditions {
modified: string;
unmodified: string;
matchETag: string;
matchETagExcept: string;
setModified(date: Date): void;
setUnmodified(date: Date): void;
setMatchETag(etag: string): void;
setMatchETagExcept(etag: string): void;
}
@@ -0,0 +1,25 @@
export class CopyConditions {
modified = '';
unmodified = '';
matchETag = '';
matchETagExcept = '';
setModified(date) {
if (!(date instanceof Date)) {
throw new TypeError('date must be of type Date');
}
this.modified = date.toUTCString();
}
setUnmodified(date) {
if (!(date instanceof Date)) {
throw new TypeError('date must be of type Date');
}
this.unmodified = date.toUTCString();
}
setMatchETag(etag) {
this.matchETag = etag;
}
setMatchETagExcept(etag) {
this.matchETagExcept = etag;
}
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDb3B5Q29uZGl0aW9ucyIsIm1vZGlmaWVkIiwidW5tb2RpZmllZCIsIm1hdGNoRVRhZyI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7XG4gICAgdGhpcy5tYXRjaEVUYWdFeGNlcHQgPSBldGFnXG4gIH1cbn1cbiJdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxNQUFNQSxjQUFjLENBQUM7RUFDbkJDLFFBQVEsR0FBRyxFQUFFO0VBQ2JDLFVBQVUsR0FBRyxFQUFFO0VBQ2ZDLFNBQVMsR0FBRyxFQUFFO0VBQ2RDLGVBQWUsR0FBRyxFQUFFO0VBRTNCQyxXQUFXQSxDQUFDQyxJQUFVLEVBQVE7SUFDNUIsSUFBSSxFQUFFQSxJQUFJLFlBQVlDLElBQUksQ0FBQyxFQUFFO01BQzNCLE1BQU0sSUFBSUMsU0FBUyxDQUFDLDJCQUEyQixDQUFDO0lBQ2xEO0lBRUEsSUFBSSxDQUFDUCxRQUFRLEdBQUdLLElBQUksQ0FBQ0csV0FBVyxDQUFDLENBQUM7RUFDcEM7RUFFQUMsYUFBYUEsQ0FBQ0osSUFBVSxFQUFRO0lBQzlCLElBQUksRUFBRUEsSUFBSSxZQUFZQyxJQUFJLENBQUMsRUFBRTtNQUMzQixNQUFNLElBQUlDLFNBQVMsQ0FBQywyQkFBMkIsQ0FBQztJQUNsRDtJQUVBLElBQUksQ0FBQ04sVUFBVSxHQUFHSSxJQUFJLENBQUNHLFdBQVcsQ0FBQyxDQUFDO0VBQ3RDO0VBRUFFLFlBQVlBLENBQUNDLElBQVksRUFBUTtJQUMvQixJQUFJLENBQUNULFNBQVMsR0FBR1MsSUFBSTtFQUN2QjtFQUVBQyxrQkFBa0JBLENBQUNELElBQVksRUFBUTtJQUNyQyxJQUFJLENBQUNSLGVBQWUsR0FBR1EsSUFBSTtFQUM3QjtBQUNGIn0=
@@ -0,0 +1,18 @@
import type { TypedClient } from "./client.mjs";
import type { BucketItemWithMetadata, BucketStream } from "./type.mjs";
export declare class Extensions {
private readonly client;
constructor(client: TypedClient);
/**
* List the objects in the bucket using S3 ListObjects V2 With Metadata
*
* @param bucketName - name of the bucket
* @param prefix - the prefix of the objects that should be listed (optional, default `''`)
* @param recursive - `true` indicates recursive style listing and `false` indicates directory style listing delimited by '/'. (optional, default `false`)
* @param startAfter - Specifies the key to start after when listing objects in a bucket. (optional, default `''`)
* @returns stream emitting the objects in the bucket, the object is of the format:
*/
listObjectsV2WithMetadata(bucketName: string, prefix?: string, recursive?: boolean, startAfter?: string): BucketStream<BucketItemWithMetadata>;
private listObjectsV2WithMetadataGen;
private listObjectsV2WithMetadataQuery;
}
File diff suppressed because one or more lines are too long
+173
View File
@@ -0,0 +1,173 @@
/// <reference types="node" />
/// <reference types="node" />
import * as stream from 'node:stream';
import _ from 'lodash';
import type { Binary, Encryption, ObjectMetaData, RequestHeaders, ResponseHeader } from "./type.mjs";
export declare function hashBinary(buf: Buffer, enableSHA256: boolean): {
md5sum: string;
sha256sum: string;
};
export declare function uriEscape(uriStr: string): string;
export declare function uriResourceEscape(string: string): string;
export declare function getScope(region: string, date: Date, serviceName?: string): string;
/**
* isAmazonEndpoint - true if endpoint is 's3.amazonaws.com' or 's3.cn-north-1.amazonaws.com.cn'
*/
export declare function isAmazonEndpoint(endpoint: string): boolean;
/**
* isVirtualHostStyle - verify if bucket name is support with virtual
* hosts. bucketNames with periods should be always treated as path
* style if the protocol is 'https:', this is due to SSL wildcard
* limitation. For all other buckets and Amazon S3 endpoint we will
* default to virtual host style.
*/
export declare function isVirtualHostStyle(endpoint: string, protocol: string, bucket: string, pathStyle: boolean): boolean;
export declare function isValidIP(ip: string): boolean;
/**
* @returns if endpoint is valid domain.
*/
export declare function isValidEndpoint(endpoint: string): boolean;
/**
* @returns if input host is a valid domain.
*/
export declare function isValidDomain(host: string): boolean;
/**
* Probes contentType using file extensions.
*
* @example
* ```
* // return 'image/png'
* probeContentType('file.png')
* ```
*/
export declare function probeContentType(path: string): string;
/**
* is input port valid.
*/
export declare function isValidPort(port: unknown): port is number;
export declare function isValidBucketName(bucket: unknown): boolean;
/**
* check if objectName is a valid object name
*/
export declare function isValidObjectName(objectName: unknown): boolean;
/**
* check if prefix is valid
*/
export declare function isValidPrefix(prefix: unknown): prefix is string;
/**
* check if typeof arg number
*/
export declare function isNumber(arg: unknown): arg is number;
export type AnyFunction = (...args: any[]) => any;
/**
* check if typeof arg function
*/
export declare function isFunction(arg: unknown): arg is AnyFunction;
/**
* check if typeof arg string
*/
export declare function isString(arg: unknown): arg is string;
/**
* check if typeof arg object
*/
export declare function isObject(arg: unknown): arg is object;
/**
* check if object is readable stream
*/
export declare function isReadableStream(arg: unknown): arg is stream.Readable;
/**
* check if arg is boolean
*/
export declare function isBoolean(arg: unknown): arg is boolean;
export declare function isEmpty(o: unknown): o is null | undefined;
export declare function isEmptyObject(o: Record<string, unknown>): boolean;
export declare function isDefined<T>(o: T): o is Exclude<T, null | undefined>;
/**
* check if arg is a valid date
*/
export declare function isValidDate(arg: unknown): arg is Date;
/**
* Create a Date string with format: 'YYYYMMDDTHHmmss' + Z
*/
export declare function makeDateLong(date?: Date): string;
/**
* Create a Date string with format: 'YYYYMMDD'
*/
export declare function makeDateShort(date?: Date): string;
/**
* pipesetup sets up pipe() from left to right os streams array
* pipesetup will also make sure that error emitted at any of the upstream Stream
* will be emitted at the last stream. This makes error handling simple
*/
export declare function pipesetup(...streams: [stream.Readable, ...stream.Duplex[], stream.Writable]): stream.Readable | stream.Duplex | stream.Writable;
/**
* return a Readable stream that emits data
*/
export declare function readableStream(data: unknown): stream.Readable;
/**
* Process metadata to insert appropriate value to `content-type` attribute
*/
export declare function insertContentType(metaData: ObjectMetaData, filePath: string): ObjectMetaData;
/**
* Function prepends metadata with the appropriate prefix if it is not already on
*/
export declare function prependXAMZMeta(metaData?: ObjectMetaData): RequestHeaders;
/**
* Checks if it is a valid header according to the AmazonS3 API
*/
export declare function isAmzHeader(key: string): boolean;
/**
* Checks if it is a supported Header
*/
export declare function isSupportedHeader(key: string): boolean;
/**
* Checks if it is a storage header
*/
export declare function isStorageClassHeader(key: string): boolean;
export declare function extractMetadata(headers: ResponseHeader): _.Dictionary<string>;
export declare function getVersionId(headers?: ResponseHeader): string | null;
export declare function getSourceVersionId(headers?: ResponseHeader): string | null;
export declare function sanitizeETag(etag?: string): string;
export declare function toMd5(payload: Binary): string;
export declare function toSha256(payload: Binary): string;
/**
* toArray returns a single element array with param being the element,
* if param is just a string, and returns 'param' back if it is an array
* So, it makes sure param is always an array
*/
export declare function toArray<T = unknown>(param: T | T[]): Array<T>;
export declare function sanitizeObjectKey(objectName: string): string;
export declare function sanitizeSize(size?: string): number | undefined;
export declare const PART_CONSTRAINTS: {
ABS_MIN_PART_SIZE: number;
MIN_PART_SIZE: number;
MAX_PARTS_COUNT: number;
MAX_PART_SIZE: number;
MAX_SINGLE_PUT_OBJECT_SIZE: number;
MAX_MULTIPART_PUT_OBJECT_SIZE: number;
};
/**
* Return Encryption headers
* @param encConfig
* @returns an object with key value pairs that can be used in headers.
*/
export declare function getEncryptionHeaders(encConfig: Encryption): RequestHeaders;
export declare function partsRequired(size: number): number;
/**
* calculateEvenSplits - computes splits for a source and returns
* start and end index slices. Splits happen evenly to be sure that no
* part is less than 5MiB, as that could fail the multipart request if
* it is not the last part.
*/
export declare function calculateEvenSplits<T extends {
Start?: number;
}>(size: number, objInfo: T): {
startIndex: number[];
objInfo: T;
endIndex: number[];
} | null;
export declare function parseXml(xml: string): any;
/**
* get content size of object content to upload
*/
export declare function getContentLength(s: stream.Readable | Buffer | string): Promise<number | null>;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
/**
* joinHostPort combines host and port into a network address of the
* form "host:port". If host contains a colon, as found in literal
* IPv6 addresses, then JoinHostPort returns "[host]:port".
*
* @param host
* @param port
* @returns Cleaned up host
* @internal
*/
export declare function joinHostPort(host: string, port?: number): string;
@@ -0,0 +1,23 @@
/**
* joinHostPort combines host and port into a network address of the
* form "host:port". If host contains a colon, as found in literal
* IPv6 addresses, then JoinHostPort returns "[host]:port".
*
* @param host
* @param port
* @returns Cleaned up host
* @internal
*/
export function joinHostPort(host, port) {
if (port === undefined) {
return host;
}
// We assume that host is a literal IPv6 address if host has
// colons.
if (host.includes(':')) {
return `[${host}]:${port.toString()}`;
}
return `${host}:${port.toString()}`;
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJqb2luSG9zdFBvcnQiLCJob3N0IiwicG9ydCIsInVuZGVmaW5lZCIsImluY2x1ZGVzIiwidG9TdHJpbmciXSwic291cmNlcyI6WyJqb2luLWhvc3QtcG9ydC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIGpvaW5Ib3N0UG9ydCBjb21iaW5lcyBob3N0IGFuZCBwb3J0IGludG8gYSBuZXR3b3JrIGFkZHJlc3Mgb2YgdGhlXG4gKiBmb3JtIFwiaG9zdDpwb3J0XCIuIElmIGhvc3QgY29udGFpbnMgYSBjb2xvbiwgYXMgZm91bmQgaW4gbGl0ZXJhbFxuICogSVB2NiBhZGRyZXNzZXMsIHRoZW4gSm9pbkhvc3RQb3J0IHJldHVybnMgXCJbaG9zdF06cG9ydFwiLlxuICpcbiAqIEBwYXJhbSBob3N0XG4gKiBAcGFyYW0gcG9ydFxuICogQHJldHVybnMgQ2xlYW5lZCB1cCBob3N0XG4gKiBAaW50ZXJuYWxcbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIGpvaW5Ib3N0UG9ydChob3N0OiBzdHJpbmcsIHBvcnQ/OiBudW1iZXIpOiBzdHJpbmcge1xuICBpZiAocG9ydCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgcmV0dXJuIGhvc3RcbiAgfVxuXG4gIC8vIFdlIGFzc3VtZSB0aGF0IGhvc3QgaXMgYSBsaXRlcmFsIElQdjYgYWRkcmVzcyBpZiBob3N0IGhhc1xuICAvLyBjb2xvbnMuXG4gIGlmIChob3N0LmluY2x1ZGVzKCc6JykpIHtcbiAgICByZXR1cm4gYFske2hvc3R9XToke3BvcnQudG9TdHJpbmcoKX1gXG4gIH1cblxuICByZXR1cm4gYCR7aG9zdH06JHtwb3J0LnRvU3RyaW5nKCl9YFxufVxuIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLE9BQU8sU0FBU0EsWUFBWUEsQ0FBQ0MsSUFBWSxFQUFFQyxJQUFhLEVBQVU7RUFDaEUsSUFBSUEsSUFBSSxLQUFLQyxTQUFTLEVBQUU7SUFDdEIsT0FBT0YsSUFBSTtFQUNiOztFQUVBO0VBQ0E7RUFDQSxJQUFJQSxJQUFJLENBQUNHLFFBQVEsQ0FBQyxHQUFHLENBQUMsRUFBRTtJQUN0QixPQUFRLElBQUdILElBQUssS0FBSUMsSUFBSSxDQUFDRyxRQUFRLENBQUMsQ0FBRSxFQUFDO0VBQ3ZDO0VBRUEsT0FBUSxHQUFFSixJQUFLLElBQUdDLElBQUksQ0FBQ0csUUFBUSxDQUFDLENBQUUsRUFBQztBQUNyQyJ9
@@ -0,0 +1,17 @@
import type { ObjectMetaData } from "./type.mjs";
export declare class PostPolicy {
policy: {
conditions: (string | number)[][];
expiration?: string;
};
formData: Record<string, string>;
setExpires(date: Date): void;
setKey(objectName: string): void;
setKeyStartsWith(prefix: string): void;
setBucket(bucketName: string): void;
setContentType(type: string): void;
setContentTypeStartsWith(prefix: string): void;
setContentDisposition(value: string): void;
setContentLengthRange(min: number, max: number): void;
setUserMetaData(metaData: ObjectMetaData): void;
}
File diff suppressed because one or more lines are too long
+11
View File
@@ -0,0 +1,11 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import type * as https from 'node:https';
import type * as stream from 'node:stream';
import type { Transport } from "./type.mjs";
export declare function request(transport: Transport, opt: https.RequestOptions, body?: Buffer | string | stream.Readable | null): Promise<http.IncomingMessage>;
export declare const retryHttpCodes: Record<string, boolean>;
export declare function requestWithRetry(transport: Transport, opt: https.RequestOptions, body?: Buffer | string | stream.Readable | null, maxRetries?: number): Promise<http.IncomingMessage>;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type http from 'node:http';
import type stream from 'node:stream';
export declare function readAsBuffer(res: stream.Readable): Promise<Buffer>;
export declare function readAsString(res: http.IncomingMessage): Promise<string>;
export declare function drainResponse(res: stream.Readable): Promise<void>;
+16
View File
@@ -0,0 +1,16 @@
export async function readAsBuffer(res) {
return new Promise((resolve, reject) => {
const body = [];
res.on('data', chunk => body.push(chunk)).on('error', e => reject(e)).on('end', () => resolve(Buffer.concat(body)));
});
}
export async function readAsString(res) {
const body = await readAsBuffer(res);
return body.toString();
}
export async function drainResponse(res) {
return new Promise((resolve, reject) => {
res.on('data', () => {}).on('error', e => reject(e)).on('end', () => resolve());
});
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJyZWFkQXNCdWZmZXIiLCJyZXMiLCJQcm9taXNlIiwicmVzb2x2ZSIsInJlamVjdCIsImJvZHkiLCJvbiIsImNodW5rIiwicHVzaCIsImUiLCJCdWZmZXIiLCJjb25jYXQiLCJyZWFkQXNTdHJpbmciLCJ0b1N0cmluZyIsImRyYWluUmVzcG9uc2UiXSwic291cmNlcyI6WyJyZXNwb25zZS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSBodHRwIGZyb20gJ25vZGU6aHR0cCdcbmltcG9ydCB0eXBlIHN0cmVhbSBmcm9tICdub2RlOnN0cmVhbSdcblxuZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIHJlYWRBc0J1ZmZlcihyZXM6IHN0cmVhbS5SZWFkYWJsZSk6IFByb21pc2U8QnVmZmVyPiB7XG4gIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgY29uc3QgYm9keTogQnVmZmVyW10gPSBbXVxuICAgIHJlc1xuICAgICAgLm9uKC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LLENBQUMsQ0FBQyxDQUFDLENBQzdCSCxFQUFFLENBQUMsS0FBSyxFQUFFLE1BQU1ILE9BQU8sQ0FBQ08sTUFBTSxDQUFDQyxNQUFNLENBQUNOLElBQUksQ0FBQyxDQUFDLENBQUM7RUFDbEQsQ0FBQyxDQUFDO0FBQ0o7QUFFQSxPQUFPLGVBQWVPLFlBQVlBLENBQUNYLEdBQXlCLEVBQW1CO0VBQzdFLE1BQU1JLElBQUksR0FBRyxNQUFNTCxZQUFZLENBQUNDLEdBQUcsQ0FBQztFQUNwQyxPQUFPSSxJQUFJLENBQUNRLFFBQVEsQ0FBQyxDQUFDO0FBQ3hCO0FBRUEsT0FBTyxlQUFlQyxhQUFhQSxDQUFDYixHQUFvQixFQUFpQjtFQUN2RSxPQUFPLElBQUlDLE9BQU8sQ0FBQyxDQUFDQyxPQUFPLEVBQUVDLE1BQU0sS0FBSztJQUN0Q0gsR0FBRyxDQUNBSyxFQUFFLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsQ0FDcEJBLEVBQUUsQ0FBQyxPQUFPLEVBQUdHLENBQUMsSUFBS0wsTUFBTSxDQUFDSyxDQUFDLENBQUMsQ0FBQyxDQUM3QkgsRUFBRSxDQUFDLEtBQUssRUFBRSxNQUFNSCxPQUFPLENBQUMsQ0FBQyxDQUFDO0VBQy9CLENBQUMsQ0FBQztBQUNKIn0=
@@ -0,0 +1,38 @@
declare const awsS3Endpoint: {
'af-south-1': string;
'ap-east-1': string;
'ap-south-1': string;
'ap-south-2': string;
'ap-southeast-1': string;
'ap-southeast-2': string;
'ap-southeast-3': string;
'ap-southeast-4': string;
'ap-southeast-5': string;
'ap-northeast-1': string;
'ap-northeast-2': string;
'ap-northeast-3': string;
'ca-central-1': string;
'ca-west-1': string;
'cn-north-1': string;
'eu-central-1': string;
'eu-central-2': string;
'eu-north-1': string;
'eu-south-1': string;
'eu-south-2': string;
'eu-west-1': string;
'eu-west-2': string;
'eu-west-3': string;
'il-central-1': string;
'me-central-1': string;
'me-south-1': string;
'sa-east-1': string;
'us-east-1': string;
'us-east-2': string;
'us-west-1': string;
'us-west-2': string;
'us-gov-east-1': string;
'us-gov-west-1': string;
};
export type Region = keyof typeof awsS3Endpoint | string;
export declare function getS3Endpoint(region: Region): string;
export {};
File diff suppressed because one or more lines are too long
+447
View File
@@ -0,0 +1,447 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import type { Readable as ReadableStream } from 'node:stream';
import type { CopyDestinationOptions, CopySourceOptions } from "../helpers.mjs";
import type { CopyConditions } from "./copy-conditions.mjs";
export type VersionIdentificator = {
versionId?: string;
};
export type GetObjectOpts = VersionIdentificator & {
SSECustomerAlgorithm?: string;
SSECustomerKey?: string;
SSECustomerKeyMD5?: string;
};
export type Binary = string | Buffer;
export type ResponseHeader = Record<string, string>;
export type ObjectMetaData = Record<string, string | number>;
export type RequestHeaders = Record<string, string | boolean | number | undefined>;
export type Encryption = {
type: ENCRYPTION_TYPES.SSEC;
} | {
type: ENCRYPTION_TYPES.KMS;
SSEAlgorithm?: string;
KMSMasterKeyID?: string;
};
export type EnabledOrDisabledStatus = 'Enabled' | 'Disabled';
export declare enum ENCRYPTION_TYPES {
/**
* SSEC represents server-side-encryption with customer provided keys
*/
SSEC = "SSE-C",
/**
* KMS represents server-side-encryption with managed keys
*/
KMS = "KMS",
}
export declare enum RETENTION_MODES {
GOVERNANCE = "GOVERNANCE",
COMPLIANCE = "COMPLIANCE",
}
export declare enum RETENTION_VALIDITY_UNITS {
DAYS = "Days",
YEARS = "Years",
}
export declare enum LEGAL_HOLD_STATUS {
ENABLED = "ON",
DISABLED = "OFF",
}
export type Transport = Pick<typeof http, 'request'>;
export interface IRequest {
protocol: string;
port?: number | string;
method: string;
path: string;
headers: RequestHeaders;
}
export type ICanonicalRequest = string;
export interface IncompleteUploadedBucketItem {
key: string;
uploadId: string;
size: number;
}
export interface MetadataItem {
Key: string;
Value: string;
}
export interface ItemBucketMetadataList {
Items: MetadataItem[];
}
export interface ItemBucketMetadata {
[key: string]: any;
}
export interface ItemBucketTags {
[key: string]: any;
}
export interface BucketItemFromList {
name: string;
creationDate: Date;
}
export interface BucketItemCopy {
etag: string;
lastModified: Date;
}
export type BucketItem = {
name: string;
size: number;
etag: string;
prefix?: never;
lastModified: Date;
} | {
name?: never;
etag?: never;
lastModified?: never;
prefix: string;
size: 0;
};
export type BucketItemWithMetadata = BucketItem & {
metadata?: ItemBucketMetadata | ItemBucketMetadataList;
tags?: ItemBucketTags;
};
export interface BucketStream<T> extends ReadableStream {
on(event: 'data', listener: (item: T) => void): this;
on(event: 'end' | 'pause' | 'readable' | 'resume' | 'close', listener: () => void): this;
on(event: 'error', listener: (err: Error) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
}
export interface BucketItemStat {
size: number;
etag: string;
lastModified: Date;
metaData: ItemBucketMetadata;
versionId?: string | null;
}
export type StatObjectOpts = {
versionId?: string;
};
export type ReplicationRuleStatus = {
Status: EnabledOrDisabledStatus;
};
export type Tag = {
Key: string;
Value: string;
};
export type Tags = Record<string, string>;
export type ReplicationRuleDestination = {
Bucket: string;
StorageClass: string;
};
export type ReplicationRuleAnd = {
Prefix: string;
Tags: Tag[];
};
export type ReplicationRuleFilter = {
Prefix: string;
And: ReplicationRuleAnd;
Tag: Tag;
};
export type ReplicaModifications = {
Status: ReplicationRuleStatus;
};
export type SourceSelectionCriteria = {
ReplicaModifications: ReplicaModifications;
};
export type ExistingObjectReplication = {
Status: ReplicationRuleStatus;
};
export type ReplicationRule = {
ID: string;
Status: ReplicationRuleStatus;
Priority: number;
DeleteMarkerReplication: ReplicationRuleStatus;
DeleteReplication: ReplicationRuleStatus;
Destination: ReplicationRuleDestination;
Filter: ReplicationRuleFilter;
SourceSelectionCriteria: SourceSelectionCriteria;
ExistingObjectReplication: ExistingObjectReplication;
};
export type ReplicationConfigOpts = {
role: string;
rules: ReplicationRule[];
};
export type ReplicationConfig = {
ReplicationConfiguration: ReplicationConfigOpts;
};
export type ResultCallback<T> = (error: Error | null, result: T) => void;
export type GetObjectLegalHoldOptions = {
versionId: string;
};
/**
* @deprecated keep for backward compatible, use `LEGAL_HOLD_STATUS` instead
*/
export type LegalHoldStatus = LEGAL_HOLD_STATUS;
export type PutObjectLegalHoldOptions = {
versionId?: string;
status: LEGAL_HOLD_STATUS;
};
export interface UploadedObjectInfo {
etag: string;
versionId: string | null;
}
export interface RetentionOptions {
versionId: string;
mode?: RETENTION_MODES;
retainUntilDate?: IsoDate;
governanceBypass?: boolean;
}
export type Retention = RetentionOptions | EmptyObject;
export type IsoDate = string;
export type EmptyObject = Record<string, never>;
export type ObjectLockInfo = {
objectLockEnabled: EnabledOrDisabledStatus;
mode: RETENTION_MODES;
unit: RETENTION_VALIDITY_UNITS;
validity: number;
} | EmptyObject;
export type ObjectLockConfigParam = {
ObjectLockEnabled?: 'Enabled' | undefined;
Rule?: {
DefaultRetention: {
Mode: RETENTION_MODES;
Days: number;
Years: number;
} | EmptyObject;
} | EmptyObject;
};
export type VersioningEnabled = 'Enabled';
export type VersioningSuspended = 'Suspended';
export type TaggingOpts = {
versionId: string;
};
export type PutTaggingParams = {
bucketName: string;
objectName?: string;
tags: Tags;
putOpts?: TaggingOpts;
};
export type RemoveTaggingParams = {
bucketName: string;
objectName?: string;
removeOpts?: TaggingOpts;
};
export type InputSerialization = {
CompressionType?: 'NONE' | 'GZIP' | 'BZIP2';
CSV?: {
AllowQuotedRecordDelimiter?: boolean;
Comments?: string;
FieldDelimiter?: string;
FileHeaderInfo?: 'NONE' | 'IGNORE' | 'USE';
QuoteCharacter?: string;
QuoteEscapeCharacter?: string;
RecordDelimiter?: string;
};
JSON?: {
Type: 'DOCUMENT' | 'LINES';
};
Parquet?: EmptyObject;
};
export type OutputSerialization = {
CSV?: {
FieldDelimiter?: string;
QuoteCharacter?: string;
QuoteEscapeCharacter?: string;
QuoteFields?: string;
RecordDelimiter?: string;
};
JSON?: {
RecordDelimiter?: string;
};
};
export type SelectProgress = {
Enabled: boolean;
};
export type ScanRange = {
Start: number;
End: number;
};
export type SelectOptions = {
expression: string;
expressionType?: string;
inputSerialization: InputSerialization;
outputSerialization: OutputSerialization;
requestProgress?: SelectProgress;
scanRange?: ScanRange;
};
export type Expiration = {
Date?: string;
Days: number;
DeleteMarker?: boolean;
DeleteAll?: boolean;
};
export type RuleFilterAnd = {
Prefix: string;
Tags: Tag[];
};
export type RuleFilter = {
And?: RuleFilterAnd;
Prefix: string;
Tag?: Tag[];
};
export type NoncurrentVersionExpiration = {
NoncurrentDays: number;
NewerNoncurrentVersions?: number;
};
export type NoncurrentVersionTransition = {
StorageClass: string;
NoncurrentDays?: number;
NewerNoncurrentVersions?: number;
};
export type Transition = {
Date?: string;
StorageClass: string;
Days: number;
};
export type AbortIncompleteMultipartUpload = {
DaysAfterInitiation: number;
};
export type LifecycleRule = {
AbortIncompleteMultipartUpload?: AbortIncompleteMultipartUpload;
ID: string;
Prefix?: string;
Status?: string;
Expiration?: Expiration;
Filter?: RuleFilter;
NoncurrentVersionExpiration?: NoncurrentVersionExpiration;
NoncurrentVersionTransition?: NoncurrentVersionTransition;
Transition?: Transition;
};
export type LifecycleConfig = {
Rule: LifecycleRule[];
};
export type LifeCycleConfigParam = LifecycleConfig | null | undefined | '';
export type ApplySSEByDefault = {
KmsMasterKeyID?: string;
SSEAlgorithm: string;
};
export type EncryptionRule = {
ApplyServerSideEncryptionByDefault?: ApplySSEByDefault;
};
export type EncryptionConfig = {
Rule: EncryptionRule[];
};
export type GetObjectRetentionOpts = {
versionId: string;
};
export type ObjectRetentionInfo = {
mode: RETENTION_MODES;
retainUntilDate: string;
};
export type RemoveObjectsEntry = {
name: string;
versionId?: string;
};
export type ObjectName = string;
export type RemoveObjectsParam = ObjectName[] | RemoveObjectsEntry[];
export type RemoveObjectsRequestEntry = {
Key: string;
VersionId?: string;
};
export type RemoveObjectsResponse = null | undefined | {
Error?: {
Code?: string;
Message?: string;
Key?: string;
VersionId?: string;
};
};
export type CopyObjectResultV1 = {
etag: string;
lastModified: string | Date;
};
export type CopyObjectResultV2 = {
Bucket?: string;
Key?: string;
LastModified: string | Date;
MetaData?: ResponseHeader;
VersionId?: string | null;
SourceVersionId?: string | null;
Etag?: string;
Size?: number;
};
export type CopyObjectResult = CopyObjectResultV1 | CopyObjectResultV2;
export type CopyObjectParams = [CopySourceOptions, CopyDestinationOptions] | [string, string, string, CopyConditions?];
export type ExcludedPrefix = {
Prefix: string;
};
export type BucketVersioningConfiguration = {
Status: VersioningEnabled | VersioningSuspended;
MFADelete?: string;
ExcludedPrefixes?: ExcludedPrefix[];
ExcludeFolders?: boolean;
};
export type UploadPartConfig = {
bucketName: string;
objectName: string;
uploadID: string;
partNumber: number;
headers: RequestHeaders;
sourceObj: string;
};
export type PreSignRequestParams = {
[key: string]: string;
};
/** List object api types **/
export type CommonPrefix = {
Prefix: string;
};
export type Owner = {
ID: string;
DisplayName: string;
};
export type Metadata = {
Items: MetadataItem[];
};
export type ObjectInfo = {
key?: string;
name?: string;
lastModified?: Date;
etag?: string;
owner?: Owner;
storageClass?: string;
userMetadata?: Metadata;
userTags?: string;
prefix?: string;
size?: number;
};
export type ListObjectQueryRes = {
isTruncated?: boolean;
nextMarker?: string;
versionIdMarker?: string;
objects?: ObjectInfo[];
};
export type ListObjectQueryOpts = {
Delimiter?: string;
MaxKeys?: number;
IncludeVersion?: boolean;
};
/** List object api types **/
export type ObjectVersionEntry = {
IsLatest?: string;
VersionId?: string;
};
export type ObjectRowEntry = ObjectVersionEntry & {
Key: string;
LastModified?: Date | undefined;
ETag?: string;
Size?: string;
Owner?: Owner;
StorageClass?: string;
};
export interface ListBucketResultV1 {
Name?: string;
Prefix?: string;
ContinuationToken?: string;
KeyCount?: string;
Marker?: string;
MaxKeys?: string;
Delimiter?: string;
IsTruncated?: boolean;
Contents?: ObjectRowEntry[];
NextKeyMarker?: string;
CommonPrefixes?: CommonPrefix[];
Version?: ObjectRowEntry[];
DeleteMarker?: ObjectRowEntry[];
VersionIdMarker?: string;
NextVersionIdMarker?: string;
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,90 @@
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import { SelectResults } from "../helpers.mjs";
import type { BucketItemFromList, BucketItemWithMetadata, CopyObjectResultV1, ObjectInfo, ObjectLockInfo, ReplicationConfig } from "./type.mjs";
export declare function parseBucketRegion(xml: string): string;
export declare function parseError(xml: string, headerInfo: Record<string, unknown>): Record<string, unknown>;
export declare function parseResponseError(response: http.IncomingMessage): Promise<Record<string, string>>;
/**
* parse XML response for list objects v2 with metadata in a bucket
*/
export declare function parseListObjectsV2WithMetadata(xml: string): {
objects: Array<BucketItemWithMetadata>;
isTruncated: boolean;
nextContinuationToken: string;
};
export type UploadedPart = {
part: number;
lastModified?: Date;
etag: string;
size: number;
};
export declare function parseListParts(xml: string): {
isTruncated: boolean;
marker: number;
parts: UploadedPart[];
};
export declare function parseListBucket(xml: string): BucketItemFromList[];
export declare function parseInitiateMultipart(xml: string): string;
export declare function parseReplicationConfig(xml: string): ReplicationConfig;
export declare function parseObjectLegalHoldConfig(xml: string): any;
export declare function parseTagging(xml: string): any;
export declare function parseCompleteMultipart(xml: string): {
location: any;
bucket: any;
key: any;
etag: any;
errCode?: undefined;
errMessage?: undefined;
} | {
errCode: any;
errMessage: any;
location?: undefined;
bucket?: undefined;
key?: undefined;
etag?: undefined;
} | undefined;
type UploadID = string;
export type ListMultipartResult = {
uploads: {
key: string;
uploadId: UploadID;
initiator?: {
id: string;
displayName: string;
};
owner?: {
id: string;
displayName: string;
};
storageClass: unknown;
initiated: Date;
}[];
prefixes: {
prefix: string;
}[];
isTruncated: boolean;
nextKeyMarker: string;
nextUploadIdMarker: string;
};
export declare function parseListMultipart(xml: string): ListMultipartResult;
export declare function parseObjectLockConfig(xml: string): ObjectLockInfo;
export declare function parseBucketVersioningConfig(xml: string): any;
export declare function parseSelectObjectContentResponse(res: Buffer): SelectResults | undefined;
export declare function parseLifecycleConfig(xml: string): any;
export declare function parseBucketEncryptionConfig(xml: string): any;
export declare function parseObjectRetentionConfig(xml: string): {
mode: any;
retainUntilDate: any;
};
export declare function removeObjectsParser(xml: string): any[];
export declare function parseCopyObject(xml: string): CopyObjectResultV1;
export declare function parseListObjects(xml: string): {
objects: ObjectInfo[];
isTruncated?: boolean | undefined;
nextMarker?: string | undefined;
versionIdMarker?: string | undefined;
};
export declare function uploadPartParser(xml: string): any;
export {};
File diff suppressed because one or more lines are too long
+66
View File
@@ -0,0 +1,66 @@
// imported from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/93cfb0ec069731dcdfc31464788613f7cddb8192/types/minio/index.d.ts
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { LEGAL_HOLD_STATUS, RETENTION_MODES, RETENTION_VALIDITY_UNITS } from "./helpers.mjs";
import type { ClientOptions, NoResultCallback, RemoveOptions } from "./internal/client.mjs";
import { TypedClient } from "./internal/client.mjs";
import { CopyConditions } from "./internal/copy-conditions.mjs";
import { PostPolicy } from "./internal/post-policy.mjs";
import type { BucketItem, BucketItemCopy, BucketItemFromList, BucketItemStat, BucketItemWithMetadata, BucketStream, EmptyObject, ExistingObjectReplication, GetObjectLegalHoldOptions, IncompleteUploadedBucketItem, InputSerialization, IsoDate, ItemBucketMetadata, ItemBucketMetadataList, LegalHoldStatus, LifecycleConfig, LifecycleRule, MetadataItem, ObjectLockInfo, OutputSerialization, PutObjectLegalHoldOptions, ReplicaModifications, ReplicationConfig, ReplicationConfigOpts, ReplicationRule, ReplicationRuleAnd, ReplicationRuleDestination, ReplicationRuleFilter, ReplicationRuleStatus, ResultCallback, Retention, RetentionOptions, ScanRange, SelectOptions, SelectProgress, SourceSelectionCriteria, Tag } from "./internal/type.mjs";
import type { NotificationConfig, NotificationEvent, NotificationPoller } from "./notification.mjs";
export * from "./errors.mjs";
export * from "./helpers.mjs";
export type { Region } from "./internal/s3-endpoints.mjs";
export type * from "./notification.mjs";
export * from "./notification.mjs";
export { CopyConditions, PostPolicy };
export type { MakeBucketOpt } from "./internal/client.mjs";
export type { BucketItem, BucketItemCopy, BucketItemFromList, BucketItemStat, BucketItemWithMetadata, BucketStream, ClientOptions, EmptyObject, ExistingObjectReplication, GetObjectLegalHoldOptions, IncompleteUploadedBucketItem, InputSerialization, IsoDate, ItemBucketMetadata, ItemBucketMetadataList, LegalHoldStatus, LifecycleConfig, LifecycleRule, MetadataItem, NoResultCallback, ObjectLockInfo, OutputSerialization, PutObjectLegalHoldOptions, RemoveOptions, ReplicaModifications, ReplicationConfig, ReplicationConfigOpts, ReplicationRule, ReplicationRuleAnd, ReplicationRuleDestination, ReplicationRuleFilter, ReplicationRuleStatus, Retention, RetentionOptions, ScanRange, SelectOptions, SelectProgress, SourceSelectionCriteria, Tag };
/**
* @deprecated keep for backward compatible, use `RETENTION_MODES` instead
*/
export type Mode = RETENTION_MODES;
/**
* @deprecated keep for backward compatible
*/
export type LockUnit = RETENTION_VALIDITY_UNITS;
export type VersioningConfig = Record<string | number | symbol, unknown>;
export type TagList = Record<string, string>;
export interface PostPolicyResult {
postURL: string;
formData: {
[key: string]: any;
};
}
export interface LockConfig {
mode: RETENTION_MODES;
unit: RETENTION_VALIDITY_UNITS;
validity: number;
}
export interface LegalHoldOptions {
versionId: string;
status: LEGAL_HOLD_STATUS;
}
export interface SourceObjectStats {
size: number;
metaData: string;
lastModicied: Date;
versionId: string;
etag: string;
}
// Exports from library
export class Client extends TypedClient {
listObjectsV2(bucketName: string, prefix?: string, recursive?: boolean, startAfter?: string): BucketStream<BucketItem>;
// Bucket Policy & Notification operations
getBucketNotification(bucketName: string, callback: ResultCallback<NotificationConfig>): void;
getBucketNotification(bucketName: string): Promise<NotificationConfig>;
setBucketNotification(bucketName: string, bucketNotificationConfig: NotificationConfig, callback: NoResultCallback): void;
setBucketNotification(bucketName: string, bucketNotificationConfig: NotificationConfig): Promise<void>;
removeAllBucketNotification(bucketName: string, callback: NoResultCallback): void;
removeAllBucketNotification(bucketName: string): Promise<void>;
listenBucketNotification(bucketName: string, prefix: string, suffix: string, events: NotificationEvent[]): NotificationPoller;
}
File diff suppressed because one or more lines are too long
+58
View File
@@ -0,0 +1,58 @@
import { EventEmitter } from 'eventemitter3';
import type { TypedClient } from "./internal/client.mjs";
type Event = unknown;
export declare class TargetConfig {
private Filter?;
private Event?;
private Id;
setId(id: unknown): void;
addEvent(newevent: Event): void;
addFilterSuffix(suffix: string): void;
addFilterPrefix(prefix: string): void;
}
export declare class TopicConfig extends TargetConfig {
private Topic;
constructor(arn: string);
}
export declare class QueueConfig extends TargetConfig {
private Queue;
constructor(arn: string);
}
export declare class CloudFunctionConfig extends TargetConfig {
private CloudFunction;
constructor(arn: string);
}
export declare class NotificationConfig {
private TopicConfiguration?;
private CloudFunctionConfiguration?;
private QueueConfiguration?;
add(target: TargetConfig): void;
}
export declare const buildARN: (partition: string, service: string, region: string, accountId: string, resource: string) => string;
export declare const ObjectCreatedAll = "s3:ObjectCreated:*";
export declare const ObjectCreatedPut = "s3:ObjectCreated:Put";
export declare const ObjectCreatedPost = "s3:ObjectCreated:Post";
export declare const ObjectCreatedCopy = "s3:ObjectCreated:Copy";
export declare const ObjectCreatedCompleteMultipartUpload = "s3:ObjectCreated:CompleteMultipartUpload";
export declare const ObjectRemovedAll = "s3:ObjectRemoved:*";
export declare const ObjectRemovedDelete = "s3:ObjectRemoved:Delete";
export declare const ObjectRemovedDeleteMarkerCreated = "s3:ObjectRemoved:DeleteMarkerCreated";
export declare const ObjectReducedRedundancyLostObject = "s3:ReducedRedundancyLostObject";
export type NotificationEvent = 's3:ObjectCreated:*' | 's3:ObjectCreated:Put' | 's3:ObjectCreated:Post' | 's3:ObjectCreated:Copy' | 's3:ObjectCreated:CompleteMultipartUpload' | 's3:ObjectRemoved:*' | 's3:ObjectRemoved:Delete' | 's3:ObjectRemoved:DeleteMarkerCreated' | 's3:ReducedRedundancyLostObject' | 's3:TestEvent' | 's3:ObjectRestore:Post' | 's3:ObjectRestore:Completed' | 's3:Replication:OperationFailedReplication' | 's3:Replication:OperationMissedThreshold' | 's3:Replication:OperationReplicatedAfterThreshold' | 's3:Replication:OperationNotTracked' | string;
export type NotificationRecord = unknown;
export declare class NotificationPoller extends EventEmitter<{
notification: (event: NotificationRecord) => void;
error: (error: unknown) => void;
}> {
private client;
private bucketName;
private prefix;
private suffix;
private events;
private ending;
constructor(client: TypedClient, bucketName: string, prefix: string, suffix: string, events: NotificationEvent[]);
start(): void;
stop(): void;
checkForChanges(): void;
}
export {};
File diff suppressed because one or more lines are too long
+30
View File
@@ -0,0 +1,30 @@
// Returns a wrapper function that will promisify a given callback function.
// It will preserve 'this'.
export function promisify(fn) {
return function () {
// If the last argument is a function, assume its the callback.
let callback = arguments[arguments.length - 1];
// If the callback is given, don't promisify, just pass straight in.
if (typeof callback === 'function') {
return fn.apply(this, arguments);
}
// Otherwise, create a new set of arguments, and wrap
// it in a promise.
let args = [...arguments];
return new Promise((resolve, reject) => {
// Add the callback function.
args.push((err, value) => {
if (err) {
return reject(err);
}
resolve(value);
});
// Call the function with our special adaptor callback added.
fn.apply(this, args);
});
};
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJwcm9taXNpZnkiLCJmbiIsImNhbGxiYWNrIiwiYXJndW1lbnRzIiwibGVuZ3RoIiwiYXBwbHkiLCJhcmdzIiwiUHJvbWlzZSIsInJlc29sdmUiLCJyZWplY3QiLCJwdXNoIiwiZXJyIiwidmFsdWUiXSwic291cmNlcyI6WyJwcm9taXNpZnkuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gUmV0dXJucyBhIHdyYXBwZXIgZnVuY3Rpb24gdGhhdCB3aWxsIHByb21pc2lmeSBhIGdpdmVuIGNhbGxiYWNrIGZ1bmN0aW9uLlxuLy8gSXQgd2lsbCBwcmVzZXJ2ZSAndGhpcycuXG5leHBvcnQgZnVuY3Rpb24gcHJvbWlzaWZ5KGZuKSB7XG4gIH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UFFO0VBQzVCLE9BQU8sWUFBWTtJQUNqQjtJQUNBLElBQUlDLFFBQVEsR0FBR0MsU0FBUyxDQUFDQSxTQUFTLENBQUNDLE1BQU0sR0FBRyxDQUFDLENBQUM7O0lBRTlDO0lBQ0EsSUFBSSxPQUFPRixRQUFRLEtBQUssVUFBVSxFQUFFO01BQ2xDLE9BQU9ELEVBQUUsQ0FBQ0ksS0FBSyxDQUFDLElBQUksRUFBRUYsU0FBUyxDQUFDO0lBQ2xDOztJQUVBO0lBQ0E7SUFDQSxJQUFJRyxJQUFJLEdBQUcsQ0FBQyxHQUFHSCxTQUFTLENBQUM7SUFFekIsT0FBTyxJQUFJSSxPQUFPLENBQUMsQ0FBQ0MsT0FBTyxFQUFFQyxNQUFNLEtBQUs7TUFDdEM7TUFDQUgsSUFBSSxDQUFDSSxJQUFJLENBQUMsQ0FBQ0MsR0FBRyxFQUFFQyxLQUFLLEtBQUs7UUFDeEIsSUFBSUQsR0FBRyxFQUFFO1VBQ1AsT0FBT0YsTUFBTSxDQUFDRSxHQUFHLENBQUM7UUFDcEI7UUFFQUgsT0FBTyxDQUFDSSxLQUFLLENBQUM7TUFDaEIsQ0FBQyxDQUFDOztNQUVGO01BQ0FYLEVBQUUsQ0FBQ0ksS0FBSyxDQUFDLElBQUksRUFBRUMsSUFBSSxDQUFDO0lBQ3RCLENBQUMsQ0FBQztFQUNKLENBQUM7QUFDSCJ9
+5
View File
@@ -0,0 +1,5 @@
import type { IRequest } from "./internal/type.mjs";
export declare function postPresignSignatureV4(region: string, date: Date, secretKey: string, policyBase64: string): string;
export declare function signV4(request: IRequest, accessKey: string, secretKey: string, region: string, requestDate: Date, sha256sum: string, serviceName?: string): string;
export declare function signV4ByServiceName(request: IRequest, accessKey: string, secretKey: string, region: string, requestDate: Date, contentSha256: string, serviceName?: string): string;
export declare function presignSignatureV4(request: IRequest, accessKey: string, secretKey: string, sessionToken: string | undefined, region: string, requestDate: Date, expires: number | undefined): string;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,86 @@
/// <reference types="node" />
import * as http from 'node:http';
import { CredentialProvider } from "./CredentialProvider.js";
import { Credentials } from "./Credentials.js";
/**
* @see https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
*/
type CredentialResponse = {
ErrorResponse?: {
Error?: {
Code?: string;
Message?: string;
};
};
AssumeRoleResponse: {
AssumeRoleResult: {
Credentials: {
AccessKeyId: string;
SecretAccessKey: string;
SessionToken: string;
Expiration: string;
};
};
};
};
export interface AssumeRoleProviderOptions {
stsEndpoint: string;
accessKey: string;
secretKey: string;
durationSeconds?: number;
sessionToken?: string;
policy?: string;
region?: string;
roleArn?: string;
roleSessionName?: string;
externalId?: string;
token?: string;
webIdentityToken?: string;
action?: string;
transportAgent?: http.Agent;
}
export declare class AssumeRoleProvider extends CredentialProvider {
private readonly stsEndpoint;
private readonly accessKey;
private readonly secretKey;
private readonly durationSeconds;
private readonly policy?;
private readonly region;
private readonly roleArn?;
private readonly roleSessionName?;
private readonly externalId?;
private readonly token?;
private readonly webIdentityToken?;
private readonly action;
private _credentials;
private readonly expirySeconds;
private accessExpiresAt;
private readonly transportAgent?;
private readonly transport;
constructor({
stsEndpoint,
accessKey,
secretKey,
durationSeconds,
sessionToken,
policy,
region,
roleArn,
roleSessionName,
externalId,
token,
webIdentityToken,
action,
transportAgent
}: AssumeRoleProviderOptions);
getRequestConfig(): {
requestOptions: http.RequestOptions;
requestData: string;
};
performRequest(): Promise<CredentialResponse>;
parseCredentials(respObj: CredentialResponse): Credentials;
refreshCredentials(): Promise<Credentials>;
getCredentials(): Promise<Credentials>;
isAboutToExpire(): boolean;
}
export default AssumeRoleProvider;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,22 @@
import { Credentials } from "./Credentials.js";
export declare class CredentialProvider {
private credentials;
constructor({
accessKey,
secretKey,
sessionToken
}: {
accessKey: string;
secretKey: string;
sessionToken?: string;
});
getCredentials(): Promise<Credentials>;
setCredentials(credentials: Credentials): void;
setAccessKey(accessKey: string): void;
getAccessKey(): string;
setSecretKey(secretKey: string): void;
getSecretKey(): string;
setSessionToken(sessionToken: string): void;
getSessionToken(): string | undefined;
}
export default CredentialProvider;
+55
View File
@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _Credentials = require("./Credentials.js");
class CredentialProvider {
constructor({
accessKey,
secretKey,
sessionToken
}) {
this.credentials = new _Credentials.Credentials({
accessKey,
secretKey,
sessionToken
});
}
async getCredentials() {
return this.credentials.get();
}
setCredentials(credentials) {
if (credentials instanceof _Credentials.Credentials) {
this.credentials = credentials;
} else {
throw new Error('Unable to set Credentials. it should be an instance of Credentials class');
}
}
setAccessKey(accessKey) {
this.credentials.setAccessKey(accessKey);
}
getAccessKey() {
return this.credentials.getAccessKey();
}
setSecretKey(secretKey) {
this.credentials.setSecretKey(secretKey);
}
getSecretKey() {
return this.credentials.getSecretKey();
}
setSessionToken(sessionToken) {
this.credentials.setSessionToken(sessionToken);
}
getSessionToken() {
return this.credentials.getSessionToken();
}
}
// deprecated default export, please use named exports.
// keep for backward compatibility.
// eslint-disable-next-line import/no-default-export
exports.CredentialProvider = CredentialProvider;
var _default = CredentialProvider;
exports.default = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfQ3JlZGVudGlhbHMiLCJyZXF1aXJlIiwiQ3JlZGVudGlhbFByb3ZpZGVyIiwiY29uc3RydWN0b3IiLCJhY2Nlc3NLZXkiLCJzZWNyZXRLZXkiLCJzZXNzaW9uVG9rZW4iLCJjcmVkZW50aWFscyIsIkNyZWRlbnRpYWxzIiwiZ2V0Q3JlZGVudGlhbHMiLCJnZXQiLCJzZXRDcmVkZW50aWFscyIsIkVycm9yIiwic2V0QWNjZXNzS2V5IiwiZ2V0QWNjZXNzS2V5Iiwic2V0U2VjcmV0S2V5IiwiZ2V0U2VjcmV0S2V5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UFFQVksZUFBZUEsQ0FBQSxFQUFHO0lBQ2hCLE9BQU8sSUFBSSxDQUFDWCxXQUFXLENBQUNXLGVBQWUsQ0FBQyxDQUFDO0VBQzNDO0FBQ0Y7O0FBRUE7QUFDQTtBQUNBO0FBQUFDLE9BQUEsQ0FBQWpCLGtCQUFBLEdBQUFBLGtCQUFBO0FBQUEsSUFBQWtCLFFBQUEsR0FDZWxCLGtCQUFrQjtBQUFBaUIsT0FBQSxDQUFBRSxPQUFBLEdBQUFELFFBQUEifQ==
+22
View File
@@ -0,0 +1,22 @@
export declare class Credentials {
accessKey: string;
secretKey: string;
sessionToken?: string;
constructor({
accessKey,
secretKey,
sessionToken
}: {
accessKey: string;
secretKey: string;
sessionToken?: string;
});
setAccessKey(accessKey: string): void;
getAccessKey(): string;
setSecretKey(secretKey: string): void;
getSecretKey(): string;
setSessionToken(sessionToken: string): void;
getSessionToken(): string | undefined;
get(): Credentials;
}
export default Credentials;
+45
View File
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
class Credentials {
constructor({
accessKey,
secretKey,
sessionToken
}) {
this.accessKey = accessKey;
this.secretKey = secretKey;
this.sessionToken = sessionToken;
}
setAccessKey(accessKey) {
this.accessKey = accessKey;
}
getAccessKey() {
return this.accessKey;
}
setSecretKey(secretKey) {
this.secretKey = secretKey;
}
getSecretKey() {
return this.secretKey;
}
setSessionToken(sessionToken) {
this.sessionToken = sessionToken;
}
getSessionToken() {
return this.sessionToken;
}
get() {
return this;
}
}
// deprecated default export, please use named exports.
// keep for backward compatibility.
// eslint-disable-next-line import/no-default-export
exports.Credentials = Credentials;
var _default = Credentials;
exports.default = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDcmVkZW50aWFscyIsImNvbnN0cnVjdG9yIiwiYWNjZXNzS2V5Iiwic2VjcmV0S2V5Iiwic2Vzc2lvblRva2VuIiwic2V0QWNjZXNzS2V5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BQUNMLFNBQVM7RUFDdkI7RUFFQU0sZUFBZUEsQ0FBQ0wsWUFBb0IsRUFBRTtJQUNwQyxJQUFJLENBQUNBLFlBQVksR0FBR0EsWUFBWTtFQUNsQztFQUVBTSxlQUFlQSxDQUFBLEVBQUc7SUFDaEIsT0FBTyxJQUFJLENBQUNOLFlBQVk7RUFDMUI7RUFFQU8sR0FBR0EsQ0FBQSxFQUFnQjtJQUNqQixPQUFPLElBQUk7RUFDYjtBQUNGOztBQUVBO0FBQ0E7QUFDQTtBQUFBQyxPQUFBLENBQUFaLFdBQUEsR0FBQUEsV0FBQTtBQUFBLElBQUFhLFFBQUEsR0FDZWIsV0FBVztBQUFBWSxPQUFBLENBQUFFLE9BQUEsR0FBQUQsUUFBQSJ9
+27
View File
@@ -0,0 +1,27 @@
/// <reference types="node" />
import * as http from 'node:http';
import { CredentialProvider } from "./CredentialProvider.js";
import { Credentials } from "./Credentials.js";
export interface IamAwsProviderOptions {
customEndpoint?: string;
transportAgent?: http.Agent;
}
export declare class IamAwsProvider extends CredentialProvider {
private readonly customEndpoint?;
private _credentials;
private readonly transportAgent?;
private accessExpiresAt;
constructor({
customEndpoint,
transportAgent
}: IamAwsProviderOptions);
getCredentials(): Promise<Credentials>;
private fetchCredentials;
private fetchCredentialsUsingTokenFile;
private fetchImdsToken;
private getIamRoleNamedUrl;
private getIamRoleName;
private requestCredentials;
private isAboutToExpire;
}
export default IamAwsProvider;
File diff suppressed because one or more lines are too long
+82
View File
@@ -0,0 +1,82 @@
/// <reference lib="es2022.error" />
declare class ExtendableError extends Error {
constructor(message?: string, opt?: ErrorOptions);
}
/**
* AnonymousRequestError is generated for anonymous keys on specific
* APIs. NOTE: PresignedURL generation always requires access keys.
*/
export declare class AnonymousRequestError extends ExtendableError {}
/**
* InvalidArgumentError is generated for all invalid arguments.
*/
export declare class InvalidArgumentError extends ExtendableError {}
/**
* InvalidPortError is generated when a non integer value is provided
* for ports.
*/
export declare class InvalidPortError extends ExtendableError {}
/**
* InvalidEndpointError is generated when an invalid end point value is
* provided which does not follow domain standards.
*/
export declare class InvalidEndpointError extends ExtendableError {}
/**
* InvalidBucketNameError is generated when an invalid bucket name is
* provided which does not follow AWS S3 specifications.
* http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
*/
export declare class InvalidBucketNameError extends ExtendableError {}
/**
* InvalidObjectNameError is generated when an invalid object name is
* provided which does not follow AWS S3 specifications.
* http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
*/
export declare class InvalidObjectNameError extends ExtendableError {}
/**
* AccessKeyRequiredError generated by signature methods when access
* key is not found.
*/
export declare class AccessKeyRequiredError extends ExtendableError {}
/**
* SecretKeyRequiredError generated by signature methods when secret
* key is not found.
*/
export declare class SecretKeyRequiredError extends ExtendableError {}
/**
* ExpiresParamError generated when expires parameter value is not
* well within stipulated limits.
*/
export declare class ExpiresParamError extends ExtendableError {}
/**
* InvalidDateError generated when invalid date is found.
*/
export declare class InvalidDateError extends ExtendableError {}
/**
* InvalidPrefixError generated when object prefix provided is invalid
* or does not conform to AWS S3 object key restrictions.
*/
export declare class InvalidPrefixError extends ExtendableError {}
/**
* InvalidBucketPolicyError generated when the given bucket policy is invalid.
*/
export declare class InvalidBucketPolicyError extends ExtendableError {}
/**
* IncorrectSizeError generated when total data read mismatches with
* the input size.
*/
export declare class IncorrectSizeError extends ExtendableError {}
/**
* InvalidXMLError generated when an unknown XML is found.
*/
export declare class InvalidXMLError extends ExtendableError {}
/**
* S3Error is generated for errors returned from S3 server.
* see getErrorTransformer for details
*/
export declare class S3Error extends ExtendableError {
code?: string;
region?: string;
}
export declare class IsValidBucketNameError extends ExtendableError {}
export {};
File diff suppressed because one or more lines are too long
+156
View File
@@ -0,0 +1,156 @@
import type { Encryption, ObjectMetaData, RequestHeaders } from "./internal/type.js";
import { RETENTION_MODES } from "./internal/type.js";
export { ENCRYPTION_TYPES, LEGAL_HOLD_STATUS, RETENTION_MODES, RETENTION_VALIDITY_UNITS } from "./internal/type.js";
export declare const DEFAULT_REGION = "us-east-1";
export declare const PRESIGN_EXPIRY_DAYS_MAX: number;
export interface ICopySourceOptions {
Bucket: string;
Object: string;
/**
* Valid versionId
*/
VersionID?: string;
/**
* Etag to match
*/
MatchETag?: string;
/**
* Etag to exclude
*/
NoMatchETag?: string;
/**
* Modified Date of the object/part. UTC Date in string format
*/
MatchModifiedSince?: string | null;
/**
* Modified Date of the object/part to exclude UTC Date in string format
*/
MatchUnmodifiedSince?: string | null;
/**
* true or false Object range to match
*/
MatchRange?: boolean;
Start?: number;
End?: number;
Encryption?: Encryption;
}
export declare class CopySourceOptions {
readonly Bucket: string;
readonly Object: string;
readonly VersionID: string;
MatchETag: string;
private readonly NoMatchETag;
private readonly MatchModifiedSince;
private readonly MatchUnmodifiedSince;
readonly MatchRange: boolean;
readonly Start: number;
readonly End: number;
private readonly Encryption?;
constructor({
Bucket,
Object,
VersionID,
MatchETag,
NoMatchETag,
MatchModifiedSince,
MatchUnmodifiedSince,
MatchRange,
Start,
End,
Encryption
}: ICopySourceOptions);
validate(): boolean;
getHeaders(): RequestHeaders;
}
/**
* @deprecated use nodejs fs module
*/
export declare function removeDirAndFiles(dirPath: string, removeSelf?: boolean): void;
export interface ICopyDestinationOptions {
/**
* Bucket name
*/
Bucket: string;
/**
* Object Name for the destination (composed/copied) object defaults
*/
Object: string;
/**
* Encryption configuration defaults to {}
* @default {}
*/
Encryption?: Encryption;
UserMetadata?: ObjectMetaData;
/**
* query-string encoded string or Record<string, string> Object
*/
UserTags?: Record<string, string> | string;
LegalHold?: 'on' | 'off';
/**
* UTC Date String
*/
RetainUntilDate?: string;
Mode?: RETENTION_MODES;
MetadataDirective?: 'COPY' | 'REPLACE';
/**
* Extra headers for the target object
*/
Headers?: Record<string, string>;
}
export declare class CopyDestinationOptions {
readonly Bucket: string;
readonly Object: string;
private readonly Encryption?;
private readonly UserMetadata?;
private readonly UserTags?;
private readonly LegalHold?;
private readonly RetainUntilDate?;
private readonly Mode?;
private readonly MetadataDirective?;
private readonly Headers?;
constructor({
Bucket,
Object,
Encryption,
UserMetadata,
UserTags,
LegalHold,
RetainUntilDate,
Mode,
MetadataDirective,
Headers
}: ICopyDestinationOptions);
getHeaders(): RequestHeaders;
validate(): boolean;
}
/**
* maybe this should be a generic type for Records, leave it for later refactor
*/
export declare class SelectResults {
private records?;
private response?;
private stats?;
private progress?;
constructor({
records,
// parsed data as stream
response,
// original response stream
stats,
// stats as xml
progress
}: {
records?: unknown;
response?: unknown;
stats?: string;
progress?: unknown;
});
setStats(stats: string): void;
getStats(): string | undefined;
setProgress(progress: unknown): void;
getProgress(): unknown;
setResponse(response: unknown): void;
getResponse(): unknown;
setRecords(records: unknown): void;
getRecords(): unknown;
}
File diff suppressed because one or more lines are too long
+9
View File
@@ -0,0 +1,9 @@
/// <reference types="node" />
/// <reference types="node" />
import * as fs from 'node:fs';
import * as stream from 'node:stream';
export { promises as fsp } from 'node:fs';
export declare const streamPromise: {
pipeline: typeof stream.pipeline.__promisify__;
};
export declare const fstat: typeof fs.fstat.__promisify__;
+24
View File
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var fs = _interopRequireWildcard(require("fs"), true);
var stream = _interopRequireWildcard(require("stream"), true);
var _util = require("util");
var _nodeFs = require("fs");
exports.fsp = _nodeFs.promises;
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
// promise helper for stdlib
// TODO: use "node:fs/promise" directly after we stop testing on nodejs 12
const streamPromise = {
// node:stream/promises Added in: v15.0.0
pipeline: (0, _util.promisify)(stream.pipeline)
};
exports.streamPromise = streamPromise;
const fstat = (0, _util.promisify)(fs.fstat);
exports.fstat = fstat;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJmcyIsIl9pbnRlcm9wUmVxdWlyZVdpbGRjYXJkIiwicmVxdWlyZSIsInN0cmVhbSIsIl91dGlsIiwiX25vZGVGcyIsImV4cG9ydHMiLCJmc3AiLCJwcm9taXNlcyIsIl9nZXRSZXF1aXJlV2lsZGNhcmRDYWNoZSIsIm5vZGVJbnRlcm9wIiwiV2Vha01hcCIsImNhY2hlQmFiZWxJbnRlcm9wIiwiY2FjaGVOb2RlSW50ZXJvcCIsIm9iaiIsIl9fZXNNb2R1bGUiLCJkZWZhdWx0IiwiY2FjaGUiLCJoYXMiLCJnZXQiLCJuZXdPYmoiLCJoYXNQcm9wZXJ0eURlc2NyaXB0b3IiLCJPYmplY3QiLCJkZWZpbmVQcm9wZXJ0eSIsImdldE93blByb3BlcnR5RGVzY3JpcHRvciIsImtleSIsInByb3RvdHlwZSIsImhhc093blByb3BlcnR5IiwiY2FsbCIsImRlc2MiLCJzZXQiLCJzdHJlYW1Qcm9taXNlIiwicGlwZWxpbmUiLCJwcm9taXNpZnkiLCJmc3RhdCJdLCJzb3VyY2VzIjpbImFzeW5jLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIHByb21pc2UgaGVscGVyIGZvciBzdGRsaWJcblxuaW1wb3J0ICogYXMgZnMgZn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QUNyQyxDQUFDO0FBQUExQixPQUFBLENBQUF5QixhQUFBLEdBQUFBLGFBQUE7QUFFTSxNQUFNRyxLQUFLLEdBQUcsSUFBQUQsZUFBUyxFQUFDakMsRUFBRSxDQUFDa0MsS0FBSyxDQUFDO0FBQUE1QixPQUFBLENBQUE0QixLQUFBLEdBQUFBLEtBQUEifQ==
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.callbackify = callbackify;
// wrapper an async function that support callback style API.
// It will preserve 'this'.
function callbackify(fn) {
return function () {
const args = [...arguments];
const callback = args.pop();
// If the last argument is a function, assume it's the callback.
if (typeof callback === 'function') {
return fn.apply(this, args).then(result => callback(null, result), err => callback(err));
}
return fn.apply(this, arguments);
};
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJjYWxsYmFja2lmeSIsImZuIiwiYXJncyIsImFyZ3VtZW50cyIsImNhbGxiYWNrIiwicG9wIiwiYXBwbHkiLCJ0aGVuIiwicmVzdWx0IiwiZXJyIl0sInNvdXJjZXMiOlsiY2FsbGJhY2tpZnkuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gd3JhcHBlciBhbiBhc3luYyBmdW5jdGlvbiB0aGF0IHN1cHBvcnQgY2FsbGJhY2sgc3R5bGUgQVBJLlxuLy8gSXQgd2lsbCBwcmVzZXJ2ZSAndGhpcycuXG5leHBvcnQgZnVuY3Rpb24gY2FsbGJhY2tpZnkoZm4pIHtcbiAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICBjb25zdCBhcmdzID0gWy4uLmFyZ3VtZW50c11cbiAgICBjb25zdCBjYWxsYmFjayA9IGFyZ3MucG9wKClcblxuICAgIC8vIElmIHRoZSBsYXN0IGFyZ3VtZW50IGlzIGEgZnVuY3Rpb24sIGFzc3VtZSBpdCdzIHRoZSBjYWxsYmFjay5cbiAgICBpZiAodHlwZW9mIGNhbGxiYWNrID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICByZXR1cm4gZm4uYXBwbHkodGhpcywgYXJncykudGhlbihcbiAgICAgICAgKHJlc3VsdCkgPT4gY2FsbGJhY2sobnVsbCwgcmVzdWx0KSxcbiAgICAgICAgKGVycikgPT4gY2FsbGJhY2soZXJyKSxcbiAgICAgIClcbiAgICB9XG5cbiAgICByZXR1cm4gZm4uYXBwbHkodGhpcywgYXJndW1lbnRzKVxuICB9XG59XG4iXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBO0FBQ0E7QUFDTyxTQUFTQSxXQUFXQSxDQUFDQyxFQUFFLEVBQUU7RUFDOUIsT0FBTyxZQUFZO0lBQ2pCLE1BQU1DLElBQUksR0FBRyxDQUFDLEdBQUdDLFNBQVMsQ0FBQztJQUMzQixNQUFNQyxRQUFRLEdBQUdGLElBQUksQ0FBQ0csR0FBRyxDQUFDLENBQUM7O0lBRTNCO0lBQ0EsSUFBSSxPQUFPRCxRQUFRLEtBQUssVUFBVSxFQUFFO01BQ2xDLE9BQU9ILEVBQUUsQ0FBQ0ssS0FBSyxDQUFDLElBQUksRUFBRUosSUFBSSxDQUFDLENBQUNLLElBQUksQ0FDN0JDLE1BQU0sSUFBS0osUUFBUSxDQUFDLElBQUksRUFBRUksTUFBTSxDQUFDLEVBQ2pDQyxHQUFHLElBQUtMLFFBQVEsQ0FBQ0ssR0FBRyxDQUN2QixDQUFDO0lBQ0g7SUFFQSxPQUFPUixFQUFFLENBQUNLLEtBQUssQ0FBQyxJQUFJLEVBQUVILFNBQVMsQ0FBQztFQUNsQyxDQUFDO0FBQ0gifQ==
+359
View File
@@ -0,0 +1,359 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import * as http from 'node:http';
import * as https from 'node:https';
import * as stream from 'node:stream';
import { CredentialProvider } from "../CredentialProvider.js";
import type { SelectResults } from "../helpers.js";
import { CopyDestinationOptions, CopySourceOptions, LEGAL_HOLD_STATUS } from "../helpers.js";
import type { PostPolicyResult } from "../minio.js";
import { CopyConditions } from "./copy-conditions.js";
import { Extensions } from "./extensions.js";
import { PostPolicy } from "./post-policy.js";
import type { Region } from "./s3-endpoints.js";
import type { Binary, BucketItemFromList, BucketItemStat, BucketStream, BucketVersioningConfiguration, CopyObjectResult, EncryptionConfig, GetObjectLegalHoldOptions, GetObjectOpts, GetObjectRetentionOpts, IncompleteUploadedBucketItem, IRequest, ItemBucketMetadata, LifecycleConfig, LifeCycleConfigParam, ListObjectQueryOpts, ObjectInfo, ObjectLockInfo, ObjectMetaData, ObjectRetentionInfo, PreSignRequestParams, PutObjectLegalHoldOptions, RemoveObjectsParam, RemoveObjectsResponse, ReplicationConfig, ReplicationConfigOpts, RequestHeaders, ResultCallback, Retention, SelectOptions, StatObjectOpts, Tag, TaggingOpts, Tags, Transport, UploadedObjectInfo } from "./type.js";
import type { ListMultipartResult, UploadedPart } from "./xml-parser.js";
declare const requestOptionProperties: readonly ["agent", "ca", "cert", "ciphers", "clientCertEngine", "crl", "dhparam", "ecdhCurve", "family", "honorCipherOrder", "key", "passphrase", "pfx", "rejectUnauthorized", "secureOptions", "secureProtocol", "servername", "sessionIdContext"];
export interface ClientOptions {
endPoint: string;
accessKey?: string;
secretKey?: string;
useSSL?: boolean;
port?: number;
region?: Region;
transport?: Transport;
sessionToken?: string;
partSize?: number;
pathStyle?: boolean;
credentialsProvider?: CredentialProvider;
s3AccelerateEndpoint?: string;
transportAgent?: http.Agent;
}
export type RequestOption = Partial<IRequest> & {
method: string;
bucketName?: string;
objectName?: string;
query?: string;
pathStyle?: boolean;
};
export type NoResultCallback = (error: unknown) => void;
export interface MakeBucketOpt {
ObjectLocking?: boolean;
}
export interface RemoveOptions {
versionId?: string;
governanceBypass?: boolean;
forceDelete?: boolean;
}
export declare class TypedClient {
protected transport: Transport;
protected host: string;
protected port: number;
protected protocol: string;
protected accessKey: string;
protected secretKey: string;
protected sessionToken?: string;
protected userAgent: string;
protected anonymous: boolean;
protected pathStyle: boolean;
protected regionMap: Record<string, string>;
region?: string;
protected credentialsProvider?: CredentialProvider;
partSize: number;
protected overRidePartSize?: boolean;
protected maximumPartSize: number;
protected maxObjectSize: number;
enableSHA256: boolean;
protected s3AccelerateEndpoint?: string;
protected reqOptions: Record<string, unknown>;
protected transportAgent: http.Agent;
private readonly clientExtensions;
constructor(params: ClientOptions);
/**
* Minio extensions that aren't necessary present for Amazon S3 compatible storage servers
*/
get extensions(): Extensions;
/**
* @param endPoint - valid S3 acceleration end point
*/
setS3TransferAccelerate(endPoint: string): void;
/**
* Sets the supported request options.
*/
setRequestOptions(options: Pick<https.RequestOptions, (typeof requestOptionProperties)[number]>): void;
/**
* This is s3 Specific and does not hold validity in any other Object storage.
*/
private getAccelerateEndPointIfSet;
/**
* Set application specific information.
* Generates User-Agent in the following style.
* MinIO (OS; ARCH) LIB/VER APP/VER
*/
setAppInfo(appName: string, appVersion: string): void;
/**
* returns options object that can be used with http.request()
* Takes care of constructing virtual-host-style or path-style hostname
*/
protected getRequestOptions(opts: RequestOption & {
region: string;
}): IRequest & {
host: string;
headers: Record<string, string>;
};
setCredentialsProvider(credentialsProvider: CredentialProvider): Promise<void>;
private checkAndRefreshCreds;
private logStream?;
/**
* log the request, response, error
*/
private logHTTP;
/**
* Enable tracing
*/
traceOn(stream?: stream.Writable): void;
/**
* Disable tracing
*/
traceOff(): void;
/**
* makeRequest is the primitive used by the apis for making S3 requests.
* payload can be empty string in case of no payload.
* statusCode is the expected statusCode. If response.statusCode does not match
* we parse the XML error and call the callback with the error message.
*
* A valid region is passed by the calls - listBuckets, makeBucket and getBucketRegion.
*
* @internal
*/
makeRequestAsync(options: RequestOption, payload?: Binary, expectedCodes?: number[], region?: string): Promise<http.IncomingMessage>;
/**
* new request with promise
*
* No need to drain response, response body is not valid
*/
makeRequestAsyncOmit(options: RequestOption, payload?: Binary, statusCodes?: number[], region?: string): Promise<Omit<http.IncomingMessage, 'on'>>;
/**
* makeRequestStream will be used directly instead of makeRequest in case the payload
* is available as a stream. for ex. putObject
*
* @internal
*/
makeRequestStreamAsync(options: RequestOption, body: stream.Readable | Binary, sha256sum: string, statusCodes: number[], region: string): Promise<http.IncomingMessage>;
/**
* gets the region of the bucket
*
* @param bucketName
*
* @internal
*/
protected getBucketRegionAsync(bucketName: string): Promise<string>;
/**
* makeRequest is the primitive used by the apis for making S3 requests.
* payload can be empty string in case of no payload.
* statusCode is the expected statusCode. If response.statusCode does not match
* we parse the XML error and call the callback with the error message.
* A valid region is passed by the calls - listBuckets, makeBucket and
* getBucketRegion.
*
* @deprecated use `makeRequestAsync` instead
*/
makeRequest(options: RequestOption, payload: Binary | undefined, expectedCodes: number[] | undefined, region: string | undefined, returnResponse: boolean, cb: (cb: unknown, result: http.IncomingMessage) => void): void;
/**
* makeRequestStream will be used directly instead of makeRequest in case the payload
* is available as a stream. for ex. putObject
*
* @deprecated use `makeRequestStreamAsync` instead
*/
makeRequestStream(options: RequestOption, stream: stream.Readable | Buffer, sha256sum: string, statusCodes: number[], region: string, returnResponse: boolean, cb: (cb: unknown, result: http.IncomingMessage) => void): void;
/**
* @deprecated use `getBucketRegionAsync` instead
*/
getBucketRegion(bucketName: string, cb: (err: unknown, region: string) => void): Promise<void>;
/**
* Creates the bucket `bucketName`.
*
*/
makeBucket(bucketName: string, region?: Region, makeOpts?: MakeBucketOpt): Promise<void>;
/**
* To check if a bucket already exists.
*/
bucketExists(bucketName: string): Promise<boolean>;
removeBucket(bucketName: string): Promise<void>;
/**
* @deprecated use promise style API
*/
removeBucket(bucketName: string, callback: NoResultCallback): void;
/**
* Callback is called with readable stream of the object content.
*/
getObject(bucketName: string, objectName: string, getOpts?: GetObjectOpts): Promise<stream.Readable>;
/**
* Callback is called with readable stream of the partial object content.
* @param bucketName
* @param objectName
* @param offset
* @param length - length of the object that will be read in the stream (optional, if not specified we read the rest of the file from the offset)
* @param getOpts
*/
getPartialObject(bucketName: string, objectName: string, offset: number, length?: number, getOpts?: GetObjectOpts): Promise<stream.Readable>;
/**
* download object content to a file.
* This method will create a temp file named `${filename}.${base64(etag)}.part.minio` when downloading.
*
* @param bucketName - name of the bucket
* @param objectName - name of the object
* @param filePath - path to which the object data will be written to
* @param getOpts - Optional object get option
*/
fGetObject(bucketName: string, objectName: string, filePath: string, getOpts?: GetObjectOpts): Promise<void>;
/**
* Stat information of the object.
*/
statObject(bucketName: string, objectName: string, statOpts?: StatObjectOpts): Promise<BucketItemStat>;
removeObject(bucketName: string, objectName: string, removeOpts?: RemoveOptions): Promise<void>;
listIncompleteUploads(bucket: string, prefix: string, recursive: boolean): BucketStream<IncompleteUploadedBucketItem>;
/**
* Called by listIncompleteUploads to fetch a batch of incomplete uploads.
*/
listIncompleteUploadsQuery(bucketName: string, prefix: string, keyMarker: string, uploadIdMarker: string, delimiter: string): Promise<ListMultipartResult>;
/**
* Initiate a new multipart upload.
* @internal
*/
initiateNewMultipartUpload(bucketName: string, objectName: string, headers: RequestHeaders): Promise<string>;
/**
* Internal Method to abort a multipart upload request in case of any errors.
*
* @param bucketName - Bucket Name
* @param objectName - Object Name
* @param uploadId - id of a multipart upload to cancel during compose object sequence.
*/
abortMultipartUpload(bucketName: string, objectName: string, uploadId: string): Promise<void>;
findUploadId(bucketName: string, objectName: string): Promise<string | undefined>;
/**
* this call will aggregate the parts on the server into a single object.
*/
completeMultipartUpload(bucketName: string, objectName: string, uploadId: string, etags: {
part: number;
etag?: string;
}[]): Promise<{
etag: string;
versionId: string | null;
}>;
/**
* Get part-info of all parts of an incomplete upload specified by uploadId.
*/
protected listParts(bucketName: string, objectName: string, uploadId: string): Promise<UploadedPart[]>;
/**
* Called by listParts to fetch a batch of part-info
*/
private listPartsQuery;
listBuckets(): Promise<BucketItemFromList[]>;
/**
* Calculate part size given the object size. Part size will be atleast this.partSize
*/
calculatePartSize(size: number): number;
/**
* Uploads the object using contents from a file
*/
fPutObject(bucketName: string, objectName: string, filePath: string, metaData?: ObjectMetaData): Promise<UploadedObjectInfo>;
/**
* Uploading a stream, "Buffer" or "string".
* It's recommended to pass `size` argument with stream.
*/
putObject(bucketName: string, objectName: string, stream: stream.Readable | Buffer | string, size?: number, metaData?: ItemBucketMetadata): Promise<UploadedObjectInfo>;
/**
* method to upload buffer in one call
* @private
*/
private uploadBuffer;
/**
* upload stream with MultipartUpload
* @private
*/
private uploadStream;
removeBucketReplication(bucketName: string): Promise<void>;
removeBucketReplication(bucketName: string, callback: NoResultCallback): void;
setBucketReplication(bucketName: string, replicationConfig: ReplicationConfigOpts): void;
setBucketReplication(bucketName: string, replicationConfig: ReplicationConfigOpts): Promise<void>;
getBucketReplication(bucketName: string): void;
getBucketReplication(bucketName: string): Promise<ReplicationConfig>;
getObjectLegalHold(bucketName: string, objectName: string, getOpts?: GetObjectLegalHoldOptions, callback?: ResultCallback<LEGAL_HOLD_STATUS>): Promise<LEGAL_HOLD_STATUS>;
setObjectLegalHold(bucketName: string, objectName: string, setOpts?: PutObjectLegalHoldOptions): void;
/**
* Get Tags associated with a Bucket
*/
getBucketTagging(bucketName: string): Promise<Tag[]>;
/**
* Get the tags associated with a bucket OR an object
*/
getObjectTagging(bucketName: string, objectName: string, getOpts?: GetObjectOpts): Promise<Tag[]>;
/**
* Set the policy on a bucket or an object prefix.
*/
setBucketPolicy(bucketName: string, policy: string): Promise<void>;
/**
* Get the policy on a bucket or an object prefix.
*/
getBucketPolicy(bucketName: string): Promise<string>;
putObjectRetention(bucketName: string, objectName: string, retentionOpts?: Retention): Promise<void>;
getObjectLockConfig(bucketName: string, callback: ResultCallback<ObjectLockInfo>): void;
getObjectLockConfig(bucketName: string): void;
getObjectLockConfig(bucketName: string): Promise<ObjectLockInfo>;
setObjectLockConfig(bucketName: string, lockConfigOpts: Omit<ObjectLockInfo, 'objectLockEnabled'>): void;
setObjectLockConfig(bucketName: string, lockConfigOpts: Omit<ObjectLockInfo, 'objectLockEnabled'>): Promise<void>;
getBucketVersioning(bucketName: string): Promise<BucketVersioningConfiguration>;
setBucketVersioning(bucketName: string, versionConfig: BucketVersioningConfiguration): Promise<void>;
private setTagging;
private removeTagging;
setBucketTagging(bucketName: string, tags: Tags): Promise<void>;
removeBucketTagging(bucketName: string): Promise<void>;
setObjectTagging(bucketName: string, objectName: string, tags: Tags, putOpts?: TaggingOpts): Promise<void>;
removeObjectTagging(bucketName: string, objectName: string, removeOpts: TaggingOpts): Promise<void>;
selectObjectContent(bucketName: string, objectName: string, selectOpts: SelectOptions): Promise<SelectResults | undefined>;
private applyBucketLifecycle;
removeBucketLifecycle(bucketName: string): Promise<void>;
setBucketLifecycle(bucketName: string, lifeCycleConfig: LifeCycleConfigParam): Promise<void>;
getBucketLifecycle(bucketName: string): Promise<LifecycleConfig | null>;
setBucketEncryption(bucketName: string, encryptionConfig?: EncryptionConfig): Promise<void>;
getBucketEncryption(bucketName: string): Promise<any>;
removeBucketEncryption(bucketName: string): Promise<void>;
getObjectRetention(bucketName: string, objectName: string, getOpts?: GetObjectRetentionOpts): Promise<ObjectRetentionInfo | null | undefined>;
removeObjects(bucketName: string, objectsList: RemoveObjectsParam): Promise<RemoveObjectsResponse[]>;
removeIncompleteUpload(bucketName: string, objectName: string): Promise<void>;
private copyObjectV1;
private copyObjectV2;
copyObject(source: CopySourceOptions, dest: CopyDestinationOptions): Promise<CopyObjectResult>;
copyObject(targetBucketName: string, targetObjectName: string, sourceBucketNameAndObjectName: string, conditions?: CopyConditions): Promise<CopyObjectResult>;
uploadPart(partConfig: {
bucketName: string;
objectName: string;
uploadID: string;
partNumber: number;
headers: RequestHeaders;
}, payload?: Binary): Promise<{
etag: string;
key: string;
part: number;
}>;
composeObject(destObjConfig: CopyDestinationOptions, sourceObjList: CopySourceOptions[]): Promise<boolean | {
etag: string;
versionId: string | null;
} | Promise<void> | CopyObjectResult>;
presignedUrl(method: string, bucketName: string, objectName: string, expires?: number | PreSignRequestParams | undefined, reqParams?: PreSignRequestParams | Date, requestDate?: Date): Promise<string>;
presignedGetObject(bucketName: string, objectName: string, expires?: number, respHeaders?: PreSignRequestParams | Date, requestDate?: Date): Promise<string>;
presignedPutObject(bucketName: string, objectName: string, expires?: number): Promise<string>;
newPostPolicy(): PostPolicy;
presignedPostPolicy(postPolicy: PostPolicy): Promise<PostPolicyResult>;
listObjectsQuery(bucketName: string, prefix?: string, marker?: string, listQueryOpts?: ListObjectQueryOpts): Promise<{
objects: ObjectInfo[];
isTruncated?: boolean | undefined;
nextMarker?: string | undefined;
versionIdMarker?: string | undefined;
}>;
listObjects(bucketName: string, prefix?: string, recursive?: boolean, listOpts?: ListObjectQueryOpts | undefined): BucketStream<ObjectInfo>;
}
export {};
File diff suppressed because one or more lines are too long
@@ -0,0 +1,10 @@
export declare class CopyConditions {
modified: string;
unmodified: string;
matchETag: string;
matchETagExcept: string;
setModified(date: Date): void;
setUnmodified(date: Date): void;
setMatchETag(etag: string): void;
setMatchETagExcept(etag: string): void;
}
@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
class CopyConditions {
modified = '';
unmodified = '';
matchETag = '';
matchETagExcept = '';
setModified(date) {
if (!(date instanceof Date)) {
throw new TypeError('date must be of type Date');
}
this.modified = date.toUTCString();
}
setUnmodified(date) {
if (!(date instanceof Date)) {
throw new TypeError('date must be of type Date');
}
this.unmodified = date.toUTCString();
}
setMatchETag(etag) {
this.matchETag = etag;
}
setMatchETagExcept(etag) {
this.matchETagExcept = etag;
}
}
exports.CopyConditions = CopyConditions;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJDb3B5Q29uZGl0aW9ucyIsIm1vZGlmaWVkIiwidW5tb2RpZmllZCIsIm1hdGNoRVRhZyIsIm1hdGNoRVRhZ0V4Y2VwdCIsInNldE1vZGlmaWVkIiwiZGF0ZSIsIkRhdGUiLCJUeXBlRXJyb3IiLCJ0b1VUQ1N0cmluZyIsInNldFVubW9kaWZpZWQiLCJzZXRNYXRjaEVUYWciLCJldGFnIiwic2V0TWF0Y2hFVGFnRXhjZXB0IiwiZXhwb3J0c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TtFQUNmQyxTQUFTLEdBQUcsRUFBRTtFQUNkQyxlQUFlLEdBQUcsRUFBRTtFQUUzQkMsV0FBV0EsQ0FBQ0MsSUFBVSxFQUFRO0lBQzVCLElBQUksRUFBRUEsSUFBSSxZQUFZQyxJQUFJLENBQUMsRUFBRTtNQUMzQixNQUFNLElBQUlDLFNBQVMsQ0FBQywyQkFBMkIsQ0FBQztJQUNsRDtJQUVBLElBQUksQ0FBQ1AsUUFBUSxHQUFHSyxJQUFJLENBQUNHLFdBQVcsQ0FBQyxDQUFDO0VBQ3BDO0VBRUFDLGFBQWFBLENBQUNKLElBQVUsRUFBUTtJQUM5QixJQUFJLEVBQUVBLElBQUksWUFBWUMsSUFBSSxDQUFDLEVBQUU7TUFDM0IsTUFBTSxJQUFJQyxTQUFTLENBQUMsMkJBQTJCLENBQUM7SUFDbEQ7SUFFQSxJQUFJLENBQUNOLFVBQVUsR0FBR0ksSUFBSSxDQUFDRyxXQUFXLENBQUMsQ0FBQztFQUN0QztFQUVBRSxZQUFZQSxDQUFDQyxJQUFZLEVBQVE7SUFDL0IsSUFBSSxDQUFDVCxTQUFTLEdBQUdTLElBQUk7RUFDdkI7RUFFQUMsa0JBQWtCQSxDQUFDRCxJQUFZLEVBQVE7SUFDckMsSUFBSSxDQUFDUixlQUFlLEdBQUdRLElBQUk7RUFDN0I7QUFDRjtBQUFDRSxPQUFBLENBQUFkLGNBQUEsR0FBQUEsY0FBQSJ9
@@ -0,0 +1,18 @@
import type { TypedClient } from "./client.js";
import type { BucketItemWithMetadata, BucketStream } from "./type.js";
export declare class Extensions {
private readonly client;
constructor(client: TypedClient);
/**
* List the objects in the bucket using S3 ListObjects V2 With Metadata
*
* @param bucketName - name of the bucket
* @param prefix - the prefix of the objects that should be listed (optional, default `''`)
* @param recursive - `true` indicates recursive style listing and `false` indicates directory style listing delimited by '/'. (optional, default `false`)
* @param startAfter - Specifies the key to start after when listing objects in a bucket. (optional, default `''`)
* @returns stream emitting the objects in the bucket, the object is of the format:
*/
listObjectsV2WithMetadata(bucketName: string, prefix?: string, recursive?: boolean, startAfter?: string): BucketStream<BucketItemWithMetadata>;
private listObjectsV2WithMetadataGen;
private listObjectsV2WithMetadataQuery;
}
File diff suppressed because one or more lines are too long
+173
View File
@@ -0,0 +1,173 @@
/// <reference types="node" />
/// <reference types="node" />
import * as stream from 'node:stream';
import _ from 'lodash';
import type { Binary, Encryption, ObjectMetaData, RequestHeaders, ResponseHeader } from "./type.js";
export declare function hashBinary(buf: Buffer, enableSHA256: boolean): {
md5sum: string;
sha256sum: string;
};
export declare function uriEscape(uriStr: string): string;
export declare function uriResourceEscape(string: string): string;
export declare function getScope(region: string, date: Date, serviceName?: string): string;
/**
* isAmazonEndpoint - true if endpoint is 's3.amazonaws.com' or 's3.cn-north-1.amazonaws.com.cn'
*/
export declare function isAmazonEndpoint(endpoint: string): boolean;
/**
* isVirtualHostStyle - verify if bucket name is support with virtual
* hosts. bucketNames with periods should be always treated as path
* style if the protocol is 'https:', this is due to SSL wildcard
* limitation. For all other buckets and Amazon S3 endpoint we will
* default to virtual host style.
*/
export declare function isVirtualHostStyle(endpoint: string, protocol: string, bucket: string, pathStyle: boolean): boolean;
export declare function isValidIP(ip: string): boolean;
/**
* @returns if endpoint is valid domain.
*/
export declare function isValidEndpoint(endpoint: string): boolean;
/**
* @returns if input host is a valid domain.
*/
export declare function isValidDomain(host: string): boolean;
/**
* Probes contentType using file extensions.
*
* @example
* ```
* // return 'image/png'
* probeContentType('file.png')
* ```
*/
export declare function probeContentType(path: string): string;
/**
* is input port valid.
*/
export declare function isValidPort(port: unknown): port is number;
export declare function isValidBucketName(bucket: unknown): boolean;
/**
* check if objectName is a valid object name
*/
export declare function isValidObjectName(objectName: unknown): boolean;
/**
* check if prefix is valid
*/
export declare function isValidPrefix(prefix: unknown): prefix is string;
/**
* check if typeof arg number
*/
export declare function isNumber(arg: unknown): arg is number;
export type AnyFunction = (...args: any[]) => any;
/**
* check if typeof arg function
*/
export declare function isFunction(arg: unknown): arg is AnyFunction;
/**
* check if typeof arg string
*/
export declare function isString(arg: unknown): arg is string;
/**
* check if typeof arg object
*/
export declare function isObject(arg: unknown): arg is object;
/**
* check if object is readable stream
*/
export declare function isReadableStream(arg: unknown): arg is stream.Readable;
/**
* check if arg is boolean
*/
export declare function isBoolean(arg: unknown): arg is boolean;
export declare function isEmpty(o: unknown): o is null | undefined;
export declare function isEmptyObject(o: Record<string, unknown>): boolean;
export declare function isDefined<T>(o: T): o is Exclude<T, null | undefined>;
/**
* check if arg is a valid date
*/
export declare function isValidDate(arg: unknown): arg is Date;
/**
* Create a Date string with format: 'YYYYMMDDTHHmmss' + Z
*/
export declare function makeDateLong(date?: Date): string;
/**
* Create a Date string with format: 'YYYYMMDD'
*/
export declare function makeDateShort(date?: Date): string;
/**
* pipesetup sets up pipe() from left to right os streams array
* pipesetup will also make sure that error emitted at any of the upstream Stream
* will be emitted at the last stream. This makes error handling simple
*/
export declare function pipesetup(...streams: [stream.Readable, ...stream.Duplex[], stream.Writable]): stream.Readable | stream.Duplex | stream.Writable;
/**
* return a Readable stream that emits data
*/
export declare function readableStream(data: unknown): stream.Readable;
/**
* Process metadata to insert appropriate value to `content-type` attribute
*/
export declare function insertContentType(metaData: ObjectMetaData, filePath: string): ObjectMetaData;
/**
* Function prepends metadata with the appropriate prefix if it is not already on
*/
export declare function prependXAMZMeta(metaData?: ObjectMetaData): RequestHeaders;
/**
* Checks if it is a valid header according to the AmazonS3 API
*/
export declare function isAmzHeader(key: string): boolean;
/**
* Checks if it is a supported Header
*/
export declare function isSupportedHeader(key: string): boolean;
/**
* Checks if it is a storage header
*/
export declare function isStorageClassHeader(key: string): boolean;
export declare function extractMetadata(headers: ResponseHeader): _.Dictionary<string>;
export declare function getVersionId(headers?: ResponseHeader): string | null;
export declare function getSourceVersionId(headers?: ResponseHeader): string | null;
export declare function sanitizeETag(etag?: string): string;
export declare function toMd5(payload: Binary): string;
export declare function toSha256(payload: Binary): string;
/**
* toArray returns a single element array with param being the element,
* if param is just a string, and returns 'param' back if it is an array
* So, it makes sure param is always an array
*/
export declare function toArray<T = unknown>(param: T | T[]): Array<T>;
export declare function sanitizeObjectKey(objectName: string): string;
export declare function sanitizeSize(size?: string): number | undefined;
export declare const PART_CONSTRAINTS: {
ABS_MIN_PART_SIZE: number;
MIN_PART_SIZE: number;
MAX_PARTS_COUNT: number;
MAX_PART_SIZE: number;
MAX_SINGLE_PUT_OBJECT_SIZE: number;
MAX_MULTIPART_PUT_OBJECT_SIZE: number;
};
/**
* Return Encryption headers
* @param encConfig
* @returns an object with key value pairs that can be used in headers.
*/
export declare function getEncryptionHeaders(encConfig: Encryption): RequestHeaders;
export declare function partsRequired(size: number): number;
/**
* calculateEvenSplits - computes splits for a source and returns
* start and end index slices. Splits happen evenly to be sure that no
* part is less than 5MiB, as that could fail the multipart request if
* it is not the last part.
*/
export declare function calculateEvenSplits<T extends {
Start?: number;
}>(size: number, objInfo: T): {
startIndex: number[];
objInfo: T;
endIndex: number[];
} | null;
export declare function parseXml(xml: string): any;
/**
* get content size of object content to upload
*/
export declare function getContentLength(s: stream.Readable | Buffer | string): Promise<number | null>;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
/**
* joinHostPort combines host and port into a network address of the
* form "host:port". If host contains a colon, as found in literal
* IPv6 addresses, then JoinHostPort returns "[host]:port".
*
* @param host
* @param port
* @returns Cleaned up host
* @internal
*/
export declare function joinHostPort(host: string, port?: number): string;
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.joinHostPort = joinHostPort;
/**
* joinHostPort combines host and port into a network address of the
* form "host:port". If host contains a colon, as found in literal
* IPv6 addresses, then JoinHostPort returns "[host]:port".
*
* @param host
* @param port
* @returns Cleaned up host
* @internal
*/
function joinHostPort(host, port) {
if (port === undefined) {
return host;
}
// We assume that host is a literal IPv6 address if host has
// colons.
if (host.includes(':')) {
return `[${host}]:${port.toString()}`;
}
return `${host}:${port.toString()}`;
}
//#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QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNPLFNBQVNBLFlBQVlBLENBQUNDLElBQVksRUFBRUMsSUFBYSxFQUFVO0VBQ2hFLElBQUlBLElBQUksS0FBS0MsU0FBUyxFQUFFO0lBQ3RCLE9BQU9GLElBQUk7RUFDYjs7RUFFQTtFQUNBO0VBQ0EsSUFBSUEsSUFBSSxDQUFDRyxRQUFRLENBQUMsR0FBRyxDQUFDLEVBQUU7SUFDdEIsT0FBUSxJQUFHSCxJQUFLLEtBQUlDLElBQUksQ0FBQ0csUUFBUSxDQUFDLENBQUUsRUFBQztFQUN2QztFQUVBLE9BQVEsR0FBRUosSUFBSyxJQUFHQyxJQUFJLENBQUNHLFFBQVEsQ0FBQyxDQUFFLEVBQUM7QUFDckMifQ==
@@ -0,0 +1,17 @@
import type { ObjectMetaData } from "./type.js";
export declare class PostPolicy {
policy: {
conditions: (string | number)[][];
expiration?: string;
};
formData: Record<string, string>;
setExpires(date: Date): void;
setKey(objectName: string): void;
setKeyStartsWith(prefix: string): void;
setBucket(bucketName: string): void;
setContentType(type: string): void;
setContentTypeStartsWith(prefix: string): void;
setContentDisposition(value: string): void;
setContentLengthRange(min: number, max: number): void;
setUserMetaData(metaData: ObjectMetaData): void;
}
File diff suppressed because one or more lines are too long
+11
View File
@@ -0,0 +1,11 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import type * as https from 'node:https';
import type * as stream from 'node:stream';
import type { Transport } from "./type.js";
export declare function request(transport: Transport, opt: https.RequestOptions, body?: Buffer | string | stream.Readable | null): Promise<http.IncomingMessage>;
export declare const retryHttpCodes: Record<string, boolean>;
export declare function requestWithRetry(transport: Transport, opt: https.RequestOptions, body?: Buffer | string | stream.Readable | null, maxRetries?: number): Promise<http.IncomingMessage>;
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type http from 'node:http';
import type stream from 'node:stream';
export declare function readAsBuffer(res: stream.Readable): Promise<Buffer>;
export declare function readAsString(res: http.IncomingMessage): Promise<string>;
export declare function drainResponse(res: stream.Readable): Promise<void>;
+24
View File
@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.drainResponse = drainResponse;
exports.readAsBuffer = readAsBuffer;
exports.readAsString = readAsString;
async function readAsBuffer(res) {
return new Promise((resolve, reject) => {
const body = [];
res.on('data', chunk => body.push(chunk)).on('error', e => reject(e)).on('end', () => resolve(Buffer.concat(body)));
});
}
async function readAsString(res) {
const body = await readAsBuffer(res);
return body.toString();
}
async function drainResponse(res) {
return new Promise((resolve, reject) => {
res.on('data', () => {}).on('error', e => reject(e)).on('end', () => resolve());
});
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJyZWFkQXNCdWZmZXIiLCJyZXMiLCJQcm9taXNlIiwicmVzb2x2ZSIsInJlamVjdCIsImJvZHkiLCJvbiIsImNodW5rIiwicHVzaCIsImUiLCJCdWZmZXIiLCJjb25jYXQiLCJyZWFkQXNTdHJpbmciLCJ0b1N0cmluZyIsImRyYWluUmVzcG9uc2UiXSwic291cmNlcyI6WyJyZXNwb25zZS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSBodHRwIGZyb20gJ25vZGU6aHR0cCdcbmltcG9ydCB0eXBlIHN0cmVhbSBmcm9tICdub2RlOnN0cmVhbSdcblxuZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIHJlYWRBc0J1ZmZlcihyZXM6IHN0cmVhbS5SZWFkYWJsZSk6IFByb21pc2U8QnVmZmVyPiB7XG4gIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgY29uc3QgYm9keTogQnVmZmVyW10gPSBbXVxuICAgIHJlc1xuICAgICAgLm9uKCdkYXRh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NLLENBQUMsQ0FBQyxDQUFDLENBQzdCSCxFQUFFLENBQUMsS0FBSyxFQUFFLE1BQU1ILE9BQU8sQ0FBQ08sTUFBTSxDQUFDQyxNQUFNLENBQUNOLElBQUksQ0FBQyxDQUFDLENBQUM7RUFDbEQsQ0FBQyxDQUFDO0FBQ0o7QUFFTyxlQUFlTyxZQUFZQSxDQUFDWCxHQUF5QixFQUFtQjtFQUM3RSxNQUFNSSxJQUFJLEdBQUcsTUFBTUwsWUFBWSxDQUFDQyxHQUFHLENBQUM7RUFDcEMsT0FBT0ksSUFBSSxDQUFDUSxRQUFRLENBQUMsQ0FBQztBQUN4QjtBQUVPLGVBQWVDLGFBQWFBLENBQUNiLEdBQW9CLEVBQWlCO0VBQ3ZFLE9BQU8sSUFBSUMsT0FBTyxDQUFDLENBQUNDLE9BQU8sRUFBRUMsTUFBTSxLQUFLO0lBQ3RDSCxHQUFHLENBQ0FLLEVBQUUsQ0FBQyxNQUFNLEVBQUUsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUNwQkEsRUFBRSxDQUFDLE9BQU8sRUFBR0csQ0FBQyxJQUFLTCxNQUFNLENBQUNLLENBQUMsQ0FBQyxDQUFDLENBQzdCSCxFQUFFLENBQUMsS0FBSyxFQUFFLE1BQU1ILE9BQU8sQ0FBQyxDQUFDLENBQUM7RUFDL0IsQ0FBQyxDQUFDO0FBQ0oifQ==
@@ -0,0 +1,38 @@
declare const awsS3Endpoint: {
'af-south-1': string;
'ap-east-1': string;
'ap-south-1': string;
'ap-south-2': string;
'ap-southeast-1': string;
'ap-southeast-2': string;
'ap-southeast-3': string;
'ap-southeast-4': string;
'ap-southeast-5': string;
'ap-northeast-1': string;
'ap-northeast-2': string;
'ap-northeast-3': string;
'ca-central-1': string;
'ca-west-1': string;
'cn-north-1': string;
'eu-central-1': string;
'eu-central-2': string;
'eu-north-1': string;
'eu-south-1': string;
'eu-south-2': string;
'eu-west-1': string;
'eu-west-2': string;
'eu-west-3': string;
'il-central-1': string;
'me-central-1': string;
'me-south-1': string;
'sa-east-1': string;
'us-east-1': string;
'us-east-2': string;
'us-west-1': string;
'us-west-2': string;
'us-gov-east-1': string;
'us-gov-west-1': string;
};
export type Region = keyof typeof awsS3Endpoint | string;
export declare function getS3Endpoint(region: Region): string;
export {};
File diff suppressed because one or more lines are too long
+447
View File
@@ -0,0 +1,447 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import type { Readable as ReadableStream } from 'node:stream';
import type { CopyDestinationOptions, CopySourceOptions } from "../helpers.js";
import type { CopyConditions } from "./copy-conditions.js";
export type VersionIdentificator = {
versionId?: string;
};
export type GetObjectOpts = VersionIdentificator & {
SSECustomerAlgorithm?: string;
SSECustomerKey?: string;
SSECustomerKeyMD5?: string;
};
export type Binary = string | Buffer;
export type ResponseHeader = Record<string, string>;
export type ObjectMetaData = Record<string, string | number>;
export type RequestHeaders = Record<string, string | boolean | number | undefined>;
export type Encryption = {
type: ENCRYPTION_TYPES.SSEC;
} | {
type: ENCRYPTION_TYPES.KMS;
SSEAlgorithm?: string;
KMSMasterKeyID?: string;
};
export type EnabledOrDisabledStatus = 'Enabled' | 'Disabled';
export declare enum ENCRYPTION_TYPES {
/**
* SSEC represents server-side-encryption with customer provided keys
*/
SSEC = "SSE-C",
/**
* KMS represents server-side-encryption with managed keys
*/
KMS = "KMS",
}
export declare enum RETENTION_MODES {
GOVERNANCE = "GOVERNANCE",
COMPLIANCE = "COMPLIANCE",
}
export declare enum RETENTION_VALIDITY_UNITS {
DAYS = "Days",
YEARS = "Years",
}
export declare enum LEGAL_HOLD_STATUS {
ENABLED = "ON",
DISABLED = "OFF",
}
export type Transport = Pick<typeof http, 'request'>;
export interface IRequest {
protocol: string;
port?: number | string;
method: string;
path: string;
headers: RequestHeaders;
}
export type ICanonicalRequest = string;
export interface IncompleteUploadedBucketItem {
key: string;
uploadId: string;
size: number;
}
export interface MetadataItem {
Key: string;
Value: string;
}
export interface ItemBucketMetadataList {
Items: MetadataItem[];
}
export interface ItemBucketMetadata {
[key: string]: any;
}
export interface ItemBucketTags {
[key: string]: any;
}
export interface BucketItemFromList {
name: string;
creationDate: Date;
}
export interface BucketItemCopy {
etag: string;
lastModified: Date;
}
export type BucketItem = {
name: string;
size: number;
etag: string;
prefix?: never;
lastModified: Date;
} | {
name?: never;
etag?: never;
lastModified?: never;
prefix: string;
size: 0;
};
export type BucketItemWithMetadata = BucketItem & {
metadata?: ItemBucketMetadata | ItemBucketMetadataList;
tags?: ItemBucketTags;
};
export interface BucketStream<T> extends ReadableStream {
on(event: 'data', listener: (item: T) => void): this;
on(event: 'end' | 'pause' | 'readable' | 'resume' | 'close', listener: () => void): this;
on(event: 'error', listener: (err: Error) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
}
export interface BucketItemStat {
size: number;
etag: string;
lastModified: Date;
metaData: ItemBucketMetadata;
versionId?: string | null;
}
export type StatObjectOpts = {
versionId?: string;
};
export type ReplicationRuleStatus = {
Status: EnabledOrDisabledStatus;
};
export type Tag = {
Key: string;
Value: string;
};
export type Tags = Record<string, string>;
export type ReplicationRuleDestination = {
Bucket: string;
StorageClass: string;
};
export type ReplicationRuleAnd = {
Prefix: string;
Tags: Tag[];
};
export type ReplicationRuleFilter = {
Prefix: string;
And: ReplicationRuleAnd;
Tag: Tag;
};
export type ReplicaModifications = {
Status: ReplicationRuleStatus;
};
export type SourceSelectionCriteria = {
ReplicaModifications: ReplicaModifications;
};
export type ExistingObjectReplication = {
Status: ReplicationRuleStatus;
};
export type ReplicationRule = {
ID: string;
Status: ReplicationRuleStatus;
Priority: number;
DeleteMarkerReplication: ReplicationRuleStatus;
DeleteReplication: ReplicationRuleStatus;
Destination: ReplicationRuleDestination;
Filter: ReplicationRuleFilter;
SourceSelectionCriteria: SourceSelectionCriteria;
ExistingObjectReplication: ExistingObjectReplication;
};
export type ReplicationConfigOpts = {
role: string;
rules: ReplicationRule[];
};
export type ReplicationConfig = {
ReplicationConfiguration: ReplicationConfigOpts;
};
export type ResultCallback<T> = (error: Error | null, result: T) => void;
export type GetObjectLegalHoldOptions = {
versionId: string;
};
/**
* @deprecated keep for backward compatible, use `LEGAL_HOLD_STATUS` instead
*/
export type LegalHoldStatus = LEGAL_HOLD_STATUS;
export type PutObjectLegalHoldOptions = {
versionId?: string;
status: LEGAL_HOLD_STATUS;
};
export interface UploadedObjectInfo {
etag: string;
versionId: string | null;
}
export interface RetentionOptions {
versionId: string;
mode?: RETENTION_MODES;
retainUntilDate?: IsoDate;
governanceBypass?: boolean;
}
export type Retention = RetentionOptions | EmptyObject;
export type IsoDate = string;
export type EmptyObject = Record<string, never>;
export type ObjectLockInfo = {
objectLockEnabled: EnabledOrDisabledStatus;
mode: RETENTION_MODES;
unit: RETENTION_VALIDITY_UNITS;
validity: number;
} | EmptyObject;
export type ObjectLockConfigParam = {
ObjectLockEnabled?: 'Enabled' | undefined;
Rule?: {
DefaultRetention: {
Mode: RETENTION_MODES;
Days: number;
Years: number;
} | EmptyObject;
} | EmptyObject;
};
export type VersioningEnabled = 'Enabled';
export type VersioningSuspended = 'Suspended';
export type TaggingOpts = {
versionId: string;
};
export type PutTaggingParams = {
bucketName: string;
objectName?: string;
tags: Tags;
putOpts?: TaggingOpts;
};
export type RemoveTaggingParams = {
bucketName: string;
objectName?: string;
removeOpts?: TaggingOpts;
};
export type InputSerialization = {
CompressionType?: 'NONE' | 'GZIP' | 'BZIP2';
CSV?: {
AllowQuotedRecordDelimiter?: boolean;
Comments?: string;
FieldDelimiter?: string;
FileHeaderInfo?: 'NONE' | 'IGNORE' | 'USE';
QuoteCharacter?: string;
QuoteEscapeCharacter?: string;
RecordDelimiter?: string;
};
JSON?: {
Type: 'DOCUMENT' | 'LINES';
};
Parquet?: EmptyObject;
};
export type OutputSerialization = {
CSV?: {
FieldDelimiter?: string;
QuoteCharacter?: string;
QuoteEscapeCharacter?: string;
QuoteFields?: string;
RecordDelimiter?: string;
};
JSON?: {
RecordDelimiter?: string;
};
};
export type SelectProgress = {
Enabled: boolean;
};
export type ScanRange = {
Start: number;
End: number;
};
export type SelectOptions = {
expression: string;
expressionType?: string;
inputSerialization: InputSerialization;
outputSerialization: OutputSerialization;
requestProgress?: SelectProgress;
scanRange?: ScanRange;
};
export type Expiration = {
Date?: string;
Days: number;
DeleteMarker?: boolean;
DeleteAll?: boolean;
};
export type RuleFilterAnd = {
Prefix: string;
Tags: Tag[];
};
export type RuleFilter = {
And?: RuleFilterAnd;
Prefix: string;
Tag?: Tag[];
};
export type NoncurrentVersionExpiration = {
NoncurrentDays: number;
NewerNoncurrentVersions?: number;
};
export type NoncurrentVersionTransition = {
StorageClass: string;
NoncurrentDays?: number;
NewerNoncurrentVersions?: number;
};
export type Transition = {
Date?: string;
StorageClass: string;
Days: number;
};
export type AbortIncompleteMultipartUpload = {
DaysAfterInitiation: number;
};
export type LifecycleRule = {
AbortIncompleteMultipartUpload?: AbortIncompleteMultipartUpload;
ID: string;
Prefix?: string;
Status?: string;
Expiration?: Expiration;
Filter?: RuleFilter;
NoncurrentVersionExpiration?: NoncurrentVersionExpiration;
NoncurrentVersionTransition?: NoncurrentVersionTransition;
Transition?: Transition;
};
export type LifecycleConfig = {
Rule: LifecycleRule[];
};
export type LifeCycleConfigParam = LifecycleConfig | null | undefined | '';
export type ApplySSEByDefault = {
KmsMasterKeyID?: string;
SSEAlgorithm: string;
};
export type EncryptionRule = {
ApplyServerSideEncryptionByDefault?: ApplySSEByDefault;
};
export type EncryptionConfig = {
Rule: EncryptionRule[];
};
export type GetObjectRetentionOpts = {
versionId: string;
};
export type ObjectRetentionInfo = {
mode: RETENTION_MODES;
retainUntilDate: string;
};
export type RemoveObjectsEntry = {
name: string;
versionId?: string;
};
export type ObjectName = string;
export type RemoveObjectsParam = ObjectName[] | RemoveObjectsEntry[];
export type RemoveObjectsRequestEntry = {
Key: string;
VersionId?: string;
};
export type RemoveObjectsResponse = null | undefined | {
Error?: {
Code?: string;
Message?: string;
Key?: string;
VersionId?: string;
};
};
export type CopyObjectResultV1 = {
etag: string;
lastModified: string | Date;
};
export type CopyObjectResultV2 = {
Bucket?: string;
Key?: string;
LastModified: string | Date;
MetaData?: ResponseHeader;
VersionId?: string | null;
SourceVersionId?: string | null;
Etag?: string;
Size?: number;
};
export type CopyObjectResult = CopyObjectResultV1 | CopyObjectResultV2;
export type CopyObjectParams = [CopySourceOptions, CopyDestinationOptions] | [string, string, string, CopyConditions?];
export type ExcludedPrefix = {
Prefix: string;
};
export type BucketVersioningConfiguration = {
Status: VersioningEnabled | VersioningSuspended;
MFADelete?: string;
ExcludedPrefixes?: ExcludedPrefix[];
ExcludeFolders?: boolean;
};
export type UploadPartConfig = {
bucketName: string;
objectName: string;
uploadID: string;
partNumber: number;
headers: RequestHeaders;
sourceObj: string;
};
export type PreSignRequestParams = {
[key: string]: string;
};
/** List object api types **/
export type CommonPrefix = {
Prefix: string;
};
export type Owner = {
ID: string;
DisplayName: string;
};
export type Metadata = {
Items: MetadataItem[];
};
export type ObjectInfo = {
key?: string;
name?: string;
lastModified?: Date;
etag?: string;
owner?: Owner;
storageClass?: string;
userMetadata?: Metadata;
userTags?: string;
prefix?: string;
size?: number;
};
export type ListObjectQueryRes = {
isTruncated?: boolean;
nextMarker?: string;
versionIdMarker?: string;
objects?: ObjectInfo[];
};
export type ListObjectQueryOpts = {
Delimiter?: string;
MaxKeys?: number;
IncludeVersion?: boolean;
};
/** List object api types **/
export type ObjectVersionEntry = {
IsLatest?: string;
VersionId?: string;
};
export type ObjectRowEntry = ObjectVersionEntry & {
Key: string;
LastModified?: Date | undefined;
ETag?: string;
Size?: string;
Owner?: Owner;
StorageClass?: string;
};
export interface ListBucketResultV1 {
Name?: string;
Prefix?: string;
ContinuationToken?: string;
KeyCount?: string;
Marker?: string;
MaxKeys?: string;
Delimiter?: string;
IsTruncated?: boolean;
Contents?: ObjectRowEntry[];
NextKeyMarker?: string;
CommonPrefixes?: CommonPrefix[];
Version?: ObjectRowEntry[];
DeleteMarker?: ObjectRowEntry[];
VersionIdMarker?: string;
NextVersionIdMarker?: string;
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,90 @@
/// <reference types="node" />
/// <reference types="node" />
import type * as http from 'node:http';
import { SelectResults } from "../helpers.js";
import type { BucketItemFromList, BucketItemWithMetadata, CopyObjectResultV1, ObjectInfo, ObjectLockInfo, ReplicationConfig } from "./type.js";
export declare function parseBucketRegion(xml: string): string;
export declare function parseError(xml: string, headerInfo: Record<string, unknown>): Record<string, unknown>;
export declare function parseResponseError(response: http.IncomingMessage): Promise<Record<string, string>>;
/**
* parse XML response for list objects v2 with metadata in a bucket
*/
export declare function parseListObjectsV2WithMetadata(xml: string): {
objects: Array<BucketItemWithMetadata>;
isTruncated: boolean;
nextContinuationToken: string;
};
export type UploadedPart = {
part: number;
lastModified?: Date;
etag: string;
size: number;
};
export declare function parseListParts(xml: string): {
isTruncated: boolean;
marker: number;
parts: UploadedPart[];
};
export declare function parseListBucket(xml: string): BucketItemFromList[];
export declare function parseInitiateMultipart(xml: string): string;
export declare function parseReplicationConfig(xml: string): ReplicationConfig;
export declare function parseObjectLegalHoldConfig(xml: string): any;
export declare function parseTagging(xml: string): any;
export declare function parseCompleteMultipart(xml: string): {
location: any;
bucket: any;
key: any;
etag: any;
errCode?: undefined;
errMessage?: undefined;
} | {
errCode: any;
errMessage: any;
location?: undefined;
bucket?: undefined;
key?: undefined;
etag?: undefined;
} | undefined;
type UploadID = string;
export type ListMultipartResult = {
uploads: {
key: string;
uploadId: UploadID;
initiator?: {
id: string;
displayName: string;
};
owner?: {
id: string;
displayName: string;
};
storageClass: unknown;
initiated: Date;
}[];
prefixes: {
prefix: string;
}[];
isTruncated: boolean;
nextKeyMarker: string;
nextUploadIdMarker: string;
};
export declare function parseListMultipart(xml: string): ListMultipartResult;
export declare function parseObjectLockConfig(xml: string): ObjectLockInfo;
export declare function parseBucketVersioningConfig(xml: string): any;
export declare function parseSelectObjectContentResponse(res: Buffer): SelectResults | undefined;
export declare function parseLifecycleConfig(xml: string): any;
export declare function parseBucketEncryptionConfig(xml: string): any;
export declare function parseObjectRetentionConfig(xml: string): {
mode: any;
retainUntilDate: any;
};
export declare function removeObjectsParser(xml: string): any[];
export declare function parseCopyObject(xml: string): CopyObjectResultV1;
export declare function parseListObjects(xml: string): {
objects: ObjectInfo[];
isTruncated?: boolean | undefined;
nextMarker?: string | undefined;
versionIdMarker?: string | undefined;
};
export declare function uploadPartParser(xml: string): any;
export {};
File diff suppressed because one or more lines are too long
+66
View File
@@ -0,0 +1,66 @@
// imported from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/93cfb0ec069731dcdfc31464788613f7cddb8192/types/minio/index.d.ts
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { LEGAL_HOLD_STATUS, RETENTION_MODES, RETENTION_VALIDITY_UNITS } from "./helpers.js";
import type { ClientOptions, NoResultCallback, RemoveOptions } from "./internal/client.js";
import { TypedClient } from "./internal/client.js";
import { CopyConditions } from "./internal/copy-conditions.js";
import { PostPolicy } from "./internal/post-policy.js";
import type { BucketItem, BucketItemCopy, BucketItemFromList, BucketItemStat, BucketItemWithMetadata, BucketStream, EmptyObject, ExistingObjectReplication, GetObjectLegalHoldOptions, IncompleteUploadedBucketItem, InputSerialization, IsoDate, ItemBucketMetadata, ItemBucketMetadataList, LegalHoldStatus, LifecycleConfig, LifecycleRule, MetadataItem, ObjectLockInfo, OutputSerialization, PutObjectLegalHoldOptions, ReplicaModifications, ReplicationConfig, ReplicationConfigOpts, ReplicationRule, ReplicationRuleAnd, ReplicationRuleDestination, ReplicationRuleFilter, ReplicationRuleStatus, ResultCallback, Retention, RetentionOptions, ScanRange, SelectOptions, SelectProgress, SourceSelectionCriteria, Tag } from "./internal/type.js";
import type { NotificationConfig, NotificationEvent, NotificationPoller } from "./notification.js";
export * from "./errors.js";
export * from "./helpers.js";
export type { Region } from "./internal/s3-endpoints.js";
export type * from "./notification.js";
export * from "./notification.js";
export { CopyConditions, PostPolicy };
export type { MakeBucketOpt } from "./internal/client.js";
export type { BucketItem, BucketItemCopy, BucketItemFromList, BucketItemStat, BucketItemWithMetadata, BucketStream, ClientOptions, EmptyObject, ExistingObjectReplication, GetObjectLegalHoldOptions, IncompleteUploadedBucketItem, InputSerialization, IsoDate, ItemBucketMetadata, ItemBucketMetadataList, LegalHoldStatus, LifecycleConfig, LifecycleRule, MetadataItem, NoResultCallback, ObjectLockInfo, OutputSerialization, PutObjectLegalHoldOptions, RemoveOptions, ReplicaModifications, ReplicationConfig, ReplicationConfigOpts, ReplicationRule, ReplicationRuleAnd, ReplicationRuleDestination, ReplicationRuleFilter, ReplicationRuleStatus, Retention, RetentionOptions, ScanRange, SelectOptions, SelectProgress, SourceSelectionCriteria, Tag };
/**
* @deprecated keep for backward compatible, use `RETENTION_MODES` instead
*/
export type Mode = RETENTION_MODES;
/**
* @deprecated keep for backward compatible
*/
export type LockUnit = RETENTION_VALIDITY_UNITS;
export type VersioningConfig = Record<string | number | symbol, unknown>;
export type TagList = Record<string, string>;
export interface PostPolicyResult {
postURL: string;
formData: {
[key: string]: any;
};
}
export interface LockConfig {
mode: RETENTION_MODES;
unit: RETENTION_VALIDITY_UNITS;
validity: number;
}
export interface LegalHoldOptions {
versionId: string;
status: LEGAL_HOLD_STATUS;
}
export interface SourceObjectStats {
size: number;
metaData: string;
lastModicied: Date;
versionId: string;
etag: string;
}
// Exports from library
export class Client extends TypedClient {
listObjectsV2(bucketName: string, prefix?: string, recursive?: boolean, startAfter?: string): BucketStream<BucketItem>;
// Bucket Policy & Notification operations
getBucketNotification(bucketName: string, callback: ResultCallback<NotificationConfig>): void;
getBucketNotification(bucketName: string): Promise<NotificationConfig>;
setBucketNotification(bucketName: string, bucketNotificationConfig: NotificationConfig, callback: NoResultCallback): void;
setBucketNotification(bucketName: string, bucketNotificationConfig: NotificationConfig): Promise<void>;
removeAllBucketNotification(bucketName: string, callback: NoResultCallback): void;
removeAllBucketNotification(bucketName: string): Promise<void>;
listenBucketNotification(bucketName: string, prefix: string, suffix: string, events: NotificationEvent[]): NotificationPoller;
}
File diff suppressed because one or more lines are too long
+58
View File
@@ -0,0 +1,58 @@
import { EventEmitter } from 'eventemitter3';
import type { TypedClient } from "./internal/client.js";
type Event = unknown;
export declare class TargetConfig {
private Filter?;
private Event?;
private Id;
setId(id: unknown): void;
addEvent(newevent: Event): void;
addFilterSuffix(suffix: string): void;
addFilterPrefix(prefix: string): void;
}
export declare class TopicConfig extends TargetConfig {
private Topic;
constructor(arn: string);
}
export declare class QueueConfig extends TargetConfig {
private Queue;
constructor(arn: string);
}
export declare class CloudFunctionConfig extends TargetConfig {
private CloudFunction;
constructor(arn: string);
}
export declare class NotificationConfig {
private TopicConfiguration?;
private CloudFunctionConfiguration?;
private QueueConfiguration?;
add(target: TargetConfig): void;
}
export declare const buildARN: (partition: string, service: string, region: string, accountId: string, resource: string) => string;
export declare const ObjectCreatedAll = "s3:ObjectCreated:*";
export declare const ObjectCreatedPut = "s3:ObjectCreated:Put";
export declare const ObjectCreatedPost = "s3:ObjectCreated:Post";
export declare const ObjectCreatedCopy = "s3:ObjectCreated:Copy";
export declare const ObjectCreatedCompleteMultipartUpload = "s3:ObjectCreated:CompleteMultipartUpload";
export declare const ObjectRemovedAll = "s3:ObjectRemoved:*";
export declare const ObjectRemovedDelete = "s3:ObjectRemoved:Delete";
export declare const ObjectRemovedDeleteMarkerCreated = "s3:ObjectRemoved:DeleteMarkerCreated";
export declare const ObjectReducedRedundancyLostObject = "s3:ReducedRedundancyLostObject";
export type NotificationEvent = 's3:ObjectCreated:*' | 's3:ObjectCreated:Put' | 's3:ObjectCreated:Post' | 's3:ObjectCreated:Copy' | 's3:ObjectCreated:CompleteMultipartUpload' | 's3:ObjectRemoved:*' | 's3:ObjectRemoved:Delete' | 's3:ObjectRemoved:DeleteMarkerCreated' | 's3:ReducedRedundancyLostObject' | 's3:TestEvent' | 's3:ObjectRestore:Post' | 's3:ObjectRestore:Completed' | 's3:Replication:OperationFailedReplication' | 's3:Replication:OperationMissedThreshold' | 's3:Replication:OperationReplicatedAfterThreshold' | 's3:Replication:OperationNotTracked' | string;
export type NotificationRecord = unknown;
export declare class NotificationPoller extends EventEmitter<{
notification: (event: NotificationRecord) => void;
error: (error: unknown) => void;
}> {
private client;
private bucketName;
private prefix;
private suffix;
private events;
private ending;
constructor(client: TypedClient, bucketName: string, prefix: string, suffix: string, events: NotificationEvent[]);
start(): void;
stop(): void;
checkForChanges(): void;
}
export {};
File diff suppressed because one or more lines are too long
+36
View File
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.promisify = promisify;
// Returns a wrapper function that will promisify a given callback function.
// It will preserve 'this'.
function promisify(fn) {
return function () {
// If the last argument is a function, assume its the callback.
let callback = arguments[arguments.length - 1];
// If the callback is given, don't promisify, just pass straight in.
if (typeof callback === 'function') {
return fn.apply(this, arguments);
}
// Otherwise, create a new set of arguments, and wrap
// it in a promise.
let args = [...arguments];
return new Promise((resolve, reject) => {
// Add the callback function.
args.push((err, value) => {
if (err) {
return reject(err);
}
resolve(value);
});
// Call the function with our special adaptor callback added.
fn.apply(this, args);
});
};
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJwcm9taXNpZnkiLCJmbiIsImNhbGxiYWNrIiwiYXJndW1lbnRzIiwibGVuZ3RoIiwiYXBwbHkiLCJhcmdzIiwiUHJvbWlzZSIsInJlc29sdmUiLCJyZWplY3QiLCJwdXNoIiwiZXJyIiwidmFsdWUiXSwic291cmNlcyI6WyJwcm9taXNpZnkuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gUmV0dXJucyBhIHdyYXBwZXIgZnVuY3Rpb24gdGhhdCB3aWxsIHByb21pc2lmeSBhIGdpdmVuIGNhbGxiYWNrIGZ1bmN0aW9uLlxuLy8gSXQgd2lsbCBwcmVzZXJ2ZSAndGhpcycuXG5leHBvcnQgZnVuY3Rpb24gcHJvbWlzaWZ5KGZuKSB7XG4gIH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FBRTtFQUM1QixPQUFPLFlBQVk7SUFDakI7SUFDQSxJQUFJQyxRQUFRLEdBQUdDLFNBQVMsQ0FBQ0EsU0FBUyxDQUFDQyxNQUFNLEdBQUcsQ0FBQyxDQUFDOztJQUU5QztJQUNBLElBQUksT0FBT0YsUUFBUSxLQUFLLFVBQVUsRUFBRTtNQUNsQyxPQUFPRCxFQUFFLENBQUNJLEtBQUssQ0FBQyxJQUFJLEVBQUVGLFNBQVMsQ0FBQztJQUNsQzs7SUFFQTtJQUNBO0lBQ0EsSUFBSUcsSUFBSSxHQUFHLENBQUMsR0FBR0gsU0FBUyxDQUFDO0lBRXpCLE9BQU8sSUFBSUksT0FBTyxDQUFDLENBQUNDLE9BQU8sRUFBRUMsTUFBTSxLQUFLO01BQ3RDO01BQ0FILElBQUksQ0FBQ0ksSUFBSSxDQUFDLENBQUNDLEdBQUcsRUFBRUMsS0FBSyxLQUFLO1FBQ3hCLElBQUlELEdBQUcsRUFBRTtVQUNQLE9BQU9GLE1BQU0sQ0FBQ0UsR0FBRyxDQUFDO1FBQ3BCO1FBRUFILE9BQU8sQ0FBQ0ksS0FBSyxDQUFDO01BQ2hCLENBQUMsQ0FBQzs7TUFFRjtNQUNBWCxFQUFFLENBQUNJLEtBQUssQ0FBQyxJQUFJLEVBQUVDLElBQUksQ0FBQztJQUN0QixDQUFDLENBQUM7RUFDSixDQUFDO0FBQ0gifQ==
+5
View File
@@ -0,0 +1,5 @@
import type { IRequest } from "./internal/type.js";
export declare function postPresignSignatureV4(region: string, date: Date, secretKey: string, policyBase64: string): string;
export declare function signV4(request: IRequest, accessKey: string, secretKey: string, region: string, requestDate: Date, sha256sum: string, serviceName?: string): string;
export declare function signV4ByServiceName(request: IRequest, accessKey: string, secretKey: string, region: string, requestDate: Date, contentSha256: string, serviceName?: string): string;
export declare function presignSignatureV4(request: IRequest, accessKey: string, secretKey: string, sessionToken: string | undefined, region: string, requestDate: Date, expires: number | undefined): string;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long