uuid-apikey type definitions (#41527)

* initial commit

* Testing

* headers

* header fixes
This commit is contained in:
Ben Allfree
2020-01-16 13:20:45 -05:00
committed by Eli Barzilay
parent 28897f7536
commit 7ecea94027
4 changed files with 62 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for uuid-apikey 1.4
// Project: https://github.com/chronosis/uuid-apikey
// Definitions by: Ben Allfree <https://github.com/benallfree>
// 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<UUIDOptions>): string;
toUUID(apiKey: string): string;
check(apiKey: string, uuid: string): boolean;
create(options?: Partial<UUIDOptions>): ApiKeyInfo;
}
declare let obj: UUIDAPIKey;
export default obj;
+23
View 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",
"uuid-apikey-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5
View File
@@ -0,0 +1,5 @@
import uuidApiKey from 'uuid-apikey';
const info = uuidApiKey.create();
const isValid = uuidApiKey.check(info.apiKey, info.uuid);
// true