@shopify/shopify-app-remix 3.8.4 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/cjs/server/adapters/node/index.js +0 -2
- package/dist/cjs/server/adapters/node/index.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/authenticate.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/helpers/create-admin-api-context.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/helpers/trigger-after-auth-hook.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/scope/client/fetch-scopes-details.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/scope/client/revoke-scopes.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/scope/factory.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/scope/query.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/scope/request.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/scope/revoke.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/strategies/auth-code-flow.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/strategies/merchant-custom-app.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/strategies/token-exchange.js.map +1 -1
- package/dist/cjs/server/authenticate/flow/authenticate.js.map +1 -1
- package/dist/cjs/server/authenticate/fulfillment-service/authenticate.js.map +1 -1
- package/dist/cjs/server/authenticate/public/appProxy/authenticate.js.map +1 -1
- package/dist/cjs/server/authenticate/public/factory.js.map +1 -1
- package/dist/cjs/server/authenticate/webhooks/authenticate.js.map +1 -1
- package/dist/cjs/server/clients/admin/factory.js +0 -11
- package/dist/cjs/server/clients/admin/factory.js.map +1 -1
- package/dist/cjs/server/clients/admin/graphql.js +1 -2
- package/dist/cjs/server/clients/admin/graphql.js.map +1 -1
- package/dist/cjs/server/future/flags.js.map +1 -1
- package/dist/cjs/server/index.js +0 -8
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/server/override-logger.js +2 -2
- package/dist/cjs/server/override-logger.js.map +1 -1
- package/dist/cjs/server/shopify-app.js +1 -2
- package/dist/cjs/server/shopify-app.js.map +1 -1
- package/dist/cjs/server/test-helpers/test-config.js.map +1 -1
- package/dist/cjs/server/types.js.map +1 -1
- package/dist/cjs/server/unauthenticated/admin/factory.js.map +1 -1
- package/dist/cjs/server/version.js +1 -1
- package/dist/cjs/server/version.js.map +1 -1
- package/dist/esm/server/adapters/node/index.mjs +1 -3
- package/dist/esm/server/adapters/node/index.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/authenticate.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/helpers/create-admin-api-context.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/helpers/trigger-after-auth-hook.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/scope/client/fetch-scopes-details.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/scope/client/revoke-scopes.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/scope/factory.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/scope/query.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/scope/request.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/scope/revoke.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/strategies/auth-code-flow.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/strategies/merchant-custom-app.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/strategies/token-exchange.mjs.map +1 -1
- package/dist/esm/server/authenticate/flow/authenticate.mjs.map +1 -1
- package/dist/esm/server/authenticate/fulfillment-service/authenticate.mjs.map +1 -1
- package/dist/esm/server/authenticate/public/appProxy/authenticate.mjs.map +1 -1
- package/dist/esm/server/authenticate/public/factory.mjs.map +1 -1
- package/dist/esm/server/authenticate/webhooks/authenticate.mjs.map +1 -1
- package/dist/esm/server/clients/admin/factory.mjs +0 -11
- package/dist/esm/server/clients/admin/factory.mjs.map +1 -1
- package/dist/esm/server/clients/admin/graphql.mjs +1 -2
- package/dist/esm/server/clients/admin/graphql.mjs.map +1 -1
- package/dist/esm/server/future/flags.mjs.map +1 -1
- package/dist/esm/server/index.mjs +1 -1
- package/dist/esm/server/index.mjs.map +1 -1
- package/dist/esm/server/override-logger.mjs +2 -2
- package/dist/esm/server/override-logger.mjs.map +1 -1
- package/dist/esm/server/shopify-app.mjs +2 -3
- package/dist/esm/server/shopify-app.mjs.map +1 -1
- package/dist/esm/server/test-helpers/test-config.mjs.map +1 -1
- package/dist/esm/server/types.mjs.map +1 -1
- package/dist/esm/server/unauthenticated/admin/factory.mjs.map +1 -1
- package/dist/esm/server/version.mjs +1 -1
- package/dist/esm/server/version.mjs.map +1 -1
- package/dist/ts/server/authenticate/admin/authenticate.admin.doc.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/authenticate.d.ts +2 -2
- package/dist/ts/server/authenticate/admin/authenticate.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/billing/types.d.ts +1 -2
- package/dist/ts/server/authenticate/admin/billing/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/helpers/create-admin-api-context.d.ts +2 -3
- package/dist/ts/server/authenticate/admin/helpers/create-admin-api-context.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/helpers/trigger-after-auth-hook.d.ts +2 -3
- package/dist/ts/server/authenticate/admin/helpers/trigger-after-auth-hook.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/scope/client/fetch-scopes-details.d.ts +1 -2
- package/dist/ts/server/authenticate/admin/scope/client/fetch-scopes-details.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/scope/client/revoke-scopes.d.ts +1 -2
- package/dist/ts/server/authenticate/admin/scope/client/revoke-scopes.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/scope/factory.d.ts +1 -2
- package/dist/ts/server/authenticate/admin/scope/factory.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/scope/query.d.ts +1 -2
- package/dist/ts/server/authenticate/admin/scope/query.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/scope/request.d.ts +1 -2
- package/dist/ts/server/authenticate/admin/scope/request.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/scope/revoke.d.ts +1 -2
- package/dist/ts/server/authenticate/admin/scope/revoke.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/strategies/auth-code-flow.d.ts +3 -3
- package/dist/ts/server/authenticate/admin/strategies/auth-code-flow.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/strategies/merchant-custom-app.d.ts +2 -2
- package/dist/ts/server/authenticate/admin/strategies/merchant-custom-app.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/strategies/token-exchange.d.ts +2 -2
- package/dist/ts/server/authenticate/admin/strategies/token-exchange.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/types.d.ts +9 -9
- package/dist/ts/server/authenticate/admin/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/flow/authenticate.d.ts +1 -3
- package/dist/ts/server/authenticate/flow/authenticate.d.ts.map +1 -1
- package/dist/ts/server/authenticate/flow/types.d.ts +4 -5
- package/dist/ts/server/authenticate/flow/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/fulfillment-service/authenticate.d.ts +1 -3
- package/dist/ts/server/authenticate/fulfillment-service/authenticate.d.ts.map +1 -1
- package/dist/ts/server/authenticate/fulfillment-service/types.d.ts +4 -5
- package/dist/ts/server/authenticate/fulfillment-service/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/public/appProxy/authenticate.d.ts +1 -3
- package/dist/ts/server/authenticate/public/appProxy/authenticate.d.ts.map +1 -1
- package/dist/ts/server/authenticate/public/appProxy/types.d.ts +6 -7
- package/dist/ts/server/authenticate/public/appProxy/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/public/factory.d.ts +1 -3
- package/dist/ts/server/authenticate/public/factory.d.ts.map +1 -1
- package/dist/ts/server/authenticate/public/types.d.ts +2 -3
- package/dist/ts/server/authenticate/public/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/webhooks/authenticate.d.ts +1 -3
- package/dist/ts/server/authenticate/webhooks/authenticate.d.ts.map +1 -1
- package/dist/ts/server/authenticate/webhooks/types.d.ts +5 -6
- package/dist/ts/server/authenticate/webhooks/types.d.ts.map +1 -1
- package/dist/ts/server/clients/admin/factory.d.ts +3 -4
- package/dist/ts/server/clients/admin/factory.d.ts.map +1 -1
- package/dist/ts/server/clients/admin/graphql.d.ts.map +1 -1
- package/dist/ts/server/clients/admin/types.d.ts +2 -134
- package/dist/ts/server/clients/admin/types.d.ts.map +1 -1
- package/dist/ts/server/config-types.d.ts +14 -16
- package/dist/ts/server/config-types.d.ts.map +1 -1
- package/dist/ts/server/future/flags.d.ts +2 -22
- package/dist/ts/server/future/flags.d.ts.map +1 -1
- package/dist/ts/server/index.d.ts +1 -1
- package/dist/ts/server/index.d.ts.map +1 -1
- package/dist/ts/server/shopify-app.d.ts +1 -2
- package/dist/ts/server/shopify-app.d.ts.map +1 -1
- package/dist/ts/server/test-helpers/test-config.d.ts +2 -2
- package/dist/ts/server/test-helpers/test-config.d.ts.map +1 -1
- package/dist/ts/server/types-contexts.d.ts +17 -31
- package/dist/ts/server/types-contexts.d.ts.map +1 -1
- package/dist/ts/server/types.d.ts +13 -14
- package/dist/ts/server/types.d.ts.map +1 -1
- package/dist/ts/server/unauthenticated/admin/factory.d.ts +1 -3
- package/dist/ts/server/unauthenticated/admin/factory.d.ts.map +1 -1
- package/dist/ts/server/unauthenticated/admin/types.d.ts +5 -6
- package/dist/ts/server/unauthenticated/admin/types.d.ts.map +1 -1
- package/dist/ts/server/unauthenticated/types.d.ts +3 -5
- package/dist/ts/server/unauthenticated/types.d.ts.map +1 -1
- package/dist/ts/server/version.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +13 -16
- package/dist/cjs/server/clients/admin/rest.js +0 -132
- package/dist/cjs/server/clients/admin/rest.js.map +0 -1
- package/dist/esm/server/clients/admin/rest.mjs +0 -130
- package/dist/esm/server/clients/admin/rest.mjs.map +0 -1
- package/dist/ts/server/clients/admin/rest.d.ts +0 -39
- package/dist/ts/server/clients/admin/rest.d.ts.map +0 -1
package/dist/cjs/server/index.js
CHANGED
|
@@ -28,18 +28,10 @@ Object.defineProperty(exports, "DeliveryMethod", {
|
|
|
28
28
|
enumerable: true,
|
|
29
29
|
get: function () { return shopifyApi.DeliveryMethod; }
|
|
30
30
|
});
|
|
31
|
-
Object.defineProperty(exports, "LATEST_API_VERSION", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return shopifyApi.LATEST_API_VERSION; }
|
|
34
|
-
});
|
|
35
31
|
Object.defineProperty(exports, "LogSeverity", {
|
|
36
32
|
enumerable: true,
|
|
37
33
|
get: function () { return shopifyApi.LogSeverity; }
|
|
38
34
|
});
|
|
39
|
-
Object.defineProperty(exports, "RELEASE_CANDIDATE_API_VERSION", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () { return shopifyApi.RELEASE_CANDIDATE_API_VERSION; }
|
|
42
|
-
});
|
|
43
35
|
Object.defineProperty(exports, "Session", {
|
|
44
36
|
enumerable: true,
|
|
45
37
|
get: function () { return shopifyApi.Session; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/server/index.ts"],"sourcesContent":["import '@shopify/shopify-api/adapters/web-api';\nimport {setAbstractRuntimeString} from '@shopify/shopify-api/runtime';\n\nsetAbstractRuntimeString(() => {\n return `Remix`;\n});\n\nexport {\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/server/index.ts"],"sourcesContent":["import '@shopify/shopify-api/adapters/web-api';\nimport {setAbstractRuntimeString} from '@shopify/shopify-api/runtime';\n\nsetAbstractRuntimeString(() => {\n return `Remix`;\n});\n\nexport {\n LogSeverity,\n DeliveryMethod,\n BillingInterval,\n BillingReplacementBehavior,\n ApiVersion,\n Session,\n} from '@shopify/shopify-api';\n\nexport type {JwtPayload} from '@shopify/shopify-api';\n\nexport type * from './types-contexts';\nexport type {ShopifyApp, LoginError} from './types';\nexport {LoginErrorType, AppDistribution} from './types';\nexport {boundary} from './boundary';\nexport {shopifyApp} from './shopify-app';\nexport * from './errors';\n"],"names":["setAbstractRuntimeString"],"mappings":";;;;;;;;;;AAGAA,gCAAwB,CAAC,MAAK;AAC5B,IAAA,OAAO,OAAO;AAChB,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var compareVersions = require('compare-versions');
|
|
4
4
|
var shopifyApi = require('@shopify/shopify-api');
|
|
5
5
|
var version = require('./version.js');
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ function overrideLogger(logger) {
|
|
|
12
12
|
const warningFunction = (message, context = {}) => logger.warning(message, { ...baseContext, ...context });
|
|
13
13
|
function deprecated(warningFunction) {
|
|
14
14
|
return function (version$1, message) {
|
|
15
|
-
if (
|
|
15
|
+
if (compareVersions.compare(version.SHOPIFY_REMIX_LIBRARY_VERSION, version$1, '>=')) {
|
|
16
16
|
throw new shopifyApi.FeatureDeprecatedError(`Feature was deprecated in version ${version$1}`);
|
|
17
17
|
}
|
|
18
18
|
return warningFunction(`[Deprecated | ${version$1}] ${message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"override-logger.js","sources":["../../../../src/server/override-logger.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"override-logger.js","sources":["../../../../src/server/override-logger.ts"],"sourcesContent":["import {compare} from 'compare-versions';\nimport {FeatureDeprecatedError, Shopify} from '@shopify/shopify-api';\n\nimport {SHOPIFY_REMIX_LIBRARY_VERSION} from './version';\n\n// eslint-disable-next-line no-warning-comments\n// TODO This has been copied from shopify-app-express, it should be extracted into a shared package\n// https://github.com/orgs/Shopify/projects/6899/views/1?pane=issue&itemId=28358070\nexport function overrideLogger(logger: Shopify['logger']): Shopify['logger'] {\n const baseContext = {package: 'shopify-app'};\n\n const warningFunction: Shopify['logger']['warning'] = (\n message,\n context = {},\n ) => logger.warning(message, {...baseContext, ...context});\n\n function deprecated(warningFunction: Shopify['logger']['warning']) {\n return function (version: string, message: string): Promise<void> {\n if (compare(SHOPIFY_REMIX_LIBRARY_VERSION, version, '>=')) {\n throw new FeatureDeprecatedError(\n `Feature was deprecated in version ${version}`,\n );\n }\n\n return warningFunction(`[Deprecated | ${version}] ${message}`);\n };\n }\n\n return {\n ...logger,\n log: (severity, message, context = {}) =>\n logger.log(severity, message, {...baseContext, ...context}),\n debug: (message, context = {}) =>\n logger.debug(message, {...baseContext, ...context}),\n info: (message, context = {}) =>\n logger.info(message, {...baseContext, ...context}),\n warning: warningFunction,\n error: (message, context = {}) =>\n logger.error(message, {...baseContext, ...context}),\n deprecated: deprecated(warningFunction),\n };\n}\n"],"names":["version","compare","SHOPIFY_REMIX_LIBRARY_VERSION","FeatureDeprecatedError"],"mappings":";;;;;;AAKA;AACA;AACA;AACM,SAAU,cAAc,CAAC,MAAyB,EAAA;AACtD,IAAA,MAAM,WAAW,GAAG,EAAC,OAAO,EAAE,aAAa,EAAC;IAE5C,MAAM,eAAe,GAAiC,CACpD,OAAO,EACP,OAAO,GAAG,EAAE,KACT,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAC,GAAG,WAAW,EAAE,GAAG,OAAO,EAAC,CAAC;IAE1D,SAAS,UAAU,CAAC,eAA6C,EAAA;QAC/D,OAAO,UAAUA,SAAe,EAAE,OAAe,EAAA;YAC/C,IAAIC,uBAAO,CAACC,qCAA6B,EAAEF,SAAO,EAAE,IAAI,CAAC,EAAE;AACzD,gBAAA,MAAM,IAAIG,iCAAsB,CAC9B,qCAAqCH,SAAO,CAAA,CAAE,CAC/C;YACH;YAEA,OAAO,eAAe,CAAC,CAAA,cAAA,EAAiBA,SAAO,KAAK,OAAO,CAAA,CAAE,CAAC;AAChE,QAAA,CAAC;IACH;IAEA,OAAO;AACL,QAAA,GAAG,MAAM;QACT,GAAG,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,KACnC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAC,GAAG,WAAW,EAAE,GAAG,OAAO,EAAC,CAAC;QAC7D,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,KAC3B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAC,GAAG,WAAW,EAAE,GAAG,OAAO,EAAC,CAAC;QACrD,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,KAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,EAAC,GAAG,WAAW,EAAE,GAAG,OAAO,EAAC,CAAC;AACpD,QAAA,OAAO,EAAE,eAAe;QACxB,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,KAC3B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAC,GAAG,WAAW,EAAE,GAAG,OAAO,EAAC,CAAC;AACrD,QAAA,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC;KACxC;AACH;;;;"}
|
|
@@ -126,11 +126,10 @@ function deriveApi(appConfig) {
|
|
|
126
126
|
hostScheme: appUrl.protocol.replace(':', ''),
|
|
127
127
|
userAgentPrefix,
|
|
128
128
|
isEmbeddedApp: appConfig.isEmbeddedApp ?? true,
|
|
129
|
-
apiVersion: appConfig.apiVersion
|
|
129
|
+
apiVersion: appConfig.apiVersion,
|
|
130
130
|
isCustomStoreApp: appConfig.distribution === types.AppDistribution.ShopifyAdmin,
|
|
131
131
|
billing: appConfig.billing,
|
|
132
132
|
future: {
|
|
133
|
-
lineItemBilling: true,
|
|
134
133
|
unstable_managedPricingSupport: true,
|
|
135
134
|
},
|
|
136
135
|
_logDisabledFutureFlags: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-app.js","sources":["../../../../src/server/shopify-app.ts"],"sourcesContent":["import '@shopify/shopify-api/adapters/web-api';\nimport {\n ConfigInterface as ApiConfig,\n LATEST_API_VERSION,\n ShopifyError,\n ShopifyRestResources,\n shopifyApi,\n} from '@shopify/shopify-api';\nimport {SessionStorage} from '@shopify/shopify-app-session-storage';\n\nimport {type AppConfig, type AppConfigArg} from './config-types';\nimport {\n AppDistribution,\n type BasicParams,\n type ShopifyApp,\n type ShopifyAppBase,\n type AdminApp,\n type SingleMerchantApp,\n type AppStoreApp,\n} from './types';\nimport {SHOPIFY_REMIX_LIBRARY_VERSION} from './version';\nimport {registerWebhooksFactory} from './authenticate/webhooks';\nimport {authStrategyFactory} from './authenticate/admin/authenticate';\nimport {authenticateWebhookFactory} from './authenticate/webhooks/authenticate';\nimport {overrideLogger} from './override-logger';\nimport {addDocumentResponseHeadersFactory} from './authenticate/helpers';\nimport {loginFactory} from './authenticate/login/login';\nimport {unauthenticatedAdminContextFactory} from './unauthenticated/admin';\nimport {authenticatePublicFactory} from './authenticate/public';\nimport {unauthenticatedStorefrontContextFactory} from './unauthenticated/storefront';\nimport {AuthCodeFlowStrategy} from './authenticate/admin/strategies/auth-code-flow';\nimport {TokenExchangeStrategy} from './authenticate/admin/strategies/token-exchange';\nimport {MerchantCustomAuth} from './authenticate/admin/strategies/merchant-custom-app';\nimport {IdempotentPromiseHandler} from './authenticate/helpers/idempotent-promise-handler';\nimport {authenticateFlowFactory} from './authenticate/flow/authenticate';\nimport {authenticateFulfillmentServiceFactory} from './authenticate/fulfillment-service/authenticate';\nimport {FutureFlagOptions, logDisabledFutureFlags} from './future/flags';\n\n/**\n * Creates an object your app will use to interact with Shopify.\n *\n * @param appConfig Configuration options for your Shopify app, such as the scopes your app needs.\n * @returns `ShopifyApp` An object constructed using your appConfig. It has methods for interacting with Shopify.\n *\n * @example\n * <caption>The minimum viable configuration</caption>\n * ```ts\n * // /shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * apiKey: process.env.SHOPIFY_API_KEY!,\n * apiSecretKey: process.env.SHOPIFY_API_SECRET!,\n * scopes: process.env.SCOPES?.split(\",\")!,\n * appUrl: process.env.SHOPIFY_APP_URL!,\n * });\n * export default shopify;\n * ```\n */\nexport function shopifyApp<\n Config extends AppConfigArg<Resources, Storage, Future>,\n Resources extends ShopifyRestResources,\n Storage extends SessionStorage,\n Future extends FutureFlagOptions = Config['future'],\n>(appConfig: Readonly<Config>): ShopifyApp<Config> {\n const api = deriveApi(appConfig);\n const config = deriveConfig<Storage>(appConfig, api.config);\n const logger = overrideLogger(api.logger);\n\n if (appConfig.webhooks) {\n api.webhooks.addHandlers(appConfig.webhooks);\n }\n\n const params: BasicParams = {api, config, logger};\n\n let strategy;\n if (config.distribution === AppDistribution.ShopifyAdmin) {\n strategy = new MerchantCustomAuth(params);\n } else if (\n config.future.unstable_newEmbeddedAuthStrategy &&\n config.isEmbeddedApp\n ) {\n strategy = new TokenExchangeStrategy(params);\n } else {\n strategy = new AuthCodeFlowStrategy(params);\n }\n\n const authStrategy = authStrategyFactory<Config, Resources>({\n ...params,\n strategy,\n });\n\n const shopify:\n | AdminApp<Config>\n | AppStoreApp<Config>\n | SingleMerchantApp<Config> = {\n sessionStorage: config.sessionStorage,\n addDocumentResponseHeaders: addDocumentResponseHeadersFactory(params),\n registerWebhooks: registerWebhooksFactory(params),\n authenticate: {\n admin: authStrategy,\n flow: authenticateFlowFactory<Config, Resources>(params),\n public: authenticatePublicFactory<Config, Resources>(params),\n fulfillmentService: authenticateFulfillmentServiceFactory<\n Config,\n Resources\n >(params),\n webhook: authenticateWebhookFactory<Config, Resources, string>(params),\n },\n unauthenticated: {\n admin: unauthenticatedAdminContextFactory<Config, Resources>(params),\n storefront: unauthenticatedStorefrontContextFactory(params),\n },\n };\n\n if (\n isAppStoreApp(shopify, appConfig) ||\n isSingleMerchantApp(shopify, appConfig)\n ) {\n shopify.login = loginFactory(params);\n }\n\n logDisabledFutureFlags(config, logger);\n\n return shopify as ShopifyApp<Config>;\n}\n\nfunction isAppStoreApp<Config extends AppConfigArg>(\n _shopify: ShopifyAppBase<Config>,\n config: Config,\n): _shopify is AppStoreApp<Config> {\n return config.distribution === AppDistribution.AppStore;\n}\n\nfunction isSingleMerchantApp<Config extends AppConfigArg>(\n _shopify: ShopifyAppBase<Config>,\n config: Config,\n): _shopify is SingleMerchantApp<Config> {\n return config.distribution === AppDistribution.SingleMerchant;\n}\n\n// This function is only exported so we can unit test it without having to mock the underlying module.\n// It's not available to consumers of the library because it is not exported in the index module, and never should be.\nexport function deriveApi(appConfig: AppConfigArg): BasicParams['api'] {\n let appUrl: URL;\n try {\n appUrl = new URL(appConfig.appUrl);\n } catch (error) {\n const message =\n appConfig.appUrl === ''\n ? `Detected an empty appUrl configuration, please make sure to set the necessary environment variables.\\n` +\n `If you're deploying your app, you can find more information at https://shopify.dev/docs/apps/launch/deployment/deploy-web-app/deploy-to-hosting-service#step-4-set-up-environment-variables`\n : `Invalid appUrl configuration '${appConfig.appUrl}', please provide a valid URL.`;\n throw new ShopifyError(message);\n }\n\n /* eslint-disable no-process-env */\n if (appUrl.hostname === 'localhost' && !appUrl.port && process.env.PORT) {\n appUrl.port = process.env.PORT;\n }\n /* eslint-enable no-process-env */\n appConfig.appUrl = appUrl.origin;\n\n let userAgentPrefix = `Shopify Remix Library v${SHOPIFY_REMIX_LIBRARY_VERSION}`;\n if (appConfig.userAgentPrefix) {\n userAgentPrefix = `${appConfig.userAgentPrefix} | ${userAgentPrefix}`;\n }\n\n return shopifyApi({\n ...appConfig,\n hostName: appUrl.host,\n hostScheme: appUrl.protocol.replace(':', '') as 'http' | 'https',\n userAgentPrefix,\n isEmbeddedApp: appConfig.isEmbeddedApp ?? true,\n apiVersion: appConfig.apiVersion ?? LATEST_API_VERSION,\n isCustomStoreApp: appConfig.distribution === AppDistribution.ShopifyAdmin,\n billing: appConfig.billing as ApiConfig['billing'],\n future: {\n lineItemBilling: true,\n unstable_managedPricingSupport: true,\n },\n _logDisabledFutureFlags: false,\n });\n}\n\nfunction deriveConfig<Storage extends SessionStorage>(\n appConfig: AppConfigArg,\n apiConfig: ApiConfig,\n): AppConfig<Storage> {\n if (\n !appConfig.sessionStorage &&\n appConfig.distribution !== AppDistribution.ShopifyAdmin\n ) {\n throw new ShopifyError(\n 'Please provide a valid session storage. Refer to https://github.com/Shopify/shopify-app-js/blob/main/README.md#session-storage-options for options.',\n );\n }\n\n const authPathPrefix = appConfig.authPathPrefix || '/auth';\n appConfig.distribution = appConfig.distribution ?? AppDistribution.AppStore;\n\n return {\n ...appConfig,\n ...apiConfig,\n billing: appConfig.billing as ApiConfig['billing'],\n scopes: apiConfig.scopes,\n idempotentPromiseHandler: new IdempotentPromiseHandler(),\n canUseLoginForm: appConfig.distribution !== AppDistribution.ShopifyAdmin,\n useOnlineTokens: appConfig.useOnlineTokens ?? false,\n hooks: appConfig.hooks ?? {},\n sessionStorage: appConfig.sessionStorage as Storage,\n future: appConfig.future ?? {},\n auth: {\n path: authPathPrefix,\n callbackPath: `${authPathPrefix}/callback`,\n patchSessionTokenPath: `${authPathPrefix}/session-token`,\n exitIframePath: `${authPathPrefix}/exit-iframe`,\n loginPath: `${authPathPrefix}/login`,\n },\n distribution: appConfig.distribution,\n };\n}\n"],"names":["overrideLogger","AppDistribution","MerchantCustomAuth","TokenExchangeStrategy","AuthCodeFlowStrategy","authStrategyFactory","addDocumentResponseHeadersFactory","registerWebhooksFactory","authenticateFlowFactory","authenticatePublicFactory","authenticateFulfillmentServiceFactory","authenticateWebhookFactory","unauthenticatedAdminContextFactory","unauthenticatedStorefrontContextFactory","loginFactory","logDisabledFutureFlags","ShopifyError","SHOPIFY_REMIX_LIBRARY_VERSION","shopifyApi","LATEST_API_VERSION","IdempotentPromiseHandler"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,UAAU,CAKxB,SAA2B,EAAA;AAC3B,IAAA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AA,GAAG,SAAS;AACZ,QAAA,GAAG,SAAS;QACZ,OAAO,EAAE,SAAS,CAAC,OAA+B;QAClD,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,wBAAwB,EAAE,IAAImB,iDAAwB,EAAE;AACxD,QAAA,eAAe,EAAE,SAAS,CAAC,YAAY,KAAKnB,qBAAe,CAAC,YAAY;AACxE,QAAA,eAAe,EAAE,SAAS,CAAC,eAAe,IAAI,KAAK;AACnD,QAAA,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,EAAE;QAC5B,cAAc,EAAE,SAAS,CAAC,cAAyB;AACnD,QAAA,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,EAAE;AAC9B,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,cAAc;YACpB,YAAY,EAAE,CAAA,EAAG,cAAc,CAAA,SAAA,CAAW;YAC1C,qBAAqB,EAAE,CAAA,EAAG,cAAc,CAAA,cAAA,CAAgB;YACxD,cAAc,EAAE,CAAA,EAAG,cAAc,CAAA,YAAA,CAAc;YAC/C,SAAS,EAAE,CAAA,EAAG,cAAc,CAAA,MAAA,CAAQ;AACrC,SAAA;QACD,YAAY,EAAE,SAAS,CAAC,YAAY;KACrC;AACH;;;;;"}
|
|
1
|
+
{"version":3,"file":"shopify-app.js","sources":["../../../../src/server/shopify-app.ts"],"sourcesContent":["import '@shopify/shopify-api/adapters/web-api';\nimport {\n ConfigInterface as ApiConfig,\n ShopifyError,\n shopifyApi,\n} from '@shopify/shopify-api';\nimport {SessionStorage} from '@shopify/shopify-app-session-storage';\n\nimport {type AppConfig, type AppConfigArg} from './config-types';\nimport {\n AppDistribution,\n type BasicParams,\n type ShopifyApp,\n type ShopifyAppBase,\n type AdminApp,\n type SingleMerchantApp,\n type AppStoreApp,\n} from './types';\nimport {SHOPIFY_REMIX_LIBRARY_VERSION} from './version';\nimport {registerWebhooksFactory} from './authenticate/webhooks';\nimport {authStrategyFactory} from './authenticate/admin/authenticate';\nimport {authenticateWebhookFactory} from './authenticate/webhooks/authenticate';\nimport {overrideLogger} from './override-logger';\nimport {addDocumentResponseHeadersFactory} from './authenticate/helpers';\nimport {loginFactory} from './authenticate/login/login';\nimport {unauthenticatedAdminContextFactory} from './unauthenticated/admin';\nimport {authenticatePublicFactory} from './authenticate/public';\nimport {unauthenticatedStorefrontContextFactory} from './unauthenticated/storefront';\nimport {AuthCodeFlowStrategy} from './authenticate/admin/strategies/auth-code-flow';\nimport {TokenExchangeStrategy} from './authenticate/admin/strategies/token-exchange';\nimport {MerchantCustomAuth} from './authenticate/admin/strategies/merchant-custom-app';\nimport {IdempotentPromiseHandler} from './authenticate/helpers/idempotent-promise-handler';\nimport {authenticateFlowFactory} from './authenticate/flow/authenticate';\nimport {authenticateFulfillmentServiceFactory} from './authenticate/fulfillment-service/authenticate';\nimport {FutureFlagOptions, logDisabledFutureFlags} from './future/flags';\n\n/**\n * Creates an object your app will use to interact with Shopify.\n *\n * @param appConfig Configuration options for your Shopify app, such as the scopes your app needs.\n * @returns `ShopifyApp` An object constructed using your appConfig. It has methods for interacting with Shopify.\n *\n * @example\n * <caption>The minimum viable configuration</caption>\n * ```ts\n * // /shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * apiKey: process.env.SHOPIFY_API_KEY!,\n * apiSecretKey: process.env.SHOPIFY_API_SECRET!,\n * scopes: process.env.SCOPES?.split(\",\")!,\n * appUrl: process.env.SHOPIFY_APP_URL!,\n * });\n * export default shopify;\n * ```\n */\nexport function shopifyApp<\n Config extends AppConfigArg<Storage, Future>,\n Storage extends SessionStorage,\n Future extends FutureFlagOptions = Config['future'],\n>(appConfig: Readonly<Config>): ShopifyApp<Config> {\n const api = deriveApi(appConfig);\n const config = deriveConfig<Storage>(appConfig, api.config);\n const logger = overrideLogger(api.logger);\n\n if (appConfig.webhooks) {\n api.webhooks.addHandlers(appConfig.webhooks);\n }\n\n const params: BasicParams = {api, config, logger};\n\n let strategy;\n if (config.distribution === AppDistribution.ShopifyAdmin) {\n strategy = new MerchantCustomAuth(params);\n } else if (\n config.future.unstable_newEmbeddedAuthStrategy &&\n config.isEmbeddedApp\n ) {\n strategy = new TokenExchangeStrategy(params);\n } else {\n strategy = new AuthCodeFlowStrategy(params);\n }\n\n const authStrategy = authStrategyFactory<Config>({\n ...params,\n strategy,\n });\n\n const shopify:\n | AdminApp<Config>\n | AppStoreApp<Config>\n | SingleMerchantApp<Config> = {\n sessionStorage: config.sessionStorage,\n addDocumentResponseHeaders: addDocumentResponseHeadersFactory(params),\n registerWebhooks: registerWebhooksFactory(params),\n authenticate: {\n admin: authStrategy,\n flow: authenticateFlowFactory(params),\n public: authenticatePublicFactory(params),\n fulfillmentService: authenticateFulfillmentServiceFactory(params),\n webhook: authenticateWebhookFactory<string>(params),\n },\n unauthenticated: {\n admin: unauthenticatedAdminContextFactory(params),\n storefront: unauthenticatedStorefrontContextFactory(params),\n },\n };\n\n if (\n isAppStoreApp(shopify, appConfig) ||\n isSingleMerchantApp(shopify, appConfig)\n ) {\n shopify.login = loginFactory(params);\n }\n\n logDisabledFutureFlags(config, logger);\n\n return shopify as ShopifyApp<Config>;\n}\n\nfunction isAppStoreApp<Config extends AppConfigArg>(\n _shopify: ShopifyAppBase<Config>,\n config: Config,\n): _shopify is AppStoreApp<Config> {\n return config.distribution === AppDistribution.AppStore;\n}\n\nfunction isSingleMerchantApp<Config extends AppConfigArg>(\n _shopify: ShopifyAppBase<Config>,\n config: Config,\n): _shopify is SingleMerchantApp<Config> {\n return config.distribution === AppDistribution.SingleMerchant;\n}\n\n// This function is only exported so we can unit test it without having to mock the underlying module.\n// It's not available to consumers of the library because it is not exported in the index module, and never should be.\nexport function deriveApi(appConfig: AppConfigArg): BasicParams['api'] {\n let appUrl: URL;\n try {\n appUrl = new URL(appConfig.appUrl);\n } catch (error) {\n const message =\n appConfig.appUrl === ''\n ? `Detected an empty appUrl configuration, please make sure to set the necessary environment variables.\\n` +\n `If you're deploying your app, you can find more information at https://shopify.dev/docs/apps/launch/deployment/deploy-web-app/deploy-to-hosting-service#step-4-set-up-environment-variables`\n : `Invalid appUrl configuration '${appConfig.appUrl}', please provide a valid URL.`;\n throw new ShopifyError(message);\n }\n\n /* eslint-disable no-process-env */\n if (appUrl.hostname === 'localhost' && !appUrl.port && process.env.PORT) {\n appUrl.port = process.env.PORT;\n }\n /* eslint-enable no-process-env */\n appConfig.appUrl = appUrl.origin;\n\n let userAgentPrefix = `Shopify Remix Library v${SHOPIFY_REMIX_LIBRARY_VERSION}`;\n if (appConfig.userAgentPrefix) {\n userAgentPrefix = `${appConfig.userAgentPrefix} | ${userAgentPrefix}`;\n }\n\n return shopifyApi({\n ...appConfig,\n hostName: appUrl.host,\n hostScheme: appUrl.protocol.replace(':', '') as 'http' | 'https',\n userAgentPrefix,\n isEmbeddedApp: appConfig.isEmbeddedApp ?? true,\n apiVersion: appConfig.apiVersion,\n isCustomStoreApp: appConfig.distribution === AppDistribution.ShopifyAdmin,\n billing: appConfig.billing as ApiConfig['billing'],\n future: {\n unstable_managedPricingSupport: true,\n },\n _logDisabledFutureFlags: false,\n });\n}\n\nfunction deriveConfig<Storage extends SessionStorage>(\n appConfig: AppConfigArg,\n apiConfig: ApiConfig,\n): AppConfig<Storage> {\n if (\n !appConfig.sessionStorage &&\n appConfig.distribution !== AppDistribution.ShopifyAdmin\n ) {\n throw new ShopifyError(\n 'Please provide a valid session storage. Refer to https://github.com/Shopify/shopify-app-js/blob/main/README.md#session-storage-options for options.',\n );\n }\n\n const authPathPrefix = appConfig.authPathPrefix || '/auth';\n appConfig.distribution = appConfig.distribution ?? AppDistribution.AppStore;\n\n return {\n ...appConfig,\n ...apiConfig,\n billing: appConfig.billing as ApiConfig['billing'],\n scopes: apiConfig.scopes,\n idempotentPromiseHandler: new IdempotentPromiseHandler(),\n canUseLoginForm: appConfig.distribution !== AppDistribution.ShopifyAdmin,\n useOnlineTokens: appConfig.useOnlineTokens ?? false,\n hooks: appConfig.hooks ?? {},\n sessionStorage: appConfig.sessionStorage as Storage,\n future: appConfig.future ?? {},\n auth: {\n path: authPathPrefix,\n callbackPath: `${authPathPrefix}/callback`,\n patchSessionTokenPath: `${authPathPrefix}/session-token`,\n exitIframePath: `${authPathPrefix}/exit-iframe`,\n loginPath: `${authPathPrefix}/login`,\n },\n distribution: appConfig.distribution,\n };\n}\n"],"names":["overrideLogger","AppDistribution","MerchantCustomAuth","TokenExchangeStrategy","AuthCodeFlowStrategy","authStrategyFactory","addDocumentResponseHeadersFactory","registerWebhooksFactory","authenticateFlowFactory","authenticatePublicFactory","authenticateFulfillmentServiceFactory","authenticateWebhookFactory","unauthenticatedAdminContextFactory","unauthenticatedStorefrontContextFactory","loginFactory","logDisabledFutureFlags","ShopifyError","SHOPIFY_REMIX_LIBRARY_VERSION","shopifyApi","IdempotentPromiseHandler"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,UAAU,CAIxB,SAA2B,EAAA;AAC3B,IAAA,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC;IAChC,MAAM,MAAM,GAAG,YAAY,CAAU,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC;IAC3D,MAAM,MAAM,GAAGA,6BAAc,CAAC,GAAG,CAAC,MAAM,CAAC;AAEzC,IAAA,IAAI,SAAS,CAAC,QAAQ,EAAE;QACtB,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC;IAC9C;IAEA,MAAM,MAAM,GAAgB,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAC;AAEjD,IAAA,IAAI,QAAQ;IACZ,IAAI,MAAM,CAAC,YAAY,KAAKC,qBAAe,CAAC,YAAY,EAAE;AACxD,QAAA,QAAQ,GAAG,IAAIC,oCAAkB,CAAC,MAAM,CAAC;IAC3C;AAAO,SAAA,IACL,MAAM,CAAC,MAAM,CAAC,gCAAgC;QAC9C,M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AAA,CAAc;YAC/C,SAAS,EAAE,CAAA,EAAG,cAAc,CAAA,MAAA,CAAQ;AACrC,SAAA;QACD,YAAY,EAAE,SAAS,CAAC,YAAY;KACrC;AACH;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-config.js","sources":["../../../../../src/server/test-helpers/test-config.ts"],"sourcesContent":["import {LogSeverity
|
|
1
|
+
{"version":3,"file":"test-config.js","sources":["../../../../../src/server/test-helpers/test-config.ts"],"sourcesContent":["import {LogSeverity} from '@shopify/shopify-api';\nimport {SessionStorage} from '@shopify/shopify-app-session-storage';\nimport {MemorySessionStorage} from '@shopify/shopify-app-session-storage-memory';\nimport {\n API_KEY,\n API_SECRET_KEY,\n APP_URL,\n} from '@shopify/shopify-api/test-helpers';\n\nimport type {AppConfigArg} from '../config-types';\nimport type {FutureFlagOptions} from '../future/flags';\n\nconst TEST_CONFIG = {\n apiKey: API_KEY,\n apiSecretKey: API_SECRET_KEY,\n scopes: ['testScope'] as any,\n appUrl: APP_URL,\n adminApiAccessToken: API_KEY,\n privateAppStorefrontAccessToken: API_KEY,\n logger: {\n level: LogSeverity.Debug,\n },\n sessionStorage: new MemorySessionStorage(),\n isTesting: true,\n} as const;\n\nexport function testConfig<\n Overrides extends TestOverridesArg,\n Future extends FutureFlagOptions,\n>(\n {future, ...overrides}: Overrides & {future?: Future} = {} as Overrides & {\n future?: Future;\n },\n): TestConfig<Overrides> {\n return {\n ...TEST_CONFIG,\n ...overrides,\n logger: {\n ...TEST_CONFIG.logger,\n ...(overrides as NonNullable<Overrides>).logger,\n },\n future,\n } as any;\n}\n\n/*\n * This type combines both passed in types, by ignoring any keys from Type1 that are present (and not undefined)\n * in Type2, and then adding any keys from Type1 that are not present in Type2.\n *\n * This effectively enables us to create a type that is the const TEST_CONFIG below, plus any overrides passed in with\n * the output being a const object.\n */\ntype Modify<Type1, Type2> = {\n [key in keyof Type2 as Type2[key] extends undefined\n ? never\n : key]: Type2[key];\n} & {\n [key in keyof Type1 as key extends keyof Type2 ? never : key]: Type1[key];\n};\n\n/*\n * We omit the future prop and then redefine it with a partial of that object so we can pass the fully typed object in\n * to AppConfigArg.\n */\ntype TestOverrides = Partial<\n Omit<AppConfigArg<SessionStorage, FutureFlagOptions>, 'future'> & {\n future: Partial<FutureFlagOptions>;\n }\n>;\n\nexport type TestOverridesArg = undefined | TestOverrides;\n\nexport type TestConfig<Overrides extends TestOverridesArg> = Modify<\n typeof TEST_CONFIG,\n Overrides\n> & {\n future: FutureFlagOptions;\n logger: AppConfigArg['logger'];\n};\n"],"names":["API_KEY","API_SECRET_KEY","APP_URL","LogSeverity","MemorySessionStorage"],"mappings":";;;;;;AAYA,MAAM,WAAW,GAAG;AAClB,IAAA,MAAM,EAAEA,mBAAO;AACf,IAAA,YAAY,EAAEC,0BAAc;IAC5B,MAAM,EAAE,CAAC,WAAW,CAAQ;AAC5B,IAAA,MAAM,EAAEC,mBAAO;AACf,IAAA,mBAAmB,EAAEF,mBAAO;AAC5B,IAAA,+BAA+B,EAAEA,mBAAO;AACxC,IAAA,MAAM,EAAE;QACN,KAAK,EAAEG,sBAAW,CAAC,KAAK;AACzB,KAAA;IACD,cAAc,EAAE,IAAIC,2BAAoB,EAAE;AAC1C,IAAA,SAAS,EAAE,IAAI;CACP;AAEJ,SAAU,UAAU,CAIxB,EAAC,MAAM,EAAE,GAAG,SAAS,EAAA,GAAmC,EAEvD,EAAA;IAED,OAAO;AACL,QAAA,GAAG,WAAW;AACd,QAAA,GAAG,SAAS;AACZ,QAAA,MAAM,EAAE;YACN,GAAG,WAAW,CAAC,MAAM;YACrB,GAAI,SAAoC,CAAC,MAAM;AAChD,SAAA;QACD,MAAM;KACA;AACV;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../src/server/types.ts"],"sourcesContent":["import {\n RegisterReturn,\n Shopify,\n ShopifyRestResources,\n} from '@shopify/shopify-api';\nimport {SessionStorage} from '@shopify/shopify-app-session-storage';\n\nimport type {AuthenticateAdmin} from './authenticate/admin/types';\nimport type {AuthenticateFlow} from './authenticate/flow/types';\nimport {AuthenticateFulfillmentService} from './authenticate/fulfillment-service/types';\nimport type {AuthenticatePublic} from './authenticate/public/types';\nimport type {\n AuthenticateWebhook,\n RegisterWebhooksOptions,\n} from './authenticate/webhooks/types';\nimport type {AppConfig, AppConfigArg} from './config-types';\nimport type {\n ApiConfigWithFutureFlags,\n ApiFutureFlags,\n FutureFlagOptions,\n} from './future/flags';\nimport type {Unauthenticated} from './unauthenticated/types';\n\nexport interface BasicParams<\n Future extends FutureFlagOptions = FutureFlagOptions,\n> {\n api: Shopify<\n ApiConfigWithFutureFlags<Future>,\n ShopifyRestResources,\n ApiFutureFlags<Future>\n >;\n config: AppConfig;\n logger: Shopify['logger'];\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Use this enum to replace the isCustomStoreApp config option in shopify-api-js\nexport enum AppDistribution {\n AppStore = 'app_store',\n SingleMerchant = 'single_merchant',\n ShopifyAdmin = 'shopify_admin',\n}\n\ntype RegisterWebhooks = (\n options: RegisterWebhooksOptions,\n) => Promise<RegisterReturn | void>;\n\nexport enum LoginErrorType {\n MissingShop = 'MISSING_SHOP',\n InvalidShop = 'INVALID_SHOP',\n}\n\nexport interface LoginError {\n shop?: LoginErrorType;\n}\n\ntype Login = (request: Request) => Promise<LoginError | never>;\n\ntype AddDocumentResponseHeaders = (request: Request, headers: Headers) => void;\n\ntype RestResourcesType<Config extends AppConfigArg> =\n Config['restResources'] extends ShopifyRestResources\n ? Config['restResources']\n : ShopifyRestResources;\n\ntype SessionStorageType<Config extends AppConfigArg> =\n Config['sessionStorage'] extends SessionStorage\n ? Config['sessionStorage']\n : SessionStorage;\n\ninterface Authenticate<Config extends AppConfigArg> {\n /**\n * Authenticate an admin Request and get back an authenticated admin context. Use the authenticated admin context to interact with Shopify.\n *\n * Examples of when to use this are requests from your app's UI, or requests from admin extensions.\n *\n * If there is no session for the Request, this will redirect the merchant to correct auth flows.\n *\n * @example\n * <caption>Authenticating a request for an embedded app.</caption>\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticate } from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const {admin, session, sessionToken, billing} = authenticate.admin(request);\n * const response = await admin.graphql(`{ shop { name } }`)\n *\n * return json(await response.json());\n * }\n * ```\n * ```ts\n * // /app/shopify.server.ts\n * import { LATEST_API_VERSION, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * export const authenticate = shopify.authenticate;\n * ```\n */\n admin: AuthenticateAdmin<Config, RestResourcesType<Config>>;\n\n /**\n * Authenticate a Flow extension Request and get back an authenticated context, containing an admin context to access\n * the API, and the payload of the request.\n *\n * If there is no session for the Request, this will return an HTTP 400 error.\n *\n * Note that this will always be a POST request.\n *\n * @example\n * <caption>Authenticating a Flow extension request.</caption>\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { ActionFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticate } from \"../../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const {admin, session, payload} = authenticate.flow(request);\n *\n * // Perform flow extension logic\n *\n * // Return a 200 response\n * return null;\n * }\n * ```\n * ```ts\n * // /app/shopify.server.ts\n * import { LATEST_API_VERSION, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * export const authenticate = shopify.authenticate;\n * ```\n */\n flow: AuthenticateFlow<Config, RestResourcesType<Config>>;\n\n /**\n * Authenticate a request from a fulfillment service and get back an authenticated context.\n *\n * @example\n * <caption>Shopify session for the fulfillment service request.</caption>\n * <description>Use the session associated with this request to use the Admin GraphQL API </description>\n * ```ts\n * // /app/routes/fulfillment_order_notification.ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { authenticate } from \"../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const { admin, session } = await authenticate.fulfillmentService(request);\n *\n * console.log(session.id)\n *\n * return new Response();\n * }\n * ```\n * */\n fulfillmentService: AuthenticateFulfillmentService<\n Config,\n RestResourcesType<Config>\n >;\n\n /**\n * Authenticate a public request and get back a session token.\n *\n * @example\n * <caption>Authenticating a request from a checkout extension</caption>\n *\n * ```ts\n * // /app/routes/api/checkout.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticate } from \"../../shopify.server\";\n * import { getWidgets } from \"~/db/widgets\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const {sessionToken} = authenticate.public.checkout(request);\n *\n * return json(await getWidgets(sessionToken));\n * }\n * ```\n */\n public: AuthenticatePublic<Config>;\n\n /**\n * Authenticate a Shopify webhook request, get back an authenticated admin context and details on the webhook request\n * \n * @example\n * <caption>Authenticating a webhook request</caption>\n *\n * ```ts\n * // app/routes/webhooks.ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { authenticate } from \"../shopify.server\";\n * import db from \"../db.server\";\n *\n * export const action = async ({ request }: ActionFunctionArgs) => {\n * const { topic, shop, session, payload } = await authenticate.webhook(request);\n * \n * // Webhook requests can trigger after an app is uninstalled\n * // If the app is already uninstalled, the session may be undefined.\n * if (!session) {\n * throw new Response();\n * }\n * \n * // Handle the webhook\n * console.log(`${TOPIC} webhook received with payload:`, JSON.stringify(payload))\n *\n * throw new Response();\n * };\n * ```\n * \n * @example\n * <caption>Registering app-specific webhooks (Recommended)</caption>\n * ```toml\n * # shopify.app.toml\n * [webhooks]\n * api_version = \"2024-07\"\n\n * [[webhooks.subscriptions]]\n * topics = [\"products/create\"]\n * uri = \"/webhooks/products/create\"\n * \n * ```\n * \n * @example\n * <caption>Registering shop-specific webhooks.</caption>\n * <description>In many cases you won't need this. Please see: [https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions](https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions)\n * </description>\n * ```ts\n * // app/shopify.server.ts\n * import { DeliveryMethod, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * webhooks: {\n * PRODUCTS_CREATE: {\n * deliveryMethod: DeliveryMethod.Http,\n * callbackUrl: \"/webhooks/products/create\",\n * },\n * },\n * hooks: {\n * afterAuth: async ({ session }) => {\n * // Register webhooks for the shop\n * // In this example, every shop will have these webhooks\n * // You could wrap this in some custom shop specific conditional logic if needed\n * shopify.registerWebhooks({ session });\n * },\n * },\n * // ...etc\n * });\n * ```\n */\n webhook: AuthenticateWebhook<Config, RestResourcesType<Config>, string>;\n}\n\nexport interface ShopifyAppBase<Config extends AppConfigArg> {\n /**\n * The `SessionStorage` instance you passed in as a config option.\n *\n * @example\n * <caption>Storing sessions with Prisma.</caption>\n * <description>Import the `@shopify/shopify-app-session-storage-prisma` package to store sessions in your Prisma database.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n * import { PrismaSessionStorage } from \"@shopify/shopify-app-session-storage-prisma\";\n * import prisma from \"~/db.server\";\n *\n * const shopify = shopifyApp({\n * sessionStorage: new PrismaSessionStorage(prisma),\n * // ...etc\n * })\n *\n * // shopify.sessionStorage is an instance of PrismaSessionStorage\n * ```\n */\n sessionStorage?: SessionStorageType<Config>;\n\n /**\n * Adds the required Content Security Policy headers for Shopify apps to the given Headers object.\n *\n * {@link https://shopify.dev/docs/apps/store/security/iframe-protection}\n *\n * @example\n * <caption>Return headers on all requests.</caption>\n * <description>Add headers to all HTML requests by calling `shopify.addDocumentResponseHeaders` in `entry.server.tsx`.</description>\n *\n * ```\n * // ~/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * export const addDocumentResponseheaders = shopify.addDocumentResponseheaders;\n * ```\n *\n * ```ts\n * // entry.server.tsx\n * import { addDocumentResponseHeaders } from \"~/shopify.server\";\n *\n * export default function handleRequest(\n * request: Request,\n * responseStatusCode: number,\n * responseHeaders: Headers,\n * remixContext: EntryContext\n * ) {\n * const markup = renderToString(\n * <RemixServer context={remixContext} url={request.url} />\n * );\n *\n * responseHeaders.set(\"Content-Type\", \"text/html\");\n * addDocumentResponseHeaders(request, responseHeaders);\n *\n * return new Response(\"<!DOCTYPE html>\" + markup, {\n * status: responseStatusCode,\n * headers: responseHeaders,\n * });\n * }\n * ```\n */\n addDocumentResponseHeaders: AddDocumentResponseHeaders;\n\n /**\n * Register shop-specific webhook subscriptions using the Admin GraphQL API.\n *\n * In many cases defining app-specific webhooks in the `shopify.app.toml` will be sufficient and easier to manage. Please see:\n *\n * {@link https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions}\n *\n * You should only use this if you need shop-specific webhooks.\n *\n * @example\n * <caption>Registering shop-specific webhooks after install</caption>\n * <description>Trigger the registration to create the shop-specific webhook subscriptions after a merchant installs your app using the `afterAuth` hook. Learn more about [subscribing to webhooks.](https://shopify.dev/docs/api/shopify-app-remix/v3/guide-webhooks)</description>\n * ```ts\n * // app/shopify.server.ts\n * import { DeliveryMethod, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * webhooks: {\n * PRODUCTS_CREATE: {\n * deliveryMethod: DeliveryMethod.Http,\n * callbackUrl: \"/webhooks/products/create\",\n * },\n * },\n * hooks: {\n * afterAuth: async ({ session }) => {\n * // Register webhooks for the shop\n * // In this example, every shop will have these webhooks\n * // You could wrap this in some custom shop specific conditional logic if needed\n * shopify.registerWebhooks({ session });\n * },\n * },\n * // ...etc\n * });\n * ```\n */\n registerWebhooks: RegisterWebhooks;\n\n /**\n * Ways to authenticate requests from different surfaces across Shopify.\n *\n * @example\n * <caption>Authenticate Shopify requests.</caption>\n * <description>Use the functions in `authenticate` to validate requests coming from Shopify.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { LATEST_API_VERSION, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * ```\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import shopify from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const {admin, session, sessionToken, billing} = shopify.authenticate.admin(request);\n * const response = admin.graphql(`{ shop { name } }`)\n *\n * return json(await response.json());\n * }\n * ```\n */\n authenticate: Authenticate<Config>;\n\n /**\n * Ways to get Contexts from requests that do not originate from Shopify.\n *\n * @example\n * <caption>Using unauthenticated contexts.</caption>\n * <description>Create contexts for requests that don't come from Shopify.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { LATEST_API_VERSION, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * ```\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticateExternal } from \"~/helpers/authenticate\"\n * import shopify from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const shop = await authenticateExternal(request)\n * const {admin} = await shopify.unauthenticated.admin(shop);\n * const response = admin.graphql(`{ shop { currencyCode } }`)\n *\n * return json(await response.json());\n * }\n * ```\n */\n unauthenticated: Unauthenticated<Config, RestResourcesType<Config>>;\n}\n\nexport interface ShopifyAppLogin {\n /**\n * Log a merchant in, and redirect them to the app root. Will redirect the merchant to authentication if a shop is\n * present in the URL search parameters or form data.\n *\n * This function won't be present when the `distribution` config option is set to `AppDistribution.ShopifyAdmin`,\n * because Admin apps aren't allowed to show a login page.\n *\n * @example\n * <caption>Creating a login page.</caption>\n * <description>Use `shopify.login` to create a login form, in a route that can handle GET and POST requests.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { LATEST_API_VERSION, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * ```\n * ```ts\n * // /app/routes/auth/login.tsx\n * import shopify from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const errors = shopify.login(request);\n *\n * return json(errors);\n * }\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const errors = shopify.login(request);\n *\n * return json(errors);\n * }\n *\n * export default function Auth() {\n * const actionData = useActionData<typeof action>();\n * const [shop, setShop] = useState(\"\");\n *\n * return (\n * <Page>\n * <Card>\n * <Form method=\"post\">\n * <FormLayout>\n * <Text variant=\"headingMd\" as=\"h2\">\n * Login\n * </Text>\n * <TextField\n * type=\"text\"\n * name=\"shop\"\n * label=\"Shop domain\"\n * helpText=\"e.g: my-shop-domain.myshopify.com\"\n * value={shop}\n * onChange={setShop}\n * autoComplete=\"on\"\n * error={actionData?.errors.shop}\n * />\n * <Button submit primary>\n * Submit\n * </Button>\n * </FormLayout>\n * </Form>\n * </Card>\n * </Page>\n * );\n * }\n * ```\n */\n login: Login;\n}\n\nexport type AdminApp<Config extends AppConfigArg> = ShopifyAppBase<Config>;\nexport type SingleMerchantApp<Config extends AppConfigArg> =\n ShopifyAppBase<Config> & ShopifyAppLogin;\nexport type AppStoreApp<Config extends AppConfigArg> = ShopifyAppBase<Config> &\n ShopifyAppLogin;\n\ntype EnforceSessionStorage<Config extends AppConfigArg, Base> = Base & {\n sessionStorage: SessionStorageType<Config>;\n};\n\n/**\n * An object your app can use to interact with Shopify.\n *\n * By default, the app's distribution is `AppStore`.\n */\nexport type ShopifyApp<Config extends AppConfigArg> =\n Config['distribution'] extends AppDistribution.ShopifyAdmin\n ? AdminApp<Config>\n : Config['distribution'] extends AppDistribution.SingleMerchant\n ? EnforceSessionStorage<Config, SingleMerchantApp<Config>>\n : Config['distribution'] extends AppDistribution.AppStore\n ? EnforceSessionStorage<Config, AppStoreApp<Config>>\n : EnforceSessionStorage<Config, AppStoreApp<Config>>;\n"],"names":["AppDistribution","LoginErrorType"],"mappings":";;AAmCA;AACA;AACYA;AAAZ,CAAA,UAAY,eAAe,EAAA;AACzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB;AACtB,IAAA,eAAA,CAAA,gBAAA,CAAA,GAAA,iBAAkC;AAClC,IAAA,eAAA,CAAA,cAAA,CAAA,GAAA,eAA8B;AAChC,CAAC,EAJWA,uBAAe,KAAfA,uBAAe,GAAA,EAAA,CAAA,CAAA;AAUfC;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,cAA4B;AAC5B,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,cAA4B;AAC9B,CAAC,EAHWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../src/server/types.ts"],"sourcesContent":["import {RegisterReturn, Shopify} from '@shopify/shopify-api';\nimport {SessionStorage} from '@shopify/shopify-app-session-storage';\n\nimport type {AuthenticateAdmin} from './authenticate/admin/types';\nimport type {AuthenticateFlow} from './authenticate/flow/types';\nimport {AuthenticateFulfillmentService} from './authenticate/fulfillment-service/types';\nimport type {AuthenticatePublic} from './authenticate/public/types';\nimport type {\n AuthenticateWebhook,\n RegisterWebhooksOptions,\n} from './authenticate/webhooks/types';\nimport type {AppConfig, AppConfigArg} from './config-types';\nimport type {\n ApiConfigWithFutureFlags,\n ApiFutureFlags,\n FutureFlagOptions,\n} from './future/flags';\nimport type {Unauthenticated} from './unauthenticated/types';\n\nexport interface BasicParams<\n Future extends FutureFlagOptions = FutureFlagOptions,\n> {\n api: Shopify<ApiConfigWithFutureFlags<Future>, ApiFutureFlags<Future>>;\n config: AppConfig;\n logger: Shopify['logger'];\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Use this enum to replace the isCustomStoreApp config option in shopify-api-js\nexport enum AppDistribution {\n AppStore = 'app_store',\n SingleMerchant = 'single_merchant',\n ShopifyAdmin = 'shopify_admin',\n}\n\ntype RegisterWebhooks = (\n options: RegisterWebhooksOptions,\n) => Promise<RegisterReturn | void>;\n\nexport enum LoginErrorType {\n MissingShop = 'MISSING_SHOP',\n InvalidShop = 'INVALID_SHOP',\n}\n\nexport interface LoginError {\n shop?: LoginErrorType;\n}\n\ntype Login = (request: Request) => Promise<LoginError | never>;\n\ntype AddDocumentResponseHeaders = (request: Request, headers: Headers) => void;\n\ntype SessionStorageType<Config extends AppConfigArg> =\n Config['sessionStorage'] extends SessionStorage\n ? Config['sessionStorage']\n : SessionStorage;\n\ninterface Authenticate<Config extends AppConfigArg> {\n /**\n * Authenticate an admin Request and get back an authenticated admin context. Use the authenticated admin context to interact with Shopify.\n *\n * Examples of when to use this are requests from your app's UI, or requests from admin extensions.\n *\n * If there is no session for the Request, this will redirect the merchant to correct auth flows.\n *\n * @example\n * <caption>Authenticating a request for an embedded app.</caption>\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticate } from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const {admin, session, sessionToken, billing} = authenticate.admin(request);\n * const response = await admin.graphql(`{ shop { name } }`)\n *\n * return json(await response.json());\n * }\n * ```\n * ```ts\n * // /app/shopify.server.ts\n * import { ApiVersion, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * export const authenticate = shopify.authenticate;\n * ```\n */\n admin: AuthenticateAdmin<Config>;\n\n /**\n * Authenticate a Flow extension Request and get back an authenticated context, containing an admin context to access\n * the API, and the payload of the request.\n *\n * If there is no session for the Request, this will return an HTTP 400 error.\n *\n * Note that this will always be a POST request.\n *\n * @example\n * <caption>Authenticating a Flow extension request.</caption>\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { ActionFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticate } from \"../../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const {admin, session, payload} = authenticate.flow(request);\n *\n * // Perform flow extension logic\n *\n * // Return a 200 response\n * return null;\n * }\n * ```\n * ```ts\n * // /app/shopify.server.ts\n * import { ApiVersion, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * export const authenticate = shopify.authenticate;\n * ```\n */\n flow: AuthenticateFlow;\n\n /**\n * Authenticate a request from a fulfillment service and get back an authenticated context.\n *\n * @example\n * <caption>Shopify session for the fulfillment service request.</caption>\n * <description>Use the session associated with this request to use the Admin GraphQL API </description>\n * ```ts\n * // /app/routes/fulfillment_order_notification.ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { authenticate } from \"../shopify.server\";\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const { admin, session } = await authenticate.fulfillmentService(request);\n *\n * console.log(session.id)\n *\n * return new Response();\n * }\n * ```\n * */\n fulfillmentService: AuthenticateFulfillmentService;\n\n /**\n * Authenticate a public request and get back a session token.\n *\n * @example\n * <caption>Authenticating a request from a checkout extension</caption>\n *\n * ```ts\n * // /app/routes/api/checkout.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticate } from \"../../shopify.server\";\n * import { getWidgets } from \"~/db/widgets\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const {sessionToken} = authenticate.public.checkout(request);\n *\n * return json(await getWidgets(sessionToken));\n * }\n * ```\n */\n public: AuthenticatePublic;\n\n /**\n * Authenticate a Shopify webhook request, get back an authenticated admin context and details on the webhook request\n * \n * @example\n * <caption>Authenticating a webhook request</caption>\n *\n * ```ts\n * // app/routes/webhooks.ts\n * import { ActionFunctionArgs } from \"@remix-run/node\";\n * import { authenticate } from \"../shopify.server\";\n * import db from \"../db.server\";\n *\n * export const action = async ({ request }: ActionFunctionArgs) => {\n * const { topic, shop, session, payload } = await authenticate.webhook(request);\n * \n * // Webhook requests can trigger after an app is uninstalled\n * // If the app is already uninstalled, the session may be undefined.\n * if (!session) {\n * throw new Response();\n * }\n * \n * // Handle the webhook\n * console.log(`${TOPIC} webhook received with payload:`, JSON.stringify(payload))\n *\n * throw new Response();\n * };\n * ```\n * \n * @example\n * <caption>Registering app-specific webhooks (Recommended)</caption>\n * ```toml\n * # shopify.app.toml\n * [webhooks]\n * api_version = \"2024-07\"\n\n * [[webhooks.subscriptions]]\n * topics = [\"products/create\"]\n * uri = \"/webhooks/products/create\"\n * \n * ```\n * \n * @example\n * <caption>Registering shop-specific webhooks.</caption>\n * <description>In many cases you won't need this. Please see: [https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions](https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions)\n * </description>\n * ```ts\n * // app/shopify.server.ts\n * import { DeliveryMethod, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * webhooks: {\n * PRODUCTS_CREATE: {\n * deliveryMethod: DeliveryMethod.Http,\n * callbackUrl: \"/webhooks/products/create\",\n * },\n * },\n * hooks: {\n * afterAuth: async ({ session }) => {\n * // Register webhooks for the shop\n * // In this example, every shop will have these webhooks\n * // You could wrap this in some custom shop specific conditional logic if needed\n * shopify.registerWebhooks({ session });\n * },\n * },\n * // ...etc\n * });\n * ```\n */\n webhook: AuthenticateWebhook<string>;\n}\n\nexport interface ShopifyAppBase<Config extends AppConfigArg> {\n /**\n * The `SessionStorage` instance you passed in as a config option.\n *\n * @example\n * <caption>Storing sessions with Prisma.</caption>\n * <description>Import the `@shopify/shopify-app-session-storage-prisma` package to store sessions in your Prisma database.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n * import { PrismaSessionStorage } from \"@shopify/shopify-app-session-storage-prisma\";\n * import prisma from \"~/db.server\";\n *\n * const shopify = shopifyApp({\n * sessionStorage: new PrismaSessionStorage(prisma),\n * // ...etc\n * })\n *\n * // shopify.sessionStorage is an instance of PrismaSessionStorage\n * ```\n */\n sessionStorage?: SessionStorageType<Config>;\n\n /**\n * Adds the required Content Security Policy headers for Shopify apps to the given Headers object.\n *\n * {@link https://shopify.dev/docs/apps/store/security/iframe-protection}\n *\n * @example\n * <caption>Return headers on all requests.</caption>\n * <description>Add headers to all HTML requests by calling `shopify.addDocumentResponseHeaders` in `entry.server.tsx`.</description>\n *\n * ```\n * // ~/shopify.server.ts\n * import { shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * export const addDocumentResponseheaders = shopify.addDocumentResponseheaders;\n * ```\n *\n * ```ts\n * // entry.server.tsx\n * import { addDocumentResponseHeaders } from \"~/shopify.server\";\n *\n * export default function handleRequest(\n * request: Request,\n * responseStatusCode: number,\n * responseHeaders: Headers,\n * remixContext: EntryContext\n * ) {\n * const markup = renderToString(\n * <RemixServer context={remixContext} url={request.url} />\n * );\n *\n * responseHeaders.set(\"Content-Type\", \"text/html\");\n * addDocumentResponseHeaders(request, responseHeaders);\n *\n * return new Response(\"<!DOCTYPE html>\" + markup, {\n * status: responseStatusCode,\n * headers: responseHeaders,\n * });\n * }\n * ```\n */\n addDocumentResponseHeaders: AddDocumentResponseHeaders;\n\n /**\n * Register shop-specific webhook subscriptions using the Admin GraphQL API.\n *\n * In many cases defining app-specific webhooks in the `shopify.app.toml` will be sufficient and easier to manage. Please see:\n *\n * {@link https://shopify.dev/docs/apps/build/webhooks/subscribe#app-specific-vs-shop-specific-subscriptions}\n *\n * You should only use this if you need shop-specific webhooks.\n *\n * @example\n * <caption>Registering shop-specific webhooks after install</caption>\n * <description>Trigger the registration to create the shop-specific webhook subscriptions after a merchant installs your app using the `afterAuth` hook. Learn more about [subscribing to webhooks.](https://shopify.dev/docs/api/shopify-app-remix/v3/guide-webhooks)</description>\n * ```ts\n * // app/shopify.server.ts\n * import { DeliveryMethod, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * webhooks: {\n * PRODUCTS_CREATE: {\n * deliveryMethod: DeliveryMethod.Http,\n * callbackUrl: \"/webhooks/products/create\",\n * },\n * },\n * hooks: {\n * afterAuth: async ({ session }) => {\n * // Register webhooks for the shop\n * // In this example, every shop will have these webhooks\n * // You could wrap this in some custom shop specific conditional logic if needed\n * shopify.registerWebhooks({ session });\n * },\n * },\n * // ...etc\n * });\n * ```\n */\n registerWebhooks: RegisterWebhooks;\n\n /**\n * Ways to authenticate requests from different surfaces across Shopify.\n *\n * @example\n * <caption>Authenticate Shopify requests.</caption>\n * <description>Use the functions in `authenticate` to validate requests coming from Shopify.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { ApiVersion, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * ```\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import shopify from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const {admin, session, sessionToken, billing} = shopify.authenticate.admin(request);\n * const response = admin.graphql(`{ shop { name } }`)\n *\n * return json(await response.json());\n * }\n * ```\n */\n authenticate: Authenticate<Config>;\n\n /**\n * Ways to get Contexts from requests that do not originate from Shopify.\n *\n * @example\n * <caption>Using unauthenticated contexts.</caption>\n * <description>Create contexts for requests that don't come from Shopify.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { ApiVersion, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * ```\n * ```ts\n * // /app/routes/**\\/*.jsx\n * import { LoaderFunctionArgs, json } from \"@remix-run/node\";\n * import { authenticateExternal } from \"~/helpers/authenticate\"\n * import shopify from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const shop = await authenticateExternal(request)\n * const {admin} = await shopify.unauthenticated.admin(shop);\n * const response = admin.graphql(`{ shop { currencyCode } }`)\n *\n * return json(await response.json());\n * }\n * ```\n */\n unauthenticated: Unauthenticated;\n}\n\nexport interface ShopifyAppLogin {\n /**\n * Log a merchant in, and redirect them to the app root. Will redirect the merchant to authentication if a shop is\n * present in the URL search parameters or form data.\n *\n * This function won't be present when the `distribution` config option is set to `AppDistribution.ShopifyAdmin`,\n * because Admin apps aren't allowed to show a login page.\n *\n * @example\n * <caption>Creating a login page.</caption>\n * <description>Use `shopify.login` to create a login form, in a route that can handle GET and POST requests.</description>\n * ```ts\n * // /app/shopify.server.ts\n * import { ApiVersion, shopifyApp } from \"@shopify/shopify-app-remix/server\";\n *\n * const shopify = shopifyApp({\n * // ...etc\n * });\n * export default shopify;\n * ```\n * ```ts\n * // /app/routes/auth/login.tsx\n * import shopify from \"../../shopify.server\";\n *\n * export async function loader({ request }: LoaderFunctionArgs) {\n * const errors = shopify.login(request);\n *\n * return json(errors);\n * }\n *\n * export async function action({ request }: ActionFunctionArgs) {\n * const errors = shopify.login(request);\n *\n * return json(errors);\n * }\n *\n * export default function Auth() {\n * const actionData = useActionData<typeof action>();\n * const [shop, setShop] = useState(\"\");\n *\n * return (\n * <Page>\n * <Card>\n * <Form method=\"post\">\n * <FormLayout>\n * <Text variant=\"headingMd\" as=\"h2\">\n * Login\n * </Text>\n * <TextField\n * type=\"text\"\n * name=\"shop\"\n * label=\"Shop domain\"\n * helpText=\"e.g: my-shop-domain.myshopify.com\"\n * value={shop}\n * onChange={setShop}\n * autoComplete=\"on\"\n * error={actionData?.errors.shop}\n * />\n * <Button submit primary>\n * Submit\n * </Button>\n * </FormLayout>\n * </Form>\n * </Card>\n * </Page>\n * );\n * }\n * ```\n */\n login: Login;\n}\n\nexport type AdminApp<Config extends AppConfigArg> = ShopifyAppBase<Config>;\nexport type SingleMerchantApp<Config extends AppConfigArg> =\n ShopifyAppBase<Config> & ShopifyAppLogin;\nexport type AppStoreApp<Config extends AppConfigArg> = ShopifyAppBase<Config> &\n ShopifyAppLogin;\n\ntype EnforceSessionStorage<Config extends AppConfigArg, Base> = Base & {\n sessionStorage: SessionStorageType<Config>;\n};\n\n/**\n * An object your app can use to interact with Shopify.\n *\n * By default, the app's distribution is `AppStore`.\n */\nexport type ShopifyApp<Config extends AppConfigArg> =\n Config['distribution'] extends AppDistribution.ShopifyAdmin\n ? AdminApp<Config>\n : Config['distribution'] extends AppDistribution.SingleMerchant\n ? EnforceSessionStorage<Config, SingleMerchantApp<Config>>\n : Config['distribution'] extends AppDistribution.AppStore\n ? EnforceSessionStorage<Config, AppStoreApp<Config>>\n : EnforceSessionStorage<Config, AppStoreApp<Config>>;\n"],"names":["AppDistribution","LoginErrorType"],"mappings":";;AA2BA;AACA;AACYA;AAAZ,CAAA,UAAY,eAAe,EAAA;AACzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,WAAsB;AACtB,IAAA,eAAA,CAAA,gBAAA,CAAA,GAAA,iBAAkC;AAClC,IAAA,eAAA,CAAA,cAAA,CAAA,GAAA,eAA8B;AAChC,CAAC,EAJWA,uBAAe,KAAfA,uBAAe,GAAA,EAAA,CAAA,CAAA;AAUfC;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,cAA4B;AAC5B,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,cAA4B;AAC9B,CAAC,EAHWA,sBAAc,KAAdA,sBAAc,GAAA,EAAA,CAAA,CAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sources":["../../../../../../src/server/unauthenticated/admin/factory.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"factory.js","sources":["../../../../../../src/server/unauthenticated/admin/factory.ts"],"sourcesContent":["import {createOrLoadOfflineSession} from '../../authenticate/helpers/create-or-load-offline-session';\nimport {SessionNotFoundError} from '../../errors';\nimport {BasicParams} from '../../types';\nimport {adminClientFactory} from '../../clients/admin';\n\nimport {UnauthenticatedAdminContext} from './types';\n\nexport function unauthenticatedAdminContextFactory(params: BasicParams) {\n return async (shop: string): Promise<UnauthenticatedAdminContext> => {\n const session = await createOrLoadOfflineSession(shop, params);\n\n if (!session) {\n throw new SessionNotFoundError(\n `Could not find a session for shop ${shop} when creating unauthenticated admin context`,\n );\n }\n\n return {\n session,\n admin: adminClientFactory({params, session}),\n };\n };\n}\n"],"names":["createOrLoadOfflineSession","SessionNotFoundError","adminClientFactory"],"mappings":";;;;;;AAOM,SAAU,kCAAkC,CAAC,MAAmB,EAAA;AACpE,IAAA,OAAO,OAAO,IAAY,KAA0C;QAClE,MAAM,OAAO,GAAG,MAAMA,qDAA0B,CAAC,IAAI,EAAE,MAAM,CAAC;QAE9D,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,MAAM,IAAIC,2BAAoB,CAC5B,qCAAqC,IAAI,CAAA,4CAAA,CAA8C,CACxF;QACH;QAEA,OAAO;YACL,OAAO;YACP,KAAK,EAAEC,0BAAkB,CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC;SAC7C;AACH,IAAA,CAAC;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../../src/server/version.ts"],"sourcesContent":["export const SHOPIFY_REMIX_LIBRARY_VERSION = '
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../../src/server/version.ts"],"sourcesContent":["export const SHOPIFY_REMIX_LIBRARY_VERSION = '4.0.0';\n"],"names":[],"mappings":";;AAAO,MAAM,6BAA6B,GAAG;;;;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { setCrypto, setAbstractRuntimeString } from '@shopify/shopify-api/runtime';
|
|
1
|
+
import { setAbstractRuntimeString } from '@shopify/shopify-api/runtime';
|
|
3
2
|
import { setAppBridgeUrlOverride } from '../../authenticate/helpers/app-bridge-url.mjs';
|
|
4
3
|
import '@remix-run/server-runtime';
|
|
5
4
|
import 'isbot';
|
|
6
5
|
import '../../types.mjs';
|
|
7
6
|
|
|
8
|
-
setCrypto(crypto);
|
|
9
7
|
setAbstractRuntimeString(() => {
|
|
10
8
|
return `Remix (Node)`;
|
|
11
9
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../../src/server/adapters/node/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../../src/server/adapters/node/index.ts"],"sourcesContent":["import {setAbstractRuntimeString} from '@shopify/shopify-api/runtime';\n\nimport {setAppBridgeUrlOverride} from '../../authenticate/helpers';\n\nsetAbstractRuntimeString(() => {\n return `Remix (Node)`;\n});\n\n/* eslint-disable no-process-env */\nif (process.env.APP_BRIDGE_URL) {\n setAppBridgeUrlOverride(process.env.APP_BRIDGE_URL);\n}\n/* eslint-enable no-process-env */\n"],"names":[],"mappings":";;;;;;AAIA,wBAAwB,CAAC,MAAK;AAC5B,IAAA,OAAO,cAAc;AACvB,CAAC,CAAC;AAEF;AACA,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;AAC9B,IAAA,uBAAuB,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AACrD;AACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.mjs","sources":["../../../../../../src/server/authenticate/admin/authenticate.ts"],"sourcesContent":["import {JwtPayload, Session, ShopifyRestResources} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../types';\nimport type {AppConfigArg} from '../../config-types';\nimport {\n getSessionTokenHeader,\n ensureCORSHeadersFactory,\n getSessionTokenFromUrlParam,\n respondToBotRequest,\n respondToOptionsRequest,\n validateSessionToken,\n getShopFromRequest,\n} from '../helpers';\n\nimport {\n cancelBillingFactory,\n requestBillingFactory,\n requireBillingFactory,\n checkBillingFactory,\n createUsageRecordFactory,\n updateUsageCappedAmountFactory,\n} from './billing';\nimport type {\n AdminContext,\n AuthenticateAdmin,\n EmbeddedAdminContext,\n NonEmbeddedAdminContext,\n} from './types';\nimport {\n createAdminApiContext,\n ensureAppIsEmbeddedIfRequired,\n ensureSessionTokenSearchParamIfRequired,\n redirectFactory,\n renderAppBridge,\n validateShopAndHostParams,\n} from './helpers';\nimport {AuthorizationStrategy} from './strategies/types';\nimport {scopesApiFactory} from './scope/factory';\n\nexport interface SessionTokenContext {\n shop: string;\n sessionId?: string;\n sessionToken?: string;\n payload?: JwtPayload;\n}\n\ninterface AuthStrategyParams extends BasicParams {\n strategy: AuthorizationStrategy;\n}\n\nexport function authStrategyFactory<\n ConfigArg extends AppConfigArg,\n Resources extends ShopifyRestResources = ShopifyRestResources,\n>({\n strategy,\n ...params\n}: AuthStrategyParams): AuthenticateAdmin<ConfigArg, Resources> {\n const {api, logger, config} = params;\n\n async function respondToBouncePageRequest(request: Request) {\n const url = new URL(request.url);\n\n if (url.pathname === config.auth.patchSessionTokenPath) {\n logger.debug('Rendering bounce page', {\n shop: getShopFromRequest(request),\n });\n throw renderAppBridge({config, logger, api}, request);\n }\n }\n\n async function respondToExitIframeRequest(request: Request) {\n const url = new URL(request.url);\n\n if (url.pathname === config.auth.exitIframePath) {\n const destination = url.searchParams.get('exitIframe')!;\n\n logger.debug('Rendering exit iframe page', {\n shop: getShopFromRequest(request),\n destination,\n });\n throw renderAppBridge({config, logger, api}, request, {url: destination});\n }\n }\n\n type AdminContextBase =\n | EmbeddedAdminContext<ConfigArg, Resources>\n | NonEmbeddedAdminContext<ConfigArg, Resources>;\n\n function createContext(\n request: Request,\n session: Session,\n authStrategy: AuthorizationStrategy,\n sessionToken?: JwtPayload,\n ): AdminContext<ConfigArg, Resources> {\n let context: AdminContextBase = {\n admin: createAdminApiContext<ConfigArg, Resources>(\n session,\n params,\n authStrategy.handleClientError(request),\n ),\n billing: {\n require: requireBillingFactory(params, request, session),\n check: checkBillingFactory(params, request, session),\n request: requestBillingFactory(params, request, session),\n cancel: cancelBillingFactory(params, request, session),\n createUsageRecord: createUsageRecordFactory(params, request, session),\n updateUsageCappedAmount: updateUsageCappedAmountFactory(\n params,\n request,\n session,\n ),\n },\n\n session,\n cors: ensureCORSHeadersFactory(params, request),\n };\n\n context = addEmbeddedFeatures(context, request, session, sessionToken);\n context = addScopesFeatures(context);\n\n return context as AdminContext<ConfigArg, Resources>;\n }\n\n function addEmbeddedFeatures(\n context: AdminContextBase,\n request: Request,\n session: Session,\n sessionToken?: JwtPayload,\n ) {\n if (config.isEmbeddedApp) {\n return {\n ...context,\n sessionToken,\n redirect: redirectFactory(params, request, session.shop),\n };\n }\n return context;\n }\n\n function addScopesFeatures(context: AdminContextBase) {\n return {\n ...context,\n scopes: scopesApiFactory(params, context.session, context.admin),\n };\n }\n\n return async function authenticateAdmin(request: Request) {\n try {\n respondToBotRequest(params, request);\n respondToOptionsRequest(params, request);\n await respondToBouncePageRequest(request);\n await respondToExitIframeRequest(request);\n await strategy.respondToOAuthRequests(request);\n\n // If this is a valid request, but it doesn't have a session token header, this is a document request. We need to\n // ensure we're embedded if needed and we have the information needed to load the session.\n if (!getSessionTokenHeader(request)) {\n validateShopAndHostParams(params, request);\n await ensureAppIsEmbeddedIfRequired(params, request);\n await ensureSessionTokenSearchParamIfRequired(params, request);\n }\n\n logger.info('Authenticating admin request', {\n shop: getShopFromRequest(request),\n });\n\n const {payload, shop, sessionId, sessionToken} =\n await getSessionTokenContext(params, request);\n\n logger.debug('Loading session from storage', {shop, sessionId});\n const existingSession = sessionId\n ? await config.sessionStorage!.loadSession(sessionId)\n : undefined;\n\n const session = await strategy.authenticate(request, {\n session: existingSession,\n sessionToken,\n shop,\n });\n\n return createContext(request, session, strategy, payload);\n } catch (errorOrResponse) {\n if (errorOrResponse instanceof Response) {\n logger.debug('Authenticate returned a response', {\n shop: getShopFromRequest(request),\n });\n ensureCORSHeadersFactory(params, request)(errorOrResponse);\n }\n\n throw errorOrResponse;\n }\n };\n}\n\nasync function getSessionTokenContext(\n params: BasicParams,\n request: Request,\n): Promise<SessionTokenContext> {\n const {api, config, logger} = params;\n\n const headerSessionToken = getSessionTokenHeader(request);\n const searchParamSessionToken = getSessionTokenFromUrlParam(request);\n const sessionToken = (headerSessionToken || searchParamSessionToken)!;\n\n logger.debug('Attempting to authenticate session token', {\n shop: getShopFromRequest(request),\n sessionToken: JSON.stringify({\n header: headerSessionToken,\n search: searchParamSessionToken,\n }),\n });\n\n if (config.isEmbeddedApp) {\n const payload = await validateSessionToken(params, request, sessionToken);\n const dest = new URL(payload.dest);\n const shop = dest.hostname;\n\n logger.debug('Session token is valid - authenticated', {shop, payload});\n const sessionId = config.useOnlineTokens\n ? api.session.getJwtSessionId(shop, payload.sub)\n : api.session.getOfflineId(shop);\n\n return {shop, payload, sessionId, sessionToken};\n }\n\n const url = new URL(request.url);\n const shop = url.searchParams.get('shop')!;\n\n const sessionId = await api.session.getCurrentId({\n isOnline: config.useOnlineTokens,\n rawRequest: request,\n });\n\n return {shop, sessionId, payload: undefined, sessionToken};\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkDM,SAAU,mBAAmB,CAGjC,EACA,QAAQ,EACR,GAAG,MAAM,EACU,EAAA;IACnB,MAAM,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAC,GAAG,MAAM;IAEpC,eAAe,0BAA0B,CAAC,OAAgB,EAAA;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;QAEhC,IAAI,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE;AACtD,YAAA,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE;AACpC,gBAAA,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC;AAClC,aAAA,CAAC;AACF,YAAA,MAAM,eAAe,CAAC,EAAC,MAAmB,CAAC,EAAE,OAAO,CAAC;QACvD;IACF;I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":["../../../../../../src/server/authenticate/admin/authenticate.ts"],"sourcesContent":["import {JwtPayload, Session} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../types';\nimport type {AppConfigArg} from '../../config-types';\nimport {\n getSessionTokenHeader,\n ensureCORSHeadersFactory,\n getSessionTokenFromUrlParam,\n respondToBotRequest,\n respondToOptionsRequest,\n validateSessionToken,\n getShopFromRequest,\n} from '../helpers';\n\nimport {\n cancelBillingFactory,\n requestBillingFactory,\n requireBillingFactory,\n checkBillingFactory,\n createUsageRecordFactory,\n updateUsageCappedAmountFactory,\n} from './billing';\nimport type {\n AdminContext,\n AuthenticateAdmin,\n EmbeddedAdminContext,\n NonEmbeddedAdminContext,\n} from './types';\nimport {\n createAdminApiContext,\n ensureAppIsEmbeddedIfRequired,\n ensureSessionTokenSearchParamIfRequired,\n redirectFactory,\n renderAppBridge,\n validateShopAndHostParams,\n} from './helpers';\nimport {AuthorizationStrategy} from './strategies/types';\nimport {scopesApiFactory} from './scope/factory';\n\nexport interface SessionTokenContext {\n shop: string;\n sessionId?: string;\n sessionToken?: string;\n payload?: JwtPayload;\n}\n\ninterface AuthStrategyParams extends BasicParams {\n strategy: AuthorizationStrategy;\n}\n\nexport function authStrategyFactory<ConfigArg extends AppConfigArg>({\n strategy,\n ...params\n}: AuthStrategyParams): AuthenticateAdmin<ConfigArg> {\n const {api, logger, config} = params;\n\n async function respondToBouncePageRequest(request: Request) {\n const url = new URL(request.url);\n\n if (url.pathname === config.auth.patchSessionTokenPath) {\n logger.debug('Rendering bounce page', {\n shop: getShopFromRequest(request),\n });\n throw renderAppBridge({config, logger, api}, request);\n }\n }\n\n async function respondToExitIframeRequest(request: Request) {\n const url = new URL(request.url);\n\n if (url.pathname === config.auth.exitIframePath) {\n const destination = url.searchParams.get('exitIframe')!;\n\n logger.debug('Rendering exit iframe page', {\n shop: getShopFromRequest(request),\n destination,\n });\n throw renderAppBridge({config, logger, api}, request, {url: destination});\n }\n }\n\n type AdminContextBase =\n | EmbeddedAdminContext<ConfigArg>\n | NonEmbeddedAdminContext<ConfigArg>;\n\n function createContext(\n request: Request,\n session: Session,\n authStrategy: AuthorizationStrategy,\n sessionToken?: JwtPayload,\n ): AdminContext<ConfigArg> {\n let context: AdminContextBase = {\n admin: createAdminApiContext(\n session,\n params,\n authStrategy.handleClientError(request),\n ),\n billing: {\n require: requireBillingFactory(params, request, session),\n check: checkBillingFactory(params, request, session),\n request: requestBillingFactory(params, request, session),\n cancel: cancelBillingFactory(params, request, session),\n createUsageRecord: createUsageRecordFactory(params, request, session),\n updateUsageCappedAmount: updateUsageCappedAmountFactory(\n params,\n request,\n session,\n ),\n },\n\n session,\n cors: ensureCORSHeadersFactory(params, request),\n };\n\n context = addEmbeddedFeatures(context, request, session, sessionToken);\n context = addScopesFeatures(context);\n\n return context as AdminContext<ConfigArg>;\n }\n\n function addEmbeddedFeatures(\n context: AdminContextBase,\n request: Request,\n session: Session,\n sessionToken?: JwtPayload,\n ) {\n if (config.isEmbeddedApp) {\n return {\n ...context,\n sessionToken,\n redirect: redirectFactory(params, request, session.shop),\n };\n }\n return context;\n }\n\n function addScopesFeatures(context: AdminContextBase) {\n return {\n ...context,\n scopes: scopesApiFactory(params, context.session, context.admin),\n };\n }\n\n return async function authenticateAdmin(request: Request) {\n try {\n respondToBotRequest(params, request);\n respondToOptionsRequest(params, request);\n await respondToBouncePageRequest(request);\n await respondToExitIframeRequest(request);\n await strategy.respondToOAuthRequests(request);\n\n // If this is a valid request, but it doesn't have a session token header, this is a document request. We need to\n // ensure we're embedded if needed and we have the information needed to load the session.\n if (!getSessionTokenHeader(request)) {\n validateShopAndHostParams(params, request);\n await ensureAppIsEmbeddedIfRequired(params, request);\n await ensureSessionTokenSearchParamIfRequired(params, request);\n }\n\n logger.info('Authenticating admin request', {\n shop: getShopFromRequest(request),\n });\n\n const {payload, shop, sessionId, sessionToken} =\n await getSessionTokenContext(params, request);\n\n logger.debug('Loading session from storage', {shop, sessionId});\n const existingSession = sessionId\n ? await config.sessionStorage!.loadSession(sessionId)\n : undefined;\n\n const session = await strategy.authenticate(request, {\n session: existingSession,\n sessionToken,\n shop,\n });\n\n return createContext(request, session, strategy, payload);\n } catch (errorOrResponse) {\n if (errorOrResponse instanceof Response) {\n logger.debug('Authenticate returned a response', {\n shop: getShopFromRequest(request),\n });\n ensureCORSHeadersFactory(params, request)(errorOrResponse);\n }\n\n throw errorOrResponse;\n }\n };\n}\n\nasync function getSessionTokenContext(\n params: BasicParams,\n request: Request,\n): Promise<SessionTokenContext> {\n const {api, config, logger} = params;\n\n const headerSessionToken = getSessionTokenHeader(request);\n const searchParamSessionToken = getSessionTokenFromUrlParam(request);\n const sessionToken = (headerSessionToken || searchParamSessionToken)!;\n\n logger.debug('Attempting to authenticate session token', {\n shop: getShopFromRequest(request),\n sessionToken: JSON.stringify({\n header: headerSessionToken,\n search: searchParamSessionToken,\n }),\n });\n\n if (config.isEmbeddedApp) {\n const payload = await validateSessionToken(params, request, sessionToken);\n const dest = new URL(payload.dest);\n const shop = dest.hostname;\n\n logger.debug('Session token is valid - authenticated', {shop, payload});\n const sessionId = config.useOnlineTokens\n ? api.session.getJwtSessionId(shop, payload.sub)\n : api.session.getOfflineId(shop);\n\n return {shop, payload, sessionId, sessionToken};\n }\n\n const url = new URL(request.url);\n const shop = url.searchParams.get('shop')!;\n\n const sessionId = await api.session.getCurrentId({\n isOnline: config.useOnlineTokens,\n rawRequest: request,\n });\n\n return {shop, sessionId, payload: undefined, sessionToken};\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkDM,SAAU,mBAAmB,CAAiC,EAClE,QAAQ,EACR,GAAG,MAAM,EACU,EAAA;IACnB,MAAM,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAC,GAAG,MAAM;IAEpC,eAAe,0BAA0B,CAAC,OAAgB,EAAA;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;QAEhC,IAAI,GAAG,CAAC,Q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AG,CAAC,OAAO,CAAC,YAAY,CAAC;QAC/C,QAAQ,EAAE,MAAM,CAAC,eAAe;AAChC,QAAA,UAAU,EAAE,OAAO;AACpB,KAAA,CAAC;IAEF,OAAO,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAC;AAC5D;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-admin-api-context.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/create-admin-api-context.ts"],"sourcesContent":["import {Session
|
|
1
|
+
{"version":3,"file":"create-admin-api-context.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/create-admin-api-context.ts"],"sourcesContent":["import {Session} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../../types';\nimport {\n AdminApiContext,\n HandleAdminClientError,\n adminClientFactory,\n} from '../../../clients/admin';\n\nexport function createAdminApiContext(\n session: Session,\n params: BasicParams,\n handleClientError: HandleAdminClientError,\n): AdminApiContext {\n return adminClientFactory({\n session,\n params,\n handleClientError,\n });\n}\n"],"names":[],"mappings":";;SASgB,qBAAqB,CACnC,OAAgB,EAChB,MAAmB,EACnB,iBAAyC,EAAA;AAEzC,IAAA,OAAO,kBAAkB,CAAC;QACxB,OAAO;QACP,MAAM;QACN,iBAAiB;AAClB,KAAA,CAAC;AACJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-after-auth-hook.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/trigger-after-auth-hook.ts"],"sourcesContent":["import {Session
|
|
1
|
+
{"version":3,"file":"trigger-after-auth-hook.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/trigger-after-auth-hook.ts"],"sourcesContent":["import {Session} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../../types';\nimport {AuthorizationStrategy} from '../strategies/types';\n\nimport {createAdminApiContext} from './create-admin-api-context';\n\nexport async function triggerAfterAuthHook(\n params: BasicParams,\n session: Session,\n request: Request,\n authStrategy: AuthorizationStrategy,\n) {\n const {config, logger} = params;\n if (config.hooks.afterAuth) {\n logger.info('Running afterAuth hook', {shop: session.shop});\n\n const admin = createAdminApiContext(\n session,\n params,\n authStrategy.handleClientError(request),\n );\n\n await config.hooks.afterAuth({\n session,\n admin,\n });\n }\n}\n"],"names":[],"mappings":";;AAOO,eAAe,oBAAoB,CACxC,MAAmB,EACnB,OAAgB,EAChB,OAAgB,EAChB,YAAmC,EAAA;AAEnC,IAAA,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,MAAM;AAC/B,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE;AAC1B,QAAA,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAC,CAAC;AAE3D,QAAA,MAAM,KAAK,GAAG,qBAAqB,CACjC,OAAO,EACP,MAAM,EACN,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,CACxC;AAED,QAAA,MAAM,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;YAC3B,OAAO;YACP,KAAK;AACN,SAAA,CAAC;IACJ;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-scopes-details.mjs","sources":["../../../../../../../../src/server/authenticate/admin/scope/client/fetch-scopes-details.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"fetch-scopes-details.mjs","sources":["../../../../../../../../src/server/authenticate/admin/scope/client/fetch-scopes-details.ts"],"sourcesContent":["import {AdminApiContext} from '../../../../clients';\n\nexport interface FetchScopesDetailResponse {\n app: {\n requestedAccessScopes: {\n handle: string;\n }[];\n optionalAccessScopes: {\n handle: string;\n }[];\n installation: {\n accessScopes: {\n handle: string;\n }[];\n };\n };\n}\n\nconst FETCH_SCOPES_DETAIL_QUERY = `#graphql\nquery FetchAccessScopes{\n app {\n requestedAccessScopes {\n handle\n }\n optionalAccessScopes {\n handle\n }\n installation {\n accessScopes {\n handle\n }\n }\n }\n}`;\n\nexport async function fetchScopeDetail(\n admin: AdminApiContext,\n): Promise<FetchScopesDetailResponse> {\n const fetchScopeDetailResult = await admin.graphql(FETCH_SCOPES_DETAIL_QUERY);\n\n const resultContent = await fetchScopeDetailResult.json();\n return resultContent.data;\n}\n"],"names":[],"mappings":"AAkBA,MAAM,yBAAyB,GAAG,CAAA;;;;;;;;;;;;;;;EAehC;AAEK,eAAe,gBAAgB,CACpC,KAAsB,EAAA;IAEtB,MAAM,sBAAsB,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,yBAAyB,CAAC;AAE7E,IAAA,MAAM,aAAa,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE;IACzD,OAAO,aAAa,CAAC,IAAI;AAC3B;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revoke-scopes.mjs","sources":["../../../../../../../../src/server/authenticate/admin/scope/client/revoke-scopes.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"revoke-scopes.mjs","sources":["../../../../../../../../src/server/authenticate/admin/scope/client/revoke-scopes.ts"],"sourcesContent":["import {AdminApiContext} from '../../../../clients';\n\nexport interface RevokeScopesResponse {\n revoked: {\n handle: string;\n }[];\n userErrors: {\n field: string;\n message: string;\n }[];\n}\n\nconst REVOKE_SCOPE_MUTATION = `#graphql\nmutation AppRevokeAccessScopes($scopes: [String!]!) {\n appRevokeAccessScopes(scopes: $scopes){\n revoked {\n handle\n }\n userErrors {\n field\n message\n }\n }\n}`;\n\nexport async function revokeScopes(\n admin: AdminApiContext,\n scopes: string[],\n): Promise<RevokeScopesResponse> {\n const revokeScopesResult = await admin.graphql(REVOKE_SCOPE_MUTATION, {\n variables: {\n scopes,\n },\n });\n\n const resultContent = await revokeScopesResult.json();\n return resultContent.data.appRevokeAccessScopes;\n}\n"],"names":[],"mappings":"AAYA,MAAM,qBAAqB,GAAG,CAAA;;;;;;;;;;;EAW5B;AAEK,eAAe,YAAY,CAChC,KAAsB,EACtB,MAAgB,EAAA;IAEhB,MAAM,kBAAkB,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE;AACpE,QAAA,SAAS,EAAE;YACT,MAAM;AACP,SAAA;AACF,KAAA,CAAC;AAEF,IAAA,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC,IAAI,EAAE;AACrD,IAAA,OAAO,aAAa,CAAC,IAAI,CAAC,qBAAqB;AACjD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/factory.ts"],"sourcesContent":["import {Session} from '@shopify/shopify-api';\n\nimport {
|
|
1
|
+
{"version":3,"file":"factory.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/factory.ts"],"sourcesContent":["import {Session} from '@shopify/shopify-api';\n\nimport {BasicParams} from '../../../types';\nimport {AdminApiContext} from '../../../clients';\n\nimport {ScopesApiContext} from './types';\nimport {requestScopesFactory} from './request';\nimport {queryScopesFactory} from './query';\nimport {revokeScopesFactory} from './revoke';\n\nexport function scopesApiFactory(\n params: BasicParams,\n session: Session,\n admin: AdminApiContext,\n): ScopesApiContext {\n return {\n query: queryScopesFactory(params, session, admin),\n request: requestScopesFactory(params, session, admin),\n revoke: revokeScopesFactory(params, session, admin),\n };\n}\n"],"names":[],"mappings":";;;;SAUgB,gBAAgB,CAC9B,MAAmB,EACnB,OAAgB,EAChB,KAAsB,EAAA;IAEtB,OAAO;QACL,KAAK,EAAE,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;QACjD,OAAO,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;QACrD,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;KACpD;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/query.ts"],"sourcesContent":["import {AuthScopes, Session} from '@shopify/shopify-api';\n\nimport {
|
|
1
|
+
{"version":3,"file":"query.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/query.ts"],"sourcesContent":["import {AuthScopes, Session} from '@shopify/shopify-api';\n\nimport {AdminApiContext} from '../../../clients';\nimport type {BasicParams} from '../../../types';\n\nimport {ScopesDetail} from './types';\nimport {\n FetchScopesDetailResponse,\n fetchScopeDetail,\n} from './client/fetch-scopes-details';\n\nexport function queryScopesFactory(\n params: BasicParams,\n session: Session,\n admin: AdminApiContext,\n) {\n return async function queryScopes() {\n const {logger} = params;\n\n logger.debug('Querying scopes details: ', {\n shop: session.shop,\n });\n\n const scopesDetail = await fetchScopeDetail(admin);\n return mapFetchScopeDetail(scopesDetail);\n };\n}\n\nexport function mapFetchScopeDetail(\n scopesDetailResponse: FetchScopesDetailResponse,\n): ScopesDetail {\n const appInformation = scopesDetailResponse.app;\n\n const granted = new AuthScopes(\n appInformation.installation.accessScopes.map((scope) => scope.handle),\n ).toArray(true);\n\n const required = new AuthScopes(\n appInformation.requestedAccessScopes.map((scope) => scope.handle),\n ).toArray(true);\n\n const optional = new AuthScopes(\n appInformation.optionalAccessScopes.map((scope) => scope.handle),\n ).toArray(true);\n\n return {\n granted,\n required,\n optional,\n };\n}\n"],"names":[],"mappings":";;;SAWgB,kBAAkB,CAChC,MAAmB,EACnB,OAAgB,EAChB,KAAsB,EAAA;IAEtB,OAAO,eAAe,WAAW,GAAA;AAC/B,QAAA,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM;AAEvB,QAAA,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE;YACxC,IAAI,EAAE,OAAO,CAAC,IAAI;AACnB,SAAA,CAAC;AAEF,QAAA,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC;AAClD,QAAA,OAAO,mBAAmB,CAAC,YAAY,CAAC;AAC1C,IAAA,CAAC;AACH;AAEM,SAAU,mBAAmB,CACjC,oBAA+C,EAAA;AAE/C,IAAA,MAAM,cAAc,GAAG,oBAAoB,CAAC,GAAG;AAE/C,IAAA,MAAM,OAAO,GAAG,IAAI,UAAU,CAC5B,cAAc,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,CACtE,CAAC,OAAO,CAAC,IAAI,CAAC;IAEf,MAAM,QAAQ,GAAG,IAAI,UAAU,CAC7B,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,CAClE,CAAC,OAAO,CAAC,IAAI,CAAC;IAEf,MAAM,QAAQ,GAAG,IAAI,UAAU,CAC7B,cAAc,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,CACjE,CAAC,OAAO,CAAC,IAAI,CAAC;IAEf,OAAO;QACL,OAAO;QACP,QAAQ;QACR,QAAQ;KACT;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/request.ts"],"sourcesContent":["import {AuthScopes, Session} from '@shopify/shopify-api';\n\nimport
|
|
1
|
+
{"version":3,"file":"request.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/request.ts"],"sourcesContent":["import {AuthScopes, Session} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../../types';\nimport {redirectToInstallPage} from '../helpers/redirect-to-install-page';\nimport {AdminApiContext} from '../../../clients';\n\nimport {fetchScopeDetail} from './client/fetch-scopes-details';\n\nexport function requestScopesFactory(\n params: BasicParams,\n session: Session,\n admin: AdminApiContext,\n) {\n return async function requestScopes(scopes: string[]) {\n const {logger} = params;\n\n logger.debug('Requesting optional scopes: ', {shop: session.shop, scopes});\n\n if (scopes.length === 0) return;\n if (await alreadyGranted(scopes, admin)) return;\n\n throw await redirectToInstallPage(params, session.shop, scopes);\n };\n\n async function alreadyGranted(scopes: string[], admin: AdminApiContext) {\n const scopesDetail = await fetchScopeDetail(admin);\n const grantedScopes = scopesDetail.app.installation.accessScopes.map(\n (scope) => scope.handle,\n );\n return new AuthScopes(grantedScopes).has(scopes);\n }\n}\n"],"names":[],"mappings":";;;;SAQgB,oBAAoB,CAClC,MAAmB,EACnB,OAAgB,EAChB,KAAsB,EAAA;AAEtB,IAAA,OAAO,eAAe,aAAa,CAAC,MAAgB,EAAA;AAClD,QAAA,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM;AAEvB,QAAA,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAC,CAAC;AAE1E,QAAA,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE;AACzB,QAAA,IAAI,MAAM,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC;YAAE;QAEzC,MAAM,MAAM,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;AACjE,IAAA,CAAC;AAED,IAAA,eAAe,cAAc,CAAC,MAAgB,EAAE,KAAsB,EAAA;AACpE,QAAA,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC;QAClD,MAAM,aAAa,GAAG,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,CAClE,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CACxB;QACD,OAAO,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IAClD;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revoke.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/revoke.ts"],"sourcesContent":["import {Session} from '@shopify/shopify-api';\n\nimport {
|
|
1
|
+
{"version":3,"file":"revoke.mjs","sources":["../../../../../../../src/server/authenticate/admin/scope/revoke.ts"],"sourcesContent":["import {Session} from '@shopify/shopify-api';\n\nimport {AdminApiContext} from '../../../clients';\nimport type {BasicParams} from '../../../types';\n\nimport {revokeScopes} from './client/revoke-scopes';\n\nexport function revokeScopesFactory(\n params: BasicParams,\n session: Session,\n admin: AdminApiContext,\n) {\n return async function revoke(scopes: string[]) {\n const {logger} = params;\n\n await validateScopes(scopes);\n\n logger.debug('Revoke scopes: ', {\n shop: session.shop,\n scopes,\n });\n\n const revokeScopesResult = await revokeScopes(admin, scopes);\n if (revokeScopesResult.userErrors?.length > 0) {\n logger.error('Failed to revoke scopes: ', {\n shop: session.shop,\n errors: revokeScopesResult.userErrors,\n });\n\n throw new Response(JSON.stringify(revokeScopesResult.userErrors), {\n status: 422,\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n }\n\n return {\n revoked: revokeScopesResult.revoked.map((scope) => scope.handle),\n };\n };\n}\n\nasync function validateScopes(scopes: string[]) {\n if (!scopes || scopes.length === 0) {\n throw new Response('No scopes provided', {status: 400});\n }\n}\n"],"names":[],"mappings":";;SAOgB,mBAAmB,CACjC,MAAmB,EACnB,OAAgB,EAChB,KAAsB,EAAA;AAEtB,IAAA,OAAO,eAAe,MAAM,CAAC,MAAgB,EAAA;AAC3C,QAAA,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM;AAEvB,QAAA,MAAM,cAAc,CAAC,MAAM,CAAC;AAE5B,QAAA,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE;YAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM;AACP,SAAA,CAAC;QAEF,MAAM,kBAAkB,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC;QAC5D,IAAI,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,EAAE;AAC7C,YAAA,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE;gBACxC,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,kBAAkB,CAAC,UAAU;AACtC,aAAA,CAAC;YAEF,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE;AAChE,gBAAA,MAAM,EAAE,GAAG;AACX,gBAAA,OAAO,EAAE;AACP,oBAAA,cAAc,EAAE,kBAAkB;AACnC,iBAAA;AACF,aAAA,CAAC;QACJ;QAEA,OAAO;AACL,YAAA,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC;SACjE;AACH,IAAA,CAAC;AACH;AAEA,eAAe,cAAc,CAAC,MAAgB,EAAA;IAC5C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,MAAM,IAAI,QAAQ,CAAC,oBAAoB,EAAE,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;IACzD;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-code-flow.mjs","sources":["../../../../../../../src/server/authenticate/admin/strategies/auth-code-flow.ts"],"sourcesContent":["import {\n CookieNotFound,\n GraphqlQueryError,\n HttpResponseError,\n InvalidHmacError,\n InvalidOAuthError,\n Session,\n Shopify,\n ShopifyRestResources,\n} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../../types';\nimport {\n beginAuth,\n handleClientErrorFactory,\n redirectToAuthPage,\n redirectToShopifyOrAppRoot,\n redirectWithExitIframe,\n triggerAfterAuthHook,\n validateShopAndHostParams,\n} from '../helpers';\nimport {AppConfig, AppConfigArg} from '../../../config-types';\nimport {getSessionTokenHeader} from '../../helpers';\nimport {HandleAdminClientError} from '../../../clients';\nimport type {\n ApiConfigWithFutureFlags,\n ApiFutureFlags,\n} from '../../../future/flags';\n\nimport {AuthorizationStrategy, SessionContext, OnErrorOptions} from './types';\n\nexport class AuthCodeFlowStrategy<\n Config extends AppConfigArg,\n Resources extends ShopifyRestResources = ShopifyRestResources,\n> implements AuthorizationStrategy\n{\n protected api: Shopify<\n ApiConfigWithFutureFlags<Config['future']>,\n ShopifyRestResources,\n ApiFutureFlags<Config['future']>\n >;\n\n protected config: AppConfig;\n protected logger: Shopify['logger'];\n\n public constructor({api, config, logger}: BasicParams) {\n this.api = api;\n this.config = config;\n this.logger = logger;\n }\n\n public async respondToOAuthRequests(request: Request): Promise<void | never> {\n const {api, config} = this;\n\n const url = new URL(request.url);\n const isAuthRequest = url.pathname === config.auth.path;\n const isAuthCallbackRequest = url.pathname === config.auth.callbackPath;\n\n if (isAuthRequest || isAuthCallbackRequest) {\n const shop = api.utils.sanitizeShop(url.searchParams.get('shop')!);\n if (!shop) throw new Response('Shop param is invalid', {status: 400});\n\n if (isAuthRequest) {\n throw await this.handleAuthBeginRequest(request, shop);\n } else {\n throw await this.handleAuthCallbackRequest(request, shop);\n }\n }\n\n if (!getSessionTokenHeader(request)) {\n // This is a document request that doesn't contain a session token. We check if the app is installed.\n // If the app isn't installed, we initiate the OAuth auth code flow.\n // Requests with a header can only happen after the app is installed.\n await this.ensureInstalledOnShop(request);\n }\n }\n\n public async authenticate(\n request: Request,\n sessionContext: SessionContext,\n ): Promise<Session | never> {\n const {api, config, logger} = this;\n\n const {shop, session} = sessionContext;\n\n if (!session) {\n logger.debug('No session found, redirecting to OAuth', {shop});\n await redirectToAuthPage({config, logger, api}, request, shop);\n } else if (!session.isActive(config.scopes)) {\n logger.debug(\n 'Found a session, but it has expired, redirecting to OAuth',\n {shop},\n );\n await redirectToAuthPage({config, logger, api}, request, shop);\n }\n\n logger.debug('Found a valid session', {shop});\n\n return session!;\n }\n\n public handleClientError(request: Request): HandleAdminClientError {\n const {api, config, logger} = this;\n return handleClientErrorFactory({\n request,\n onError: async ({session, error}: OnErrorOptions) => {\n if (error.response.code === 401) {\n throw await redirectToAuthPage(\n {api, config, logger},\n request,\n session.shop,\n );\n }\n },\n });\n }\n\n private async ensureInstalledOnShop(request: Request) {\n const {api, config, logger} = this;\n\n validateShopAndHostParams({api, config, logger}, request);\n\n const url = new URL(request.url);\n let shop = url.searchParams.get('shop');\n\n // Ensure app is installed\n logger.debug('Ensuring app is installed on shop', {shop});\n\n if (!(await this.hasValidOfflineId(request))) {\n logger.info(\"Could not find a shop, can't authenticate request\");\n throw new Response(undefined, {\n status: 400,\n statusText: 'Bad Request',\n });\n }\n\n const offlineSession = await this.getOfflineSession(request);\n const isEmbedded = url.searchParams.get('embedded') === '1';\n\n if (!offlineSession) {\n logger.info(\"Shop hasn't installed app yet, redirecting to OAuth\", {\n shop,\n });\n if (isEmbedded) {\n redirectWithExitIframe({api, config, logger}, request, shop!);\n } else {\n throw await beginAuth({api, config, logger}, request, false, shop!);\n }\n }\n\n shop = shop || offlineSession.shop;\n\n if (config.isEmbeddedApp && !isEmbedded) {\n try {\n logger.debug('Ensuring offline session is valid before embedding', {\n shop,\n });\n await this.testSession(offlineSession);\n\n logger.debug('Offline session is still valid, embedding app', {shop});\n } catch (error) {\n await this.handleInvalidOfflineSession(error, request, shop);\n }\n }\n }\n\n private async handleAuthBeginRequest(\n request: Request,\n shop: string,\n ): Promise<never> {\n const {api, config, logger} = this;\n\n logger.info('Handling OAuth begin request', {shop});\n\n // If we're loading from an iframe, we need to break out of it\n if (\n config.isEmbeddedApp &&\n request.headers.get('Sec-Fetch-Dest') === 'iframe'\n ) {\n logger.debug('Auth request in iframe detected, exiting iframe', {shop});\n throw redirectWithExitIframe({api, config, logger}, request, shop);\n } else {\n throw await beginAuth({api, config, logger}, request, false, shop);\n }\n }\n\n private async handleAuthCallbackRequest(\n request: Request,\n shop: string,\n ): Promise<never> {\n const {api, config, logger} = this;\n\n logger.info('Handling OAuth callback request', {shop});\n\n try {\n const {session, headers: responseHeaders} = await api.auth.callback({\n rawRequest: request,\n });\n\n await config.sessionStorage!.storeSession(session);\n\n if (config.useOnlineTokens && !session.isOnline) {\n logger.info('Requesting online access token for offline session', {\n shop,\n });\n await beginAuth({api, config, logger}, request, true, shop);\n }\n\n logger.debug('Request is valid, loaded session from OAuth callback', {\n shop: session.shop,\n isOnline: session.isOnline,\n });\n\n await triggerAfterAuthHook<Config, Resources>(\n {api, config, logger},\n session,\n request,\n this,\n );\n\n throw await redirectToShopifyOrAppRoot(\n request,\n {api, config, logger},\n responseHeaders,\n );\n } catch (error) {\n if (error instanceof Response) throw error;\n\n throw await this.oauthCallbackError(error, request, shop);\n }\n }\n\n private async getOfflineSession(\n request: Request,\n ): Promise<Session | undefined> {\n const offlineId = await this.getOfflineSessionId(request);\n return this.config.sessionStorage!.loadSession(offlineId!);\n }\n\n private async hasValidOfflineId(request: Request) {\n return Boolean(await this.getOfflineSessionId(request));\n }\n\n private async getOfflineSessionId(\n request: Request,\n ): Promise<string | undefined> {\n const {api} = this;\n const url = new URL(request.url);\n const shop = url.searchParams.get('shop');\n\n return shop\n ? api.session.getOfflineId(shop)\n : api.session.getCurrentId({isOnline: false, rawRequest: request});\n }\n\n private async testSession(session: Session): Promise<void> {\n const {api} = this;\n\n const client = new api.clients.Graphql({\n session,\n });\n\n await client.request(`#graphql\n query shopifyAppShopName {\n shop {\n name\n }\n }\n `);\n }\n\n private async oauthCallbackError(\n error: Error,\n request: Request,\n shop: string,\n ) {\n const {logger} = this;\n logger.error('Error during OAuth callback', {shop, error: error.message});\n\n if (error instanceof CookieNotFound) {\n return this.handleAuthBeginRequest(request, shop);\n }\n\n if (\n error instanceof InvalidHmacError ||\n error instanceof InvalidOAuthError\n ) {\n return new Response(undefined, {\n status: 400,\n statusText: 'Invalid OAuth Request',\n });\n }\n\n return new Response(undefined, {\n status: 500,\n statusText: 'Internal Server Error',\n });\n }\n\n private async handleInvalidOfflineSession(\n error: Error,\n request: Request,\n shop: string,\n ) {\n const {api, logger, config} = this;\n if (error instanceof HttpResponseError) {\n if (error.response.code === 401) {\n logger.info('Shop session is no longer valid, redirecting to OAuth', {\n shop,\n });\n throw await beginAuth({api, config, logger}, request, false, shop);\n } else {\n const message = JSON.stringify(error.response.body, null, 2);\n logger.error(`Unexpected error during session validation: ${message}`, {\n shop,\n });\n\n throw new Response(undefined, {\n status: error.response.code,\n statusText: error.response.statusText,\n });\n }\n } else if (error instanceof GraphqlQueryError) {\n const context: Record<string, string> = {shop};\n if (error.response) {\n context.response = JSON.stringify(error.body);\n }\n\n logger.error(\n `Unexpected error during session validation: ${error.message}`,\n context,\n );\n\n throw new Response(undefined, {\n status: 500,\n statusText: 'Internal Server Error',\n });\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;MA+Ba,oBAAoB,CAAA;AAKrB,IAAA,GAAG;AAMH,IAAA,MAAM;AACN,IAAA,MAAM;AAEhB,IAAA,WAAA,CAAmB,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAc,EAAA;AACnD,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;AACd,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;IAEO,MAAM,sBAAsB,CAAC,OAAgB,EAAA;AAClD,QAAA,MAAM,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,IAAI;QAE1B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;QAChC,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI;QACvD,MAAM,qBAAqB,GAAG,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC,YAAY;AAEvE,QAAA,IAAI,aAAa,IAAI,qBAAqB,EAAE;AAC1C,YAAA,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;AAClE,YAAA,IAAI,CAAC,IAAI;gBAAE,MAAM,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;YAErE,IAAI,aAAa,EAAE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AAU,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU;AACtC,iBAAA,CAAC;YACJ;QACF;AAAO,aAAA,IAAI,KAAK,YAAY,iBAAiB,EAAE;AAC7C,YAAA,MAAM,OAAO,GAA2B,EAAC,IAAI,EAAC;AAC9C,YAAA,IAAI,KAAK,CAAC,QAAQ,EAAE;gBAClB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;YAC/C;YAEA,MAAM,CAAC,KAAK,CACV,CAAA,4CAAA,EAA+C,KAAK,CAAC,OAAO,CAAA,CAAE,EAC9D,OAAO,CACR;AAED,YAAA,MAAM,IAAI,QAAQ,CAAC,SAAS,EAAE;AAC5B,gBAAA,MAAM,EAAE,GAAG;AACX,gBAAA,UAAU,EAAE,uBAAuB;AACpC,aAAA,CAAC;QACJ;IACF;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"auth-code-flow.mjs","sources":["../../../../../../../src/server/authenticate/admin/strategies/auth-code-flow.ts"],"sourcesContent":["import {\n CookieNotFound,\n GraphqlQueryError,\n HttpResponseError,\n InvalidHmacError,\n InvalidOAuthError,\n Session,\n Shopify,\n} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../../types';\nimport {\n beginAuth,\n handleClientErrorFactory,\n redirectToAuthPage,\n redirectToShopifyOrAppRoot,\n redirectWithExitIframe,\n triggerAfterAuthHook,\n validateShopAndHostParams,\n} from '../helpers';\nimport {AppConfig, AppConfigArg} from '../../../config-types';\nimport {getSessionTokenHeader} from '../../helpers';\nimport {HandleAdminClientError} from '../../../clients';\nimport type {\n ApiConfigWithFutureFlags,\n ApiFutureFlags,\n} from '../../../future/flags';\n\nimport {AuthorizationStrategy, SessionContext, OnErrorOptions} from './types';\n\nexport class AuthCodeFlowStrategy<Config extends AppConfigArg>\n implements AuthorizationStrategy\n{\n protected api: Shopify<\n ApiConfigWithFutureFlags<Config['future']>,\n ApiFutureFlags<Config['future']>\n >;\n\n protected config: AppConfig;\n protected logger: Shopify['logger'];\n\n public constructor({api, config, logger}: BasicParams) {\n this.api = api;\n this.config = config;\n this.logger = logger;\n }\n\n public async respondToOAuthRequests(request: Request): Promise<void | never> {\n const {api, config} = this;\n\n const url = new URL(request.url);\n const isAuthRequest = url.pathname === config.auth.path;\n const isAuthCallbackRequest = url.pathname === config.auth.callbackPath;\n\n if (isAuthRequest || isAuthCallbackRequest) {\n const shop = api.utils.sanitizeShop(url.searchParams.get('shop')!);\n if (!shop) throw new Response('Shop param is invalid', {status: 400});\n\n if (isAuthRequest) {\n throw await this.handleAuthBeginRequest(request, shop);\n } else {\n throw await this.handleAuthCallbackRequest(request, shop);\n }\n }\n\n if (!getSessionTokenHeader(request)) {\n // This is a document request that doesn't contain a session token. We check if the app is installed.\n // If the app isn't installed, we initiate the OAuth auth code flow.\n // Requests with a header can only happen after the app is installed.\n await this.ensureInstalledOnShop(request);\n }\n }\n\n public async authenticate(\n request: Request,\n sessionContext: SessionContext,\n ): Promise<Session | never> {\n const {api, config, logger} = this;\n\n const {shop, session} = sessionContext;\n\n if (!session) {\n logger.debug('No session found, redirecting to OAuth', {shop});\n await redirectToAuthPage({config, logger, api}, request, shop);\n } else if (!session.isActive(config.scopes)) {\n logger.debug(\n 'Found a session, but it has expired, redirecting to OAuth',\n {shop},\n );\n await redirectToAuthPage({config, logger, api}, request, shop);\n }\n\n logger.debug('Found a valid session', {shop});\n\n return session!;\n }\n\n public handleClientError(request: Request): HandleAdminClientError {\n const {api, config, logger} = this;\n return handleClientErrorFactory({\n request,\n onError: async ({session, error}: OnErrorOptions) => {\n if (error.response.code === 401) {\n throw await redirectToAuthPage(\n {api, config, logger},\n request,\n session.shop,\n );\n }\n },\n });\n }\n\n private async ensureInstalledOnShop(request: Request) {\n const {api, config, logger} = this;\n\n validateShopAndHostParams({api, config, logger}, request);\n\n const url = new URL(request.url);\n let shop = url.searchParams.get('shop');\n\n // Ensure app is installed\n logger.debug('Ensuring app is installed on shop', {shop});\n\n if (!(await this.hasValidOfflineId(request))) {\n logger.info(\"Could not find a shop, can't authenticate request\");\n throw new Response(undefined, {\n status: 400,\n statusText: 'Bad Request',\n });\n }\n\n const offlineSession = await this.getOfflineSession(request);\n const isEmbedded = url.searchParams.get('embedded') === '1';\n\n if (!offlineSession) {\n logger.info(\"Shop hasn't installed app yet, redirecting to OAuth\", {\n shop,\n });\n if (isEmbedded) {\n redirectWithExitIframe({api, config, logger}, request, shop!);\n } else {\n throw await beginAuth({api, config, logger}, request, false, shop!);\n }\n }\n\n shop = shop || offlineSession.shop;\n\n if (config.isEmbeddedApp && !isEmbedded) {\n try {\n logger.debug('Ensuring offline session is valid before embedding', {\n shop,\n });\n await this.testSession(offlineSession);\n\n logger.debug('Offline session is still valid, embedding app', {shop});\n } catch (error) {\n await this.handleInvalidOfflineSession(error, request, shop);\n }\n }\n }\n\n private async handleAuthBeginRequest(\n request: Request,\n shop: string,\n ): Promise<never> {\n const {api, config, logger} = this;\n\n logger.info('Handling OAuth begin request', {shop});\n\n // If we're loading from an iframe, we need to break out of it\n if (\n config.isEmbeddedApp &&\n request.headers.get('Sec-Fetch-Dest') === 'iframe'\n ) {\n logger.debug('Auth request in iframe detected, exiting iframe', {shop});\n throw redirectWithExitIframe({api, config, logger}, request, shop);\n } else {\n throw await beginAuth({api, config, logger}, request, false, shop);\n }\n }\n\n private async handleAuthCallbackRequest(\n request: Request,\n shop: string,\n ): Promise<never> {\n const {api, config, logger} = this;\n\n logger.info('Handling OAuth callback request', {shop});\n\n try {\n const {session, headers: responseHeaders} = await api.auth.callback({\n rawRequest: request,\n });\n\n await config.sessionStorage!.storeSession(session);\n\n if (config.useOnlineTokens && !session.isOnline) {\n logger.info('Requesting online access token for offline session', {\n shop,\n });\n await beginAuth({api, config, logger}, request, true, shop);\n }\n\n logger.debug('Request is valid, loaded session from OAuth callback', {\n shop: session.shop,\n isOnline: session.isOnline,\n });\n\n await triggerAfterAuthHook({api, config, logger}, session, request, this);\n\n throw await redirectToShopifyOrAppRoot(\n request,\n {api, config, logger},\n responseHeaders,\n );\n } catch (error) {\n if (error instanceof Response) throw error;\n\n throw await this.oauthCallbackError(error, request, shop);\n }\n }\n\n private async getOfflineSession(\n request: Request,\n ): Promise<Session | undefined> {\n const offlineId = await this.getOfflineSessionId(request);\n return this.config.sessionStorage!.loadSession(offlineId!);\n }\n\n private async hasValidOfflineId(request: Request) {\n return Boolean(await this.getOfflineSessionId(request));\n }\n\n private async getOfflineSessionId(\n request: Request,\n ): Promise<string | undefined> {\n const {api} = this;\n const url = new URL(request.url);\n const shop = url.searchParams.get('shop');\n\n return shop\n ? api.session.getOfflineId(shop)\n : api.session.getCurrentId({isOnline: false, rawRequest: request});\n }\n\n private async testSession(session: Session): Promise<void> {\n const {api} = this;\n\n const client = new api.clients.Graphql({\n session,\n });\n\n await client.request(`#graphql\n query shopifyAppShopName {\n shop {\n name\n }\n }\n `);\n }\n\n private async oauthCallbackError(\n error: Error,\n request: Request,\n shop: string,\n ) {\n const {logger} = this;\n logger.error('Error during OAuth callback', {shop, error: error.message});\n\n if (error instanceof CookieNotFound) {\n return this.handleAuthBeginRequest(request, shop);\n }\n\n if (\n error instanceof InvalidHmacError ||\n error instanceof InvalidOAuthError\n ) {\n return new Response(undefined, {\n status: 400,\n statusText: 'Invalid OAuth Request',\n });\n }\n\n return new Response(undefined, {\n status: 500,\n statusText: 'Internal Server Error',\n });\n }\n\n private async handleInvalidOfflineSession(\n error: Error,\n request: Request,\n shop: string,\n ) {\n const {api, logger, config} = this;\n if (error instanceof HttpResponseError) {\n if (error.response.code === 401) {\n logger.info('Shop session is no longer valid, redirecting to OAuth', {\n shop,\n });\n throw await beginAuth({api, config, logger}, request, false, shop);\n } else {\n const message = JSON.stringify(error.response.body, null, 2);\n logger.error(`Unexpected error during session validation: ${message}`, {\n shop,\n });\n\n throw new Response(undefined, {\n status: error.response.code,\n statusText: error.response.statusText,\n });\n }\n } else if (error instanceof GraphqlQueryError) {\n const context: Record<string, string> = {shop};\n if (error.response) {\n context.response = JSON.stringify(error.body);\n }\n\n logger.error(\n `Unexpected error during session validation: ${error.message}`,\n context,\n );\n\n throw new Response(undefined, {\n status: 500,\n statusText: 'Internal Server Error',\n });\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;MA8Ba,oBAAoB,CAAA;AAGrB,IAAA,GAAG;AAKH,IAAA,MAAM;AACN,IAAA,MAAM;AAEhB,IAAA,WAAA,CAAmB,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAc,EAAA;AACnD,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG;AACd,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;IAEO,MAAM,sBAAsB,CAAC,OAAgB,EAAA;AAClD,QAAA,MAAM,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,IAAI;QAE1B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;QAChC,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI;QACvD,MAAM,qBAAqB,GAAG,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC,YAAY;AAEvE,QAAA,IAAI,aAAa,IAAI,qBAAqB,EAAE;AAC1C,YAAA,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;AAClE,YAAA,IAAI,CAAC,IAAI;gBAAE,MAAM,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;YAErE,IAAI,aAAa,EAAE;gBACjB,MAAM,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC;YACxD;iBAAO;gBACL,MAAM,MAAM,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,IAAI,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