-
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.
- Loading branch information
Showing
4 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
import anonyflow from "../../anonyflow.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
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}}", | ||
type: "action", | ||
props: { | ||
anonyflow, | ||
sensitiveData: { | ||
propDefinition: [ | ||
anonyflow, | ||
"sensitiveData", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const encryptedResponse = await this.anonyflow.encryptData({ | ||
sensitiveData: this.sensitiveData, | ||
}); | ||
$.export("$summary", "Sensitive data encrypted successfully"); | ||
return encryptedResponse; | ||
}, | ||
}; |
27 changes: 27 additions & 0 deletions
27
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,27 @@ | ||
import anonyflow from "../../anonyflow.app.mjs"; | ||
import { axios } from "@pipedream/platform"; | ||
|
||
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}}", | ||
type: "action", | ||
props: { | ||
anonyflow, | ||
encryptedData: { | ||
propDefinition: [ | ||
anonyflow, | ||
"encryptedData", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.anonyflow.decryptData({ | ||
encryptedData: this.encryptedData, | ||
}); | ||
|
||
$.export("$summary", "Successfully decrypted the data"); | ||
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,59 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "anonyflow", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
encryptedData: { | ||
type: "string", | ||
label: "Encrypted Data", | ||
description: "The data to be decrypted", | ||
}, | ||
sensitiveData: { | ||
type: "string", | ||
label: "Sensitive Data", | ||
description: "The sensitive data to be encrypted", | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
}, | ||
_baseUrl() { | ||
return "https://api.anonyflow.com"; | ||
}, | ||
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, | ||
}, | ||
}); | ||
}, | ||
async decryptData({ encryptedData }) { | ||
return this._makeRequest({ | ||
path: "/deanony-value", | ||
data: { | ||
value: encryptedData, | ||
}, | ||
}); | ||
}, | ||
}, | ||
}; | ||
version: "0.0.{{ts}}", | ||
}; |
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 |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
"publishConfig": { | ||
"access": "public" | ||
} | ||
} | ||
} |