@rushstack/rush-http-build-cache-plugin 5.159.0 → 5.160.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"HttpBuildCacheProvider.d.ts","sourceRoot":"","sources":["../src/HttpBuildCacheProvider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,KAAK,wBAAwB,EAG7B,KAAK,WAAW,EAEjB,MAAM,qBAAqB,CAAC;AAkB7B,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,2BAA2B,CAAC;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAKD,qBAAa,sBAAuB,YAAW,wBAAwB;IACrE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAqB;IAC5D,OAAO,CAAC,QAAQ,CAAC,mCAAmC,CAAU;IAC9D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;IAC3B,OAAO,CAAC,QAAQ,CAA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UAAU,EAAE,CAAC,CAAC;gBAClF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;gBACtB,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACvF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;gBAChC,MAAM,IAAI,KAAK,CACb;oBACE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,mBAAmB,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,GAAG;oBAC9E,mDAAmD;oBACnD,6FAA6F;oBAC7F,EAAE;oBACF,4BAA4B;oBAC5B,EAAE;oBACF,iDAAiD;oBACjD,EAAE;iBACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArYD,wDAqYC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Executable, Async } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport {\n type ICloudBuildCacheProvider,\n type ICredentialCacheEntry,\n CredentialCache,\n type RushSession,\n EnvironmentConfiguration\n} from '@rushstack/rush-sdk';\nimport { WebClient, type IWebClientResponse } from '@rushstack/rush-sdk/lib/utilities/WebClient';\nimport type { SpawnSyncReturns } from 'child_process';\n\nenum CredentialsOptions {\n Optional,\n Required,\n Omit\n}\n\nenum FailureType {\n None,\n Informational,\n Warning,\n Error,\n Authentication\n}\n\nexport interface IHttpBuildCacheTokenHandler {\n exec: string;\n args?: string[];\n}\n\n/**\n * @public\n */\nexport type UploadMethod = 'PUT' | 'POST' | 'PATCH';\n\n/**\n * @public\n */\nexport interface IHttpBuildCacheProviderOptions {\n url: string;\n tokenHandler?: IHttpBuildCacheTokenHandler;\n uploadMethod?: UploadMethod;\n minHttpRetryDelayMs?: number;\n headers?: Record<string, string>;\n cacheKeyPrefix?: string;\n isCacheWriteAllowed: boolean;\n pluginName: string;\n rushJsonFolder: string;\n}\n\nconst MAX_HTTP_CACHE_ATTEMPTS: number = 3;\nconst DEFAULT_MIN_HTTP_RETRY_DELAY_MS: number = 2500;\n\nexport class HttpBuildCacheProvider implements ICloudBuildCacheProvider {\n private readonly _pluginName: string;\n private readonly _rushProjectRoot: string;\n private readonly _environmentCredential: string | undefined;\n private readonly _isCacheWriteAllowedByConfiguration: boolean;\n private readonly _url: URL;\n private readonly _uploadMethod: UploadMethod;\n private readonly _headers: Record<string, string>;\n private readonly _cacheKeyPrefix: string;\n private readonly _tokenHandler: IHttpBuildCacheTokenHandler | undefined;\n private readonly _minHttpRetryDelayMs: number;\n private __credentialCacheId: string | undefined;\n\n public get isCacheWriteAllowed(): boolean {\n return EnvironmentConfiguration.buildCacheWriteAllowed ?? this._isCacheWriteAllowedByConfiguration;\n }\n\n public constructor(options: IHttpBuildCacheProviderOptions, rushSession: RushSession) {\n this._pluginName = options.pluginName;\n this._rushProjectRoot = options.rushJsonFolder;\n\n this._environmentCredential = EnvironmentConfiguration.buildCacheCredential;\n this._isCacheWriteAllowedByConfiguration = options.isCacheWriteAllowed;\n this._url = new URL(options.url.endsWith('/') ? options.url : options.url + '/');\n this._uploadMethod = options.uploadMethod ?? 'PUT';\n this._headers = options.headers ?? {};\n this._tokenHandler = options.tokenHandler;\n this._cacheKeyPrefix = options.cacheKeyPrefix ?? '';\n this._minHttpRetryDelayMs = options.minHttpRetryDelayMs ?? DEFAULT_MIN_HTTP_RETRY_DELAY_MS;\n }\n\n public async tryGetCacheEntryBufferByIdAsync(\n terminal: ITerminal,\n cacheId: string\n ): Promise<Buffer | undefined> {\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: 'GET',\n body: undefined,\n warningText: 'Could not get cache entry',\n readBody: true,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return Buffer.isBuffer(result) ? result : undefined;\n } catch (e) {\n terminal.writeWarningLine(`Error getting cache entry: ${e}`);\n return undefined;\n }\n }\n\n public async trySetCacheEntryBufferAsync(\n terminal: ITerminal,\n cacheId: string,\n objectBuffer: Buffer\n ): Promise<boolean> {\n if (!this.isCacheWriteAllowed) {\n terminal.writeErrorLine('Writing to cache is not allowed in the current configuration.');\n return false;\n }\n\n terminal.writeDebugLine('Uploading object with cacheId: ', cacheId);\n\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: this._uploadMethod,\n body: objectBuffer,\n warningText: 'Could not write cache entry',\n readBody: false,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return result !== false;\n } catch (e) {\n terminal.writeWarningLine(`Error uploading cache entry: ${e}`);\n return false;\n }\n }\n\n public async updateCachedCredentialAsync(terminal: ITerminal, credential: string): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.setCacheEntry(this._credentialCacheId, {\n credential: credential\n });\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n public async updateCachedCredentialInteractiveAsync(terminal: ITerminal): Promise<void> {\n if (!this._tokenHandler) {\n throw new Error(\n `The interactive cloud credentials flow is not configured.\\n` +\n `Set the 'tokenHandler' setting in 'common/config/rush-plugins/${this._pluginName}.json' to a command that writes your credentials to standard output and exits with code 0 ` +\n `or provide your credentials to rush using the --credential flag instead. Credentials must be the ` +\n `'Authorization' header expected by ${this._url.href}`\n );\n }\n\n const cmd: string = `${this._tokenHandler.exec} ${(this._tokenHandler.args || []).join(' ')}`;\n terminal.writeVerboseLine(`Running '${cmd}' to get credentials`);\n const result: SpawnSyncReturns<string> = Executable.spawnSync(\n this._tokenHandler.exec,\n this._tokenHandler.args || [],\n {\n currentWorkingDirectory: this._rushProjectRoot\n }\n );\n\n terminal.writeErrorLine(result.stderr);\n\n if (result.error) {\n throw new Error(`Could not obtain credentials. The command '${cmd}' failed.`);\n }\n\n const credential: string = result.stdout.trim();\n terminal.writeVerboseLine('Got credentials');\n\n await this.updateCachedCredentialAsync(terminal, credential);\n\n terminal.writeLine('Updated credentials cache');\n }\n\n public async deleteCachedCredentialsAsync(terminal: ITerminal): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.deleteCacheEntry(this._credentialCacheId);\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n private get _credentialCacheId(): string {\n if (!this.__credentialCacheId) {\n const cacheIdParts: string[] = [this._url.href];\n\n if (this._isCacheWriteAllowedByConfiguration) {\n cacheIdParts.push('cacheWriteAllowed');\n }\n\n this.__credentialCacheId = cacheIdParts.join('|');\n }\n\n return this.__credentialCacheId;\n }\n\n private async _makeHttpRequestAsync(options: {\n terminal: ITerminal;\n relUrl: string;\n method: 'GET' | UploadMethod;\n body: Buffer | undefined;\n warningText: string;\n readBody: boolean;\n maxAttempts: number;\n credentialOptions?: CredentialsOptions;\n }): Promise<Buffer | boolean> {\n const { terminal, relUrl, method, body, warningText, readBody, credentialOptions } = options;\n const safeCredentialOptions: CredentialsOptions = credentialOptions ?? CredentialsOptions.Optional;\n const credentials: string | undefined = await this._tryGetCredentialsAsync(safeCredentialOptions);\n const url: string = new URL(relUrl, this._url).href;\n\n const headers: Record<string, string> = {};\n if (typeof credentials === 'string') {\n headers.Authorization = credentials;\n }\n\n for (const [key, value] of Object.entries(this._headers)) {\n if (typeof value === 'string') {\n headers[key] = value;\n }\n }\n\n const bodyLength: number | 'unknown' = (body as { length: number })?.length || 'unknown';\n\n terminal.writeDebugLine(`[http-build-cache] request: ${method} ${url} ${bodyLength} bytes`);\n\n const webClient: WebClient = new WebClient();\n const response: IWebClientResponse = await webClient.fetchAsync(url, {\n verb: method,\n headers: headers,\n body: body,\n redirect: 'follow',\n timeoutMs: 0 // Use the default timeout\n });\n\n if (!response.ok) {\n const isNonCredentialResponse: boolean = response.status >= 500 && response.status < 600;\n\n if (\n !isNonCredentialResponse &&\n typeof credentials !== 'string' &&\n safeCredentialOptions === CredentialsOptions.Optional\n ) {\n // If we don't already have credentials yet, and we got a response from the server\n // that is a \"normal\" failure (4xx), then we assume that credentials are probably\n // required. Re-attempt the request, requiring credentials this time.\n //\n // This counts as part of the \"first attempt\", so it is not included in the max attempts\n return await this._makeHttpRequestAsync({\n ...options,\n credentialOptions: CredentialsOptions.Required\n });\n }\n\n if (options.maxAttempts > 1) {\n // Pause a bit before retrying in case the server is busy\n // Add some random jitter to the retry so we can spread out load on the remote service\n // A proper solution might add exponential back off in case the retry count is high (10 or more)\n const factor: number = 1.0 + Math.random(); // A random number between 1.0 and 2.0\n const retryDelay: number = Math.floor(factor * this._minHttpRetryDelayMs);\n\n await Async.sleepAsync(retryDelay);\n\n return await this._makeHttpRequestAsync({ ...options, maxAttempts: options.maxAttempts - 1 });\n }\n\n this._reportFailure(terminal, method, response, false, warningText);\n return false;\n }\n\n const result: Buffer | boolean = readBody ? await response.getBufferAsync() : true;\n\n terminal.writeDebugLine(\n `[http-build-cache] actual response: ${response.status} ${url} ${\n result === true ? 'true' : result.length\n } bytes`\n );\n\n return result;\n }\n\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Required): Promise<string>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Optional): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Omit): Promise<undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined> {\n if (options === CredentialsOptions.Omit) {\n return;\n }\n\n let credentials: string | undefined = this._environmentCredential;\n\n if (credentials === undefined) {\n credentials = await this._tryGetCredentialsFromCacheAsync();\n }\n\n if (typeof credentials !== 'string' && options === CredentialsOptions.Required) {\n throw new Error(\n [\n `Credentials for ${this._url.href} have not been provided.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n\n return credentials;\n }\n\n private async _tryGetCredentialsFromCacheAsync(): Promise<string | undefined> {\n let cacheEntry: ICredentialCacheEntry | undefined;\n\n await CredentialCache.usingAsync(\n {\n supportEditing: false\n },\n (credentialsCache: CredentialCache) => {\n cacheEntry = credentialsCache.tryGetCacheEntry(this._credentialCacheId);\n }\n );\n\n if (cacheEntry) {\n const expirationTime: number | undefined = cacheEntry.expires?.getTime();\n if (!expirationTime || expirationTime >= Date.now()) {\n return cacheEntry.credential;\n }\n }\n }\n\n private _getFailureType(\n requestMethod: string,\n response: IWebClientResponse,\n isRedirect: boolean\n ): FailureType {\n if (response.ok) {\n return FailureType.None;\n }\n\n switch (response.status) {\n case 503: {\n // We select 503 specifically because this represents \"service unavailable\" and\n // \"rate limit throttle\" errors, which are transient issues.\n //\n // There are other 5xx errors, such as 501, that can occur if the request is\n // malformed, so as a general rule we want to let through other 5xx errors\n // so the user can troubleshoot.\n\n // Don't fail production builds with warnings for transient issues\n return FailureType.Informational;\n }\n\n case 401:\n case 403:\n case 407: {\n if (requestMethod === 'GET' && (isRedirect || response.redirected)) {\n // Cache misses for GET requests are not errors\n // This is a workaround behavior where a server can issue a redirect and we fail to authenticate at the new location.\n // We do not want to signal this as an authentication failure because the authorization header is not passed on to redirects.\n // i.e The authentication header was accepted for the first request and therefore subsequent failures\n // where it was not present should not be attributed to the header.\n // This scenario usually comes up with services that redirect to pre-signed URLS that don't actually exist.\n // Those services then usually treat the 404 as a 403 to prevent leaking information.\n return FailureType.None;\n }\n\n return FailureType.Authentication;\n }\n\n case 404: {\n if (requestMethod === 'GET') {\n // Cache misses for GET requests are not errors\n return FailureType.None;\n }\n }\n }\n\n // Let dev builds succeed, let Prod builds fail\n return FailureType.Warning;\n }\n\n private _reportFailure(\n terminal: ITerminal,\n requestMethod: string,\n response: IWebClientResponse,\n isRedirect: boolean,\n message: string\n ): void {\n switch (this._getFailureType(requestMethod, response, isRedirect)) {\n default: {\n terminal.writeErrorLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Warning: {\n terminal.writeWarningLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Informational: {\n terminal.writeLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.None: {\n terminal.writeDebugLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Authentication: {\n throw new Error(\n [\n `${this._url.href} responded with ${response.status}: ${response.statusText}.`,\n `Credentials may be misconfigured or have expired.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"HttpBuildCacheProvider.js","sourceRoot":"","sources":["../src/HttpBuildCacheProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,oEAAiE;AAEjE,kDAM6B;AAC7B,2EAAiG;AAEjG,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACrB,mEAAQ,CAAA;IACR,mEAAQ,CAAA;IACR,2DAAI,CAAA;AACN,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AAED,IAAK,WAMJ;AAND,WAAK,WAAW;IACd,6CAAI,CAAA;IACJ,+DAAa,CAAA;IACb,mDAAO,CAAA;IACP,+CAAK,CAAA;IACL,iEAAc,CAAA;AAChB,CAAC,EANI,WAAW,KAAX,WAAW,QAMf;AA2BD,MAAM,uBAAuB,GAAW,CAAC,CAAC;AAC1C,MAAM,+BAA+B,GAAW,IAAI,C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AC;gBACzF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC/B,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBAClF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;gBACtB,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACvF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;gBAChC,MAAM,IAAI,KAAK,CACb;oBACE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,mBAAmB,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,GAAG;oBAC9E,mDAAmD;oBACnD,6FAA6F;oBAC7F,EAAE;oBACF,4BAA4B;oBAC5B,EAAE;oBACF,iDAAiD;oBACjD,EAAE;iBACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArYD,wDAqYC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { SpawnSyncReturns } from 'node:child_process';\n\nimport { Executable, Async } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport {\n type ICloudBuildCacheProvider,\n type ICredentialCacheEntry,\n CredentialCache,\n type RushSession,\n EnvironmentConfiguration\n} from '@rushstack/rush-sdk';\nimport { WebClient, type IWebClientResponse } from '@rushstack/rush-sdk/lib/utilities/WebClient';\n\nenum CredentialsOptions {\n Optional,\n Required,\n Omit\n}\n\nenum FailureType {\n None,\n Informational,\n Warning,\n Error,\n Authentication\n}\n\nexport interface IHttpBuildCacheTokenHandler {\n exec: string;\n args?: string[];\n}\n\n/**\n * @public\n */\nexport type UploadMethod = 'PUT' | 'POST' | 'PATCH';\n\n/**\n * @public\n */\nexport interface IHttpBuildCacheProviderOptions {\n url: string;\n tokenHandler?: IHttpBuildCacheTokenHandler;\n uploadMethod?: UploadMethod;\n minHttpRetryDelayMs?: number;\n headers?: Record<string, string>;\n cacheKeyPrefix?: string;\n isCacheWriteAllowed: boolean;\n pluginName: string;\n rushJsonFolder: string;\n}\n\nconst MAX_HTTP_CACHE_ATTEMPTS: number = 3;\nconst DEFAULT_MIN_HTTP_RETRY_DELAY_MS: number = 2500;\n\nexport class HttpBuildCacheProvider implements ICloudBuildCacheProvider {\n private readonly _pluginName: string;\n private readonly _rushProjectRoot: string;\n private readonly _environmentCredential: string | undefined;\n private readonly _isCacheWriteAllowedByConfiguration: boolean;\n private readonly _url: URL;\n private readonly _uploadMethod: UploadMethod;\n private readonly _headers: Record<string, string>;\n private readonly _cacheKeyPrefix: string;\n private readonly _tokenHandler: IHttpBuildCacheTokenHandler | undefined;\n private readonly _minHttpRetryDelayMs: number;\n private __credentialCacheId: string | undefined;\n\n public get isCacheWriteAllowed(): boolean {\n return EnvironmentConfiguration.buildCacheWriteAllowed ?? this._isCacheWriteAllowedByConfiguration;\n }\n\n public constructor(options: IHttpBuildCacheProviderOptions, rushSession: RushSession) {\n this._pluginName = options.pluginName;\n this._rushProjectRoot = options.rushJsonFolder;\n\n this._environmentCredential = EnvironmentConfiguration.buildCacheCredential;\n this._isCacheWriteAllowedByConfiguration = options.isCacheWriteAllowed;\n this._url = new URL(options.url.endsWith('/') ? options.url : options.url + '/');\n this._uploadMethod = options.uploadMethod ?? 'PUT';\n this._headers = options.headers ?? {};\n this._tokenHandler = options.tokenHandler;\n this._cacheKeyPrefix = options.cacheKeyPrefix ?? '';\n this._minHttpRetryDelayMs = options.minHttpRetryDelayMs ?? DEFAULT_MIN_HTTP_RETRY_DELAY_MS;\n }\n\n public async tryGetCacheEntryBufferByIdAsync(\n terminal: ITerminal,\n cacheId: string\n ): Promise<Buffer | undefined> {\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: 'GET',\n body: undefined,\n warningText: 'Could not get cache entry',\n readBody: true,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return Buffer.isBuffer(result) ? result : undefined;\n } catch (e) {\n terminal.writeWarningLine(`Error getting cache entry: ${e}`);\n return undefined;\n }\n }\n\n public async trySetCacheEntryBufferAsync(\n terminal: ITerminal,\n cacheId: string,\n objectBuffer: Buffer\n ): Promise<boolean> {\n if (!this.isCacheWriteAllowed) {\n terminal.writeErrorLine('Writing to cache is not allowed in the current configuration.');\n return false;\n }\n\n terminal.writeDebugLine('Uploading object with cacheId: ', cacheId);\n\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: this._uploadMethod,\n body: objectBuffer,\n warningText: 'Could not write cache entry',\n readBody: false,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return result !== false;\n } catch (e) {\n terminal.writeWarningLine(`Error uploading cache entry: ${e}`);\n return false;\n }\n }\n\n public async updateCachedCredentialAsync(terminal: ITerminal, credential: string): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.setCacheEntry(this._credentialCacheId, {\n credential: credential\n });\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n public async updateCachedCredentialInteractiveAsync(terminal: ITerminal): Promise<void> {\n if (!this._tokenHandler) {\n throw new Error(\n `The interactive cloud credentials flow is not configured.\\n` +\n `Set the 'tokenHandler' setting in 'common/config/rush-plugins/${this._pluginName}.json' to a command that writes your credentials to standard output and exits with code 0 ` +\n `or provide your credentials to rush using the --credential flag instead. Credentials must be the ` +\n `'Authorization' header expected by ${this._url.href}`\n );\n }\n\n const cmd: string = `${this._tokenHandler.exec} ${(this._tokenHandler.args || []).join(' ')}`;\n terminal.writeVerboseLine(`Running '${cmd}' to get credentials`);\n const result: SpawnSyncReturns<string> = Executable.spawnSync(\n this._tokenHandler.exec,\n this._tokenHandler.args || [],\n {\n currentWorkingDirectory: this._rushProjectRoot\n }\n );\n\n terminal.writeErrorLine(result.stderr);\n\n if (result.error) {\n throw new Error(`Could not obtain credentials. The command '${cmd}' failed.`);\n }\n\n const credential: string = result.stdout.trim();\n terminal.writeVerboseLine('Got credentials');\n\n await this.updateCachedCredentialAsync(terminal, credential);\n\n terminal.writeLine('Updated credentials cache');\n }\n\n public async deleteCachedCredentialsAsync(terminal: ITerminal): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.deleteCacheEntry(this._credentialCacheId);\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n private get _credentialCacheId(): string {\n if (!this.__credentialCacheId) {\n const cacheIdParts: string[] = [this._url.href];\n\n if (this._isCacheWriteAllowedByConfiguration) {\n cacheIdParts.push('cacheWriteAllowed');\n }\n\n this.__credentialCacheId = cacheIdParts.join('|');\n }\n\n return this.__credentialCacheId;\n }\n\n private async _makeHttpRequestAsync(options: {\n terminal: ITerminal;\n relUrl: string;\n method: 'GET' | UploadMethod;\n body: Buffer | undefined;\n warningText: string;\n readBody: boolean;\n maxAttempts: number;\n credentialOptions?: CredentialsOptions;\n }): Promise<Buffer | boolean> {\n const { terminal, relUrl, method, body, warningText, readBody, credentialOptions } = options;\n const safeCredentialOptions: CredentialsOptions = credentialOptions ?? CredentialsOptions.Optional;\n const credentials: string | undefined = await this._tryGetCredentialsAsync(safeCredentialOptions);\n const url: string = new URL(relUrl, this._url).href;\n\n const headers: Record<string, string> = {};\n if (typeof credentials === 'string') {\n headers.Authorization = credentials;\n }\n\n for (const [key, value] of Object.entries(this._headers)) {\n if (typeof value === 'string') {\n headers[key] = value;\n }\n }\n\n const bodyLength: number | 'unknown' = (body as { length: number })?.length || 'unknown';\n\n terminal.writeDebugLine(`[http-build-cache] request: ${method} ${url} ${bodyLength} bytes`);\n\n const webClient: WebClient = new WebClient();\n const response: IWebClientResponse = await webClient.fetchAsync(url, {\n verb: method,\n headers: headers,\n body: body,\n redirect: 'follow',\n timeoutMs: 0 // Use the default timeout\n });\n\n if (!response.ok) {\n const isNonCredentialResponse: boolean = response.status >= 500 && response.status < 600;\n\n if (\n !isNonCredentialResponse &&\n typeof credentials !== 'string' &&\n safeCredentialOptions === CredentialsOptions.Optional\n ) {\n // If we don't already have credentials yet, and we got a response from the server\n // that is a \"normal\" failure (4xx), then we assume that credentials are probably\n // required. Re-attempt the request, requiring credentials this time.\n //\n // This counts as part of the \"first attempt\", so it is not included in the max attempts\n return await this._makeHttpRequestAsync({\n ...options,\n credentialOptions: CredentialsOptions.Required\n });\n }\n\n if (options.maxAttempts > 1) {\n // Pause a bit before retrying in case the server is busy\n // Add some random jitter to the retry so we can spread out load on the remote service\n // A proper solution might add exponential back off in case the retry count is high (10 or more)\n const factor: number = 1.0 + Math.random(); // A random number between 1.0 and 2.0\n const retryDelay: number = Math.floor(factor * this._minHttpRetryDelayMs);\n\n await Async.sleepAsync(retryDelay);\n\n return await this._makeHttpRequestAsync({ ...options, maxAttempts: options.maxAttempts - 1 });\n }\n\n this._reportFailure(terminal, method, response, false, warningText);\n return false;\n }\n\n const result: Buffer | boolean = readBody ? await response.getBufferAsync() : true;\n\n terminal.writeDebugLine(\n `[http-build-cache] actual response: ${response.status} ${url} ${\n result === true ? 'true' : result.length\n } bytes`\n );\n\n return result;\n }\n\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Required): Promise<string>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Optional): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Omit): Promise<undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined> {\n if (options === CredentialsOptions.Omit) {\n return;\n }\n\n let credentials: string | undefined = this._environmentCredential;\n\n if (credentials === undefined) {\n credentials = await this._tryGetCredentialsFromCacheAsync();\n }\n\n if (typeof credentials !== 'string' && options === CredentialsOptions.Required) {\n throw new Error(\n [\n `Credentials for ${this._url.href} have not been provided.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n\n return credentials;\n }\n\n private async _tryGetCredentialsFromCacheAsync(): Promise<string | undefined> {\n let cacheEntry: ICredentialCacheEntry | undefined;\n\n await CredentialCache.usingAsync(\n {\n supportEditing: false\n },\n (credentialsCache: CredentialCache) => {\n cacheEntry = credentialsCache.tryGetCacheEntry(this._credentialCacheId);\n }\n );\n\n if (cacheEntry) {\n const expirationTime: number | undefined = cacheEntry.expires?.getTime();\n if (!expirationTime || expirationTime >= Date.now()) {\n return cacheEntry.credential;\n }\n }\n }\n\n private _getFailureType(\n requestMethod: string,\n response: IWebClientResponse,\n isRedirect: boolean\n ): FailureType {\n if (response.ok) {\n return FailureType.None;\n }\n\n switch (response.status) {\n case 503: {\n // We select 503 specifically because this represents \"service unavailable\" and\n // \"rate limit throttle\" errors, which are transient issues.\n //\n // There are other 5xx errors, such as 501, that can occur if the request is\n // malformed, so as a general rule we want to let through other 5xx errors\n // so the user can troubleshoot.\n\n // Don't fail production builds with warnings for transient issues\n return FailureType.Informational;\n }\n\n case 401:\n case 403:\n case 407: {\n if (requestMethod === 'GET' && (isRedirect || response.redirected)) {\n // Cache misses for GET requests are not errors\n // This is a workaround behavior where a server can issue a redirect and we fail to authenticate at the new location.\n // We do not want to signal this as an authentication failure because the authorization header is not passed on to redirects.\n // i.e The authentication header was accepted for the first request and therefore subsequent failures\n // where it was not present should not be attributed to the header.\n // This scenario usually comes up with services that redirect to pre-signed URLS that don't actually exist.\n // Those services then usually treat the 404 as a 403 to prevent leaking information.\n return FailureType.None;\n }\n\n return FailureType.Authentication;\n }\n\n case 404: {\n if (requestMethod === 'GET') {\n // Cache misses for GET requests are not errors\n return FailureType.None;\n }\n }\n }\n\n // Let dev builds succeed, let Prod builds fail\n return FailureType.Warning;\n }\n\n private _reportFailure(\n terminal: ITerminal,\n requestMethod: string,\n response: IWebClientResponse,\n isRedirect: boolean,\n message: string\n ): void {\n switch (this._getFailureType(requestMethod, response, isRedirect)) {\n default: {\n terminal.writeErrorLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Warning: {\n terminal.writeWarningLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Informational: {\n terminal.writeLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.None: {\n terminal.writeDebugLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Authentication: {\n throw new Error(\n [\n `${this._url.href} responded with ${response.status}: ${response.statusText}.`,\n `Credentials may be misconfigured or have expired.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RushHttpBuildCachePlugin.d.ts","sourceRoot":"","sources":["../src/RushHttpBuildCachePlugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,KAAK,EAAkC,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7F;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE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IACL,CAAC;CACF;AA9BD,4DA8BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { IRushPlugin, RushSession, RushConfiguration } from '@rushstack/rush-sdk';\nimport type { IHttpBuildCacheProviderOptions, UploadMethod } from './HttpBuildCacheProvider';\n\nconst PLUGIN_NAME: string = 'HttpBuildCachePlugin';\n\n/**\n * @public\n */\nexport interface IRushHttpBuildCachePluginConfig {\n /**\n * The URL of the server that stores the caches (e.g. \"https://build-caches.example.com\").\n */\n url: string;\n\n /**\n * The HTTP method to use when writing to the cache (defaults to PUT).\n */\n uploadMethod?: UploadMethod;\n\n /**\n * An optional set of HTTP headers to pass to the cache server.\n */\n headers?: Record<string, string>;\n\n /**\n * An optional command that prints the endpoint's credentials to stdout. Provide the\n * command or script to execute and, optionally, any arguments to pass to the script.\n */\n tokenHandler?: {\n exec: string;\n args?: string[];\n };\n\n /**\n * Prefix for cache keys.\n */\n cacheKeyPrefix?: string;\n\n /**\n * If set to true, allow writing to the cache. Defaults to false.\n */\n isCacheWriteAllowed?: boolean;\n}\n\n/**\n * @public\n */\nexport class RushHttpBuildCachePlugin implements IRushPlugin {\n public readonly pluginName: string = PLUGIN_NAME;\n\n public apply(rushSession: RushSession, rushConfig: RushConfiguration): void {\n rushSession.hooks.initialize.tap(this.pluginName, () => {\n rushSession.registerCloudBuildCacheProviderFactory('http', async (buildCacheConfig) => {\n const config: IRushHttpBuildCachePluginConfig = (\n buildCacheConfig as typeof buildCacheConfig & {\n httpConfiguration: IRushHttpBuildCachePluginConfig;\n }\n ).httpConfiguration;\n\n const { url, uploadMethod, headers, tokenHandler, cacheKeyPrefix, isCacheWriteAllowed } = config;\n\n const options: IHttpBuildCacheProviderOptions = {\n pluginName: this.pluginName,\n rushJsonFolder: rushConfig.rushJsonFolder,\n url: url,\n uploadMethod: uploadMethod,\n headers: headers,\n tokenHandler: tokenHandler,\n cacheKeyPrefix: cacheKeyPrefix,\n isCacheWriteAllowed: !!isCacheWriteAllowed\n };\n\n const { HttpBuildCacheProvider } = await import('./HttpBuildCacheProvider');\n return new HttpBuildCacheProvider(options, rushSession);\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"RushHttpBuildCachePlugin.js","sourceRoot":"","sources":["../src/RushHttpBuildCachePlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM3D,MAAM,WAAW,GAAW,sBAAsB,CAAC;AAyCnD;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACkB,eAAU,GAAW,WAAW,CAAC;IA6BnD,CAAC;IA3BQ,KAAK,CAAC,WAAwB,EAAE,UAA6B;QAClE,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;YACrD,WAAW,CAAC,sCAAsC,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE;gBACpF,MAAM,MAAM,GACV,gBAGD,CAAC,iBAAiB,CAAC;gBAEpB,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAC;gBAEjG,MAAM,OAAO,GAAmC;oBAC9C,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,GAAG,EAAE,GAAG;oBACR,YAAY,EAAE,YAAY;oBAC1B,OAAO,EAAE,OAAO;oBAChB,YAAY,EAAE,YAAY;oBAC1B,cAAc,EAAE,cAAc;oBAC9B,mBAAmB,EAAE,CAAC,CAAC,mBAAmB;iBAC3C,CAAC;gBAEF,MAAM,EAAE,sBAAsB,EAAE,GAAG,wDAAa,0BAA0B,GAAC,CAAC;gBAC5E,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9BD,4DA8BC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { IRushPlugin, RushSession, RushConfiguration } from '@rushstack/rush-sdk';\n\nimport type { IHttpBuildCacheProviderOptions, UploadMethod } from './HttpBuildCacheProvider';\n\nconst PLUGIN_NAME: string = 'HttpBuildCachePlugin';\n\n/**\n * @public\n */\nexport interface IRushHttpBuildCachePluginConfig {\n /**\n * The URL of the server that stores the caches (e.g. \"https://build-caches.example.com\").\n */\n url: string;\n\n /**\n * The HTTP method to use when writing to the cache (defaults to PUT).\n */\n uploadMethod?: UploadMethod;\n\n /**\n * An optional set of HTTP headers to pass to the cache server.\n */\n headers?: Record<string, string>;\n\n /**\n * An optional command that prints the endpoint's credentials to stdout. Provide the\n * command or script to execute and, optionally, any arguments to pass to the script.\n */\n tokenHandler?: {\n exec: string;\n args?: string[];\n };\n\n /**\n * Prefix for cache keys.\n */\n cacheKeyPrefix?: string;\n\n /**\n * If set to true, allow writing to the cache. Defaults to false.\n */\n isCacheWriteAllowed?: boolean;\n}\n\n/**\n * @public\n */\nexport class RushHttpBuildCachePlugin implements IRushPlugin {\n public readonly pluginName: string = PLUGIN_NAME;\n\n public apply(rushSession: RushSession, rushConfig: RushConfiguration): void {\n rushSession.hooks.initialize.tap(this.pluginName, () => {\n rushSession.registerCloudBuildCacheProviderFactory('http', async (buildCacheConfig) => {\n const config: IRushHttpBuildCachePluginConfig = (\n buildCacheConfig as typeof buildCacheConfig & {\n httpConfiguration: IRushHttpBuildCachePluginConfig;\n }\n ).httpConfiguration;\n\n const { url, uploadMethod, headers, tokenHandler, cacheKeyPrefix, isCacheWriteAllowed } = config;\n\n const options: IHttpBuildCacheProviderOptions = {\n pluginName: this.pluginName,\n rushJsonFolder: rushConfig.rushJsonFolder,\n url: url,\n uploadMethod: uploadMethod,\n headers: headers,\n tokenHandler: tokenHandler,\n cacheKeyPrefix: cacheKeyPrefix,\n isCacheWriteAllowed: !!isCacheWriteAllowed\n };\n\n const { HttpBuildCacheProvider } = await import('./HttpBuildCacheProvider');\n return new HttpBuildCacheProvider(options, rushSession);\n });\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rush-http-build-cache-plugin",
3
- "version": "5.159.0",
3
+ "version": "5.160.0",
4
4
  "description": "Rush plugin for generic HTTP cloud build cache",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,15 +13,15 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "https-proxy-agent": "~5.0.0",
16
- "@rushstack/node-core-library": "5.15.1",
17
- "@rushstack/rush-sdk": "5.159.0"
16
+ "@rushstack/node-core-library": "5.16.0",
17
+ "@rushstack/rush-sdk": "5.160.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "eslint": "~9.25.1",
21
- "@rushstack/heft": "1.0.0",
22
- "@microsoft/rush-lib": "5.159.0",
23
- "@rushstack/terminal": "0.18.0",
24
- "local-node-rig": "1.0.0"
21
+ "@microsoft/rush-lib": "5.160.0",
22
+ "@rushstack/heft": "1.1.0",
23
+ "local-node-rig": "1.0.0",
24
+ "@rushstack/terminal": "0.19.0"
25
25
  },
26
26
  "scripts": {
27
27
  "build": "heft build --clean",