UNPKG

1.14 kBJavaScriptView Raw
1/*!
2 * Copyright (c) 2012-2018 Digital Bazaar, Inc. All rights reserved.
3 */
4const bedrock = require('bedrock');
5
6const w3cDateTime = require('./w3cDateTime');
7const identifier = require('./identifier');
8
9const signature = {
10 title: 'Linked Data Signature',
11 description: 'A Linked Data digital signature.',
12 type: 'object',
13 properties: {
14 id: identifier(),
15 type: {
16 title: 'Linked Data Signature Type',
17 type: 'string',
18 enum: ['LinkedDataSignature2015', 'LinkedDataSignature2016']
19 },
20 creator: identifier(),
21 created: w3cDateTime(),
22 signatureValue: {
23 title: 'Digital Signature Value',
24 description: 'The Base64 encoding of the result of the signature ' +
25 'algorithm.',
26 type: 'string'
27 },
28 },
29 // NOTE: id is not required
30 required: ['type', 'creator', 'created', 'signatureValue']
31};
32
33const schema = {
34 title: 'Linked Data Signatures',
35 anyOf: [{
36 type: 'array',
37 items: signature,
38 minItems: 1,
39 }, signature]
40};
41
42module.exports = extend => {
43 if(extend) {
44 return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
45 }
46 return schema;
47};