feat: add @actions/cache

This commit is contained in:
xHyroM 2022-07-12 09:00:22 +02:00
parent b15fb7d098
commit 16e8c96a41
1932 changed files with 261172 additions and 10 deletions

View file

@ -0,0 +1,46 @@
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 declare class ApiKeyCredentials implements ServiceClientCredentials {
/**
* A key value pair of the header parameters that need to be applied to the request.
*/
private readonly inHeader?;
/**
* A key value pair of the query parameters that need to be applied to the request.
*/
private readonly inQuery?;
/**
* @constructor
* @param {object} options Specifies the options to be provided for auth. Either header or query needs to be provided.
*/
constructor(options: ApiKeyCredentialOptions);
/**
* 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>;
}
//# sourceMappingURL=apiKeyCredentials.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"apiKeyCredentials.d.ts","sourceRoot":"","sources":["../../../lib/credentials/apiKeyCredentials.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAChC;AAED;;GAEG;AACH,qBAAa,iBAAkB,YAAW,wBAAwB;IAChE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAuB;IACjD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAuB;IAEhD;;;OAGG;gBACS,OAAO,EAAE,uBAAuB;IAU5C;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CAiCpE"}

View file

@ -0,0 +1,56 @@
// 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";
/**
* Authenticates to a service using an API key.
*/
var ApiKeyCredentials = /** @class */ (function () {
/**
* @constructor
* @param {object} options Specifies the options to be provided for auth. Either header or query needs to be provided.
*/
function ApiKeyCredentials(options) {
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.
*/
ApiKeyCredentials.prototype.signRequest = function (webResource) {
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 (var 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 (var key in this.inQuery) {
if (!webResource.url.endsWith("?")) {
webResource.url += "&";
}
webResource.url += key + "=" + this.inQuery[key];
}
}
return Promise.resolve(webResource);
};
return ApiKeyCredentials;
}());
export { ApiKeyCredentials };
//# sourceMappingURL=apiKeyCredentials.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"apiKeyCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/apiKeyCredentials.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F;AAE/F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAmB7C;;GAEG;AACH;IAUE;;;OAGG;IACH,2BAAY,OAAgC;QAC1C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAClE,MAAM,IAAI,KAAK,CACb,8HAA0H,CAC3H,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,uCAAW,GAAX,UAAY,WAA4B;QACtC,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,yEAAuE,CAAC,CACnF,CAAC;SACH;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;gBACxB,WAAW,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;aACzC;YACD,KAAK,IAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACtC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;aAChE;SACF;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE;gBACpB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC;aAC/E;YACD,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACpC,WAAW,CAAC,GAAG,IAAI,GAAG,CAAC;aACxB;YACD,KAAK,IAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC9B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBAClC,WAAW,CAAC,GAAG,IAAI,GAAG,CAAC;iBACxB;gBACD,WAAW,CAAC,GAAG,IAAO,GAAG,SAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAG,CAAC;aAClD;SACF;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IACH,wBAAC;AAAD,CAAC,AA/DD,IA+DC"}

View file

@ -0,0 +1,20 @@
import { ServiceClientCredentials } from "./serviceClientCredentials";
import { WebResource } from "../webResource";
import { TokenCredential } from "@azure/core-auth";
import { TokenResponse } from "./tokenResponse";
/**
* Resource manager endpoints to match in order to specify a valid scope to the AzureIdentityCredentialAdapter.
*/
export declare const azureResourceManagerEndpoints: string[];
/**
* 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 declare class AzureIdentityCredentialAdapter implements ServiceClientCredentials {
private azureTokenCredential;
private scopes;
constructor(azureTokenCredential: TokenCredential, scopes?: string | string[]);
getToken(): Promise<TokenResponse>;
signRequest(webResource: WebResource): Promise<WebResource>;
}
//# sourceMappingURL=azureIdentityTokenCredentialAdapter.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"azureIdentityTokenCredentialAdapter.d.ts","sourceRoot":"","sources":["../../../lib/credentials/azureIdentityTokenCredentialAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD;;GAEG;AACH,eAAO,MAAM,6BAA6B,UAKzC,CAAC;AAEF;;;GAGG;AACH,qBAAa,8BAA+B,YAAW,wBAAwB;IAC7E,OAAO,CAAC,oBAAoB,CAAkB;IAC9C,OAAO,CAAC,MAAM,CAAoB;gBAEhC,oBAAoB,EAAE,eAAe,EACrC,MAAM,GAAE,MAAM,GAAG,MAAM,EAA4C;IAMxD,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;IAclC,WAAW,CAAC,WAAW,EAAE,WAAW;CAQlD"}

View file

@ -0,0 +1,66 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
import { __awaiter, __generator } from "tslib";
import { Constants as MSRestConstants } from "../util/constants";
var DEFAULT_AUTHORIZATION_SCHEME = "Bearer";
/**
* Resource manager endpoints to match in order to specify a valid scope to the AzureIdentityCredentialAdapter.
*/
export var 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.
*/
var AzureIdentityCredentialAdapter = /** @class */ (function () {
function AzureIdentityCredentialAdapter(azureTokenCredential, scopes) {
if (scopes === void 0) { scopes = "https://management.azure.com/.default"; }
this.azureTokenCredential = azureTokenCredential;
this.scopes = scopes;
}
AzureIdentityCredentialAdapter.prototype.getToken = function () {
return __awaiter(this, void 0, void 0, function () {
var accessToken, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.azureTokenCredential.getToken(this.scopes)];
case 1:
accessToken = _a.sent();
if (accessToken !== null) {
result = {
accessToken: accessToken.token,
tokenType: DEFAULT_AUTHORIZATION_SCHEME,
expiresOn: accessToken.expiresOnTimestamp,
};
return [2 /*return*/, result];
}
else {
throw new Error("Could find token for scope");
}
return [2 /*return*/];
}
});
});
};
AzureIdentityCredentialAdapter.prototype.signRequest = function (webResource) {
return __awaiter(this, void 0, void 0, function () {
var tokenResponse;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getToken()];
case 1:
tokenResponse = _a.sent();
webResource.headers.set(MSRestConstants.HeaderConstants.AUTHORIZATION, tokenResponse.tokenType + " " + tokenResponse.accessToken);
return [2 /*return*/, Promise.resolve(webResource)];
}
});
});
};
return AzureIdentityCredentialAdapter;
}());
export { AzureIdentityCredentialAdapter };
//# sourceMappingURL=azureIdentityTokenCredentialAdapter.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"azureIdentityTokenCredentialAdapter.js","sourceRoot":"","sources":["../../../lib/credentials/azureIdentityTokenCredentialAdapter.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F;;AAG/F,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMjE,IAAM,4BAA4B,GAAG,QAAQ,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,IAAM,6BAA6B,GAAG;IAC3C,gCAAgC;IAChC,qCAAqC;IACrC,sCAAsC;IACtC,gCAAgC;CACjC,CAAC;AAEF;;;GAGG;AACH;IAGE,wCACE,oBAAqC,EACrC,MAAmE;QAAnE,uBAAA,EAAA,gDAAmE;QAEnE,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEY,iDAAQ,GAArB;;;;;4BACsB,qBAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAA;;wBAAnE,WAAW,GAAG,SAAqD;wBACzE,IAAI,WAAW,KAAK,IAAI,EAAE;4BAClB,MAAM,GAAkB;gCAC5B,WAAW,EAAE,WAAW,CAAC,KAAK;gCAC9B,SAAS,EAAE,4BAA4B;gCACvC,SAAS,EAAE,WAAW,CAAC,kBAAkB;6BAC1C,CAAC;4BACF,sBAAO,MAAM,EAAC;yBACf;6BAAM;4BACL,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;yBAC/C;;;;;KACF;IAEY,oDAAW,GAAxB,UAAyB,WAAwB;;;;;4BACzB,qBAAM,IAAI,CAAC,QAAQ,EAAE,EAAA;;wBAArC,aAAa,GAAG,SAAqB;wBAC3C,WAAW,CAAC,OAAO,CAAC,GAAG,CACrB,eAAe,CAAC,eAAe,CAAC,aAAa,EAC1C,aAAa,CAAC,SAAS,SAAI,aAAa,CAAC,WAAa,CAC1D,CAAC;wBACF,sBAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAC;;;;KACrC;IACH,qCAAC;AAAD,CAAC,AAjCD,IAiCC"}

View file

@ -0,0 +1,24 @@
import { WebResourceLike } from "../webResource";
import { ServiceClientCredentials } from "./serviceClientCredentials";
export declare class BasicAuthenticationCredentials implements ServiceClientCredentials {
userName: string;
password: string;
authorizationScheme: string;
/**
* 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);
/**
* 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): Promise<WebResourceLike>;
}
//# sourceMappingURL=basicAuthenticationCredentials.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"basicAuthenticationCredentials.d.ts","sourceRoot":"","sources":["../../../lib/credentials/basicAuthenticationCredentials.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAItE,qBAAa,8BAA+B,YAAW,wBAAwB;IAC7E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAgC;IAE3D;;;;;;;OAOG;gBAED,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,GAAE,MAAqC;IAa5D;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,eAAe;CAOzC"}

View file

@ -0,0 +1,47 @@
// 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";
var HeaderConstants = Constants.HeaderConstants;
var DEFAULT_AUTHORIZATION_SCHEME = "Basic";
var BasicAuthenticationCredentials = /** @class */ (function () {
/**
* Creates a new BasicAuthenticationCredentials object.
*
* @constructor
* @param {string} userName User name.
* @param {string} password Password.
* @param {string} [authorizationScheme] The authorization scheme.
*/
function BasicAuthenticationCredentials(userName, password, authorizationScheme) {
if (authorizationScheme === void 0) { authorizationScheme = DEFAULT_AUTHORIZATION_SCHEME; }
this.authorizationScheme = 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.
*/
BasicAuthenticationCredentials.prototype.signRequest = function (webResource) {
var credentials = this.userName + ":" + this.password;
var encodedCredentials = this.authorizationScheme + " " + base64.encodeString(credentials);
if (!webResource.headers)
webResource.headers = new HttpHeaders();
webResource.headers.set(HeaderConstants.AUTHORIZATION, encodedCredentials);
return Promise.resolve(webResource);
};
return BasicAuthenticationCredentials;
}());
export { BasicAuthenticationCredentials };
//# sourceMappingURL=basicAuthenticationCredentials.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"basicAuthenticationCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/basicAuthenticationCredentials.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F;AAE/F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,IAAM,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AAClD,IAAM,4BAA4B,GAAG,OAAO,CAAC;AAE7C;IAKE;;;;;;;OAOG;IACH,wCACE,QAAgB,EAChB,QAAgB,EAChB,mBAA0D;QAA1D,oCAAA,EAAA,kDAA0D;QAb5D,wBAAmB,GAAW,4BAA4B,CAAC;QAezD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE;YACzF,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QACD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE;YACzF,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QACD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,oDAAW,GAAX,UAAY,WAA4B;QACtC,IAAM,WAAW,GAAM,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAU,CAAC;QACxD,IAAM,kBAAkB,GAAM,IAAI,CAAC,mBAAmB,SAAI,MAAM,CAAC,YAAY,CAAC,WAAW,CAAG,CAAC;QAC7F,IAAI,CAAC,WAAW,CAAC,OAAO;YAAE,WAAW,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;QAC3E,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IACH,qCAAC;AAAD,CAAC,AA1CD,IA0CC"}

View file

@ -0,0 +1,2 @@
export declare type Authenticator = (challenge: object) => Promise<string>;
//# sourceMappingURL=credentials.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../lib/credentials/credentials.ts"],"names":[],"mappings":"AAGA,oBAAY,aAAa,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC"}

View file

@ -0,0 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//# sourceMappingURL=credentials.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../lib/credentials/credentials.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F"}

View file

@ -0,0 +1,11 @@
import { ApiKeyCredentials } from "./apiKeyCredentials";
export declare class DomainCredentials extends ApiKeyCredentials {
/**
* Creates a new EventGrid DomainCredentials object.
*
* @constructor
* @param {string} domainKey The EventGrid domain key
*/
constructor(domainKey: string);
}
//# sourceMappingURL=domainCredentials.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"domainCredentials.d.ts","sourceRoot":"","sources":["../../../lib/credentials/domainCredentials.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAEjF,qBAAa,iBAAkB,SAAQ,iBAAiB;IACtD;;;;;OAKG;gBACS,SAAS,EAAE,MAAM;CAW9B"}

View file

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
import { __extends } from "tslib";
import { ApiKeyCredentials } from "./apiKeyCredentials";
var DomainCredentials = /** @class */ (function (_super) {
__extends(DomainCredentials, _super);
/**
* Creates a new EventGrid DomainCredentials object.
*
* @constructor
* @param {string} domainKey The EventGrid domain key
*/
function DomainCredentials(domainKey) {
var _this = this;
if (!domainKey || (domainKey && typeof domainKey !== "string")) {
throw new Error("domainKey cannot be null or undefined and must be of type string.");
}
var options = {
inHeader: {
"aeg-sas-key": domainKey,
},
};
_this = _super.call(this, options) || this;
return _this;
}
return DomainCredentials;
}(ApiKeyCredentials));
export { DomainCredentials };
//# sourceMappingURL=domainCredentials.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"domainCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/domainCredentials.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAEjF;IAAuC,qCAAiB;IACtD;;;;;OAKG;IACH,2BAAY,SAAiB;QAA7B,iBAUC;QATC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,CAAC,EAAE;YAC9D,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;SACtF;QACD,IAAM,OAAO,GAA4B;YACvC,QAAQ,EAAE;gBACR,aAAa,EAAE,SAAS;aACzB;SACF,CAAC;QACF,QAAA,kBAAM,OAAO,CAAC,SAAC;;IACjB,CAAC;IACH,wBAAC;AAAD,CAAC,AAlBD,CAAuC,iBAAiB,GAkBvD"}

View file

@ -0,0 +1,11 @@
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>;
}
//# sourceMappingURL=serviceClientCredentials.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"serviceClientCredentials.d.ts","sourceRoot":"","sources":["../../../lib/credentials/serviceClientCredentials.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACrE"}

View file

@ -0,0 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//# sourceMappingURL=serviceClientCredentials.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"serviceClientCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/serviceClientCredentials.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F"}

View file

@ -0,0 +1,25 @@
import { WebResourceLike } from "../webResource";
import { ServiceClientCredentials } from "./serviceClientCredentials";
/**
* A credentials object that uses a token string and a authorzation scheme to authenticate.
*/
export declare class TokenCredentials implements ServiceClientCredentials {
token: string;
authorizationScheme: string;
/**
* Creates a new TokenCredentials object.
*
* @constructor
* @param {string} token The token.
* @param {string} [authorizationScheme] The authorization scheme.
*/
constructor(token: string, authorizationScheme?: string);
/**
* 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): Promise<WebResourceLike>;
}
//# sourceMappingURL=tokenCredentials.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tokenCredentials.d.ts","sourceRoot":"","sources":["../../../lib/credentials/tokenCredentials.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAKtE;;GAEG;AACH,qBAAa,gBAAiB,YAAW,wBAAwB;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,MAAM,CAAgC;IAE3D;;;;;;OAMG;gBACS,KAAK,EAAE,MAAM,EAAE,mBAAmB,GAAE,MAAqC;IAQrF;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,eAAe;CAQzC"}

View file

@ -0,0 +1,42 @@
// 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";
var HeaderConstants = Constants.HeaderConstants;
var DEFAULT_AUTHORIZATION_SCHEME = "Bearer";
/**
* A credentials object that uses a token string and a authorzation scheme to authenticate.
*/
var TokenCredentials = /** @class */ (function () {
/**
* Creates a new TokenCredentials object.
*
* @constructor
* @param {string} token The token.
* @param {string} [authorizationScheme] The authorization scheme.
*/
function TokenCredentials(token, authorizationScheme) {
if (authorizationScheme === void 0) { authorizationScheme = DEFAULT_AUTHORIZATION_SCHEME; }
this.authorizationScheme = 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.
*/
TokenCredentials.prototype.signRequest = function (webResource) {
if (!webResource.headers)
webResource.headers = new HttpHeaders();
webResource.headers.set(HeaderConstants.AUTHORIZATION, this.authorizationScheme + " " + this.token);
return Promise.resolve(webResource);
};
return TokenCredentials;
}());
export { TokenCredentials };
//# sourceMappingURL=tokenCredentials.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tokenCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/tokenCredentials.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F;AAE/F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI9C,IAAM,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AAClD,IAAM,4BAA4B,GAAG,QAAQ,CAAC;AAE9C;;GAEG;AACH;IAIE;;;;;;OAMG;IACH,0BAAY,KAAa,EAAE,mBAA0D;QAA1D,oCAAA,EAAA,kDAA0D;QATrF,wBAAmB,GAAW,4BAA4B,CAAC;QAUzD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACvD;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,sCAAW,GAAX,UAAY,WAA4B;QACtC,IAAI,CAAC,WAAW,CAAC,OAAO;YAAE,WAAW,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClE,WAAW,CAAC,OAAO,CAAC,GAAG,CACrB,eAAe,CAAC,aAAa,EAC1B,IAAI,CAAC,mBAAmB,SAAI,IAAI,CAAC,KAAO,CAC5C,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IACH,uBAAC;AAAD,CAAC,AAjCD,IAiCC"}

View file

@ -0,0 +1,10 @@
/**
* 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;
}
//# sourceMappingURL=tokenResponse.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tokenResponse.d.ts","sourceRoot":"","sources":["../../../lib/credentials/tokenResponse.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAC3B"}

View file

@ -0,0 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//# sourceMappingURL=tokenResponse.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"tokenResponse.js","sourceRoot":"","sources":["../../../lib/credentials/tokenResponse.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F"}

View file

@ -0,0 +1,11 @@
import { ApiKeyCredentials } from "./apiKeyCredentials";
export declare class TopicCredentials extends ApiKeyCredentials {
/**
* Creates a new EventGrid TopicCredentials object.
*
* @constructor
* @param {string} topicKey The EventGrid topic key
*/
constructor(topicKey: string);
}
//# sourceMappingURL=topicCredentials.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"topicCredentials.d.ts","sourceRoot":"","sources":["../../../lib/credentials/topicCredentials.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAEjF,qBAAa,gBAAiB,SAAQ,iBAAiB;IACrD;;;;;OAKG;gBACS,QAAQ,EAAE,MAAM;CAW7B"}

View file

@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
import { __extends } from "tslib";
import { ApiKeyCredentials } from "./apiKeyCredentials";
var TopicCredentials = /** @class */ (function (_super) {
__extends(TopicCredentials, _super);
/**
* Creates a new EventGrid TopicCredentials object.
*
* @constructor
* @param {string} topicKey The EventGrid topic key
*/
function TopicCredentials(topicKey) {
var _this = this;
if (!topicKey || (topicKey && typeof topicKey !== "string")) {
throw new Error("topicKey cannot be null or undefined and must be of type string.");
}
var options = {
inHeader: {
"aeg-sas-key": topicKey,
},
};
_this = _super.call(this, options) || this;
return _this;
}
return TopicCredentials;
}(ApiKeyCredentials));
export { TopicCredentials };
//# sourceMappingURL=topicCredentials.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"topicCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/topicCredentials.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,OAAO,EAAE,iBAAiB,EAA2B,MAAM,qBAAqB,CAAC;AAEjF;IAAsC,oCAAiB;IACrD;;;;;OAKG;IACH,0BAAY,QAAgB;QAA5B,iBAUC;QATC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,EAAE;YAC3D,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QACD,IAAM,OAAO,GAA4B;YACvC,QAAQ,EAAE;gBACR,aAAa,EAAE,QAAQ;aACxB;SACF,CAAC;QACF,QAAA,kBAAM,OAAO,CAAC,SAAC;;IACjB,CAAC;IACH,uBAAC;AAAD,CAAC,AAlBD,CAAsC,iBAAiB,GAkBtD"}