-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* anonyflow init * Tested components
- Loading branch information
Showing
6 changed files
with
174 additions
and
7 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
components/anonyflow/actions/protect-sensitive-data/protect-sensitive-data.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
50 changes: 50 additions & 0 deletions
50
components/anonyflow/actions/unprotect-sensitive-data/unprotect-sensitive-data.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^1.6.0" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.