@signatu/consent
TypeScript icon, indicating that this package has built-in type declarations

0.213.0 • Public • Published

Signatu Consent for Javascript

This is a Javascript client library for Signatu Consent. It depends on the Signatu service, and the library will load data from signatu.com.

Installation

npm

npm install @signatu/consent

Schema

The JSON Schemas for ConsentRequest and ConsentEvent is available in src/schema.

Usage

All cases require a config object that specifies the apiKey and accessToken:

const config = {
    apiKey: 'MY_API_KEY',
    accessToken: 'MY_ACCESS_TOKEN',
    consentAPI: 'http://url-to-consent-api' /** Optional */,
}

Generic consent

    import {ConsentClient} from '@signatu/consent'

    const client = new ConsentClient(config)

    /** Defaults */
    const options = {
        limitToCurrent: true,
        useCache: false
    }

    const consentTarget = {
        subject: "Some subject ID",
        target: "URL of target",
        scope: "optional list of scopes"
    }
    /** Get the last (current) event */
    const currentEvent = client.load(consentTarget, options)
        .then((consent) => console.log('Consent: ', consent)
        .catch((error) => console.error(error));

    // ...
    const consentEvent = {
        subject: "Some Subject ID",
        target: "URL of target",
        action: true
    }
    const newEvent = consent.save(consentEvent)
        .then((consent) => console.log('New consent: ', consent)
        .catch((error) => console.error(error));

Cookie consent

Cookie Consent uses the standard Consent API, but sets most of the parameters by default.

    import {CookieConsent} from '@signatu/consent'

    const cookieConsent = new CookieConsent(config)
    /* Get current status */
    cookieConsent.getCookieConsent()
        .then(consent => console.log(consent))
        .catch(error => console.error(consent)))
    }

    /* Set new status - true for accept, false for deny */
    cookieConsent.setCookieConsent(true)
        .then(consent => console.log(consent))
        .catch(error => console.error(consent)))

Further information

Go to signatu.com or send us an email on support@signatu.com.

License

This library is MIT Licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i @signatu/consent

Weekly Downloads

1

Version

0.213.0

License

SEE LICENSE IN LICENSE

Unpacked Size

447 kB

Total Files

308

Last publish

Collaborators

  • torgeir.at.signatu