Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,12 @@ export function _checkCredential({credential, now = new Date()}) {
if(typeof now === 'string') {
now = new Date(now);
}
// normalize to an array to allow the common case of context being a string
const context = Array.isArray(credential['@context']) ?
credential['@context'] : [credential['@context']];

// ensure first context is 'https://www.w3.org/2018/credentials/v1'
if(credential['@context'][0] !== CREDENTIALS_CONTEXT_V1_URL) {
if(context[0] !== CREDENTIALS_CONTEXT_V1_URL) {
throw new Error(
`"${CREDENTIALS_CONTEXT_V1_URL}" needs to be first in the ` +
'list of contexts.');
Expand Down