Skip to content
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

New Components - anyflow #10816

Merged
merged 2 commits into from
Mar 11, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../anonyflow.app.mjs";
import utils from "../../common/utils.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.1",
type: "action",
props: {
app,
data: {
propDefinition: [
app,
"data",
],
},
keys: {
propDefinition: [
app,
"keys",
],
},
},
methods: {
anonyPacket(args = {}) {
return this.app.post({
path: "/anony-packet",
...args,
});
},
},
async run({ $ }) {
const {
anonyPacket,
data,
keys,
} = this;

const response = await anonyPacket({
$,
data: {
data: utils.valueToObject(data),
keys,
},
});
$.export("$summary", `Successfully protected the data with status \`${response.status}\``);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import app from "../../anonyflow.app.mjs";
import utils from "../../common/utils.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.1",
type: "action",
props: {
app,
data: {
propDefinition: [
app,
"data",
],
},
keys: {
propDefinition: [
app,
"keys",
],
},
},
methods: {
deanonyPacket(args = {}) {
return this.app.post({
path: "/deanony-packet",
...args,
});
},
},
async run({ $ }) {
const {
deanonyPacket,
data,
keys,
} = this;

const response = await deanonyPacket({
$,
data: {
data: utils.valueToObject(data),
keys,
},
});
$.export("$summary", `Successfully unprotected the data with status \`${response.status}\``);
return response;
},
};
44 changes: 40 additions & 4 deletions components/anonyflow/anonyflow.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "anonyflow",
propDefinitions: {},
propDefinitions: {
data: {
type: "object",
label: "Data",
description: "Data packet to be Anonymized or Deanonymized. Note that **only JSON Object is accepted**",
},
keys: {
type: "string[]",
label: "Keys",
description: "Provided keys to be used for Anonymization or Deanonymization",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `https://api.anonyflow.com${path}`;
},
getHeaders(headers) {
return {
...headers,
"Accept": "application/json",
"Content-Type": "application/json",
"x-api-key": this.$auth.api_key,
};
},
_makeRequest({
$ = this, path, headers, ...args
} = {}) {
const config = {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
};
return axios($, config);
},
post(args = {}) {
return this._makeRequest({
method: "post",
...args,
});
},
},
};
25 changes: 25 additions & 0 deletions components/anonyflow/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function isJson(value) {
if (typeof(value) !== "string") {
return false;
}

let parsedValue;
try {
parsedValue = JSON.parse(value);
} catch (e) {
return false;
}

return typeof(parsedValue) === "object" && parsedValue !== null;
}

function valueToObject(value) {
if (!isJson(value)) {
return value;
}
return JSON.parse(value);
}

export default {
valueToObject,
};
7 changes: 5 additions & 2 deletions 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"
}
}
}
24 changes: 7 additions & 17 deletions pnpm-lock.yaml

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

Loading