@shopify/shopify-app-remix 1.0.0-rc.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/LICENSE.md +9 -0
- package/README.md +373 -0
- package/build/cjs/adapters/node/index.js +13 -0
- package/build/cjs/auth/admin/authenticate.js +599 -0
- package/build/cjs/auth/admin/graphql-client.js +57 -0
- package/build/cjs/auth/admin/rest-client.js +124 -0
- package/build/cjs/auth/const.js +17 -0
- package/build/cjs/auth/helpers/add-response-headers.js +69 -0
- package/build/cjs/auth/helpers/begin-auth.js +18 -0
- package/build/cjs/auth/helpers/get-session-token-header.js +10 -0
- package/build/cjs/auth/helpers/handle-client-error.js +37 -0
- package/build/cjs/auth/helpers/redirect-to-auth-page.js +22 -0
- package/build/cjs/auth/helpers/redirect-with-app-bridge-headers.js +31 -0
- package/build/cjs/auth/helpers/redirect-with-exitiframe.js +23 -0
- package/build/cjs/auth/helpers/reject-bot-request.js +23 -0
- package/build/cjs/auth/helpers/validate-session-token.js +25 -0
- package/build/cjs/auth/login/login.js +54 -0
- package/build/cjs/auth/public/authenticate.js +32 -0
- package/build/cjs/auth/webhooks/authenticate.js +68 -0
- package/build/cjs/auth/webhooks/register.js +40 -0
- package/build/cjs/billing/cancel.js +40 -0
- package/build/cjs/billing/request.js +83 -0
- package/build/cjs/billing/require.js +47 -0
- package/build/cjs/index.js +140 -0
- package/build/cjs/override-logger.js +55 -0
- package/build/cjs/types.js +25 -0
- package/build/cjs/version.js +7 -0
- package/build/ts/adapters/node/index.d.ts +2 -0
- package/build/ts/adapters/node/index.d.ts.map +1 -0
- package/build/ts/adapters/node/index.js +10 -0
- package/build/ts/adapters/node/index.js.map +1 -0
- package/build/ts/auth/admin/authenticate.d.ts +32 -0
- package/build/ts/auth/admin/authenticate.d.ts.map +1 -0
- package/build/ts/auth/admin/authenticate.js +571 -0
- package/build/ts/auth/admin/authenticate.js.map +1 -0
- package/build/ts/auth/admin/graphql-client.d.ts +22 -0
- package/build/ts/auth/admin/graphql-client.d.ts.map +1 -0
- package/build/ts/auth/admin/graphql-client.js +53 -0
- package/build/ts/auth/admin/graphql-client.js.map +1 -0
- package/build/ts/auth/admin/rest-client.d.ts +34 -0
- package/build/ts/auth/admin/rest-client.d.ts.map +1 -0
- package/build/ts/auth/admin/rest-client.js +134 -0
- package/build/ts/auth/admin/rest-client.js.map +1 -0
- package/build/ts/auth/admin/types.d.ts +100 -0
- package/build/ts/auth/admin/types.d.ts.map +1 -0
- package/build/ts/auth/admin/types.js +3 -0
- package/build/ts/auth/admin/types.js.map +1 -0
- package/build/ts/auth/const.d.ts +9 -0
- package/build/ts/auth/const.d.ts.map +1 -0
- package/build/ts/auth/const.js +12 -0
- package/build/ts/auth/const.js.map +1 -0
- package/build/ts/auth/helpers/add-response-headers.d.ts +5 -0
- package/build/ts/auth/helpers/add-response-headers.d.ts.map +1 -0
- package/build/ts/auth/helpers/add-response-headers.js +60 -0
- package/build/ts/auth/helpers/add-response-headers.js.map +1 -0
- package/build/ts/auth/helpers/begin-auth.d.ts +3 -0
- package/build/ts/auth/helpers/begin-auth.d.ts.map +1 -0
- package/build/ts/auth/helpers/begin-auth.js +24 -0
- package/build/ts/auth/helpers/begin-auth.js.map +1 -0
- package/build/ts/auth/helpers/get-session-token-header.d.ts +2 -0
- package/build/ts/auth/helpers/get-session-token-header.d.ts.map +1 -0
- package/build/ts/auth/helpers/get-session-token-header.js +9 -0
- package/build/ts/auth/helpers/get-session-token-header.js.map +1 -0
- package/build/ts/auth/helpers/handle-client-error.d.ts +11 -0
- package/build/ts/auth/helpers/handle-client-error.d.ts.map +1 -0
- package/build/ts/auth/helpers/handle-client-error.js +40 -0
- package/build/ts/auth/helpers/handle-client-error.js.map +1 -0
- package/build/ts/auth/helpers/index.d.ts +8 -0
- package/build/ts/auth/helpers/index.d.ts.map +1 -0
- package/build/ts/auth/helpers/index.js +18 -0
- package/build/ts/auth/helpers/index.js.map +1 -0
- package/build/ts/auth/helpers/redirect-to-auth-page.d.ts +3 -0
- package/build/ts/auth/helpers/redirect-to-auth-page.d.ts.map +1 -0
- package/build/ts/auth/helpers/redirect-to-auth-page.js +33 -0
- package/build/ts/auth/helpers/redirect-to-auth-page.js.map +1 -0
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.d.ts +4 -0
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.d.ts.map +1 -0
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.js +24 -0
- package/build/ts/auth/helpers/redirect-with-app-bridge-headers.js.map +1 -0
- package/build/ts/auth/helpers/redirect-with-exitiframe.d.ts +3 -0
- package/build/ts/auth/helpers/redirect-with-exitiframe.d.ts.map +1 -0
- package/build/ts/auth/helpers/redirect-with-exitiframe.js +18 -0
- package/build/ts/auth/helpers/redirect-with-exitiframe.js.map +1 -0
- package/build/ts/auth/helpers/reject-bot-request.d.ts +3 -0
- package/build/ts/auth/helpers/reject-bot-request.d.ts.map +1 -0
- package/build/ts/auth/helpers/reject-bot-request.js +14 -0
- package/build/ts/auth/helpers/reject-bot-request.js.map +1 -0
- package/build/ts/auth/helpers/validate-session-token.d.ts +4 -0
- package/build/ts/auth/helpers/validate-session-token.d.ts.map +1 -0
- package/build/ts/auth/helpers/validate-session-token.js +36 -0
- package/build/ts/auth/helpers/validate-session-token.js.map +1 -0
- package/build/ts/auth/login/login.d.ts +3 -0
- package/build/ts/auth/login/login.d.ts.map +1 -0
- package/build/ts/auth/login/login.js +56 -0
- package/build/ts/auth/login/login.js.map +1 -0
- package/build/ts/auth/public/authenticate.d.ts +4 -0
- package/build/ts/auth/public/authenticate.d.ts.map +1 -0
- package/build/ts/auth/public/authenticate.js +35 -0
- package/build/ts/auth/public/authenticate.js.map +1 -0
- package/build/ts/auth/public/types.d.ts +27 -0
- package/build/ts/auth/public/types.d.ts.map +1 -0
- package/build/ts/auth/public/types.js +3 -0
- package/build/ts/auth/public/types.js.map +1 -0
- package/build/ts/auth/webhooks/authenticate.d.ts +5 -0
- package/build/ts/auth/webhooks/authenticate.d.ts.map +1 -0
- package/build/ts/auth/webhooks/authenticate.js +71 -0
- package/build/ts/auth/webhooks/authenticate.js.map +1 -0
- package/build/ts/auth/webhooks/index.d.ts +2 -0
- package/build/ts/auth/webhooks/index.d.ts.map +1 -0
- package/build/ts/auth/webhooks/index.js +6 -0
- package/build/ts/auth/webhooks/index.js.map +1 -0
- package/build/ts/auth/webhooks/register.d.ts +4 -0
- package/build/ts/auth/webhooks/register.d.ts.map +1 -0
- package/build/ts/auth/webhooks/register.js +39 -0
- package/build/ts/auth/webhooks/register.js.map +1 -0
- package/build/ts/auth/webhooks/types.d.ts +18 -0
- package/build/ts/auth/webhooks/types.d.ts.map +1 -0
- package/build/ts/auth/webhooks/types.js +3 -0
- package/build/ts/auth/webhooks/types.js.map +1 -0
- package/build/ts/billing/cancel.d.ts +5 -0
- package/build/ts/billing/cancel.d.ts.map +1 -0
- package/build/ts/billing/cancel.js +43 -0
- package/build/ts/billing/cancel.js.map +1 -0
- package/build/ts/billing/index.d.ts +4 -0
- package/build/ts/billing/index.d.ts.map +1 -0
- package/build/ts/billing/index.js +10 -0
- package/build/ts/billing/index.js.map +1 -0
- package/build/ts/billing/request.d.ts +6 -0
- package/build/ts/billing/request.d.ts.map +1 -0
- package/build/ts/billing/request.js +84 -0
- package/build/ts/billing/request.js.map +1 -0
- package/build/ts/billing/require.d.ts +6 -0
- package/build/ts/billing/require.d.ts.map +1 -0
- package/build/ts/billing/require.js +55 -0
- package/build/ts/billing/require.js.map +1 -0
- package/build/ts/billing/types.d.ts +228 -0
- package/build/ts/billing/types.d.ts.map +1 -0
- package/build/ts/billing/types.js +3 -0
- package/build/ts/billing/types.js.map +1 -0
- package/build/ts/config-types.d.ts +325 -0
- package/build/ts/config-types.d.ts.map +1 -0
- package/build/ts/config-types.js +3 -0
- package/build/ts/config-types.js.map +1 -0
- package/build/ts/index.d.ts +29 -0
- package/build/ts/index.d.ts.map +1 -0
- package/build/ts/index.js +108 -0
- package/build/ts/index.js.map +1 -0
- package/build/ts/override-logger.d.ts +3 -0
- package/build/ts/override-logger.d.ts.map +1 -0
- package/build/ts/override-logger.js +40 -0
- package/build/ts/override-logger.js.map +1 -0
- package/build/ts/types.d.ts +353 -0
- package/build/ts/types.d.ts.map +1 -0
- package/build/ts/types.js +17 -0
- package/build/ts/types.js.map +1 -0
- package/build/ts/version.d.ts +2 -0
- package/build/ts/version.d.ts.map +1 -0
- package/build/ts/version.js +5 -0
- package/build/ts/version.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shopifyApi = require('@shopify/shopify-api');
|
|
6
|
+
var serverRuntime = require('@remix-run/server-runtime');
|
|
7
|
+
var redirectToAuthPage = require('../auth/helpers/redirect-to-auth-page.js');
|
|
8
|
+
require('isbot');
|
|
9
|
+
var redirectWithAppBridgeHeaders = require('../auth/helpers/redirect-with-app-bridge-headers.js');
|
|
10
|
+
|
|
11
|
+
function requestBillingFactory(params, request, session) {
|
|
12
|
+
return async function requestBilling({
|
|
13
|
+
plan,
|
|
14
|
+
isTest,
|
|
15
|
+
returnUrl
|
|
16
|
+
}) {
|
|
17
|
+
const {
|
|
18
|
+
api,
|
|
19
|
+
logger
|
|
20
|
+
} = params;
|
|
21
|
+
logger.info('Requesting billing', {
|
|
22
|
+
shop: session.shop,
|
|
23
|
+
plan,
|
|
24
|
+
isTest,
|
|
25
|
+
returnUrl
|
|
26
|
+
});
|
|
27
|
+
let result;
|
|
28
|
+
try {
|
|
29
|
+
result = await api.billing.request({
|
|
30
|
+
plan: plan,
|
|
31
|
+
session,
|
|
32
|
+
isTest,
|
|
33
|
+
returnUrl,
|
|
34
|
+
returnObject: true
|
|
35
|
+
});
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error instanceof shopifyApi.HttpResponseError && error.response.code === 401) {
|
|
38
|
+
logger.debug('API token was invalid, redirecting to OAuth', {
|
|
39
|
+
shop: session.shop
|
|
40
|
+
});
|
|
41
|
+
throw await redirectToAuthPage.redirectToAuthPage(params, request, session.shop);
|
|
42
|
+
} else {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
throw redirectOutOfApp(params, request, result.confirmationUrl, session.shop);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function redirectOutOfApp(params, request, url, shop) {
|
|
50
|
+
const {
|
|
51
|
+
config,
|
|
52
|
+
logger
|
|
53
|
+
} = params;
|
|
54
|
+
logger.debug('Redirecting out of app', {
|
|
55
|
+
url
|
|
56
|
+
});
|
|
57
|
+
const requestUrl = new URL(request.url);
|
|
58
|
+
const isEmbeddedRequest = requestUrl.searchParams.get('embedded') === '1';
|
|
59
|
+
const isXhrRequest = request.headers.get('authorization');
|
|
60
|
+
if (isXhrRequest) {
|
|
61
|
+
// eslint-disable-next-line no-warning-comments
|
|
62
|
+
// TODO Check this with the beta flag disabled (with the bounce page)
|
|
63
|
+
// Remix is not including the X-Shopify-API-Request-Failure-Reauthorize-Url when throwing a Response
|
|
64
|
+
// https://github.com/remix-run/remix/issues/5356
|
|
65
|
+
throw new Response(undefined, {
|
|
66
|
+
status: 401,
|
|
67
|
+
statusText: 'Unauthorized',
|
|
68
|
+
headers: redirectWithAppBridgeHeaders.getAppBridgeHeaders(params, url, shop)
|
|
69
|
+
});
|
|
70
|
+
} else if (isEmbeddedRequest) {
|
|
71
|
+
const params = new URLSearchParams({
|
|
72
|
+
shop,
|
|
73
|
+
host: requestUrl.searchParams.get('host'),
|
|
74
|
+
exitIframe: url
|
|
75
|
+
});
|
|
76
|
+
throw serverRuntime.redirect(`${config.auth.exitIframePath}?${params.toString()}`);
|
|
77
|
+
} else {
|
|
78
|
+
// This will only ever happen for non-embedded apps, because the authenticator will stop before reaching this point
|
|
79
|
+
throw serverRuntime.redirect(url);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.requestBillingFactory = requestBillingFactory;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shopifyApi = require('@shopify/shopify-api');
|
|
6
|
+
var redirectToAuthPage = require('../auth/helpers/redirect-to-auth-page.js');
|
|
7
|
+
require('@remix-run/server-runtime');
|
|
8
|
+
require('isbot');
|
|
9
|
+
|
|
10
|
+
function requireBillingFactory(params, request, session) {
|
|
11
|
+
const {
|
|
12
|
+
api,
|
|
13
|
+
logger
|
|
14
|
+
} = params;
|
|
15
|
+
return async function requireBilling(options) {
|
|
16
|
+
const logContext = {
|
|
17
|
+
shop: session.shop,
|
|
18
|
+
plans: options.plans,
|
|
19
|
+
isTest: options.isTest
|
|
20
|
+
};
|
|
21
|
+
logger.debug('Checking billing for the shop', logContext);
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = await api.billing.check({
|
|
25
|
+
session,
|
|
26
|
+
plans: options.plans,
|
|
27
|
+
isTest: options.isTest,
|
|
28
|
+
returnObject: true
|
|
29
|
+
});
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (error instanceof shopifyApi.HttpResponseError && error.response.code === 401) {
|
|
32
|
+
logger.debug('API token was invalid, redirecting to OAuth', logContext);
|
|
33
|
+
throw await redirectToAuthPage.redirectToAuthPage(params, request, session.shop);
|
|
34
|
+
} else {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!data.hasActivePayment) {
|
|
39
|
+
logger.debug('Billing check failed', logContext);
|
|
40
|
+
throw await options.onFailure(new Error('Billing check failed'));
|
|
41
|
+
}
|
|
42
|
+
logger.debug('Billing check succeeded', logContext);
|
|
43
|
+
return data;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.requireBillingFactory = requireBillingFactory;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('@shopify/shopify-api/adapters/web-api');
|
|
6
|
+
var shopifyApi = require('@shopify/shopify-api');
|
|
7
|
+
var runtime = require('@shopify/shopify-api/runtime');
|
|
8
|
+
var types = require('./types.js');
|
|
9
|
+
var version = require('./version.js');
|
|
10
|
+
var register = require('./auth/webhooks/register.js');
|
|
11
|
+
var authenticate$2 = require('./auth/admin/authenticate.js');
|
|
12
|
+
var authenticate$1 = require('./auth/webhooks/authenticate.js');
|
|
13
|
+
var authenticate = require('./auth/public/authenticate.js');
|
|
14
|
+
var overrideLogger = require('./override-logger.js');
|
|
15
|
+
var addResponseHeaders = require('./auth/helpers/add-response-headers.js');
|
|
16
|
+
var login = require('./auth/login/login.js');
|
|
17
|
+
|
|
18
|
+
runtime.setAbstractRuntimeString(() => {
|
|
19
|
+
return `Remix`;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates an object your app will use to interact with Shopify.
|
|
24
|
+
*
|
|
25
|
+
* @param appConfig Configuration options for your shopify app. For example, the scopes your app needs.
|
|
26
|
+
* @returns `ShopifyApp` An object constructed using your appConfig. It has methods for interacting with Shopify.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* The minimum viable configuration
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { shopifyApp } from "@shopify/shopify-app-remix";
|
|
32
|
+
*
|
|
33
|
+
* export const shopify = shopifyApp({
|
|
34
|
+
* apiKey: process.env.SHOPIFY_API_KEY!,
|
|
35
|
+
* apiSecretKey: process.env.SHOPIFY_API_SECRET!,
|
|
36
|
+
* scopes: process.env.SCOPES?.split(",")!,
|
|
37
|
+
* appUrl: process.env.SHOPIFY_APP_URL!,
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function shopifyApp(appConfig) {
|
|
42
|
+
const api = deriveApi(appConfig);
|
|
43
|
+
const config = deriveConfig(appConfig, api.config);
|
|
44
|
+
const logger = overrideLogger.overrideLogger(api.logger);
|
|
45
|
+
addResponseHeaders.installGlobalResponseHeaders(config.isEmbeddedApp);
|
|
46
|
+
if (appConfig.webhooks) {
|
|
47
|
+
api.webhooks.addHandlers(appConfig.webhooks);
|
|
48
|
+
}
|
|
49
|
+
const params = {
|
|
50
|
+
api,
|
|
51
|
+
config,
|
|
52
|
+
logger
|
|
53
|
+
};
|
|
54
|
+
const oauth = new authenticate$2.AuthStrategy(params);
|
|
55
|
+
return {
|
|
56
|
+
sessionStorage: config.sessionStorage,
|
|
57
|
+
canUseLoginForm: config.canUseLoginForm,
|
|
58
|
+
addResponseHeaders: addResponseHeaders.addResponseHeadersFactory(params),
|
|
59
|
+
registerWebhooks: register.registerWebhooksFactory(params),
|
|
60
|
+
login: login.loginFactory(params),
|
|
61
|
+
authenticate: {
|
|
62
|
+
admin: oauth.authenticateAdmin.bind(oauth),
|
|
63
|
+
public: authenticate.authenticatePublicFactory(params),
|
|
64
|
+
webhook: authenticate$1.authenticateWebhookFactory(params)
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function deriveApi(appConfig) {
|
|
69
|
+
var _appConfig$isEmbedded, _appConfig$apiVersion;
|
|
70
|
+
let appUrl;
|
|
71
|
+
try {
|
|
72
|
+
appUrl = new URL(appConfig.appUrl);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw new shopifyApi.ShopifyError('Invalid appUrl provided. Please provide a valid URL.');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* eslint-disable no-process-env */
|
|
78
|
+
if (appUrl.hostname === 'localhost' && !appUrl.port && process.env.PORT) {
|
|
79
|
+
appUrl.port = process.env.PORT;
|
|
80
|
+
}
|
|
81
|
+
/* eslint-enable no-process-env */
|
|
82
|
+
appConfig.appUrl = appUrl.origin;
|
|
83
|
+
let userAgentPrefix = `Shopify Remix Library v${version.SHOPIFY_REMIX_LIBRARY_VERSION}`;
|
|
84
|
+
if (appConfig.userAgentPrefix) {
|
|
85
|
+
userAgentPrefix = `${appConfig.userAgentPrefix} | ${userAgentPrefix}`;
|
|
86
|
+
}
|
|
87
|
+
const cleanApiConfig = {
|
|
88
|
+
...appConfig,
|
|
89
|
+
hostName: appUrl.host,
|
|
90
|
+
hostScheme: appUrl.protocol.replace(':', ''),
|
|
91
|
+
userAgentPrefix,
|
|
92
|
+
isEmbeddedApp: (_appConfig$isEmbedded = appConfig.isEmbeddedApp) !== null && _appConfig$isEmbedded !== void 0 ? _appConfig$isEmbedded : true,
|
|
93
|
+
apiVersion: (_appConfig$apiVersion = appConfig.apiVersion) !== null && _appConfig$apiVersion !== void 0 ? _appConfig$apiVersion : shopifyApi.LATEST_API_VERSION,
|
|
94
|
+
isCustomStoreApp: appConfig.distribution === types.AppDistribution.ShopifyAdmin
|
|
95
|
+
};
|
|
96
|
+
return shopifyApi.shopifyApi(cleanApiConfig);
|
|
97
|
+
}
|
|
98
|
+
function deriveConfig(appConfig, apiConfig) {
|
|
99
|
+
var _appConfig$distributi, _appConfig$useOnlineT, _appConfig$hooks;
|
|
100
|
+
if (!appConfig.sessionStorage) {
|
|
101
|
+
throw new shopifyApi.ShopifyError('Please provide a valid session storage. See https://github.com/Shopify/shopify-app-js/blob/main/README.md#session-storage-options for options.');
|
|
102
|
+
}
|
|
103
|
+
const authPathPrefix = appConfig.authPathPrefix || '/auth';
|
|
104
|
+
const distribution = (_appConfig$distributi = appConfig.distribution) !== null && _appConfig$distributi !== void 0 ? _appConfig$distributi : types.AppDistribution.AppStore;
|
|
105
|
+
return {
|
|
106
|
+
...appConfig,
|
|
107
|
+
...apiConfig,
|
|
108
|
+
canUseLoginForm: distribution !== types.AppDistribution.ShopifyAdmin,
|
|
109
|
+
useOnlineTokens: (_appConfig$useOnlineT = appConfig.useOnlineTokens) !== null && _appConfig$useOnlineT !== void 0 ? _appConfig$useOnlineT : false,
|
|
110
|
+
hooks: (_appConfig$hooks = appConfig.hooks) !== null && _appConfig$hooks !== void 0 ? _appConfig$hooks : {},
|
|
111
|
+
sessionStorage: appConfig.sessionStorage,
|
|
112
|
+
auth: {
|
|
113
|
+
path: authPathPrefix,
|
|
114
|
+
callbackPath: `${authPathPrefix}/callback`,
|
|
115
|
+
patchSessionTokenPath: `${authPathPrefix}/session-token`,
|
|
116
|
+
exitIframePath: `${authPathPrefix}/exit-iframe`,
|
|
117
|
+
loginPath: `${authPathPrefix}/login`
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
Object.defineProperty(exports, 'BillingInterval', {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function () { return shopifyApi.BillingInterval; }
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, 'DeliveryMethod', {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function () { return shopifyApi.DeliveryMethod; }
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(exports, 'LATEST_API_VERSION', {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () { return shopifyApi.LATEST_API_VERSION; }
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(exports, 'LogSeverity', {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function () { return shopifyApi.LogSeverity; }
|
|
137
|
+
});
|
|
138
|
+
exports.AppDistribution = types.AppDistribution;
|
|
139
|
+
exports.LoginErrorType = types.LoginErrorType;
|
|
140
|
+
exports.shopifyApp = shopifyApp;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var semver = require('semver');
|
|
6
|
+
var shopifyApi = require('@shopify/shopify-api');
|
|
7
|
+
var version = require('./version.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver);
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line no-warning-comments
|
|
14
|
+
// TODO This has been copied from shopify-app-express, it should be extracted into a shared package
|
|
15
|
+
// https://github.com/orgs/Shopify/projects/6899/views/1?pane=issue&itemId=28358070
|
|
16
|
+
function overrideLogger(logger) {
|
|
17
|
+
const baseContext = {
|
|
18
|
+
package: 'shopify-app'
|
|
19
|
+
};
|
|
20
|
+
const warningFunction = (message, context = {}) => logger.warning(message, {
|
|
21
|
+
...baseContext,
|
|
22
|
+
...context
|
|
23
|
+
});
|
|
24
|
+
function deprecated(warningFunction) {
|
|
25
|
+
return function (version$1, message) {
|
|
26
|
+
if (semver__default["default"].gte(version.SHOPIFY_REMIX_LIBRARY_VERSION, version$1)) {
|
|
27
|
+
throw new shopifyApi.FeatureDeprecatedError(`Feature was deprecated in version ${version$1}`);
|
|
28
|
+
}
|
|
29
|
+
return warningFunction(`[Deprecated | ${version$1}] ${message}`);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...logger,
|
|
34
|
+
log: (severity, message, context = {}) => logger.log(severity, message, {
|
|
35
|
+
...baseContext,
|
|
36
|
+
...context
|
|
37
|
+
}),
|
|
38
|
+
debug: (message, context = {}) => logger.debug(message, {
|
|
39
|
+
...baseContext,
|
|
40
|
+
...context
|
|
41
|
+
}),
|
|
42
|
+
info: (message, context = {}) => logger.info(message, {
|
|
43
|
+
...baseContext,
|
|
44
|
+
...context
|
|
45
|
+
}),
|
|
46
|
+
warning: warningFunction,
|
|
47
|
+
error: (message, context = {}) => logger.error(message, {
|
|
48
|
+
...baseContext,
|
|
49
|
+
...context
|
|
50
|
+
}),
|
|
51
|
+
deprecated: deprecated(warningFunction)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.overrideLogger = overrideLogger;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line no-warning-comments
|
|
6
|
+
// TODO: Use this enum to replace the isCustomStoreApp config option in shopify-api-js
|
|
7
|
+
let AppDistribution = /*#__PURE__*/function (AppDistribution) {
|
|
8
|
+
AppDistribution["AppStore"] = "app_store";
|
|
9
|
+
AppDistribution["SingleMerchant"] = "single_merchant";
|
|
10
|
+
AppDistribution["ShopifyAdmin"] = "shopify_admin";
|
|
11
|
+
return AppDistribution;
|
|
12
|
+
}({});
|
|
13
|
+
let LoginErrorType = /*#__PURE__*/function (LoginErrorType) {
|
|
14
|
+
LoginErrorType["MissingShop"] = "MISSING_SHOP";
|
|
15
|
+
LoginErrorType["InvalidShop"] = "INVALID_SHOP";
|
|
16
|
+
return LoginErrorType;
|
|
17
|
+
}({});
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* An object your app can use to interact with Shopify.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
exports.AppDistribution = AppDistribution;
|
|
25
|
+
exports.LoginErrorType = LoginErrorType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapters/node/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
5
|
+
var runtime_1 = require("@shopify/shopify-api/runtime");
|
|
6
|
+
(0, runtime_1.setCrypto)(crypto_1.default);
|
|
7
|
+
(0, runtime_1.setAbstractRuntimeString)(function () {
|
|
8
|
+
return "Remix (Node)";
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapters/node/index.ts"],"names":[],"mappings":";;;AAAA,0DAA4B;AAE5B,wDAGsC;AAEtC,IAAA,mBAAS,EAAC,gBAAa,CAAC,CAAC;AAEzB,IAAA,kCAAwB,EAAC;IACvB,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Shopify, ShopifyRestResources } from '@shopify/shopify-api';
|
|
2
|
+
import type { BasicParams } from '../../types';
|
|
3
|
+
import type { AppConfig, AppConfigArg } from '../../config-types';
|
|
4
|
+
import type { AdminContext } from './types';
|
|
5
|
+
export declare class AuthStrategy<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> {
|
|
6
|
+
protected api: Shopify;
|
|
7
|
+
protected config: AppConfig;
|
|
8
|
+
protected logger: Shopify['logger'];
|
|
9
|
+
constructor({ api, config, logger }: BasicParams);
|
|
10
|
+
authenticateAdmin(request: Request): Promise<AdminContext<Config, Resources>>;
|
|
11
|
+
private authenticateAndGetSessionContext;
|
|
12
|
+
private handleAuthBeginRequest;
|
|
13
|
+
private handleAuthCallbackRequest;
|
|
14
|
+
private validateUrlParams;
|
|
15
|
+
private ensureInstalledOnShop;
|
|
16
|
+
private testSession;
|
|
17
|
+
private ensureValidShopParam;
|
|
18
|
+
private ensureAppIsEmbeddedIfRequired;
|
|
19
|
+
private ensureSessionTokenSearchParamIfRequired;
|
|
20
|
+
private ensureSessionExists;
|
|
21
|
+
private validateAuthenticatedSession;
|
|
22
|
+
private loadSession;
|
|
23
|
+
private redirectToShopifyOrAppRoot;
|
|
24
|
+
private redirectToBouncePage;
|
|
25
|
+
private renderAppBridge;
|
|
26
|
+
private respondToOptionsRequest;
|
|
27
|
+
private ensureResponseHeaders;
|
|
28
|
+
private overriddenRestClient;
|
|
29
|
+
private createBillingContext;
|
|
30
|
+
private createAdminApiContext;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=authenticate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../../../src/auth/admin/authenticate.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,OAAO,EACP,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAEV,SAAS,EACT,YAAY,EACb,MAAM,oBAAoB,CAAC;AAkB5B,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAW1C,qBAAa,YAAY,CACvB,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB;IAE7D,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAEjB,EAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAC,EAAE,WAAW;IAMxC,iBAAiB,CAC5B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAiC7B,gCAAgC;YA6ChC,sBAAsB;YAqBtB,yBAAyB;YAsDzB,iBAAiB;YAuBjB,qBAAqB;YAyErB,WAAW;IAkBzB,OAAO,CAAC,oBAAoB;YAcd,6BAA6B;YAY7B,uCAAuC;YAgBvC,mBAAmB;YAsCnB,4BAA4B;YAoB5B,WAAW;YAwBX,0BAA0B;IAiBxC,OAAO,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAiC5B,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,qBAAqB;CAe9B"}
|