Skip to content

Commit e0ab1f2

Browse files
committed
Improve zcap policy JSON schemas; fix interaction JSON schema.
1 parent 41f5a70 commit e0ab1f2

File tree

2 files changed

+61
-19
lines changed

2 files changed

+61
-19
lines changed

lib/zcaps.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ bedrock.events.on('bedrock-express.configure.routes', app => {
3434
routes.policies,
3535
cors(),
3636
validate({bodySchema: schemas.createZcapPolicyBody}),
37-
validate({bodySchema: schemas.createZcapPolicy}),
3837
middleware.authorizeProfileZcapRequest(),
3938
asyncHandler(async (req, res) => {
4039
const {profileId} = req.params;

schemas/bedrock-profile-http.js

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ const id = {
2323
maxLength: 4096
2424
};
2525

26+
const sequence = {
27+
title: 'sequence',
28+
type: 'integer',
29+
minimum: 0,
30+
maximum: Number.MAX_SAFE_INTEGER - 1
31+
};
32+
2633
// this should match query objects with an account in them
2734
const accountQuery = {
2835
title: 'Account Query',
@@ -272,24 +279,11 @@ const createInteraction = {
272279
exchange: {
273280
type: 'object',
274281
required: ['variables'],
275-
variables: {
276-
type: 'object',
277-
additionalProperties: false,
278-
oneOf: [{
279-
required: ['verifiablePresentation']
280-
}, {
281-
required: ['verifiablePresentationRequest']
282-
}],
283-
properties: {
284-
allowUnprotectedPresentation: {
285-
type: 'boolean'
286-
},
287-
verifiablePresentation: {
288-
type: 'object'
289-
},
290-
verifiablePresentationRequest: {
291-
type: 'object'
292-
}
282+
additionalProperties: false,
283+
properties: {
284+
variables: {
285+
type: 'object',
286+
additionalProperties: true
293287
}
294288
}
295289
}
@@ -308,13 +302,62 @@ const getInteractionQuery = {
308302
}
309303
};
310304

305+
const zcapPolicy = {
306+
title: 'Zcap Policy',
307+
type: 'object',
308+
required: ['sequence', 'refresh'],
309+
additionalProperties: false,
310+
properties: {
311+
sequence,
312+
refresh: {
313+
anyOf: [{
314+
const: false
315+
}, {
316+
type: 'object',
317+
additionalProperties: false,
318+
properties: {
319+
constraints: {
320+
type: 'object',
321+
additionalProperties: false,
322+
properties: {
323+
maxTtlBeforeRefresh: {
324+
type: 'number'
325+
}
326+
}
327+
}
328+
}
329+
}]
330+
}
331+
}
332+
};
333+
334+
const createZcapPolicyBody = {
335+
title: 'Create Zcap Policy',
336+
type: 'object',
337+
required: ['policy'],
338+
additionalProperties: false,
339+
properties: {
340+
policy: zcapPolicy
341+
}
342+
};
343+
const getZcapPoliciesQuery = {
344+
title: 'Zcap Policy Query',
345+
type: 'object',
346+
additionalProperties: false,
347+
properties: {}
348+
};
349+
const updateZcapPolicyBody = createZcapPolicyBody;
350+
311351
export {
312352
profileAgent,
313353
profileAgents,
314354
accountQuery,
315355
delegateCapability,
316356
createInteraction,
317357
getInteractionQuery,
358+
createZcapPolicyBody,
359+
getZcapPoliciesQuery,
360+
updateZcapPolicyBody,
318361
zcaps,
319362
refreshableZcap
320363
};

0 commit comments

Comments
 (0)