egg-google-auth

    0.0.4 • Public • Published

    egg-google-auth

    NPM version build status Test coverage David deps Known Vulnerabilities npm download

    Install

    $ npm i egg-google-auth --save
    or
    $ yarn add egg-google-auth

    Usage

    // {app_root}/config/plugin.js
    exports.googleAuth = {
      enable: true,
      package: 'egg-google-auth',
    };

    Configuration

    // {app_root}/config/config.default.js
    exports.googleAuth = {
      appName: 'Application name',
      options: {
        // Time offset, used to avoid verification problems caused by user network delay. Default: 0
        timeExcursion: 0,
      },
    };

    see config/config.default.js for more detail.

    Example

    // Generate Google authentication private key
    ctx.helper.generateGoogleSecretKey()
    
    // Generate identity binding QR code information
    ctx.helper.generateGoogleQrCodeText('your secretKey', 'your user')
    
    // Get the base64 string of the QR code
    ctx.helper.generateGoogleQrCodeUrl('your secretKey', 'your user')
    
    // Get Google verification code
    ctx.helper.generateGoogleCode('your secretKey')
    
    // Get the Google verification code for the specified time slice
    ctx.helper.generateGoogleCodeByTime('your secretKey', 'The first 30 seconds Date.now() / 1000 / 30')
    
    // Google verification code verification
    ctx.helper.googleAuthVerify('your secretKey', 'TOTP verification code entered by the user')

    WeChat applet version of the client

    weapp-google-auth

    Questions & Suggestions

    Please open an issue here.

    License

    MIT

    Install

    npm i egg-google-auth

    DownloadsWeekly Downloads

    3

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    8.9 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar