convex
Version:
Client for the Convex Cloud
78 lines (77 loc) • 2.25 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) {
const errorText = await response.text();
if (response.status === 422 && errorText.includes("already exists")) {
return { modified: false };
}
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) {
const errorText = await response.text();
if (response.status === 409 && (errorText.includes("duplicate_cors_origin") || errorText.includes("already exists"))) {
return { modified: false };
}
return await ctx.crash({
exitCode: 1,
errorType: "fatal",
printedMessage: `Failed to create CORS origin: ${response.status} ${errorText}`
});
}
return { modified: true };
}
//# sourceMappingURL=environmentApi.js.map