mirror of
				https://kkgithub.com/actions/setup-node.git
				synced 2025-10-31 18:51:54 +08:00 
			
		
		
		
	Add auth
This commit is contained in:
		
							
								
								
									
										48
									
								
								node_modules/@octokit/request-error/dist-web/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								node_modules/@octokit/request-error/dist-web/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| import { Deprecation } from 'deprecation'; | ||||
| import once from '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("[@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; | ||||
|   } | ||||
|  | ||||
| } | ||||
|  | ||||
| export { RequestError }; | ||||
		Reference in New Issue
	
	Block a user
	 Danny McCormick
					Danny McCormick