1 |
|
2 |
|
3 |
|
4 | 'use strict';
|
5 |
|
6 | const w3cDateTime = require('./w3cDateTime');
|
7 | const identifier = require('./identifier');
|
8 |
|
9 | const baseSignature = {
|
10 | title: 'Linked Data Signature',
|
11 | description: 'A Linked Data digital signature.',
|
12 |
|
13 | required: ['type', 'created', 'jws'],
|
14 | type: 'object',
|
15 | properties: {
|
16 | id: identifier(),
|
17 | type: {
|
18 | title: 'Linked Data Signature Type',
|
19 | type: 'string',
|
20 | enum: ['Ed25519Signature2018', 'RsaSignature2018']
|
21 | },
|
22 | creator: identifier(),
|
23 | created: w3cDateTime(),
|
24 | jws: {
|
25 | title: 'Digital Signature Value',
|
26 | description: 'The Base64 encoding of the result of the signature ' +
|
27 | 'algorithm.',
|
28 | type: 'string'
|
29 | },
|
30 | verificationMethod: identifier(),
|
31 | },
|
32 | };
|
33 |
|
34 | const signature = {
|
35 | allOf: [
|
36 | baseSignature, {
|
37 |
|
38 | anyOf: [{
|
39 | required: ['creator'],
|
40 | not: {required: ['verificationMethod']},
|
41 | }, {
|
42 | required: ['verificationMethod'],
|
43 | not: {required: ['creator']},
|
44 | }]
|
45 | }
|
46 | ]
|
47 | };
|
48 |
|
49 | const schema = {
|
50 | title: 'Linked Data Signatures',
|
51 | oneOf: [{
|
52 | type: 'array',
|
53 | items: signature,
|
54 | minItems: 1,
|
55 | }, signature]
|
56 | };
|
57 |
|
58 | module.exports = () => (schema);
|