/// import * as http from 'http'; interface GetCredentialsResponse { client_email?: string; } export interface AuthClient { sign(blobToSign: string): Promise; getCredentials(): Promise; } export interface BucketI { name: string; } export interface FileI { name: string; } export interface Query { [key: string]: string; } export interface GetSignedUrlConfigInternal { expiration: number; accessibleAt?: Date; method: string; extensionHeaders?: http.OutgoingHttpHeaders; queryParams?: Query; cname?: string; contentMd5?: string; contentType?: string; bucket: string; file?: string; } export interface SignerGetSignedUrlConfig { method: 'GET' | 'PUT' | 'DELETE' | 'POST'; expires: string | number | Date; accessibleAt?: string | number | Date; virtualHostedStyle?: boolean; version?: 'v2' | 'v4'; cname?: string; extensionHeaders?: http.OutgoingHttpHeaders; queryParams?: Query; contentMd5?: string; contentType?: string; } export declare type SignerGetSignedUrlResponse = string; export declare type GetSignedUrlResponse = [SignerGetSignedUrlResponse]; export interface GetSignedUrlCallback { (err: Error | null, url?: string): void; } export declare enum SignerExceptionMessages { ACCESSIBLE_DATE_INVALID = "The accessible at date provided was invalid.", EXPIRATION_BEFORE_ACCESSIBLE_DATE = "An expiration date cannot be before accessible date.", X_GOOG_CONTENT_SHA256 = "The header X-Goog-Content-SHA256 must be a hexadecimal string." } /** * @const {string} * @private */ export declare const PATH_STYLED_HOST = "https://storage.googleapis.com"; export declare class URLSigner { private authClient; private bucket; private file?; constructor(authClient: AuthClient, bucket: BucketI, file?: FileI); getSignedUrl(cfg: SignerGetSignedUrlConfig): Promise; private getSignedUrlV2; private getSignedUrlV4; /** * Create canonical headers for signing v4 url. * * The canonical headers for v4-signing a request demands header names are * first lowercased, followed by sorting the header names. * Then, construct the canonical headers part of the request: * + ":" + Trim() + "\n" * .. * + ":" + Trim() + "\n" * * @param headers * @private */ getCanonicalHeaders(headers: http.OutgoingHttpHeaders): string; getCanonicalRequest(method: string, path: string, query: string, headers: string, signedHeaders: string, contentSha256?: string): string; getCanonicalQueryParams(query: Query): string; getResourcePath(cname: boolean, bucket: string, file?: string): string; parseExpires(expires: string | number | Date, current?: Date): number; parseAccessibleAt(accessibleAt?: string | number | Date): number; } /** * Custom error type for errors related to getting signed errors and policies. * * @private */ export declare class SigningError extends Error { name: string; } export {};