@0xpolygonid/js-sdk 1.8.2 → 1.8.3
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/dist/browser/esm/index.js +6 -3
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +6 -3
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/iden3comm/handlers/auth.js +5 -3
- package/dist/node/cjs/iden3comm/handlers/contract-request.js +1 -0
- package/dist/node/esm/iden3comm/handlers/auth.js +5 -3
- package/dist/node/esm/iden3comm/handlers/contract-request.js +1 -0
- package/package.json +1 -1
|
@@ -97,6 +97,7 @@ class AuthHandler {
|
|
|
97
97
|
if (message.type !== constants_2.PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE) {
|
|
98
98
|
throw new Error('Invalid media type');
|
|
99
99
|
}
|
|
100
|
+
authRequest.body.scope = authRequest.body.scope || [];
|
|
100
101
|
return authRequest;
|
|
101
102
|
}
|
|
102
103
|
/**
|
|
@@ -208,7 +209,8 @@ class AuthHandler {
|
|
|
208
209
|
throw new Error(`sender of the request is not a target of response - expected ${request.from}, given ${response.to}`);
|
|
209
210
|
}
|
|
210
211
|
this.verifyAuthRequest(request);
|
|
211
|
-
const requestScope = request.body.scope;
|
|
212
|
+
const requestScope = request.body.scope || [];
|
|
213
|
+
const responseScope = response.body.scope || [];
|
|
212
214
|
if (!response.from) {
|
|
213
215
|
throw new Error(`proof response doesn't contain from field`);
|
|
214
216
|
}
|
|
@@ -216,7 +218,7 @@ class AuthHandler {
|
|
|
216
218
|
// group requests by query group id
|
|
217
219
|
for (const proofRequest of requestScope) {
|
|
218
220
|
const groupId = proofRequest.query.groupId;
|
|
219
|
-
const proofResp =
|
|
221
|
+
const proofResp = responseScope.find((resp) => resp.id === proofRequest.id);
|
|
220
222
|
if (!proofResp) {
|
|
221
223
|
throw new Error(`proof is not given for requestId ${proofRequest.id}`);
|
|
222
224
|
}
|
|
@@ -252,7 +254,7 @@ class AuthHandler {
|
|
|
252
254
|
}
|
|
253
255
|
verifyAuthRequest(request) {
|
|
254
256
|
const groupIdValidationMap = {};
|
|
255
|
-
const requestScope = request.body.scope;
|
|
257
|
+
const requestScope = request.body.scope || [];
|
|
256
258
|
for (const proofRequest of requestScope) {
|
|
257
259
|
const groupId = proofRequest.query.groupId;
|
|
258
260
|
if (groupId) {
|
|
@@ -44,6 +44,7 @@ class ContractRequestHandler {
|
|
|
44
44
|
if (message.type !== constants_1.PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE) {
|
|
45
45
|
throw new Error('Invalid media type');
|
|
46
46
|
}
|
|
47
|
+
ciRequest.body.scope = ciRequest.body.scope || [];
|
|
47
48
|
return ciRequest;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
@@ -69,6 +69,7 @@ export class AuthHandler {
|
|
|
69
69
|
if (message.type !== PROTOCOL_MESSAGE_TYPE.AUTHORIZATION_REQUEST_MESSAGE_TYPE) {
|
|
70
70
|
throw new Error('Invalid media type');
|
|
71
71
|
}
|
|
72
|
+
authRequest.body.scope = authRequest.body.scope || [];
|
|
72
73
|
return authRequest;
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
@@ -180,7 +181,8 @@ export class AuthHandler {
|
|
|
180
181
|
throw new Error(`sender of the request is not a target of response - expected ${request.from}, given ${response.to}`);
|
|
181
182
|
}
|
|
182
183
|
this.verifyAuthRequest(request);
|
|
183
|
-
const requestScope = request.body.scope;
|
|
184
|
+
const requestScope = request.body.scope || [];
|
|
185
|
+
const responseScope = response.body.scope || [];
|
|
184
186
|
if (!response.from) {
|
|
185
187
|
throw new Error(`proof response doesn't contain from field`);
|
|
186
188
|
}
|
|
@@ -188,7 +190,7 @@ export class AuthHandler {
|
|
|
188
190
|
// group requests by query group id
|
|
189
191
|
for (const proofRequest of requestScope) {
|
|
190
192
|
const groupId = proofRequest.query.groupId;
|
|
191
|
-
const proofResp =
|
|
193
|
+
const proofResp = responseScope.find((resp) => resp.id === proofRequest.id);
|
|
192
194
|
if (!proofResp) {
|
|
193
195
|
throw new Error(`proof is not given for requestId ${proofRequest.id}`);
|
|
194
196
|
}
|
|
@@ -224,7 +226,7 @@ export class AuthHandler {
|
|
|
224
226
|
}
|
|
225
227
|
verifyAuthRequest(request) {
|
|
226
228
|
const groupIdValidationMap = {};
|
|
227
|
-
const requestScope = request.body.scope;
|
|
229
|
+
const requestScope = request.body.scope || [];
|
|
228
230
|
for (const proofRequest of requestScope) {
|
|
229
231
|
const groupId = proofRequest.query.groupId;
|
|
230
232
|
if (groupId) {
|