@verii/credentialing-hub-operator-api 1.3.0 → 1.4.0-pre.1794611916.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/index.js +1 -0
- package/package.json +4 -3
- package/src/services.js +32 -0
- package/src/vp-auth-rules.js +19 -1
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ An issuer service's `verifiablePresentationAuthRules` read values from the crede
|
|
|
59
59
|
|
|
60
60
|
- `selectClaims(pointer, credential)` evaluates a claims path pointer (OpenID4VP 1.0, section 7) against a credential and returns what it selects. A string selects a key of an object, a non-negative integer an index of an array, and `null` every element of an array. It never throws.
|
|
61
61
|
- `ruleValues(rule, credentials)` returns the distinct normalized scalar values that a rule finds in the credentials of its `type`. `credentials` are `{ type, credential }` for each credential. The rule's pointers are tried in order, and the first one that selects a value of the rule's `valueType` supplies the values. Values of other types are ignored, never converted.
|
|
62
|
+
- `ruleCandidateValues(rule, credentials)` returns the values of `ruleValues` that the Hub matches depots with: all of them for a `pick` rule, and for an `equal` rule the value only when there is exactly one. Any other `rule` gives none.
|
|
62
63
|
|
|
63
64
|
```js
|
|
64
65
|
const { ruleValues } = require('@verii/credentialing-hub-operator-api');
|
|
@@ -69,6 +70,11 @@ ruleValues(
|
|
|
69
70
|
); // ['adam@example.com']
|
|
70
71
|
```
|
|
71
72
|
|
|
73
|
+
## Services
|
|
74
|
+
|
|
75
|
+
- `isInternalVpAuth(service)` is true for a service with the `internal` `authMode` and the `verifiable_presentation` auth method, which matches depots by the auth values its `verifiablePresentationAuthRules` read.
|
|
76
|
+
- `isServiceDeactivated(service)` is true once the service's `deactivationDate` is before now. The Hub then treats a reference to the service as one to a missing service, so `depots/create` answers `referenced_service_not_found`.
|
|
77
|
+
|
|
72
78
|
## Error codes
|
|
73
79
|
|
|
74
80
|
The `errorCode`s that the issuer service, depot and credential operator endpoints return:
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verii/credentialing-hub-operator-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-pre.1794611916.0",
|
|
4
4
|
"description": "Schemas, validation, auth value and error code helpers shared by the Credentialing Hub's operator API and its clients",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"ajv": "8.20.0",
|
|
13
13
|
"ajv-formats": "3.0.1",
|
|
14
|
+
"date-fns": "^4.4.0",
|
|
14
15
|
"lodash": "^4.18.1",
|
|
15
|
-
"@verii/common-schemas": "1.
|
|
16
|
-
"@verii/validation": "1.
|
|
16
|
+
"@verii/common-schemas": "1.4.0-pre.1794611916.0",
|
|
17
|
+
"@verii/validation": "1.4.0-pre.1794611916.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"eslint": "9.39.5",
|
package/src/services.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Velocity Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
const { isBefore } = require('date-fns/fp');
|
|
18
|
+
|
|
19
|
+
// A service that matches depots by the auth values its
|
|
20
|
+
// verifiablePresentationAuthRules read from the presented credentials.
|
|
21
|
+
const isInternalVpAuth = (service) =>
|
|
22
|
+
service.authMode === 'internal' &&
|
|
23
|
+
service.authMethods?.includes('verifiable_presentation');
|
|
24
|
+
|
|
25
|
+
// date-fns/fp takes the date to compare with first, so this is
|
|
26
|
+
// deactivationDate < now: a service is deactivated once its deactivationDate
|
|
27
|
+
// has passed. deactivationDate is a Date or an ISO string.
|
|
28
|
+
const isServiceDeactivated = (service) =>
|
|
29
|
+
service.deactivationDate != null &&
|
|
30
|
+
isBefore(new Date(), service.deactivationDate);
|
|
31
|
+
|
|
32
|
+
module.exports = { isInternalVpAuth, isServiceDeactivated };
|
package/src/vp-auth-rules.js
CHANGED
|
@@ -25,6 +25,7 @@ const {
|
|
|
25
25
|
flow,
|
|
26
26
|
get,
|
|
27
27
|
has,
|
|
28
|
+
identity,
|
|
28
29
|
isArray,
|
|
29
30
|
isEmpty,
|
|
30
31
|
isInteger,
|
|
@@ -118,4 +119,21 @@ const ruleValues = (rule, credentials) => {
|
|
|
118
119
|
)(credentials);
|
|
119
120
|
};
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
// pick keeps every value found. equal needs exactly one distinct value.
|
|
123
|
+
const RuleCandidateValues = {
|
|
124
|
+
pick: identity,
|
|
125
|
+
equal: (values) => (size(values) === 1 ? values : []),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// The values of ruleValues that the rule uses. Only the rules' own names count,
|
|
129
|
+
// so a rule such as "constructor" gives no values rather than an inherited
|
|
130
|
+
// method.
|
|
131
|
+
const ruleCandidateValues = (rule, credentials) => {
|
|
132
|
+
if (!has([rule.rule], RuleCandidateValues)) {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const candidateValues = get([rule.rule], RuleCandidateValues);
|
|
136
|
+
return candidateValues(ruleValues(rule, credentials));
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
module.exports = { ruleCandidateValues, ruleValues, selectClaims };
|