diff --git a/types/alks-node/alks-node-tests.ts b/types/alks-node/alks-node-tests.ts new file mode 100644 index 0000000000..8180073cf7 --- /dev/null +++ b/types/alks-node/alks-node-tests.ts @@ -0,0 +1,48 @@ +import { + Auth, + Account, + AwsKey, + createIamKey, + createIamRole, + createIamTrustRole, + createKey, + createLongTermKey, + deleteIamRole, + deleteLongTermKey, + generateConsoleUrl, + getAccounts, + getDurations, + getIamRoleTypes, + refreshTokenToAccessToken, +} from 'alks-node'; + +const auth: Auth = { + password: 'pass', + token: 'token', +}; + +const acct: Account = { + alksAccount: 'alksAcct', + alksRole: 'alksRole', + server: 'server', + userid: 'userId', +}; + +const awsKey: AwsKey = { + accessKey: 'accessKey', + secretKey: 'secretKey', + sessionToken: 'sessionToken', +}; + +createIamKey(acct, auth, 1, {}, () => {}); +createIamRole(acct, auth, 'roleName', 'roleType', true, {}, () => {}); +createIamTrustRole(acct, auth, 'roleName', 'roleType', 'trustArn', {}, () => {}); +createKey(acct, auth, 1, {}, () => {}); +createLongTermKey(acct, auth, 'iamUserName', {}, () => {}); +deleteIamRole(acct, auth, 'roleName', {}, () => {}); +deleteLongTermKey(acct, auth, 'iamUserName', {}, () => {}); +generateConsoleUrl(awsKey, {}, () => {}); +getAccounts('server', 'userId', auth, {}, () => {}); +getDurations(acct, auth, {}, () => {}); +getIamRoleTypes('server', 'userId', auth, {}, () => {}); +refreshTokenToAccessToken(acct, 'token', {}, () => {}); diff --git a/types/alks-node/index.d.ts b/types/alks-node/index.d.ts new file mode 100644 index 0000000000..d61101dabf --- /dev/null +++ b/types/alks-node/index.d.ts @@ -0,0 +1,125 @@ +// Type definitions for alks-node 0.9 +// Project: https://github.com/Cox-Automotive/alks-node#readme +// Definitions by: Matt Hoang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Moment } from 'moment'; + +export interface Auth { + token?: string; + password?: string; +} +export interface Account { + userid: string; + server: string; + alksAccount: string; + alksRole: string; +} +export interface AlksAccount { + account: string; + role: string; + iam?: boolean; +} +export interface LongTermKeyData { + accessKey: string; + secretKey: string; + iamUserName: string; + iamUserArn: string; + alksAccount: string; + alksRole: string; +} +export interface KeyData { + accessKey: string; + secretKey: string; + sessionToken: string; + alksAccount: string; + alksRole: string; + sessionTime: string; + expires: Moment; +} +export interface AwsKey { + accessKey: string; + secretKey: string; + sessionToken: string; +} +export function getDurations( + account: Account, + auth: Auth, + opts: object, + callback: (err: Error, duration: number[]) => void +): void; +export function createKey( + account: Account, + auth: Auth, + duration: number, + opts: object, + callback: (err: Error, key: KeyData) => void +): void; +export function createIamKey( + account: Account, + auth: Auth, + duration: number, + opts: object, + callback: (err: Error, key: KeyData) => void +): void; +export function createLongTermKey( + account: Account, + auth: Auth, + iamUserName: string, + opts: object, + callback: (err: Error, data: LongTermKeyData) => void +): void; +export function createIamRole( + account: Account, + auth: Auth, + roleName: string, + roleType: string, + includeDefaultPolicies: boolean, + opts: object, + callback: (err: Error, body: any) => void +): void; +export function createIamTrustRole( + account: Account, + auth: Auth, + roleName: string, + roleType: string, + trustArn: string, + opts: object, + callback: (err: Error, body: any) => void +): void; +export function getAccounts( + server: string, + userid: string, + auth: Auth, + opts: object, + callback: (err: Error, accounts: AlksAccount[]) => void +): void; +export function getIamRoleTypes( + server: string, + userid: string, + auth: Auth, + opts: object, + callback: (err: Error, body: any) => void +): void; +export function generateConsoleUrl(key: AwsKey, opts: object, callback: (err: Error, url: string) => void): void; +export function deleteIamRole( + account: Account, + auth: Auth, + roleName: string, + opts: object, + callback: (err: Error, body: any) => void +): void; +export function deleteLongTermKey( + account: Account, + auth: Auth, + iamUserName: string, + opts: object, + callback: (err: Error, body: any) => void +): void; +export function refreshTokenToAccessToken( + account: Account, + token: string, + opts: object, + callback: (err: Error, body: any) => void +): void; diff --git a/types/alks-node/package.json b/types/alks-node/package.json new file mode 100644 index 0000000000..7811d9a9ba --- /dev/null +++ b/types/alks-node/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "moment": ">=2.15.2" + } +} \ No newline at end of file diff --git a/types/alks-node/tsconfig.json b/types/alks-node/tsconfig.json new file mode 100644 index 0000000000..8b7769cf46 --- /dev/null +++ b/types/alks-node/tsconfig.json @@ -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", + "alks-node-tests.ts" + ] +} diff --git a/types/alks-node/tslint.json b/types/alks-node/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/alks-node/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }