Skip to content

Commit

Permalink
Next.js app dir compatibility (#26)
Browse files Browse the repository at this point in the history
Fixes #14

### Features

- Default in-memory storage for access token can be now overridden by
providing the `accessTokenStorage` argument in `SaleorAuthClient`
- This enables support for server-side auth flows where access token is
stored in cookies
- New export path is added: `@saleor/auth-sdk/next/server` that exports
`getNextServerCookiesStorage` meant for best compatibility with Next.js
13+ App Router. See [this example for
details](https://github.com/saleor/example-auth-sdk/blob/5babda35969c35f423680b47d1446466b18b2461/app/ssr/page.tsx#L14-L18).

### BREAKING CHANGES

- `storage` argument in `SaleorAuthClient` has been renamed to
`refreshTokenStorage`
  • Loading branch information
typeofweb authored Nov 17, 2023
1 parent 60b6b7e commit 7e11da7
Show file tree
Hide file tree
Showing 12 changed files with 722 additions and 680 deletions.
75 changes: 0 additions & 75 deletions .github/workflows/codeql.yml

This file was deleted.

22 changes: 11 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: QA
name: Build, TypeScripts, tests
on:
pull_request:
merge_group:
branches:
- main

concurrency:
group: tests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
- name: Install PNPM
uses: pnpm/action-setup@v2
with:
version: 8
version: 8.10.0

- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
node-version-file: package.json
cache: "pnpm"

- name: Install dependencies
run: pnpm --version && pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint:ci

- name: Test
run: CI=true pnpm test
- name: Run tests
run: pnpm test
46 changes: 25 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"license": "BSD-3-Clause",
"dependencies": {
"@graphql-typed-document-node/core": "^3.2.0",
"cookie": "^0.5.0",
"cookie": "^0.6.0",
"graphql": "^16.8.1"
},
"peerDependencies": {
Expand All @@ -33,9 +33,6 @@
"urql": "^4.0.3"
},
"peerDependenciesMeta": {
"@apollo/client": {
"optional": true
},
"react": {
"optional": true
},
Expand All @@ -50,35 +47,34 @@
}
},
"devDependencies": {
"@apollo/client": "^3.8.6",
"@graphql-typed-document-node/core": "^3.2.0",
"@types/cookie": "^0.5.3",
"@types/debug": "^4.1.10",
"@types/node": "^20.8.9",
"@types/node-fetch": "^2.6.7",
"@types/react": "^18.2.33",
"@types/react-dom": "^18.2.14",
"@types/uuid": "^9.0.6",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"@vitejs/plugin-react": "^4.1.0",
"@types/cookie": "^0.5.4",
"@types/debug": "^4.1.12",
"@types/node": "^20.9.0",
"@types/node-fetch": "^2.6.9",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"@vitejs/plugin-react": "^4.1.1",
"clean-publish": "^4.2.0",
"eslint": "^8.52.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"jsdom": "^22.1.0",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"release-it": "^16.2.1",
"release-it": "^17.0.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"urql": "^4.0.5",
"urql": "^4.0.6",
"vite": "^4.5.0",
"vitest": "^0.34.6",
"vitest-fetch-mock": "^0.2.2"
Expand All @@ -99,6 +95,11 @@
"import": "./next/index.mjs",
"require": "./next/index.js"
},
"./next/server": {
"types": "./next/server.d.ts",
"import": "./next/server.mjs",
"require": "./next/server.js"
},
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
Expand All @@ -116,5 +117,8 @@
"bugs": {
"url": "https://github.com/saleor/auth-sdk/issues"
},
"homepage": "https://github.com/saleor/auth-sdk#readme"
"homepage": "https://github.com/saleor/auth-sdk#readme",
"engines": {
"node": ">=18.0.0"
}
}
Loading

0 comments on commit 7e11da7

Please sign in to comment.