pkce-pair

1.0.0 • Public • Published

pkce-pair

(c)Bumblehead

npm version Build Status

Creates and validates PKCE-pairs for node and browser environments. pkce-pair copies from projects here and here. PKCE-pair brings together a few things missing from other PKCE packages out there,

  • works with node and browser crypto,
  • returns Promises and not callbacks to use browser window.crypto

If you're using PKCE pairs in a node server environment only and not a browser environment, consider using the pkce-challenge package to generate synchronous pkce values instead (browser window.crypto is asynchronous).

import pkcePair, {
  create,
  createVerifier,
  createChallenge,
  isVerified
} from 'pkce-pair';

call imported functions with a node or browser crypto object,

import pkcePair from 'pkce-pair';
import crypto from 'crypto';

const pair = await pkcePair(crypto);
const isVerified = await isVerified(crypto, pair.verifier, pair.challenge);

console.log(isVerified); // true

another example, using browser window.crypto

import pkcePair from 'pkce-pair';

const pair = await pkcePair(window.crypto);
const challenge = await pkcePair.createChallenge(window.crypto, pair.verifier);
const isVerified = await isVerified(window.crypto, pair.verifier, challenge);

console.log(isVerified); // true

scrounge

(The MIT License)

Copyright (c) Bumblehead chris@bumblehead.com

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i pkce-pair

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    9 kB

    Total Files

    4

    Last publish

    Collaborators

    • bumblehead