-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix empty objects in credential throws error #16
base: master
Are you sure you want to change the base?
Conversation
b8194f9
to
ff3741d
Compare
Signed-off-by: Samuel Hellawell <[email protected]>
ff3741d
to
254aa17
Compare
|
||
// If empty object, skip it here otherwise causes problems downstream | ||
if (schemaKeys.size === 0) { | ||
delete schemaProps[key]; |
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 isn't needed as it will ignore credential values for which the schema has an empty object type. Such a schema is not valid and an error should be thrown. Secondly, is ignoring those fields what you want?
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 isn't needed as it will ignore credential values for which the schema has an empty object type
that is intended, because that value cant exactly be encoded (unless its stringified to {} but that seems pointless to me?)
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.
Why? The schema should never have an empty object.
builder.schema = new CredentialSchema(CredentialSchema.essential()); | ||
builder.subject = { | ||
fname: 'John', | ||
emptyObject: {}, |
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.
There should be a similar test for an empty array.
@@ -56,7 +57,8 @@ export function dockSaverEncryptionGensUncompressed(): SaverEncryptionGensUncomp | |||
export function flattenTill2ndLastKey(obj: object): [string[], object[]] { | |||
const flattened = {}; | |||
const temp = flatten(obj) as object; | |||
for (const k of Object.keys(temp)) { | |||
const tempKeys = Object.keys(temp).filter((key) => typeof temp[key] !== 'object' || !isEmptyObject(temp[key])); |
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.
The following for loop is going to iterate over keys of temp
. Rather than iterating again, move these checks inside the loop.
Signed-off-by: Samuel Hellawell <[email protected]>
No description provided.