[duo_web_sdk] Add new typing for duo_web_sdk (#41887)

* Add new typing for duo_web_sdk

* Fix functions
This commit is contained in:
Heok Hong Low
2020-01-27 10:58:10 -08:00
committed by Wesley Wigham
parent 623e54f1e7
commit e21cf45ff1
4 changed files with 76 additions and 0 deletions
+21
View File
@@ -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");
+30
View File
@@ -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 <https://github.com/lhhong>
// 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;
+24
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }