Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(did): ts interface checker to validate did update request
commit 16494a9 Author: Passerino <bartosz.d.wrobel@gmail.com> Date: Wed Mar 2 10:04:01 2022 +0100 feat(did): update did document params validation checking params on updateSignedDidPublicKey, updateSignedDidDelegate functions checking params on updateDocument conditionally depending on didAttribute value in case of validation issues - throws Error with the list of invalid or missing properties
- Loading branch information
Showing
6 changed files
with
153 additions
and
25 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 { | ||
DIDAttribute, | ||
Encoding, | ||
PubKeyType, | ||
} from '@ew-did-registry/did-resolver-interface'; | ||
import { KeyType } from '@ew-did-registry/keys'; | ||
import { createCheckers, iface, enumtype } from 'ts-interface-checker'; | ||
|
||
const IS_REQ_STRING = 'string'; | ||
export const { UpdateServicePoint, UpdateDelegate, UpdatePublicKey } = | ||
createCheckers({ | ||
UpdateServicePoint: iface([], { | ||
did: IS_REQ_STRING, | ||
didAttribute: enumtype({ ServicePoint: DIDAttribute.ServicePoint }), | ||
data: iface([], { | ||
type: enumtype({ ServicePoint: DIDAttribute.ServicePoint }), | ||
value: iface([], { | ||
id: IS_REQ_STRING, | ||
hash: IS_REQ_STRING, | ||
hashAlg: IS_REQ_STRING, | ||
}), | ||
}), | ||
}), | ||
|
||
UpdateDelegate: iface([], { | ||
did: IS_REQ_STRING, | ||
didAttribute: enumtype({ Authenticate: DIDAttribute.Authenticate }), | ||
data: iface([], { | ||
type: enumtype(PubKeyType), | ||
value: iface([], { | ||
id: IS_REQ_STRING, | ||
hash: IS_REQ_STRING, | ||
hashAlg: IS_REQ_STRING, | ||
}), | ||
delegate: IS_REQ_STRING, | ||
}), | ||
}), | ||
|
||
UpdatePublicKey: iface([], { | ||
did: IS_REQ_STRING, | ||
didAttribute: enumtype({ PublicKey: DIDAttribute.PublicKey }), | ||
data: iface([], { | ||
type: enumtype(PubKeyType), | ||
algo: enumtype(KeyType), | ||
encoding: enumtype(Encoding), | ||
value: iface([], { | ||
publicKey: IS_REQ_STRING, | ||
tag: IS_REQ_STRING, | ||
}), | ||
}), | ||
}), | ||
}); |