mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-19 16:49:45 +08:00
Merge pull request #18124 from YuJianrong/master
Add .d.ts files for npm module node-vault
This commit is contained in:
127
types/node-vault/index.d.ts
vendored
Normal file
127
types/node-vault/index.d.ts
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
// Type definitions for node-vault 0.5
|
||||
// Project: https://github.com/kr1sp1n/node-vault
|
||||
// Definitions by: Jianrong Yu <https://github.com/YuJianrong>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as mustache from "mustache";
|
||||
import * as request from "request";
|
||||
|
||||
declare namespace NodeVault {
|
||||
interface Option {
|
||||
[p: string]: any;
|
||||
}
|
||||
|
||||
interface RequestOption extends Option {
|
||||
path: string;
|
||||
method: string;
|
||||
}
|
||||
|
||||
interface functionConf {
|
||||
method: string;
|
||||
path: string;
|
||||
schema?: {
|
||||
req?: Option;
|
||||
query?: Option;
|
||||
res?: Option;
|
||||
};
|
||||
}
|
||||
|
||||
interface client {
|
||||
handleVaultResponse(res?: { statusCode: number, request: Option, body: any }): Promise<any>;
|
||||
apiVersion: string;
|
||||
endpoint: string;
|
||||
token: string;
|
||||
|
||||
request(requestOptions: RequestOption): Promise<any>;
|
||||
|
||||
help(path: string, requestOptions?: Option): Promise<any>;
|
||||
write(path: string, data: any, requestOptions?: Option): Promise<any>;
|
||||
read(path: string, requestOptions?: Option): Promise<any>;
|
||||
list(path: string, requestOptions?: Option): Promise<any>;
|
||||
delete(path: string, requestOptions?: Option): Promise<any>;
|
||||
|
||||
generateFunction(name: string, conf: functionConf): void;
|
||||
|
||||
status(options?: Option): Promise<any>;
|
||||
initialized(options?: Option): Promise<any>;
|
||||
init(options?: Option): Promise<any>;
|
||||
unseal(options?: Option): Promise<any>;
|
||||
seal(options?: Option): Promise<any>;
|
||||
generateRootStatus(options?: Option): Promise<any>;
|
||||
generateRootInit(options?: Option): Promise<any>;
|
||||
generateRootCancel(options?: Option): Promise<any>;
|
||||
generateRootUpdate(options?: Option): Promise<any>;
|
||||
mounts(options?: Option): Promise<any>;
|
||||
mount(options?: Option): Promise<any>;
|
||||
unmount(options?: Option): Promise<any>;
|
||||
remount(options?: Option): Promise<any>;
|
||||
policies(options?: Option): Promise<any>;
|
||||
addPolicy(options?: Option): Promise<any>;
|
||||
getPolicy(options?: Option): Promise<any>;
|
||||
removePolicy(options?: Option): Promise<any>;
|
||||
auths(options?: Option): Promise<any>;
|
||||
enableAuth(options?: Option): Promise<any>;
|
||||
disableAuth(options?: Option): Promise<any>;
|
||||
audits(options?: Option): Promise<any>;
|
||||
enableAudit(options?: Option): Promise<any>;
|
||||
disableAudit(options?: Option): Promise<any>;
|
||||
renew(options?: Option): Promise<any>;
|
||||
revoke(options?: Option): Promise<any>;
|
||||
revokePrefix(options?: Option): Promise<any>;
|
||||
rotate(options?: Option): Promise<any>;
|
||||
githubLogin(options?: Option): Promise<any>;
|
||||
userpassLogin(options?: Option): Promise<any>;
|
||||
tokenAccessors(options?: Option): Promise<any>;
|
||||
tokenCreate(options?: Option): Promise<any>;
|
||||
tokenCreateOrphan(options?: Option): Promise<any>;
|
||||
tokenCreateRole(options?: Option): Promise<any>;
|
||||
tokenLookup(options?: Option): Promise<any>;
|
||||
tokenLookupAccessor(options?: Option): Promise<any>;
|
||||
tokenLookupSelf(options?: Option): Promise<any>;
|
||||
tokenRenew(options?: Option): Promise<any>;
|
||||
tokenRenewSelf(options?: Option): Promise<any>;
|
||||
tokenRevoke(options?: Option): Promise<any>;
|
||||
tokenRevokeAccessor(options?: Option): Promise<any>;
|
||||
tokenRevokeOrphan(options?: Option): Promise<any>;
|
||||
tokenRevokeSelf(options?: Option): Promise<any>;
|
||||
tokenRoles(options?: Option): Promise<any>;
|
||||
addTokenRole(options?: Option): Promise<any>;
|
||||
getTokenRole(options?: Option): Promise<any>;
|
||||
removeTokenRole(options?: Option): Promise<any>;
|
||||
approleRoles(options?: Option): Promise<any>;
|
||||
addApproleRole(options?: Option): Promise<any>;
|
||||
getApproleRole(options?: Option): Promise<any>;
|
||||
deleteApproleRole(options?: Option): Promise<any>;
|
||||
getApproleRoleId(options?: Option): Promise<any>;
|
||||
updateApproleRoleId(options?: Option): Promise<any>;
|
||||
getApproleRoleSecret(options?: Option): Promise<any>;
|
||||
approleSecretAccessors(options?: Option): Promise<any>;
|
||||
approleSecretLookup(options?: Option): Promise<any>;
|
||||
approleSecretDestroy(options?: Option): Promise<any>;
|
||||
approleSecretAccessorLookup(options?: Option): Promise<any>;
|
||||
approleSecretAccessorDestroy(options?: Option): Promise<any>;
|
||||
approleLogin(options?: Option): Promise<any>;
|
||||
health(options?: Option): Promise<any>;
|
||||
leader(options?: Option): Promise<any>;
|
||||
stepDown(options?: Option): Promise<any>;
|
||||
}
|
||||
|
||||
interface VaultOptions {
|
||||
debug?(...args: any[]): any;
|
||||
tv4?(...args: any[]): any;
|
||||
commands?: Array<{ method: string, path: string, scheme: any }>;
|
||||
mustache?: MustacheStatic;
|
||||
"request-promise"?: any;
|
||||
Promise?: PromiseConstructor;
|
||||
|
||||
apiVersion?: string;
|
||||
endpoint?: string;
|
||||
token?: string;
|
||||
requestOptions?: request.CoreOptions;
|
||||
}
|
||||
}
|
||||
|
||||
type GetClient = (options?: NodeVault.VaultOptions) => NodeVault.client;
|
||||
|
||||
declare const getClient: GetClient;
|
||||
export = getClient;
|
||||
28
types/node-vault/node-vault-tests.ts
Normal file
28
types/node-vault/node-vault-tests.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as nv from "node-vault";
|
||||
|
||||
// Test code came from the sample code in README of the module.
|
||||
const options = {
|
||||
apiVersion: 'v1', // default
|
||||
endpoint: 'http://127.0.0.1:8200', // default
|
||||
token: '1234', // optional client token; can be fetched after valid initialization of the server
|
||||
};
|
||||
|
||||
// get new instance of the client
|
||||
let vault = nv(options);
|
||||
|
||||
// init vault server
|
||||
vault.init({ secret_shares: 1, secret_threshold: 1 })
|
||||
.then( (result) => {
|
||||
let keys = result.keys;
|
||||
// set token for all following requests
|
||||
vault.token = result.root_token;
|
||||
// unseal vault server
|
||||
return vault.unseal({ secret_shares: 1, key: keys[0] });
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
// write, read and delete secrets
|
||||
vault.write('secret/hello', { value: 'world', lease: '1s' })
|
||||
.then( () => vault.read('secret/hello'))
|
||||
.then( () => vault.delete('secret/hello'))
|
||||
.catch(console.error);
|
||||
22
types/node-vault/tsconfig.json
Normal file
22
types/node-vault/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"node-vault-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/node-vault/tslint.json
Normal file
1
types/node-vault/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user