mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
passport-saml-metadata: new package (#43964)
* feat(passport-saml-metadata): Define new Package refact: Better Interfaces * refact: Clean Overeager Generics * style: mirror lib hierarchy Co-authored-by: gfournier <gfournier@focusoptimization.com>
This commit is contained in:
parent
031f592cc7
commit
5cfcaa22e3
7
types/passport-saml-metadata/index.d.ts
vendored
Normal file
7
types/passport-saml-metadata/index.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
// Type definitions for passport-saml-metadata 2.2
|
||||
// Project: https://github.com/compwright/passport-saml-metadata#readme
|
||||
// Definitions by: Gabriel Fournier <https://github.com/carboneater>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.8
|
||||
|
||||
export * from "./src";
|
||||
21
types/passport-saml-metadata/passport-saml-metadata-tests.ts
Normal file
21
types/passport-saml-metadata/passport-saml-metadata-tests.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { claimsToCamelCase, fetch, metadata, MetadataReader, toPassportConfig } from "passport-saml-metadata/src";
|
||||
import { Profile, Strategy, VerifiedCallback } from "passport-saml";
|
||||
|
||||
// From README Example
|
||||
fetch({ url: "https:saml.test.com/metadata.xml" }).then(
|
||||
(reader) => {
|
||||
const config = toPassportConfig(reader);
|
||||
config.protocol = 'saml2';
|
||||
|
||||
new Strategy(config, (profile: Profile, done: VerifiedCallback) => {
|
||||
profile = claimsToCamelCase(profile, reader.claimSchema);
|
||||
done(null, profile);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const reader = new MetadataReader("xml string");
|
||||
const otherReader = new MetadataReader("Other String", {authnRequestBinding: "HTTP-POST", throwExceptions: true});
|
||||
const config = toPassportConfig(reader, {multipleCerts : true});
|
||||
|
||||
metadata(config)(); // matches the code, not the doc
|
||||
12
types/passport-saml-metadata/src/fetch.d.ts
vendored
Normal file
12
types/passport-saml-metadata/src/fetch.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
export interface FetchAxiosConfig {
|
||||
backupStore: Map<string, string>;
|
||||
responseType: string;
|
||||
timeout: number;
|
||||
}
|
||||
|
||||
export type FetchConfig = {
|
||||
client?: {get(url: string, params?: Partial<FetchAxiosConfig>): Promise<{data: string}>};
|
||||
url: string;
|
||||
} & Partial<FetchAxiosConfig>;
|
||||
|
||||
export function fetch(config: FetchConfig): Promise<string>;
|
||||
7
types/passport-saml-metadata/src/index.d.ts
vendored
Normal file
7
types/passport-saml-metadata/src/index.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { FetchConfig } from "./fetch";
|
||||
import { MetadataReader } from "./reader";
|
||||
|
||||
export function fetch(config: FetchConfig): Promise<MetadataReader>;
|
||||
export { metadata } from "./metadata";
|
||||
export { claimsToCamelCase, toPassportConfig } from "./passport";
|
||||
export { MetadataReader } from "./reader";
|
||||
3
types/passport-saml-metadata/src/metadata.d.ts
vendored
Normal file
3
types/passport-saml-metadata/src/metadata.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { SamlConfig } from "passport-saml";
|
||||
|
||||
export function metadata(config: SamlConfig): (() => void);
|
||||
6
types/passport-saml-metadata/src/passport.d.ts
vendored
Normal file
6
types/passport-saml-metadata/src/passport.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import { SamlConfig } from "passport-saml";
|
||||
import { MetadataReader } from "./reader";
|
||||
|
||||
export function claimsToCamelCase(claims: any, claimSchema: any): any;
|
||||
|
||||
export function toPassportConfig(reader?: MetadataReader, options?: { multipleCerts: boolean }): SamlConfig;
|
||||
15
types/passport-saml-metadata/src/reader.d.ts
vendored
Normal file
15
types/passport-saml-metadata/src/reader.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
export interface MetadataConstructorOptions {
|
||||
authnRequestBinding: string;
|
||||
throwExceptions: boolean;
|
||||
}
|
||||
export class MetadataReader {
|
||||
constructor(metadata: string, options?: Partial<MetadataConstructorOptions>);
|
||||
get claimSchema(): {[name: string]: { camelCase: string; description: string; name: string; }};
|
||||
get encryptionCert(): string|undefined;
|
||||
get encryptionCerts(): string[];
|
||||
get identifierFormat(): string|undefined;
|
||||
get identityProviderUrl(): string|undefined;
|
||||
get logoutUrl(): string|undefined;
|
||||
get signingCert(): string|undefined;
|
||||
get signingCerts(): string[];
|
||||
}
|
||||
23
types/passport-saml-metadata/tsconfig.json
Normal file
23
types/passport-saml-metadata/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"passport-saml-metadata-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/passport-saml-metadata/tslint.json
Normal file
1
types/passport-saml-metadata/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user