Giter VIP home page Giter VIP logo

vt-augment's Introduction

VT Augment logo

Client library that wraps common patterns when interacting with the VirusTotal Augment widget.


Table of Contents

Installation

npm i @virustotal/vt-augment --save

Usage

VT Augment is bundled using the UMD format (@dist/vt-augment.min.js).

<!--- "VTAugment" will be attached to the global window object. -->
<script src="./node_modules/@virustotal/vt-augment/dist/vt-augment.min.js"></script>

Code

<div id="vt-augment-container"></div>
const container = document.querySelector('#vt-augment-container');

const vtaugment = new VTAugment(container, options)

vtaugment.load("[url]").openDrawer()

Modes

Drawer

This is the default mode, VT Augment will be shown in a right side panel when the openDrawer method is called.

Standalone

This mode allows you to integrate the widget as a non-animated div in your page. See Options.

API

vtaugment(container = null, opts = {})

Creates a new object with a html element and a set of options. An iframe is dynamically created inside the container to host the VT API response.

Methods

Methods can be chained and can be called in whatever order.

load openDrawer closeDrawer loading

load(url: string)

Loads the VT API url into the iframe.

vtaugment.load("...")

// Additionally, if the mode is `drawer` can be used along with the method `openDrawer`

vtaugment.load("...").openDrawer()

openDrawer()

Open a drawer panel from the right side. (Only works in drawer mode)

vtaugment.openDrawer()

closeDrawer()

Close the drawer panel. (Only works in drawer mode)

vtaugment.closeDrawer()

loading(active: boolean)

The loading state is managed internally by the library but in the case of need the api provides this method to control loading manually. (Active loading hide the content)

vtaugment.loading(true)

Options

{
  // Background color for loading states. Default ''.
  background: '#fff',
  // Force to closing the widget only with the X button. Default true.
  closingFromOutside: true | false,
  // Select the widget mode. Default drawer.
  mode: 'drawer' | 'standalone',
}

vt-augment's People

Contributors

azakrzewski avatar danipv avatar dependabot[bot] avatar diviei avatar escipion avatar karlhiramoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vt-augment's Issues

Attribution Blur

We've added the vt-augment for an internal application, but would like to unblur the attribution. We have an enterprise account license, but don't want create accounts for every user and require that they log in. Is there any way to populate this data via API key instead? Maybe have the application download it and relay the request to the user?

If I find out that we don't actually have the VirusTotal Threat Landscape module, is this a tab we can disable?

how to use the VT Augment widget in ES6 ?!

I have faced an error when using the VT Augment widget in ES6.
This is the code:
// Start of code
import React, { useEffect, useRef } from "react";
import VTAugment from "@virustotal/vt-augment";

const VTButton = () => {
const containerRef = useRef(null);
const vtaugmentRef = useRef(null);

const handleButtonClick = () => {
if (vtaugmentRef.current) {
vtaugmentRef.current
.load(
"https://www.virustotal.com/ui/widget/html/MTMuMTA3LjEyLjUwfHxpcF9hZGRyZXNzfHx7ImJkMSI6ICIjNGQ2Mzg1IiwgImJnMSI6ICIjMzEzZDVhIiwgImJnMiI6ICIjMjIyYzQyIiwgImZnMSI6ICIjZmZmZmZmIiwgInR5cGUiOiAiZGVmYXVsdCJ9fHxzZXNzaW9ufHxmb3VuZHx8djN8fDE2OTYyNjY1MzV8fGYwZjMxMDQ2MDllZmI3NzU1MzBjMmM4NGEzZTYxZDQxNDcwZWRjMDYxOWEyYzA0ZWU2NzFjZjIxNzgwOWRmZjY"
)
.openDrawer();
}
};

useEffect(() => {
if (containerRef.current) {
vtaugmentRef.current = new VTAugment(containerRef.current, {
mode: "drawer",
});
}
}, []);

return (







);
};

export default VTButton;

// End of code

and this is the error:
Uncaught TypeError: import_vt_augment.default is not a constructor
at VTButton.jsx:20:30
at commitHookEffectListMount (react-dom.development.js:23150:26)
at commitPassiveMountOnFiber (react-dom.development.js:24926:13)
at commitPassiveMountEffects_complete (react-dom.development.js:24891:9)
at commitPassiveMountEffects_begin (react-dom.development.js:24878:7)
at commitPassiveMountEffects (react-dom.development.js:24866:3)
at flushPassiveEffectsImpl (react-dom.development.js:27039:3)
at flushPassiveEffects (react-dom.development.js:26984:14)
at performSyncWorkOnRoot (react-dom.development.js:26076:3)
at flushSyncCallbacks (react-dom.development.js:12042:22)

Unexpected Type Error

I'm getting a Type Error and I can't figure out why. I'm using the following code inside an onclick event, inside a component from the Material UI React lib.


  const container = document.querySelector('#vt-augment-container');

  const options = {
    background: '#fff',
    closingFromOutside: true | false,
    mode: 'drawer' | 'standalone',
  };

  const vtaugment = new VTAugment(container, options);

  vtaugment.load(vtHTMLUrl).openDrawer();

The offending line seems to be the one which instantiates the new VTAugment object. It happens both with the declared options object and with an empty object.

I have verified that the querySelector is working and also that the URL I'm passing to the load function is valid.

Here is the error output:

TypeError: e is undefined
    vb vt-augment.min.js:73
    Z vt-augment.min.js:63
    onClick Table.js:1110
    promise callback*onClick Table.js:1099
    React 14
    unstable_runWithPriority scheduler.development.js:468
    React 15
    <anonymous> app.js:223
    js app-094bb9ab3b626bb2c09c.js:2342
    __webpack_require__ app-094bb9ab3b626bb2c09c.js:80
    2 app-094bb9ab3b626bb2c09c.js:7538
    __webpack_require__ app-094bb9ab3b626bb2c09c.js:80
    checkDeferredModules app-094bb9ab3b626bb2c09c.js:46
    <anonymous> app-094bb9ab3b626bb2c09c.js:153
    <anonymous> app-094bb9ab3b626bb2c09c.js:156

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.