@bedrock/vc-verifier 21.2.0 → 21.2.2
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/lib/challenges.js +5 -6
- package/package.json +1 -1
package/lib/challenges.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
|
|
2
|
+
* Copyright (c) 2022-2025 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import * as bedrock from '@bedrock/core';
|
|
5
5
|
import * as database from '@bedrock/mongodb';
|
|
@@ -16,14 +16,13 @@ bedrock.events.on('bedrock-mongodb.ready', async () => {
|
|
|
16
16
|
await database.createIndexes([{
|
|
17
17
|
collection: COLLECTION_NAME,
|
|
18
18
|
fields: {'challenge.value': 1},
|
|
19
|
-
options: {unique: true
|
|
19
|
+
options: {unique: true}
|
|
20
20
|
}, {
|
|
21
21
|
// automatically expire challenges
|
|
22
22
|
collection: COLLECTION_NAME,
|
|
23
23
|
fields: {'challenge.expires': 1},
|
|
24
24
|
options: {
|
|
25
25
|
unique: false,
|
|
26
|
-
background: false,
|
|
27
26
|
expireAfterSeconds: 0
|
|
28
27
|
}
|
|
29
28
|
}]);
|
|
@@ -110,7 +109,7 @@ async function _insert({challenge, ttl} = {}) {
|
|
|
110
109
|
assert.number(ttl, 'ttl');
|
|
111
110
|
challenge = _decodeChallenge({challenge});
|
|
112
111
|
|
|
113
|
-
// insert the configuration and
|
|
112
|
+
// insert the configuration and return the updated record
|
|
114
113
|
const now = Date.now();
|
|
115
114
|
const meta = {created: now, updated: now};
|
|
116
115
|
const expires = new Date(now + ttl);
|
|
@@ -124,8 +123,8 @@ async function _insert({challenge, ttl} = {}) {
|
|
|
124
123
|
};
|
|
125
124
|
try {
|
|
126
125
|
const collection = database.collections[COLLECTION_NAME];
|
|
127
|
-
|
|
128
|
-
return
|
|
126
|
+
await collection.insertOne(record);
|
|
127
|
+
return record;
|
|
129
128
|
} catch(e) {
|
|
130
129
|
if(!database.isDuplicateError(e)) {
|
|
131
130
|
throw e;
|