Coder Social home page Coder Social logo

kinde-oss / kinde-auth-pkce-js Goto Github PK

View Code? Open in Web Editor NEW
17.0 6.0 11.0 698 KB

Kinde vanilla JavaScript authentication for SPAs using PKCE flows. Can be used with Vue / Angular or any JS framework

Home Page: https://kinde.com/docs/developer-tools/javascript-sdk/

License: MIT License

Shell 0.19% TypeScript 99.81%
authentication javascript pkce sdk

kinde-auth-pkce-js's Introduction

Kinde JavaScript

The Kinde SDK for JavaScript.

You can also use the JavaScript starter kit here.

PRs Welcome Kinde Docs Kinde Community

Documentation

Please refer to the Kinde Javacript SDK document.

Publishing

The core team handles publishing.

To publish a new package version, use the “Release and Publish to NPM” action in the “Actions” tab.

Contributing

Please refer to Kinde’s contributing guidelines.

License

By contributing to Kinde, you agree that your contributions will be licensed under its MIT License.

kinde-auth-pkce-js's People

Contributors

abury avatar atifcppprogrammer avatar coel avatar danielrivers avatar daveordead avatar dependabot[bot] avatar evgenyk avatar faforty avatar kinde-engineering avatar mchr3k avatar oliwolff1 avatar peterphanouvong avatar rudolf-erasmus avatar shayden-at-kinde avatar viv-kinde avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kinde-auth-pkce-js's Issues

Bug: PWAs deployed to the Play Store on Samsung A52 need to use local storage

Prerequisites

Describe the issue

We are seeing an issue when the following conditions are met:

  • App is a PWA deployed to the Play Store
  • Samsung mobile device which is either A42, A52 or S22
  • Android version 12
  • Custom domain applied

In this case the cookie seems to be unreadable by the device. It is fine when viewing in the browser, just not when installed as a PWA.

You can work around this by using the is_dangerously_use_local_storage escape hatch but this isn't recommended (as the name implies!)

Suggest we detect if the SDK is running on an installed PWA and fallback to local storage in that instance only.

Library URL

https://github.com/kinde-oss/kinde-auth-pkce-js/

Library version

3.0.16

Operating system(s)

Android

Operating system version(s)

Android v12

Further environment details

  • App is a PWA deployed to the Play Store
  • Samsung mobile device which is either A42, A52 or S22
  • Using custom domains

Reproducible test case URL

No response

Additional information

No response

Bug: (`console.error` logs appearing during test run)

Prerequisites

Describe the issue

Running the command npm run test executes all the test-suites with jest. All the tests pass however there are console.error logs displayed as jest executes all the tests, a screenshot and a code-sandbox environment have been shared below to demonstrate this, evidently this is not a "bug" per se but without closer inspection the appearance of the console.error logs does give the misleading impression that something is wrong even though it is not. 😏

Library URL

https://github.com/kinde-oss/kinde-auth-pkce-js

Library version

3.0.18

Operating system(s)

Ubuntu

Operating system version(s)

Ubuntu 22.04

Further environment details

  • Browser: Mozilla Firefox 116.0.2
  • JavaScript Runtime: Node.js v18.16.1

Reproducible test case URL

https://codesandbox.io/p/github/kinde-oss/kinde-auth-pkce-js/main?file=/.prettierrc.json:1,1

Additional information

kindeauthpkcejs-test-suite-error

Bug: handleRedirectToApp should not hijack other Oauth flows

Prerequisites

Describe the issue

Hi Team,

In the init method for createKindeClient.ts, it currently uses the presence of the code param in the window.location to detect if it's a Kinde based redirect. This means that any unrelated oauth flows will be hijacked.

Since KindeClient has a redirect URI, ideally it would also be looking for a match based on the window.location's protocol, host and path:

  const init = async () => {
  const { protocol, host, pathname, search } = window.location
    const q = new URLSearchParams(search);
    
    const currentRedirectUri = `${protocol}${host}${pathname}`
    const isRedirectUrl = redirect_uri === currentRedirectUri // You could add an optional param to options to skip/add this check
    if (isRedirectUri && q.has('code')) {
      await handleRedirectToApp(q);
    } else {
      // For onload / new tab / page refresh
      if (is_use_cookie || is_dangerously_use_local_storage) {
        await useRefreshToken();
      }
    }
  };

Library URL

https://github.com/kinde-oss/kinde-auth-pkce-js

Library version

3.0.20

Operating system(s)

macOS

Operating system version(s)

13.4 (22F66)

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: KindeClient methods require arguments that are in fact optional

Prerequisites

Describe the issue

The login, register, and createOrg methods in the KindeClient type are currently making the options argument required. When looking at AuthOptions and OrgOptions, both types are fully optional. Fixing these will stop TypeScript errors showing up when using this library within a TypeScript project.

Library URL

https://github.com/kinde-oss/kinde-auth-pkce-js

Library version

3.0.25

Operating system(s)

macOS

Operating system version(s)

macOS Sonoma 14.1

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: createKindeClient.ts creates an extra history entry

Prerequisites

Describe the issue

https://github.dev/kinde-oss/kinde-auth-pkce-js/blob/main/src/createKindeClient.ts

handleRedirectToApp(...) calls window.history.pushState({}, '', url); on line 258. Is there any chance that this could be changed to https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState The use of pushState(...) means that a history entry gets generated which means that if a user click the Back button in their browser after login, they end up on back on the URL which has the ?code=... query args, which get stripped back out by Kinde and redirects them forward again to the page they just tried to press Back on.

Library URL

https://github.dev/kinde-oss/kinde-auth-pkce-js

Library version

3.0.27

Operating system(s)

macOS

Operating system version(s)

14.0

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: When using multiple audiences we get a "(aud) claim mismatch" error

Prerequisites

Describe the issue

Given the following code, using the @kinde-oss/kinde-auth-react

<KindeProvider
    clientId="xxx"
    domain="https://zzzzz.eu.kinde.com"
    audience="first-audience second-audience"

After the success login redirect we see the following error:

Error: (aud) claim mismatch. Expected: "first-audience second-audience", Received: "first-audience, second-audience"
    at isTokenValid (kinde-auth-pkce-js.esm.js:242:1)
    at setStore (kinde-auth-pkce-js.esm.js:316:1)
    at handleRedirectToApp (kinde-auth-pkce-js.esm.js:480:1)
    at async init (kinde-auth-pkce-js.esm.js:600:1)
    at async createKindeClient (kinde-auth-pkce-js.esm.js:621:1)

Library URL

https://github.com/kinde-oss/kinde-auth-react

Library version

4.0.1

Operating system(s)

Windows

Operating system version(s)

Windows 11, Version - 10.0.22631 Build 22631

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Feature request: Extract utils into a shared library

Prerequisites

What is the problem you’re trying to solve?

Many of the utility functions are common across all our JS based SDKs (vanilla JS, Next, Node, React) and there is unnecessary code duplication. These are helpers for:

  • getting permissions
  • getting organizations
  • getting feature flags
    etc

What solution would you like to see?

A consolidated shared helper library that can be consumed by all our JS libraries

Additional information

No response

Bug: (rollup reports a circular-depency at build time)

Prerequisites

Describe the issue

Hi @DaveOrDead, found this when working on #29, when building the package rollup reports the presence of a circular dependency, a screen shot corroborating this can be found here.

Library URL

https://github.com/kinde-oss/kinde-auth-pkce-js.git

Library version

3.0.18

Operating system(s)

Ubuntu

Operating system version(s)

Ubuntu 22.04

Further environment details

Browser: Mozilla Firefox 116.0.2
JavaScript Runtime: Node.js v18.16.1

Reproducible test case URL

https://codesandbox.io/p/github/kinde-oss/kinde-auth-pkce-js/main?file=/.prettierrc.json:1,1

Additional information

No response

Feature request: Convert to TypeScript

Prerequisites

What is the problem you’re trying to solve?

Feedback from the community is they would like a TS version of the SDK.

We currently expose all the types in a type definition file index.d.ts

What solution would you like to see?

Conversion of library to TypeScript

Additional information

No response

Bug: Console error parsing id token

Prerequisites

Describe the issue

Occasionally when parsing the ID token the following console error is thrown

Screenshot 2023-08-31 at 8 31 40 am
Screenshot 2023-08-31 at 8 31 53 am

Library URL

https://github.com/kinde-oss/kinde-auth-pkce-js

Library version

3.0.16

Operating system(s)

macOS

Operating system version(s)

Ventura

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Bug: (`isAuthenticated` method is missing from `KindeClient` type in `index.d.ts`)

Prerequisites

Describe the issue

The isAuthenticated method is missing from KindeClient type in index.d.ts.

Library URL

https://github.com/kinde-oss/kinde-auth-pkce-js

Library version

3.0.19

Operating system(s)

Ubuntu

Operating system version(s)

Ubuntu 22.04

Further environment details

No response

Reproducible test case URL

No response

Additional information

No response

Documentation issue: Add starter kit link

Prerequisites

How can we improve the docs or what is missing?

Update README to Kinde's OSS template for SDK - https://github.com/kinde-oss/kinde-oss-repo-template/blob/main/README_template_non-generator.md

Provide extra context, such as what you were trying to do and your requirements

N/A

If the docs page already exists, please provide a link

No response

Feature request: Add prettier

Prerequisites

What is the problem you’re trying to solve?

Consistent code style and making life easier for contributors

What solution would you like to see?

Prettier package added to library, config file and formatting applied across the library

Additional information

No response

Feature request: Provide an `isAuthenticated` method

Prerequisites

What is the problem you’re trying to solve?

Several of the other Kinde SDKs offer an isAuthenticated method to improve the developer experience of checking if a user is authenticated

What solution would you like to see?

Add an isAuthenticated method to the library

Additional information

No response

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.