1.0.1 • Published 1 year ago

@ketch-sdk/ketch-js v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

ketch-js

Ketch JavaScript ES Module for the Ketch Tag

Installation

npm install --save @ketch-sdk/ketch-js

Initialization

import { loadScript } from '@ketch-sdk/ketch-js'

const api = await loadScript('myOrgCode', 'myPropertyCode')

Register a plugin

api.registerPlugin(myPlugin)

Register an identity provider

api.registerIdentityProvider('myIdentity', myProvider)

Register a storage provider

api.registerStorageProvider(myProvider)

Emits a custom event

api.emit('myEvent', 'some argument')

Register an event listener

import { Consent } from '@ketch-sdk/ketch-types'

function myConsentHandler(consent: Consent) {
  console.log(consent)
}

api.on('consent', myConsentHandler)
api.addListener('consent', myConsentHandler)

Register an event listener that is called only once

api.once('consent', myConsentHandler)

Deregister an event listener

api.off('consent', myConsentHandler)
api.removeEventListener('consent', myConsentHandler)

Deregister all event listeners

api.removeAllListeners('consent')

Get config

const config = await api.getConfig()

Get consent

const consent = await api.getConsent()

Get environment

const env = await api.getEnvironment()

Get GeoIP

const ipInfo = await api.getGeoIP()

Get identities

const identities = await api.getIdentities()

Get jurisdiction

const jurisdiction = await api.getJurisdiction()

Get region information

const regionInfo = await api.getRegionInfo()

Show the Consent experience

api.showConsentExperience()

Show the Preference experience.

const options: ShowPreferenceOptions = {}
api.showPreferenceExperience(options)

Invoke a right

const request: InvokeRightEvent = {}
api.invokeRight(request)
1.0.1

1 year ago

1.0.0

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago