descope / react-sdk Goto Github PK
View Code? Open in Web Editor NEWReact library used to integrate with Descope
Home Page: https://docs.descope.com
License: MIT License
React library used to integrate with Descope
Home Page: https://docs.descope.com
License: MIT License
Issue seems to affect versions 2.0.17
-> 2.0.23
, using Next.js version 14.2.3
and the App Router. It appears importing the AuthProvider
named export, even within components with the 'use client'
directive, breaks static page generation due to references to client-side APIs.
Broken example:
// project/app/home/layout.tsx
'use client'
import { AuthProvider } from '@descope/react-sdk'
export default function HomeLayout( {children}: {children: ReactNode} ) {
return (
<AuthProvider
projectId={myProjectId}
sessionTokenViaCookie
baseUrl={myAppBaseUrl}
>
{children}
</AuthProvider>
);
}
Ran into this problem today when our dependency on descope/react-sdk
was upgraded from 2.0.2
to 2.0.23
as part of some package upgrades (our version string in our package.json was ^2.0.2
)
After the version upgrade, we began seeing errors like this when running next build
:
Error occurred prerendering page "/home". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: document is not defined
/** trimmed stack trace **/
Using the dynamic
utility to lazy-load the dependency seems to resolve the issue:
'use client'
import dynamic from 'next/dynamic';
// explicitly lazy-load the AuthProvider, and disable SSR
const AuthProvider = dynamic(
() => import('@descope/react-sdk').then(mod => mod.AuthProvider),
{ ssr: false }
);
export default function HomeLayout( {children}: {children: ReactNode} ) {
return (
<AuthProvider
projectId={myProjectId}
sessionTokenViaCookie
baseUrl={myAppBaseUrl}
>
{children}
</AuthProvider>
);
}
I don't fully understand why this change/regression happened, surely versions of the SDK prior to 2.0.17
had to reference document
or other properties present in the browser in order to do basic functionality? I wasn't able to find a changelog for this release that might indicate what changes were the root cause here. We've found this workaround for now, so including that here for anyone else that might run into this problem.
I'm curious if there is a public facing changelog for the library beyond what notes are included in the github releases, which appear to be more sparse than what is published to npm. Also, are there any integration tests being run for the SDK in popular frameworks like Next.js?
privateMap.get is not a function
TypeError: privateMap.get is not a function
at __classPrivateFieldGet (http://localhost:3000/static/js/bundle.js:181799:21)
at new Lt (http://localhost:3000/static/js/vendors-node_modules_descope_web-component_dist_esm_index_js.chunk.js:278:78)
at new Mt (http://localhost:3000/static/js/vendors-node_modules_descope_web-component_dist_esm_index_js.chunk.js:592:5)
at createElement (http://localhost:3000/static/js/bundle.js:97103:38)
at createInstance (http://localhost:3000/static/js/bundle.js:98290:24)
at completeWork (http://localhost:3000/static/js/bundle.js:107416:32)
at completeUnitOfWork (http://localhost:3000/static/js/bundle.js:110721:20)
at performUnitOfWork (http://localhost:3000/static/js/bundle.js:110693:9)
at workLoopSync (http://localhost:3000/static/js/bundle.js:110619:9)
at renderRootSync (http://localhost:3000/static/js/bundle.js:110585:11)
@descope/react-sdk
version: 1.0.4
Error happens even running locally.
Clicking the continue buttons print the error below into the console:
Uncaught (in promise) ReferenceError: PublicKeyCredential is not defined
at index-b7476a59.js:2:4291
at f (regeneratorRuntime.js:44:17)
at Generator.<anonymous> (regeneratorRuntime.js:125:22)
at Generator.next (regeneratorRuntime.js:69:21)
at r (asyncToGenerator.js:3:20)
at s (asyncToGenerator.js:22:9)
at asyncToGenerator.js:27:7
at new Promise (<anonymous>)
at asyncToGenerator.js:19:12
at Cr (index-b7476a59.js:2:4306)
Version: 1.0.3
I am trying to catch 401 while fetching refresh token in react sdk I found DescopeInterceptor in angular sdk is there a way to catch 401/403 while refresh token
I was trying following code could't login. We are using Descope sso on our login page. Let me know what am I missing
Cypress.Commands.add('loginViaDescopeUI', () => {
cy.request({
method: 'POST',
url: `${descopeApiBaseURL}/mgmt/user/create`,
headers: authHeader,
body: testUser,
})
.then(({ body }) => {
const loginId = body["user"]["loginIds"][0];
cy.request({
method: 'POST',
url: `${descopeApiBaseURL}/mgmt/tests/generate/otp`,
headers: authHeader,
body: {
"loginId": loginId,
"deliveryMethod": "email"
}
})
.then(({ body }) => {
const otpCode = body["code"]
cy.request({
method: 'POST',
url: `${descopeApiBaseURL}/auth/otp/verify/email`,
headers: authHeader,
body: {
"loginId": loginId,
"code": otpCode
}
})
.then(({ body }) => {
console.log(body)
const sessionJwt = body["sessionJwt"]
const refreshJwt = body["refreshJwt"]
/** Default name for the session cookie name / local storage key */
const SESSION_TOKEN_KEY = 'DS';
/** Default name for the refresh local storage key */
const REFRESH_TOKEN_KEY = 'DSR';
// As of June 12, 2023, the session and refresh token constants can be found in:
// https://github.dev/descope/web-js-sdk src/withPersistTokens/constants.ts
// // Store the JWT in the browser's local storage.
cy.window().then((win) => {
win.localStorage.setItem(SESSION_TOKEN_KEY, sessionJwt);
win.localStorage.setItem(REFRESH_TOKEN_KEY, refreshJwt);
win.sessionStorage.setItem('sessionJWT', sessionJwt)
});
})
})
})
})
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are awaiting their schedule. Click on a checkbox to get an update now.
@babel/core
, @babel/preset-env
, @babel/preset-react
, @babel/preset-typescript
)These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.
These updates await pending status checks. To force their creation now, click the checkbox below.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
@types/jest
, babel-jest
, jest
, ts-jest
).github/actions/setup/action.yml
actions/setup-node v4
actions/cache v4
.github/workflows/ci.yml
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
actions/checkout v4
actions/setup-node v4
devmasx/coverage-check-action v1.2.0
actions/checkout v4
actions/setup-node v4
.github/workflows/publish-next.yml
actions/checkout v4
actions/setup-node v4
.github/workflows/publish.yml
actions/checkout v4
actions/setup-node v4
.github/workflows/release.yml
actions/checkout v4
tibdex/github-app-token v1
package.json
@descope/access-key-management-widget 0.1.58
@descope/audit-management-widget 0.1.21
@descope/role-management-widget 0.1.56
@descope/user-management-widget 0.4.58
@descope/user-profile-widget 0.0.23
@descope/web-component 3.11.17
@babel/core 7.23.0
@babel/preset-env 7.22.20
@babel/preset-react 7.22.15
@babel/preset-typescript 7.23.0
@open-wc/rollup-plugin-html ^1.2.5
@rollup/plugin-commonjs ^25.0.0
@rollup/plugin-node-resolve ^15.0.0
@rollup/plugin-replace ^5.0.0
@rollup/plugin-typescript ^8.3.0
@testing-library/jest-dom 5.17.0
@testing-library/react 12.1.5
@testing-library/user-event 14.5.1
@types/jest ^27.0.2
@types/react-dom 18.2.12
@types/react-router-dom ^5.3.3
babel-jest 27.5.1
eslint 8.51.0
eslint-config-airbnb 19.0.4
eslint-config-airbnb-typescript 17.1.0
eslint-config-prettier 8.10.0
eslint-config-standard 17.1.0
eslint-import-resolver-typescript 2.7.1
eslint-plugin-import 2.28.1
eslint-plugin-jest 27.4.2
eslint-plugin-jest-dom 4.0.3
eslint-plugin-jest-formatting 3.1.0
eslint-plugin-jsx-a11y 6.7.1
eslint-plugin-n 15.7.0
eslint-plugin-no-only-tests 3.1.0
eslint-plugin-prefer-arrow 1.2.3
eslint-plugin-prettier 4.2.1
eslint-plugin-promise 6.1.1
eslint-plugin-react 7.33.2
eslint-plugin-react-hooks 4.6.0
eslint-plugin-testing-library 5.11.1
husky ^8.0.1
jest ^27.3.1
jest-extended ^3.2.2
lint-staged ^13.0.3
pretty-quick ^3.1.3
react-router-dom 6.16.0
rollup ^2.62.0
rollup-plugin-auto-external ^2.0.0
rollup-plugin-browsersync ^1.3.3
rollup-plugin-define ^1.0.1
rollup-plugin-delete ^2.0.0
rollup-plugin-dotenv ^0.5.0
rollup-plugin-dts ^4.2.2
rollup-plugin-livereload ^2.0.5
rollup-plugin-serve ^2.0.0
rollup-plugin-terser ^7.0.2
ts-jest ^27.0.7
ts-node 10.9.1
typescript ^4.5.3
@descope/web-js-sdk >=1
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: Cannot find preset's package (local>descope/renovate-config)
./node_modules/@descope/react-sdk/dist/index.esm.js 34:22
Module parse failed: Unexpected token (34:22)
File was processed with these loaders:
const w = () => m ? k?.getSessionToken() : (console.warn("Get session token is not supported in SSR"), ""),
| y = () => m ? k?.getRefreshToken() : (console.warn("Get refresh token is not supported in SSR"), ""),
| b = p((e = w(), r) => k?.getJwtPermissions(e, r)),
Node: 14.18.2
React: 17.0.1
react-scripts: "4.0.1"
Kindly help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.