UNPKG

@shopify/shopify-app-remix

Version:

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

31 lines (27 loc) 1.22 kB
'use strict'; var shopifyApi = require('@shopify/shopify-api'); var fetchScopesDetails = require('./client/fetch-scopes-details.js'); function queryScopesFactory(params, session, admin) { return async function queryScopes() { const { logger } = params; logger.debug('Querying scopes details: ', { shop: session.shop, }); const scopesDetail = await fetchScopesDetails.fetchScopeDetail(admin); return mapFetchScopeDetail(scopesDetail); }; } function mapFetchScopeDetail(scopesDetailResponse) { const appInformation = scopesDetailResponse.app; const granted = new shopifyApi.AuthScopes(appInformation.installation.accessScopes.map((scope) => scope.handle)); const required = new shopifyApi.AuthScopes(appInformation.requestedAccessScopes.map((scope) => scope.handle)); const optional = new shopifyApi.AuthScopes(appInformation.optionalAccessScopes.map((scope) => scope.handle)); return { granted: granted.toArray(), required: required.toArray(), optional: optional.toArray(), }; } exports.mapFetchScopeDetail = mapFetchScopeDetail; exports.queryScopesFactory = queryScopesFactory; //# sourceMappingURL=query.js.map