@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
65 lines (60 loc) • 2.1 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type V2KeysRerollKeyResponseData = {
/**
* The unique identifier for the newly created key.
*
* @remarks
*
* This is NOT the actual API key token, but a reference ID for management operations.
* Store this ID to:
* - Update or revoke the key later
* - Track the key in your database
* - Display in admin dashboards (safe to log)
*
* Note: This is a new ID - the original key retains its own ID.
*/
keyId: string;
/**
* The newly generated API key token (the actual secret that authenticates requests).
*
* @remarks
*
* **SECURITY CRITICAL:**
* - This is the only time you'll receive the complete key
* - Unkey stores only a hashed version (unless the original key was created with `recoverable=true`)
* - Never log, store, or expose this value in your systems
* - Transmit directly to the end user via secure channels only
* - If lost and not recoverable, you must reroll or create a new key
*
* The key format follows: `[prefix]_[random_bytes]`
* - Prefix is extracted from the original key or uses API default
* - Random bytes follow API configuration (default: 16 bytes)
*
* This is NOT the keyId - it's the actual secret token used for authentication.
*/
key: string;
};
/** @internal */
export const V2KeysRerollKeyResponseData$inboundSchema: z.ZodType<
V2KeysRerollKeyResponseData,
z.ZodTypeDef,
unknown
> = z.object({
keyId: z.string(),
key: z.string(),
});
export function v2KeysRerollKeyResponseDataFromJSON(
jsonString: string,
): SafeParseResult<V2KeysRerollKeyResponseData, SDKValidationError> {
return safeParse(
jsonString,
(x) => V2KeysRerollKeyResponseData$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'V2KeysRerollKeyResponseData' from JSON`,
);
}