Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cantoo/cantoo-api

Package Overview
Dependencies
Maintainers
6
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cantoo/cantoo-api

A client api for integration with Cantoo Scribe

  • 1.0.16
  • latest
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

cantoo-api

Creating a new connection

To create a new connection with the cantoo api you must call the static method CantooApi.connect(). This method will create an iframe on the provided DOM node and return a new CantooApi instance. Don't forget to call destroy before getting rid of the CantooApi instance.

CantooApi.connect() receives an Object as param. The object should have the following properties:

keytyperequireddescription
domElement HTMLElementrequiredThe DOM element which the iframe will be attached to. It should use display:flex;
userIdstringrequiredThe user id that wants to interact with the api (as received from the GAR)
fileIdstringoptionalThe file id that is going to be edited (as received in the "ready" and "completed" events)
titlestringoptionalThe title of the file that will be created. Should not be set if fileId is set
idEntstringrequiredThe idEnt as received from the GAR
uaistringrequiredThe UAI as received from the GAR
env'prod' | 'preprod' | 'develop'requiredThe environment that the client will connect to
readOnlybooleanrequiredShould the user be able to edit the file, or is it only a viewer?
const api = await CantooAPI.connect({domElement, env: 'develop', idEnt: '1', uai: '2', userId: '10', fileId: '10', readOnly: true})

The CantooApi instance

Once the connection is done you can interact with the cantoo api through the following methods:

nametypedescription
loadDocument(id: string, readOnly?: boolean | undefined) => Promise<void>Loads a new document on the Iframe
addEventListener(eventName: 'ready', callback: (event: { id: string, userId: string, fileId: string }) => void) => voidAdds a new listener to the 'ready' event
addEventListener(eventName: 'completed', callback: (event: { id: string, title: string, userId: string }) => void) => voidAdds a new listener to the 'completed' event
addEventListener(eventName: 'destroyed', callback: () => void) => voidAdds a new listener to the 'destroyed' event
addEventListener(eventName: 'logout', callback: (event: { id: string, userId: string }) => void) => voidAdds a new listener to the 'logout' event
removeEventListener(eventName: 'ready|completed|destroyed|logout', callback) => voidRemoves a listener that is attached to some event. The callback is the function instance that was previously added to the listener
destroy() => voidCloses the connection with the api. This function also removes all listeners and call the listerners that were attached to the 'destroyed' event

The connection state

The CantooApi holds the connection state on the readOnly attribute state.

There are 4 possible states:

namedescription
launchingThe iframe was attached to the DOM and is loading its content
readyThe document id is ready for edition
completedThe document id has been created and can be retrieved or shared
destroyedThe iframe was destroyed and detached

FAQs

Package last updated on 24 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc