@shopify/shopify-app-remix 4.2.0 → 5.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/dist/cjs/react/components/AppProvider/AppProvider.js.map +1 -1
- package/dist/cjs/react/components/AppProxyForm/AppProxyForm.js +4 -3
- package/dist/cjs/react/components/AppProxyForm/AppProxyForm.js.map +1 -1
- package/dist/cjs/react/components/AppProxyLink/AppProxyLink.js +4 -3
- package/dist/cjs/react/components/AppProxyLink/AppProxyLink.js.map +1 -1
- package/dist/cjs/react/components/AppProxyProvider/AppProxyProvider.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/authenticate.js +1 -3
- package/dist/cjs/server/authenticate/admin/authenticate.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/helpers/redirect.js +2 -2
- package/dist/cjs/server/authenticate/admin/helpers/redirect.js.map +1 -1
- package/dist/cjs/server/authenticate/admin/helpers/validate-redirect-url.js +1 -1
- package/dist/cjs/server/authenticate/admin/helpers/validate-redirect-url.js.map +1 -1
- package/dist/cjs/server/authenticate/public/appProxy/authenticate.js +9 -3
- package/dist/cjs/server/authenticate/public/appProxy/authenticate.js.map +1 -1
- package/dist/cjs/server/authenticate/webhooks/authenticate.js +1 -2
- package/dist/cjs/server/authenticate/webhooks/authenticate.js.map +1 -1
- package/dist/cjs/server/future/flags.js.map +1 -1
- package/dist/cjs/server/shopify-app.js +2 -1
- 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/version.js +1 -1
- package/dist/cjs/server/version.js.map +1 -1
- package/dist/esm/react/components/AppProvider/AppProvider.mjs.map +1 -1
- package/dist/esm/react/components/AppProxyForm/AppProxyForm.mjs +5 -4
- package/dist/esm/react/components/AppProxyForm/AppProxyForm.mjs.map +1 -1
- package/dist/esm/react/components/AppProxyLink/AppProxyLink.mjs +5 -4
- package/dist/esm/react/components/AppProxyLink/AppProxyLink.mjs.map +1 -1
- package/dist/esm/react/components/AppProxyProvider/AppProxyProvider.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/authenticate.mjs +1 -3
- package/dist/esm/server/authenticate/admin/authenticate.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/helpers/redirect.mjs +2 -2
- package/dist/esm/server/authenticate/admin/helpers/redirect.mjs.map +1 -1
- package/dist/esm/server/authenticate/admin/helpers/validate-redirect-url.mjs +1 -1
- package/dist/esm/server/authenticate/admin/helpers/validate-redirect-url.mjs.map +1 -1
- package/dist/esm/server/authenticate/public/appProxy/authenticate.mjs +9 -3
- package/dist/esm/server/authenticate/public/appProxy/authenticate.mjs.map +1 -1
- package/dist/esm/server/authenticate/webhooks/authenticate.mjs +1 -2
- package/dist/esm/server/authenticate/webhooks/authenticate.mjs.map +1 -1
- package/dist/esm/server/future/flags.mjs.map +1 -1
- package/dist/esm/server/shopify-app.mjs +2 -1
- 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/version.mjs +1 -1
- package/dist/esm/server/version.mjs.map +1 -1
- package/dist/ts/react/components/AppProvider/AppProvider.d.ts +5 -1
- package/dist/ts/react/components/AppProvider/AppProvider.d.ts.map +1 -1
- package/dist/ts/react/components/AppProxyForm/AppProxyForm.d.ts +2 -1
- package/dist/ts/react/components/AppProxyForm/AppProxyForm.d.ts.map +1 -1
- package/dist/ts/react/components/AppProxyLink/AppProxyLink.d.ts +2 -1
- package/dist/ts/react/components/AppProxyLink/AppProxyLink.d.ts.map +1 -1
- package/dist/ts/react/components/AppProxyProvider/AppProxyProvider.d.ts +5 -1
- package/dist/ts/react/components/AppProxyProvider/AppProxyProvider.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/authenticate.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/billing/types.d.ts +4 -0
- package/dist/ts/server/authenticate/admin/billing/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/scope/types.d.ts +2 -1
- package/dist/ts/server/authenticate/admin/scope/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/admin/types.d.ts +10 -0
- package/dist/ts/server/authenticate/admin/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/flow/types.d.ts +4 -0
- package/dist/ts/server/authenticate/flow/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/fulfillment-service/types.d.ts +4 -0
- package/dist/ts/server/authenticate/fulfillment-service/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/public/appProxy/types.d.ts +4 -0
- package/dist/ts/server/authenticate/public/appProxy/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/public/checkout/types.d.ts +4 -0
- package/dist/ts/server/authenticate/public/checkout/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/public/customer-account/types.d.ts +4 -0
- package/dist/ts/server/authenticate/public/customer-account/types.d.ts.map +1 -1
- package/dist/ts/server/authenticate/webhooks/authenticate.d.ts.map +1 -1
- package/dist/ts/server/authenticate/webhooks/types.d.ts +6 -24
- package/dist/ts/server/authenticate/webhooks/types.d.ts.map +1 -1
- package/dist/ts/server/boundary/error.d.ts +1 -1
- package/dist/ts/server/boundary/error.d.ts.map +1 -1
- package/dist/ts/server/clients/admin/types.d.ts +4 -0
- package/dist/ts/server/clients/admin/types.d.ts.map +1 -1
- package/dist/ts/server/clients/storefront/types.d.ts +4 -0
- package/dist/ts/server/clients/storefront/types.d.ts.map +1 -1
- package/dist/ts/server/config-types.d.ts +1 -1
- package/dist/ts/server/future/flags.d.ts +6 -0
- package/dist/ts/server/future/flags.d.ts.map +1 -1
- package/dist/ts/server/shopify-app.d.ts +1 -0
- package/dist/ts/server/shopify-app.d.ts.map +1 -1
- package/dist/ts/server/test-helpers/test-config.d.ts.map +1 -1
- package/dist/ts/server/unauthenticated/admin/types.d.ts +4 -0
- package/dist/ts/server/unauthenticated/admin/types.d.ts.map +1 -1
- package/dist/ts/server/unauthenticated/storefront/types.d.ts +4 -0
- package/dist/ts/server/unauthenticated/storefront/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 +16 -17
- package/src/react/components/AppProvider/AppProvider.tsx +4 -0
- package/src/react/components/AppProxyForm/AppProxyForm.tsx +18 -15
- package/src/react/components/AppProxyLink/AppProxyLink.tsx +18 -15
- package/src/react/components/AppProxyProvider/AppProxyProvider.tsx +4 -0
- package/src/server/__test-helpers/const.ts +1 -1
- package/src/server/__test-helpers/expect-admin-api-client.ts +1 -1
- package/src/server/__test-helpers/expect-storefront-api-client.ts +1 -1
- package/src/server/__test-helpers/mock-graphql-request.ts +2 -2
- package/src/server/__test-helpers/request-mock.ts +1 -1
- package/src/server/__test-helpers/setup-non-embedded-flow.ts +1 -1
- package/src/server/__test-helpers/setup-valid-request.ts +1 -2
- package/src/server/__test-helpers/sign-request-cookie.ts +21 -10
- package/src/server/__test-helpers/test-config.ts +1 -1
- package/src/server/authenticate/admin/authenticate.ts +3 -6
- package/src/server/authenticate/admin/billing/types.ts +4 -0
- package/src/server/authenticate/admin/helpers/redirect.ts +2 -2
- package/src/server/authenticate/admin/helpers/validate-redirect-url.ts +1 -1
- package/src/server/authenticate/admin/scope/types.ts +2 -1
- package/src/server/authenticate/admin/types.ts +10 -0
- package/src/server/authenticate/flow/types.ts +4 -0
- package/src/server/authenticate/fulfillment-service/types.ts +4 -0
- package/src/server/authenticate/public/appProxy/authenticate.ts +9 -12
- package/src/server/authenticate/public/appProxy/types.ts +4 -0
- package/src/server/authenticate/public/checkout/types.ts +4 -0
- package/src/server/authenticate/public/customer-account/authenticate.public.customerAccount.doc.example.ts +2 -1
- package/src/server/authenticate/public/customer-account/types.ts +4 -0
- package/src/server/authenticate/webhooks/authenticate.ts +1 -2
- package/src/server/authenticate/webhooks/authenticate.webhooks.doc.example.ts +6 -6
- package/src/server/authenticate/webhooks/types.ts +7 -27
- package/src/server/clients/admin/types.ts +4 -0
- package/src/server/clients/storefront/types.ts +4 -0
- package/src/server/config-types.ts +1 -1
- package/src/server/future/flags.ts +6 -0
- package/src/server/shopify-app.ts +3 -4
- package/src/server/test-helpers/test-config.ts +3 -3
- package/src/server/unauthenticated/admin/types.ts +4 -0
- package/src/server/unauthenticated/storefront/types.ts +4 -0
- package/src/server/version.ts +1 -1
- package/dist/ts/react/components/AppProvider/AppProvider.doc.d.ts +0 -4
- package/dist/ts/react/components/AppProvider/AppProvider.doc.d.ts.map +0 -1
- package/dist/ts/react/components/AppProxyForm/AppProxyForm.doc.d.ts +0 -4
- package/dist/ts/react/components/AppProxyForm/AppProxyForm.doc.d.ts.map +0 -1
- package/dist/ts/react/components/AppProxyLink/AppProxyLink.doc.d.ts +0 -4
- package/dist/ts/react/components/AppProxyLink/AppProxyLink.doc.d.ts.map +0 -1
- package/dist/ts/react/components/AppProxyProvider/AppProxyProvider.doc.d.ts +0 -4
- package/dist/ts/react/components/AppProxyProvider/AppProxyProvider.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/admin/authenticate.admin.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/admin/authenticate.admin.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/admin/billing/authenticate.admin.billing.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/admin/billing/authenticate.admin.billing.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/admin/scope/authenticate.admin.scopes.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/admin/scope/authenticate.admin.scopes.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/flow/authenticate.flow.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/flow/authenticate.flow.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/fulfillment-service/authenticate.fulfillment-service.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/fulfillment-service/authenticate.fulfillment-service.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/public/checkout/authenticate.public.checkout.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/public/checkout/authenticate.public.checkout.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/public/customer-account/authenticate.public.customerAccount.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/public/customer-account/authenticate.public.customerAccount.doc.d.ts.map +0 -1
- package/dist/ts/server/authenticate/webhooks/authenticate.webhooks.doc.d.ts +0 -4
- package/dist/ts/server/authenticate/webhooks/authenticate.webhooks.doc.d.ts.map +0 -1
- package/dist/ts/server/clients/admin/authenticate.admin.api.doc.d.ts +0 -4
- package/dist/ts/server/clients/admin/authenticate.admin.api.doc.d.ts.map +0 -1
- package/dist/ts/server/clients/storefront/authenticate.storefront.api.doc.d.ts +0 -4
- package/dist/ts/server/clients/storefront/authenticate.storefront.api.doc.d.ts.map +0 -1
- package/dist/ts/server/shopify-app.doc.d.ts +0 -4
- package/dist/ts/server/shopify-app.doc.d.ts.map +0 -1
- package/dist/ts/server/unauthenticated/admin/unauthenticated.admin.doc.d.ts +0 -4
- package/dist/ts/server/unauthenticated/admin/unauthenticated.admin.doc.d.ts.map +0 -1
- package/dist/ts/server/unauthenticated/storefront/unauthenticated.storefront.doc.d.ts +0 -4
- package/dist/ts/server/unauthenticated/storefront/unauthenticated.storefront.doc.d.ts.map +0 -1
- package/src/react/components/AppProvider/AppProvider.doc.ts +0 -35
- package/src/react/components/AppProxyForm/AppProxyForm.doc.ts +0 -28
- package/src/react/components/AppProxyLink/AppProxyLink.doc.ts +0 -28
- package/src/react/components/AppProxyProvider/AppProxyProvider.doc.ts +0 -40
- package/src/server/authenticate/admin/authenticate.admin.doc.ts +0 -51
- package/src/server/authenticate/admin/billing/authenticate.admin.billing.doc.ts +0 -29
- package/src/server/authenticate/admin/scope/authenticate.admin.scopes.doc.ts +0 -28
- package/src/server/authenticate/flow/authenticate.flow.doc.ts +0 -47
- package/src/server/authenticate/fulfillment-service/authenticate.fulfillment-service.doc.ts +0 -48
- package/src/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.ts +0 -55
- package/src/server/authenticate/public/checkout/authenticate.public.checkout.doc.ts +0 -49
- package/src/server/authenticate/public/customer-account/authenticate.public.customerAccount.doc.ts +0 -49
- package/src/server/authenticate/webhooks/authenticate.webhooks.doc.ts +0 -39
- package/src/server/clients/admin/authenticate.admin.api.doc.ts +0 -34
- package/src/server/clients/storefront/authenticate.storefront.api.doc.ts +0 -34
- package/src/server/shopify-app.doc.ts +0 -45
- package/src/server/unauthenticated/admin/unauthenticated.admin.doc.ts +0 -40
- package/src/server/unauthenticated/storefront/unauthenticated.storefront.doc.ts +0 -40
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useContext } from 'react';
|
|
2
|
+
import { forwardRef, useContext } from 'react';
|
|
3
3
|
import { Form } from '@remix-run/react';
|
|
4
4
|
import { AppProxyProviderContext } from '../AppProxyProvider/AppProxyProvider.mjs';
|
|
5
5
|
|
|
@@ -58,15 +58,16 @@ import { AppProxyProviderContext } from '../AppProxyProvider/AppProxyProvider.mj
|
|
|
58
58
|
* );
|
|
59
59
|
* }
|
|
60
60
|
* ```
|
|
61
|
+
* @publicDocs
|
|
61
62
|
*/
|
|
62
|
-
function AppProxyForm(props) {
|
|
63
|
+
const AppProxyForm = forwardRef(function AppProxyForm(props, ref) {
|
|
63
64
|
const context = useContext(AppProxyProviderContext);
|
|
64
65
|
if (!context) {
|
|
65
66
|
throw new Error('AppProxyForm must be used within an AppProxyProvider component');
|
|
66
67
|
}
|
|
67
68
|
const { children, action, ...otherProps } = props;
|
|
68
|
-
return (jsx(Form, { action: context.formatUrl(action, false), ...otherProps, children: children }));
|
|
69
|
-
}
|
|
69
|
+
return (jsx(Form, { action: context.formatUrl(action, false), ...otherProps, ref: ref, children: children }));
|
|
70
|
+
});
|
|
70
71
|
|
|
71
72
|
export { AppProxyForm };
|
|
72
73
|
//# sourceMappingURL=AppProxyForm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProxyForm.mjs","sources":["../../../../../../src/react/components/AppProxyForm/AppProxyForm.tsx"],"sourcesContent":["import {useContext} from 'react';\nimport {Form, type FormProps} from '@remix-run/react';\n\nimport {AppProxyProviderContext} from '../AppProxyProvider';\n\nexport interface AppProxyFormProps extends FormProps {\n action: string;\n}\n\n/**\n * Sets up a Remix `<Form>` component that works when rendered on an app proxy page.\n *\n * Supports any properties accepted by the `<Form>` component.\n *\n * Because Remix doesn't support URL rewriting, any route using this component should <b>match the pathname of the proxy\n * URL exactly</b>, and <b>end in a trailing slash</b> (e.g., `https://<shop>/apps/proxy/`), or set the Remix Form prop\n * `navigate` to `false`.\n *\n * @example\n * <caption>Render a form element in a proxied route.</caption>\n * <description>Use an `AppProxyForm` within an `AppProxy` to create a form.</description>\n * ```ts\n * // /app/routes/apps/appProxy.ts\n * import {\n * AppProxyProvider,\n * AppProxyForm,\n * } from \"@shopify/shopify-app-remix/react\";\n * import { authenticate } from \"~/shopify.server\";\n *\n * export async function loader({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * return json({ appUrl: process.env.SHOPIFY_APP_URL });\n * }\n *\n * export async function action({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * const formData = await request.formData();\n * const field = formData.get(\"field\")?.toString();\n *\n * // Perform actions\n * if (field) {\n * console.log(\"Field:\", field);\n * }\n *\n * // Return JSON to the client\n * return json({ message: \"Success!\" });\n * }\n *\n * export default function App() {\n * const { appUrl } = useLoaderData();\n *\n * return (\n * <AppProxyProvider appUrl={appUrl}>\n * <AppProxyForm action=\"/apps/appProxy\" method=\"post\">\n * <input type=\"text\" name=\"field\" />\n *\n * <input type=\"submit\" name=\"Submit\" />\n * </AppProxyForm>\n * </AppProxyProvider>\n * );\n * }\n * ```\n */\nexport function AppProxyForm(props
|
|
1
|
+
{"version":3,"file":"AppProxyForm.mjs","sources":["../../../../../../src/react/components/AppProxyForm/AppProxyForm.tsx"],"sourcesContent":["import {forwardRef, useContext} from 'react';\nimport {Form, type FormProps} from '@remix-run/react';\n\nimport {AppProxyProviderContext} from '../AppProxyProvider';\n\nexport interface AppProxyFormProps extends FormProps {\n action: string;\n}\n\n/**\n * Sets up a Remix `<Form>` component that works when rendered on an app proxy page.\n *\n * Supports any properties accepted by the `<Form>` component.\n *\n * Because Remix doesn't support URL rewriting, any route using this component should <b>match the pathname of the proxy\n * URL exactly</b>, and <b>end in a trailing slash</b> (e.g., `https://<shop>/apps/proxy/`), or set the Remix Form prop\n * `navigate` to `false`.\n *\n * @example\n * <caption>Render a form element in a proxied route.</caption>\n * <description>Use an `AppProxyForm` within an `AppProxy` to create a form.</description>\n * ```ts\n * // /app/routes/apps/appProxy.ts\n * import {\n * AppProxyProvider,\n * AppProxyForm,\n * } from \"@shopify/shopify-app-remix/react\";\n * import { authenticate } from \"~/shopify.server\";\n *\n * export async function loader({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * return json({ appUrl: process.env.SHOPIFY_APP_URL });\n * }\n *\n * export async function action({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * const formData = await request.formData();\n * const field = formData.get(\"field\")?.toString();\n *\n * // Perform actions\n * if (field) {\n * console.log(\"Field:\", field);\n * }\n *\n * // Return JSON to the client\n * return json({ message: \"Success!\" });\n * }\n *\n * export default function App() {\n * const { appUrl } = useLoaderData();\n *\n * return (\n * <AppProxyProvider appUrl={appUrl}>\n * <AppProxyForm action=\"/apps/appProxy\" method=\"post\">\n * <input type=\"text\" name=\"field\" />\n *\n * <input type=\"submit\" name=\"Submit\" />\n * </AppProxyForm>\n * </AppProxyProvider>\n * );\n * }\n * ```\n * @publicDocs\n */\nexport const AppProxyForm = forwardRef<HTMLFormElement, AppProxyFormProps>(\n function AppProxyForm(props, ref) {\n const context = useContext(AppProxyProviderContext);\n\n if (!context) {\n throw new Error(\n 'AppProxyForm must be used within an AppProxyProvider component',\n );\n }\n\n const {children, action, ...otherProps} = props;\n\n return (\n <Form action={context.formatUrl(action, false)} {...otherProps} ref={ref}>\n {children}\n </Form>\n );\n },\n);\n"],"names":["_jsx"],"mappings":";;;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDG;AACI,MAAM,YAAY,GAAG,UAAU,CACpC,SAAS,YAAY,CAAC,KAAK,EAAE,GAAG,EAAA;AAC9B,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,uBAAuB,CAAC;IAEnD,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE;IACH;IAEA,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,EAAC,GAAG,KAAK;IAE/C,QACEA,GAAA,CAAC,IAAI,EAAA,EAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,EAAA,GAAM,UAAU,EAAE,GAAG,EAAE,GAAG,EAAA,QAAA,EACrE,QAAQ,EAAA,CACJ;AAEX,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useContext } from 'react';
|
|
2
|
+
import { forwardRef, useContext } from 'react';
|
|
3
3
|
import { AppProxyProviderContext } from '../AppProxyProvider/AppProxyProvider.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -31,15 +31,16 @@ import { AppProxyProviderContext } from '../AppProxyProvider/AppProxyProvider.mj
|
|
|
31
31
|
* );
|
|
32
32
|
* }
|
|
33
33
|
* ```
|
|
34
|
+
* @publicDocs
|
|
34
35
|
*/
|
|
35
|
-
function AppProxyLink(props) {
|
|
36
|
+
const AppProxyLink = forwardRef(function AppProxyLink(props, ref) {
|
|
36
37
|
const context = useContext(AppProxyProviderContext);
|
|
37
38
|
if (!context) {
|
|
38
39
|
throw new Error('AppProxyLink must be used within an AppProxyProvider component');
|
|
39
40
|
}
|
|
40
41
|
const { children, href, ...otherProps } = props;
|
|
41
|
-
return (jsx("a", { href: context.formatUrl(href), ...otherProps, children: children }));
|
|
42
|
-
}
|
|
42
|
+
return (jsx("a", { href: context.formatUrl(href), ...otherProps, ref: ref, children: children }));
|
|
43
|
+
});
|
|
43
44
|
|
|
44
45
|
export { AppProxyLink };
|
|
45
46
|
//# sourceMappingURL=AppProxyLink.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProxyLink.mjs","sources":["../../../../../../src/react/components/AppProxyLink/AppProxyLink.tsx"],"sourcesContent":["import {useContext} from 'react';\n\nimport {AppProxyProviderContext} from '../AppProxyProvider';\n\nexport interface AppProxyLinkProps extends React.DetailedHTMLProps<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> {\n href: string;\n}\n\n/**\n * Sets up an `<a />` HTML element that works when rendered behind an app proxy.\n *\n * Supports any properties accepted by the `<a />` HTML element.\n *\n * @example\n * <caption>Link to a different route.</caption>\n * <description>Use an `AppProxyLink` within an `AppProxyProvider` to link to a different proxied route.</description>\n * ```ts\n * // /app/routes/**\\/*.ts\n * import {authenticate} from '~/shopify.server';\n * import {AppProxyProvider, AppProxyLink} from '@shopify/shopify-app-remix/react';\n *\n * export async function loader({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * return json({ appUrl: process.env.SHOPIFY_APP_URL });\n * }\n *\n * export default function App() {\n * const { appUrl } = useLoaderData();\n *\n * return (\n * <AppProxyProvider appUrl={appUrl}>\n * <AppProxyLink href=\"/other-proxy-route\">Link to another route</AppProxyLink>\n * </AppProxyProvider>\n * );\n * }\n * ```\n */\nexport function AppProxyLink(props
|
|
1
|
+
{"version":3,"file":"AppProxyLink.mjs","sources":["../../../../../../src/react/components/AppProxyLink/AppProxyLink.tsx"],"sourcesContent":["import {forwardRef, useContext} from 'react';\n\nimport {AppProxyProviderContext} from '../AppProxyProvider';\n\nexport interface AppProxyLinkProps extends React.DetailedHTMLProps<\n React.AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n> {\n href: string;\n}\n\n/**\n * Sets up an `<a />` HTML element that works when rendered behind an app proxy.\n *\n * Supports any properties accepted by the `<a />` HTML element.\n *\n * @example\n * <caption>Link to a different route.</caption>\n * <description>Use an `AppProxyLink` within an `AppProxyProvider` to link to a different proxied route.</description>\n * ```ts\n * // /app/routes/**\\/*.ts\n * import {authenticate} from '~/shopify.server';\n * import {AppProxyProvider, AppProxyLink} from '@shopify/shopify-app-remix/react';\n *\n * export async function loader({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * return json({ appUrl: process.env.SHOPIFY_APP_URL });\n * }\n *\n * export default function App() {\n * const { appUrl } = useLoaderData();\n *\n * return (\n * <AppProxyProvider appUrl={appUrl}>\n * <AppProxyLink href=\"/other-proxy-route\">Link to another route</AppProxyLink>\n * </AppProxyProvider>\n * );\n * }\n * ```\n * @publicDocs\n */\nexport const AppProxyLink = forwardRef<HTMLAnchorElement, AppProxyLinkProps>(\n function AppProxyLink(props, ref) {\n const context = useContext(AppProxyProviderContext);\n\n if (!context) {\n throw new Error(\n 'AppProxyLink must be used within an AppProxyProvider component',\n );\n }\n\n const {children, href, ...otherProps} = props;\n\n return (\n <a href={context.formatUrl(href)} {...otherProps} ref={ref}>\n {children}\n </a>\n );\n },\n);\n"],"names":["_jsx"],"mappings":";;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,MAAM,YAAY,GAAG,UAAU,CACpC,SAAS,YAAY,CAAC,KAAK,EAAE,GAAG,EAAA;AAC9B,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,uBAAuB,CAAC;IAEnD,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE;IACH;IAEA,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,UAAU,EAAC,GAAG,KAAK;IAE7C,QACEA,WAAG,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,KAAM,UAAU,EAAE,GAAG,EAAE,GAAG,YACvD,QAAQ,EAAA,CACP;AAER,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProxyProvider.mjs","sources":["../../../../../../src/react/components/AppProxyProvider/AppProxyProvider.tsx"],"sourcesContent":["import {createContext, useEffect, useState} from 'react';\n\nexport interface AppProxyProviderProps {\n /**\n * The URL where the app is hosted. You can set this from the `SHOPIFY_APP_URL` environment variable.\n */\n appUrl: string;\n\n /**\n * The children to render.\n */\n children?: React.ReactNode;\n}\n\ntype FormatUrlFunction = (\n url: string | undefined,\n addOrigin?: boolean,\n) => string | undefined;\n\ninterface AppProxyProviderContextProps {\n appUrl: string;\n formatUrl: FormatUrlFunction;\n requestUrl?: URL;\n}\n\nexport const AppProxyProviderContext =\n createContext<AppProxyProviderContextProps | null>(null);\n\n/**\n * Sets up a page to render behind a Shopify app proxy, enabling JavaScript and CSS to be loaded from the app.\n *\n * Also provides components that enable using other components such as links and forms within proxies.\n *\n * > Caution:\n * Because Remix doesn't support URL rewriting, any route using this component should <b>match the pathname of the proxy\n * URL exactly</b>, and <b>end in a trailing slash</b> (e.g., `https://<shop>/apps/proxy/`).\n *\n * @example\n * <caption>Wrap a route with an AppProxyProvider component.</caption>\n * <description>Wrap your route component in the `AppProxyProvider` component and pass in your app URL.</description>\n * ```ts\n * // /app/routes/**\\/*.ts\n * import {authenticate} from '~/shopify.server';\n * import {AppProxyProvider} from '@shopify/shopify-app-remix/react';\n *\n * export async function loader({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * return json({ appUrl: process.env.SHOPIFY_APP_URL });\n * }\n *\n * export default function App() {\n * const { appUrl } = useLoaderData();\n *\n * return (\n * <AppProxyProvider appUrl={appUrl}>\n * Page content\n * </AppProxyProvider>\n * );\n * }\n * ```\n */\nexport function AppProxyProvider(props: AppProxyProviderProps) {\n const {children, appUrl} = props;\n const [requestUrl, setRequestUrl] = useState<URL | undefined>();\n\n useEffect(\n () => setRequestUrl(new URL(window.location.href)),\n [setRequestUrl],\n );\n\n return (\n <AppProxyProviderContext.Provider\n value={{appUrl, requestUrl, formatUrl: formatProxyUrl(requestUrl)}}\n >\n <base href={appUrl} />\n\n {children}\n </AppProxyProviderContext.Provider>\n );\n}\n\nfunction formatProxyUrl(requestUrl: URL | undefined): FormatUrlFunction {\n return (url: string | undefined, addOrigin = true) => {\n if (!url) {\n return url;\n }\n\n let finalUrl = url;\n\n if (addOrigin && requestUrl && finalUrl.startsWith('/')) {\n finalUrl = new URL(`${requestUrl.origin}${url}`).href;\n }\n if (!finalUrl.endsWith('/')) {\n finalUrl = `${finalUrl}/`;\n }\n\n return finalUrl;\n };\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AppProxyProvider.mjs","sources":["../../../../../../src/react/components/AppProxyProvider/AppProxyProvider.tsx"],"sourcesContent":["import {createContext, useEffect, useState} from 'react';\n\n/**\n * Props for the `AppProxyProvider` component.\n * @publicDocs\n */\nexport interface AppProxyProviderProps {\n /**\n * The URL where the app is hosted. You can set this from the `SHOPIFY_APP_URL` environment variable.\n */\n appUrl: string;\n\n /**\n * The children to render.\n */\n children?: React.ReactNode;\n}\n\ntype FormatUrlFunction = (\n url: string | undefined,\n addOrigin?: boolean,\n) => string | undefined;\n\ninterface AppProxyProviderContextProps {\n appUrl: string;\n formatUrl: FormatUrlFunction;\n requestUrl?: URL;\n}\n\nexport const AppProxyProviderContext =\n createContext<AppProxyProviderContextProps | null>(null);\n\n/**\n * Sets up a page to render behind a Shopify app proxy, enabling JavaScript and CSS to be loaded from the app.\n *\n * Also provides components that enable using other components such as links and forms within proxies.\n *\n * > Caution:\n * Because Remix doesn't support URL rewriting, any route using this component should <b>match the pathname of the proxy\n * URL exactly</b>, and <b>end in a trailing slash</b> (e.g., `https://<shop>/apps/proxy/`).\n *\n * @example\n * <caption>Wrap a route with an AppProxyProvider component.</caption>\n * <description>Wrap your route component in the `AppProxyProvider` component and pass in your app URL.</description>\n * ```ts\n * // /app/routes/**\\/*.ts\n * import {authenticate} from '~/shopify.server';\n * import {AppProxyProvider} from '@shopify/shopify-app-remix/react';\n *\n * export async function loader({ request }) {\n * await authenticate.public.appProxy(request);\n *\n * return json({ appUrl: process.env.SHOPIFY_APP_URL });\n * }\n *\n * export default function App() {\n * const { appUrl } = useLoaderData();\n *\n * return (\n * <AppProxyProvider appUrl={appUrl}>\n * Page content\n * </AppProxyProvider>\n * );\n * }\n * ```\n */\nexport function AppProxyProvider(props: AppProxyProviderProps) {\n const {children, appUrl} = props;\n const [requestUrl, setRequestUrl] = useState<URL | undefined>();\n\n useEffect(\n () => setRequestUrl(new URL(window.location.href)),\n [setRequestUrl],\n );\n\n return (\n <AppProxyProviderContext.Provider\n value={{appUrl, requestUrl, formatUrl: formatProxyUrl(requestUrl)}}\n >\n <base href={appUrl} />\n\n {children}\n </AppProxyProviderContext.Provider>\n );\n}\n\nfunction formatProxyUrl(requestUrl: URL | undefined): FormatUrlFunction {\n return (url: string | undefined, addOrigin = true) => {\n if (!url) {\n return url;\n }\n\n let finalUrl = url;\n\n if (addOrigin && requestUrl && finalUrl.startsWith('/')) {\n finalUrl = new URL(`${requestUrl.origin}${url}`).href;\n }\n if (!finalUrl.endsWith('/')) {\n finalUrl = `${finalUrl}/`;\n }\n\n return finalUrl;\n };\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;MA6Ba,uBAAuB,GAClC,aAAa,CAAsC,IAAI;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AACG,SAAU,gBAAgB,CAAC,KAA4B,EAAA;AAC3D,IAAA,MAAM,EAAC,QAAQ,EAAE,MAAM,EAAC,GAAG,KAAK;IAChC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,EAAmB;IAE/D,SAAS,CACP,MAAM,aAAa,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAClD,CAAC,aAAa,CAAC,CAChB;AAED,IAAA,QACEA,IAAA,CAAC,uBAAuB,CAAC,QAAQ,EAAA,EAC/B,KAAK,EAAE,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EAAC,EAAA,QAAA,EAAA,CAElEC,GAAA,CAAA,MAAA,EAAA,EAAM,IAAI,EAAE,MAAM,EAAA,CAAI,EAErB,QAAQ,CAAA,EAAA,CACwB;AAEvC;AAEA,SAAS,cAAc,CAAC,UAA2B,EAAA;AACjD,IAAA,OAAO,CAAC,GAAuB,EAAE,SAAS,GAAG,IAAI,KAAI;QACnD,IAAI,CAAC,GAAG,EAAE;AACR,YAAA,OAAO,GAAG;QACZ;QAEA,IAAI,QAAQ,GAAG,GAAG;QAElB,IAAI,SAAS,IAAI,UAAU,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AACvD,YAAA,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,CAAA,EAAG,GAAG,CAAA,CAAE,CAAC,CAAC,IAAI;QACvD;QACA,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAC3B,YAAA,QAAQ,GAAG,CAAA,EAAG,QAAQ,CAAA,CAAA,CAAG;QAC3B;AAEA,QAAA,OAAO,QAAQ;AACjB,IAAA,CAAC;AACH;;;;"}
|
|
@@ -90,10 +90,8 @@ function authStrategyFactory({ strategy, ...params }) {
|
|
|
90
90
|
await ensureAppIsEmbeddedIfRequired(params, request);
|
|
91
91
|
await ensureSessionTokenSearchParamIfRequired(params, request);
|
|
92
92
|
}
|
|
93
|
-
logger.info('Authenticating admin request', {
|
|
94
|
-
shop: getShopFromRequest(request),
|
|
95
|
-
});
|
|
96
93
|
const { payload, shop, sessionId, sessionToken } = await getSessionTokenContext(params, request);
|
|
94
|
+
logger.info('Authenticating admin request', { shop });
|
|
97
95
|
logger.debug('Loading session from storage', { shop, sessionId });
|
|
98
96
|
const existingSession = sessionId
|
|
99
97
|
? await config.sessionStorage.loadSession(sessionId)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.mjs","sources":["../../../../../../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,MA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OAAO,EAAE,SAAS,EAAE,YAAY,EAAC;IACjD;IAEA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;IAChC,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE;IAE1C,MAAM,SAAS,GAAG,MAAM,GAAG,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
|
+
{"version":3,"file":"authenticate.mjs","sources":["../../../../../../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> | 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 const {payload, shop, sessionId, sessionToken} =\n await getSessionTokenContext(params, request);\n\n logger.info('Authenticating admin request', {shop});\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,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;IAEA,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,cAAc,EAAE;YAC/C,MAAM,WAAW,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAE;AAEvD,YAAA,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE;AACzC,gBAAA,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC;gBACjC,WAAW;AACZ,aAAA,CAAC;AACF,YAAA,MAAM,eAAe,CAAC,EAAC,MAAmB,CAAC,EAAE,OAAO,EAAE,EAAC,GAAG,EAAE,WAAW,EAAC,CAAC;QAC3E;IACF;IAKA,SAAS,aAAa,CACpB,OAAgB,EAChB,OAA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AAM,CAAC;AACvB,cAAE,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG;cAC7C,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC;QAElC,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAC;IACjD;IAEA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;IAChC,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE;IAE1C,MAAM,SAAS,GAAG,MAAM,GAAG,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;;;;"}
|
|
@@ -15,8 +15,8 @@ function redirectFactory(params, request, shop) {
|
|
|
15
15
|
init,
|
|
16
16
|
});
|
|
17
17
|
logger.debug('Redirecting', { shop, url: parsedUrl.toString() });
|
|
18
|
-
const isSameOrigin = parsedUrl.origin === config.appUrl;
|
|
19
|
-
if (isSameOrigin
|
|
18
|
+
const isSameOrigin = parsedUrl.origin === new URL(config.appUrl).origin;
|
|
19
|
+
if (isSameOrigin) {
|
|
20
20
|
searchParams.forEach((value, key) => {
|
|
21
21
|
if (!parsedUrl.searchParams.has(key)) {
|
|
22
22
|
parsedUrl.searchParams.set(key, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/redirect.ts"],"sourcesContent":["import {\n TypedResponse,\n redirect as remixRedirect,\n} from '@remix-run/server-runtime';\n\nimport {BasicParams} from '../../../types';\nimport {getSessionTokenHeader} from '../../helpers/get-session-token-header';\n\nimport {renderAppBridge} from './render-app-bridge';\nimport {redirectWithAppBridgeHeaders} from './redirect-with-app-bridge-headers';\n\nexport type RedirectTarget = '_self' | '_parent' | '_top' | '_blank';\nexport type RedirectInit = number | (ResponseInit & {target?: RedirectTarget});\nexport type RedirectFunction = (\n url: string,\n init?: RedirectInit,\n) => TypedResponse<never>;\n\ninterface ParseURLOptions {\n params: BasicParams;\n url: string;\n base: string;\n shop: string;\n init: RedirectInit;\n}\n\ninterface ParsedURL {\n url: URL;\n target: RedirectTarget;\n}\n\nexport function redirectFactory(\n params: BasicParams,\n request: Request,\n shop: string,\n): RedirectFunction {\n const {config, logger} = params;\n\n return function redirect(url, init: RedirectInit) {\n const {searchParams} = new URL(request.url);\n const {url: parsedUrl, target} = parseURL({\n params,\n url,\n base: config.appUrl,\n shop,\n init,\n });\n\n logger.debug('Redirecting', {shop, url: parsedUrl.toString()});\n\n const isSameOrigin = parsedUrl.origin === config.appUrl;\n if (isSameOrigin
|
|
1
|
+
{"version":3,"file":"redirect.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/redirect.ts"],"sourcesContent":["import {\n TypedResponse,\n redirect as remixRedirect,\n} from '@remix-run/server-runtime';\n\nimport {BasicParams} from '../../../types';\nimport {getSessionTokenHeader} from '../../helpers/get-session-token-header';\n\nimport {renderAppBridge} from './render-app-bridge';\nimport {redirectWithAppBridgeHeaders} from './redirect-with-app-bridge-headers';\n\nexport type RedirectTarget = '_self' | '_parent' | '_top' | '_blank';\nexport type RedirectInit = number | (ResponseInit & {target?: RedirectTarget});\nexport type RedirectFunction = (\n url: string,\n init?: RedirectInit,\n) => TypedResponse<never>;\n\ninterface ParseURLOptions {\n params: BasicParams;\n url: string;\n base: string;\n shop: string;\n init: RedirectInit;\n}\n\ninterface ParsedURL {\n url: URL;\n target: RedirectTarget;\n}\n\nexport function redirectFactory(\n params: BasicParams,\n request: Request,\n shop: string,\n): RedirectFunction {\n const {config, logger} = params;\n\n return function redirect(url, init: RedirectInit) {\n const {searchParams} = new URL(request.url);\n const {url: parsedUrl, target} = parseURL({\n params,\n url,\n base: config.appUrl,\n shop,\n init,\n });\n\n logger.debug('Redirecting', {shop, url: parsedUrl.toString()});\n\n const isSameOrigin = parsedUrl.origin === new URL(config.appUrl).origin;\n if (isSameOrigin) {\n searchParams.forEach((value, key) => {\n if (!parsedUrl.searchParams.has(key)) {\n parsedUrl.searchParams.set(key, value);\n }\n });\n }\n\n if (target === '_self') {\n if (isBounceRequest(request)) {\n throw renderAppBridge(params, request, {\n url: parsedUrl.toString(),\n target,\n });\n } else {\n return remixRedirect(parsedUrl.toString(), init);\n }\n } else if (isDataRequest(request)) {\n throw redirectWithAppBridgeHeaders(parsedUrl.toString());\n } else if (isEmbeddedRequest(request)) {\n throw renderAppBridge(params, request, {\n url: parsedUrl.toString(),\n target,\n });\n }\n return remixRedirect(url, init);\n };\n}\n\nfunction isBounceRequest(request: Request) {\n return (\n Boolean(getSessionTokenHeader(request)) &&\n request.headers.has('X-Shopify-Bounce')\n );\n}\n\nfunction isDataRequest(request: Request) {\n const isGet = request.method === 'GET';\n const sessionTokenHeader = Boolean(getSessionTokenHeader(request));\n\n return (\n sessionTokenHeader &&\n !isBounceRequest(request) &&\n (!isEmbeddedRequest(request) || !isGet)\n );\n}\n\nfunction isEmbeddedRequest(request: Request) {\n const {searchParams} = new URL(request.url);\n\n return searchParams.get('embedded') === '1';\n}\n\nfunction parseURL({params, base, init, shop, url}: ParseURLOptions): ParsedURL {\n let target: RedirectTarget | undefined =\n typeof init !== 'number' && init?.target ? init.target : undefined;\n\n if (isAdminRemotePath(url)) {\n const {config} = params;\n\n const adminPath = getAdminRemotePath(url);\n const cleanShopName = shop.replace('.myshopify.com', '');\n\n if (!target) {\n target = config.isEmbeddedApp ? '_parent' : '_self';\n }\n\n return {\n url: new URL(\n `https://admin.shopify.com/store/${cleanShopName}${adminPath}`,\n ),\n target,\n };\n } else {\n return {\n url: new URL(url, base),\n target: target ?? '_self',\n };\n }\n}\n\nconst ADMIN_REGEX = /^shopify:\\/*admin\\//i;\n\nfunction isAdminRemotePath(url: string) {\n return ADMIN_REGEX.test(url);\n}\n\nfunction getAdminRemotePath(url: string | URL) {\n const parsedUrl = removeRestrictedParams(new URL(url)).href;\n return parsedUrl.replace(ADMIN_REGEX, '/');\n}\n\nconst embeddedFrameParamsToRemove = [\n 'hmac',\n 'locale',\n 'protocol',\n 'session',\n 'id_token',\n 'shop',\n 'timestamp',\n 'host',\n 'embedded',\n // sent when clicking rel=\"home\" nav item\n 'appLoadId',\n];\n\nfunction removeRestrictedParams(url: URL | string) {\n const newUrl = new URL(url);\n embeddedFrameParamsToRemove.forEach((param) =>\n newUrl.searchParams.delete(param),\n );\n return newUrl;\n}\n"],"names":["redirect","remixRedirect"],"mappings":";;;;;SA+BgB,eAAe,CAC7B,MAAmB,EACnB,OAAgB,EAChB,IAAY,EAAA;AAEZ,IAAA,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,MAAM;AAE/B,IAAA,OAAO,SAASA,UAAQ,CAAC,GAAG,EAAE,IAAkB,EAAA;QAC9C,MAAM,EAAC,YAAY,EAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;QAC3C,MAAM,EAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAC,GAAG,QAAQ,CAAC;YACxC,MAAM;YACN,GAAG;YACH,IAAI,EAAE,MAAM,CAAC,MAAM;YACnB,IAAI;YACJ,IAAI;AACL,SAAA,CAAC;AAEF,QAAA,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,QAAQ,EAAE,EAAC,CAAC;AAE9D,QAAA,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM;QACvE,IAAI,YAAY,EAAE;YAChB,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,KAAI;gBAClC,IAAI,CAAC,SAAS,CAAC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,EAAA;AAC3C,IAAA,MAAM,SAAS,GAAG,sBAAsB,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI;IAC3D,OAAO,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC;AAC5C;AAEA,MAAM,2BAA2B,GAAG;IAClC,MAAM;IACN,QAAQ;IACR,UAAU;IACV,SAAS;IACT,UAAU;IACV,MAAM;IACN,WAAW;IACX,MAAM;IACN,UAAU;;IAEV,WAAW;CACZ;AAED,SAAS,sBAAsB,CAAC,GAAiB,EAAA;AAC/C,IAAA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC;AAC3B,IAAA,2BAA2B,CAAC,OAAO,CAAC,CAAC,KAAK,KACxC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAClC;AACD,IAAA,OAAO,MAAM;AACf;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-redirect-url.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/validate-redirect-url.ts"],"sourcesContent":["import {ShopifyError} from '@shopify/shopify-api';\n\ninterface Options {\n requireSSL?: boolean;\n throwOnInvalid?: boolean;\n}\n\ntype SanitizedRedirectUrl<OptionsArg extends Options> =\n OptionsArg['throwOnInvalid'] extends false ? URL | undefined : URL;\n\nconst FILE_URI_MATCH = /\\/\\/\\//;\nconst INVALID_RELATIVE_URL = /[/\\\\][/\\\\]/;\nconst WHITESPACE_CHARACTER = /\\s/;\nconst VALID_PROTOCOLS = ['https:', 'http:'];\n\nfunction isSafe(\n domain: string,\n redirectUrl: unknown,\n requireSSL: boolean | undefined = true,\n): redirectUrl is string {\n if (typeof redirectUrl !== 'string') {\n return false;\n }\n\n if (\n FILE_URI_MATCH.test(redirectUrl) ||\n WHITESPACE_CHARACTER.test(redirectUrl)\n ) {\n return false;\n }\n\n let url: URL;\n\n try {\n url = new URL(redirectUrl, domain);\n } catch (
|
|
1
|
+
{"version":3,"file":"validate-redirect-url.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/validate-redirect-url.ts"],"sourcesContent":["import {ShopifyError} from '@shopify/shopify-api';\n\ninterface Options {\n requireSSL?: boolean;\n throwOnInvalid?: boolean;\n}\n\ntype SanitizedRedirectUrl<OptionsArg extends Options> =\n OptionsArg['throwOnInvalid'] extends false ? URL | undefined : URL;\n\nconst FILE_URI_MATCH = /\\/\\/\\//;\nconst INVALID_RELATIVE_URL = /[/\\\\][/\\\\]/;\nconst WHITESPACE_CHARACTER = /\\s/;\nconst VALID_PROTOCOLS = ['https:', 'http:'];\n\nfunction isSafe(\n domain: string,\n redirectUrl: unknown,\n requireSSL: boolean | undefined = true,\n): redirectUrl is string {\n if (typeof redirectUrl !== 'string') {\n return false;\n }\n\n if (\n FILE_URI_MATCH.test(redirectUrl) ||\n WHITESPACE_CHARACTER.test(redirectUrl)\n ) {\n return false;\n }\n\n let url: URL;\n\n try {\n url = new URL(redirectUrl, domain);\n } catch (_error) {\n return false;\n }\n\n if (INVALID_RELATIVE_URL.test(url.pathname)) {\n return false;\n }\n\n if (!VALID_PROTOCOLS.includes(url.protocol)) {\n return false;\n }\n\n if (requireSSL && url.protocol !== 'https:') {\n return false;\n }\n\n return true;\n}\n\nexport function sanitizeRedirectUrl<OptionsArg extends Options>(\n domain: string,\n redirectUrl: unknown,\n options: OptionsArg = {} as OptionsArg,\n): SanitizedRedirectUrl<OptionsArg> {\n if (isSafe(domain, redirectUrl, options.requireSSL)) {\n return new URL(redirectUrl, domain) as SanitizedRedirectUrl<OptionsArg>;\n } else if (options.throwOnInvalid === false) {\n return undefined as SanitizedRedirectUrl<OptionsArg>;\n } else {\n throw new ShopifyError('Invalid URL. Refusing to redirect');\n }\n}\n"],"names":[],"mappings":";;AAUA,MAAM,cAAc,GAAG,QAAQ;AAC/B,MAAM,oBAAoB,GAAG,YAAY;AACzC,MAAM,oBAAoB,GAAG,IAAI;AACjC,MAAM,eAAe,GAAG,CAAC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
66
|
if (!searchParams.get('index')) {
|
|
67
67
|
searchParams.delete('index');
|
|
68
68
|
}
|
|
69
|
-
let isValid = await api.utils.validateHmac(
|
|
69
|
+
let isValid = await api.utils.validateHmac(searchParams, {
|
|
70
|
+
signator: 'appProxy',
|
|
71
|
+
});
|
|
70
72
|
if (!isValid) {
|
|
71
73
|
const cleanPath = url.pathname
|
|
72
74
|
.replace(/^\//, '')
|
|
@@ -74,10 +76,14 @@ async function validateAppProxyHmac(params, url) {
|
|
|
74
76
|
.replaceAll('/', '.');
|
|
75
77
|
const data = `routes%2F${cleanPath}`;
|
|
76
78
|
searchParams = new URLSearchParams(`?_data=${data}&${searchParams.toString().replace(/^\?/, '')}`);
|
|
77
|
-
isValid = await api.utils.validateHmac(
|
|
79
|
+
isValid = await api.utils.validateHmac(searchParams, {
|
|
80
|
+
signator: 'appProxy',
|
|
81
|
+
});
|
|
78
82
|
if (!isValid) {
|
|
79
83
|
const searchParams = new URLSearchParams(`?_data=${data}._index&${url.search.replace(/^\?/, '')}`);
|
|
80
|
-
isValid = await api.utils.validateHmac(
|
|
84
|
+
isValid = await api.utils.validateHmac(searchParams, {
|
|
85
|
+
signator: 'appProxy',
|
|
86
|
+
});
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
return isValid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.mjs","sources":["../../../../../../../src/server/authenticate/public/appProxy/authenticate.ts"],"sourcesContent":["import {adminClientFactory, storefrontClientFactory} from '../../../clients';\nimport {ensureValidOfflineSession} from '../../../helpers';\nimport {BasicParams} from '../../../types';\n\nimport {\n AppProxyContext,\n AppProxyContextWithSession,\n AuthenticateAppProxy,\n LiquidResponseFunction,\n} from './types';\n\nexport function authenticateAppProxyFactory(\n params: BasicParams,\n): AuthenticateAppProxy {\n const {logger} = params;\n\n return async function authenticate(\n request: Request,\n ): Promise<AppProxyContext | AppProxyContextWithSession> {\n const url = new URL(request.url);\n const shop = url.searchParams.get('shop')!;\n logger.info('Authenticating app proxy request', {shop});\n\n if (!(await validateAppProxyHmac(params, url))) {\n logger.info('App proxy request has invalid signature', {shop});\n throw new Response(undefined, {\n status: 400,\n statusText: 'Bad Request',\n });\n }\n\n const session = await ensureValidOfflineSession(params, shop);\n\n if (!session) {\n logger.debug('Could not find offline session, returning empty context', {\n shop,\n ...Object.fromEntries(url.searchParams.entries()),\n });\n\n const context: AppProxyContext = {\n liquid,\n session: undefined,\n admin: undefined,\n storefront: undefined,\n };\n\n return context;\n }\n\n const context: AppProxyContextWithSession = {\n liquid,\n session,\n admin: adminClientFactory({params, session}),\n storefront: storefrontClientFactory({params, session}),\n };\n\n return context;\n };\n}\n\nconst liquid: LiquidResponseFunction = (body, initAndOptions) => {\n const processedBody = processLiquidBody(body);\n\n if (typeof initAndOptions !== 'object') {\n return new Response(processedBody, {\n status: initAndOptions || 200,\n headers: {\n 'Content-Type': 'application/liquid',\n },\n });\n }\n\n const {layout, ...responseInit} = initAndOptions || {};\n const responseBody =\n layout === false ? `{% layout none %} ${processedBody}` : processedBody;\n\n const headers = new Headers(responseInit.headers);\n headers.set('Content-Type', 'application/liquid');\n\n return new Response(responseBody, {\n ...responseInit,\n headers,\n });\n};\n\nasync function validateAppProxyHmac(\n params: BasicParams,\n url: URL,\n): Promise<boolean> {\n const {api, logger} = params;\n\n try {\n let searchParams = new URLSearchParams(url.search);\n if (!searchParams.get('index')) {\n searchParams.delete('index');\n }\n\n let isValid = await api.utils.validateHmac(\n
|
|
1
|
+
{"version":3,"file":"authenticate.mjs","sources":["../../../../../../../src/server/authenticate/public/appProxy/authenticate.ts"],"sourcesContent":["import {adminClientFactory, storefrontClientFactory} from '../../../clients';\nimport {ensureValidOfflineSession} from '../../../helpers';\nimport {BasicParams} from '../../../types';\n\nimport {\n AppProxyContext,\n AppProxyContextWithSession,\n AuthenticateAppProxy,\n LiquidResponseFunction,\n} from './types';\n\nexport function authenticateAppProxyFactory(\n params: BasicParams,\n): AuthenticateAppProxy {\n const {logger} = params;\n\n return async function authenticate(\n request: Request,\n ): Promise<AppProxyContext | AppProxyContextWithSession> {\n const url = new URL(request.url);\n const shop = url.searchParams.get('shop')!;\n logger.info('Authenticating app proxy request', {shop});\n\n if (!(await validateAppProxyHmac(params, url))) {\n logger.info('App proxy request has invalid signature', {shop});\n throw new Response(undefined, {\n status: 400,\n statusText: 'Bad Request',\n });\n }\n\n const session = await ensureValidOfflineSession(params, shop);\n\n if (!session) {\n logger.debug('Could not find offline session, returning empty context', {\n shop,\n ...Object.fromEntries(url.searchParams.entries()),\n });\n\n const context: AppProxyContext = {\n liquid,\n session: undefined,\n admin: undefined,\n storefront: undefined,\n };\n\n return context;\n }\n\n const context: AppProxyContextWithSession = {\n liquid,\n session,\n admin: adminClientFactory({params, session}),\n storefront: storefrontClientFactory({params, session}),\n };\n\n return context;\n };\n}\n\nconst liquid: LiquidResponseFunction = (body, initAndOptions) => {\n const processedBody = processLiquidBody(body);\n\n if (typeof initAndOptions !== 'object') {\n return new Response(processedBody, {\n status: initAndOptions || 200,\n headers: {\n 'Content-Type': 'application/liquid',\n },\n });\n }\n\n const {layout, ...responseInit} = initAndOptions || {};\n const responseBody =\n layout === false ? `{% layout none %} ${processedBody}` : processedBody;\n\n const headers = new Headers(responseInit.headers);\n headers.set('Content-Type', 'application/liquid');\n\n return new Response(responseBody, {\n ...responseInit,\n headers,\n });\n};\n\nasync function validateAppProxyHmac(\n params: BasicParams,\n url: URL,\n): Promise<boolean> {\n const {api, logger} = params;\n\n try {\n let searchParams = new URLSearchParams(url.search);\n if (!searchParams.get('index')) {\n searchParams.delete('index');\n }\n\n let isValid = await api.utils.validateHmac(searchParams, {\n signator: 'appProxy',\n });\n\n if (!isValid) {\n const cleanPath = url.pathname\n .replace(/^\\//, '')\n .replace(/\\/$/, '')\n .replaceAll('/', '.');\n const data = `routes%2F${cleanPath}`;\n\n searchParams = new URLSearchParams(\n `?_data=${data}&${searchParams.toString().replace(/^\\?/, '')}`,\n );\n\n isValid = await api.utils.validateHmac(searchParams, {\n signator: 'appProxy',\n });\n\n if (!isValid) {\n const searchParams = new URLSearchParams(\n `?_data=${data}._index&${url.search.replace(/^\\?/, '')}`,\n );\n\n isValid = await api.utils.validateHmac(searchParams, {\n signator: 'appProxy',\n });\n }\n }\n\n return isValid;\n } catch (error) {\n const shop = url.searchParams.get('shop')!;\n logger.info(error.message, {shop});\n throw new Response(undefined, {status: 400, statusText: 'Bad Request'});\n }\n}\n\nfunction processLiquidBody(body: string) {\n return (\n body\n // Add trailing slashes to relative form action URLs\n .replaceAll(\n /<(form[^>]+)action=\"(\\/[^\"?]+)(\\?[^\"]+)?\">/g,\n '<$1action=\"$2/$3\">',\n )\n // Add trailing slashes to relative link href URLs\n .replaceAll(/<(a[^>]+)href=\"(\\/[^\"?]+)(\\?[^\"]+)?\">/g, '<$1href=\"$2/$3\">')\n );\n}\n"],"names":[],"mappings":";;;;;;AAWM,SAAU,2BAA2B,CACzC,MAAmB,EAAA;AAEnB,IAAA,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM;AAEvB,IAAA,OAAO,eAAe,YAAY,CAChC,OAAgB,EAAA;QAEhB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;QAChC,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE;QAC1C,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,EAAC,IAAI,EAAC,CAAC;QAEvD,IAAI,EAAE,MAAM,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE;YAC9C,MAAM,CAAC,IAAI,CAAC,yCAAyC,EAAE,EAAC,IAAI,EAAC,CAAC;AAC9D,YAAA,MAAM,IAAI,QAAQ,CAAC,SAAS,EAAE;AAC5B,gBAAA,MAAM,EAAE,GAAG;AACX,gBAAA,UAAU,EAAE,aAAa;AAC1B,aAAA,CAAC;QACJ;QAEA,MAAM,OAAO,GAAG,MAAM,yBAA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AAA,OAAA,EAAU,IAAI,WAAW,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA,CAAE,CACzD;gBAED,OAAO,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE;AACnD,oBAAA,QAAQ,EAAE,UAAU;AACrB,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,OAAO;IAChB;IAAE,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE;QAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAC,IAAI,EAAC,CAAC;AAClC,QAAA,MAAM,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAC,CAAC;IACzE;AACF;AAEA,SAAS,iBAAiB,CAAC,IAAY,EAAA;AACrC,IAAA,QACE;;AAEG,SAAA,UAAU,CACT,6CAA6C,EAC7C,oBAAoB;;AAGrB,SAAA,UAAU,CAAC,wCAAwC,EAAE,kBAAkB,CAAC;AAE/E;;;;"}
|
|
@@ -42,7 +42,6 @@ function authenticateWebhookFactory(params) {
|
|
|
42
42
|
topic: check.topic,
|
|
43
43
|
webhookId: check.webhookId,
|
|
44
44
|
payload: JSON.parse(rawBody),
|
|
45
|
-
subTopic: check.subTopic || undefined,
|
|
46
45
|
session: undefined,
|
|
47
46
|
admin: undefined,
|
|
48
47
|
webhookType: check.webhookType,
|
|
@@ -56,7 +55,7 @@ function authenticateWebhookFactory(params) {
|
|
|
56
55
|
apiVersion: check.apiVersion,
|
|
57
56
|
shop: check.domain,
|
|
58
57
|
topic: check.topic,
|
|
59
|
-
webhookId: check.
|
|
58
|
+
webhookId: check.webhookId,
|
|
60
59
|
payload: JSON.parse(rawBody),
|
|
61
60
|
session: undefined,
|
|
62
61
|
admin: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.mjs","sources":["../../../../../../src/server/authenticate/webhooks/authenticate.ts"],"sourcesContent":["import {WebhookValidationErrorReason, WebhookType} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../types';\nimport {adminClientFactory} from '../../clients';\nimport {handleClientErrorFactory} from '../admin/helpers';\nimport {ensureValidOfflineSession} from '../../helpers';\n\nimport type {\n AuthenticateWebhook,\n WebhookContext,\n WebhookContextWithoutSession,\n} from './types';\n\nexport function authenticateWebhookFactory<Topics extends string>(\n params: BasicParams,\n): AuthenticateWebhook<Topics> {\n const {api, logger} = params;\n\n return async function authenticate(\n request: Request,\n ): Promise<WebhookContext<Topics>> {\n if (request.method !== 'POST') {\n logger.debug(\n 'Received a non-POST request for a webhook. Only POST requests are allowed.',\n {url: request.url, method: request.method},\n );\n throw new Response(undefined, {\n status: 405,\n statusText: 'Method not allowed',\n });\n }\n\n const rawBody = await request.text();\n\n const check = await api.webhooks.validate({\n rawBody,\n rawRequest: request,\n });\n\n if (!check.valid) {\n if (check.reason === WebhookValidationErrorReason.InvalidHmac) {\n logger.debug('Webhook HMAC validation failed', check);\n throw new Response(undefined, {\n status: 401,\n statusText: 'Unauthorized',\n });\n } else {\n logger.debug('Webhook validation failed', check);\n throw new Response(undefined, {status: 400, statusText: 'Bad Request'});\n }\n }\n const session = await ensureValidOfflineSession(params, check.domain);\n\n let webhookContext: WebhookContextWithoutSession<Topics>;\n\n if (check.webhookType === WebhookType.Webhooks) {\n webhookContext = {\n apiVersion: check.apiVersion,\n shop: check.domain,\n topic: check.topic as Topics,\n webhookId: check.webhookId,\n payload: JSON.parse(rawBody),\n
|
|
1
|
+
{"version":3,"file":"authenticate.mjs","sources":["../../../../../../src/server/authenticate/webhooks/authenticate.ts"],"sourcesContent":["import {WebhookValidationErrorReason, WebhookType} from '@shopify/shopify-api';\n\nimport type {BasicParams} from '../../types';\nimport {adminClientFactory} from '../../clients';\nimport {handleClientErrorFactory} from '../admin/helpers';\nimport {ensureValidOfflineSession} from '../../helpers';\n\nimport type {\n AuthenticateWebhook,\n WebhookContext,\n WebhookContextWithoutSession,\n} from './types';\n\nexport function authenticateWebhookFactory<Topics extends string>(\n params: BasicParams,\n): AuthenticateWebhook<Topics> {\n const {api, logger} = params;\n\n return async function authenticate(\n request: Request,\n ): Promise<WebhookContext<Topics>> {\n if (request.method !== 'POST') {\n logger.debug(\n 'Received a non-POST request for a webhook. Only POST requests are allowed.',\n {url: request.url, method: request.method},\n );\n throw new Response(undefined, {\n status: 405,\n statusText: 'Method not allowed',\n });\n }\n\n const rawBody = await request.text();\n\n const check = await api.webhooks.validate({\n rawBody,\n rawRequest: request,\n });\n\n if (!check.valid) {\n if (check.reason === WebhookValidationErrorReason.InvalidHmac) {\n logger.debug('Webhook HMAC validation failed', check);\n throw new Response(undefined, {\n status: 401,\n statusText: 'Unauthorized',\n });\n } else {\n logger.debug('Webhook validation failed', check);\n throw new Response(undefined, {status: 400, statusText: 'Bad Request'});\n }\n }\n const session = await ensureValidOfflineSession(params, check.domain);\n\n let webhookContext: WebhookContextWithoutSession<Topics>;\n\n if (check.webhookType === WebhookType.Webhooks) {\n webhookContext = {\n apiVersion: check.apiVersion,\n shop: check.domain,\n topic: check.topic as Topics,\n webhookId: check.webhookId,\n payload: JSON.parse(rawBody),\n session: undefined,\n admin: undefined,\n webhookType: check.webhookType,\n name: check.name,\n triggeredAt: check.triggeredAt,\n eventId: check.eventId,\n };\n } else {\n webhookContext = {\n apiVersion: check.apiVersion,\n shop: check.domain,\n topic: check.topic as Topics,\n webhookId: check.webhookId,\n payload: JSON.parse(rawBody),\n session: undefined,\n admin: undefined,\n webhookType: check.webhookType,\n handle: check.handle,\n action: check.action,\n resourceId: check.resourceId,\n triggeredAt: check.triggeredAt,\n eventId: check.eventId,\n };\n }\n\n if (!session) {\n return webhookContext;\n }\n\n const admin = adminClientFactory({\n params,\n session,\n handleClientError: handleClientErrorFactory({request}),\n });\n\n return {\n ...webhookContext,\n session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M,KAAK,GAAG,kBAAkB,CAAC;YAC/B,MAAM;YACN,OAAO;AACP,YAAA,iBAAiB,EAAE,wBAAwB,CAAC,EAAC,OAAO,EAAC,CAAC;AACvD,SAAA,CAAC;QAEF,OAAO;AACL,YAAA,GAAG,cAAc;YACjB,OAAO;YACP,KAAK;SACN;AACH,IAAA,CAAC;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.mjs","sources":["../../../../../src/server/future/flags.ts"],"sourcesContent":["import type {ConfigParams, Shopify} from '@shopify/shopify-api';\n\nimport {AppConfig} from '../config-types';\n\n// When adding new flags, you should also add them to the `TEST_FUTURE_FLAGS` object in `test-config.ts` to ensure that\n// it doesn't cause regressions.\nexport interface FutureFlags {\n /**\n * When enabled, embedded apps will fetch access tokens via [token exchange](https://shopify.dev/docs/apps/auth/get-access-tokens/token-exchange).\n * This assumes the app has scopes declared for [Shopify managing installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation).\n *\n * Learn more about this [new embedded app auth strategy](https://shopify.dev/docs/api/shopify-app-remix#embedded-auth-strategy).\n *\n * @default false\n */\n unstable_newEmbeddedAuthStrategy?: boolean;\n /**\n * When enabled, the app will start using expiring offline access tokens and automatically refresh them when they are close to expiring.\n *\n * @default false\n */\n expiringOfflineAccessTokens?: boolean;\n}\n\n// When adding new flags, use this format:\n// apiFutureFlag: Future extends FutureFlags ? Future['remixFutureFlag'] : false;\nexport interface ApiFutureFlags<Future extends FutureFlagOptions> {\n expiringOfflineAccessTokens: Future extends FutureFlags\n ? Future['expiringOfflineAccessTokens']\n : false;\n unstable_managedPricingSupport: true;\n}\n\nexport type ApiConfigWithFutureFlags<Future extends FutureFlagOptions> =\n ConfigParams<ApiFutureFlags<Future>>;\n\nexport type FutureFlagOptions = FutureFlags | undefined;\n\nexport type FeatureEnabled<\n Future extends FutureFlagOptions,\n Flag extends keyof FutureFlags,\n> = Future extends FutureFlags\n ? Future[Flag] extends true\n ? true\n : false\n : false;\n\nexport function logDisabledFutureFlags(\n config: AppConfig,\n logger: Shopify['logger'],\n) {\n const logFlag = (flag: string, message: string) =>\n logger.info(`Future flag ${flag} is disabled.\\n\\n ${message}\\n`);\n\n if (!config.future.unstable_newEmbeddedAuthStrategy) {\n logFlag(\n 'unstable_newEmbeddedAuthStrategy',\n 'Enable this to use OAuth token exchange instead of auth code to generate API access tokens.' +\n '\\n Your app must be using Shopify managed install: https://shopify.dev/docs/apps/auth/installation',\n );\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flags.mjs","sources":["../../../../../src/server/future/flags.ts"],"sourcesContent":["import type {ConfigParams, Shopify} from '@shopify/shopify-api';\n\nimport {AppConfig} from '../config-types';\n\n// When adding new flags, you should also add them to the `TEST_FUTURE_FLAGS` object in `test-config.ts` to ensure that\n// it doesn't cause regressions.\n/**\n * Set future flags using the `future` configuration field to opt in to upcoming breaking changes.\n *\n * With this feature, you can prepare for major releases ahead of time, as well as try out new features before they are released.\n * @publicDocs\n */\nexport interface FutureFlags {\n /**\n * When enabled, embedded apps will fetch access tokens via [token exchange](https://shopify.dev/docs/apps/auth/get-access-tokens/token-exchange).\n * This assumes the app has scopes declared for [Shopify managing installation](https://shopify.dev/docs/apps/auth/installation#shopify-managed-installation).\n *\n * Learn more about this [new embedded app auth strategy](https://shopify.dev/docs/api/shopify-app-remix#embedded-auth-strategy).\n *\n * @default false\n */\n unstable_newEmbeddedAuthStrategy?: boolean;\n /**\n * When enabled, the app will start using expiring offline access tokens and automatically refresh them when they are close to expiring.\n *\n * @default false\n */\n expiringOfflineAccessTokens?: boolean;\n}\n\n// When adding new flags, use this format:\n// apiFutureFlag: Future extends FutureFlags ? Future['remixFutureFlag'] : false;\nexport interface ApiFutureFlags<Future extends FutureFlagOptions> {\n expiringOfflineAccessTokens: Future extends FutureFlags\n ? Future['expiringOfflineAccessTokens']\n : false;\n unstable_managedPricingSupport: true;\n}\n\nexport type ApiConfigWithFutureFlags<Future extends FutureFlagOptions> =\n ConfigParams<ApiFutureFlags<Future>>;\n\nexport type FutureFlagOptions = FutureFlags | undefined;\n\nexport type FeatureEnabled<\n Future extends FutureFlagOptions,\n Flag extends keyof FutureFlags,\n> = Future extends FutureFlags\n ? Future[Flag] extends true\n ? true\n : false\n : false;\n\nexport function logDisabledFutureFlags(\n config: AppConfig,\n logger: Shopify['logger'],\n) {\n const logFlag = (flag: string, message: string) =>\n logger.info(`Future flag ${flag} is disabled.\\n\\n ${message}\\n`);\n\n if (!config.future.unstable_newEmbeddedAuthStrategy) {\n logFlag(\n 'unstable_newEmbeddedAuthStrategy',\n 'Enable this to use OAuth token exchange instead of auth code to generate API access tokens.' +\n '\\n Your app must be using Shopify managed install: https://shopify.dev/docs/apps/auth/installation',\n );\n }\n}\n"],"names":[],"mappings":"AAqDM,SAAU,sBAAsB,CACpC,MAAiB,EACjB,MAAyB,EAAA;AAEzB,IAAA,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,OAAe,KAC5C,MAAM,CAAC,IAAI,CAAC,CAAA,YAAA,EAAe,IAAI,sBAAsB,OAAO,CAAA,EAAA,CAAI,CAAC;AAEnE,IAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gCAAgC,EAAE;QACnD,OAAO,CACL,kCAAkC,EAClC,6FAA6F;AAC3F,YAAA,qGAAqG,CACxG;IACH;AACF;;;;"}
|
|
@@ -26,6 +26,7 @@ import { logDisabledFutureFlags } from './future/flags.mjs';
|
|
|
26
26
|
*
|
|
27
27
|
* @param appConfig Configuration options for your Shopify app, such as the scopes your app needs.
|
|
28
28
|
* @returns `ShopifyApp` An object constructed using your appConfig. It has methods for interacting with Shopify.
|
|
29
|
+
* @publicDocs
|
|
29
30
|
*
|
|
30
31
|
* @example
|
|
31
32
|
* <caption>The minimum viable configuration</caption>
|
|
@@ -101,7 +102,7 @@ function deriveApi(appConfig) {
|
|
|
101
102
|
try {
|
|
102
103
|
appUrl = new URL(appConfig.appUrl);
|
|
103
104
|
}
|
|
104
|
-
catch (
|
|
105
|
+
catch (_error) {
|
|
105
106
|
const message = appConfig.appUrl === ''
|
|
106
107
|
? `Detected an empty appUrl configuration, please make sure to set the necessary environment variables.\n` +
|
|
107
108
|
`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`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-app.mjs","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":[],"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,GAAG,cAAc,CAAC,GAAG,CAAC,MA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AK;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.mjs","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 * @publicDocs\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> | AppStoreApp<Config> | 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":[],"mappings":";;;;;;;;;;;;;;;;;;;;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S;AACZ,QAAA,GAAG,SAAS;QACZ,OAAO,EAAE,SAAS,CAAC,OAA+B;QAClD,MAAM,EAAE,SAAS,CAAC,MAAM;QACxB,wBAAwB,EAAE,IAAI,wBAAwB,EAAE;AACxD,QAAA,eAAe,EAAE,SAAS,CAAC,YAAY,KAAK,eAAe,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-config.mjs","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
|
|
1
|
+
{"version":3,"file":"test-config.mjs","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 [\n key in keyof Type2 as Type2[key] extends undefined ? never : key\n ]: 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":[],"mappings":";;;;AAYA,MAAM,WAAW,GAAG;AAClB,IAAA,MAAM,EAAE,OAAO;AACf,IAAA,YAAY,EAAE,cAAc;IAC5B,MAAM,EAAE,CAAC,WAAW,CAAQ;AAC5B,IAAA,MAAM,EAAE,OAAO;AACf,IAAA,mBAAmB,EAAE,OAAO;AAC5B,IAAA,+BAA+B,EAAE,OAAO;AACxC,IAAA,MAAM,EAAE;QACN,KAAK,EAAE,WAAW,CAAC,KAAK;AACzB,KAAA;IACD,cAAc,EAAE,IAAI,oBAAoB,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":"version.mjs","sources":["../../../../src/server/version.ts"],"sourcesContent":["export const SHOPIFY_REMIX_LIBRARY_VERSION = '
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../../src/server/version.ts"],"sourcesContent":["export const SHOPIFY_REMIX_LIBRARY_VERSION = '5.0.0';\n"],"names":[],"mappings":"AAAO,MAAM,6BAA6B,GAAG;;;;"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { AppProviderProps as PolarisAppProviderProps } from '@shopify/polaris';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the `AppProvider` component.
|
|
4
|
+
* @publicDocs
|
|
5
|
+
*/
|
|
2
6
|
export interface AppProviderProps extends Omit<PolarisAppProviderProps, 'linkComponent' | 'i18n'> {
|
|
3
7
|
/**
|
|
4
8
|
* The API key for your Shopify app. This is the `Client ID` from the Partner Dashboard.
|
|
@@ -88,5 +92,5 @@ export interface AppProviderProps extends Omit<PolarisAppProviderProps, 'linkCom
|
|
|
88
92
|
* }
|
|
89
93
|
* ```
|
|
90
94
|
*/
|
|
91
|
-
export declare function AppProvider(props: AppProviderProps): import("react
|
|
95
|
+
export declare function AppProvider(props: AppProviderProps): import("react").JSX.Element;
|
|
92
96
|
//# sourceMappingURL=AppProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProvider.d.ts","sourceRoot":"","sources":["../../../../../src/react/components/AppProvider/AppProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,IAAI,uBAAuB,EAC5C,MAAM,kBAAkB,CAAC;AAW1B,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,uBAAuB,EACvB,eAAe,GAAG,MAAM,CACzB;IACC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,IAAI,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACvC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB
|
|
1
|
+
{"version":3,"file":"AppProvider.d.ts","sourceRoot":"","sources":["../../../../../src/react/components/AppProvider/AppProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,IAAI,uBAAuB,EAC5C,MAAM,kBAAkB,CAAC;AAW1B;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAC5C,uBAAuB,EACvB,eAAe,GAAG,MAAM,CACzB;IACC;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,IAAI,CAAC,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACvC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAuClD"}
|
|
@@ -57,6 +57,7 @@ export interface AppProxyFormProps extends FormProps {
|
|
|
57
57
|
* );
|
|
58
58
|
* }
|
|
59
59
|
* ```
|
|
60
|
+
* @publicDocs
|
|
60
61
|
*/
|
|
61
|
-
export declare
|
|
62
|
+
export declare const AppProxyForm: import("react").ForwardRefExoticComponent<AppProxyFormProps & import("react").RefAttributes<HTMLFormElement>>;
|
|
62
63
|
//# sourceMappingURL=AppProxyForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProxyForm.d.ts","sourceRoot":"","sources":["../../../../../src/react/components/AppProxyForm/AppProxyForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAItD,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"AppProxyForm.d.ts","sourceRoot":"","sources":["../../../../../src/react/components/AppProxyForm/AppProxyForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAItD,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,eAAO,MAAM,YAAY,+GAkBxB,CAAC"}
|
|
@@ -30,6 +30,7 @@ export interface AppProxyLinkProps extends React.DetailedHTMLProps<React.AnchorH
|
|
|
30
30
|
* );
|
|
31
31
|
* }
|
|
32
32
|
* ```
|
|
33
|
+
* @publicDocs
|
|
33
34
|
*/
|
|
34
|
-
export declare
|
|
35
|
+
export declare const AppProxyLink: import("react").ForwardRefExoticComponent<Omit<AppProxyLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
35
36
|
//# sourceMappingURL=AppProxyLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppProxyLink.d.ts","sourceRoot":"","sources":["../../../../../src/react/components/AppProxyLink/AppProxyLink.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAkB,SAAQ,KAAK,CAAC,iBAAiB,CAChE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAC7C,iBAAiB,CAClB;IACC,IAAI,EAAE,MAAM,CAAC;CACd;AAED
|
|
1
|
+
{"version":3,"file":"AppProxyLink.d.ts","sourceRoot":"","sources":["../../../../../src/react/components/AppProxyLink/AppProxyLink.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAkB,SAAQ,KAAK,CAAC,iBAAiB,CAChE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAC7C,iBAAiB,CAClB;IACC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,YAAY,8HAkBxB,CAAC"}
|