git ssb

1+

cel / ssb-did-resolver



Commit 12e3d422661ad8e3b5e26ef52cee5db237d76bd6

Allow querying versionTime exact match with second precision

Charles E. Lehner committed on 7/27/2021, 2:00:42 AM
Parent: a6fa28b538e52449614896809fd6eb6552b4f3a5

Files changed

gen-test.jschanged
resolver.jschanged
gen-test.jsView
@@ -53,9 +53,9 @@
5353 didUrl: 'did:ssb:ed25519:f_6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU?versionId=%25Vlo6kAc%2BIbGGBhD2MUi2r3ULz%2FNAGBWwGb%2FEMa4w4FI%3D.sha256',
5454 dereferenceOptions: {}
5555 },
5656 {
57- didUrl: 'did:ssb:ed25519:f_6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU?versionTime=2021-07-24T03:38:46Z',
57 + didUrl: 'did:ssb:ed25519:f_6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU?versionTime=2021-07-24T03:38:45Z',
5858 dereferenceOptions: {}
5959 }
6060 ];
6161
resolver.jsView
@@ -15,8 +15,9 @@
1515 const didRe = /^did:ssb:(ed25519):([0-9a-zA-Z._\-]+)$/;
1616 const didUrlRe = /^(did:[^?#\/]*)(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;
1717 const ssbRefRe = /^(@|%|&)([A-Za-z0-9\/+]{43}=)\.([\w\d]+)$/;
1818 const ssbMsgIdRe = /^%[A-Za-z0-9\/+]{43}=\.[\w\d]+$/;
19 +const dateTimeRe = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$/;
1920
2021 function parseDIDURL(uri) {
2122 const m = didUrlRe.exec(uri);
2223 if (!m) return null;
@@ -99,9 +100,11 @@
99100 msg = {key: msgId, value};
100101 gotLatestMessage();
101102 });
102103 } else if (versionTime) {
104 + if (!dateTimeRe.test(versionTime)) return cb({error: 'invalidVersionTime'}, Null, {});
103105 const versionDate = new Date(versionTime);
106 + const timestampQuery = {$lte: versionDate.getTime() + 1000};
104107 // 5
105108 pull(
106109 self.sbot.query.read({
107110 reverse: true,
@@ -110,9 +113,9 @@
110113 {$filter: {
111114 value: {
112115 author: feedId,
113116 content: {type: 'did-document-update'},
114- timestamp: {$lte: versionDate.getTime()}
117 + timestamp: timestampQuery
115118 }
116119 }}
117120 ]
118121 }),

Built with git-ssb-web