Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions components/virifi/actions/add-member/add-member.mjs
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;
},
};
90 changes: 90 additions & 0 deletions components/virifi/actions/certify-document/certify-document.mjs
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;
},
};
87 changes: 87 additions & 0 deletions components/virifi/actions/sign-document/sign-document.mjs
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;
},
};
29 changes: 29 additions & 0 deletions components/virifi/common/constants.mjs
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",
},
};
Comment on lines +4 to +17
Copy link
Contributor

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 label property of SIGN_BY_YOURSELF.

The label property of SIGN_BY_YOURSELF has 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 SIGN_BY_OPTION = {
SIGN_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",
},
};


const SIGNATURE_TYPE_OPTION = {
AES: "AES",
PES: "PES",
};

export default {
BASE_URL,
VERSION_PATH,
SIGN_BY_OPTION,
SIGNATURE_TYPE_OPTION,
};
47 changes: 47 additions & 0 deletions components/virifi/common/utils.mjs
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;
}

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");
}
}

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");
}
}

export default {
parseArray: (value) => parseArray(value).map(parse),
};
9 changes: 7 additions & 2 deletions components/virifi/package.json
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": [
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependencies section looks mostly good, but there's a question about the fs dependency.

The addition of the dependencies section and the new dependencies aligns with the AI-generated summary, which mentions an enhancement in functionality.

  • The @pipedream/platform dependency at version 3.0.1 suggests an integration with the Pipedream platform, which makes sense for this component.
  • The form-data dependency at version ^4.0.0 is likely used for handling form data in the component, which is a common requirement.

However, the fs dependency at version ^0.0.1-security seems unusual. Node.js has a built-in fs module that can be used directly without installing it as a dependency.

Consider removing the fs dependency and using the built-in fs module instead:

  "dependencies": {
    "@pipedream/platform": "3.0.1",
    "form-data": "^4.0.0",
-   "fs": "^0.0.1-security"
  }
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"dependencies": {
"@pipedream/platform": "3.0.1",
"form-data": "^4.0.0",
"fs": "^0.0.1-security"
"dependencies": {
"@pipedream/platform": "3.0.1",
"form-data": "^4.0.0"
}

}
}
}
40 changes: 35 additions & 5 deletions components/virifi/virifi.app.mjs
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,
});
},
},
};
};
9 changes: 8 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.