mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-23 02:29:33 +01:00
78148dae50
* Updates * Update * Update * Update * Update * Yarn sometimes prefers npmrc, so use same token * Description * Update readme * Feedback * Add type * new toolkit and scoped registries * npmrc in RUNNER_TEMP * Dont always auth * Try exporting blank token * Get auth working for now pending runner changes * Fix string interpolation for auth token. * Don't export both userconfigs * Update authutil.js * Add single quotes for authString * Fix the registry string. * Use userconfig and append trailing slash * Keep in root of repo * Try just adding auth token * Remove auth token * Try changes again * Add tests * Npm and GPR samples * Add types
54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
|
|
var deprecation = require('deprecation');
|
|
var once = _interopDefault(require('once'));
|
|
|
|
const logOnce = once(deprecation => console.warn(deprecation));
|
|
/**
|
|
* Error with extra properties to help with debugging
|
|
*/
|
|
|
|
class RequestError extends Error {
|
|
constructor(message, statusCode, options) {
|
|
super(message); // Maintains proper stack trace (only available on V8)
|
|
|
|
/* istanbul ignore next */
|
|
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, this.constructor);
|
|
}
|
|
|
|
this.name = "HttpError";
|
|
this.status = statusCode;
|
|
Object.defineProperty(this, "code", {
|
|
get() {
|
|
logOnce(new deprecation.Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
|
|
return statusCode;
|
|
}
|
|
|
|
});
|
|
this.headers = options.headers; // redact request credentials without mutating original request options
|
|
|
|
const requestCopy = Object.assign({}, options.request);
|
|
|
|
if (options.request.headers.authorization) {
|
|
requestCopy.headers = Object.assign({}, options.request.headers, {
|
|
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]")
|
|
});
|
|
}
|
|
|
|
requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit
|
|
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
|
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") // OAuth tokens can be passed as URL query parameters, although it is not recommended
|
|
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
|
|
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
|
this.request = requestCopy;
|
|
}
|
|
|
|
}
|
|
|
|
exports.RequestError = RequestError;
|