UNPKG

@shopify/shopify-app-remix

Version:

Shopify Remix - to simplify the building of Shopify Apps with Remix

37 lines (34 loc) 1.21 kB
import { revokeScopes } from './client/revoke-scopes.mjs'; function revokeScopesFactory(params, session, admin) { return async function revoke(scopes) { const { logger } = params; await validateScopes(scopes); logger.debug('Revoke scopes: ', { shop: session.shop, scopes, }); const revokeScopesResult = await revokeScopes(admin, scopes); if (revokeScopesResult.userErrors?.length > 0) { logger.error('Failed to revoke scopes: ', { shop: session.shop, errors: revokeScopesResult.userErrors, }); throw new Response(JSON.stringify(revokeScopesResult.userErrors), { status: 422, headers: { 'Content-Type': 'application/json', }, }); } return { revoked: revokeScopesResult.revoked.map((scope) => scope.handle), }; }; } async function validateScopes(scopes) { if (!scopes || scopes.length === 0) { throw new Response('No scopes provided', { status: 400 }); } } export { revokeScopesFactory }; //# sourceMappingURL=revoke.mjs.map