- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
[Components] Virifi: Added new components. #13939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import app from "../../virifi.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "virifi-add-member", | ||
| name: "Add Member", | ||
| description: "Adds a new member to your organization. [See the documentation](https://virifi.io/open/api-guide).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "The e-mail address of the new member.", | ||
| }, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "The first name of the new member.", | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "The last name of the new member.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| addMember(args = {}) { | ||
| return this.app.post({ | ||
| path: "/add-member", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| addMember, | ||
| email, | ||
| firstName, | ||
| lastName, | ||
| } = this; | ||
|  | ||
| const response = await addMember({ | ||
| $, | ||
| data: { | ||
| email, | ||
| firstName, | ||
| lastName, | ||
| }, | ||
| }); | ||
| $.export("$summary", "Successfully sent invitation to the new member."); | ||
| return response; | ||
| }, | ||
| }; | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import fs from "fs"; | ||
| import FormData from "form-data"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import app from "../../virifi.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "virifi-certify-document", | ||
| name: "Certify Document", | ||
| description: "Triggers the process for sending a PDF document for certification. For this operation, the user must provide the PDF document. In addition, the user can optionally specify the authenticators for this document. [See the documentation](https://virifi.io/open/api-guide)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| folderName: { | ||
| type: "string", | ||
| label: "Folder Name", | ||
| description: "The name of the folder where the document will be stored.", | ||
| }, | ||
| digitalTwin: { | ||
| propDefinition: [ | ||
| app, | ||
| "digitalTwin", | ||
| ], | ||
| }, | ||
| totalDoc: { | ||
| type: "integer", | ||
| label: "Total Doc", | ||
| description: "The total number of documents.", | ||
| reloadProps: true, | ||
| default: 1, | ||
| }, | ||
| }, | ||
| additionalProps() { | ||
| const { totalDoc } = this; | ||
|  | ||
| if (totalDoc > 5) { | ||
| throw new ConfigurationError("The maximum number of documents is 5."); | ||
| } | ||
|  | ||
| return Array.from({ | ||
| length: totalDoc, | ||
| }).reduce((acc, _, index) => { | ||
| return Object.assign(acc, { | ||
| [`doc${index}`]: { | ||
| type: "string", | ||
| label: `File Path Document ${index + 1}`, | ||
| description: "The document to be sent for certification. This should be the path to the file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).", | ||
| }, | ||
| }); | ||
| }, {}); | ||
| }, | ||
| methods: { | ||
| certifyDocument(args = {}) { | ||
| return this.app.post({ | ||
| path: "/certify-document", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| certifyDocument, | ||
| folderName, | ||
| digitalTwin, | ||
| totalDoc, | ||
| ...props | ||
| } = this; | ||
|  | ||
| const form = new FormData(); | ||
| form.append("folderName", folderName); | ||
| form.append("digitalTwin", String(digitalTwin)); | ||
| form.append("totalDoc", String(totalDoc)); | ||
|  | ||
| Array.from({ | ||
| length: totalDoc, | ||
| }).forEach((_, index) => { | ||
| const value = fs.createReadStream(props[`doc${index}`]); | ||
| form.append(`doc${index}`, value); | ||
| }); | ||
|  | ||
| const response = await certifyDocument({ | ||
| $, | ||
| data: form, | ||
| headers: form.getHeaders(), | ||
| }); | ||
|  | ||
| $.export("$summary", "Document certified successfully"); | ||
| return response; | ||
| }, | ||
| }; | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import fs from "fs"; | ||
| import FormData from "form-data"; | ||
| import app from "../../virifi.app.mjs"; | ||
| import constants from "../../common/constants.mjs"; | ||
|  | ||
| export default { | ||
| key: "virifi-sign-document", | ||
| name: "Sign Document", | ||
| description: "Enables the sending process of a PDF document for signing. Upload the PDF document and specify the participants who need to sign the document, if any. [See the documentation](https://virifi.io/open/api-guide)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| fileName: { | ||
| type: "string", | ||
| label: "File Name", | ||
| description: "The name of the file to be sent for signing.", | ||
| }, | ||
| digitalTwin: { | ||
| propDefinition: [ | ||
| app, | ||
| "digitalTwin", | ||
| ], | ||
| }, | ||
| doc: { | ||
| type: "string", | ||
| label: "Document", | ||
| description: "The PDF document to be sent for signing. This should be the path to the file saved to the `/tmp` directory (e.g. `/tmp/example.pdf`). [See the documentation](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory).", | ||
| }, | ||
| signBy: { | ||
| type: "string", | ||
| label: "Sign By", | ||
| description: "The participants who need to sign the document.", | ||
| options: Object.values(constants.SIGN_BY_OPTION), | ||
| }, | ||
| signUser: { | ||
| type: "string[]", | ||
| label: "Sign Users", | ||
| description: "The participants who need to sign the document where each row should contain at least the email address of the participant in JSON format. Eg. `{\"email\":\"[email protected]\",\"number\":\"1234567890\"}`. The account owner's email address should be listed as the first entry when selecting `signByYourself` or `signAndInviteOthers` in the **Sign By** property.", | ||
| }, | ||
| signatureType: { | ||
| type: "string", | ||
| label: "Signature Type", | ||
| description: "The type of signature to use.", | ||
| options: Object.values(constants.SIGNATURE_TYPE_OPTION), | ||
| }, | ||
| }, | ||
| methods: { | ||
| signDocument(args = {}) { | ||
| return this.app.post({ | ||
| path: "/sign-document", | ||
| headers: { | ||
| "Content-Type": "multipart/form-data", | ||
| }, | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| signDocument, | ||
| doc, | ||
| fileName, | ||
| digitalTwin, | ||
| signBy, | ||
| signUser, | ||
| signatureType, | ||
| } = this; | ||
|  | ||
| const form = new FormData(); | ||
| form.append("doc", fs.createReadStream(doc)); | ||
| form.append("fileName", fileName); | ||
| form.append("digitalTwin", String(digitalTwin)); | ||
| form.append("signBy", signBy); | ||
| form.append("signUser", JSON.stringify(signUser)); | ||
| form.append("signatureType", signatureType); | ||
|  | ||
| const response = await signDocument({ | ||
| $, | ||
| data: form, | ||
| headers: form.getHeaders(), | ||
| }); | ||
|  | ||
| $.export("$summary", "Document sent for signing successfully"); | ||
| return response; | ||
| }, | ||
| }; | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| const BASE_URL = "https://virifi.io"; | ||
| const VERSION_PATH = "/api/developer"; | ||
|  | ||
| const SIGN_BY_OPTION = { | ||
| SIGN_BY_YOURSELF: { | ||
| label: "Sing By Yourself", | ||
| value: "signByYourself", | ||
| }, | ||
| SIGN_AND_INVITE_OTHERS: { | ||
| label: "Sign And Invite Others", | ||
| value: "signAndInviteOthers", | ||
| }, | ||
| SIGN_OTHER: { | ||
| label: "Sign Other", | ||
| value: "signOther", | ||
| }, | ||
| }; | ||
|  | ||
| const SIGNATURE_TYPE_OPTION = { | ||
| AES: "AES", | ||
| PES: "PES", | ||
| }; | ||
|  | ||
| export default { | ||
| BASE_URL, | ||
| VERSION_PATH, | ||
| SIGN_BY_OPTION, | ||
| SIGNATURE_TYPE_OPTION, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|  | ||
| function emptyStrToUndefined(value) { | ||
| const trimmed = typeof(value) === "string" && value.trim(); | ||
| return trimmed === "" | ||
| ? undefined | ||
| : value; | ||
| } | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| function parse(value) { | ||
| const valueToParse = emptyStrToUndefined(value); | ||
| if (typeof(valueToParse) === "object" || valueToParse === undefined) { | ||
| return valueToParse; | ||
| } | ||
| try { | ||
| return JSON.parse(valueToParse); | ||
| } catch (e) { | ||
| throw new ConfigurationError("Make sure the custom expression contains a valid object"); | ||
| } | ||
| } | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| function parseArray(value) { | ||
| try { | ||
| if (!value) { | ||
| return []; | ||
| } | ||
|  | ||
| if (Array.isArray(value)) { | ||
| return value; | ||
| } | ||
|  | ||
| const parsedValue = JSON.parse(value); | ||
|  | ||
| if (!Array.isArray(parsedValue)) { | ||
| throw new Error("Not an array"); | ||
| } | ||
|  | ||
| return parsedValue; | ||
|  | ||
| } catch (e) { | ||
| throw new ConfigurationError("Make sure the custom expression contains a valid array object"); | ||
| } | ||
| } | ||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| export default { | ||
| parseArray: (value) => parseArray(value).map(parse), | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||
| { | ||||||||||||||||||
| "name": "@pipedream/virifi", | ||||||||||||||||||
| "version": "0.0.1", | ||||||||||||||||||
| "version": "0.1.0", | ||||||||||||||||||
| "description": "Pipedream Virifi Components", | ||||||||||||||||||
| "main": "virifi.app.mjs", | ||||||||||||||||||
| "keywords": [ | ||||||||||||||||||
|  | @@ -11,5 +11,10 @@ | |||||||||||||||||
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||||||||||||||||||
| "publishConfig": { | ||||||||||||||||||
| "access": "public" | ||||||||||||||||||
| }, | ||||||||||||||||||
| "dependencies": { | ||||||||||||||||||
| "@pipedream/platform": "3.0.1", | ||||||||||||||||||
| "form-data": "^4.0.0", | ||||||||||||||||||
| "fs": "^0.0.1-security" | ||||||||||||||||||
| 
      Comment on lines
    
      +15
     to 
      +18
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dependencies section looks mostly good, but there's a question about the  The addition of the  
 However, the  Consider removing the    "dependencies": {
    "@pipedream/platform": "3.0.1",
    "form-data": "^4.0.0",
-   "fs": "^0.0.1-security"
  }Committable suggestion
 
        Suggested change
       
 | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,11 +1,41 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import constants from "./common/constants.mjs"; | ||
|  | ||
| export default { | ||
| type: "app", | ||
| app: "virifi", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| digitalTwin: { | ||
| type: "boolean", | ||
| label: "Digital Twin", | ||
| description: "Whether to create a digital twin of the document.", | ||
| default: false, | ||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| getUrl(path) { | ||
| return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`; | ||
| }, | ||
| getHeaders(headers) { | ||
| return { | ||
| "Authorization": `Bearer ${this.$auth.api_key}`, | ||
| ...headers, | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, headers, ...args | ||
| } = {}) { | ||
| return axios($, { | ||
| ...args, | ||
| url: this.getUrl(path), | ||
| headers: this.getHeaders(headers), | ||
| }); | ||
| }, | ||
| post(args = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | 
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the typo in the
labelproperty ofSIGN_BY_YOURSELF.The
labelproperty ofSIGN_BY_YOURSELFhas a typo. It should be "Sign By Yourself" instead of "Sing By Yourself".Apply this diff to fix the typo:
const SIGN_BY_OPTION = { SIGN_BY_YOURSELF: { - label: "Sing By Yourself", + label: "Sign By Yourself", value: "signByYourself", }, SIGN_AND_INVITE_OTHERS: { label: "Sign And Invite Others", value: "signAndInviteOthers", }, SIGN_OTHER: { label: "Sign Other", value: "signOther", }, };Committable suggestion