@pregen/verify 0.2.0 → 0.2.1
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/index.js +3 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const MAX_INT = 2 ** 53 - 1;
|
|
|
13
13
|
const PREFIX = /^[ABCDEFGHJKMNPQRSTVWXYZ]{4}$/;
|
|
14
14
|
const FINGERPRINT = /^pg-ed25519:[0-9a-f]{32}$/;
|
|
15
15
|
const ISSUER_IN_CODE = /^PG-([ABCDEFGHJKMNPQRSTVWXYZ]{4})-/;
|
|
16
|
-
const BARE_CODE = /^PG-(?:
|
|
16
|
+
const BARE_CODE = /^PG-(?:[A-Z]{3}-)?[0-9]/;
|
|
17
17
|
|
|
18
18
|
export class PregenError extends Error {
|
|
19
19
|
constructor(message) { super(message); this.name = "PregenError"; }
|
|
@@ -265,7 +265,8 @@ export async function checkDecision(decision, request, { directory, fetch: fetch
|
|
|
265
265
|
const got = decision.intended_use ?? {}, sent = request.intended_use ?? {};
|
|
266
266
|
if (typeof got !== "object" || typeof sent !== "object") fail("intended_use must be an object");
|
|
267
267
|
for (const k of new Set([...Object.keys(got), ...Object.keys(sent)])) {
|
|
268
|
-
|
|
268
|
+
const ok = isEmpty(sent[k]) ? isEmpty(got[k]) : same(got[k] ?? null, sent[k]); // empty and absent are the same
|
|
269
|
+
if (!ok) fail(`intended_use.${k} does not match the request`);
|
|
269
270
|
}
|
|
270
271
|
for (const f of ["generation_id", "provider_identity_link_id"]) {
|
|
271
272
|
if (!isEmpty(request[f]) && decision[f] !== request[f]) fail(`${f} does not match the request`);
|