JSPM

netlify-auth-js

0.5.5
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 11
    • Score
      100M100P100Q48855F
    • License MIT

    Netlify Auth API client for JavaScript

    Package Exports

    • netlify-auth-js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (netlify-auth-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Netlify Auth JS Client

    This is a JS library for Netlify Auth API.

    It lets you signup and authenticate users and is a building block for constructing the UI for signups, password recovery, login and logout.

    Usage

    import NetlifyAuth from 'netlify-auth-js'
    
    const auth = new NetlifyAuth({
      APIUrl: 'https://auth.netlify.com'
    });
    
    auth.signup(username, email).then(
      (response) => console.log("Confirmation email sent"),
      (error) => console.log("Error during signup: %o", error.msg)
    );
    
    auth.confirm(token).then(
      (user) => console.log("Logged in as %s", user.email),
      (error) => console.log("Failed to log in: %o", error)
    );
    
    auth.login(email, password).then(
      (user) => console.log("Logged in as %s", user.email),
      (error) => console.log("Failed to log in: %o", error);
    )
    
    auth.requestPasswordRecovery(email).then(
      (response) => console.log("Recovery email sent"),
      (error) => console.log("Error sending recovery mail: %o", error)
    );
    
    auth.recover(token).then(
      (user) => console.log("Logged in as %s", user.email),
      (error) => console.log("Failed to verify recover token: %o", error)
    );
    
    const user = auth.currentUser()
    
    user.update({email: newEmail, password: newPassword}).then(
      (user) => console.log("Updated user"),
      (error) => console.log("Failed to update user: %o", error)
    );
    
    user.jwt().then(
      (token) => console.log("Current token: %s", token),
      (error) => console.log("Failed to get token: %o", error)
    );
    
    user.logout().then(
      (response) => console.log("User logged out"),
      (error) => console.log("Failed to logout user: %o", error)
    );