@sphereon/ssi-sdk.resource-resolver 0.30.2-unstable.22 → 0.30.2-unstable.23
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/agent/ResourceResolver.d.ts.map +1 -1
- package/dist/agent/ResourceResolver.js +1 -3
- package/dist/agent/ResourceResolver.js.map +1 -1
- package/dist/utils/ResourceResolverUtils.d.ts +1 -3
- package/dist/utils/ResourceResolverUtils.d.ts.map +1 -1
- package/dist/utils/ResourceResolverUtils.js +2 -7
- package/dist/utils/ResourceResolverUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/agent/ResourceResolver.ts +1 -6
- package/src/utils/ResourceResolverUtils.ts +2 -8
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResourceResolver.d.ts","sourceRoot":"","sources":["../../src/agent/ResourceResolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;
|
1
|
+
{"version":3,"file":"ResourceResolver.d.ts","sourceRoot":"","sources":["../../src/agent/ResourceResolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAS3C,OAAO,EAIL,iBAAiB,EAKjB,uBAAuB,EAIxB,MAAM,4BAA4B,CAAA;AAEnC;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,MAAM,MAA2B;IAC1C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAMlC;IAED,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuC;gBAE3D,OAAO,CAAC,EAAE,uBAAuB;IA4B7C,sDAAsD;YACxC,eAAe;IAoD7B,gEAAgE;YAClD,yBAAyB;IAOvC,6DAA6D;YAC/C,sBAAsB;IAIpC,+DAA+D;YACjD,wBAAwB;IAItC,yDAAyD;YAC3C,kBAAkB;YAIlB,WAAW;YAUX,eAAe;IAe7B,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,MAAM;CAKf"}
|
@@ -74,9 +74,7 @@ class ResourceResolver {
|
|
74
74
|
const { input, init, resourceType, resolveOpts, partyCorrelationId, storeId, namespace } = args;
|
75
75
|
const resourceIdentifier = (0, ResourceResolverUtils_1.getResourceIdentifier)(input);
|
76
76
|
const cachedResource = yield this.getResource({ resourceIdentifier, storeId, namespace });
|
77
|
-
if (cachedResource.value &&
|
78
|
-
(0, ResourceResolverUtils_1.isCacheWithinMaxAge)(cachedResource, resolveOpts) &&
|
79
|
-
(0, ResourceResolverUtils_1.isRequestCacheable)(input, resolveOpts)) {
|
77
|
+
if (cachedResource.value && (0, ResourceResolverUtils_1.isCacheWithinMaxAge)(cachedResource.value, resolveOpts)) {
|
80
78
|
return (0, ResourceResolverUtils_1.deserializeResponse)(cachedResource.value.response);
|
81
79
|
}
|
82
80
|
if (resolveOpts === null || resolveOpts === void 0 ? void 0 : resolveOpts.onlyCache) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResourceResolver.js","sourceRoot":"","sources":["../../src/agent/ResourceResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAKwC;AAExC,2DAAsD;AACtD,oCAAiC;AACjC,
|
1
|
+
{"version":3,"file":"ResourceResolver.js","sourceRoot":"","sources":["../../src/agent/ResourceResolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAKwC;AAExC,2DAAsD;AACtD,oCAAiC;AACjC,0EAKuC;AAgBvC;;GAEG;AACH,MAAa,gBAAgB;IAe3B,YAAY,OAAiC;QAdpC,WAAM,GAAG,cAAM,CAAC,iBAAiB,CAAA;QACjC,YAAO,GAAsB;YACpC,eAAe,EAAE,IAAI,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C,IAAsB;QACzC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QAC1B,OAAO,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,gBAAgB,CAAA;IAC3C,CAAC;IAEO,MAAM,CAAC,IAAgB;QAC7B,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAA;QAC9C,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,kBAAkB,EAAE,CAAA;IACpE,CAAC;CAEF;AAxKD,4CAwKC"}
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import { IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
|
2
1
|
import { Response, Request } from 'cross-fetch';
|
3
2
|
import { ResolveOptions, Resource, SerializedResponse } from '../types/IResourceResolver';
|
4
3
|
export declare const getResourceIdentifier: (input: Request | string | URL) => string;
|
5
4
|
export declare const serializeResponse: (response: Response) => Promise<SerializedResponse>;
|
6
5
|
export declare const deserializeResponse: (data: SerializedResponse) => Promise<Response>;
|
7
|
-
export declare const isCacheWithinMaxAge: (cachedResource:
|
8
|
-
export declare const isRequestCacheable: (input: RequestInfo | URL, resolveOpts?: ResolveOptions) => boolean;
|
6
|
+
export declare const isCacheWithinMaxAge: (cachedResource: Resource, resolveOpts?: ResolveOptions) => boolean;
|
9
7
|
//# sourceMappingURL=ResourceResolverUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResourceResolverUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ResourceResolverUtils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"ResourceResolverUtils.d.ts","sourceRoot":"","sources":["../../src/utils/ResourceResolverUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEzF,eAAO,MAAM,qBAAqB,UAAW,OAAO,GAAG,MAAM,GAAG,GAAG,KAAG,MAUrE,CAAA;AAED,eAAO,MAAM,iBAAiB,aAAoB,QAAQ,KAAG,QAAQ,kBAAkB,CAUtF,CAAA;AAED,eAAO,MAAM,mBAAmB,SAAgB,kBAAkB,KAAG,QAAQ,QAAQ,CAgBpF,CAAA;AAGD,eAAO,MAAM,mBAAmB,mBAAoB,QAAQ,gBAAgB,cAAc,KAAG,OAE5F,CAAA"}
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
32
32
|
});
|
33
33
|
};
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
-
exports.
|
35
|
+
exports.isCacheWithinMaxAge = exports.deserializeResponse = exports.serializeResponse = exports.getResourceIdentifier = void 0;
|
36
36
|
const cross_fetch_1 = require("cross-fetch");
|
37
37
|
const u8a = __importStar(require("uint8arrays"));
|
38
38
|
const getResourceIdentifier = (input) => {
|
@@ -72,12 +72,7 @@ const deserializeResponse = (data) => __awaiter(void 0, void 0, void 0, function
|
|
72
72
|
exports.deserializeResponse = deserializeResponse;
|
73
73
|
// Check if the cache is still within the acceptable age
|
74
74
|
const isCacheWithinMaxAge = (cachedResource, resolveOpts) => {
|
75
|
-
return
|
75
|
+
return cachedResource && ((resolveOpts === null || resolveOpts === void 0 ? void 0 : resolveOpts.maxAgeMs) === undefined || (Date.now() - cachedResource.insertedAt < resolveOpts.maxAgeMs));
|
76
76
|
};
|
77
77
|
exports.isCacheWithinMaxAge = isCacheWithinMaxAge;
|
78
|
-
// Check if the request should use the cache
|
79
|
-
const isRequestCacheable = (input, resolveOpts) => {
|
80
|
-
return !(input instanceof cross_fetch_1.Request) || input.method === 'GET' || input.method === 'HEAD' || !!(resolveOpts === null || resolveOpts === void 0 ? void 0 : resolveOpts.onlyCache);
|
81
|
-
};
|
82
|
-
exports.isRequestCacheable = isRequestCacheable;
|
83
78
|
//# sourceMappingURL=ResourceResolverUtils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ResourceResolverUtils.js","sourceRoot":"","sources":["../../src/utils/ResourceResolverUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"ResourceResolverUtils.js","sourceRoot":"","sources":["../../src/utils/ResourceResolverUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwD;AACxD,iDAAkC;AAG3B,MAAM,qBAAqB,GAAG,CAAC,KAA6B,EAAU,EAAE;IAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;SAAM,IAAI,KAAK,YAAY,qBAAO,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC,GAAG,CAAC;IACnB,CAAC;SAAM,IAAI,KAAK,YAAY,GAAG,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AAC3E,CAAC,CAAA;AAVY,QAAA,qBAAqB,yBAUjC;AAEM,MAAM,iBAAiB,GAAG,CAAO,QAAkB,EAA+B,EAAE;IACzF,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;IAEzE,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvD,IAAI,EAAE,SAAS;KAChB,CAAA;AACH,CAAC,CAAA,CAAA;AAVY,QAAA,iBAAiB,qBAU7B;AAEM,MAAM,mBAAmB,GAAG,CAAO,IAAwB,EAAqB,EAAE;IACvF,MAAM,EACJ,MAAM,EACN,UAAU,EACV,OAAO,EACP,IAAI,EACL,GAAG,IAAI,CAAA;IAER,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IACpD,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAElH,OAAO,IAAI,sBAAQ,CAAC,WAAW,EAAE;QAC/B,MAAM;QACN,UAAU;QACV,OAAO,EAAE,IAAI,qBAAO,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AAhBY,QAAA,mBAAmB,uBAgB/B;AAED,wDAAwD;AACjD,MAAM,mBAAmB,GAAG,CAAC,cAAwB,EAAE,WAA4B,EAAW,EAAE;IACrG,OAAO,cAAc,IAAI,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,MAAK,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,cAAc,CAAC,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAA;AACnI,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sphereon/ssi-sdk.resource-resolver",
|
3
|
-
"version": "0.30.2-unstable.
|
3
|
+
"version": "0.30.2-unstable.23+3d2a8a87",
|
4
4
|
"source": "src/index.ts",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -14,14 +14,14 @@
|
|
14
14
|
"build:clean": "tsc --build --clean && tsc --build"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
-
"@sphereon/ssi-sdk.kv-store-temp": "0.30.2-unstable.
|
17
|
+
"@sphereon/ssi-sdk.kv-store-temp": "0.30.2-unstable.23+3d2a8a87",
|
18
18
|
"cross-fetch": "^3.1.8",
|
19
19
|
"debug": "^4.3.5",
|
20
20
|
"typeorm": "^0.3.20",
|
21
21
|
"uint8arrays": "^3.1.1"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
24
|
-
"@sphereon/ssi-sdk.agent-config": "0.30.2-unstable.
|
24
|
+
"@sphereon/ssi-sdk.agent-config": "0.30.2-unstable.23+3d2a8a87",
|
25
25
|
"@veramo/remote-client": "4.2.0",
|
26
26
|
"@veramo/remote-server": "4.2.0",
|
27
27
|
"nock": "^13.5.4",
|
@@ -48,5 +48,5 @@
|
|
48
48
|
"Resource Management",
|
49
49
|
"Caching"
|
50
50
|
],
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "3d2a8a87d0a1786b2a4558627ef46b889341c410"
|
52
52
|
}
|
@@ -11,7 +11,6 @@ import {
|
|
11
11
|
deserializeResponse,
|
12
12
|
getResourceIdentifier,
|
13
13
|
isCacheWithinMaxAge,
|
14
|
-
isRequestCacheable,
|
15
14
|
serializeResponse
|
16
15
|
} from '../utils/ResourceResolverUtils'
|
17
16
|
import {
|
@@ -90,11 +89,7 @@ export class ResourceResolver implements IAgentPlugin {
|
|
90
89
|
const resourceIdentifier = getResourceIdentifier(input)
|
91
90
|
|
92
91
|
const cachedResource = await this.getResource({ resourceIdentifier, storeId, namespace })
|
93
|
-
if (
|
94
|
-
cachedResource.value &&
|
95
|
-
isCacheWithinMaxAge(cachedResource, resolveOpts) &&
|
96
|
-
isRequestCacheable(input, resolveOpts)
|
97
|
-
) {
|
92
|
+
if (cachedResource.value && isCacheWithinMaxAge(cachedResource.value, resolveOpts)) {
|
98
93
|
return deserializeResponse(cachedResource.value.response);
|
99
94
|
}
|
100
95
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { IValueData } from '@sphereon/ssi-sdk.kv-store-temp'
|
2
1
|
import { Headers, Response, Request } from 'cross-fetch'
|
3
2
|
import * as u8a from 'uint8arrays'
|
4
3
|
import { ResolveOptions, Resource, SerializedResponse } from '../types/IResourceResolver'
|
@@ -46,11 +45,6 @@ export const deserializeResponse = async (data: SerializedResponse): Promise<Res
|
|
46
45
|
}
|
47
46
|
|
48
47
|
// Check if the cache is still within the acceptable age
|
49
|
-
export const isCacheWithinMaxAge = (cachedResource:
|
50
|
-
return
|
51
|
-
}
|
52
|
-
|
53
|
-
// Check if the request should use the cache
|
54
|
-
export const isRequestCacheable = (input: RequestInfo | URL, resolveOpts?: ResolveOptions): boolean => {
|
55
|
-
return !(input instanceof Request) || input.method === 'GET' || input.method === 'HEAD' || !!resolveOpts?.onlyCache
|
48
|
+
export const isCacheWithinMaxAge = (cachedResource: Resource, resolveOpts?: ResolveOptions): boolean => {
|
49
|
+
return cachedResource && (resolveOpts?.maxAgeMs === undefined || (Date.now() - cachedResource.insertedAt < resolveOpts.maxAgeMs))
|
56
50
|
}
|