0.0.44 • Published 3 years ago

@secure-share/integrations v0.0.44

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Secure Share Integrations

This repo hosts the custom integration implementation files loaded via CDN by Secure Share.

How does it work?

process flow diagram

A custom integration is comprised of a single JS file written using the Secure Share SDK to register the desired custom functionality with Secure Share. That JS file is then pushed to a TBD CDN host that Secure Share can later use to pull in the custom integration. Any necessary npm dependencies may be used and webpack will bundle them all into a single file when built.

Back in Secure Share, query parameters are used to trigger the loading of the custom integration's CDN file (ex: /secure-share/sharing?ch={channel}. A "channel" refers to the unique identifier for a custom integration. Once Secure Share has loaded the file, it will apply all changes passed in the registerIntegration function.

TODO: clarify a bit better and add documentation for registerIntegration function

Creating a new custom integration

1) Create a feature branch from main 2) Choose a unique channel id for your integration, typically using an abbreviation (e.g. Zendesk integration => 'zd'). 3) Add a new file for your integration to the /src folder using the naming structure {unique_channel_id}.js (e.g. Zendesk integration => zd.js). 4) Write your custom code for the window.SecureShare.registerIntegration() function call. 5) Update webpack.config.js to include an entry point for your new file. 6) Run npm build to create the new /dist file. 7) todo: publishing

Complete example (using Zendesk example)

unique channel id for integration = 'zd'

// ./src/zd.js

import axios from 'axios';

window.SecureShare.registerIntegration('zd', {
    onRender: async ({ params }) => {
        
        const { deliveryChannelURL, objectId, userId, appId } = params;

        const { data } = await axios.get(`${deliveryChannelURL}/greeting/zd/${objectId}`, {
            headers: {
                authorization: `Virtru [["${appId}", "${userId}"]]`
            }
        });
        
        if (data) {
            const { zdTenant, users, ticketTitle, ticketBody } = data;

            const fields = [
                {
                    type: 'display',
                    label: 'Ticket Title',
                    value: ticketTitle
                },
                {
                    type: 'display',
                    label: 'Ticket Body',
                    value: ticketBody
                },
                {
                    type: 'display',
                    label: 'ZD Tenant',
                    value: zdTenant
                }
            ];

            return {
                header: `Zendesk ticket: ${ticketTitle}`,
                fields,
                recipients: users
            }
        }
    },

    onSubmit: async ({ params, files }) => {

        const { deliveryChannelURL, objectId, userId, appId } = params;

        const { data } = await axios.post(
            `${deliveryChannelURL}/send/zd/${objectId}`, 
            { files }, 
            {  
                headers: { authorization: `Virtru [["${appId}", "${userId}"]]` } 
            }
        );

        if (data) {
            console.log('response.data', data);
        }
    }
});
// webpack.config.js

module.exports = {
    ...
    entry: {
        ...
        zd: path.resolve(__dirname, 'src/zd.js') // zendesk
    },
    ...
};
0.0.44

3 years ago

0.0.40

3 years ago

0.0.41

3 years ago

0.0.42

3 years ago

0.0.38

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.33

3 years ago

0.0.34

3 years ago

0.0.36

3 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.26

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.6-beta.9

3 years ago

0.0.6-beta.8

3 years ago

0.0.6-beta.7

3 years ago

0.0.6-beta.6

3 years ago

0.0.6-beta.5

3 years ago

0.0.6-beta.4

3 years ago

0.0.10

3 years ago

0.0.6-beta.3

3 years ago

0.0.6-beta.2

3 years ago

0.0.6-beta.1

3 years ago

0.0.9

3 years ago

0.0.6-beta.0

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago