diff --git a/types/duo_web_sdk/duo_web_sdk-tests.ts b/types/duo_web_sdk/duo_web_sdk-tests.ts new file mode 100644 index 0000000000..1ba04f6970 --- /dev/null +++ b/types/duo_web_sdk/duo_web_sdk-tests.ts @@ -0,0 +1,21 @@ +import * as Duo from "duo_web_sdk"; + +Duo.init({ + host: "http://example.com", + sig_request: "sig_request", + iframe: "iframe_id", + iframeContainer: "container_id", + iframeAttributes: { + title: "title", + height: "200px", + width: "200px", + }, + post_action: "/post_destination", + post_argument: "post_argument", + submit_callback: (duo_form: HTMLFormElement) => duo_form, +}); + +Duo._onReady(() => {}); +Duo._parseSigRequest("sig"); +Duo._isDuoMessage(new MessageEvent("event")); +Duo._doPostBack("response"); diff --git a/types/duo_web_sdk/index.d.ts b/types/duo_web_sdk/index.d.ts new file mode 100644 index 0000000000..6fdeb95315 --- /dev/null +++ b/types/duo_web_sdk/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for non-npm package duo_web_sdk-browser 2.7 +// Project: https://github.com/duosecurity/duo_web_sdk +// Definitions by: Low Heok Hong +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace Duo; + +export interface InitOptions { + host: string; + sig_request: string; + iframe?: string | HTMLIFrameElement; + iframeContainer?: string | HTMLElement; + iframeAttributes?: object; + post_action?: string; + post_argument?: string; + submit_callback?: (duo_form: HTMLFormElement) => void; +} + +export interface ParsedSig { + sigRequest: string; + duoSig: string; + appSig: string; +} + +export function init(options: InitOptions): void; + +export function _onReady(callback: () => void): void; +export function _parseSigRequest(sig: string): ParsedSig; +export function _isDuoMessage(event: MessageEvent): boolean; +export function _doPostBack(response: string): void; diff --git a/types/duo_web_sdk/tsconfig.json b/types/duo_web_sdk/tsconfig.json new file mode 100644 index 0000000000..5120d09b4b --- /dev/null +++ b/types/duo_web_sdk/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "duo_web_sdk-tests.ts" + ] +} diff --git a/types/duo_web_sdk/tslint.json b/types/duo_web_sdk/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/duo_web_sdk/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }