npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@twilio/twilio-compliance-embed

v1.0.8

Published

React library for Twilio Compliance Embed

Downloads

696

Readme

Twilio Compliance Embed React SDK

npm version

Client-Side Integration

After initializing a ComplianceInquiry using the server-side integration guide, you may render the embedded experience in your website using the TwilioComplianceEmbed React client. The client-side integration is the same process across all supported products such as customer profiles, toll-free verification, etc.

Installation

Install the package in your React project using your preferred package manager:

NPM:

npm install @twilio/twilio-compliance-embed

Yarn:

yarn add @twilio/twilio-compliance-embed

Usage

React

The ComplianceInquiry UI can be embedded into your site with the following code snippet:

import * as React from "react";
import { TwilioComplianceEmbed } from "@twilio/twilio-compliance-embed";

const ComplianceInquiry = () => {
  return (
    <TwilioComplianceEmbed
      inquiryId="<your inquiry id from server-side request>"
      inquirySessionToken="<your inquiry session token from server-side request>"
    />
  );
};

Note: launching the ComplianceInquiry UI may take a few seconds to load & render.

Example with widget padding

import * as React from "react";
import { Spinner } from "@twilio-paste/core/spinner";
import { TwilioComplianceEmbed } from "@twilio/twilio-compliance-embed";

function MyComplianceInquiry() {
  const [data, setData] = React.useState(null);
  const [isLoading, setLoading] = React.useState(true);

  React.useEffect(() => {
    fetch("/my/backend/server/api", {
      method: "get",
    })
      .then((res) => res.json())
      .then((data) => {
        setData(data);
        setLoading(false);
      });
  }, []);

  return !isLoading ? (
    <TwilioComplianceEmbed
      inquiryId={data.inquiry_id}
      sessionToken={data.inquiry_session_token}
      onReady={() => {
        console.log("Ready!");
      }}
      onInquirySubmitted={() => {
        console.log("Registration complete");
      }}
      widgetPadding={{ top: 0, left: 100, right: 100, bottom: 0 }}
    />
  ) : (
    <Spinner decorative={false} title="Loading" />
  );
}

export default MyComplianceInquiry;

Available Properties

| Name | Type | Description | | ------------------- | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | inquiryId | (Required) String | A valid inquiryId returned by the server-side initialize call | | inquirySessionToken | (Required) String | A valid inquirySessionToken returned by the server-side initialize call | | onInquirySubmitted | () => void | An event handler that fires when the user has completed the ComplianceInquiry process. This event is fired when the user lands on the last page. | | onCancel | () => void | An event handler that fires when the user has canceled the ComplianceInquiry process | | onError | () => void | An event handler that fires when an unexpected error occurs during the ComplianceInquiry process | | onReady | () => void | An event handler that fires when the ComplianceInquiry UI has finished loading | | widgetPadding | { top?: number; bottom?: number; left?: number; right?: number; } | Allows customizing the internal padding inside the iframe. If this is not passed it will use the default values {top: 74, left: 24, right: 24, bottom: 24} |

Other Frameworks

We do not provide native support for integrations with other frontend frameworks today. However, you’re free to explore its compatibility with your own set-up. See this GitHub repo as an example for how you may integrate the Compliance Embeddable into a web page that is not built on top of React leveraging Twilio CLI and Serverless Toolkit. In addition, you are free to explore integration methods on your own using third-party libraries such as veaury NPM, etc. But please note, Twilio is not responsible for maintaining compatibility with these third-party libraries.

Security

Exchange of all sensitive information such as credentials, permanent resource identifiers, and PII is designed to occur securely between your website, your server and the Twilio API.

  1. Your customer initiates the ComplianceInquiry UI in your site.
  2. Your server will request the inquiryId & the ephemeral inquirySessionToken from the Twilio API using Twilio’s REST API authentication mechanism (https://www.twilio.com/docs/iam/credentials/api).
  3. Your server will return the inquiryId & inquirySessionToken to your website to be passed into the TwilioComplianceEmbed client component.

Note: we recommend enabling CSP (Content Security Policy) as an added layer of security to protect these secrets in the browser.

The TwilioComplianceEmbed client component will launch and securely load the ComplianceInquiry experience automatically.

License

This project is licensed under the MIT License.