@foundbyte/auth
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

auth

TODO: captcha auth library by Foundbyte

install

yarn add @foundbyte/auth
// or
npm install @foundbyte/auth

Usage

import React, { useRef, useState } from 'react';
import { Captcha, useCaptcha } from '@foundbyte/auth';
import { print } from '@foundbyte/util';

export default () => {
  const ref = useRef<any>();
  const [path, setPath] = useState<string>('https://api.ejiexi.com/system/cgi');
  const [run] = useCaptcha({
    path: path,
    type: 'auto',
  });

  const onClick = () => {
    ref.current?.verify();
  };

  return (
    <>
      <Captcha
        onSuccess={data => print.success(data)}
        path={path}
        type="auto"
        ref={ref}
      >
        <button onClick={onClick} className='demo-btn'>
          点击
        </button>
        <button className='demo-btn' onClick={async () => {
            try {
              if (run) {
                const data = await run();
                print.success(data);
              }
            } catch (e) {
              print.error(e);
            }
          }}>
          hook
        </button>
      </Captcha>
    </>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @foundbyte/auth

Weekly Downloads

1

Version

1.1.7

License

ISC

Unpacked Size

117 kB

Total Files

85

Last publish

Collaborators

  • qiaoyuwen
  • zhoubo
  • guccihuiyuan
  • rccq17mj