0.15.12 • Published 3 years ago

@funpodium/fp-captcha-client-js-sdk v0.15.12

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
gitlab
Last release
3 years ago

fpCaptcha Client JS SDK

🚧 This is still a WIP project, do not use this in production. 🚧

install

  1. Follow this guide to retrieve a GitLab personal access token.
  2. Run these lines in shell to add the config to npm.
$ npm config set @funpodium:registry https://gitlab.com/api/v4/packages/npm/
$ npm config set -- '//gitlab.com/api/v4/packages/npm/:_authToken' "<your_personal_access_token>"
  1. Run one of these lines to add it to the project's package.json.
npm install @funpodium/fp-captcha-client-js-sdk
# or use yarn
yarn add @funpodium/fp-captcha-client-js-sdk

usage

FpCaptcha

all-in-one class that encapsulate the instructions of setting up the captcha interface.

import { FpCaptcha } from "@funpodium/fp-captcha-client-js-sdk";

const captcha = new FpCaptcha(canvasElement, options);

returns

FpCaptcha(instance)

arguments

PositionKeyTypeRemark
1canvasElementHTMLCanvasElementthe canvas element
2optionsFpCaptchaOptionsoptions to setup FpCaptcha service

options

KeyTypeRemark
windowWindowA window containing a DOM document
configFpCaptchaConfigType

config (FpCaptchaConfigType)

KeyTypeRemark
apiUrlstringAPI endpoint to the fpCaptcha service
chunkSizenumberchunk size for the decipher
dragThresholdnumberdrag active area on the map
dismissTimenumberavailable for dragging after dismissTime
applicationLocalestringLocale of captcha

methods

Method nameUsage
buildto make challenge request and draw on canvas
refreshto re-request for another challenge
teardownto remove all listeners
addResultListenerto add listeners after judgement

method details

build

PositionKeyTypeRemark
1challengeUuidstringchallenge uuid
2isRefreshbooleandefault: false, if true => refresh only chart; if false => refresh the whole captcha

teardown | Position | Key | Type | Remark | | -------- | --------------- | ------- | ------------------------------------------------------------------------------------ | | 1 | isRefresh | boolean | default: false, if true => refresh only chart; if false => refresh the whole captcha |


addResultListener | Position | Key | Type | Remark | | -------- | --------------- | ------- | ------------------------------------------------------------------------------------ | | 1 | callback | (judgement: FpCaptchaJudgement)=> void | callback after judgement |


FpCaptchaView

all-in-one class that encapsulate the captcha view.

import { FpCaptchaView } from "@funpodium/fp-captcha-client-js-sdk";

const captcha = new FpCaptchaView(config);

returns

FpCaptchaView(instance)

arguments

PositionKeyTypeRemark
1configFpCaptchaConfigTypeconfig to setup FpCaptcha service

methods

Method nameUsage
mountto create elements onto document
unmountto remove all elements from document
buildto make challenge request and draw on canvas
addEventListenerto add listeners to various events

method details

build | Position | Key | Type | Remark | | -------- | --------------- | ------- | ------------------------------------------------------------------------------------ | | 1 | challengeUuid | string | challenge uuid |


addEventListener | Position | Key | Type | Remark | | -------- | --------------- | ------- | ------------------------------------------------------------------------------------ | | 1 | eventType | 'open' | 'passed'| 'failed' | 'close' | event listener typ | | 2 | callback | (args: unknown)=> void | callback after specific type of event happened|


0.15.10

3 years ago

0.15.11

3 years ago

0.15.12

3 years ago

0.15.8

3 years ago

0.15.9

3 years ago

0.15.4

3 years ago

0.15.5

3 years ago

0.15.6

3 years ago

0.15.7

3 years ago

0.14.0

3 years ago

0.15.0

3 years ago

0.14.1

3 years ago

0.15.1

3 years ago

0.14.2

3 years ago

0.13.3

3 years ago

0.15.2

3 years ago

0.14.3

3 years ago

0.14.4

3 years ago

0.13.2

4 years ago

0.13.1

4 years ago

0.13.0

4 years ago

0.12.5

4 years ago