UNPKG

3.86 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as querystring from "querystring";
3import { CacheProvider as InMemoryCacheProvider } from "./inmemory-cache-provider";
4import { ParsedQs } from "qs";
5import { SamlOptions } from "./types";
6import { AuthenticateOptions, AuthorizeOptions, Profile, SamlConfig } from "../passport-saml/types";
7interface NameID {
8 value: string | null;
9 format: string | null;
10}
11declare class SAML {
12 options: SamlOptions;
13 cacheProvider: InMemoryCacheProvider;
14 constructor(ctorOptions: SamlConfig);
15 initialize(ctorOptions: SamlConfig): SamlOptions;
16 private getCallbackUrl;
17 _generateUniqueID(): string;
18 private generateInstant;
19 private signRequest;
20 private generateAuthorizeRequestAsync;
21 _generateLogoutRequest(user: Profile): Promise<string>;
22 _generateLogoutResponse(logoutRequest: Profile): string;
23 _requestToUrlAsync(request: string | null | undefined, response: string | null, operation: string, additionalParameters: querystring.ParsedUrlQuery): Promise<string>;
24 _getAdditionalParams(RelayState: string, operation: string, overrideParams?: querystring.ParsedUrlQuery): querystring.ParsedUrlQuery;
25 getAuthorizeUrlAsync(RelayState: string, host: string | undefined, options: AuthorizeOptions): Promise<string>;
26 getAuthorizeFormAsync(RelayState: string, host?: string): Promise<string>;
27 getLogoutUrlAsync(user: Profile, RelayState: string, options: AuthenticateOptions & AuthorizeOptions): Promise<string>;
28 getLogoutResponseUrl(samlLogoutRequest: Profile, RelayState: string, options: AuthenticateOptions & AuthorizeOptions, callback: (err: Error | null, url?: string | null) => void): void;
29 private getLogoutResponseUrlAsync;
30 _certToPEM(cert: string): string;
31 private certsToCheck;
32 validateSignature(fullXml: string, currentNode: Element, certs: string[]): boolean;
33 validatePostResponseAsync(container: Record<string, string>): Promise<{
34 profile?: Profile | null;
35 loggedOut?: boolean;
36 }>;
37 private validateInResponseTo;
38 validateRedirectAsync(container: ParsedQs, originalQuery: string | null): Promise<{
39 profile?: Profile | null;
40 loggedOut?: boolean;
41 }>;
42 private hasValidSignatureForRedirect;
43 private validateSignatureForRedirect;
44 private verifyLogoutRequest;
45 private verifyLogoutResponse;
46 private verifyIssuer;
47 private processValidlySignedAssertionAsync;
48 private checkTimestampsValidityError;
49 private checkAudienceValidityError;
50 validatePostRequestAsync(container: Record<string, string>): Promise<{
51 profile?: Profile;
52 loggedOut?: boolean;
53 }>;
54 _getNameIdAsync(self: SAML, doc: Node): Promise<NameID>;
55 generateServiceProviderMetadata(decryptionCert: string | null, signingCert?: string | null): string;
56 _keyToPEM(key: string | Buffer): typeof key extends string | Buffer ? string | Buffer : Error;
57 /**
58 * Process max age assertion and use it if it is more restrictive than the NotOnOrAfter age
59 * assertion received in the SAMLResponse.
60 *
61 * @param maxAssertionAgeMs Max time after IssueInstant that we will accept assertion, in Ms.
62 * @param notOnOrAfter Expiration provided in response.
63 * @param issueInstant Time when response was issued.
64 * @returns {*} The expiration time to be used, in Ms.
65 */
66 private processMaxAgeAssertionTime;
67 /**
68 * Convert a date string to a timestamp (in milliseconds).
69 *
70 * @param dateString A string representation of a date
71 * @param label Descriptive name of the date being passed in, e.g. "NotOnOrAfter"
72 * @throws Will throw an error if parsing `dateString` returns `NaN`
73 * @returns {number} The timestamp (in milliseconds) representation of the given date
74 */
75 private dateStringToTimestamp;
76}
77export { SAML };