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,148 @@
import { AuthorityType } from "./AuthorityType";
import { IUri } from "../url/IUri";
import { INetworkModule } from "../network/INetworkModule";
import { ProtocolMode } from "./ProtocolMode";
import { ICacheManager } from "../cache/interface/ICacheManager";
import { AuthorityOptions } from "./AuthorityOptions";
import { CloudDiscoveryMetadata } from "./CloudDiscoveryMetadata";
/**
* The authority class validates the authority URIs used by the user, and retrieves the OpenID Configuration Data from the
* endpoint. It will store the pertinent config data in this object for use during token calls.
*/
export declare class Authority {
private _canonicalAuthority;
private _canonicalAuthorityUrlComponents;
protected networkInterface: INetworkModule;
protected cacheManager: ICacheManager;
private authorityOptions;
private metadata;
constructor(authority: string, networkInterface: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions);
get authorityType(): AuthorityType;
/**
* ProtocolMode enum representing the way endpoints are constructed.
*/
get protocolMode(): ProtocolMode;
/**
* Returns authorityOptions which can be used to reinstantiate a new authority instance
*/
get options(): AuthorityOptions;
/**
* A URL that is the authority set by the developer
*/
get canonicalAuthority(): string;
/**
* Sets canonical authority.
*/
set canonicalAuthority(url: string);
/**
* Get authority components.
*/
get canonicalAuthorityUrlComponents(): IUri;
/**
* Get hostname and port i.e. login.microsoftonline.com
*/
get hostnameAndPort(): string;
/**
* Get tenant for authority.
*/
get tenant(): string;
/**
* OAuth /authorize endpoint for requests
*/
get authorizationEndpoint(): string;
/**
* OAuth /token endpoint for requests
*/
get tokenEndpoint(): string;
get deviceCodeEndpoint(): string;
/**
* OAuth logout endpoint for requests
*/
get endSessionEndpoint(): string;
/**
* OAuth issuer for requests
*/
get selfSignedJwtAudience(): string;
/**
* Replaces tenant in url path with current tenant. Defaults to common.
* @param urlString
*/
private replaceTenant;
/**
* Replaces path such as tenant or policy with the current tenant or policy.
* @param urlString
*/
private replacePath;
/**
* The default open id configuration endpoint for any canonical authority.
*/
protected get defaultOpenIdConfigurationEndpoint(): string;
/**
* Boolean that returns whethr or not tenant discovery has been completed.
*/
discoveryComplete(): boolean;
/**
* Perform endpoint discovery to discover aliases, preferred_cache, preferred_network
* and the /authorize, /token and logout endpoints.
*/
resolveEndpointsAsync(): Promise<void>;
/**
* Update AuthorityMetadataEntity with new endpoints and return where the information came from
* @param metadataEntity
*/
private updateEndpointMetadata;
/**
* Compares the number of url components after the domain to determine if the cached authority metadata can be used for the requested authority
* Protects against same domain different authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
* @param metadataEntity
*/
private isAuthoritySameType;
/**
* Parse authorityMetadata config option
*/
private getEndpointMetadataFromConfig;
/**
* Gets OAuth endpoints from the given OpenID configuration endpoint.
*/
private getEndpointMetadataFromNetwork;
/**
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache and returns where the information was retrived from
* @param cachedMetadata
* @param newMetadata
*/
private updateCloudDiscoveryMetadata;
/**
* Parse cloudDiscoveryMetadata config or check knownAuthorities
*/
private getCloudDiscoveryMetadataFromConfig;
/**
* Called to get metadata from network if CloudDiscoveryMetadata was not populated by config
* @param networkInterface
*/
private getCloudDiscoveryMetadataFromNetwork;
/**
* Helper function to determine if this host is included in the knownAuthorities config option
*/
private isInKnownAuthorities;
/**
* Creates cloud discovery metadata object from a given host
* @param host
*/
static createCloudDiscoveryMetadataFromHost(host: string): CloudDiscoveryMetadata;
/**
* Searches instance discovery network response for the entry that contains the host in the aliases list
* @param response
* @param authority
*/
static getCloudDiscoveryMetadataFromNetworkResponse(response: CloudDiscoveryMetadata[], authority: string): CloudDiscoveryMetadata | null;
/**
* helper function to generate environment from authority object
*/
getPreferredCache(): string;
/**
* Returns whether or not the provided host is an alias of this authority instance
* @param host
*/
isAlias(host: string): boolean;
}
//# sourceMappingURL=Authority.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Authority.d.ts","sourceRoot":"","sources":["../../src/authority/Authority.ts"],"names":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ED,IAAW,kBAAkB,IAAI,MAAM,CAOtC;IAED;;OAEG;IACH,IAAW,kBAAkB,IAAI,MAAM,CAOtC;IAED;;OAEG;IACH,IAAW,qBAAqB,IAAI,MAAM,CAOzC;IAED;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAgBnB;;OAEG;IACH,SAAS,KAAK,kCAAkC,IAAI,MAAM,CAKzD;IAED;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;;OAGG;IACU,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBnD;;;OAGG;YACW,sBAAsB;IAqBpC;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,6BAA6B;IAYrC;;OAEG;YACW,8BAA8B;IAS5C;;;;OAIG;YACW,4BAA4B;IAuB1C;;OAEG;IACH,OAAO,CAAC,mCAAmC;IAsB3C;;;OAGG;YACW,oCAAoC;IAkBlD;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;;OAGG;IACH,MAAM,CAAC,oCAAoC,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB;IAQjF;;;;OAIG;IACH,MAAM,CAAC,4CAA4C,CAAC,QAAQ,EAAE,sBAAsB,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAWzI;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAQ3B;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGjC"}

View File

@@ -0,0 +1,29 @@
import { Authority } from "./Authority";
import { INetworkModule } from "../network/INetworkModule";
import { ICacheManager } from "../cache/interface/ICacheManager";
import { AuthorityOptions } from "./AuthorityOptions";
export declare class AuthorityFactory {
/**
* Create an authority object of the correct type based on the url
* Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
*
* Also performs endpoint discovery.
*
* @param authorityUri
* @param networkClient
* @param protocolMode
*/
static createDiscoveredInstance(authorityUri: string, networkClient: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions): Promise<Authority>;
/**
* Create an authority object of the correct type based on the url
* Performs basic authority validation - checks to see if the authority is of a valid type (i.e. aad, b2c, adfs)
*
* Does not perform endpoint discovery.
*
* @param authorityUrl
* @param networkInterface
* @param protocolMode
*/
static createInstance(authorityUrl: string, networkInterface: INetworkModule, cacheManager: ICacheManager, authorityOptions: AuthorityOptions): Authority;
}
//# sourceMappingURL=AuthorityFactory.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AuthorityFactory.d.ts","sourceRoot":"","sources":["../../src/authority/AuthorityFactory.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,qBAAa,gBAAgB;IAEzB;;;;;;;;;OASG;WACU,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAY/K;;;;;;;;;OASG;IACH,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,SAAS;CAQ5J"}

View File

@@ -0,0 +1,8 @@
import { ProtocolMode } from "./ProtocolMode";
export declare type AuthorityOptions = {
protocolMode: ProtocolMode;
knownAuthorities: Array<string>;
cloudDiscoveryMetadata: string;
authorityMetadata: string;
};
//# sourceMappingURL=AuthorityOptions.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AuthorityOptions.d.ts","sourceRoot":"","sources":["../../src/authority/AuthorityOptions.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,oBAAY,gBAAgB,GAAG;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;CAC7B,CAAC"}

View File

@@ -0,0 +1,8 @@
/**
* Authority types supported by MSAL.
*/
export declare enum AuthorityType {
Default = 0,
Adfs = 1
}
//# sourceMappingURL=AuthorityType.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AuthorityType.d.ts","sourceRoot":"","sources":["../../src/authority/AuthorityType.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,aAAa;IACrB,OAAO,IAAA;IACP,IAAI,IAAA;CACP"}

View File

@@ -0,0 +1,6 @@
export declare type CloudDiscoveryMetadata = {
preferred_network: string;
preferred_cache: string;
aliases: Array<string>;
};
//# sourceMappingURL=CloudDiscoveryMetadata.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CloudDiscoveryMetadata.d.ts","sourceRoot":"","sources":["../../src/authority/CloudDiscoveryMetadata.ts"],"names":[],"mappings":"AAKA,oBAAY,sBAAsB,GAAG;IACjC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B,CAAC"}

View File

@@ -0,0 +1,10 @@
import { CloudDiscoveryMetadata } from "./CloudDiscoveryMetadata";
/**
* The OpenID Configuration Endpoint Response type. Used by the authority class to get relevant OAuth endpoints.
*/
export declare type CloudInstanceDiscoveryResponse = {
tenant_discovery_endpoint: string;
metadata: Array<CloudDiscoveryMetadata>;
};
export declare function isCloudInstanceDiscoveryResponse(response: object): boolean;
//# sourceMappingURL=CloudInstanceDiscoveryResponse.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CloudInstanceDiscoveryResponse.d.ts","sourceRoot":"","sources":["../../src/authority/CloudInstanceDiscoveryResponse.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;GAEG;AACH,oBAAY,8BAA8B,GAAG;IACzC,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;CAC3C,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAK1E"}

View File

@@ -0,0 +1,11 @@
/**
* Tenant Discovery Response which contains the relevant OAuth endpoints and data needed for authentication and authorization.
*/
export declare type OpenIdConfigResponse = {
authorization_endpoint: string;
token_endpoint: string;
end_session_endpoint: string;
issuer: string;
};
export declare function isOpenIdConfigResponse(response: object): boolean;
//# sourceMappingURL=OpenIdConfigResponse.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"OpenIdConfigResponse.d.ts","sourceRoot":"","sources":["../../src/authority/OpenIdConfigResponse.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,oBAAoB,GAAG;IAC/B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOhE"}

View File

@@ -0,0 +1,8 @@
/**
* Protocol modes supported by MSAL.
*/
export declare enum ProtocolMode {
AAD = "AAD",
OIDC = "OIDC"
}
//# sourceMappingURL=ProtocolMode.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ProtocolMode.d.ts","sourceRoot":"","sources":["../../src/authority/ProtocolMode.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,oBAAY,YAAY;IACpB,GAAG,QAAQ;IACX,IAAI,SAAS;CAChB"}