@litehex/node-vault
Advanced tools
Comparing version 0.1.0-alpha.6 to 0.1.0-alpha.8
import { RequestInit as RequestInit$1 } from 'undici'; | ||
import { z } from 'zod'; | ||
import { PartialDeep } from 'type-fest'; | ||
import { JsonObject, PartialDeep } from 'type-fest'; | ||
@@ -14,10 +14,7 @@ interface RequestInit extends Omit<RequestInit$1, 'body'> { | ||
body?: z.ZodObject<any> | z.ZodAny; | ||
response?: z.ZodObject<any> | z.ZodRecord<any>; | ||
response?: z.ZodObject<any> | z.ZodRecord<any> | z.ZodDiscriminatedUnion<any, any> | z.ZodAny; | ||
} | ||
type ValidatedResponse<T extends RequestSchema> = T['response'] extends z.ZodRecord<any> ? Record<string, Serializable> : T['response'] extends z.ZodObject<any> ? z.infer<T['response']> : unknown; | ||
type CommandArgs<Schema extends RequestSchema> = (Schema['searchParams'] extends z.ZodObject<any> ? z.infer<Schema['searchParams']> : {}) & (Schema['body'] extends z.ZodAny ? Record<string, Serializable> : Schema['body'] extends z.ZodObject<any> ? z.infer<Schema['body']> : {}) & (Schema['path'] extends z.ZodObject<any> ? z.infer<Schema['path']> : {}); | ||
type ValidatedResponse<T extends RequestSchema> = T['response'] extends z.ZodAny ? any : T['response'] extends z.ZodRecord<any> ? JsonObject : T['response'] extends z.ZodObject<any> ? z.infer<T['response']> : unknown; | ||
type CommandArgs<Schema extends RequestSchema> = (Schema['searchParams'] extends z.ZodObject<any> ? z.infer<Schema['searchParams']> : {}) & (Schema['body'] extends z.ZodDiscriminatedUnion<any, any> ? z.infer<Schema['body']> : Schema['body'] extends z.ZodAny ? JsonObject : Schema['body'] extends z.ZodObject<any> ? z.infer<Schema['body']> : {}) & (Schema['path'] extends z.ZodObject<any> ? z.infer<Schema['path']> : {}); | ||
type CommandFn<Schema extends RequestSchema> = (args?: CommandArgs<Schema>, options?: Omit<RequestInit, 'url'>) => Promise<ValidatedResponse<Schema>>; | ||
type Serializable = string | number | boolean | null | Serializable[] | { | ||
[key: string]: Serializable; | ||
}; | ||
@@ -33,2 +30,145 @@ type CommandInit<Schema extends RequestSchema> = { | ||
type Engine = Record<EngineAction, RequestSchema>; | ||
type EngineAction = 'read'; | ||
declare const engines: { | ||
readonly kv2: { | ||
read: { | ||
path: z.ZodObject<{ | ||
path: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
path: string; | ||
}, { | ||
path: string; | ||
}>; | ||
searchParams: z.ZodObject<{ | ||
list: z.ZodBoolean; | ||
version: z.ZodOptional<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
list: boolean; | ||
version?: number | undefined; | ||
}, { | ||
list: boolean; | ||
version?: number | undefined; | ||
}>; | ||
response: z.ZodObject<{ | ||
request_id: z.ZodString; | ||
lease_id: z.ZodNullable<z.ZodString>; | ||
renewable: z.ZodBoolean; | ||
lease_duration: z.ZodNumber; | ||
data: z.ZodNullable<z.ZodObject<{ | ||
data: z.ZodRecord<z.ZodString, z.ZodString>; | ||
metadata: z.ZodObject<{ | ||
created_time: z.ZodString; | ||
custom_metadata: z.ZodNullable<z.ZodAny>; | ||
deletion_time: z.ZodString; | ||
destroyed: z.ZodBoolean; | ||
version: z.ZodNumber; | ||
}, "strip", z.ZodTypeAny, { | ||
version: number; | ||
created_time: string; | ||
deletion_time: string; | ||
destroyed: boolean; | ||
custom_metadata?: any; | ||
}, { | ||
version: number; | ||
created_time: string; | ||
deletion_time: string; | ||
destroyed: boolean; | ||
custom_metadata?: any; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
data: Record<string, string>; | ||
metadata: { | ||
version: number; | ||
created_time: string; | ||
deletion_time: string; | ||
destroyed: boolean; | ||
custom_metadata?: any; | ||
}; | ||
}, { | ||
data: Record<string, string>; | ||
metadata: { | ||
version: number; | ||
created_time: string; | ||
deletion_time: string; | ||
destroyed: boolean; | ||
custom_metadata?: any; | ||
}; | ||
}>>; | ||
wrap_info: z.ZodNullable<z.ZodAny>; | ||
warnings: z.ZodNullable<z.ZodArray<z.ZodString, "many">>; | ||
auth: z.ZodNullable<z.ZodObject<{ | ||
client_token: z.ZodString; | ||
policies: z.ZodArray<z.ZodString, "many">; | ||
metadata: z.ZodAny; | ||
lease_duration: z.ZodNumber; | ||
renewable: z.ZodBoolean; | ||
}, "strip", z.ZodTypeAny, { | ||
renewable: boolean; | ||
lease_duration: number; | ||
client_token: string; | ||
policies: string[]; | ||
metadata?: any; | ||
}, { | ||
renewable: boolean; | ||
lease_duration: number; | ||
client_token: string; | ||
policies: string[]; | ||
metadata?: any; | ||
}>>; | ||
}, "strip", z.ZodTypeAny, { | ||
request_id: string; | ||
lease_id: string | null; | ||
renewable: boolean; | ||
lease_duration: number; | ||
data: { | ||
data: Record<string, string>; | ||
metadata: { | ||
version: number; | ||
created_time: string; | ||
deletion_time: string; | ||
destroyed: boolean; | ||
custom_metadata?: any; | ||
}; | ||
} | null; | ||
warnings: string[] | null; | ||
auth: { | ||
renewable: boolean; | ||
lease_duration: number; | ||
client_token: string; | ||
policies: string[]; | ||
metadata?: any; | ||
} | null; | ||
wrap_info?: any; | ||
}, { | ||
request_id: string; | ||
lease_id: string | null; | ||
renewable: boolean; | ||
lease_duration: number; | ||
data: { | ||
data: Record<string, string>; | ||
metadata: { | ||
version: number; | ||
created_time: string; | ||
deletion_time: string; | ||
destroyed: boolean; | ||
custom_metadata?: any; | ||
}; | ||
} | null; | ||
warnings: string[] | null; | ||
auth: { | ||
renewable: boolean; | ||
lease_duration: number; | ||
client_token: string; | ||
policies: string[]; | ||
metadata?: any; | ||
} | null; | ||
wrap_info?: any; | ||
}>; | ||
}; | ||
}; | ||
}; | ||
type EngineName = keyof typeof engines; | ||
type EngineSchema<T extends EngineName> = (typeof engines)[T]; | ||
declare const ClientOptionsSchema: z.ZodObject<{ | ||
@@ -65,4 +205,31 @@ endpoint: z.ZodOptional<z.ZodString>; | ||
private assignCommands; | ||
read<Engine extends EngineName = any>(query: QueryArgs<Engine, 'read'>, options?: Omit<RequestInit, 'url'>): Promise<ValidatedResponse<EngineSchema<Engine>['read']>>; | ||
write: CommandFn<{ | ||
path: z.ZodObject<{ | ||
path: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
path: string; | ||
}, { | ||
path: string; | ||
}>; | ||
body: z.ZodAny; | ||
response: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
}>; | ||
delete: CommandFn<{ | ||
path: z.ZodObject<{ | ||
path: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
path: string; | ||
}, { | ||
path: string; | ||
}>; | ||
response: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
}>; | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/seal-status#seal-status | ||
*/ | ||
status: CommandFn<{ | ||
response: z.ZodObject<{ | ||
type: z.ZodString; | ||
initialized: z.ZodBoolean; | ||
sealed: z.ZodBoolean; | ||
@@ -72,3 +239,12 @@ t: z.ZodNumber; | ||
progress: z.ZodNumber; | ||
nonce: z.ZodString; | ||
version: z.ZodString; | ||
build_date: z.ZodString; | ||
migration: z.ZodBoolean; | ||
recovery_seal: z.ZodBoolean; | ||
storage_type: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: string; | ||
version: string; | ||
initialized: boolean; | ||
sealed: boolean; | ||
@@ -78,3 +254,11 @@ t: number; | ||
progress: number; | ||
nonce: string; | ||
build_date: string; | ||
migration: boolean; | ||
recovery_seal: boolean; | ||
storage_type: string; | ||
}, { | ||
type: string; | ||
version: string; | ||
initialized: boolean; | ||
sealed: boolean; | ||
@@ -84,14 +268,52 @@ t: number; | ||
progress: number; | ||
nonce: string; | ||
build_date: string; | ||
migration: boolean; | ||
recovery_seal: boolean; | ||
storage_type: string; | ||
}>; | ||
}>; | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/init#read-initialization-status | ||
*/ | ||
initialized: CommandFn<{ | ||
response: z.ZodObject<{ | ||
initialized: z.ZodBoolean; | ||
}, "strip", z.ZodTypeAny, { | ||
initialized: boolean; | ||
}, { | ||
initialized: boolean; | ||
}>; | ||
}>; | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/init#start-initialization | ||
*/ | ||
init: CommandFn<{ | ||
body: z.ZodObject<{ | ||
pgp_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
root_token_pgp_key: z.ZodOptional<z.ZodDefault<z.ZodString>>; | ||
secret_shares: z.ZodNumber; | ||
secret_threshold: z.ZodNumber; | ||
stored_shares: z.ZodOptional<z.ZodNumber>; | ||
recovery_shares: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; | ||
recovery_threshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>; | ||
recovery_pgp_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
}, "strip", z.ZodTypeAny, { | ||
secret_shares: number; | ||
secret_threshold: number; | ||
pgp_keys?: string[] | undefined; | ||
root_token_pgp_key?: string | undefined; | ||
stored_shares?: number | undefined; | ||
recovery_shares?: number | undefined; | ||
recovery_threshold?: number | undefined; | ||
recovery_pgp_keys?: string[] | undefined; | ||
}, { | ||
secret_shares: number; | ||
secret_threshold: number; | ||
pgp_keys?: string[] | undefined; | ||
root_token_pgp_key?: string | undefined; | ||
stored_shares?: number | undefined; | ||
recovery_shares?: number | undefined; | ||
recovery_threshold?: number | undefined; | ||
recovery_pgp_keys?: string[] | undefined; | ||
}>; | ||
@@ -112,35 +334,32 @@ response: z.ZodObject<{ | ||
}>; | ||
read: CommandFn<{ | ||
path: z.ZodObject<{ | ||
path: z.ZodString; | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/unseal#submit-unseal-key | ||
*/ | ||
unseal: CommandFn<{ | ||
body: z.ZodObject<{ | ||
key: z.ZodString; | ||
reset: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; | ||
migrate: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>; | ||
}, "strip", z.ZodTypeAny, { | ||
path: string; | ||
key: string; | ||
reset?: boolean | undefined; | ||
migrate?: boolean | undefined; | ||
}, { | ||
path: string; | ||
key: string; | ||
reset?: boolean | undefined; | ||
migrate?: boolean | undefined; | ||
}>; | ||
response: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
response: z.ZodDiscriminatedUnion<"sealed", [z.ZodDiscriminatedUnionOption<"sealed">, ...z.ZodDiscriminatedUnionOption<"sealed">[]]>; | ||
}>; | ||
write: CommandFn<{ | ||
path: z.ZodObject<{ | ||
path: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
path: string; | ||
}, { | ||
path: string; | ||
}>; | ||
body: z.ZodAny; | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/seal#seal | ||
*/ | ||
seal: CommandFn<{ | ||
response: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
}>; | ||
delete: CommandFn<{ | ||
path: z.ZodObject<{ | ||
path: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
path: string; | ||
}, { | ||
path: string; | ||
}>; | ||
response: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
}>; | ||
} | ||
type QueryArgs<Name extends EngineName, Action extends EngineAction> = Name extends EngineName ? EngineSchema<Name> extends Engine ? CommandArgs<EngineSchema<Name>[Action]> & { | ||
engine?: Name; | ||
} : never : never; | ||
export { Client, type ClientOptions, type CommandArgs, type CommandFn, type RequestInit, type RequestSchema, type Serializable, type ValidatedResponse, generateCommand }; | ||
export { Client, type ClientOptions, type CommandArgs, type CommandFn, type RequestInit, type RequestSchema, type ValidatedResponse, generateCommand }; |
@@ -37,8 +37,8 @@ "use strict"; | ||
module.exports = __toCommonJS(src_exports); | ||
var import_zod3 = require("zod"); | ||
var import_zod5 = require("zod"); | ||
// src/request.ts | ||
// src/lib/request.ts | ||
var import_undici = require("undici"); | ||
// src/errors.ts | ||
// src/lib/errors.ts | ||
var import_zod = require("zod"); | ||
@@ -57,10 +57,4 @@ var ApiResponseError = class extends Error { | ||
// src/request.ts | ||
// src/lib/request.ts | ||
async function request(init, schema) { | ||
if (schema.searchParams) { | ||
const valid = schema.searchParams.safeParse(init.url); | ||
if (!valid.success) { | ||
throw new Error("ErrorSearchPrams: Invalid Args. " + valid.error.message); | ||
} | ||
} | ||
if (schema.body) { | ||
@@ -112,44 +106,127 @@ const valid = schema.body.safeParse(init.body); | ||
var import_lodash = __toESM(require("lodash.pick")); | ||
var import_lodash2 = __toESM(require("lodash.omit")); | ||
var import_zod2 = require("zod"); | ||
function generateCommand(init) { | ||
return (args, options = {}) => { | ||
const { method, path, client, schema } = init; | ||
if (schema.path) { | ||
schema.path.parse(args); | ||
async function generateCommandRequestInit(init, args, options) { | ||
const { method = "GET", path, client, schema } = init; | ||
if (schema.path) { | ||
schema.path.parse(args); | ||
} | ||
const signedPath = import_mustache.default.render(path, args); | ||
const url = new URL( | ||
`${client.endpoint}/${client.apiVersion}${client.pathPrefix}${signedPath}`.replace(///g, "/") | ||
); | ||
const { headers: extraHeaders, ...restOpts } = options; | ||
const headers = removeUndefined({ | ||
"X-Vault-Token": client.token, | ||
"X-Vault-Namespace": client.namespace, | ||
...extraHeaders | ||
}); | ||
if (schema.searchParams) { | ||
const items = removeUndefined((0, import_lodash.default)(args || {}, Object.keys(schema.searchParams.shape))); | ||
if (!schema.searchParams.safeParse(items).success) { | ||
throw new Error("ErrorSearchPrams: Invalid Args."); | ||
} | ||
const signedPath = import_mustache.default.render(path, args); | ||
let url = `${client.endpoint}/${client.apiVersion}${client.pathPrefix}${signedPath}`; | ||
url = url.replace(///g, "/"); | ||
const { headers: extraHeaders, ...restOpts } = options; | ||
const headers = removeUndefined({ | ||
"X-Vault-Token": client.token, | ||
"X-Vault-Namespace": client.namespace, | ||
...extraHeaders | ||
}); | ||
let requestInit = { | ||
...restOpts, | ||
method, | ||
url, | ||
headers | ||
}; | ||
if (schema.body && schema.body instanceof import_zod2.z.ZodObject) { | ||
requestInit.body = (0, import_lodash.default)(args, Object.keys(schema.body.shape)); | ||
for (const [key, val] of Object.entries(items)) { | ||
if (val === void 0 || val === null) { | ||
console.warn(`Search param "${key}" is undefined or empty. Skipping...`); | ||
continue; | ||
} | ||
if (typeof val === "boolean") { | ||
url.searchParams.set(key, val ? "1" : "0"); | ||
continue; | ||
} | ||
url.searchParams.set(key, String(val)); | ||
} | ||
if (schema.body && schema.body instanceof import_zod2.z.ZodAny) { | ||
requestInit.body = args; | ||
} | ||
let requestInit = { | ||
...restOpts, | ||
method, | ||
url: url.toString(), | ||
headers | ||
}; | ||
if (schema.body) { | ||
if (schema.body instanceof import_zod2.z.ZodAny) { | ||
requestInit.body = removeUndefined((0, import_lodash2.default)(args, Object.keys(schema.searchParams?.shape || {}))); | ||
} | ||
if (init.refine) { | ||
requestInit = init.refine(requestInit, args || {}); | ||
if (schema.body instanceof import_zod2.z.ZodObject) { | ||
const items = removeUndefined((0, import_lodash.default)(args || {}, Object.keys(schema.body.shape))); | ||
if (!schema.body.safeParse(items).success) { | ||
throw new Error("ErrorBody: Invalid Args."); | ||
} | ||
requestInit.body = items; | ||
} | ||
return request(requestInit, schema); | ||
} | ||
if (init.refine) { | ||
requestInit = init.refine(requestInit, args); | ||
} | ||
return requestInit; | ||
} | ||
function generateCommand(init) { | ||
return async (args, options = {}) => { | ||
const requestInit = await generateCommandRequestInit(init, args || {}, options); | ||
return request(requestInit, init.schema); | ||
}; | ||
} | ||
// src/lib/engine.ts | ||
var import_zod4 = require("zod"); | ||
// src/schema.ts | ||
var import_zod3 = require("zod"); | ||
var AuthSchema = import_zod3.z.object({ | ||
client_token: import_zod3.z.string(), | ||
policies: import_zod3.z.array(import_zod3.z.string()), | ||
metadata: import_zod3.z.any(), | ||
lease_duration: import_zod3.z.number(), | ||
renewable: import_zod3.z.boolean() | ||
}); | ||
// src/lib/engine.ts | ||
var AnyEngineSchema = { | ||
path: import_zod4.z.object({ | ||
path: import_zod4.z.string() | ||
}), | ||
response: import_zod4.z.any() | ||
}; | ||
var KV2Engine = { | ||
read: { | ||
path: import_zod4.z.object({ | ||
path: import_zod4.z.string() | ||
}), | ||
searchParams: import_zod4.z.object({ | ||
list: import_zod4.z.boolean(), | ||
version: import_zod4.z.number().optional() | ||
}), | ||
response: import_zod4.z.object({ | ||
request_id: import_zod4.z.string(), | ||
lease_id: import_zod4.z.string().nullable(), | ||
renewable: import_zod4.z.boolean(), | ||
lease_duration: import_zod4.z.number(), | ||
data: import_zod4.z.object({ | ||
data: import_zod4.z.record(import_zod4.z.string()), | ||
metadata: import_zod4.z.object({ | ||
created_time: import_zod4.z.string(), | ||
custom_metadata: import_zod4.z.any().nullable(), | ||
deletion_time: import_zod4.z.string(), | ||
destroyed: import_zod4.z.boolean(), | ||
version: import_zod4.z.number() | ||
}) | ||
}).nullable(), | ||
wrap_info: import_zod4.z.any().nullable(), | ||
warnings: import_zod4.z.array(import_zod4.z.string()).nullable(), | ||
auth: AuthSchema.nullable() | ||
}) | ||
} | ||
}; | ||
var engines = { | ||
kv2: KV2Engine | ||
}; | ||
// src/index.ts | ||
var ClientOptionsSchema = import_zod3.z.object({ | ||
endpoint: import_zod3.z.string().optional(), | ||
apiVersion: import_zod3.z.string().optional(), | ||
pathPrefix: import_zod3.z.string().optional(), | ||
token: import_zod3.z.string().optional(), | ||
namespace: import_zod3.z.string().optional() | ||
var ClientOptionsSchema = import_zod5.z.object({ | ||
endpoint: import_zod5.z.string().optional(), | ||
apiVersion: import_zod5.z.string().optional(), | ||
pathPrefix: import_zod5.z.string().optional(), | ||
token: import_zod5.z.string().optional(), | ||
namespace: import_zod5.z.string().optional() | ||
}); | ||
@@ -177,2 +254,43 @@ var Client = class { | ||
} | ||
async read(query, options = {}) { | ||
const { engine, ...args } = query || {}; | ||
const schema = engine && engines[engine] && engines[engine]["read"] ? engines[engine]["read"] : AnyEngineSchema; | ||
const init = await generateCommandRequestInit( | ||
{ | ||
method: "GET", | ||
path: "/{{path}}", | ||
client: this, | ||
schema | ||
}, | ||
args, | ||
options | ||
); | ||
return request(init, schema); | ||
} | ||
write = generateCommand({ | ||
method: "POST", | ||
path: "/{{path}}", | ||
client: this, | ||
schema: { | ||
path: import_zod5.z.object({ | ||
path: import_zod5.z.string() | ||
}), | ||
body: import_zod5.z.any(), | ||
response: import_zod5.z.record(import_zod5.z.any()) | ||
} | ||
}); | ||
delete = generateCommand({ | ||
method: "DELETE", | ||
path: "/{{path}}", | ||
client: this, | ||
schema: { | ||
path: import_zod5.z.object({ | ||
path: import_zod5.z.string() | ||
}), | ||
response: import_zod5.z.record(import_zod5.z.any()) | ||
} | ||
}); | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/seal-status#seal-status | ||
*/ | ||
status = generateCommand({ | ||
@@ -183,68 +301,101 @@ method: "GET", | ||
schema: { | ||
response: import_zod3.z.object({ | ||
sealed: import_zod3.z.boolean(), | ||
t: import_zod3.z.number(), | ||
n: import_zod3.z.number(), | ||
progress: import_zod3.z.number() | ||
response: import_zod5.z.object({ | ||
type: import_zod5.z.string(), | ||
initialized: import_zod5.z.boolean(), | ||
sealed: import_zod5.z.boolean(), | ||
t: import_zod5.z.number(), | ||
n: import_zod5.z.number(), | ||
progress: import_zod5.z.number(), | ||
nonce: import_zod5.z.string(), | ||
version: import_zod5.z.string(), | ||
build_date: import_zod5.z.string(), | ||
migration: import_zod5.z.boolean(), | ||
recovery_seal: import_zod5.z.boolean(), | ||
storage_type: import_zod5.z.string() | ||
}) | ||
} | ||
}); | ||
init = generateCommand({ | ||
method: "PUT", | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/init#read-initialization-status | ||
*/ | ||
initialized = generateCommand({ | ||
method: "GET", | ||
path: "/sys/init", | ||
client: this, | ||
schema: { | ||
body: import_zod3.z.object({ | ||
secret_shares: import_zod3.z.number(), | ||
secret_threshold: import_zod3.z.number() | ||
}), | ||
response: import_zod3.z.object({ | ||
keys: import_zod3.z.array(import_zod3.z.string()), | ||
keys_base64: import_zod3.z.array(import_zod3.z.string()), | ||
root_token: import_zod3.z.string() | ||
response: import_zod5.z.object({ | ||
initialized: import_zod5.z.boolean() | ||
}) | ||
} | ||
}); | ||
read = generateCommand({ | ||
method: "GET", | ||
path: "/{{path}}", | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/init#start-initialization | ||
*/ | ||
init = generateCommand({ | ||
method: "POST", | ||
path: "/sys/init", | ||
client: this, | ||
schema: { | ||
path: import_zod3.z.object({ | ||
path: import_zod3.z.string() | ||
body: import_zod5.z.object({ | ||
pgp_keys: import_zod5.z.array(import_zod5.z.string()).optional(), | ||
root_token_pgp_key: import_zod5.z.string().default("").optional(), | ||
secret_shares: import_zod5.z.number(), | ||
secret_threshold: import_zod5.z.number(), | ||
stored_shares: import_zod5.z.number().optional(), | ||
recovery_shares: import_zod5.z.number().default(0).optional(), | ||
recovery_threshold: import_zod5.z.number().default(0).optional(), | ||
recovery_pgp_keys: import_zod5.z.array(import_zod5.z.string()).optional() | ||
}), | ||
response: import_zod3.z.record(import_zod3.z.any()) | ||
response: import_zod5.z.object({ | ||
keys: import_zod5.z.array(import_zod5.z.string()), | ||
keys_base64: import_zod5.z.array(import_zod5.z.string()), | ||
root_token: import_zod5.z.string() | ||
}) | ||
} | ||
}); | ||
write = generateCommand({ | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/unseal#submit-unseal-key | ||
*/ | ||
unseal = generateCommand({ | ||
method: "POST", | ||
path: "/{{path}}", | ||
path: "/sys/unseal", | ||
client: this, | ||
schema: { | ||
path: import_zod3.z.object({ | ||
path: import_zod3.z.string() | ||
body: import_zod5.z.object({ | ||
key: import_zod5.z.string(), | ||
reset: import_zod5.z.boolean().default(false).optional(), | ||
migrate: import_zod5.z.boolean().default(false).optional() | ||
}), | ||
body: import_zod3.z.any(), | ||
response: import_zod3.z.record(import_zod3.z.any()) | ||
response: import_zod5.z.discriminatedUnion("sealed", [ | ||
import_zod5.z.object({ | ||
sealed: import_zod5.z.literal(true), | ||
t: import_zod5.z.number(), | ||
n: import_zod5.z.number(), | ||
progress: import_zod5.z.number(), | ||
version: import_zod5.z.string() | ||
}), | ||
import_zod5.z.object({ | ||
sealed: import_zod5.z.literal(false), | ||
t: import_zod5.z.number(), | ||
n: import_zod5.z.number(), | ||
progress: import_zod5.z.number(), | ||
version: import_zod5.z.string(), | ||
cluster_name: import_zod5.z.string(), | ||
cluster_id: import_zod5.z.string() | ||
}) | ||
]) | ||
} | ||
}); | ||
delete = generateCommand({ | ||
method: "DELETE", | ||
path: "/{{path}}", | ||
/** | ||
* @link https://developer.hashicorp.com/vault/api-docs/system/seal#seal | ||
*/ | ||
seal = generateCommand({ | ||
method: "POST", | ||
path: "/sys/seal", | ||
client: this, | ||
schema: { | ||
path: import_zod3.z.object({ | ||
path: import_zod3.z.string() | ||
}), | ||
response: import_zod3.z.record(import_zod3.z.any()) | ||
response: import_zod5.z.record(import_zod5.z.any()) | ||
} | ||
}); | ||
}; | ||
var AuthSchema = import_zod3.z.object({ | ||
client_token: import_zod3.z.string(), | ||
policies: import_zod3.z.array(import_zod3.z.string()), | ||
metadata: import_zod3.z.any(), | ||
lease_duration: import_zod3.z.number(), | ||
renewable: import_zod3.z.boolean() | ||
}); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -251,0 +402,0 @@ 0 && (module.exports = { |
{ | ||
"name": "@litehex/node-vault", | ||
"version": "0.1.0-alpha.6", | ||
"version": "0.1.0-alpha.8", | ||
"private": false, | ||
@@ -32,2 +32,3 @@ "description": "Node.js client for the HashiCorp's Vault API", | ||
"dependencies": { | ||
"lodash.omit": "^4.5.0", | ||
"lodash.pick": "^4.4.0", | ||
@@ -39,2 +40,3 @@ "mustache": "^4.2.0", | ||
"devDependencies": { | ||
"@types/lodash.omit": "^4.5.9", | ||
"@types/lodash.pick": "^4.4.9", | ||
@@ -41,0 +43,0 @@ "@types/mocha": "^10.0.6", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88675
1099
5
14
+ Addedlodash.omit@^4.5.0
+ Addedlodash.omit@4.5.0(transitive)