convex
Version:
Client for the Convex Cloud
84 lines (83 loc) • 2.39 kB
JavaScript
;
export async function createRedirectURI(ctx, apiKey, uri) {
const response = await fetch(
"https://api.workos.com/user_management/redirect_uris",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`
},
body: JSON.stringify({ uri })
}
);
if (!response.ok) {
if (response.status === 422) {
const errorText2 = await response.text();
if (errorText2.includes("already exists")) {
return { modified: false };
}
}
const errorText = await response.text();
return await ctx.crash({
exitCode: 1,
errorType: "fatal",
printedMessage: `Failed to create redirect URI: ${response.status} ${errorText}`
});
}
return { modified: true };
}
export async function updateAppHomepageUrl(ctx, apiKey, url) {
const response = await fetch(
"https://api.workos.com/user_management/app_homepage_url",
{
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`
},
body: JSON.stringify({ url })
}
);
if (!response.ok) {
const errorText = await response.text();
if (response.status === 422) {
return { modified: false };
}
return await ctx.crash({
exitCode: 1,
errorType: "fatal",
printedMessage: `Failed to update app homepage URL: ${response.status} ${errorText}`
});
}
return { modified: true };
}
export async function createCORSOrigin(ctx, apiKey, origin) {
const response = await fetch(
"https://api.workos.com/user_management/cors_origins",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${apiKey}`
},
body: JSON.stringify({ origin })
}
);
if (!response.ok) {
if (response.status === 409) {
const errorText2 = await response.text();
if (errorText2.includes("duplicate_cors_origin") || errorText2.includes("already exists")) {
return { modified: false };
}
}
const errorText = await response.text();
return await ctx.crash({
exitCode: 1,
errorType: "fatal",
printedMessage: `Failed to create CORS origin: ${response.status} ${errorText}`
});
}
return { modified: true };
}
//# sourceMappingURL=environmentApi.js.map