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,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shopify/shopify-app-session-storage-dynamodb",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "Shopify App Session Storage for DynamoDB",
|
|
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-dynamodb",
|
|
13
|
+
"author": "Shopify Inc.",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "./build/cjs/dynamodb.js",
|
|
16
|
+
"types": "./build/ts/dynamodb.d.ts",
|
|
17
|
+
"scripts": {},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"shopify",
|
|
23
|
+
"node",
|
|
24
|
+
"app",
|
|
25
|
+
"graphql",
|
|
26
|
+
"rest",
|
|
27
|
+
"webhook",
|
|
28
|
+
"Admin API",
|
|
29
|
+
"Storefront API",
|
|
30
|
+
"session storage",
|
|
31
|
+
"DynamoDB",
|
|
32
|
+
"AWS"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@aws-sdk/client-dynamodb": "^3.504.0",
|
|
36
|
+
"@aws-sdk/util-dynamodb": "^3.499.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@shopify/shopify-api": "^9.3.2",
|
|
40
|
+
"@shopify/shopify-app-session-storage": "^2.1.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@shopify/shopify-app-session-storage-test-utils": "^2.0.1"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"build/*",
|
|
47
|
+
"!bundle/*",
|
|
48
|
+
"!tsconfig.tsbuildinfo",
|
|
49
|
+
"!node_modules"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as child_process from 'child_process';
|
|
2
|
+
import {promisify} from 'util';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
CreateTableCommand,
|
|
6
|
+
DynamoDBClient,
|
|
7
|
+
waitUntilTableExists,
|
|
8
|
+
} from '@aws-sdk/client-dynamodb';
|
|
9
|
+
import {
|
|
10
|
+
batteryOfTests,
|
|
11
|
+
poll,
|
|
12
|
+
} from '@shopify/shopify-app-session-storage-test-utils';
|
|
13
|
+
|
|
14
|
+
import {DynamoDBSessionStorage} from '../dynamodb';
|
|
15
|
+
|
|
16
|
+
const exec = promisify(child_process.exec);
|
|
17
|
+
|
|
18
|
+
describe('DynamoDBSessionStorage', () => {
|
|
19
|
+
const sessionTableName = 'sessionTable';
|
|
20
|
+
const shopIndexName = 'shopIndex';
|
|
21
|
+
let storage: DynamoDBSessionStorage;
|
|
22
|
+
|
|
23
|
+
let containerId: string;
|
|
24
|
+
beforeAll(async () => {
|
|
25
|
+
const dynamoDBClientConfig = {
|
|
26
|
+
endpoint: 'http://localhost:8000',
|
|
27
|
+
region: 'us-west-2',
|
|
28
|
+
credentials: {
|
|
29
|
+
accessKeyId: 'shopify',
|
|
30
|
+
secretAccessKey: 'passify',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const runCommand = await exec(
|
|
34
|
+
'podman run -d -e AWS_ACCESS_KEY_ID=shopify -e AWS_SECRET_ACCESS_KEY=passify -p 8000:8000 amazon/dynamodb-local',
|
|
35
|
+
{encoding: 'utf8'},
|
|
36
|
+
);
|
|
37
|
+
containerId = runCommand.stdout.trim();
|
|
38
|
+
|
|
39
|
+
await poll(
|
|
40
|
+
async () => {
|
|
41
|
+
try {
|
|
42
|
+
const client = new DynamoDBClient(dynamoDBClientConfig);
|
|
43
|
+
await client.send(
|
|
44
|
+
new CreateTableCommand({
|
|
45
|
+
TableName: sessionTableName,
|
|
46
|
+
AttributeDefinitions: [
|
|
47
|
+
{AttributeName: 'id', AttributeType: 'S'},
|
|
48
|
+
{AttributeName: 'shop', AttributeType: 'S'},
|
|
49
|
+
],
|
|
50
|
+
KeySchema: [{AttributeName: 'id', KeyType: 'HASH'}],
|
|
51
|
+
GlobalSecondaryIndexes: [
|
|
52
|
+
{
|
|
53
|
+
IndexName: shopIndexName,
|
|
54
|
+
KeySchema: [{AttributeName: 'shop', KeyType: 'HASH'}],
|
|
55
|
+
Projection: {ProjectionType: 'KEYS_ONLY'},
|
|
56
|
+
ProvisionedThroughput: {
|
|
57
|
+
ReadCapacityUnits: 1,
|
|
58
|
+
WriteCapacityUnits: 1,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
ProvisionedThroughput: {
|
|
63
|
+
ReadCapacityUnits: 1,
|
|
64
|
+
WriteCapacityUnits: 1,
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
await waitUntilTableExists(
|
|
69
|
+
{client, maxWaitTime: 120},
|
|
70
|
+
{TableName: sessionTableName},
|
|
71
|
+
);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
// console.error(error); // uncomment to see error for debugging tests
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
78
|
+
{interval: 500, timeout: 20000},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
storage = new DynamoDBSessionStorage({
|
|
82
|
+
sessionTableName,
|
|
83
|
+
shopIndexName,
|
|
84
|
+
config: dynamoDBClientConfig,
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
afterAll(async () => {
|
|
89
|
+
await exec(`podman rm -f ${containerId}`);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
batteryOfTests(async () => storage);
|
|
93
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AttributeValue,
|
|
3
|
+
DeleteItemCommand,
|
|
4
|
+
DynamoDBClient,
|
|
5
|
+
DynamoDBClientConfig,
|
|
6
|
+
GetItemCommand,
|
|
7
|
+
PutItemCommand,
|
|
8
|
+
QueryCommand,
|
|
9
|
+
} from '@aws-sdk/client-dynamodb';
|
|
10
|
+
import {marshall, unmarshall} from '@aws-sdk/util-dynamodb';
|
|
11
|
+
import {Session, SessionParams} from '@shopify/shopify-api';
|
|
12
|
+
import {SessionStorage} from '@shopify/shopify-app-session-storage';
|
|
13
|
+
|
|
14
|
+
export interface DynamoDBSessionStorageOptions {
|
|
15
|
+
sessionTableName: string;
|
|
16
|
+
shopIndexName: string;
|
|
17
|
+
config?: DynamoDBClientConfig;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const defaultDynamoDBSessionStorageOptions: DynamoDBSessionStorageOptions = {
|
|
21
|
+
sessionTableName: 'shopify_sessions',
|
|
22
|
+
shopIndexName: 'shop_index',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export class DynamoDBSessionStorage implements SessionStorage {
|
|
26
|
+
private client: DynamoDBClient;
|
|
27
|
+
private options: DynamoDBSessionStorageOptions;
|
|
28
|
+
|
|
29
|
+
constructor(opts?: DynamoDBSessionStorageOptions) {
|
|
30
|
+
this.options = {...defaultDynamoDBSessionStorageOptions, ...opts};
|
|
31
|
+
this.client = new DynamoDBClient({...this.options.config});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public async storeSession(session: Session): Promise<boolean> {
|
|
35
|
+
await this.client.send(
|
|
36
|
+
new PutItemCommand({
|
|
37
|
+
TableName: this.options.sessionTableName,
|
|
38
|
+
Item: this.serializeSession(session),
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async loadSession(id: string): Promise<Session | undefined> {
|
|
46
|
+
if (!id) return undefined;
|
|
47
|
+
|
|
48
|
+
const result = await this.client.send(
|
|
49
|
+
new GetItemCommand({
|
|
50
|
+
TableName: this.options.sessionTableName,
|
|
51
|
+
Key: this.serializeId(id),
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return result.Item ? this.deserializeSession(result.Item) : undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public async deleteSession(id: string): Promise<boolean> {
|
|
59
|
+
await this.client.send(
|
|
60
|
+
new DeleteItemCommand({
|
|
61
|
+
TableName: this.options.sessionTableName,
|
|
62
|
+
Key: this.serializeId(id),
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public async deleteSessions(ids: string[]): Promise<boolean> {
|
|
70
|
+
await Promise.all(ids.map((id) => this.deleteSession(id)));
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public async findSessionsByShop(shop: string): Promise<Session[]> {
|
|
75
|
+
const result = await this.client.send(
|
|
76
|
+
new QueryCommand({
|
|
77
|
+
TableName: this.options.sessionTableName,
|
|
78
|
+
IndexName: this.options.shopIndexName,
|
|
79
|
+
KeyConditionExpression: 'shop = :shop',
|
|
80
|
+
ExpressionAttributeValues: marshall({
|
|
81
|
+
':shop': shop,
|
|
82
|
+
}),
|
|
83
|
+
ProjectionExpression: 'id, shop',
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const sessions = await Promise.all(
|
|
88
|
+
result.Items?.map((item) => this.loadSession(this.deserializeId(item))) ||
|
|
89
|
+
[],
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return sessions.filter(
|
|
93
|
+
(session): session is Session => session !== undefined,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private serializeId(id: string): Record<string, AttributeValue> {
|
|
98
|
+
return marshall({id});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private deserializeId(id: Record<string, AttributeValue>): string {
|
|
102
|
+
return unmarshall(id).id;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private serializeSession(session: Session): Record<string, AttributeValue> {
|
|
106
|
+
// DynamoDB doesn't support Date objects, so we need to convert it to an ISO string
|
|
107
|
+
const rawSession = {
|
|
108
|
+
...session.toObject(),
|
|
109
|
+
expires: session.expires?.toISOString(),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return marshall(rawSession, {
|
|
113
|
+
removeUndefinedValues: true,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private deserializeSession(session: Record<string, AttributeValue>): Session {
|
|
118
|
+
const rawSession = unmarshall(session) as SessionParams;
|
|
119
|
+
|
|
120
|
+
// Convert the ISO string back to a Date object
|
|
121
|
+
return new Session({
|
|
122
|
+
...rawSession,
|
|
123
|
+
expires: rawSession.expires ? new Date(rawSession.expires) : undefined,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# @shopify/shopify-app-session-storage-kv
|
|
2
|
+
|
|
3
|
+
## 3.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6deb1bd: Updated dependency on `semver`
|
|
8
|
+
|
|
9
|
+
## 3.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 02a8341: Updated dependency on `@shopify/shopify-api` to 9.3.1
|
|
14
|
+
- 321d6a4: Update @shopify/shopify-api to 9.3.2
|
|
15
|
+
- Updated dependencies [02a8341]
|
|
16
|
+
- Updated dependencies [321d6a4]
|
|
17
|
+
- @shopify/shopify-app-session-storage@2.1.1
|
|
18
|
+
|
|
19
|
+
## 3.0.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- 64e0246: Update shopify-api version to 9.2.0
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- f5742c1: Updated dependency on `@shopify/shopify-api`
|
|
28
|
+
- Updated dependencies [f5742c1]
|
|
29
|
+
- Updated dependencies [64e0246]
|
|
30
|
+
- @shopify/shopify-app-session-storage@2.1.0
|
|
31
|
+
|
|
32
|
+
## 2.0.4
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- b4eeb24: Improved and simplified package.json dependencies
|
|
37
|
+
- b998c30: Bump shopify-api version from 9.0.1 to 9.0.2
|
|
38
|
+
- Updated dependencies [b4eeb24]
|
|
39
|
+
- Updated dependencies [b998c30]
|
|
40
|
+
- @shopify/shopify-app-session-storage@2.0.4
|
|
41
|
+
|
|
42
|
+
## 2.0.3
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- d3e4b5e: Updated the dependency on `@shopify/shopify-api`
|
|
47
|
+
- Updated dependencies [d3e4b5e]
|
|
48
|
+
- @shopify/shopify-app-session-storage@2.0.3
|
|
49
|
+
|
|
50
|
+
## 2.0.2
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 3685bd4: Bump shopify-api to ^8.1.1
|
|
55
|
+
- Updated dependencies [3685bd4]
|
|
56
|
+
- @shopify/shopify-app-session-storage@2.0.2
|
|
57
|
+
|
|
58
|
+
## 2.0.1
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- 6d12840: Updating dependencies on @shopify/shopify-api
|
|
63
|
+
- Updated dependencies [6d12840]
|
|
64
|
+
- @shopify/shopify-app-session-storage@2.0.1
|
|
65
|
+
|
|
66
|
+
## 2.0.0
|
|
67
|
+
|
|
68
|
+
### Major Changes
|
|
69
|
+
|
|
70
|
+
- f837060: **Removed support for Node 14**
|
|
71
|
+
|
|
72
|
+
Node 14 has reached its [EOL](https://endoflife.date/nodejs), and dependencies to this package no longer work on Node 14.
|
|
73
|
+
Because of that, we can no longer support that version.
|
|
74
|
+
|
|
75
|
+
If your app is running on Node 14, you'll need to update to a more recent version before upgrading this package.
|
|
76
|
+
|
|
77
|
+
This upgrade does not require any code changes.
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- a69d6fc: Updating dependency on @shopify/shopify-api to v.8.0.1
|
|
82
|
+
- Updated dependencies [f837060]
|
|
83
|
+
- Updated dependencies [a69d6fc]
|
|
84
|
+
- @shopify/shopify-app-session-storage@2.0.0
|
|
85
|
+
|
|
86
|
+
## 1.0.14
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- 616388d: Updating dependency on @shopify/shopify-api to 7.7.0
|
|
91
|
+
- Updated dependencies [616388d]
|
|
92
|
+
- @shopify/shopify-app-session-storage@1.1.10
|
|
93
|
+
|
|
94
|
+
## 1.0.13
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- 5b862fe: Upgraded shopify-api dependency to 7.6.0
|
|
99
|
+
- Updated dependencies [5b862fe]
|
|
100
|
+
- @shopify/shopify-app-session-storage@1.1.9
|
|
101
|
+
|
|
102
|
+
## 1.0.12
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- 346b623: Updating dependency on @shopify/shopify-api
|
|
107
|
+
- Updated dependencies [346b623]
|
|
108
|
+
- @shopify/shopify-app-session-storage@1.1.8
|
|
109
|
+
|
|
110
|
+
## 1.0.11
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- 13b9048: Updating @shopify/shopify-api dependency to the latest version
|
|
115
|
+
- Updated dependencies [13b9048]
|
|
116
|
+
- @shopify/shopify-app-session-storage@1.1.7
|
|
117
|
+
|
|
118
|
+
## 1.0.10
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- 32296d7: Update @shopify/shopify-api dependency to 7.5.0
|
|
123
|
+
- Updated dependencies [32296d7]
|
|
124
|
+
- @shopify/shopify-app-session-storage@1.1.6
|
|
125
|
+
|
|
126
|
+
## 1.0.9
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- 93e9126: Updating @shopify/shopify-api dependency
|
|
131
|
+
- Updated dependencies [93e9126]
|
|
132
|
+
- @shopify/shopify-app-session-storage@1.1.5
|
|
133
|
+
|
|
134
|
+
## 1.0.8
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- b3453ff: Bumping @shopify/shopify-api dependency to latest version
|
|
139
|
+
- Updated dependencies [b3453ff]
|
|
140
|
+
- @shopify/shopify-app-session-storage@1.1.4
|
|
141
|
+
|
|
142
|
+
## 1.0.7
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- 2f10cdd: Bumps [semver](https://github.com/npm/node-semver) from 7.5.0 to 7.5.1. See `semver`'s [release notes](https://github.com/npm/node-semver/releases) for more details.
|
|
147
|
+
|
|
148
|
+
## 1.0.6
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- e1d4f4f: Add @shopify/shopify-api as a peerDependencies entry for each session-storage package, to avoid API library conflicts (e.g., scopesArray.map error). Should help avoid issues like #93
|
|
153
|
+
- f40fede: Bumps [semver](https://github.com/npm/node-semver) from 7.4.0 to 7.5.0. See semver [changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md) for more details.
|
|
154
|
+
- 1d007e8: Bumps [@shopify/shopify-api](https://github.com/Shopify/shopify-api-js) from 7.0.0 to 7.1.0. See `@shopify/shopify-api`'s [changelog](https://github.com/Shopify/shopify-api-js/blob/main/packages/shopify-api/CHANGELOG.md) for more details.
|
|
155
|
+
- Updated dependencies [e1d4f4f]
|
|
156
|
+
- Updated dependencies [1d007e8]
|
|
157
|
+
- @shopify/shopify-app-session-storage@1.1.3
|
|
158
|
+
|
|
159
|
+
## 1.0.5
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- e4f3415: Bump @shopify/shopify-api from 6.2.0 to 7.0.0. See [changelog](https://github.com/Shopify/shopify-api-js/blob/main/packages/shopify-api/CHANGELOG.md) for details.
|
|
164
|
+
- 49cdf3f: Bump semver from 7.3.8 to 7.4.0. See [changelog](https://github.com/npm/node-semver/blob/main/CHANGELOG.md) for details.
|
|
165
|
+
- Updated dependencies [e4f3415]
|
|
166
|
+
- @shopify/shopify-app-session-storage@1.1.2
|
|
167
|
+
|
|
168
|
+
## 1.0.4
|
|
169
|
+
|
|
170
|
+
### Patch Changes
|
|
171
|
+
|
|
172
|
+
- Updated dependencies [97346b3]
|
|
173
|
+
- @shopify/shopify-app-session-storage@1.1.1
|
|
174
|
+
|
|
175
|
+
## 1.0.3
|
|
176
|
+
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- b6501b0: Bump typescript to 4.9.5
|
|
180
|
+
- Updated dependencies [b6501b0]
|
|
181
|
+
- Updated dependencies [becc305]
|
|
182
|
+
- @shopify/shopify-app-session-storage@1.1.0
|
|
183
|
+
|
|
184
|
+
## 1.0.2
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- 222b755: Updating @shopify/shopify-api to v6.1.0
|
|
189
|
+
- Updated dependencies [222b755]
|
|
190
|
+
- @shopify/shopify-app-session-storage@1.0.2
|
|
191
|
+
|
|
192
|
+
## 1.0.1
|
|
193
|
+
|
|
194
|
+
### Patch Changes
|
|
195
|
+
|
|
196
|
+
- 866b50c: Update dependencies on shopify-api v6.0.2
|
|
197
|
+
- Updated dependencies [866b50c]
|
|
198
|
+
- @shopify/shopify-app-session-storage@1.0.1
|
|
199
|
+
|
|
200
|
+
## 1.0.0
|
|
201
|
+
|
|
202
|
+
### Major Changes
|
|
203
|
+
|
|
204
|
+
- 8d27b9d: Initial public release of @shopify/shopify-app-session-storage-kv
|
|
@@ -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,41 @@
|
|
|
1
|
+
# Session Storage Adapter for CloudFlare KV
|
|
2
|
+
|
|
3
|
+
CloudFlare's [KV](https://www.cloudflare.com/products/workers-kv/) storage can be used on worker runtimes.
|
|
4
|
+
Before using it, you'll need to set up a namespace for your sessions and pass in a `KVNamespace` object.
|
|
5
|
+
You can do that either when creating an instance of `KVSessionStorage`, or by calling the `setNamespace` method.
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import {shopifyApp} from '@shopify/shopify-app-express';
|
|
9
|
+
import {KVSessionStorage} from '@shopify/shopify-app-session-storage-kv';
|
|
10
|
+
|
|
11
|
+
const shopify = shopifyApp({
|
|
12
|
+
sessionStorage: new KVSessionStorage(),
|
|
13
|
+
// ...
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
async fetch(
|
|
18
|
+
request: Request,
|
|
19
|
+
env: Env,
|
|
20
|
+
ctx: ExecutionContext,
|
|
21
|
+
): Promise<Response> {
|
|
22
|
+
shopify.config.sessionStorage.setNamespace(env.MY_KV_NAMESPACE);
|
|
23
|
+
// Handle request
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// OR
|
|
28
|
+
|
|
29
|
+
import {Miniflare} from 'miniflare';
|
|
30
|
+
const mf = new Miniflare({
|
|
31
|
+
kvNamespaces: ['MY_KV_NAMESPACE'],
|
|
32
|
+
});
|
|
33
|
+
const shopify = shopifyApp({
|
|
34
|
+
sessionStorage: new KVSessionStorage(
|
|
35
|
+
await mf.getKVNamespace('MY_KV_NAMESPACE'),
|
|
36
|
+
),
|
|
37
|
+
// ...
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
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/kv.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
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shopify/shopify-app-session-storage-kv",
|
|
3
|
+
"version": "3.0.2",
|
|
4
|
+
"description": "Shopify App Session Storage for KV",
|
|
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-kv",
|
|
13
|
+
"author": "Shopify Inc.",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "./build/cjs/kv.js",
|
|
16
|
+
"types": "./build/ts/kv.d.ts",
|
|
17
|
+
"scripts": {},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"shopify",
|
|
23
|
+
"node",
|
|
24
|
+
"app",
|
|
25
|
+
"graphql",
|
|
26
|
+
"rest",
|
|
27
|
+
"webhook",
|
|
28
|
+
"Admin API",
|
|
29
|
+
"Storefront API",
|
|
30
|
+
"session storage",
|
|
31
|
+
"KV",
|
|
32
|
+
"CloudFlare"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"semver": "^7.6.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@shopify/shopify-api": "^9.3.2",
|
|
39
|
+
"@shopify/shopify-app-session-storage": "^2.1.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@cloudflare/workers-types": "^4.20240208.0",
|
|
43
|
+
"@shopify/shopify-app-session-storage-test-utils": "^2.0.1",
|
|
44
|
+
"miniflare": "^3.20231218.3"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"build/*",
|
|
48
|
+
"!bundle/*",
|
|
49
|
+
"!tsconfig.tsbuildinfo",
|
|
50
|
+
"!node_modules"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Miniflare} from 'miniflare';
|
|
2
|
+
import {batteryOfTests} from '@shopify/shopify-app-session-storage-test-utils';
|
|
3
|
+
|
|
4
|
+
import {KVSessionStorage} from '../kv';
|
|
5
|
+
|
|
6
|
+
describe('KVSessionStorage', () => {
|
|
7
|
+
let storage: KVSessionStorage | undefined;
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
const mf = new Miniflare({
|
|
10
|
+
scriptPath:
|
|
11
|
+
'packages/shopify-app-session-storage-kv/src/__tests__/kv-namespace-dummy-worker.ts',
|
|
12
|
+
kvNamespaces: ['KV_TEST_NAMESPACE'],
|
|
13
|
+
modules: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
storage = new KVSessionStorage(
|
|
17
|
+
await mf.getKVNamespace('KV_TEST_NAMESPACE'),
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
batteryOfTests(async () => storage!);
|
|
22
|
+
});
|