Skip to content

Commit

Permalink
Swapped to Permissions protocol records for permission grant authoriz…
Browse files Browse the repository at this point in the history
…ation (#717)

Swapped to Permissions protocol records for permission grant authorization
  • Loading branch information
thehenrytsai authored Apr 10, 2024
1 parent 98281e0 commit abedc50
Show file tree
Hide file tree
Showing 89 changed files with 1,420 additions and 3,092 deletions.
16 changes: 9 additions & 7 deletions build/compile-validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';

import Ajv from 'ajv';
import Ajv from 'ajv/dist/2020.js';
import mkdirp from 'mkdirp';
import standaloneCode from 'ajv/dist/standalone/index.js';

Expand All @@ -32,10 +32,10 @@ import JwkVerificationMethod from '../json-schemas/jwk-verification-method.json'
import MessagesGet from '../json-schemas/interface-methods/messages-get.json' assert { type: 'json' };
import NumberRangeFilter from '../json-schemas/interface-methods/number-range-filter.json' assert { type: 'json' };
import PaginationCursor from '../json-schemas/interface-methods/pagination-cursor.json' assert { type: 'json' };
import PermissionGrantData from '../json-schemas/permissions/permission-grant-data.json' assert { type: 'json' };
import PermissionRequestData from '../json-schemas/permissions/permission-request-data.json' assert { type: 'json' };
import PermissionRevocationData from '../json-schemas/permissions/permission-revocation-data.json' assert { type: 'json' };
import PermissionsDefinitions from '../json-schemas/permissions/permissions-definitions.json' assert { type: 'json' };
import PermissionsGrant from '../json-schemas/interface-methods/permissions-grant.json' assert { type: 'json' };
import PermissionsRequest from '../json-schemas/interface-methods/permissions-request.json' assert { type: 'json' };
import PermissionsRevoke from '../json-schemas/interface-methods/permissions-revoke.json' assert { type: 'json' };
import PermissionsScopes from '../json-schemas/permissions/scopes.json' assert { type: 'json' };
import ProtocolDefinition from '../json-schemas/interface-methods/protocol-definition.json' assert { type: 'json' };
import ProtocolRuleSet from '../json-schemas/interface-methods/protocol-rule-set.json' assert { type: 'json' };
Expand All @@ -48,6 +48,7 @@ import RecordsQuery from '../json-schemas/interface-methods/records-query.json'
import RecordsRead from '../json-schemas/interface-methods/records-read.json' assert { type: 'json' };
import RecordsSubscribe from '../json-schemas/interface-methods/records-subscribe.json' assert { type: 'json' };
import RecordsWrite from '../json-schemas/interface-methods/records-write.json' assert { type: 'json' };
import RecordsWriteDataEncoded from '../json-schemas/interface-methods/records-write-data-encoded.json' assert { type: 'json' };
import RecordsWriteSignaturePayload from '../json-schemas/signature-payloads/records-write-signature-payload.json' assert { type: 'json' };
import RecordsWriteUnidentified from '../json-schemas/interface-methods/records-write-unidentified.json' assert { type: 'json' };
import StringRangeFilter from '../json-schemas/interface-methods/string-range-filter.json' assert { type: 'json' };
Expand All @@ -60,6 +61,7 @@ const schemas = {
RecordsQuery,
RecordsSubscribe,
RecordsWrite,
RecordsWriteDataEncoded,
RecordsWriteUnidentified,
EventsFilter,
EventsGet,
Expand All @@ -72,10 +74,10 @@ const schemas = {
MessagesGet,
NumberRangeFilter,
PaginationCursor,
PermissionGrantData,
PermissionRequestData,
PermissionRevocationData,
PermissionsDefinitions,
PermissionsGrant,
PermissionsRequest,
PermissionsRevoke,
PermissionsScopes,
ProtocolDefinition,
ProtocolRuleSet,
Expand Down
4 changes: 2 additions & 2 deletions json-schemas/authorization-delegated-grant.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"$id": "https://identity.foundation/dwn/json-schemas/authorization-delegated-grant.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"properties": {
"signature": {
"$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json"
},
"authorDelegatedGrant": {
"$ref": "https://identity.foundation/dwn/json-schemas/permissions-grant.json"
"$ref": "https://identity.foundation/dwn/json-schemas/records-write-data-encoded.json"
}
}
}
6 changes: 3 additions & 3 deletions json-schemas/authorization-owner.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"$id": "https://identity.foundation/dwn/json-schemas/authorization-owner.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"properties": {
"signature": {
"$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json"
},
"authorDelegatedGrant": {
"$ref": "https://identity.foundation/dwn/json-schemas/permissions-grant.json"
"$ref": "https://identity.foundation/dwn/json-schemas/records-write-data-encoded.json"
},
"ownerSignature": {
"$ref": "https://identity.foundation/dwn/json-schemas/general-jws.json"
},
"ownerDelegatedGrant": {
"$ref": "https://identity.foundation/dwn/json-schemas/permissions-grant.json"
"$ref": "https://identity.foundation/dwn/json-schemas/records-write-data-encoded.json"
}
},
"description": "`signature` can exist by itself. But if `ownerSignature` is present, then `signature` must also exist",
Expand Down
2 changes: 1 addition & 1 deletion json-schemas/authorization.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$id": "https://identity.foundation/dwn/json-schemas/authorization.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion json-schemas/definitions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/defs.json",
"type": "object",
"definitions": {
Expand Down
2 changes: 1 addition & 1 deletion json-schemas/general-jws.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$id": "https://identity.foundation/dwn/json-schemas/general-jws.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
16 changes: 11 additions & 5 deletions json-schemas/interface-methods/events-filter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/events-filter.json",
"type": "object",
"additionalProperties": false,
Expand All @@ -13,7 +13,7 @@
],
"type": "string"
},
"method":{
"method": {
"enum": [
"Configure",
"Delete",
Expand Down Expand Up @@ -96,14 +96,20 @@
{
"properties": {
"published": {
"enum": [true]
"enum": [
true
]
}
},
"required": ["published"]
"required": [
"published"
]
},
{
"not": {
"required": ["published"]
"required": [
"published"
]
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion json-schemas/interface-methods/events-get.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/events-get.json",
"type": "object",
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion json-schemas/interface-methods/events-query.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/events-query.json",
"type": "object",
"additionalProperties": false,
Expand Down
84 changes: 42 additions & 42 deletions json-schemas/interface-methods/events-subscribe.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://identity.foundation/dwn/json-schemas/events-subscribe.json",
"type": "object",
"additionalProperties": false,
"required": [
"descriptor",
"authorization"
],
"properties": {
"authorization": {
"$ref": "https://identity.foundation/dwn/json-schemas/authorization.json"
},
"descriptor": {
"type": "object",
"additionalProperties": false,
"required": [
"interface",
"method",
"messageTimestamp",
"filters"
],
"properties": {
"interface": {
"enum": [
"Events"
],
"type": "string"
},
"method": {
"enum": [
"Subscribe"
],
"type": "string"
},
"messageTimestamp": {
"type": "string"
},
"filters": {
"type": "array",
"items": {
"$ref": "https://identity.foundation/dwn/json-schemas/events-filter.json"
}
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/events-subscribe.json",
"type": "object",
"additionalProperties": false,
"required": [
"descriptor",
"authorization"
],
"properties": {
"authorization": {
"$ref": "https://identity.foundation/dwn/json-schemas/authorization.json"
},
"descriptor": {
"type": "object",
"additionalProperties": false,
"required": [
"interface",
"method",
"messageTimestamp",
"filters"
],
"properties": {
"interface": {
"enum": [
"Events"
],
"type": "string"
},
"method": {
"enum": [
"Subscribe"
],
"type": "string"
},
"messageTimestamp": {
"type": "string"
},
"filters": {
"type": "array",
"items": {
"$ref": "https://identity.foundation/dwn/json-schemas/events-filter.json"
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion json-schemas/interface-methods/messages-get.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/messages-get.json",
"type": "object",
"additionalProperties": false,
Expand Down
18 changes: 13 additions & 5 deletions json-schemas/interface-methods/number-range-filter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/number-range-filter.json",
"type": "object",
"minProperties": 1,
Expand All @@ -21,22 +21,30 @@
"dependencies": {
"gt": {
"not": {
"required": ["gte"]
"required": [
"gte"
]
}
},
"gte": {
"not": {
"required": ["gt"]
"required": [
"gt"
]
}
},
"lt": {
"not": {
"required": ["lte"]
"required": [
"lte"
]
}
},
"lte": {
"not": {
"required": ["lt"]
"required": [
"lt"
]
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions json-schemas/interface-methods/pagination-cursor.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://identity.foundation/dwn/json-schemas/pagination-cursor.json",
"type": "object",
"minProperties": 1,
Expand All @@ -13,7 +13,10 @@
"type": "string"
},
"value": {
"type": [ "string", "number" ]
"type": [
"string",
"number"
]
}
}
}
Loading

0 comments on commit abedc50

Please sign in to comment.