Skip to content

Commit

Permalink
Tested components
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes committed Mar 7, 2024
1 parent 8688a0a commit 9495d35
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
import anonyflow from "../../anonyflow.app.mjs";
import { axios } from "@pipedream/platform";
import app from "../../anonyflow.app.mjs";

export default {
key: "anonyflow-protect-sensitive-data",
name: "Protect Sensitive Data",
description: "Encrypts sensitive data using AnonyFlow encryption service with a unique private key managed by AnonyFlow. [See the documentation](https://anonyflow.com/api)",
version: "0.0.{{ts}}",
version: "0.0.1",
type: "action",
props: {
anonyflow,
sensitiveData: {
app,
data: {
propDefinition: [
anonyflow,
"sensitiveData",
app,
"data",
],
},
keys: {
propDefinition: [
app,
"keys",
],
},
},
methods: {
anonyPacket(args = {}) {
return this.app.post({
path: "/anony-packet",
...args,
});
},
},
async run({ $ }) {
const encryptedResponse = await this.anonyflow.encryptData({
sensitiveData: this.sensitiveData,
const {
anonyPacket,
data,
keys,
} = this;

const response = await anonyPacket({
$,
data: {
data,
keys,
},
});
$.export("$summary", "Sensitive data encrypted successfully");
return encryptedResponse;
$.export("$summary", `Successfully protected the data with status \`${response.status}\``);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -1,27 +1,49 @@
import anonyflow from "../../anonyflow.app.mjs";
import { axios } from "@pipedream/platform";
import app from "../../anonyflow.app.mjs";

export default {
key: "anonyflow-unprotect-sensitive-data",
name: "Unprotect Sensitive Data",
description: "Decrypts protected data using AnonyFlow decryption service with a unique private key, managed by AnonyFlow. [See the documentation](https://anonyflow.com/api)",
version: "0.0.{{ts}}",
version: "0.0.1",
type: "action",
props: {
anonyflow,
encryptedData: {
app,
data: {
propDefinition: [
anonyflow,
"encryptedData",
app,
"data",
],
},
keys: {
propDefinition: [
app,
"keys",
],
},
},
methods: {
deanonyPacket(args = {}) {
return this.app.post({
path: "/deanony-packet",
...args,
});
},
},
async run({ $ }) {
const response = await this.anonyflow.decryptData({
encryptedData: this.encryptedData,
});
const {
deanonyPacket,
data,
keys,
} = this;

$.export("$summary", "Successfully decrypted the data");
const response = await deanonyPacket({
$,
data: {
data,
keys,
},
});
$.export("$summary", `Successfully unprotected the data with status \`${response.status}\``);
return response;
},
};
69 changes: 29 additions & 40 deletions components/anonyflow/anonyflow.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,43 @@ export default {
type: "app",
app: "anonyflow",
propDefinitions: {
encryptedData: {
type: "string",
label: "Encrypted Data",
description: "The data to be decrypted",
data: {
type: "object",
label: "Data",
description: "Data packet to be Anonymized or Deanonymized",
},
sensitiveData: {
type: "string",
label: "Sensitive Data",
description: "The sensitive data to be encrypted",
keys: {
type: "string[]",
label: "Keys",
description: "Provided keys to be used for Anonymization or Deanonymization",
},
},
methods: {
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `https://api.anonyflow.com${path}`;
},
_baseUrl() {
return "https://api.anonyflow.com";
getHeaders(headers) {
return {
...headers,
"Accept": "application/json",
"Content-Type": "application/json",
"x-api-key": this.$auth.api_key,
};
},
async _makeRequest(opts = {}) {
const {
$ = this, method = "POST", path, data, headers, ...otherOpts
} = opts;
return axios($, {
...otherOpts,
method,
url: this._baseUrl() + path,
headers: {
...headers,
"Content-Type": "application/json",
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
},
data,
});
},
async encryptData({ sensitiveData }) {
return this._makeRequest({
path: "/anony-value",
data: {
value: sensitiveData,
},
});
_makeRequest({
$ = this, path, headers, ...args
} = {}) {
const config = {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
};
return axios($, config);
},
async decryptData({ encryptedData }) {
post(args = {}) {
return this._makeRequest({
path: "/deanony-value",
data: {
value: encryptedData,
},
method: "post",
...args,
});
},
},
Expand Down
5 changes: 4 additions & 1 deletion components/anonyflow/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/anonyflow",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream AnonyFlow Components",
"main": "anonyflow.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.0"
}
}
35 changes: 34 additions & 1 deletion pnpm-lock.yaml

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

0 comments on commit 9495d35

Please sign in to comment.