-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add key/import api [DEV-3486] (#448)
* feat: Add key/import api * Update routes * Update description * Update auth middleware * Add salt and fix issues * Add jsonld validator and fix tests --------- Co-authored-by: Andrew Nikitin <[email protected]>
- Loading branch information
1 parent
71c0ae9
commit e6fcece
Showing
24 changed files
with
448 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
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
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,52 @@ | ||
import { JSONLD_PROOF_TYPES } from '../../types/constants.js'; | ||
import type { JSONLDProofType } from '../../types/shared.js'; | ||
import type { IValidationResult, IValidator, Validatable } from './validator.js'; | ||
|
||
export class JsonLDProofValidator implements IValidator { | ||
validate(proof: Validatable): IValidationResult { | ||
proof = proof as JSONLDProofType; | ||
if (!proof) { | ||
return { | ||
valid: false, | ||
error: 'Proof is required', | ||
}; | ||
} | ||
if (!proof.type) { | ||
return { | ||
valid: false, | ||
error: 'Proof.type is required', | ||
}; | ||
} | ||
if (JSONLD_PROOF_TYPES.includes(proof.type) === false) { | ||
return { | ||
valid: false, | ||
error: `Only ${JSONLD_PROOF_TYPES.join(', ')} proof types are supported`, | ||
}; | ||
} | ||
if (!proof.created) { | ||
return { | ||
valid: false, | ||
error: 'Proof.created is required', | ||
}; | ||
} | ||
if (!proof.proofPurpose) { | ||
return { | ||
valid: false, | ||
error: 'Proof.proofPurpose is required', | ||
}; | ||
} | ||
if (!proof.verificationMethod) { | ||
return { | ||
valid: false, | ||
error: 'Proof.verificationMethod is required', | ||
}; | ||
} | ||
if (!proof.jws) { | ||
return { | ||
valid: false, | ||
error: 'Proof.jws is required', | ||
}; | ||
} | ||
return { valid: true }; | ||
} | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.