Code Monkey home page Code Monkey logo

react-sdk's People

Contributors

asafshen avatar bars92 avatar dependabot[bot] avatar descope[bot] avatar dorsha avatar gh-action-bump-version avatar guyp-descope avatar itaihanski avatar nirgur avatar nitzperetz avatar omercnet avatar orius123 avatar renovate[bot] avatar ruvenzx avatar shilgapira avatar talaharoni avatar tomerlichtash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-sdk's Issues

react-sdk versions >=`2.0.17` break Next.js static page generation without use of `next/dynamic`

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?

`TypeError: privateMap.get is not a function`

Screenshot from 2023-05-22 06-06-47

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.

What does `PublicKeyCredential is not defined` error mean?

Screenshot from 2023-05-19 03-20-45

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

DescopeInterceptor for reactSDK

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

Descope cypress automation could't login

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)
                        });

                    })
            })
    })
      })

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency @testing-library/user-event to v14.5.2
  • chore(deps): update dependency @types/react-dom to v18.2.25
  • chore(deps): update dependency ts-node to v10.9.2
  • chore(deps): update babel monorepo (@babel/core, @babel/preset-env, @babel/preset-react, @babel/preset-typescript)
  • chore(deps): update dependency eslint to v8.57.0
  • chore(deps): update dependency eslint-plugin-import to v2.29.1
  • chore(deps): update dependency eslint-plugin-jest to v27.9.0
  • chore(deps): update dependency eslint-plugin-jsx-a11y to v6.8.0
  • chore(deps): update dependency eslint-plugin-react to v7.34.1
  • chore(deps): update dependency react-router-dom to v6.22.3
  • chore(deps): update dependency eslint-config-prettier to v9
  • chore(deps): update dependency eslint-plugin-jest-dom to v5
  • chore(deps): update dependency eslint-plugin-prettier to v5
  • chore(deps): update dependency eslint-plugin-testing-library to v6
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency jest-extended to v4
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency pretty-quick to v4
  • chore(deps): update dependency rollup-plugin-serve to v3

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

  • chore(deps): update dependency eslint-import-resolver-typescript to v3

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • chore(deps): update tibdex/github-app-token action to v2

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.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
npm
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

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

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)

Need your help to integrate descope (version: 1.0.14)

./node_modules/@descope/react-sdk/dist/index.esm.js 34:22
Module parse failed: Unexpected token (34:22)
File was processed with these loaders:

  • ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
    You may need an additional loader to handle the result of these loaders.
    | projectId: "temp pid"
    | });

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.