@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
85 lines • 3.82 kB
JavaScript
;
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.V2KeysVerifyKeyResponseData$inboundSchema = exports.Code$inboundSchema = exports.Code = void 0;
exports.v2KeysVerifyKeyResponseDataFromJSON = v2KeysVerifyKeyResponseDataFromJSON;
const z = __importStar(require("zod/v3"));
const schemas_js_1 = require("../../lib/schemas.js");
const openEnums = __importStar(require("../../types/enums.js"));
const identity_js_1 = require("./identity.js");
const verifykeyratelimitdata_js_1 = require("./verifykeyratelimitdata.js");
/**
* A machine-readable code indicating the verification status
*
* @remarks
* or failure reason. Values: `VALID` (key is valid and passed all checks), `NOT_FOUND` (key doesn't
* exist or belongs to wrong API), `FORBIDDEN` (key lacks required permissions), `INSUFFICIENT_PERMISSIONS`
* (key lacks specific required permissions for this request), `USAGE_EXCEEDED` (key has no remaining credits), `RATE_LIMITED` (key exceeded rate limits), `DISABLED` (key was explicitly disabled),
* `EXPIRED` (key has passed its expiration date).
*/
exports.Code = {
Valid: "VALID",
NotFound: "NOT_FOUND",
Forbidden: "FORBIDDEN",
InsufficientPermissions: "INSUFFICIENT_PERMISSIONS",
UsageExceeded: "USAGE_EXCEEDED",
RateLimited: "RATE_LIMITED",
Disabled: "DISABLED",
Expired: "EXPIRED",
};
/** @internal */
exports.Code$inboundSchema = openEnums.inboundSchema(exports.Code);
/** @internal */
exports.V2KeysVerifyKeyResponseData$inboundSchema = z.object({
valid: z.boolean(),
code: exports.Code$inboundSchema,
keyId: z.string().optional(),
name: z.string().optional(),
meta: z.record(z.any()).optional(),
expires: z.number().int().optional(),
credits: z.number().int().optional(),
enabled: z.boolean().optional(),
permissions: z.array(z.string()).optional(),
roles: z.array(z.string()).optional(),
identity: identity_js_1.Identity$inboundSchema.optional(),
ratelimits: z.array(verifykeyratelimitdata_js_1.VerifyKeyRatelimitData$inboundSchema).optional(),
});
function v2KeysVerifyKeyResponseDataFromJSON(jsonString) {
return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.V2KeysVerifyKeyResponseData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'V2KeysVerifyKeyResponseData' from JSON`);
}
//# sourceMappingURL=v2keysverifykeyresponsedata.js.map