modules inc

This commit is contained in:
nannal
2021-07-15 23:10:20 +03:00
parent 6bb353de89
commit 5921b02b7c
845 changed files with 105299 additions and 121 deletions

View File

@@ -0,0 +1,30 @@
import { NetworkResponse } from "./NetworkManager";
/**
* Options allowed by network request APIs.
*/
export declare type NetworkRequestOptions = {
headers?: Record<string, string>;
body?: string;
};
/**
* Client network interface to send backend requests.
* @interface
*/
export interface INetworkModule {
/**
* Interface function for async network "GET" requests. Based on the Fetch standard: https://fetch.spec.whatwg.org/
* @param url
* @param requestParams
* @param enableCaching
*/
sendGetRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
/**
* Interface function for async network "POST" requests. Based on the Fetch standard: https://fetch.spec.whatwg.org/
* @param url
* @param requestParams
* @param enableCaching
*/
sendPostRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
}
export declare const StubbedNetworkModule: INetworkModule;
//# sourceMappingURL=INetworkModule.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"INetworkModule.d.ts","sourceRoot":"","sources":["../../src/network/INetworkModule.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,oBAAY,qBAAqB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,cAAc;IAE3B;;;;;OAKG;IACH,mBAAmB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAElG;;;;;OAKG;IACH,oBAAoB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CACtG;AAED,eAAO,MAAM,oBAAoB,EAAE,cASlC,CAAC"}

View File

@@ -0,0 +1,21 @@
import { INetworkModule, NetworkRequestOptions } from "./INetworkModule";
import { RequestThumbprint } from "./RequestThumbprint";
import { CacheManager } from "../cache/CacheManager";
export declare type NetworkResponse<T> = {
headers: Record<string, string>;
body: T;
status: number;
};
export declare class NetworkManager {
private networkClient;
private cacheManager;
constructor(networkClient: INetworkModule, cacheManager: CacheManager);
/**
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
* @param thumbprint
* @param tokenEndpoint
* @param options
*/
sendPostRequest<T>(thumbprint: RequestThumbprint, tokenEndpoint: string, options: NetworkRequestOptions): Promise<NetworkResponse<T>>;
}
//# sourceMappingURL=NetworkManager.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NetworkManager.d.ts","sourceRoot":"","sources":["../../src/network/NetworkManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,oBAAY,eAAe,CAAC,CAAC,IAAI;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,cAAc;IACvB,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,YAAY,CAAe;gBAEvB,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY;IAKrE;;;;;OAKG;IACG,eAAe,CAAC,CAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CAS9I"}

View File

@@ -0,0 +1,10 @@
/**
* Type representing a unique request thumbprint.
*/
export declare type RequestThumbprint = {
clientId: string;
authority: string;
scopes: Array<string>;
homeAccountIdentifier?: string;
};
//# sourceMappingURL=RequestThumbprint.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"RequestThumbprint.d.ts","sourceRoot":"","sources":["../../src/network/RequestThumbprint.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,iBAAiB,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC"}

View File

@@ -0,0 +1,41 @@
import { NetworkResponse } from "./NetworkManager";
import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse";
import { CacheManager } from "../cache/CacheManager";
import { RequestThumbprint } from "./RequestThumbprint";
export declare class ThrottlingUtils {
/**
* Prepares a RequestThumbprint to be stored as a key.
* @param thumbprint
*/
static generateThrottlingStorageKey(thumbprint: RequestThumbprint): string;
/**
* Performs necessary throttling checks before a network request.
* @param cacheManager
* @param thumbprint
*/
static preProcess(cacheManager: CacheManager, thumbprint: RequestThumbprint): void;
/**
* Performs necessary throttling checks after a network request.
* @param cacheManager
* @param thumbprint
* @param response
*/
static postProcess(cacheManager: CacheManager, thumbprint: RequestThumbprint, response: NetworkResponse<ServerAuthorizationTokenResponse>): void;
/**
* Checks a NetworkResponse object's status codes against 429 or 5xx
* @param response
*/
static checkResponseStatus(response: NetworkResponse<ServerAuthorizationTokenResponse>): boolean;
/**
* Checks a NetworkResponse object's RetryAfter header
* @param response
*/
static checkResponseForRetryAfter(response: NetworkResponse<ServerAuthorizationTokenResponse>): boolean;
/**
* Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
* @param throttleTime
*/
static calculateThrottleTime(throttleTime: number): number;
static removeThrottle(cacheManager: CacheManager, clientId: string, authority: string, scopes: Array<string>, homeAccountIdentifier?: string): boolean;
}
//# sourceMappingURL=ThrottlingUtils.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ThrottlingUtils.d.ts","sourceRoot":"","sources":["../../src/network/ThrottlingUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,qBAAa,eAAe;IAExB;;;OAGG;IACH,MAAM,CAAC,4BAA4B,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM;IAI1E;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAalF;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,CAAC,gCAAgC,CAAC,GAAG,IAAI;IAgBhJ;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,gCAAgC,CAAC,GAAG,OAAO;IAIhG;;;OAGG;IACH,MAAM,CAAC,0BAA0B,CAAC,QAAQ,EAAE,eAAe,CAAC,gCAAgC,CAAC,GAAG,OAAO;IAOvG;;;OAGG;IACH,MAAM,CAAC,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAW1D,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,OAAO;CAWzJ"}