mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-18 20:48:29 +02:00
feat: add @actions/cache
This commit is contained in:
parent
b15fb7d098
commit
16e8c96a41
1932 changed files with 261172 additions and 10 deletions
89
node_modules/@azure/ms-rest-js/lib/credentials/apiKeyCredentials.ts
generated
vendored
Normal file
89
node_modules/@azure/ms-rest-js/lib/credentials/apiKeyCredentials.ts
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { HttpHeaders } from "../httpHeaders";
|
||||
import { WebResourceLike } from "../webResource";
|
||||
import { ServiceClientCredentials } from "./serviceClientCredentials";
|
||||
|
||||
/**
|
||||
* @interface ApiKeyCredentialOptions
|
||||
* Describes the options to be provided while creating an instance of ApiKeyCredentials
|
||||
*/
|
||||
export interface ApiKeyCredentialOptions {
|
||||
/**
|
||||
* A key value pair of the header parameters that need to be applied to the request.
|
||||
*/
|
||||
inHeader?: { [x: string]: any };
|
||||
/**
|
||||
* A key value pair of the query parameters that need to be applied to the request.
|
||||
*/
|
||||
inQuery?: { [x: string]: any };
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticates to a service using an API key.
|
||||
*/
|
||||
export class ApiKeyCredentials implements ServiceClientCredentials {
|
||||
/**
|
||||
* A key value pair of the header parameters that need to be applied to the request.
|
||||
*/
|
||||
private readonly inHeader?: { [x: string]: any };
|
||||
/**
|
||||
* A key value pair of the query parameters that need to be applied to the request.
|
||||
*/
|
||||
private readonly inQuery?: { [x: string]: any };
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {object} options Specifies the options to be provided for auth. Either header or query needs to be provided.
|
||||
*/
|
||||
constructor(options: ApiKeyCredentialOptions) {
|
||||
if (!options || (options && !options.inHeader && !options.inQuery)) {
|
||||
throw new Error(
|
||||
`options cannot be null or undefined. Either "inHeader" or "inQuery" property of the options object needs to be provided.`
|
||||
);
|
||||
}
|
||||
this.inHeader = options.inHeader;
|
||||
this.inQuery = options.inQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs a request with the values provided in the inHeader and inQuery parameter.
|
||||
*
|
||||
* @param {WebResource} webResource The WebResource to be signed.
|
||||
* @returns {Promise<WebResource>} The signed request object.
|
||||
*/
|
||||
signRequest(webResource: WebResourceLike): Promise<WebResourceLike> {
|
||||
if (!webResource) {
|
||||
return Promise.reject(
|
||||
new Error(`webResource cannot be null or undefined and must be of type "object".`)
|
||||
);
|
||||
}
|
||||
|
||||
if (this.inHeader) {
|
||||
if (!webResource.headers) {
|
||||
webResource.headers = new HttpHeaders();
|
||||
}
|
||||
for (const headerName in this.inHeader) {
|
||||
webResource.headers.set(headerName, this.inHeader[headerName]);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.inQuery) {
|
||||
if (!webResource.url) {
|
||||
return Promise.reject(new Error(`url cannot be null in the request object.`));
|
||||
}
|
||||
if (webResource.url.indexOf("?") < 0) {
|
||||
webResource.url += "?";
|
||||
}
|
||||
for (const key in this.inQuery) {
|
||||
if (!webResource.url.endsWith("?")) {
|
||||
webResource.url += "&";
|
||||
}
|
||||
webResource.url += `${key}=${this.inQuery[key]}`;
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve(webResource);
|
||||
}
|
||||
}
|
60
node_modules/@azure/ms-rest-js/lib/credentials/azureIdentityTokenCredentialAdapter.ts
generated
vendored
Normal file
60
node_modules/@azure/ms-rest-js/lib/credentials/azureIdentityTokenCredentialAdapter.ts
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { ServiceClientCredentials } from "./serviceClientCredentials";
|
||||
import { Constants as MSRestConstants } from "../util/constants";
|
||||
import { WebResource } from "../webResource";
|
||||
|
||||
import { TokenCredential } from "@azure/core-auth";
|
||||
import { TokenResponse } from "./tokenResponse";
|
||||
|
||||
const DEFAULT_AUTHORIZATION_SCHEME = "Bearer";
|
||||
|
||||
/**
|
||||
* Resource manager endpoints to match in order to specify a valid scope to the AzureIdentityCredentialAdapter.
|
||||
*/
|
||||
export const azureResourceManagerEndpoints = [
|
||||
"https://management.windows.net",
|
||||
"https://management.chinacloudapi.cn",
|
||||
"https://management.usgovcloudapi.net",
|
||||
"https://management.cloudapi.de",
|
||||
];
|
||||
|
||||
/**
|
||||
* This class provides a simple extension to use {@link TokenCredential} from `@azure/identity` library to
|
||||
* use with legacy Azure SDKs that accept {@link ServiceClientCredentials} family of credentials for authentication.
|
||||
*/
|
||||
export class AzureIdentityCredentialAdapter implements ServiceClientCredentials {
|
||||
private azureTokenCredential: TokenCredential;
|
||||
private scopes: string | string[];
|
||||
constructor(
|
||||
azureTokenCredential: TokenCredential,
|
||||
scopes: string | string[] = "https://management.azure.com/.default"
|
||||
) {
|
||||
this.azureTokenCredential = azureTokenCredential;
|
||||
this.scopes = scopes;
|
||||
}
|
||||
|
||||
public async getToken(): Promise<TokenResponse> {
|
||||
const accessToken = await this.azureTokenCredential.getToken(this.scopes);
|
||||
if (accessToken !== null) {
|
||||
const result: TokenResponse = {
|
||||
accessToken: accessToken.token,
|
||||
tokenType: DEFAULT_AUTHORIZATION_SCHEME,
|
||||
expiresOn: accessToken.expiresOnTimestamp,
|
||||
};
|
||||
return result;
|
||||
} else {
|
||||
throw new Error("Could find token for scope");
|
||||
}
|
||||
}
|
||||
|
||||
public async signRequest(webResource: WebResource) {
|
||||
const tokenResponse = await this.getToken();
|
||||
webResource.headers.set(
|
||||
MSRestConstants.HeaderConstants.AUTHORIZATION,
|
||||
`${tokenResponse.tokenType} ${tokenResponse.accessToken}`
|
||||
);
|
||||
return Promise.resolve(webResource);
|
||||
}
|
||||
}
|
54
node_modules/@azure/ms-rest-js/lib/credentials/basicAuthenticationCredentials.ts
generated
vendored
Normal file
54
node_modules/@azure/ms-rest-js/lib/credentials/basicAuthenticationCredentials.ts
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { HttpHeaders } from "../httpHeaders";
|
||||
import * as base64 from "../util/base64";
|
||||
import { Constants } from "../util/constants";
|
||||
import { WebResourceLike } from "../webResource";
|
||||
import { ServiceClientCredentials } from "./serviceClientCredentials";
|
||||
const HeaderConstants = Constants.HeaderConstants;
|
||||
const DEFAULT_AUTHORIZATION_SCHEME = "Basic";
|
||||
|
||||
export class BasicAuthenticationCredentials implements ServiceClientCredentials {
|
||||
userName: string;
|
||||
password: string;
|
||||
authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME;
|
||||
|
||||
/**
|
||||
* Creates a new BasicAuthenticationCredentials object.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} userName User name.
|
||||
* @param {string} password Password.
|
||||
* @param {string} [authorizationScheme] The authorization scheme.
|
||||
*/
|
||||
constructor(
|
||||
userName: string,
|
||||
password: string,
|
||||
authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME
|
||||
) {
|
||||
if (userName === null || userName === undefined || typeof userName.valueOf() !== "string") {
|
||||
throw new Error("userName cannot be null or undefined and must be of type string.");
|
||||
}
|
||||
if (password === null || password === undefined || typeof password.valueOf() !== "string") {
|
||||
throw new Error("password cannot be null or undefined and must be of type string.");
|
||||
}
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
this.authorizationScheme = authorizationScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs a request with the Authentication header.
|
||||
*
|
||||
* @param {WebResourceLike} webResource The WebResourceLike to be signed.
|
||||
* @returns {Promise<WebResourceLike>} The signed request object.
|
||||
*/
|
||||
signRequest(webResource: WebResourceLike) {
|
||||
const credentials = `${this.userName}:${this.password}`;
|
||||
const encodedCredentials = `${this.authorizationScheme} ${base64.encodeString(credentials)}`;
|
||||
if (!webResource.headers) webResource.headers = new HttpHeaders();
|
||||
webResource.headers.set(HeaderConstants.AUTHORIZATION, encodedCredentials);
|
||||
return Promise.resolve(webResource);
|
||||
}
|
||||
}
|
4
node_modules/@azure/ms-rest-js/lib/credentials/credentials.ts
generated
vendored
Normal file
4
node_modules/@azure/ms-rest-js/lib/credentials/credentials.ts
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
export type Authenticator = (challenge: object) => Promise<string>;
|
24
node_modules/@azure/ms-rest-js/lib/credentials/domainCredentials.ts
generated
vendored
Normal file
24
node_modules/@azure/ms-rest-js/lib/credentials/domainCredentials.ts
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { ApiKeyCredentials, ApiKeyCredentialOptions } from "./apiKeyCredentials";
|
||||
|
||||
export class DomainCredentials extends ApiKeyCredentials {
|
||||
/**
|
||||
* Creates a new EventGrid DomainCredentials object.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} domainKey The EventGrid domain key
|
||||
*/
|
||||
constructor(domainKey: string) {
|
||||
if (!domainKey || (domainKey && typeof domainKey !== "string")) {
|
||||
throw new Error("domainKey cannot be null or undefined and must be of type string.");
|
||||
}
|
||||
const options: ApiKeyCredentialOptions = {
|
||||
inHeader: {
|
||||
"aeg-sas-key": domainKey,
|
||||
},
|
||||
};
|
||||
super(options);
|
||||
}
|
||||
}
|
14
node_modules/@azure/ms-rest-js/lib/credentials/serviceClientCredentials.ts
generated
vendored
Normal file
14
node_modules/@azure/ms-rest-js/lib/credentials/serviceClientCredentials.ts
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { WebResourceLike } from "../webResource";
|
||||
|
||||
export interface ServiceClientCredentials {
|
||||
/**
|
||||
* Signs a request with the Authentication header.
|
||||
*
|
||||
* @param {WebResourceLike} webResource The WebResourceLike/request to be signed.
|
||||
* @returns {Promise<WebResourceLike>} The signed request object;
|
||||
*/
|
||||
signRequest(webResource: WebResourceLike): Promise<WebResourceLike>;
|
||||
}
|
48
node_modules/@azure/ms-rest-js/lib/credentials/tokenCredentials.ts
generated
vendored
Normal file
48
node_modules/@azure/ms-rest-js/lib/credentials/tokenCredentials.ts
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { HttpHeaders } from "../httpHeaders";
|
||||
import { Constants } from "../util/constants";
|
||||
import { WebResourceLike } from "../webResource";
|
||||
import { ServiceClientCredentials } from "./serviceClientCredentials";
|
||||
|
||||
const HeaderConstants = Constants.HeaderConstants;
|
||||
const DEFAULT_AUTHORIZATION_SCHEME = "Bearer";
|
||||
|
||||
/**
|
||||
* A credentials object that uses a token string and a authorzation scheme to authenticate.
|
||||
*/
|
||||
export class TokenCredentials implements ServiceClientCredentials {
|
||||
token: string;
|
||||
authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME;
|
||||
|
||||
/**
|
||||
* Creates a new TokenCredentials object.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} token The token.
|
||||
* @param {string} [authorizationScheme] The authorization scheme.
|
||||
*/
|
||||
constructor(token: string, authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME) {
|
||||
if (!token) {
|
||||
throw new Error("token cannot be null or undefined.");
|
||||
}
|
||||
this.token = token;
|
||||
this.authorizationScheme = authorizationScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs a request with the Authentication header.
|
||||
*
|
||||
* @param {WebResourceLike} webResource The WebResourceLike to be signed.
|
||||
* @return {Promise<WebResourceLike>} The signed request object.
|
||||
*/
|
||||
signRequest(webResource: WebResourceLike) {
|
||||
if (!webResource.headers) webResource.headers = new HttpHeaders();
|
||||
webResource.headers.set(
|
||||
HeaderConstants.AUTHORIZATION,
|
||||
`${this.authorizationScheme} ${this.token}`
|
||||
);
|
||||
return Promise.resolve(webResource);
|
||||
}
|
||||
}
|
12
node_modules/@azure/ms-rest-js/lib/credentials/tokenResponse.ts
generated
vendored
Normal file
12
node_modules/@azure/ms-rest-js/lib/credentials/tokenResponse.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
/**
|
||||
* TokenResponse is defined in `@azure/ms-rest-nodeauth` and is copied here to not
|
||||
* add an unnecessary dependency.
|
||||
*/
|
||||
export interface TokenResponse {
|
||||
readonly tokenType: string;
|
||||
readonly accessToken: string;
|
||||
readonly [x: string]: any;
|
||||
}
|
24
node_modules/@azure/ms-rest-js/lib/credentials/topicCredentials.ts
generated
vendored
Normal file
24
node_modules/@azure/ms-rest-js/lib/credentials/topicCredentials.ts
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
|
||||
import { ApiKeyCredentials, ApiKeyCredentialOptions } from "./apiKeyCredentials";
|
||||
|
||||
export class TopicCredentials extends ApiKeyCredentials {
|
||||
/**
|
||||
* Creates a new EventGrid TopicCredentials object.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} topicKey The EventGrid topic key
|
||||
*/
|
||||
constructor(topicKey: string) {
|
||||
if (!topicKey || (topicKey && typeof topicKey !== "string")) {
|
||||
throw new Error("topicKey cannot be null or undefined and must be of type string.");
|
||||
}
|
||||
const options: ApiKeyCredentialOptions = {
|
||||
inHeader: {
|
||||
"aeg-sas-key": topicKey,
|
||||
},
|
||||
};
|
||||
super(options);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue