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

@vgs/collect-js

v0.6.3

Published

VGS Collect.js script loading module

Downloads

214,530

Readme

CircleCI

Overview

What is VGS Collect.js?

VGS Collect.js is a JavaScript library that allows you to securely collect data via any form. Instantly create custom forms that adhere to PCI, HIPAA, GDPR, or CCPA security requirements. VGS intercepts sensitive data before it hits your servers and replaces it with aliased versions while securing the original data in our vault. The form fields behave like traditional forms while preventing access to the unsecured data by injecting secure iframe components.

Why do I need to use this package?

This module intended to simplify VGS Collect.js script loading process. To stay PCI Compliant it's a mandatory to load js from our js.verygoodvault.com domain as a consequence you need to find the best way to include our script, this small utility will solve the problem for you. You can still use the conventional way and just stick a reference to the script in the HEAD section of your page but you may lose some beneficial advantages the package provides:

  • Error handling
  • Fallback CDN managing
  • Reduced latency of cross-origin requests

Installation

Install the package using npm:

npm install @vgs/collect-js

How to use

The imported function inserts the <script> tag to the document head or body and returns the Collect instance as the result of resolved Promise. The script won't be loaded until loadVGSCollect() invoked. In order to speed up cross-domain loading, dns-prefetch and preconnect were added as a side effect.

import { loadVGSCollect } from '@vgs/collect-js';

// load script
const collect = await loadVGSCollect({
  vaultId: '<vault_id>', // required
  environment: '<environment>',
  version: '<x.x.x>'
}).catch((e) => {
  // script was not loaded
});

// https://www.verygoodsecurity.com/docs/vgs-collect/js/integration#form-state
const form = collect.init(state => { console.log(state); });

// https://www.verygoodsecurity.com/docs/vgs-collect/js/integration#create-and-setup-form-fields
form.field({...});
form.field({...});
form.field({...});

// https://www.verygoodsecurity.com/docs/vgs-collect/js/integration#setup-form-submission
form.submit(...);

or use Promise syntax as an alternative:

import { loadVGSCollect } from '@vgs/collect-js';

// load script
loadVGSCollect({
  vaultId: '<vault_id>', // required
  environment: '<environment>',
  version: '<x.x.x>'
})
  .then((collect) => {
    const form = collect.create(state => { console.log(state); });
  })
  .catch((e) => {
  // script was not loaded
});

loadVGSCollect(config)

Available properties:

| Property | Type | Description | Default | |-------------|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| | vaultId | string | Every VGS vault has a unique vault id - it’s a string value beginning with the prefix tnt. | required | | environment | string | Vault environment. Can be sandbox, live, or one with a specified data region (e.g live-eu-1). | 'sandbox' | | version | string | You can specify library version being loaded. Version must be >= 2.0. Please check our Changelog for more details. | 'canary' |

.init(callback)

A wrapper over original .create() method. As we have already received vault_id and environment from the loadVGSCollect() argument, there is no need to specify those params again. The method only returns the form state in the callback.You can still use .create() if necessary.

VGSCollect.init(state => { console.log(state); });

Documentation

Full abilities of VGS Collect.js and integration details you can find in our documentation.

CSP directives

We strongly recommend to add the CSP to your application. Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. Please create CSP directives for the following domains:

connect-src https://js.verygoodvault.com https://js3.verygoodvault.com https://vgs-collect-keeper.apps.verygood.systems frame-src https://js.verygoodvault.com https://js3.verygoodvault.com script-src https://js.verygoodvault.com https://js3.verygoodvault.com

Examples

Built with

Contact

If you have any questions please reach out to support or open issue here.