@usegrant/sdk
Version:
TypeSafe TypeScript SDK for accessing the UseGrant REST API
572 lines (569 loc) • 21 kB
JavaScript
//#region rolldown:runtime
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
const zod_v4 = __toESM(require("zod/v4"));
//#region src/schema.ts
const FOURTY_EIGHT_HOURS = 48 * 60 * 60 * 1e3;
const CreateProviderSchema = zod_v4.z.object({
name: zod_v4.z.string().describe("The name of the provider").min(3, "Name must be at least 3 characters long").max(50, "Name must be less than 50 characters long"),
description: zod_v4.z.string().describe("The description of the provider").min(1, "Description is required").max(100, "Description must be less than 100 characters long")
});
const ConditionSchema = zod_v4.z.object({
key: zod_v4.z.string("Please provide a condition key.").describe("The key of the condition").min(1, "Please provide a condition key.").max(10, "Condition key must be at most 10 characters long."),
operator: zod_v4.z.enum([
"stringEquals",
"stringLike",
"stringNotEquals",
"stringNotLike"
]).describe("The operator of the condition"),
value: zod_v4.z.string("Please provide a condition value.").describe("The value of the condition").min(1, "Please provide a condition value.").max(100, "Condition value must be at most 100 characters long.")
});
const CreateClientSchema = zod_v4.z.object({
name: zod_v4.z.string().describe("The name of the client").min(3, "Name must be at least 3 characters long").max(50, "Name must be less than 50 characters long"),
audience: zod_v4.z.string().describe("The audience of the client").min(3, "Audience must be at least 3 characters long").max(100, "Audience must be less than 100 characters long")
});
const AddDomainSchema = zod_v4.z.object({ domain: zod_v4.z.string("Please enter a domain name.").regex(/^(?!:\/\/)([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?\.)+[a-zA-Z]{2,}$/, "Please enter a valid domain name.").regex(/^(?!www\.)/, "Domain name cannot start with www.").min(3, "Domain name must be at least 3 characters long.").max(255, "Domain name must be less than 255 characters long.") });
const CreateTokenSchema = zod_v4.z.object({
expiresIn: zod_v4.z.number().describe("The number of seconds the token will be valid for").max(FOURTY_EIGHT_HOURS, "Expires in must be less than 48 hours").optional(),
useJwtType: zod_v4.z.boolean().describe("Whether to use at+jwt token type in the header").optional(),
audienceAsArray: zod_v4.z.boolean().describe("Whether to use an array of audiences").optional(),
forceDefaultDomain: zod_v4.z.boolean().describe("Whether to force the default domain").optional()
});
const CreateTenantSchema = zod_v4.z.object({
name: zod_v4.z.string().describe("The name of the tenant").min(3, "Name must be at least 3 characters long"),
description: zod_v4.z.string().describe("The description of the tenant").min(1, "Description is required").max(100, "Description must be less than 200 characters long")
});
const CreateTenantProviderSchema = zod_v4.z.object({
url: zod_v4.z.url("Please provide a valid URL.").describe("The URL of the provider").transform((url) => url.replace(/\/$/, "")),
fingerprints: zod_v4.z.array(zod_v4.z.string("Please provide the provider fingerprint.").describe("The fingerprint of the provider").min(32, { message: "Fingerprint must be at least 32 characters long." }).max(64, { message: "Fingerprint must be at most 64 characters long." })).min(1, "At least one fingerprint is required.").max(5, "At most 5 fingerprints are allowed."),
audience: zod_v4.z.string("Please provide the provider audience.").describe("The audience of the provider").min(3, "Provider audience must be at least 3 characters long.").max(100, "Provider audience must be at most 100 characters long.").trim(),
earliestIssuanceTimeAllowed: zod_v4.z.coerce.number("Please provide the earliest issuance time allowed.").describe("The earliest issuance time allowed in hours").min(0, "Earliest issuance time allowed must be at least 0.").max(12, "Earliest issuance time allowed must be at most 12.")
});
const CreateTenantProviderPolicySchema = zod_v4.z.object({
name: zod_v4.z.string("Please provide a name for the tenant provider policy.").describe("The name of the tenant provider policy").min(3, "Name must be at least 3 characters long"),
description: zod_v4.z.string("Please provide a description for the tenant provider policy.").describe("The description of the tenant provider policy").min(10, "Description must be at least 10 characters long").max(100, "Description must be less than 100 characters long"),
audience: zod_v4.z.string("Please provide the audience for the tenant provider policy.").describe("The audience of the tenant provider policy").min(3, "Audience must be at least 3 characters long.").max(100, "Audience must be at most 100 characters long.").trim(),
conditions: zod_v4.z.array(ConditionSchema).describe("The conditions of the tenant provider policy").min(1, "At least one condition is required.").max(5, "At most 5 conditions are allowed.")
});
const ProviderSchema = zod_v4.z.object({
id: zod_v4.z.string().describe("The ID of the provider"),
name: zod_v4.z.string().describe("The name of the provider"),
description: zod_v4.z.string().describe("The description of the provider"),
createdAt: zod_v4.z.string().describe("The creation date of the provider"),
updatedAt: zod_v4.z.string().describe("The last update date of the provider")
});
const ClientSchema = zod_v4.z.object({
id: zod_v4.z.string().describe("The ID of the client"),
name: zod_v4.z.string().describe("The name of the client"),
audience: zod_v4.z.string().describe("The audience of the client"),
createdAt: zod_v4.z.string().describe("The creation date of the client"),
updatedAt: zod_v4.z.string().describe("The last update date of the client")
});
const DomainSchema = zod_v4.z.object({
id: zod_v4.z.string().describe("The ID of the domain"),
domain: zod_v4.z.string().describe("The domain of the domain"),
verified: zod_v4.z.boolean().describe("Whether the domain is verified"),
createdAt: zod_v4.z.string().describe("The creation date of the domain"),
updatedAt: zod_v4.z.string().describe("The last update date of the domain")
});
const TenantSchema = zod_v4.z.object({
id: zod_v4.z.string().describe("The ID of the tenant"),
name: zod_v4.z.string().describe("The name of the tenant"),
description: zod_v4.z.string().describe("The description of the tenant"),
createdAt: zod_v4.z.string().describe("The creation date of the tenant"),
updatedAt: zod_v4.z.string().describe("The last update date of the tenant")
});
const TenantProviderSchema = zod_v4.z.object({
id: zod_v4.z.string().describe("The ID of the tenant provider"),
url: zod_v4.z.string().describe("The URL of the tenant provider"),
fingerprints: zod_v4.z.array(zod_v4.z.string()).describe("The fingerprints of the tenant provider"),
audience: zod_v4.z.string().describe("The audience of the tenant provider"),
earliestIssuanceTimeAllowed: zod_v4.z.number().describe("The earliest issuance time allowed for the tenant provider"),
createdAt: zod_v4.z.string().describe("The creation date of the tenant provider"),
updatedAt: zod_v4.z.string().describe("The last update date of the tenant provider")
});
const TokenSchema = zod_v4.z.object({
accessToken: zod_v4.z.string().describe("The access token"),
expiresAt: zod_v4.z.string().describe("The expiration date of the access token"),
type: zod_v4.z.literal("Bearer").describe("The type of the token")
});
const ValidateTokenResponseSchema = zod_v4.z.object({ exp: zod_v4.z.number().describe("The expiration date of the token") });
const TenantProviderPolicySchema = zod_v4.z.object({
id: zod_v4.z.string().describe("The ID of the tenant provider policy"),
name: zod_v4.z.string().describe("The name of the tenant provider policy"),
description: zod_v4.z.string().describe("The description of the tenant provider policy"),
audience: zod_v4.z.string().describe("The audience of the tenant provider policy"),
conditions: zod_v4.z.array(ConditionSchema).describe("The conditions of the tenant provider policy"),
createdAt: zod_v4.z.string().describe("The creation date of the tenant provider policy"),
updatedAt: zod_v4.z.string().describe("The last update date of the tenant provider policy")
});
const EmptyResponseSchema = zod_v4.z.string();
const DomainValidationResponseSchema = zod_v4.z.object({
domain: DomainSchema.describe("The domain object"),
verified: zod_v4.z.boolean().describe("Whether the domain is verified"),
message: zod_v4.z.string().describe("The message about the domain validation")
});
const ProviderIdSchema = zod_v4.z.string().describe("The ID of the provider").min(1, { message: "Provider ID is required." });
const ClientIdSchema = zod_v4.z.string().describe("The ID of the client").min(1, { message: "Client ID is required." });
const DomainIdSchema = zod_v4.z.string().describe("The ID of the domain").min(1, { message: "Domain ID is required." });
const TenantIdSchema = zod_v4.z.string().describe("The ID of the tenant").min(1, { message: "Tenant ID is required." });
const TenantProviderIdSchema = zod_v4.z.string().describe("The ID of the tenant provider").min(1, { message: "Tenant provider ID is required." });
const TenantProviderPolicyIdSchema = zod_v4.z.string().describe("The ID of the tenant provider policy").min(1, { message: "Tenant provider policy ID is required." });
const GetProvidersFn = zod_v4.z.function({ output: zod_v4.z.promise(zod_v4.z.array(ProviderSchema)) });
const CreateProviderFn = zod_v4.z.function({
input: [CreateProviderSchema],
output: zod_v4.z.promise(ProviderSchema)
});
const GetProviderFn = zod_v4.z.function({
input: [ProviderIdSchema],
output: zod_v4.z.promise(ProviderSchema)
});
const DeleteProviderFn = zod_v4.z.function({
input: [ProviderIdSchema],
output: zod_v4.z.promise(EmptyResponseSchema)
});
const GetClientsFn = zod_v4.z.function({
input: [ProviderIdSchema],
output: zod_v4.z.promise(zod_v4.z.array(ClientSchema))
});
const CreateClientFn = zod_v4.z.function({
input: [ProviderIdSchema, CreateClientSchema],
output: zod_v4.z.promise(ClientSchema)
});
const GetClientFn = zod_v4.z.function({
input: [ProviderIdSchema, ClientIdSchema],
output: zod_v4.z.promise(ClientSchema)
});
const DeleteClientFn = zod_v4.z.function({
input: [ProviderIdSchema, ClientIdSchema],
output: zod_v4.z.promise(EmptyResponseSchema)
});
const CreateTokenFn = zod_v4.z.function({
input: [
ProviderIdSchema,
ClientIdSchema,
CreateTokenSchema
],
output: zod_v4.z.promise(TokenSchema)
});
const GetTenantsFn = zod_v4.z.function({
input: [],
output: zod_v4.z.promise(zod_v4.z.array(TenantSchema))
});
const AddDomainFn = zod_v4.z.function({
input: [ProviderIdSchema, AddDomainSchema],
output: zod_v4.z.promise(DomainSchema)
});
const DeleteDomainFn = zod_v4.z.function({
input: [ProviderIdSchema, DomainIdSchema],
output: zod_v4.z.promise(EmptyResponseSchema)
});
const GetDomainFn = zod_v4.z.function({
input: [ProviderIdSchema, DomainIdSchema],
output: zod_v4.z.promise(DomainSchema)
});
const GetDomainsFn = zod_v4.z.function({
input: [ProviderIdSchema],
output: zod_v4.z.promise(zod_v4.z.array(DomainSchema))
});
const VerifyDomainFn = zod_v4.z.function({
input: [ProviderIdSchema, DomainIdSchema],
output: zod_v4.z.promise(DomainValidationResponseSchema)
});
const CreateTenantFn = zod_v4.z.function({
input: [CreateTenantSchema],
output: zod_v4.z.promise(TenantSchema)
});
const GetTenantFn = zod_v4.z.function({
input: [TenantIdSchema],
output: zod_v4.z.promise(TenantSchema)
});
const DeleteTenantFn = zod_v4.z.function({
input: [TenantIdSchema],
output: zod_v4.z.promise(EmptyResponseSchema)
});
const GetTenantProvidersFn = zod_v4.z.function({
input: [TenantIdSchema],
output: zod_v4.z.promise(zod_v4.z.array(TenantProviderSchema))
});
const CreateTenantProviderFn = zod_v4.z.function({
input: [TenantIdSchema, CreateTenantProviderSchema],
output: zod_v4.z.promise(TenantProviderSchema)
});
const GetTenantProviderFn = zod_v4.z.function({
input: [TenantIdSchema, TenantProviderIdSchema],
output: zod_v4.z.promise(TenantProviderSchema)
});
const DeleteTenantProviderFn = zod_v4.z.function({
input: [TenantIdSchema, TenantProviderIdSchema],
output: zod_v4.z.promise(EmptyResponseSchema)
});
const CreateTenantProviderPolicyFn = zod_v4.z.function({
input: [
TenantIdSchema,
TenantProviderIdSchema,
CreateTenantProviderPolicySchema
],
output: zod_v4.z.promise(TenantProviderPolicySchema)
});
const GetTenantProviderPoliciesFn = zod_v4.z.function({
input: [TenantIdSchema, TenantProviderIdSchema],
output: zod_v4.z.promise(zod_v4.z.array(TenantProviderPolicySchema))
});
const GetTenantProviderPolicyFn = zod_v4.z.function({
input: [
TenantIdSchema,
TenantProviderIdSchema,
TenantProviderPolicyIdSchema
],
output: zod_v4.z.promise(TenantProviderPolicySchema)
});
const DeleteTenantProviderPolicyFn = zod_v4.z.function({
input: [
TenantIdSchema,
TenantProviderIdSchema,
TenantProviderPolicyIdSchema
],
output: zod_v4.z.promise(EmptyResponseSchema)
});
const ValidateTokenFn = zod_v4.z.function({
input: [
TenantIdSchema,
TenantProviderPolicyIdSchema,
zod_v4.z.string()
],
output: zod_v4.z.promise(ValidateTokenResponseSchema)
});
//#endregion
Object.defineProperty(exports, 'AddDomainFn', {
enumerable: true,
get: function () {
return AddDomainFn;
}
});
Object.defineProperty(exports, 'AddDomainSchema', {
enumerable: true,
get: function () {
return AddDomainSchema;
}
});
Object.defineProperty(exports, 'ClientIdSchema', {
enumerable: true,
get: function () {
return ClientIdSchema;
}
});
Object.defineProperty(exports, 'ClientSchema', {
enumerable: true,
get: function () {
return ClientSchema;
}
});
Object.defineProperty(exports, 'ConditionSchema', {
enumerable: true,
get: function () {
return ConditionSchema;
}
});
Object.defineProperty(exports, 'CreateClientFn', {
enumerable: true,
get: function () {
return CreateClientFn;
}
});
Object.defineProperty(exports, 'CreateClientSchema', {
enumerable: true,
get: function () {
return CreateClientSchema;
}
});
Object.defineProperty(exports, 'CreateProviderFn', {
enumerable: true,
get: function () {
return CreateProviderFn;
}
});
Object.defineProperty(exports, 'CreateProviderSchema', {
enumerable: true,
get: function () {
return CreateProviderSchema;
}
});
Object.defineProperty(exports, 'CreateTenantFn', {
enumerable: true,
get: function () {
return CreateTenantFn;
}
});
Object.defineProperty(exports, 'CreateTenantProviderFn', {
enumerable: true,
get: function () {
return CreateTenantProviderFn;
}
});
Object.defineProperty(exports, 'CreateTenantProviderPolicyFn', {
enumerable: true,
get: function () {
return CreateTenantProviderPolicyFn;
}
});
Object.defineProperty(exports, 'CreateTenantProviderPolicySchema', {
enumerable: true,
get: function () {
return CreateTenantProviderPolicySchema;
}
});
Object.defineProperty(exports, 'CreateTenantProviderSchema', {
enumerable: true,
get: function () {
return CreateTenantProviderSchema;
}
});
Object.defineProperty(exports, 'CreateTenantSchema', {
enumerable: true,
get: function () {
return CreateTenantSchema;
}
});
Object.defineProperty(exports, 'CreateTokenFn', {
enumerable: true,
get: function () {
return CreateTokenFn;
}
});
Object.defineProperty(exports, 'CreateTokenSchema', {
enumerable: true,
get: function () {
return CreateTokenSchema;
}
});
Object.defineProperty(exports, 'DeleteClientFn', {
enumerable: true,
get: function () {
return DeleteClientFn;
}
});
Object.defineProperty(exports, 'DeleteDomainFn', {
enumerable: true,
get: function () {
return DeleteDomainFn;
}
});
Object.defineProperty(exports, 'DeleteProviderFn', {
enumerable: true,
get: function () {
return DeleteProviderFn;
}
});
Object.defineProperty(exports, 'DeleteTenantFn', {
enumerable: true,
get: function () {
return DeleteTenantFn;
}
});
Object.defineProperty(exports, 'DeleteTenantProviderFn', {
enumerable: true,
get: function () {
return DeleteTenantProviderFn;
}
});
Object.defineProperty(exports, 'DeleteTenantProviderPolicyFn', {
enumerable: true,
get: function () {
return DeleteTenantProviderPolicyFn;
}
});
Object.defineProperty(exports, 'DomainIdSchema', {
enumerable: true,
get: function () {
return DomainIdSchema;
}
});
Object.defineProperty(exports, 'DomainSchema', {
enumerable: true,
get: function () {
return DomainSchema;
}
});
Object.defineProperty(exports, 'DomainValidationResponseSchema', {
enumerable: true,
get: function () {
return DomainValidationResponseSchema;
}
});
Object.defineProperty(exports, 'EmptyResponseSchema', {
enumerable: true,
get: function () {
return EmptyResponseSchema;
}
});
Object.defineProperty(exports, 'GetClientFn', {
enumerable: true,
get: function () {
return GetClientFn;
}
});
Object.defineProperty(exports, 'GetClientsFn', {
enumerable: true,
get: function () {
return GetClientsFn;
}
});
Object.defineProperty(exports, 'GetDomainFn', {
enumerable: true,
get: function () {
return GetDomainFn;
}
});
Object.defineProperty(exports, 'GetDomainsFn', {
enumerable: true,
get: function () {
return GetDomainsFn;
}
});
Object.defineProperty(exports, 'GetProviderFn', {
enumerable: true,
get: function () {
return GetProviderFn;
}
});
Object.defineProperty(exports, 'GetProvidersFn', {
enumerable: true,
get: function () {
return GetProvidersFn;
}
});
Object.defineProperty(exports, 'GetTenantFn', {
enumerable: true,
get: function () {
return GetTenantFn;
}
});
Object.defineProperty(exports, 'GetTenantProviderFn', {
enumerable: true,
get: function () {
return GetTenantProviderFn;
}
});
Object.defineProperty(exports, 'GetTenantProviderPoliciesFn', {
enumerable: true,
get: function () {
return GetTenantProviderPoliciesFn;
}
});
Object.defineProperty(exports, 'GetTenantProviderPolicyFn', {
enumerable: true,
get: function () {
return GetTenantProviderPolicyFn;
}
});
Object.defineProperty(exports, 'GetTenantProvidersFn', {
enumerable: true,
get: function () {
return GetTenantProvidersFn;
}
});
Object.defineProperty(exports, 'GetTenantsFn', {
enumerable: true,
get: function () {
return GetTenantsFn;
}
});
Object.defineProperty(exports, 'ProviderIdSchema', {
enumerable: true,
get: function () {
return ProviderIdSchema;
}
});
Object.defineProperty(exports, 'ProviderSchema', {
enumerable: true,
get: function () {
return ProviderSchema;
}
});
Object.defineProperty(exports, 'TenantIdSchema', {
enumerable: true,
get: function () {
return TenantIdSchema;
}
});
Object.defineProperty(exports, 'TenantProviderIdSchema', {
enumerable: true,
get: function () {
return TenantProviderIdSchema;
}
});
Object.defineProperty(exports, 'TenantProviderPolicyIdSchema', {
enumerable: true,
get: function () {
return TenantProviderPolicyIdSchema;
}
});
Object.defineProperty(exports, 'TenantProviderPolicySchema', {
enumerable: true,
get: function () {
return TenantProviderPolicySchema;
}
});
Object.defineProperty(exports, 'TenantProviderSchema', {
enumerable: true,
get: function () {
return TenantProviderSchema;
}
});
Object.defineProperty(exports, 'TenantSchema', {
enumerable: true,
get: function () {
return TenantSchema;
}
});
Object.defineProperty(exports, 'TokenSchema', {
enumerable: true,
get: function () {
return TokenSchema;
}
});
Object.defineProperty(exports, 'ValidateTokenFn', {
enumerable: true,
get: function () {
return ValidateTokenFn;
}
});
Object.defineProperty(exports, 'ValidateTokenResponseSchema', {
enumerable: true,
get: function () {
return ValidateTokenResponseSchema;
}
});
Object.defineProperty(exports, 'VerifyDomainFn', {
enumerable: true,
get: function () {
return VerifyDomainFn;
}
});
Object.defineProperty(exports, '__toESM', {
enumerable: true,
get: function () {
return __toESM;
}
});
//# sourceMappingURL=schema-BX90jiDJ.cjs.map