From 7ecea940271b347c79466e321956133c8bd75675 Mon Sep 17 00:00:00 2001 From: Ben Allfree Date: Thu, 16 Jan 2020 08:20:45 -1000 Subject: [PATCH] uuid-apikey type definitions (#41527) * initial commit * Testing * headers * header fixes --- types/uuid-apikey/index.d.ts | 33 ++++++++++++++++++++++++++ types/uuid-apikey/tsconfig.json | 23 ++++++++++++++++++ types/uuid-apikey/tslint.json | 1 + types/uuid-apikey/uuid-apikey-tests.ts | 5 ++++ 4 files changed, 62 insertions(+) create mode 100644 types/uuid-apikey/index.d.ts create mode 100644 types/uuid-apikey/tsconfig.json create mode 100644 types/uuid-apikey/tslint.json create mode 100644 types/uuid-apikey/uuid-apikey-tests.ts diff --git a/types/uuid-apikey/index.d.ts b/types/uuid-apikey/index.d.ts new file mode 100644 index 0000000000..cfed3c0e24 --- /dev/null +++ b/types/uuid-apikey/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for uuid-apikey 1.4 +// Project: https://github.com/chronosis/uuid-apikey +// Definitions by: Ben Allfree +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface UUIDOptions { + noDashes: boolean; +} + +export interface ApiKeyInfo { + uuid: string; + apiKey: string; +} + +declare class UUIDAPIKey { + checkDashes(positions: number[], str: string): boolean; + + isUUID(uuid: string): boolean; + + isAPIKey(apiKey: string): boolean; + + toAPIKey(uuid: string, options?: Partial): string; + + toUUID(apiKey: string): string; + + check(apiKey: string, uuid: string): boolean; + + create(options?: Partial): ApiKeyInfo; +} + +declare let obj: UUIDAPIKey; + +export default obj; diff --git a/types/uuid-apikey/tsconfig.json b/types/uuid-apikey/tsconfig.json new file mode 100644 index 0000000000..9fa16c89f5 --- /dev/null +++ b/types/uuid-apikey/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", + "uuid-apikey-tests.ts" + ] +} diff --git a/types/uuid-apikey/tslint.json b/types/uuid-apikey/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/uuid-apikey/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/uuid-apikey/uuid-apikey-tests.ts b/types/uuid-apikey/uuid-apikey-tests.ts new file mode 100644 index 0000000000..a1e64408af --- /dev/null +++ b/types/uuid-apikey/uuid-apikey-tests.ts @@ -0,0 +1,5 @@ +import uuidApiKey from 'uuid-apikey'; + +const info = uuidApiKey.create(); +const isValid = uuidApiKey.check(info.apiKey, info.uuid); +// true