@bedrock/vc-delivery 5.3.3 → 5.3.5

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/helpers.js CHANGED
@@ -110,6 +110,44 @@ export function decodeLocalId({localId} = {}) {
110
110
  }));
111
111
  }
112
112
 
113
+ export function deepEqual(obj1, obj2) {
114
+ const isObject1 = obj1 && typeof obj1 === 'object';
115
+ const isObject2 = obj2 && typeof obj2 === 'object';
116
+ if(isObject1 !== isObject2) {
117
+ return false;
118
+ }
119
+ if(!isObject1) {
120
+ return obj1 === obj2;
121
+ }
122
+ const isArray1 = Array.isArray(obj1);
123
+ const isArray2 = Array.isArray(obj2);
124
+ if(isArray1 !== isArray2) {
125
+ return false;
126
+ }
127
+ if(isArray1) {
128
+ if(obj1.length !== obj2.length) {
129
+ return false;
130
+ }
131
+ for(const [i, e] of obj1.entries()) {
132
+ if(!deepEqual(e, obj2[i])) {
133
+ return false;
134
+ }
135
+ }
136
+ return true;
137
+ }
138
+ const keys1 = Object.keys(obj1);
139
+ const keys2 = Object.keys(obj2);
140
+ if(keys1.length !== keys2.length) {
141
+ return false;
142
+ }
143
+ for(const k of keys1) {
144
+ if(!deepEqual(obj1[k], obj2[k])) {
145
+ return false;
146
+ }
147
+ }
148
+ return true;
149
+ }
150
+
113
151
  export function stripStacktrace(error) {
114
152
  // serialize error and allow-list specific properties
115
153
  const serialized = serializeError(error);
package/lib/oid4/http.js CHANGED
@@ -62,8 +62,17 @@ export async function createRoutes({
62
62
  authorizationResponse: `${openIdRoute}/client/authorization/response`
63
63
  };
64
64
 
65
- // urlencoded body parser (extended=true for rich JSON-like representation)
66
- const urlencoded = bodyParser.urlencoded({extended: true});
65
+ // urlencoded body parser
66
+ const urlencodedSmall = bodyParser.urlencoded({
67
+ // (extended=true for rich JSON-like representation)
68
+ extended: true
69
+ });
70
+ const urlencodedLarge = bodyParser.urlencoded({
71
+ // (extended=true for rich JSON-like representation)
72
+ extended: true,
73
+ // allow larger payloads
74
+ limit: '10MB'
75
+ });
67
76
 
68
77
  /* Note: The well-known metadata paths for the OID4VCI spec have been
69
78
  specified in at least two different ways over time, including
@@ -142,7 +151,7 @@ export async function createRoutes({
142
151
  app.post(
143
152
  routes.token,
144
153
  cors(),
145
- urlencoded,
154
+ urlencodedSmall,
146
155
  validate({bodySchema: openIdTokenBody}),
147
156
  getConfigMiddleware,
148
157
  getExchange,
@@ -316,7 +325,7 @@ export async function createRoutes({
316
325
  app.post(
317
326
  routes.authorizationResponse,
318
327
  cors(),
319
- urlencoded,
328
+ urlencodedLarge,
320
329
  validate({bodySchema: openIdAuthorizationResponseBody()}),
321
330
  getConfigMiddleware,
322
331
  getExchange,
@@ -4,7 +4,7 @@
4
4
  import * as bedrock from '@bedrock/core';
5
5
  import * as exchanges from '../exchanges.js';
6
6
  import {
7
- evaluateTemplate, getWorkflowIssuerInstances
7
+ deepEqual, evaluateTemplate, getWorkflowIssuerInstances
8
8
  } from '../helpers.js';
9
9
  import {importJWK, SignJWT} from 'jose';
10
10
  import {checkAccessToken} from '@bedrock/oauth2-verifier';
@@ -372,9 +372,9 @@ function _getSupportedFormats({workflow}) {
372
372
  function _matchCredentialRequest(expected, cr) {
373
373
  const {credential_definition: {'@context': c1, type: t1}} = expected;
374
374
  const {credential_definition: {'@context': c2, type: t2}} = cr;
375
- // contexts must match exact order but types can have different order
375
+ // contexts must match exactly but types can have different order
376
376
  return (c1.length === c2.length && t1.length === t2.length &&
377
- c1.every((c, i) => c === c2[i]) && t1.every(t => t2.some(x => t === x)));
377
+ deepEqual(c1, c2) && t1.every(t => t2.some(x => t === x)));
378
378
  }
379
379
 
380
380
  function _normalizeCredentialDefinitionTypes({credentialRequests}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/vc-delivery",
3
- "version": "5.3.3",
3
+ "version": "5.3.5",
4
4
  "type": "module",
5
5
  "description": "Bedrock Verifiable Credential Delivery",
6
6
  "main": "./lib/index.js",