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AAU,OAVX,CACb,MAAM,EAAgB,GAAc,EACpC,QAAQ,yDAAyD,cACjE,MAAM,EAAoB,GAAiB,EAAI,GAAM,KAAK,UAAxC,UACZ,MAAM,EAEhB,CAOJ,CAIJ,CACJ,CACJ","file":"/npm/transloadit@4.7.4/dist/Transloadit.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/transloadit@4.7.4/dist/Transloadit.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import * as assert from 'node:assert';\nimport { randomUUID } from 'node:crypto';\nimport { constants, createReadStream } from 'node:fs';\nimport { access, stat } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { setTimeout as delay } from 'node:timers/promises';\nimport { getSignedSmartCdnUrl, signParamsSync } from '@transloadit/utils/node';\nimport debug from 'debug';\nimport FormData from 'form-data';\nimport got, { HTTPError, RequestError } from 'got';\nimport intoStream from 'into-stream';\nimport { isReadableStream, isStream } from 'is-stream';\nimport pMap from 'p-map';\nimport packageJson from '../package.json' with { type: 'json' };\nimport { ApiError } from \"./ApiError.js\";\nimport { assemblyIndexSchema, assemblyStatusSchema } from \"./alphalib/types/assemblyStatus.js\";\nimport { zodParseWithContext } from \"./alphalib/zodParseWithContext.js\";\nimport { mintBearerTokenWithCredentials } from \"./bearerToken.js\";\nimport InconsistentResponseError from \"./InconsistentResponseError.js\";\nimport { lintAssemblyInstructions as lintAssemblyInstructionsInternal } from \"./lintAssemblyInstructions.js\";\nimport PaginationStream from \"./PaginationStream.js\";\nimport PollingTimeoutError from \"./PollingTimeoutError.js\";\nimport { sendTusRequest } from \"./tus.js\";\n// See https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#errors\n// Expose relevant errors\nexport { HTTPError, MaxRedirectsError, ParseError, ReadError, RequestError, TimeoutError, UploadError, } from 'got';\nexport * from \"./apiTypes.js\";\nexport { InconsistentResponseError, ApiError };\nexport { extractFieldNamesFromTemplate } from \"./alphalib/stepParsing.js\";\n// Builtin templates replace the legacy golden template helpers.\nexport { mergeTemplateContent } from \"./alphalib/templateMerge.js\";\nexport { prepareInputFiles } from \"./inputFiles.js\";\nexport { getRobotHelp, isKnownRobot, listRobots } from \"./robots.js\";\nconst log = debug('transloadit');\nconst logWarn = debug('transloadit:warn');\nconst { version } = packageJson;\nconst getUploadKey = (fieldname, filename, size) => {\n    if (!fieldname || !filename || size == null)\n        return null;\n    return JSON.stringify([fieldname, filename, size]);\n};\nconst getSizeFromValue = (value) => {\n    if (typeof value === 'string')\n        return Buffer.byteLength(value);\n    if (Buffer.isBuffer(value))\n        return value.length;\n    if (value instanceof ArrayBuffer)\n        return value.byteLength;\n    if (ArrayBuffer.isView(value))\n        return value.byteLength;\n    return undefined;\n};\nconst toReadableUpload = (label, value) => {\n    const readable = isReadableStream(value);\n    if (!readable && isStream(value)) {\n        throw new Error(`Upload named \"${label}\" is not a Readable stream`);\n    }\n    return readable ? value : intoStream(value);\n};\nconst buildStreamsMap = (descriptors) => Object.fromEntries(descriptors.map((descriptor) => {\n    if (descriptor.path) {\n        const stream = createReadStream(descriptor.path);\n        return [descriptor.label, { stream, path: descriptor.path }];\n    }\n    const value = descriptor.value;\n    if (value == null) {\n        throw new Error(`Upload named \"${descriptor.label}\" has no data`);\n    }\n    const stream = toReadableUpload(descriptor.label, value);\n    return [descriptor.label, { stream }];\n}));\nconst pauseStreams = (streamsMap) => {\n    for (const { stream } of Object.values(streamsMap)) {\n        stream.pause();\n    }\n};\nconst createStreamErrorPromise = (streamsMap) => {\n    const promise = new Promise((_resolve, reject) => {\n        for (const { stream } of Object.values(streamsMap)) {\n            stream.on('error', reject);\n        }\n    });\n    promise.catch(() => { });\n    return promise;\n};\n// Not sure if this is still a problem with the API, but throw a special error type so the user can retry if needed\nfunction checkAssemblyUrls(result) {\n    if (result.assembly_url == null || result.assembly_ssl_url == null) {\n        throw new InconsistentResponseError('Server returned an incomplete assembly response (no URL)');\n    }\n}\nfunction getHrTimeMs() {\n    return Number(process.hrtime.bigint() / 1000000n);\n}\nfunction getAssemblyIdFromUrl(assemblyUrl) {\n    const match = assemblyUrl.match(/\\/assemblies\\/([^/?#]+)/);\n    if (!match) {\n        throw new Error(`Invalid assembly URL: ${assemblyUrl}`);\n    }\n    return match[1] ?? '';\n}\nfunction checkResult(result) {\n    // In case server returned a successful HTTP status code, but an `error` in the JSON object\n    // This happens sometimes, for example when createAssembly with an invalid file (IMPORT_FILE_ERROR)\n    if (typeof result === 'object' &&\n        result !== null &&\n        'error' in result &&\n        typeof result.error === 'string') {\n        throw new ApiError({ body: result }); // in this case there is no `cause` because we don't have an HTTPError\n    }\n}\nexport class Transloadit {\n    _authKey;\n    _authSecret;\n    _authToken;\n    _endpoint;\n    _maxRetries;\n    _defaultTimeout;\n    _gotRetry;\n    _clientName;\n    _lastUsedAssemblyUrl = '';\n    _validateResponses = false;\n    constructor(opts) {\n        const rawToken = typeof opts?.authToken === 'string' ? opts.authToken.trim() : '';\n        const hasToken = rawToken.length > 0;\n        if (opts.endpoint?.endsWith('/')) {\n            throw new Error('Trailing slash in endpoint is not allowed');\n        }\n        if (!hasToken) {\n            if (opts?.authKey == null) {\n                throw new Error('Please provide an authKey');\n            }\n            if (opts.authSecret == null) {\n                throw new Error('Please provide an authSecret');\n            }\n        }\n        this._authKey = opts.authKey ?? '';\n        this._authSecret = opts.authSecret ?? '';\n        this._authToken = hasToken ? rawToken : null;\n        this._endpoint = opts.endpoint || 'https://api2.transloadit.com';\n        this._maxRetries = opts.maxRetries != null ? opts.maxRetries : 5;\n        this._defaultTimeout = opts.timeout != null ? opts.timeout : 60000;\n        this._clientName = opts.clientName?.trim() || `node-sdk:${version}`;\n        // Passed on to got https://github.com/sindresorhus/got/blob/main/documentation/7-retry.md\n        this._gotRetry = opts.gotRetry != null ? opts.gotRetry : { limit: 0 };\n        if (opts.validateResponses != null)\n            this._validateResponses = opts.validateResponses;\n    }\n    getLastUsedAssemblyUrl() {\n        return this._lastUsedAssemblyUrl;\n    }\n    setDefaultTimeout(timeout) {\n        this._defaultTimeout = timeout;\n    }\n    /**\n     * Create an Assembly\n     *\n     * @param opts assembly options\n     */\n    createAssembly(opts = {}) {\n        const { params = {}, waitForCompletion = false, chunkSize: requestedChunkSize = Number.POSITIVE_INFINITY, uploadConcurrency = 10, timeout = 24 * 60 * 60 * 1000, // 1 day\n        onUploadProgress = () => { }, onAssemblyProgress = () => { }, files = {}, uploads = {}, assemblyId, expectedUploads, signal, uploadBehavior = 'await', } = opts;\n        // Keep track of how long the request took\n        const startTimeMs = getHrTimeMs();\n        // Undocumented feature to allow specifying a custom assembly id from the client\n        // Not recommended for general use due to security. E.g if the user doesn't provide a cryptographically\n        // secure ID, then anyone could access the assembly.\n        let effectiveAssemblyId;\n        if (assemblyId != null) {\n            effectiveAssemblyId = assemblyId;\n        }\n        else {\n            effectiveAssemblyId = randomUUID().replace(/-/g, '');\n        }\n        const urlSuffix = `/assemblies/${effectiveAssemblyId}`;\n        // We want to be able to return the promise immediately with custom data\n        const promise = (async () => {\n            this._lastUsedAssemblyUrl = `${this._endpoint}${urlSuffix}`;\n            await pMap(Object.entries(files), async ([, path]) => access(path, constants.F_OK | constants.R_OK), { concurrency: 5 });\n            const descriptors = [\n                ...Object.entries(files).map(([label, path]) => ({\n                    label,\n                    path,\n                    filename: basename(path),\n                })),\n                ...Object.entries(uploads).map(([label, value]) => ({\n                    label,\n                    filename: label,\n                    value,\n                })),\n            ];\n            const allStreamsMap = buildStreamsMap(descriptors);\n            const allStreams = Object.values(allStreamsMap);\n            // Pause all streams\n            pauseStreams(allStreamsMap);\n            // If any stream emits error, we want to handle this and exit with error.\n            // This promise races against createAssemblyAndUpload() below via Promise.race().\n            // When createAssemblyAndUpload wins the race, this promise becomes \"orphaned\" -\n            // it's no longer awaited, but stream error handlers remain attached.\n            // The no-op catch prevents Node's unhandled rejection warning if a stream\n            // errors after the race is already won.\n            const streamErrorPromise = createStreamErrorPromise(allStreamsMap);\n            const createAssemblyAndUpload = async () => {\n                const totalExpectedUploads = expectedUploads == null ? allStreams.length : Math.max(expectedUploads, allStreams.length);\n                const result = await this._remoteJson({\n                    urlSuffix,\n                    method: 'post',\n                    timeout: { request: timeout },\n                    params,\n                    fields: {\n                        tus_num_expected_upload_files: totalExpectedUploads,\n                    },\n                    signal,\n                });\n                checkResult(result);\n                if (Object.keys(allStreamsMap).length > 0) {\n                    const { uploadUrls } = await sendTusRequest({\n                        streamsMap: allStreamsMap,\n                        assembly: result,\n                        onProgress: onUploadProgress,\n                        requestedChunkSize,\n                        uploadConcurrency,\n                        signal,\n                        uploadBehavior,\n                    });\n                    if (uploadBehavior !== 'await' && Object.keys(uploadUrls).length > 0) {\n                        result.upload_urls = uploadUrls;\n                    }\n                }\n                const shouldWaitForCompletion = waitForCompletion && uploadBehavior === 'await';\n                if (!shouldWaitForCompletion)\n                    return result;\n                if (result.assembly_id == null) {\n                    throw new InconsistentResponseError('Server returned an assembly response without an assembly_id after creation');\n                }\n                const awaitResult = await this.awaitAssemblyCompletion(result.assembly_id, {\n                    timeout,\n                    onAssemblyProgress,\n                    startTimeMs,\n                    signal,\n                });\n                checkResult(awaitResult);\n                return awaitResult;\n            };\n            return Promise.race([createAssemblyAndUpload(), streamErrorPromise]);\n        })();\n        // This allows the user to use or log the assemblyId even before it has been created for easier debugging\n        return Object.assign(promise, { assemblyId: effectiveAssemblyId });\n    }\n    /**\n     * Lint Assembly Instructions locally.\n     *\n     * If a templateId is provided, the template content is merged with the instructions,\n     * just like the API. When a template sets `allow_steps_override=false`, providing\n     * `steps` will throw a TEMPLATE_DENIES_STEPS_OVERRIDE error.\n     *\n     * The `assemblyInstructions` input may be a JSON string, a full instructions object,\n     * or a steps-only object (missing the `steps` property).\n     */\n    async lintAssemblyInstructions(options) {\n        const { templateId, ...rest } = options;\n        if (!templateId) {\n            return await lintAssemblyInstructionsInternal(rest);\n        }\n        const template = await this.getTemplate(templateId);\n        return await lintAssemblyInstructionsInternal({\n            ...rest,\n            template: template.content,\n        });\n    }\n    /**\n     * Mint a short-lived bearer token via POST /token.\n     *\n     * This uses HTTP Basic Auth (authKey + authSecret) and can optionally request a narrowed scope.\n     * If `scope` is omitted, the token inherits the auth key's scope.\n     */\n    async mintBearerToken(options = {}) {\n        if (this._authToken) {\n            throw new Error('Cannot mint bearer tokens when using authToken authentication. Provide authKey + authSecret instead.');\n        }\n        const result = await mintBearerTokenWithCredentials({ authKey: this._authKey, authSecret: this._authSecret }, {\n            ...options,\n            endpoint: options.endpoint ?? this._endpoint,\n        });\n        if (!result.ok) {\n            throw new Error(result.error);\n        }\n        return result.data;\n    }\n    async resumeAssemblyUploads(opts) {\n        const { assemblyUrl, files = {}, uploads = {}, chunkSize: requestedChunkSize = Number.POSITIVE_INFINITY, uploadConcurrency = 10, timeout = 24 * 60 * 60 * 1000, // 1 day\n        waitForCompletion = false, onUploadProgress = () => { }, onAssemblyProgress = () => { }, signal, uploadBehavior = 'await', } = opts;\n        const startTimeMs = getHrTimeMs();\n        getAssemblyIdFromUrl(assemblyUrl);\n        const assembly = await this._fetchAssemblyStatus({\n            url: assemblyUrl,\n            signal,\n        });\n        const statusUrl = assembly.assembly_ssl_url ?? assembly.assembly_url ?? assemblyUrl;\n        const finishedKeys = new Set();\n        for (const upload of assembly.uploads ?? []) {\n            const key = getUploadKey(upload.field ?? null, upload.basename ?? null, upload.size);\n            if (key)\n                finishedKeys.add(key);\n        }\n        for (const upload of assembly.tus_uploads ?? []) {\n            if (!upload.finished)\n                continue;\n            const key = getUploadKey(upload.fieldname, upload.filename, upload.size);\n            if (key)\n                finishedKeys.add(key);\n        }\n        const resumeUrls = new Map();\n        for (const upload of assembly.tus_uploads ?? []) {\n            if (upload.finished)\n                continue;\n            if (!upload.upload_url)\n                continue;\n            const key = getUploadKey(upload.fieldname, upload.filename, upload.size);\n            if (key)\n                resumeUrls.set(key, upload.upload_url);\n        }\n        const descriptors = [];\n        await pMap(Object.entries(files), async ([label, path]) => {\n            await access(path, constants.F_OK | constants.R_OK);\n            const info = await stat(path);\n            descriptors.push({\n                label,\n                path,\n                filename: basename(path),\n                size: info.size,\n            });\n        }, { concurrency: 5 });\n        for (const [label, value] of Object.entries(uploads)) {\n            descriptors.push({\n                label,\n                filename: label,\n                size: isReadableStream(value) ? undefined : getSizeFromValue(value),\n                value,\n            });\n        }\n        const descriptorsToUpload = descriptors.filter((descriptor) => {\n            const key = getUploadKey(descriptor.label, descriptor.filename, descriptor.size ?? null);\n            return key ? !finishedKeys.has(key) : true;\n        });\n        const uploadUrlsByLabel = {};\n        for (const descriptor of descriptorsToUpload) {\n            if (!descriptor.path)\n                continue;\n            const key = getUploadKey(descriptor.label, descriptor.filename, descriptor.size ?? null);\n            if (!key)\n                continue;\n            const uploadUrl = resumeUrls.get(key);\n            if (uploadUrl)\n                uploadUrlsByLabel[descriptor.label] = uploadUrl;\n        }\n        const streamsMap = buildStreamsMap(descriptorsToUpload);\n        pauseStreams(streamsMap);\n        if (Object.keys(streamsMap).length > 0) {\n            const streamErrorPromise = createStreamErrorPromise(streamsMap);\n            const uploadPromise = sendTusRequest({\n                streamsMap,\n                assembly,\n                requestedChunkSize,\n                uploadConcurrency,\n                onProgress: onUploadProgress,\n                signal,\n                uploadUrls: uploadUrlsByLabel,\n                uploadBehavior,\n            });\n            await Promise.race([uploadPromise, streamErrorPromise]);\n            const { uploadUrls } = await uploadPromise;\n            if (uploadBehavior !== 'await' && Object.keys(uploadUrls).length > 0) {\n                assembly.upload_urls = uploadUrls;\n            }\n        }\n        const latestAssembly = await this._fetchAssemblyStatus({\n            url: statusUrl,\n            signal,\n        });\n        if (uploadBehavior !== 'await' && assembly.upload_urls) {\n            latestAssembly.upload_urls = assembly.upload_urls;\n        }\n        const shouldWaitForCompletion = waitForCompletion && uploadBehavior === 'await';\n        if (!shouldWaitForCompletion)\n            return latestAssembly;\n        if (latestAssembly.assembly_id == null) {\n            throw new InconsistentResponseError('Server returned an assembly response without an assembly_id after resuming uploads');\n        }\n        const awaitResult = await this.awaitAssemblyCompletion(latestAssembly.assembly_id, {\n            timeout,\n            onAssemblyProgress,\n            startTimeMs,\n            assemblyUrl: statusUrl,\n            signal,\n        });\n        checkResult(awaitResult);\n        return awaitResult;\n    }\n    async awaitAssemblyCompletion(assemblyId, { onAssemblyProgress = () => { }, timeout, startTimeMs = getHrTimeMs(), interval = 1000, assemblyUrl, signal, onPoll, } = {}) {\n        assert.ok(assemblyId);\n        let lastResult;\n        const fetchAssemblyStatus = () => {\n            return assemblyUrl\n                ? this._fetchAssemblyStatus({ url: assemblyUrl, signal })\n                : this.getAssembly(assemblyId, { signal });\n        };\n        while (true) {\n            // Check if caller wants to stop polling early\n            if (onPoll?.() === false && lastResult) {\n                return lastResult;\n            }\n            // Check if aborted before making the request\n            if (signal?.aborted) {\n                throw signal.reason ?? new DOMException('Aborted', 'AbortError');\n            }\n            const result = await fetchAssemblyStatus();\n            lastResult = result;\n            // If 'ok' is not in result, it implies a terminal state (e.g., error, completed, canceled).\n            // If 'ok' is present, then we check if it's one of the non-terminal polling states.\n            if (!('ok' in result) ||\n                (result.ok !== 'ASSEMBLY_UPLOADING' &&\n                    result.ok !== 'ASSEMBLY_EXECUTING' &&\n                    // ASSEMBLY_REPLAYING is not a valid 'ok' status for polling, it means it's done replaying.\n                    // The API does not seem to have an ASSEMBLY_REPLAYING status in the typical polling loop.\n                    // It's usually a final status from the replay endpoint.\n                    // For polling, we only care about UPLOADING and EXECUTING.\n                    // If a replay operation puts it into a pollable state, that state would be EXECUTING.\n                    result.ok !== 'ASSEMBLY_REPLAYING') // This line might need review based on actual API behavior for replayed assembly polling\n            ) {\n                return result; // Done!\n            }\n            try {\n                onAssemblyProgress(result);\n            }\n            catch (err) {\n                log('Caught onAssemblyProgress error', err);\n            }\n            const nowMs = getHrTimeMs();\n            if (timeout != null && nowMs - startTimeMs >= timeout) {\n                throw new PollingTimeoutError('Polling timed out');\n            }\n            // Make the sleep abortable, ensuring listener cleanup to prevent memory leaks\n            await new Promise((resolve, reject) => {\n                const timeoutId = setTimeout(() => {\n                    signal?.removeEventListener('abort', onAbort);\n                    resolve();\n                }, interval);\n                function onAbort() {\n                    clearTimeout(timeoutId);\n                    reject(signal?.reason ?? new DOMException('Aborted', 'AbortError'));\n                }\n                signal?.addEventListener('abort', onAbort, { once: true });\n            });\n        }\n    }\n    maybeThrowInconsistentResponseError(message) {\n        const err = new InconsistentResponseError(message);\n        // @TODO, once our schemas have matured, we should remove the option and always throw the error here.\n        // But as it stands, schemas are new, and we can't easily update all customer's node-sdks,\n        // so there will be a long tail of throws if we enable this now.\n        if (this._validateResponses) {\n            throw err;\n        }\n        console.error(`---\\nPlease report this error to Transloadit (support@transloadit.com). We are working on better schemas for our API and this looks like something we do not cover yet: \\n\\n${err}\\nThank you in advance!\\n---\\n`);\n    }\n    /**\n     * Cancel the assembly\n     *\n     * @param assemblyId assembly ID\n     * @returns after the assembly is deleted\n     */\n    async cancelAssembly(assemblyId) {\n        const { assembly_ssl_url: url } = await this.getAssembly(assemblyId);\n        const rawResult = await this._remoteJson({\n            url,\n            isTrustedUrl: true,\n            method: 'delete',\n        });\n        const parsedResult = zodParseWithContext(assemblyStatusSchema, rawResult);\n        if (!parsedResult.success) {\n            this.maybeThrowInconsistentResponseError(`The API responded with data that does not match the expected schema while cancelling Assembly: ${assemblyId}.\\n${parsedResult.humanReadable}`);\n        }\n        checkAssemblyUrls(rawResult);\n        return rawResult;\n    }\n    /**\n     * Replay an Assembly\n     *\n     * @param assemblyId of the assembly to replay\n     * @param optional params\n     * @returns after the replay is started\n     */\n    async replayAssembly(assemblyId, params = {}) {\n        const result = await this._remoteJson({\n            urlSuffix: `/assemblies/${assemblyId}/replay`,\n            method: 'post',\n            ...(Object.keys(params).length > 0 && { params }),\n        });\n        checkResult(result);\n        return result;\n    }\n    /**\n     * Replay an Assembly notification\n     *\n     * @param assemblyId of the assembly whose notification to replay\n     * @param optional params\n     * @returns after the replay is started\n     */\n    async replayAssemblyNotification(assemblyId, params = {}) {\n        return await this._remoteJson({\n            urlSuffix: `/assembly_notifications/${assemblyId}/replay`,\n            method: 'post',\n            ...(Object.keys(params).length > 0 && { params }),\n        });\n    }\n    /**\n     * List all assemblies\n     *\n     * @param params optional request options\n     * @returns list of Assemblies\n     */\n    async listAssemblies(params) {\n        const rawResponse = await this._remoteJson({\n            urlSuffix: '/assemblies',\n            method: 'get',\n            params: params || {},\n        });\n        if (rawResponse == null ||\n            typeof rawResponse !== 'object' ||\n            !Array.isArray(rawResponse.items)) {\n            throw new InconsistentResponseError('API response for listAssemblies is malformed or missing items array');\n        }\n        const parsedResult = zodParseWithContext(assemblyIndexSchema, rawResponse.items);\n        if (!parsedResult.success) {\n            this.maybeThrowInconsistentResponseError(`API response for listAssemblies contained items that do not match the expected schema.\\n${parsedResult.humanReadable}`);\n        }\n        return {\n            items: rawResponse.items,\n            count: rawResponse.count,\n        };\n    }\n    streamAssemblies(params) {\n        return new PaginationStream(async (page) => this.listAssemblies({ ...params, page }));\n    }\n    /**\n     * Get an Assembly\n     *\n     * @param assemblyId the Assembly Id\n     * @param options optional request options\n     * @returns the retrieved Assembly\n     */\n    async getAssembly(assemblyId, options) {\n        return await this._fetchAssemblyStatus({\n            assemblyId,\n            signal: options?.signal,\n        });\n    }\n    async _fetchAssemblyStatus({ assemblyId, url, signal, }) {\n        const rawResult = await this._remoteJson({\n            url,\n            urlSuffix: url ? undefined : `/assemblies/${assemblyId}`,\n            isTrustedUrl: Boolean(url),\n            signal,\n        });\n        const parsedResult = zodParseWithContext(assemblyStatusSchema, rawResult);\n        if (!parsedResult.success) {\n            const label = assemblyId ?? url ?? 'unknown';\n            this.maybeThrowInconsistentResponseError(`The API responded with data that does not match the expected schema while getting Assembly: ${label}.\\n${parsedResult.humanReadable}`);\n        }\n        checkAssemblyUrls(rawResult);\n        return rawResult;\n    }\n    /**\n     * Create a Credential\n     *\n     * @param params optional request options\n     * @returns when the Credential is created\n     */\n    async createTemplateCredential(params) {\n        return await this._remoteJson({\n            urlSuffix: '/template_credentials',\n            method: 'post',\n            params: params || {},\n        });\n    }\n    /**\n     * Edit a Credential\n     *\n     * @param credentialId the Credential ID\n     * @param params optional request options\n     * @returns when the Credential is edited\n     */\n    async editTemplateCredential(credentialId, params) {\n        return await this._remoteJson({\n            urlSuffix: `/template_credentials/${credentialId}`,\n            method: 'put',\n            params: params || {},\n        });\n    }\n    /**\n     * Delete a Credential\n     *\n     * @param credentialId the Credential ID\n     * @returns when the Credential is deleted\n     */\n    async deleteTemplateCredential(credentialId) {\n        return await this._remoteJson({\n            urlSuffix: `/template_credentials/${credentialId}`,\n            method: 'delete',\n        });\n    }\n    /**\n     * Get a Credential\n     *\n     * @param credentialId the Credential ID\n     * @returns when the Credential is retrieved\n     */\n    async getTemplateCredential(credentialId) {\n        return await this._remoteJson({\n            urlSuffix: `/template_credentials/${credentialId}`,\n            method: 'get',\n        });\n    }\n    /**\n     * List all TemplateCredentials\n     *\n     * @param params optional request options\n     * @returns the list of templates\n     */\n    async listTemplateCredentials(params) {\n        return await this._remoteJson({\n            urlSuffix: '/template_credentials',\n            method: 'get',\n            params: params || {},\n        });\n    }\n    streamTemplateCredentials(params) {\n        return new PaginationStream(async (page) => ({\n            items: (await this.listTemplateCredentials({ ...params, page })).credentials,\n        }));\n    }\n    /**\n     * Create an Assembly Template\n     *\n     * @param params optional request options\n     * @returns when the template is created\n     */\n    async createTemplate(params) {\n        return await this._remoteJson({\n            urlSuffix: '/templates',\n            method: 'post',\n            params: params || {},\n        });\n    }\n    /**\n     * Edit an Assembly Template\n     *\n     * @param templateId the template ID\n     * @param params optional request options\n     * @returns when the template is edited\n     */\n    async editTemplate(templateId, params) {\n        return await this._remoteJson({\n            urlSuffix: `/templates/${templateId}`,\n            method: 'put',\n            params: params || {},\n        });\n    }\n    /**\n     * Delete an Assembly Template\n     *\n     * @param templateId the template ID\n     * @returns when the template is deleted\n     */\n    async deleteTemplate(templateId) {\n        return await this._remoteJson({\n            urlSuffix: `/templates/${templateId}`,\n            method: 'delete',\n        });\n    }\n    /**\n     * Get an Assembly Template\n     *\n     * @param templateId the template ID\n     * @returns when the template is retrieved\n     */\n    async getTemplate(templateId) {\n        return await this._remoteJson({\n            urlSuffix: `/templates/${templateId}`,\n            method: 'get',\n        });\n    }\n    /**\n     * List all Assembly Templates\n     *\n     * @param params optional request options\n     * @returns the list of templates\n     */\n    async listTemplates(params) {\n        return await this._remoteJson({\n            urlSuffix: '/templates',\n            method: 'get',\n            params: params || {},\n        });\n    }\n    streamTemplates(params) {\n        return new PaginationStream(async (page) => this.listTemplates({ ...params, page }));\n    }\n    /**\n     * Get account Billing details for a specific month\n     *\n     * @param month the date for the required billing in the format yyyy-mm\n     * @returns with billing data\n     * @see https://transloadit.com/docs/api/bill-date-get/\n     */\n    async getBill(month) {\n        assert.ok(month, 'month is required');\n        return await this._remoteJson({\n            urlSuffix: `/bill/${month}`,\n            method: 'get',\n        });\n    }\n    calcSignature(params, algorithm) {\n        if (!this._authKey || !this._authSecret) {\n            throw new Error('Cannot sign params without authKey and authSecret.');\n        }\n        const jsonParams = this._prepareParams(params);\n        const signature = this._calcSignature(jsonParams, algorithm);\n        return { signature, params: jsonParams };\n    }\n    /**\n     * Construct a signed Smart CDN URL. See https://transloadit.com/docs/topics/signature-authentication/#smart-cdn.\n     */\n    getSignedSmartCDNUrl(opts) {\n        if (!this._authKey || !this._authSecret) {\n            throw new Error('authKey and authSecret are required to sign Smart CDN URLs.');\n        }\n        return getSignedSmartCdnUrl({\n            ...opts,\n            authKey: this._authKey,\n            authSecret: this._authSecret,\n        });\n    }\n    _calcSignature(toSign, algorithm = 'sha384') {\n        if (!this._authSecret) {\n            throw new Error('Cannot sign params without authSecret.');\n        }\n        return signParamsSync(toSign, this._authSecret, algorithm);\n    }\n    // Sets the multipart/form-data for POST, PUT and DELETE requests, including\n    // the streams, the signed params, and any additional fields.\n    _appendForm(form, params, fields) {\n        const shouldSign = Boolean(this._authKey && this._authSecret);\n        let jsonParams = JSON.stringify(params ?? {});\n        let signature;\n        if (shouldSign) {\n            const sigData = this.calcSignature(params);\n            jsonParams = sigData.params;\n            signature = sigData.signature;\n        }\n        form.append('params', jsonParams);\n        if (fields != null) {\n            for (const [key, val] of Object.entries(fields)) {\n                form.append(key, val);\n            }\n        }\n        if (signature) {\n            form.append('signature', signature);\n        }\n    }\n    // Implements HTTP GET query params, handling the case where the url already\n    // has params.\n    _appendParamsToUrl(url, params) {\n        const prefix = url.indexOf('?') === -1 ? '?' : '&';\n        const shouldSign = Boolean(this._authKey && this._authSecret);\n        if (!shouldSign) {\n            const jsonParams = JSON.stringify(params ?? {});\n            return `${url}${prefix}params=${encodeURIComponent(jsonParams)}`;\n        }\n        const { signature, params: jsonParams } = this.calcSignature(params);\n        return `${url}${prefix}signature=${signature}&params=${encodeURIComponent(jsonParams)}`;\n    }\n    // Responsible for including auth parameters in all requests\n    _prepareParams(paramsIn) {\n        let params = paramsIn;\n        if (params == null) {\n            params = {};\n        }\n        if (params.auth == null) {\n            params.auth = {};\n        }\n        if (params.auth.key == null) {\n            params.auth.key = this._authKey;\n        }\n        if (params.auth.expires == null) {\n            params.auth.expires = this._getExpiresDate();\n        }\n        return JSON.stringify(params);\n    }\n    // We want to mock this method\n    _getExpiresDate() {\n        const expiresDate = new Date();\n        expiresDate.setDate(expiresDate.getDate() + 1);\n        return expiresDate.toISOString();\n    }\n    // Responsible for making API calls. Automatically sends streams with any POST,\n    // PUT or DELETE requests. Automatically adds signature parameters to all\n    // requests. Also automatically parses the JSON response.\n    async _remoteJson(opts) {\n        const { urlSuffix, url: urlInput, isTrustedUrl = false, timeout = { request: this._defaultTimeout }, method = 'get', params = {}, fields, headers, signal, } = opts;\n        // Allow providing either a `urlSuffix` or a full `url`\n        if (!urlSuffix && !urlInput)\n            throw new Error('No URL provided');\n        let url = urlInput || `${this._endpoint}${urlSuffix}`;\n        if (urlInput && !isTrustedUrl) {\n            const allowed = new URL(this._endpoint);\n            const candidate = new URL(urlInput);\n            if (allowed.origin !== candidate.origin) {\n                throw new Error(`Untrusted URL: ${candidate.origin}`);\n            }\n        }\n        if (method === 'get') {\n            url = this._appendParamsToUrl(url, params);\n        }\n        log('Sending request', method, url);\n        // todo use got.retry instead because we are no longer using FormData (which is a stream and can only be used once)\n        // https://github.com/sindresorhus/got/issues/1282\n        for (let retryCount = 0;; retryCount++) {\n            let form;\n            if (method === 'post' || method === 'put' || method === 'delete') {\n                form = new FormData();\n                this._appendForm(form, params, fields);\n            }\n            const requestOpts = {\n                retry: this._gotRetry,\n                body: form,\n                timeout,\n                headers: {\n                    'Transloadit-Client': this._clientName,\n                    'User-Agent': undefined, // Remove got's user-agent\n                    ...(this._authToken ? { Authorization: `Bearer ${this._authToken}` } : {}),\n                    ...headers,\n                },\n                responseType: 'json',\n                signal,\n            };\n            try {\n                const request = got[method](url, requestOpts);\n                const { body } = await request;\n                // console.log(body)\n                return body;\n            }\n            catch (err) {\n                if (!(err instanceof RequestError))\n                    throw err;\n                if (err instanceof HTTPError) {\n                    const { statusCode, body } = err.response;\n                    logWarn('HTTP error', statusCode, body);\n                    // check whether we should retry\n                    // https://transloadit.com/blog/2012/04/introducing-rate-limiting/\n                    const retryAfterHeader = err.response?.headers?.['retry-after'];\n                    const retryAfterSeconds = typeof retryAfterHeader === 'string' ? Number(retryAfterHeader) : undefined;\n                    const retryInFromInfo = typeof body === 'object' &&\n                        body != null &&\n                        'info' in body &&\n                        typeof body.info === 'object' &&\n                        body.info != null &&\n                        'retryIn' in body.info &&\n                        typeof body.info.retryIn === 'number' &&\n                        body.info.retryIn > 0\n                        ? body.info.retryIn\n                        : undefined;\n                    const retryInSec = retryInFromInfo ??\n                        (typeof retryAfterSeconds === 'number' && retryAfterSeconds > 0\n                            ? retryAfterSeconds\n                            : undefined);\n                    const shouldRetry = retryCount < this._maxRetries && // 413 taken from https://transloadit.com/blog/2012/04/introducing-rate-limiting/\n                        // todo can 413 be removed?\n                        ((statusCode === 413 &&\n                            body &&\n                            typeof body === 'object' &&\n                            body.error === 'RATE_LIMIT_REACHED') ||\n                            statusCode === 429);\n                    if (shouldRetry) {\n                        const retryDelaySec = retryInSec ?? 1;\n                        logWarn(`Rate limit reached, retrying request in approximately ${retryDelaySec} seconds.`);\n                        const retryInMs = 1000 * (retryDelaySec * (1 + 0.1 * Math.random()));\n                        await delay(retryInMs);\n                        // Retry\n                    }\n                    else {\n                        throw new ApiError({\n                            cause: err,\n                            body: err.response?.body,\n                        }); // todo don't assert type\n                    }\n                }\n                else {\n                    throw err;\n                }\n            }\n        }\n    }\n}\n"]}