-
Notifications
You must be signed in to change notification settings - Fork 16
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
Store encrypted files on IPFS and link to POD attributes #1328
base: main
Are you sure you want to change the base?
Conversation
@@ -338,7 +356,7 @@ function IssuerCreateLoan() { | |||
/> | |||
{isLoggedIn ? ( | |||
<> | |||
<PageSection titleAddition="Select a template to enter the asset details."> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated to this PR but I noticed this line should have been removed already
@@ -137,6 +138,23 @@ function TemplateField({ label, name, input }: TemplateFieldProps) { | |||
max={input.max} | |||
/> | |||
) | |||
case 'encrypted-file': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider also adding a file
type, which is not encrypted and used as a public field. Or even just having only a file
type and encrypting or not depending on whether the section is public.
}) | ||
) | ||
( | ||
await Promise.all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had to be async to allow the encrypting and pinning within this method.
) | ||
} | ||
|
||
// Source: https://gist.github.com/chrisveness/43bcda93af9f646d083fad678071b90a | ||
async function aesGcmEncrypt(plaintext: string, password: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This of course should be moved somewhere else. And maybe replaced by a higher level library that does this.
@@ -6,8 +6,8 @@ export type LoanTemplateAttribute = { | |||
label: string | |||
type: { | |||
primitive: 'string' | 'number' | |||
statistics: 'categorical' | 'continuous' | 'ordinal' | 'descrete' | |||
constructor: 'String' | 'Date' | 'Number' | |||
statistics?: 'categorical' | 'continuous' | 'ordinal' | 'discrete' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Small typo here
- I think this should be optional. It doesn't make sense to specify statistics for file uploads, and there will likely be other input types in the future for which there's no possible statistics.
function getMetadata<T = any>(uri: string): Observable<T | T[] | null> { | ||
const url = parseMetadataUrl(uri) | ||
if (!url) { | ||
return from([]) | ||
} | ||
return inst.getMetadataObservable<T>(url) | ||
return inst.getJsonObservable<T>(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this all can be use a little refactoring. getMetadata
doesn't seem specific to metadata, works for any file. getMetadataObservable
really is a getter specifically for JSON files.
PR deployed in Google Cloud |
Description
This pull request adds an
encrypted-file
attribute type to loans. When a file is added, this is encrypted using a randomly generated key, pinned on IPFS, and both the IFPS hash and the key are stored in the POD document. This way anyone with access to the POD document can download the file and decrypt it.Closes #1438
Approvals
Screenshots
Impact