shopify-app-js 0.0.1-security → 1.0.1
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.
Potentially problematic release.
This version of shopify-app-js might be problematic. Click here for more details.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +14 -0
- package/.changeset/flat-clouds-camp.md +5 -0
- package/.eslintrc.js +36 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/BUG_REPORT.md +36 -0
- package/.github/ISSUE_TEMPLATE/ENHANCEMENT.md +9 -0
- package/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +9 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +34 -0
- package/.github/dependabot.yml +9 -0
- package/.github/workflows/changelog.yml +30 -0
- package/.github/workflows/ci.yml +22 -0
- package/.github/workflows/cla.yml +22 -0
- package/.github/workflows/close-waiting-for-response-issues.yml +20 -0
- package/.github/workflows/main-release.yml +36 -0
- package/.github/workflows/markdown_link_check.yml +14 -0
- package/.github/workflows/markdown_link_checker_config.json +9 -0
- package/.github/workflows/publish-experimental-build.yml +30 -0
- package/.github/workflows/release-candidate.yml +35 -0
- package/.github/workflows/remove-labels-on-activity.yml +16 -0
- package/.github/workflows/stale.yml +26 -0
- package/.prettierignore +5 -0
- package/.prettierrc +1 -0
- package/CODE_OF_CONDUCT.md +46 -0
- package/CONTRIBUTING.md +39 -0
- package/LICENSE.md +9 -0
- package/README.md +62 -3
- package/RELEASING.md +142 -0
- package/loom.config.ts +115 -0
- package/package.json +44 -3
- package/packages/.prettierrc +1 -0
- package/packages/shopify-app-express/CHANGELOG.md +316 -0
- package/packages/shopify-app-express/LICENSE.md +9 -0
- package/packages/shopify-app-express/README.md +93 -0
- package/packages/shopify-app-express/docs/reference/README.md +3 -0
- package/packages/shopify-app-express/docs/reference/auth.md +76 -0
- package/packages/shopify-app-express/docs/reference/cspHeaders.md +24 -0
- package/packages/shopify-app-express/docs/reference/ensureInstalledOnShop.md +17 -0
- package/packages/shopify-app-express/docs/reference/migrating-app-v6-api-lib-to-express-lib.md +345 -0
- package/packages/shopify-app-express/docs/reference/processWebhooks.md +67 -0
- package/packages/shopify-app-express/docs/reference/redirectOutOfApp.md +77 -0
- package/packages/shopify-app-express/docs/reference/redirectToShopifyOrAppRoot.md +20 -0
- package/packages/shopify-app-express/docs/reference/shopifyApp.md +148 -0
- package/packages/shopify-app-express/docs/reference/validateAuthenticatedSession.md +30 -0
- package/packages/shopify-app-express/loom.config.ts +27 -0
- package/packages/shopify-app-express/package.json +54 -0
- package/packages/shopify-app-express/src/__tests__/index.test.ts +100 -0
- package/packages/shopify-app-express/src/__tests__/integration/oauth.test.ts +445 -0
- package/packages/shopify-app-express/src/__tests__/integration/responses.ts +135 -0
- package/packages/shopify-app-express/src/__tests__/integration/types.ts +22 -0
- package/packages/shopify-app-express/src/__tests__/integration/utils.ts +68 -0
- package/packages/shopify-app-express/src/__tests__/integration/webhooks.test.ts +208 -0
- package/packages/shopify-app-express/src/__tests__/redirect-to-auth.test.ts +103 -0
- package/packages/shopify-app-express/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-express/src/__tests__/test-helper.ts +204 -0
- package/packages/shopify-app-express/src/app-installations.ts +42 -0
- package/packages/shopify-app-express/src/auth/__tests__/auth.test.ts +303 -0
- package/packages/shopify-app-express/src/auth/auth-callback.ts +131 -0
- package/packages/shopify-app-express/src/auth/index.ts +32 -0
- package/packages/shopify-app-express/src/auth/types.ts +13 -0
- package/packages/shopify-app-express/src/config-types.ts +38 -0
- package/packages/shopify-app-express/src/error.ts +8 -0
- package/packages/shopify-app-express/src/index.ts +171 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/csp-headers.test.ts +69 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/ensure-installed-on-shop.test.ts +193 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/redirect-to-shopify-or-app-root.test.ts +59 -0
- package/packages/shopify-app-express/src/middlewares/__tests__/validate-authenticated-session.test.ts +319 -0
- package/packages/shopify-app-express/src/middlewares/csp-headers.ts +31 -0
- package/packages/shopify-app-express/src/middlewares/ensure-installed-on-shop.ts +176 -0
- package/packages/shopify-app-express/src/middlewares/has-valid-access-token.ts +25 -0
- package/packages/shopify-app-express/src/middlewares/index.ts +15 -0
- package/packages/shopify-app-express/src/middlewares/redirect-to-shopify-or-app-root.ts +39 -0
- package/packages/shopify-app-express/src/middlewares/types.ts +6 -0
- package/packages/shopify-app-express/src/middlewares/validate-authenticated-session.ts +142 -0
- package/packages/shopify-app-express/src/redirect-out-of-app.ts +80 -0
- package/packages/shopify-app-express/src/redirect-to-auth.ts +70 -0
- package/packages/shopify-app-express/src/types.ts +26 -0
- package/packages/shopify-app-express/src/version.ts +1 -0
- package/packages/shopify-app-express/src/webhooks/__tests__/process.test.ts +138 -0
- package/packages/shopify-app-express/src/webhooks/index.ts +54 -0
- package/packages/shopify-app-express/src/webhooks/process.ts +22 -0
- package/packages/shopify-app-express/src/webhooks/types.ts +24 -0
- package/packages/shopify-app-express/tsconfig.json +10 -0
- package/packages/shopify-app-remix/.eslintrc.js +3 -0
- package/packages/shopify-app-remix/CHANGELOG.md +569 -0
- package/packages/shopify-app-remix/LICENSE.md +9 -0
- package/packages/shopify-app-remix/README.md +223 -0
- package/packages/shopify-app-remix/docs/build-docs.sh +11 -0
- package/packages/shopify-app-remix/docs/generated/generated_docs_data.json +18650 -0
- package/packages/shopify-app-remix/docs/generated/generated_static_pages.json +540 -0
- package/packages/shopify-app-remix/docs/staticPages/admin.doc.ts +130 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/auth-cors.example.tsx +11 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/auth.example.tsx +19 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/graphql.example.tsx +29 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/headers.example.tsx +10 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/rest-resources.example.tsx +9 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/admin/rest.example.tsx +17 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/future-flags/config.example.ts +8 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/future-flags/unstable.example.ts +9 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/.graphqlrc.ts +16 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/install.npm.example.sh +2 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/install.pnpm.example.sh +2 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/install.yarn.example.sh +2 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/package.json +5 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/run.npm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/run.pnpm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/graphql-types/run.yarn.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/webhooks/config.example.ts +19 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/guides/webhooks/endpoint.example.ts +24 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/app-provider.example.ts +30 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/boundaries.example.ts +9 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/create.npm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/create.pnpm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/create.yarn.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/embedded-app-auth-strategy-config.example.ts +10 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/entry-server.example.ts +12 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/install.npm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/install.pnpm.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/install.yarn.example.sh +1 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/shopify-app.example.ts +14 -0
- package/packages/shopify-app-remix/docs/staticPages/examples/index/splat-route.example.ts +11 -0
- package/packages/shopify-app-remix/docs/staticPages/future-flags.doc.ts +94 -0
- package/packages/shopify-app-remix/docs/staticPages/graphql-types.doc.ts +148 -0
- package/packages/shopify-app-remix/docs/staticPages/index.doc.ts +227 -0
- package/packages/shopify-app-remix/docs/staticPages/webhooks.doc.ts +64 -0
- package/packages/shopify-app-remix/docs/tsconfig.docs.json +9 -0
- package/packages/shopify-app-remix/docs/typeOverride.json +1 -0
- package/packages/shopify-app-remix/docs/upcoming_changes.md +153 -0
- package/packages/shopify-app-remix/loom.config.ts +57 -0
- package/packages/shopify-app-remix/package.json +93 -0
- package/packages/shopify-app-remix/src/react/.eslintrc.js +16 -0
- package/packages/shopify-app-remix/src/react/__tests__/test-helper.ts +22 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/AppProvider.doc.ts +34 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/AppProvider.tsx +121 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/__tests__/AppProvider.test.tsx +68 -0
- package/packages/shopify-app-remix/src/react/components/AppProvider/index.ts +1 -0
- package/packages/shopify-app-remix/src/react/components/RemixPolarisLink.tsx +14 -0
- package/packages/shopify-app-remix/src/react/components/index.ts +1 -0
- package/packages/shopify-app-remix/src/react/const.ts +2 -0
- package/packages/shopify-app-remix/src/react/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/.eslintrc.js +16 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/__tests__/request-mock.test.ts +171 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/const.ts +11 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-admin-api-client.ts +119 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-begin-auth-redirect.ts +22 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-document-request-headers.ts +25 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-exit-iframe.ts +37 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-login-redirect.ts +8 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/expect-storefront-api-client.ts +50 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/get-hmac.ts +10 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/get-jwt.ts +31 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/get-thrown-response.ts +17 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/index.ts +14 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/request-mock.ts +169 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/setup-valid-session.ts +45 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/sign-request-cookie.ts +21 -0
- package/packages/shopify-app-remix/src/server/__test-helpers/test-config.ts +112 -0
- package/packages/shopify-app-remix/src/server/__tests__/override-logger.test.ts +101 -0
- package/packages/shopify-app-remix/src/server/__tests__/shopify-app.test.ts +119 -0
- package/packages/shopify-app-remix/src/server/adapters/__tests__/node-app-bridge-url.test.ts +18 -0
- package/packages/shopify-app-remix/src/server/adapters/__tests__/node.test.ts +28 -0
- package/packages/shopify-app-remix/src/server/adapters/node/__tests__/setup-jest.ts +10 -0
- package/packages/shopify-app-remix/src/server/adapters/node/index.ts +20 -0
- package/packages/shopify-app-remix/src/server/adapters/vercel/__tests__/setup-jest.ts +12 -0
- package/packages/shopify-app-remix/src/server/adapters/vercel/index.ts +13 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/admin-client.test.ts +181 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/doc-request-path.test.ts +151 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/exit-i-frame-path.test.ts +99 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/patch-session-token-path.test.ts +58 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/reject-bot.test.ts +23 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/respond-to-options.test.ts +50 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/__tests__/session-token-header-path.test.ts +91 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/authenticate.admin.doc.ts +37 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/authenticate.ts +201 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/cancel.test.ts +258 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/check.test.ts +254 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/mock-responses.ts +65 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/request.test.ts +373 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/__tests__/require.test.ts +316 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/authenticate.admin.billing.doc.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/cancel.ts +37 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/check.ts +38 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/index.ts +4 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/request.ts +101 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/require.ts +56 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/billing/types.ts +383 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/__tests__/redirect.test.ts +313 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/__tests__/validate-redirect-url.test.ts +84 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/begin-auth.ts +17 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/create-admin-api-context.ts +22 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/ensure-app-is-embedded-if-required.ts +18 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/ensure-session-token-search-param-if-required.ts +25 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/handle-client-error.ts +43 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/index.ts +14 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-to-auth-page.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-to-bounce-page.ts +23 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-to-shopify-or-app-root.ts +21 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-with-app-bridge-headers.ts +13 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect-with-exitiframe.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/redirect.ts +83 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/render-app-bridge.ts +46 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/trigger-after-auth-hook.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/validate-redirect-url.ts +67 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/helpers/validate-shop-and-host-params.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/admin-client.test.ts +222 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/auth-callback-path.test.ts +395 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/auth-path.test.ts +83 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/authenticate.test.ts +183 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/ensure-installed-on-shop.test.ts +234 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/auth-code-flow/session-token-header-path.test.ts +79 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/token-exchange/admin-client.test.ts +189 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/__tests__/token-exchange/authenticate.test.ts +310 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/auth-code-flow.ts +333 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/token-exchange.ts +169 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/strategies/types.ts +29 -0
- package/packages/shopify-app-remix/src/server/authenticate/admin/types.ts +199 -0
- package/packages/shopify-app-remix/src/server/authenticate/const.ts +15 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/__tests__/authenticate.test.ts +142 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/authenticate.flow.doc.ts +34 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/authenticate.ts +71 -0
- package/packages/shopify-app-remix/src/server/authenticate/flow/types.ts +90 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/__tests__/add-response-headers.test.ts +25 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/__tests__/app-bridge-url.test.ts +21 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/__tests__/idempotent-promise-handler.test.ts +104 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/add-response-headers.ts +43 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/app-bridge-url.ts +10 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/ensure-cors-headers.ts +38 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/get-session-token-header.ts +11 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/idempotent-promise-handler.ts +45 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/index.ts +8 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/reject-bot-request.ts +13 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/respond-to-invalid-session-token.ts +29 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/respond-to-options-request.ts +26 -0
- package/packages/shopify-app-remix/src/server/authenticate/helpers/validate-session-token.ts +32 -0
- package/packages/shopify-app-remix/src/server/authenticate/login/__tests__/login.test.ts +157 -0
- package/packages/shopify-app-remix/src/server/authenticate/login/login.ts +53 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/__tests__/factory.test.ts +224 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/__tests__/authenticate.test.ts +282 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/authenticate.public.app-proxy.doc.ts +36 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/authenticate.ts +90 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/appProxy/types.ts +164 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/__tests__/authenticate.test.ts +142 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/authenticate.public.checkout.doc.ts +23 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/authenticate.ts +45 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/checkout/types.ts +65 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/factory.ts +49 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/authenticate/public/types.ts +77 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/__tests__/authenticate.test.ts +207 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/__tests__/mock-responses.ts +45 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/__tests__/register.test.ts +210 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/authenticate.ts +113 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/authenticate.webhooks.doc.ts +28 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/register.ts +48 -0
- package/packages/shopify-app-remix/src/server/authenticate/webhooks/types.ts +246 -0
- package/packages/shopify-app-remix/src/server/boundary/__tests__/error.test.tsx +36 -0
- package/packages/shopify-app-remix/src/server/boundary/__tests__/headers.test.ts +66 -0
- package/packages/shopify-app-remix/src/server/boundary/error.tsx +14 -0
- package/packages/shopify-app-remix/src/server/boundary/headers.ts +15 -0
- package/packages/shopify-app-remix/src/server/boundary/index.ts +39 -0
- package/packages/shopify-app-remix/src/server/boundary/types.ts +4 -0
- package/packages/shopify-app-remix/src/server/clients/admin/authenticate.admin.api.doc.ts +34 -0
- package/packages/shopify-app-remix/src/server/clients/admin/factory.ts +30 -0
- package/packages/shopify-app-remix/src/server/clients/admin/graphql.ts +39 -0
- package/packages/shopify-app-remix/src/server/clients/admin/index.ts +2 -0
- package/packages/shopify-app-remix/src/server/clients/admin/rest.ts +157 -0
- package/packages/shopify-app-remix/src/server/clients/admin/types.ts +178 -0
- package/packages/shopify-app-remix/src/server/clients/index.ts +2 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/authenticate.storefront.api.doc.ts +34 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/factory.ts +32 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/index.ts +2 -0
- package/packages/shopify-app-remix/src/server/clients/storefront/types.ts +31 -0
- package/packages/shopify-app-remix/src/server/clients/types.ts +27 -0
- package/packages/shopify-app-remix/src/server/config-types.ts +293 -0
- package/packages/shopify-app-remix/src/server/errors.ts +3 -0
- package/packages/shopify-app-remix/src/server/future/flags.ts +57 -0
- package/packages/shopify-app-remix/src/server/index.ts +20 -0
- package/packages/shopify-app-remix/src/server/override-logger.ts +42 -0
- package/packages/shopify-app-remix/src/server/shopify-app.doc.ts +45 -0
- package/packages/shopify-app-remix/src/server/shopify-app.ts +198 -0
- package/packages/shopify-app-remix/src/server/types.ts +509 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/__tests__/factory.test.ts +30 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/factory.ts +29 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/types.ts +117 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/admin/unauthenticated.admin.doc.ts +40 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/helpers/get-offline-session.ts +13 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/helpers/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/__tests__/factory.test.ts +30 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/factory.ts +28 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/index.ts +1 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/types.ts +39 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/storefront/unauthenticated.storefront.doc.ts +40 -0
- package/packages/shopify-app-remix/src/server/unauthenticated/types.ts +68 -0
- package/packages/shopify-app-remix/src/server/version.ts +1 -0
- package/packages/shopify-app-remix/tsconfig.json +11 -0
- package/packages/shopify-app-session-storage/CHANGELOG.md +149 -0
- package/packages/shopify-app-session-storage/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage/README.md +5 -0
- package/packages/shopify-app-session-storage/implementing-session-storage.md +214 -0
- package/packages/shopify-app-session-storage/loom.config.ts +45 -0
- package/packages/shopify-app-session-storage/package.json +44 -0
- package/packages/shopify-app-session-storage/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage/src/abstract-migration-engine.ts +53 -0
- package/packages/shopify-app-session-storage/src/index.ts +3 -0
- package/packages/shopify-app-session-storage/src/rdbms-session-storage-migrator.ts +59 -0
- package/packages/shopify-app-session-storage/src/types.ts +174 -0
- package/packages/shopify-app-session-storage/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-dynamodb/CHANGELOG.md +150 -0
- package/packages/shopify-app-session-storage-dynamodb/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-dynamodb/README.md +75 -0
- package/packages/shopify-app-session-storage-dynamodb/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-dynamodb/package.json +51 -0
- package/packages/shopify-app-session-storage-dynamodb/src/__tests__/dynamodb.test.ts +93 -0
- package/packages/shopify-app-session-storage-dynamodb/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-dynamodb/src/dynamodb.ts +126 -0
- package/packages/shopify-app-session-storage-dynamodb/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-kv/CHANGELOG.md +204 -0
- package/packages/shopify-app-session-storage-kv/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-kv/README.md +41 -0
- package/packages/shopify-app-session-storage-kv/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-kv/package.json +52 -0
- package/packages/shopify-app-session-storage-kv/src/__tests__/kv-namespace-dummy-worker.ts +8 -0
- package/packages/shopify-app-session-storage-kv/src/__tests__/kv.test.ts +22 -0
- package/packages/shopify-app-session-storage-kv/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-kv/src/kv.ts +87 -0
- package/packages/shopify-app-session-storage-kv/tsconfig.json +11 -0
- package/packages/shopify-app-session-storage-memory/CHANGELOG.md +190 -0
- package/packages/shopify-app-session-storage-memory/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-memory/README.md +19 -0
- package/packages/shopify-app-session-storage-memory/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-memory/package.json +46 -0
- package/packages/shopify-app-session-storage-memory/src/__tests__/memory.test.ts +12 -0
- package/packages/shopify-app-session-storage-memory/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-memory/src/memory.ts +34 -0
- package/packages/shopify-app-session-storage-memory/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-mongodb/CHANGELOG.md +208 -0
- package/packages/shopify-app-session-storage-mongodb/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-mongodb/README.md +30 -0
- package/packages/shopify-app-session-storage-mongodb/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-mongodb/package.json +49 -0
- package/packages/shopify-app-session-storage-mongodb/src/__tests__/mongodb.test.ts +54 -0
- package/packages/shopify-app-session-storage-mongodb/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-mongodb/src/mongodb.ts +120 -0
- package/packages/shopify-app-session-storage-mongodb/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-mysql/CHANGELOG.md +220 -0
- package/packages/shopify-app-session-storage-mysql/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-mysql/README.md +41 -0
- package/packages/shopify-app-session-storage-mysql/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-mysql/package.json +50 -0
- package/packages/shopify-app-session-storage-mysql/src/__tests__/mysql.test.ts +137 -0
- package/packages/shopify-app-session-storage-mysql/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-mysql/src/migrations.ts +18 -0
- package/packages/shopify-app-session-storage-mysql/src/mysql-connection.ts +108 -0
- package/packages/shopify-app-session-storage-mysql/src/mysql-migrator.ts +53 -0
- package/packages/shopify-app-session-storage-mysql/src/mysql.ts +178 -0
- package/packages/shopify-app-session-storage-mysql/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-postgresql/CHANGELOG.md +210 -0
- package/packages/shopify-app-session-storage-postgresql/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-postgresql/README.md +39 -0
- package/packages/shopify-app-session-storage-postgresql/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-postgresql/package.json +52 -0
- package/packages/shopify-app-session-storage-postgresql/src/__tests__/migrate-to-case-sensitivity.test.ts +344 -0
- package/packages/shopify-app-session-storage-postgresql/src/__tests__/postgresql.test.ts +136 -0
- package/packages/shopify-app-session-storage-postgresql/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-postgresql/src/migrations.ts +70 -0
- package/packages/shopify-app-session-storage-postgresql/src/postgres-connection.ts +94 -0
- package/packages/shopify-app-session-storage-postgresql/src/postgres-migrator.ts +27 -0
- package/packages/shopify-app-session-storage-postgresql/src/postgresql.ts +178 -0
- package/packages/shopify-app-session-storage-postgresql/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-prisma/CHANGELOG.md +148 -0
- package/packages/shopify-app-session-storage-prisma/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-prisma/README.md +68 -0
- package/packages/shopify-app-session-storage-prisma/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-prisma/package.json +51 -0
- package/packages/shopify-app-session-storage-prisma/prisma/migrations/20230425184828_init/migration.sql +11 -0
- package/packages/shopify-app-session-storage-prisma/prisma/migrations/20230906155758_mySession/migration.sql +11 -0
- package/packages/shopify-app-session-storage-prisma/prisma/migrations/migration_lock.toml +3 -0
- package/packages/shopify-app-session-storage-prisma/prisma/schema.prisma +30 -0
- package/packages/shopify-app-session-storage-prisma/src/__tests__/prisma.test.ts +66 -0
- package/packages/shopify-app-session-storage-prisma/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-prisma/src/prisma.ts +145 -0
- package/packages/shopify-app-session-storage-prisma/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-redis/CHANGELOG.md +200 -0
- package/packages/shopify-app-session-storage-redis/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-redis/README.md +38 -0
- package/packages/shopify-app-session-storage-redis/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-redis/package.json +50 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/migration-test-data.ts +46 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/redis.conf +2 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/redis.test.ts +236 -0
- package/packages/shopify-app-session-storage-redis/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-redis/src/migrations.ts +36 -0
- package/packages/shopify-app-session-storage-redis/src/redis-connection.ts +64 -0
- package/packages/shopify-app-session-storage-redis/src/redis-migrator.ts +58 -0
- package/packages/shopify-app-session-storage-redis/src/redis.ts +167 -0
- package/packages/shopify-app-session-storage-redis/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-sqlite/CHANGELOG.md +202 -0
- package/packages/shopify-app-session-storage-sqlite/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-sqlite/README.md +25 -0
- package/packages/shopify-app-session-storage-sqlite/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-sqlite/package.json +51 -0
- package/packages/shopify-app-session-storage-sqlite/src/__tests__/setup-jest.ts +8 -0
- package/packages/shopify-app-session-storage-sqlite/src/__tests__/sqlite.test.ts +44 -0
- package/packages/shopify-app-session-storage-sqlite/src/migrations.ts +54 -0
- package/packages/shopify-app-session-storage-sqlite/src/sqlite-connection.ts +80 -0
- package/packages/shopify-app-session-storage-sqlite/src/sqlite-migrator.ts +34 -0
- package/packages/shopify-app-session-storage-sqlite/src/sqlite.ts +147 -0
- package/packages/shopify-app-session-storage-sqlite/tsconfig.json +10 -0
- package/packages/shopify-app-session-storage-test-utils/CHANGELOG.md +185 -0
- package/packages/shopify-app-session-storage-test-utils/LICENSE.md +9 -0
- package/packages/shopify-app-session-storage-test-utils/loom.config.ts +27 -0
- package/packages/shopify-app-session-storage-test-utils/package.json +48 -0
- package/packages/shopify-app-session-storage-test-utils/src/__tests__/session-test-utils.test.ts +273 -0
- package/packages/shopify-app-session-storage-test-utils/src/battery-of-tests.ts +250 -0
- package/packages/shopify-app-session-storage-test-utils/src/index.ts +2 -0
- package/packages/shopify-app-session-storage-test-utils/src/session-test-utils.ts +24 -0
- package/packages/shopify-app-session-storage-test-utils/src/utils.ts +71 -0
- package/packages/shopify-app-session-storage-test-utils/tsconfig.json +10 -0
- package/tests/setup/build.js +1 -0
- package/tests/setup/setup-jest.ts +8 -0
- package/tsconfig.base.json +41 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {createPackage, createProjectPlugin} from '@shopify/loom';
|
|
2
|
+
import {buildLibrary} from '@shopify/loom-plugin-build-library';
|
|
3
|
+
|
|
4
|
+
export default createPackage((pkg) => {
|
|
5
|
+
pkg.entry({root: './src/index.ts'});
|
|
6
|
+
pkg.use(
|
|
7
|
+
buildLibrary({
|
|
8
|
+
// Required. A browserslist string for specifying your target output.
|
|
9
|
+
// Use browser targets (e.g. `'defaults'`) if your package targets the browser,
|
|
10
|
+
// node targets (e.g. `'node 12.22'`) if your package targets node
|
|
11
|
+
// or both (e.g.`'defaults, node 12.22'`) if your package targets both
|
|
12
|
+
targets: 'node 16',
|
|
13
|
+
// Optional. Defaults to false. Defines if commonjs outputs should be generated.
|
|
14
|
+
commonjs: true,
|
|
15
|
+
// Optional. Defaults to false. Defines if esmodules outputs should be generated.
|
|
16
|
+
esmodules: false,
|
|
17
|
+
// Optional. Defaults to false. Defines if esnext outputs should be generated.
|
|
18
|
+
esnext: false,
|
|
19
|
+
// Optional. Defaults to true. Defines if entrypoints should be written at
|
|
20
|
+
// the root of the repository. You can disable this if you have a single
|
|
21
|
+
// entrypoint or if your package uses the `exports` key in package.json
|
|
22
|
+
rootEntrypoints: false,
|
|
23
|
+
// Optional. Defaults to 'node'. Defines if the jest environment should be 'node' or 'jsdom'.
|
|
24
|
+
jestTestEnvironment: 'node',
|
|
25
|
+
}),
|
|
26
|
+
jestConfigPlugin(),
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function jestConfigPlugin() {
|
|
31
|
+
return createProjectPlugin(
|
|
32
|
+
'sessionStorageJestAdjustments',
|
|
33
|
+
({tasks: {test}}) => {
|
|
34
|
+
test.hook(({hooks}) => {
|
|
35
|
+
hooks.configure.hook((configure) => {
|
|
36
|
+
// If no tests, pass the suite
|
|
37
|
+
configure.jestConfig?.hook((config) => ({
|
|
38
|
+
...config,
|
|
39
|
+
passWithNoTests: true,
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shopify/shopify-app-session-storage",
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"description": "Shopify App Session Storage - abstract class",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Shopify/shopify-app-js.git"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/Shopify/shopify-app-js/issues"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Shopify/shopify-app-js/tree/main/packages/shopify-app-session-storage",
|
|
13
|
+
"author": "Shopify Inc.",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "./build/cjs/index.js",
|
|
16
|
+
"types": "./build/ts/index.d.ts",
|
|
17
|
+
"scripts": {},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"@shopify:registry": "https://registry.npmjs.org"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"shopify",
|
|
24
|
+
"node",
|
|
25
|
+
"app",
|
|
26
|
+
"graphql",
|
|
27
|
+
"rest",
|
|
28
|
+
"webhook",
|
|
29
|
+
"Admin API",
|
|
30
|
+
"Storefront API",
|
|
31
|
+
"session storage"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@shopify/shopify-api": "^9.3.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {},
|
|
38
|
+
"files": [
|
|
39
|
+
"build/*",
|
|
40
|
+
"!bundle/*",
|
|
41
|
+
"!tsconfig.tsbuildinfo",
|
|
42
|
+
"!node_modules"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MigrationOperation,
|
|
3
|
+
SessionStorageMigrator,
|
|
4
|
+
SessionStorageMigratorOptions,
|
|
5
|
+
defaultSessionStorageMigratorOptions,
|
|
6
|
+
DBConnection,
|
|
7
|
+
} from './types';
|
|
8
|
+
|
|
9
|
+
export abstract class AbstractMigrationEngine<
|
|
10
|
+
ConnectionType extends DBConnection,
|
|
11
|
+
MigratorOptionType extends SessionStorageMigratorOptions,
|
|
12
|
+
> implements SessionStorageMigrator
|
|
13
|
+
{
|
|
14
|
+
protected options: SessionStorageMigratorOptions;
|
|
15
|
+
protected connection: ConnectionType;
|
|
16
|
+
protected ready: Promise<void>;
|
|
17
|
+
protected migrations: MigrationOperation[];
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
db: ConnectionType,
|
|
21
|
+
opts: Partial<MigratorOptionType> = {},
|
|
22
|
+
migrations: MigrationOperation[],
|
|
23
|
+
) {
|
|
24
|
+
this.options = {...defaultSessionStorageMigratorOptions, ...opts};
|
|
25
|
+
this.connection = db;
|
|
26
|
+
this.migrations = migrations;
|
|
27
|
+
|
|
28
|
+
this.ready = this.initMigrationPersistence();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async applyMigrations(databaseReady: Promise<void>): Promise<void> {
|
|
32
|
+
await databaseReady;
|
|
33
|
+
await this.ready;
|
|
34
|
+
|
|
35
|
+
for (const {migrationName, migrationFunction} of this.getMigrationList()) {
|
|
36
|
+
const migrationApplied =
|
|
37
|
+
await this.hasMigrationBeenApplied(migrationName);
|
|
38
|
+
if (!migrationApplied) {
|
|
39
|
+
await migrationFunction(this.connection);
|
|
40
|
+
await this.saveAppliedMigration(migrationName);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getMigrationList(): MigrationOperation[] {
|
|
47
|
+
return this.migrations;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
abstract initMigrationPersistence(): Promise<void>;
|
|
51
|
+
abstract hasMigrationBeenApplied(migrationName: string): Promise<boolean>;
|
|
52
|
+
abstract saveAppliedMigration(migrationName: string): Promise<void>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {AbstractMigrationEngine} from './abstract-migration-engine';
|
|
2
|
+
import {
|
|
3
|
+
RdbmsSessionStorageMigratorOptions,
|
|
4
|
+
defaultRdbmsSessionStorageMigratorOptions,
|
|
5
|
+
RdbmsConnection,
|
|
6
|
+
MigrationOperation,
|
|
7
|
+
} from './types';
|
|
8
|
+
|
|
9
|
+
export abstract class RdbmsSessionStorageMigrator extends AbstractMigrationEngine<
|
|
10
|
+
RdbmsConnection,
|
|
11
|
+
RdbmsSessionStorageMigratorOptions
|
|
12
|
+
> {
|
|
13
|
+
constructor(
|
|
14
|
+
dbConnection: RdbmsConnection,
|
|
15
|
+
opts: Partial<RdbmsSessionStorageMigratorOptions> = {},
|
|
16
|
+
migrations: MigrationOperation[],
|
|
17
|
+
) {
|
|
18
|
+
super(
|
|
19
|
+
dbConnection,
|
|
20
|
+
{
|
|
21
|
+
...defaultRdbmsSessionStorageMigratorOptions,
|
|
22
|
+
...opts,
|
|
23
|
+
},
|
|
24
|
+
migrations,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async hasMigrationBeenApplied(migrationName: string): Promise<boolean> {
|
|
29
|
+
await this.ready;
|
|
30
|
+
|
|
31
|
+
const query = `
|
|
32
|
+
SELECT * FROM ${this.options.migrationDBIdentifier}
|
|
33
|
+
WHERE ${this.getOptions().migrationNameColumnName} =
|
|
34
|
+
${this.connection.getArgumentPlaceholder(1)};
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const rows = await this.connection.query(query, [migrationName]);
|
|
38
|
+
return rows.length === 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async saveAppliedMigration(migrationName: string): Promise<void> {
|
|
42
|
+
await this.ready;
|
|
43
|
+
|
|
44
|
+
const insert = `
|
|
45
|
+
INSERT INTO ${this.options.migrationDBIdentifier} (${
|
|
46
|
+
this.getOptions().migrationNameColumnName
|
|
47
|
+
})
|
|
48
|
+
VALUES(${this.connection.getArgumentPlaceholder(1)});
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
await this.connection.query(insert, [migrationName]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public getOptions(): RdbmsSessionStorageMigratorOptions {
|
|
55
|
+
return this.options as RdbmsSessionStorageMigratorOptions;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
abstract initMigrationPersistence(): Promise<void>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {Session} from '@shopify/shopify-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defines the strategy to be used to store sessions for the Shopify App.
|
|
5
|
+
*/
|
|
6
|
+
export interface SessionStorage {
|
|
7
|
+
/**
|
|
8
|
+
* Creates or updates the given session in storage.
|
|
9
|
+
*
|
|
10
|
+
* @param session Session to store
|
|
11
|
+
*/
|
|
12
|
+
storeSession(session: Session): Promise<boolean>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Loads a session from storage.
|
|
16
|
+
*
|
|
17
|
+
* @param id Id of the session to load
|
|
18
|
+
*/
|
|
19
|
+
loadSession(id: string): Promise<Session | undefined>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Deletes a session from storage.
|
|
23
|
+
*
|
|
24
|
+
* @param id Id of the session to delete
|
|
25
|
+
*/
|
|
26
|
+
deleteSession(id: string): Promise<boolean>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Deletes an array of sessions from storage.
|
|
30
|
+
*
|
|
31
|
+
* @param ids Array of session id's to delete
|
|
32
|
+
*/
|
|
33
|
+
deleteSessions(ids: string[]): Promise<boolean>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Return an array of sessions for a given shop (or [] if none found).
|
|
37
|
+
*
|
|
38
|
+
* @param shop shop of the session(s) to return
|
|
39
|
+
*/
|
|
40
|
+
findSessionsByShop(shop: string): Promise<Session[]>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* define the option required to instantiate an RDBMS session storage implementation
|
|
45
|
+
*/
|
|
46
|
+
export interface RdbmsSessionStorageOptions {
|
|
47
|
+
sessionTableName: string;
|
|
48
|
+
migratorOptions?: RdbmsSessionStorageMigratorOptions;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Define a common way for migrator to execute query on the underlying persistence layer
|
|
53
|
+
*/
|
|
54
|
+
export interface DBConnection {
|
|
55
|
+
/** the table used to store sessions */
|
|
56
|
+
sessionStorageIdentifier: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Initiate the actual connection to the underlying database
|
|
60
|
+
*/
|
|
61
|
+
connect(): Promise<void>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Disconnect from the underlying database
|
|
65
|
+
*/
|
|
66
|
+
disconnect(): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* This is for the use cases of the RDBMS database where
|
|
71
|
+
*/
|
|
72
|
+
export interface RdbmsConnection extends DBConnection {
|
|
73
|
+
/**
|
|
74
|
+
* Make a query to the underlying DB
|
|
75
|
+
* @param query - the query to execute
|
|
76
|
+
* @param params - the parameters required by the query
|
|
77
|
+
*/
|
|
78
|
+
query(query: string, params: any[]): Promise<any[]>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Determine if a table exist
|
|
82
|
+
* @param tablename - the table to search
|
|
83
|
+
*/
|
|
84
|
+
hasTable(tablename: string): Promise<boolean>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Based on the the #sqlArgumentPlaceholder value and the underlying engine, return the place holder for a given position in a list of sql argument
|
|
88
|
+
* @param position the position of the given sql argument
|
|
89
|
+
*/
|
|
90
|
+
getArgumentPlaceholder(position?: number): string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Each migration 'migration_name' will be define the following way.
|
|
95
|
+
* Via a function that receive the engine in parameter.
|
|
96
|
+
*/
|
|
97
|
+
export type MigrationFunction = (engine: DBConnection) => Promise<void>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Defines what is needed for a migration to be execute
|
|
101
|
+
*/
|
|
102
|
+
export class MigrationOperation {
|
|
103
|
+
/** Name of the migration that will be used to uniquely identity it among all other migration */
|
|
104
|
+
migrationName: string;
|
|
105
|
+
|
|
106
|
+
/** The actual migration function that will modify the perisitence storage */
|
|
107
|
+
migrationFunction: MigrationFunction;
|
|
108
|
+
|
|
109
|
+
constructor(migrationName: string, migrationFunction: MigrationFunction) {
|
|
110
|
+
this.migrationName = migrationName;
|
|
111
|
+
this.migrationFunction = migrationFunction;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Defines how database migration will be handled.
|
|
117
|
+
*/
|
|
118
|
+
export interface SessionStorageMigrator {
|
|
119
|
+
/**
|
|
120
|
+
* Should ensure that the persistence 'table' is created if it does not exist yet.
|
|
121
|
+
*/
|
|
122
|
+
initMigrationPersistence(): Promise<void>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns true if the migrationName as already been applied and
|
|
126
|
+
* therefore the migrator should not apply it. if false,
|
|
127
|
+
* the migrator will run the associated migration
|
|
128
|
+
* @param migrationName the unique version name to look for in the migration table
|
|
129
|
+
*/
|
|
130
|
+
hasMigrationBeenApplied(migrationName: string): Promise<boolean>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Will persist that this migrationName has been applied in the migration table
|
|
134
|
+
* @param migrationName the version to persisited as applied
|
|
135
|
+
*/
|
|
136
|
+
saveAppliedMigration(migrationName: string): Promise<void>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Return a list MigrationOperation that needs to be executed
|
|
140
|
+
*/
|
|
141
|
+
getMigrationList(): MigrationOperation[];
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Will iterate over the map returned by #getmigrationList,
|
|
145
|
+
* for each entry call #hasMigrationBeenApplied, if it returns false
|
|
146
|
+
* it will execute execute the function and then call #saveAppliedMigration
|
|
147
|
+
* @param databaseReady - so that the migrator can wait for the database to fully up and running
|
|
148
|
+
* before starting its execution.
|
|
149
|
+
*/
|
|
150
|
+
applyMigrations(databaseReady: Promise<void>): Promise<void>;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Use to initialise session storage migrators
|
|
155
|
+
*/
|
|
156
|
+
export interface SessionStorageMigratorOptions {
|
|
157
|
+
migrationDBIdentifier: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export const defaultSessionStorageMigratorOptions: SessionStorageMigratorOptions =
|
|
161
|
+
{
|
|
162
|
+
migrationDBIdentifier: 'shopify_sessions_migrations',
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export interface RdbmsSessionStorageMigratorOptions
|
|
166
|
+
extends SessionStorageMigratorOptions {
|
|
167
|
+
migrationNameColumnName: string;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export const defaultRdbmsSessionStorageMigratorOptions: RdbmsSessionStorageMigratorOptions =
|
|
171
|
+
{
|
|
172
|
+
migrationDBIdentifier: 'shopify_sessions_migrations',
|
|
173
|
+
migrationNameColumnName: 'migration_name',
|
|
174
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# @shopify/shopify-app-session-storage-dynamodb
|
|
2
|
+
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 02a8341: Updated dependency on `@shopify/shopify-api` to 9.3.1
|
|
8
|
+
- 321d6a4: Update @shopify/shopify-api to 9.3.2
|
|
9
|
+
- Updated dependencies [02a8341]
|
|
10
|
+
- Updated dependencies [321d6a4]
|
|
11
|
+
- @shopify/shopify-app-session-storage@2.1.1
|
|
12
|
+
|
|
13
|
+
## 3.0.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 64e0246: Update shopify-api version to 9.2.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 2b54692: Update @aws-sdk/client-dynamodb from 3.470.0 to 3.504.0.
|
|
22
|
+
- e2a8fd8: Updated the `@aws-sdk/util-dynamodb` dependency to v3.499.0
|
|
23
|
+
- f5742c1: Updated dependency on `@shopify/shopify-api`
|
|
24
|
+
- Updated dependencies [f5742c1]
|
|
25
|
+
- Updated dependencies [64e0246]
|
|
26
|
+
- @shopify/shopify-app-session-storage@2.1.0
|
|
27
|
+
|
|
28
|
+
## 2.0.4
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- b4eeb24: Improved and simplified package.json dependencies
|
|
33
|
+
- b998c30: Bump shopify-api version from 9.0.1 to 9.0.2
|
|
34
|
+
- Updated dependencies [b4eeb24]
|
|
35
|
+
- Updated dependencies [b998c30]
|
|
36
|
+
- @shopify/shopify-app-session-storage@2.0.4
|
|
37
|
+
|
|
38
|
+
## 2.0.3
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- d3e4b5e: Updated the dependency on `@shopify/shopify-api`
|
|
43
|
+
- Updated dependencies [d3e4b5e]
|
|
44
|
+
- @shopify/shopify-app-session-storage@2.0.3
|
|
45
|
+
|
|
46
|
+
## 2.0.2
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- 3685bd4: Bump shopify-api to ^8.1.1
|
|
51
|
+
- Updated dependencies [3685bd4]
|
|
52
|
+
- @shopify/shopify-app-session-storage@2.0.2
|
|
53
|
+
|
|
54
|
+
## 2.0.1
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- 6d12840: Updating dependencies on @shopify/shopify-api
|
|
59
|
+
- Updated dependencies [6d12840]
|
|
60
|
+
- @shopify/shopify-app-session-storage@2.0.1
|
|
61
|
+
|
|
62
|
+
## 2.0.0
|
|
63
|
+
|
|
64
|
+
### Major Changes
|
|
65
|
+
|
|
66
|
+
- f837060: **Removed support for Node 14**
|
|
67
|
+
|
|
68
|
+
Node 14 has reached its [EOL](https://endoflife.date/nodejs), and dependencies to this package no longer work on Node 14.
|
|
69
|
+
Because of that, we can no longer support that version.
|
|
70
|
+
|
|
71
|
+
If your app is running on Node 14, you'll need to update to a more recent version before upgrading this package.
|
|
72
|
+
|
|
73
|
+
This upgrade does not require any code changes.
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- a69d6fc: Updating dependency on @shopify/shopify-api to v.8.0.1
|
|
78
|
+
- Updated dependencies [f837060]
|
|
79
|
+
- Updated dependencies [a69d6fc]
|
|
80
|
+
- @shopify/shopify-app-session-storage@2.0.0
|
|
81
|
+
|
|
82
|
+
## 1.0.8
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- 616388d: Updating dependency on @shopify/shopify-api to 7.7.0
|
|
87
|
+
- Updated dependencies [616388d]
|
|
88
|
+
- @shopify/shopify-app-session-storage@1.1.10
|
|
89
|
+
|
|
90
|
+
## 1.0.7
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- 5b862fe: Upgraded shopify-api dependency to 7.6.0
|
|
95
|
+
- Updated dependencies [5b862fe]
|
|
96
|
+
- @shopify/shopify-app-session-storage@1.1.9
|
|
97
|
+
|
|
98
|
+
## 1.0.6
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- 346b623: Updating dependency on @shopify/shopify-api
|
|
103
|
+
- Updated dependencies [346b623]
|
|
104
|
+
- @shopify/shopify-app-session-storage@1.1.8
|
|
105
|
+
|
|
106
|
+
## 1.0.5
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- 13b9048: Updating @shopify/shopify-api dependency to the latest version
|
|
111
|
+
- Updated dependencies [13b9048]
|
|
112
|
+
- @shopify/shopify-app-session-storage@1.1.7
|
|
113
|
+
|
|
114
|
+
## 1.0.4
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- 32296d7: Update @shopify/shopify-api dependency to 7.5.0
|
|
119
|
+
- Updated dependencies [32296d7]
|
|
120
|
+
- @shopify/shopify-app-session-storage@1.1.6
|
|
121
|
+
|
|
122
|
+
## 1.0.3
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- 93e9126: Updating @shopify/shopify-api dependency
|
|
127
|
+
- Updated dependencies [93e9126]
|
|
128
|
+
- @shopify/shopify-app-session-storage@1.1.5
|
|
129
|
+
|
|
130
|
+
## 1.0.2
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- b3453ff: Bumping @shopify/shopify-api dependency to latest version
|
|
135
|
+
- Updated dependencies [b3453ff]
|
|
136
|
+
- @shopify/shopify-app-session-storage@1.1.4
|
|
137
|
+
|
|
138
|
+
## 1.0.1
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- 1d260ea: Bumps [@aws-sdk/util-dynamodb](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages/util-dynamodb) from 3.294.0 to 3.332.0.
|
|
143
|
+
- 5e6cf36: Bumps [@aws-sdk/client-dynamodb](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-dynamodb) from 3.294.0 to 3.332.0.
|
|
144
|
+
- See `@aws-sdk`'s [release notes](https://github.com/aws/aws-sdk-js-v3/releases) for more details.
|
|
145
|
+
|
|
146
|
+
## 1.0.0
|
|
147
|
+
|
|
148
|
+
### Major Changes
|
|
149
|
+
|
|
150
|
+
- 3d92b70: Implementation of @shopify/shopify-app-session-storage-dynamodb for AWS DynamoDB
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present, Shopify Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Session Storage Adapter for AWS DynamoDB
|
|
2
|
+
|
|
3
|
+
This package implements the `SessionStorage` interface that works with an AWS DynamoDB database.
|
|
4
|
+
|
|
5
|
+
Contributed by [Chris](https://github.com/zirkelc) - thank you :clap:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import {shopifyApp} from '@shopify/shopify-app-express';
|
|
9
|
+
import {DynamoDBSessionStorage} from '@shopify/shopify-app-session-storage-dynamodb';
|
|
10
|
+
|
|
11
|
+
// You can use the default options
|
|
12
|
+
const storage = new DynamoDBSessionStorage();
|
|
13
|
+
|
|
14
|
+
// or, if you want to use a different session table name and shop index name
|
|
15
|
+
const storage = new DynamoDBSessionStorage({ sessionTableName: 'my-session-table', shopIndexName: 'my-shop-index' });
|
|
16
|
+
|
|
17
|
+
// or, if you want to use a different region or credentials
|
|
18
|
+
const storage = new DynamoDBSessionStorage({ config: { region: 'us-west-2', credentials: { ... } } });
|
|
19
|
+
|
|
20
|
+
const shopify = shopifyApp({
|
|
21
|
+
sessionStorage: storage,
|
|
22
|
+
// ...
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Table Schema
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
{
|
|
30
|
+
TableName: sessionTableName,
|
|
31
|
+
AttributeDefinitions: [
|
|
32
|
+
{AttributeName: 'id', AttributeType: 'S'},
|
|
33
|
+
{AttributeName: 'shop', AttributeType: 'S'},
|
|
34
|
+
],
|
|
35
|
+
KeySchema: [{AttributeName: 'id', KeyType: 'HASH'}],
|
|
36
|
+
GlobalSecondaryIndexes: [
|
|
37
|
+
{
|
|
38
|
+
IndexName: shopIndexName,
|
|
39
|
+
KeySchema: [{AttributeName: 'shop', KeyType: 'HASH'}],
|
|
40
|
+
Projection: {ProjectionType: 'KEYS_ONLY'},
|
|
41
|
+
ProvisionedThroughput: {
|
|
42
|
+
ReadCapacityUnits: 1,
|
|
43
|
+
WriteCapacityUnits: 1,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1},
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### AWS Policy for DynamoDB
|
|
52
|
+
|
|
53
|
+
This policy must be attached to a user -- `dynamodb:Query` does not work with inline policies.
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"Version": "2012-10-17",
|
|
58
|
+
"Statement": [
|
|
59
|
+
{
|
|
60
|
+
"Sid": "Statement1",
|
|
61
|
+
"Effect": "Allow",
|
|
62
|
+
"Action": [
|
|
63
|
+
"dynamodb:GetItem",
|
|
64
|
+
"dynamodb:DeleteItem",
|
|
65
|
+
"dynamodb:PutItem",
|
|
66
|
+
"dynamodb:Query",
|
|
67
|
+
"dynamodb:DescribeTable"
|
|
68
|
+
],
|
|
69
|
+
"Resource": ["arn:aws:dynamodb:<region>:<account-id>:table/<table-name>"]
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If you prefer to use your own implementation of a session storage mechanism that uses the `SessionStorage` interface, see the [implementing session storage guide](https://github.com/Shopify/shopify-app-js/blob/main/packages/shopify-app-session-storage/implementing-session-storage.md).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {createPackage} from '@shopify/loom';
|
|
2
|
+
import {buildLibrary} from '@shopify/loom-plugin-build-library';
|
|
3
|
+
|
|
4
|
+
export default createPackage((pkg) => {
|
|
5
|
+
pkg.entry({root: './src/dynamodb.ts'});
|
|
6
|
+
pkg.use(
|
|
7
|
+
buildLibrary({
|
|
8
|
+
// Required. A browserslist string for specifying your target output.
|
|
9
|
+
// Use browser targets (e.g. `'defaults'`) if your package targets the browser,
|
|
10
|
+
// node targets (e.g. `'node 12.22'`) if your package targets node
|
|
11
|
+
// or both (e.g.`'defaults, node 12.22'`) if your package targets both
|
|
12
|
+
targets: 'node 16',
|
|
13
|
+
// Optional. Defaults to false. Defines if commonjs outputs should be generated.
|
|
14
|
+
commonjs: true,
|
|
15
|
+
// Optional. Defaults to false. Defines if esmodules outputs should be generated.
|
|
16
|
+
esmodules: false,
|
|
17
|
+
// Optional. Defaults to false. Defines if esnext outputs should be generated.
|
|
18
|
+
esnext: false,
|
|
19
|
+
// Optional. Defaults to true. Defines if entrypoints should be written at
|
|
20
|
+
// the root of the repository. You can disable this if you have a single
|
|
21
|
+
// entrypoint or if your package uses the `exports` key in package.json
|
|
22
|
+
rootEntrypoints: false,
|
|
23
|
+
// Optional. Defaults to 'node'. Defines if the jest environment should be 'node' or 'jsdom'.
|
|
24
|
+
jestTestEnvironment: 'node',
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
});
|