@sphereon/ssi-sdk.geolocation-store 0.32.1-next.54 → 0.33.1-feature.jose.vcdm.55

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/index.js CHANGED
@@ -1,27 +1,333 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __commonJS = (cb, mod) => function __require() {
5
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
+ };
7
+
8
+ // plugin.schema.json
9
+ var require_plugin_schema = __commonJS({
10
+ "plugin.schema.json"(exports, module) {
11
+ module.exports = {
12
+ IGeolocationStore: {
13
+ components: {
14
+ schemas: {
15
+ GeolocationStoreClearAllLocationsArgs: {
16
+ $ref: '#/components/schemas/Pick<GeolocationStoreArgs,"storeId">'
17
+ },
18
+ 'Pick<GeolocationStoreArgs,"storeId">': {
19
+ type: "object",
20
+ properties: {
21
+ storeId: {
22
+ type: "string"
23
+ }
24
+ },
25
+ required: [
26
+ "storeId"
27
+ ],
28
+ additionalProperties: false
29
+ },
30
+ GeolocationStoreLocationResult: {
31
+ $ref: "#/components/schemas/IKeyValueStore<GeolocationStoreLocation>"
32
+ },
33
+ "IKeyValueStore<GeolocationStoreLocation>": {
34
+ type: "object",
35
+ additionalProperties: false,
36
+ description: "A Key Value store is responsible for managing Values identified by keys."
37
+ },
38
+ GeolocationStoreArgs: {
39
+ type: "object",
40
+ properties: {
41
+ ipOrHostname: {
42
+ type: "string"
43
+ },
44
+ storeId: {
45
+ type: "string"
46
+ },
47
+ namespace: {
48
+ type: "string"
49
+ }
50
+ },
51
+ required: [
52
+ "ipOrHostname",
53
+ "storeId",
54
+ "namespace"
55
+ ],
56
+ additionalProperties: false
57
+ },
58
+ GeolocationStoreLocationResultOrUndefined: {
59
+ anyOf: [
60
+ {
61
+ $ref: "#/components/schemas/GeolocationStoreLocation"
62
+ },
63
+ {
64
+ not: {}
65
+ }
66
+ ]
67
+ },
68
+ GeolocationStoreLocation: {
69
+ type: "object",
70
+ properties: {
71
+ continent: {
72
+ type: "string"
73
+ },
74
+ country: {
75
+ type: "string"
76
+ }
77
+ },
78
+ additionalProperties: false
79
+ },
80
+ GeolocationStoreLocationPersistArgs: {
81
+ type: "object",
82
+ additionalProperties: false,
83
+ properties: {
84
+ locationArgs: {
85
+ $ref: "#/components/schemas/GeolocationStoreLocation"
86
+ },
87
+ ipOrHostname: {
88
+ type: "string"
89
+ },
90
+ overwriteExisting: {
91
+ type: "boolean"
92
+ },
93
+ validation: {
94
+ type: "boolean"
95
+ },
96
+ ttl: {
97
+ type: "number"
98
+ },
99
+ storeId: {
100
+ type: "string"
101
+ },
102
+ namespace: {
103
+ type: "string"
104
+ }
105
+ },
106
+ required: [
107
+ "ipOrHostname",
108
+ "locationArgs"
109
+ ]
110
+ },
111
+ GeolocationStoreLocationResultIValueData: {
112
+ $ref: "#/components/schemas/IValueData<GeolocationStoreLocation>"
113
+ },
114
+ "IValueData<GeolocationStoreLocation>": {
115
+ type: "object",
116
+ properties: {
117
+ value: {
118
+ $ref: "#/components/schemas/GeolocationStoreLocation"
119
+ },
120
+ expires: {
121
+ type: "number"
122
+ }
123
+ },
124
+ additionalProperties: false,
125
+ description: "This is how the store will actually store the value. It contains an optional `expires` property, which indicates when the value would expire"
126
+ }
127
+ },
128
+ methods: {
129
+ geolocationStoreClearAllLocations: {
130
+ description: "",
131
+ arguments: {
132
+ $ref: "#/components/schemas/GeolocationStoreClearAllLocationsArgs"
133
+ },
134
+ returnType: {
135
+ type: "boolean"
136
+ }
137
+ },
138
+ geolocationStoreDefaultLocationStore: {
139
+ description: "",
140
+ arguments: {
141
+ type: "object"
142
+ },
143
+ returnType: {
144
+ $ref: "#/components/schemas/GeolocationStoreLocationResult"
145
+ }
146
+ },
147
+ geolocationStoreGetLocation: {
148
+ description: "",
149
+ arguments: {
150
+ $ref: "#/components/schemas/GeolocationStoreArgs"
151
+ },
152
+ returnType: {
153
+ $ref: "#/components/schemas/GeolocationStoreLocationResultOrUndefined"
154
+ }
155
+ },
156
+ geolocationStoreHasLocation: {
157
+ description: "",
158
+ arguments: {
159
+ $ref: "#/components/schemas/GeolocationStoreArgs"
160
+ },
161
+ returnType: {
162
+ type: "boolean"
163
+ }
164
+ },
165
+ geolocationStorePersistLocation: {
166
+ description: "",
167
+ arguments: {
168
+ $ref: "#/components/schemas/GeolocationStoreLocationPersistArgs"
169
+ },
170
+ returnType: {
171
+ $ref: "#/components/schemas/GeolocationStoreLocationResultIValueData"
172
+ }
173
+ },
174
+ geolocationStoreRemoveLocation: {
175
+ description: "",
176
+ arguments: {
177
+ $ref: "#/components/schemas/GeolocationStoreArgs"
178
+ },
179
+ returnType: {
180
+ type: "boolean"
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ };
187
+ }
188
+ });
189
+
190
+ // src/agent/GeolocationStore.ts
191
+ import { KeyValueStore } from "@sphereon/ssi-sdk.kv-store-temp";
192
+ var geolocationStoreMethods = [
193
+ "geolocationStorePersistLocation",
194
+ "geolocationStoreHasLocation",
195
+ "geolocationStoreRemoveLocation",
196
+ "geolocationStoreClearAllLocations",
197
+ "geolocationStoreGetLocation",
198
+ "geolocationStoreDefaultLocationStore"
199
+ ];
200
+ var GeolocationStore = class {
201
+ static {
202
+ __name(this, "GeolocationStore");
203
+ }
204
+ schema = schema.IAnomalyDetectionStore;
205
+ defaultStoreId;
206
+ defaultNamespace;
207
+ _dnsLookupStore;
208
+ methods = {
209
+ geolocationStorePersistLocation: this.geolocationStorePersistLocation.bind(this),
210
+ geolocationStoreHasLocation: this.geolocationStoreHasLocation.bind(this),
211
+ geolocationStoreRemoveLocation: this.geolocationStoreRemoveLocation.bind(this),
212
+ geolocationStoreClearAllLocations: this.geolocationStoreClearAllLocations.bind(this),
213
+ geolocationStoreGetLocation: this.geolocationStoreGetLocation.bind(this),
214
+ geolocationStoreDefaultLocationStore: this.geolocationStoreDefaultLocationStore.bind(this)
215
+ };
216
+ constructor(args) {
217
+ this.defaultStoreId = args?.defaultStoreId ?? "_default";
218
+ this.defaultNamespace = args?.defaultNamespace ?? "anomaly-detection";
219
+ if (args?.dnsLookupStore !== void 0 && args?.dnsLookupStore !== null && args.dnsLookupStore instanceof Map) {
220
+ this._dnsLookupStore = args.dnsLookupStore;
221
+ } else {
222
+ this._dnsLookupStore = (/* @__PURE__ */ new Map()).set(this.defaultStoreId, new KeyValueStore({
223
+ namespace: this.defaultNamespace,
224
+ store: /* @__PURE__ */ new Map()
225
+ }));
226
+ }
227
+ }
228
+ async geolocationStorePersistLocation(args) {
229
+ const storeId = this.storeIdStr(args);
230
+ const namespace = this.namespaceStr(args);
231
+ const { ipOrHostname, locationArgs, ttl } = args;
232
+ if (args?.validation !== false) {
233
+ }
234
+ const existing = await this.store({
235
+ stores: this._dnsLookupStore,
236
+ storeId
237
+ }).getAsValueData(this.prefix({
238
+ namespace,
239
+ ipOrHostname
240
+ }));
241
+ if (!existing.value || existing.value && args?.overwriteExisting !== false) {
242
+ return await this.store({
243
+ stores: this._dnsLookupStore,
244
+ storeId
245
+ }).set(this.prefix({
246
+ namespace,
247
+ ipOrHostname
248
+ }), locationArgs, ttl);
7
249
  }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
250
+ return existing;
251
+ }
252
+ async geolocationStoreHasLocation(args) {
253
+ const { storeId, namespace, ipOrHostname } = {
254
+ ...args
255
+ };
256
+ return this.store({
257
+ stores: this._dnsLookupStore,
258
+ storeId
259
+ }).has(this.prefix({
260
+ namespace,
261
+ ipOrHostname
262
+ }));
263
+ }
264
+ async geolocationStoreRemoveLocation(args) {
265
+ const { storeId, namespace, ipOrHostname } = {
266
+ ...args
267
+ };
268
+ return this.store({
269
+ stores: this._dnsLookupStore,
270
+ storeId
271
+ }).delete(this.prefix({
272
+ namespace,
273
+ ipOrHostname
274
+ }));
275
+ }
276
+ async geolocationStoreClearAllLocations(args) {
277
+ const { storeId } = {
278
+ ...args
279
+ };
280
+ return await this.store({
281
+ stores: this._dnsLookupStore,
282
+ storeId
283
+ }).clear().then(() => true);
284
+ }
285
+ async geolocationStoreGetLocation(args) {
286
+ const { storeId, namespace, ipOrHostname } = {
287
+ ...args
288
+ };
289
+ return this.store({
290
+ stores: this._dnsLookupStore,
291
+ storeId
292
+ }).get(this.prefix({
293
+ namespace,
294
+ ipOrHostname
295
+ }));
296
+ }
297
+ store(args) {
298
+ const storeId = this.storeIdStr({
299
+ storeId: args.storeId
300
+ });
301
+ const store = args.stores.get(storeId);
302
+ if (!store) {
303
+ throw Error(`Could not get geolocation store: ${storeId}`);
304
+ }
305
+ return store;
306
+ }
307
+ storeIdStr({ storeId }) {
308
+ return storeId ?? this.defaultStoreId;
309
+ }
310
+ geolocationStoreDefaultLocationStore() {
311
+ return Promise.resolve(this.store({
312
+ stores: this._dnsLookupStore,
313
+ storeId: this.defaultStoreId
314
+ }));
315
+ }
316
+ namespaceStr({ namespace }) {
317
+ return namespace ?? this.defaultNamespace;
318
+ }
319
+ prefix({ namespace, ipOrHostname }) {
320
+ return `${this.namespaceStr({
321
+ namespace
322
+ })}:${ipOrHostname}`;
323
+ }
324
+ };
325
+
326
+ // src/index.ts
327
+ var schema = require_plugin_schema();
328
+ export {
329
+ GeolocationStore,
330
+ geolocationStoreMethods,
331
+ schema
15
332
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.geolocationStoreMethods = exports.GeolocationStore = exports.schema = void 0;
18
- /**
19
- * @public
20
- */
21
- const schema = require('../plugin.schema.json');
22
- exports.schema = schema;
23
- var GeolocationStore_1 = require("./agent/GeolocationStore");
24
- Object.defineProperty(exports, "GeolocationStore", { enumerable: true, get: function () { return GeolocationStore_1.GeolocationStore; } });
25
- Object.defineProperty(exports, "geolocationStoreMethods", { enumerable: true, get: function () { return GeolocationStore_1.geolocationStoreMethods; } });
26
- __exportStar(require("./types/IGeolocationStore"), exports);
27
333
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AACtC,wBAAM;AACf,6DAAoF;AAA3E,oHAAA,gBAAgB,OAAA;AAAE,2HAAA,uBAAuB,OAAA;AAClD,4DAAyC"}
1
+ {"version":3,"sources":["../plugin.schema.json","../src/agent/GeolocationStore.ts","../src/index.ts"],"sourcesContent":["{\n \"IGeolocationStore\": {\n \"components\": {\n \"schemas\": {\n \"GeolocationStoreClearAllLocationsArgs\": {\n \"$ref\": \"#/components/schemas/Pick<GeolocationStoreArgs,\\\"storeId\\\">\"\n },\n \"Pick<GeolocationStoreArgs,\\\"storeId\\\">\": {\n \"type\": \"object\",\n \"properties\": {\n \"storeId\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"storeId\"\n ],\n \"additionalProperties\": false\n },\n \"GeolocationStoreLocationResult\": {\n \"$ref\": \"#/components/schemas/IKeyValueStore<GeolocationStoreLocation>\"\n },\n \"IKeyValueStore<GeolocationStoreLocation>\": {\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"description\": \"A Key Value store is responsible for managing Values identified by keys.\"\n },\n \"GeolocationStoreArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"ipOrHostname\": {\n \"type\": \"string\"\n },\n \"storeId\": {\n \"type\": \"string\"\n },\n \"namespace\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"ipOrHostname\",\n \"storeId\",\n \"namespace\"\n ],\n \"additionalProperties\": false\n },\n \"GeolocationStoreLocationResultOrUndefined\": {\n \"anyOf\": [\n {\n \"$ref\": \"#/components/schemas/GeolocationStoreLocation\"\n },\n {\n \"not\": {}\n }\n ]\n },\n \"GeolocationStoreLocation\": {\n \"type\": \"object\",\n \"properties\": {\n \"continent\": {\n \"type\": \"string\"\n },\n \"country\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n },\n \"GeolocationStoreLocationPersistArgs\": {\n \"type\": \"object\",\n \"additionalProperties\": false,\n \"properties\": {\n \"locationArgs\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreLocation\"\n },\n \"ipOrHostname\": {\n \"type\": \"string\"\n },\n \"overwriteExisting\": {\n \"type\": \"boolean\"\n },\n \"validation\": {\n \"type\": \"boolean\"\n },\n \"ttl\": {\n \"type\": \"number\"\n },\n \"storeId\": {\n \"type\": \"string\"\n },\n \"namespace\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"ipOrHostname\",\n \"locationArgs\"\n ]\n },\n \"GeolocationStoreLocationResultIValueData\": {\n \"$ref\": \"#/components/schemas/IValueData<GeolocationStoreLocation>\"\n },\n \"IValueData<GeolocationStoreLocation>\": {\n \"type\": \"object\",\n \"properties\": {\n \"value\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreLocation\"\n },\n \"expires\": {\n \"type\": \"number\"\n }\n },\n \"additionalProperties\": false,\n \"description\": \"This is how the store will actually store the value. It contains an optional `expires` property, which indicates when the value would expire\"\n }\n },\n \"methods\": {\n \"geolocationStoreClearAllLocations\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreClearAllLocationsArgs\"\n },\n \"returnType\": {\n \"type\": \"boolean\"\n }\n },\n \"geolocationStoreDefaultLocationStore\": {\n \"description\": \"\",\n \"arguments\": {\n \"type\": \"object\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreLocationResult\"\n }\n },\n \"geolocationStoreGetLocation\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreLocationResultOrUndefined\"\n }\n },\n \"geolocationStoreHasLocation\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreArgs\"\n },\n \"returnType\": {\n \"type\": \"boolean\"\n }\n },\n \"geolocationStorePersistLocation\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreLocationPersistArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreLocationResultIValueData\"\n }\n },\n \"geolocationStoreRemoveLocation\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/GeolocationStoreArgs\"\n },\n \"returnType\": {\n \"type\": \"boolean\"\n }\n }\n }\n }\n }\n}","import { IAgentPlugin } from '@veramo/core'\nimport {\n GeolocationStoreArgs,\n GeolocationStoreClearAllLocationsArgs,\n GeolocationStoreLocation,\n GeolocationStoreLocationPersistArgs,\n GeolocationStoreLocationResult,\n GeolocationStoreLocationResultIValueData,\n GeolocationStoreLocationResultOrUndefined,\n IGeolocationStore,\n schema,\n} from '../index'\n\nimport { IKeyValueStore, KeyValueStore, ValueStoreType } from '@sphereon/ssi-sdk.kv-store-temp'\n\nexport const geolocationStoreMethods: Array<string> = [\n 'geolocationStorePersistLocation',\n 'geolocationStoreHasLocation',\n 'geolocationStoreRemoveLocation',\n 'geolocationStoreClearAllLocations',\n 'geolocationStoreGetLocation',\n 'geolocationStoreDefaultLocationStore',\n]\n\n/**\n * {@inheritDoc IGeolocationStore}\n */\nexport class GeolocationStore implements IAgentPlugin {\n readonly schema = schema.IAnomalyDetectionStore\n private readonly defaultStoreId: string\n private readonly defaultNamespace: string\n private readonly _dnsLookupStore: Map<string, IKeyValueStore<GeolocationStoreLocation>>\n\n readonly methods: IGeolocationStore = {\n geolocationStorePersistLocation: this.geolocationStorePersistLocation.bind(this),\n geolocationStoreHasLocation: this.geolocationStoreHasLocation.bind(this),\n geolocationStoreRemoveLocation: this.geolocationStoreRemoveLocation.bind(this),\n geolocationStoreClearAllLocations: this.geolocationStoreClearAllLocations.bind(this),\n geolocationStoreGetLocation: this.geolocationStoreGetLocation.bind(this),\n geolocationStoreDefaultLocationStore: this.geolocationStoreDefaultLocationStore.bind(this),\n }\n\n constructor(args: {\n defaultStoreId?: string\n defaultNamespace?: string\n dnsLookupStore?: Map<string, IKeyValueStore<GeolocationStoreLocation>> | IKeyValueStore<GeolocationStoreLocation>\n }) {\n this.defaultStoreId = args?.defaultStoreId ?? '_default'\n this.defaultNamespace = args?.defaultNamespace ?? 'anomaly-detection'\n\n if (args?.dnsLookupStore !== undefined && args?.dnsLookupStore !== null && args.dnsLookupStore instanceof Map) {\n this._dnsLookupStore = args.dnsLookupStore\n } else {\n this._dnsLookupStore = new Map().set(\n this.defaultStoreId,\n new KeyValueStore({\n namespace: this.defaultNamespace,\n store: new Map<string, GeolocationStoreLocation>(),\n }),\n )\n }\n }\n\n private async geolocationStorePersistLocation(args: GeolocationStoreLocationPersistArgs): Promise<GeolocationStoreLocationResultIValueData> {\n const storeId = this.storeIdStr(args)\n const namespace = this.namespaceStr(args)\n const { ipOrHostname, locationArgs, ttl } = args\n\n if (args?.validation !== false) {\n // TODO\n }\n const existing = await this.store({ stores: this._dnsLookupStore, storeId }).getAsValueData(\n this.prefix({\n namespace,\n ipOrHostname,\n }),\n )\n if (!existing.value || (existing.value && args?.overwriteExisting !== false)) {\n return await this.store({ stores: this._dnsLookupStore, storeId }).set(\n this.prefix({\n namespace,\n ipOrHostname,\n }),\n locationArgs,\n ttl,\n )\n }\n return existing\n }\n\n private async geolocationStoreHasLocation(args: GeolocationStoreArgs): Promise<boolean> {\n const { storeId, namespace, ipOrHostname } = { ...args }\n return this.store({ stores: this._dnsLookupStore, storeId }).has(this.prefix({ namespace, ipOrHostname }))\n }\n\n private async geolocationStoreRemoveLocation(args: GeolocationStoreArgs): Promise<boolean> {\n const { storeId, namespace, ipOrHostname } = { ...args }\n return this.store({ stores: this._dnsLookupStore, storeId }).delete(this.prefix({ namespace, ipOrHostname }))\n }\n\n private async geolocationStoreClearAllLocations(args: GeolocationStoreClearAllLocationsArgs): Promise<boolean> {\n const { storeId } = { ...args }\n return await this.store({ stores: this._dnsLookupStore, storeId })\n .clear()\n .then(() => true)\n }\n\n private async geolocationStoreGetLocation(args: GeolocationStoreArgs): Promise<GeolocationStoreLocationResultOrUndefined> {\n const { storeId, namespace, ipOrHostname } = { ...args }\n return this.store<GeolocationStoreLocation>({\n stores: this._dnsLookupStore,\n storeId,\n }).get(this.prefix({ namespace, ipOrHostname }))\n }\n\n private store<T extends ValueStoreType>(args: { stores: Map<string, IKeyValueStore<T>>; storeId?: string }): IKeyValueStore<T> {\n const storeId = this.storeIdStr({ storeId: args.storeId })\n const store = args.stores.get(storeId)\n if (!store) {\n throw Error(`Could not get geolocation store: ${storeId}`)\n }\n return store\n }\n\n private storeIdStr({ storeId }: { storeId?: string }): string {\n return storeId ?? this.defaultStoreId\n }\n\n private geolocationStoreDefaultLocationStore(): Promise<GeolocationStoreLocationResult> {\n return Promise.resolve(this.store({ stores: this._dnsLookupStore, storeId: this.defaultStoreId }))\n }\n\n private namespaceStr({ namespace }: { namespace?: string }): string {\n return namespace ?? this.defaultNamespace\n }\n\n private prefix({ namespace, ipOrHostname }: { namespace?: string; ipOrHostname: string }): string {\n return `${this.namespaceStr({ namespace })}:${ipOrHostname}`\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { GeolocationStore, geolocationStoreMethods } from './agent/Ge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A,EAC7De,MAAK,EACLC,KAAK,MAAM,IAAA;EAChB;EAEA,MAAc3B,4BAA4BG,MAAgF;AACxH,UAAM,EAAEQ,SAASF,WAAWK,aAAY,IAAK;MAAE,GAAGX;IAAK;AACvD,WAAO,KAAKO,MAAgC;MAC1CS,QAAQ,KAAK1B;MACbkB;IACF,CAAA,EAAGiB,IAAI,KAAKP,OAAO;MAAEZ;MAAWK;IAAa,CAAA,CAAA;EAC/C;EAEQJ,MAAgCP,MAAuF;AAC7H,UAAMQ,UAAU,KAAKC,WAAW;MAAED,SAASR,KAAKQ;IAAQ,CAAA;AACxD,UAAMD,QAAQP,KAAKgB,OAAOS,IAAIjB,OAAAA;AAC9B,QAAI,CAACD,OAAO;AACV,YAAMmB,MAAM,oCAAoClB,OAAAA,EAAS;IAC3D;AACA,WAAOD;EACT;EAEQE,WAAW,EAAED,QAAO,GAAkC;AAC5D,WAAOA,WAAW,KAAKpB;EACzB;EAEQU,uCAAgF;AACtF,WAAO6B,QAAQC,QAAQ,KAAKrB,MAAM;MAAES,QAAQ,KAAK1B;MAAiBkB,SAAS,KAAKpB;IAAe,CAAA,CAAA;EACjG;EAEQsB,aAAa,EAAEJ,UAAS,GAAoC;AAClE,WAAOA,aAAa,KAAKjB;EAC3B;EAEQ6B,OAAO,EAAEZ,WAAWK,aAAY,GAA0D;AAChG,WAAO,GAAG,KAAKD,aAAa;MAAEJ;IAAU,CAAA,CAAA,IAAMK,YAAAA;EAChD;AACF;;;ACxIA,IAAMkB,SAASC;","names":["KeyValueStore","geolocationStoreMethods","GeolocationStore","schema","IAnomalyDetectionStore","defaultStoreId","defaultNamespace","_dnsLookupStore","methods","geolocationStorePersistLocation","bind","geolocationStoreHasLocation","geolocationStoreRemoveLocation","geolocationStoreClearAllLocations","geolocationStoreGetLocation","geolocationStoreDefaultLocationStore","constructor","args","dnsLookupStore","undefined","Map","set","KeyValueStore","namespace","store","storeId","storeIdStr","namespaceStr","ipOrHostname","locationArgs","ttl","validation","existing","stores","getAsValueData","prefix","value","overwriteExisting","has","delete","clear","then","get","Error","Promise","resolve","schema","require"]}
package/package.json CHANGED
@@ -1,32 +1,44 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.geolocation-store",
3
- "version": "0.32.1-next.54+3b988a2b",
3
+ "version": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
4
4
  "source": "src/index.ts",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "react-native": "./dist/index.js",
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "require": "./dist/index.cjs"
18
+ }
19
+ },
7
20
  "veramo": {
8
21
  "pluginInterfaces": {
9
22
  "IGeolocationStore": "./src/types/IGeolocationStore.ts"
10
23
  }
11
24
  },
12
25
  "scripts": {
13
- "build": "tsc",
14
- "build:clean": "tsc --build --clean && tsc --build",
26
+ "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
15
27
  "generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
16
28
  },
17
29
  "dependencies": {
18
- "@sphereon/ssi-sdk.kv-store-temp": "0.32.1-next.54+3b988a2b"
30
+ "@sphereon/ssi-sdk.kv-store-temp": "0.33.1-feature.jose.vcdm.55+6f02f6f8"
19
31
  },
20
32
  "devDependencies": {
21
- "@sphereon/ssi-sdk.agent-config": "0.32.1-next.54+3b988a2b",
33
+ "@sphereon/ssi-sdk.agent-config": "0.33.1-feature.jose.vcdm.55+6f02f6f8",
22
34
  "@types/node": "^20.17.1",
23
35
  "@veramo/remote-client": "4.2.0",
24
36
  "@veramo/remote-server": "4.2.0",
25
- "typeorm": "^0.3.20"
37
+ "typeorm": "0.3.20"
26
38
  },
27
39
  "files": [
28
- "dist/**/*",
29
- "src/**/*",
40
+ "dist",
41
+ "src",
30
42
  "README.md",
31
43
  "plugin.schema.json",
32
44
  "LICENSE"
@@ -45,6 +57,5 @@
45
57
  "Anomaly Detection",
46
58
  "Anomaly Detection Store"
47
59
  ],
48
- "nx": {},
49
- "gitHead": "3b988a2bb62a7c4534a2670ea3a0985fd93d00f2"
60
+ "gitHead": "6f02f6f83679198268c6e1ea956be24cc1017234"
50
61
  }
@@ -3,6 +3,9 @@
3
3
  "components": {
4
4
  "schemas": {
5
5
  "GeolocationStoreClearAllLocationsArgs": {
6
+ "$ref": "#/components/schemas/Pick<GeolocationStoreArgs,\"storeId\">"
7
+ },
8
+ "Pick<GeolocationStoreArgs,\"storeId\">": {
6
9
  "type": "object",
7
10
  "properties": {
8
11
  "storeId": {
@@ -19,6 +22,7 @@
19
22
  },
20
23
  "IKeyValueStore<GeolocationStoreLocation>": {
21
24
  "type": "object",
25
+ "additionalProperties": false,
22
26
  "description": "A Key Value store is responsible for managing Values identified by keys."
23
27
  },
24
28
  "GeolocationStoreArgs": {
@@ -38,7 +42,8 @@
38
42
  "ipOrHostname",
39
43
  "storeId",
40
44
  "namespace"
41
- ]
45
+ ],
46
+ "additionalProperties": false
42
47
  },
43
48
  "GeolocationStoreLocationResultOrUndefined": {
44
49
  "anyOf": [
@@ -59,10 +64,12 @@
59
64
  "country": {
60
65
  "type": "string"
61
66
  }
62
- }
67
+ },
68
+ "additionalProperties": false
63
69
  },
64
70
  "GeolocationStoreLocationPersistArgs": {
65
71
  "type": "object",
72
+ "additionalProperties": false,
66
73
  "properties": {
67
74
  "locationArgs": {
68
75
  "$ref": "#/components/schemas/GeolocationStoreLocation"
@@ -104,6 +111,7 @@
104
111
  "type": "number"
105
112
  }
106
113
  },
114
+ "additionalProperties": false,
107
115
  "description": "This is how the store will actually store the value. It contains an optional `expires` property, which indicates when the value would expire"
108
116
  }
109
117
  },
@@ -1,30 +0,0 @@
1
- import { IAgentPlugin } from '@veramo/core';
2
- import { GeolocationStoreLocation, IGeolocationStore } from '../index';
3
- import { IKeyValueStore } from '@sphereon/ssi-sdk.kv-store-temp';
4
- export declare const geolocationStoreMethods: Array<string>;
5
- /**
6
- * {@inheritDoc IGeolocationStore}
7
- */
8
- export declare class GeolocationStore implements IAgentPlugin {
9
- readonly schema: any;
10
- private readonly defaultStoreId;
11
- private readonly defaultNamespace;
12
- private readonly _dnsLookupStore;
13
- readonly methods: IGeolocationStore;
14
- constructor(args: {
15
- defaultStoreId?: string;
16
- defaultNamespace?: string;
17
- dnsLookupStore?: Map<string, IKeyValueStore<GeolocationStoreLocation>> | IKeyValueStore<GeolocationStoreLocation>;
18
- });
19
- private geolocationStorePersistLocation;
20
- private geolocationStoreHasLocation;
21
- private geolocationStoreRemoveLocation;
22
- private geolocationStoreClearAllLocations;
23
- private geolocationStoreGetLocation;
24
- private store;
25
- private storeIdStr;
26
- private geolocationStoreDefaultLocationStore;
27
- private namespaceStr;
28
- private prefix;
29
- }
30
- //# sourceMappingURL=GeolocationStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GeolocationStore.d.ts","sourceRoot":"","sources":["../../src/agent/GeolocationStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAGL,wBAAwB,EAKxB,iBAAiB,EAElB,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,cAAc,EAAiC,MAAM,iCAAiC,CAAA;AAE/F,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAOjD,CAAA;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,MAAM,MAAgC;IAC/C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAQ;IACzC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuD;IAEvF,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAOlC;gBAEW,IAAI,EAAE;QAChB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;QACzB,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,wBAAwB,CAAC,CAAC,GAAG,cAAc,CAAC,wBAAwB,CAAC,CAAA;KAClH;YAiBa,+BAA+B;YA2B/B,2BAA2B;YAK3B,8BAA8B;YAK9B,iCAAiC;YAOjC,2BAA2B;IAQzC,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,oCAAoC;IAI5C,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,MAAM;CAGf"}
@@ -1,122 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.GeolocationStore = exports.geolocationStoreMethods = void 0;
13
- const index_1 = require("../index");
14
- const ssi_sdk_kv_store_temp_1 = require("@sphereon/ssi-sdk.kv-store-temp");
15
- exports.geolocationStoreMethods = [
16
- 'geolocationStorePersistLocation',
17
- 'geolocationStoreHasLocation',
18
- 'geolocationStoreRemoveLocation',
19
- 'geolocationStoreClearAllLocations',
20
- 'geolocationStoreGetLocation',
21
- 'geolocationStoreDefaultLocationStore',
22
- ];
23
- /**
24
- * {@inheritDoc IGeolocationStore}
25
- */
26
- class GeolocationStore {
27
- constructor(args) {
28
- var _a, _b;
29
- this.schema = index_1.schema.IAnomalyDetectionStore;
30
- this.methods = {
31
- geolocationStorePersistLocation: this.geolocationStorePersistLocation.bind(this),
32
- geolocationStoreHasLocation: this.geolocationStoreHasLocation.bind(this),
33
- geolocationStoreRemoveLocation: this.geolocationStoreRemoveLocation.bind(this),
34
- geolocationStoreClearAllLocations: this.geolocationStoreClearAllLocations.bind(this),
35
- geolocationStoreGetLocation: this.geolocationStoreGetLocation.bind(this),
36
- geolocationStoreDefaultLocationStore: this.geolocationStoreDefaultLocationStore.bind(this),
37
- };
38
- this.defaultStoreId = (_a = args === null || args === void 0 ? void 0 : args.defaultStoreId) !== null && _a !== void 0 ? _a : '_default';
39
- this.defaultNamespace = (_b = args === null || args === void 0 ? void 0 : args.defaultNamespace) !== null && _b !== void 0 ? _b : 'anomaly-detection';
40
- if ((args === null || args === void 0 ? void 0 : args.dnsLookupStore) !== undefined && (args === null || args === void 0 ? void 0 : args.dnsLookupStore) !== null && args.dnsLookupStore instanceof Map) {
41
- this._dnsLookupStore = args.dnsLookupStore;
42
- }
43
- else {
44
- this._dnsLookupStore = new Map().set(this.defaultStoreId, new ssi_sdk_kv_store_temp_1.KeyValueStore({
45
- namespace: this.defaultNamespace,
46
- store: new Map(),
47
- }));
48
- }
49
- }
50
- geolocationStorePersistLocation(args) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const storeId = this.storeIdStr(args);
53
- const namespace = this.namespaceStr(args);
54
- const { ipOrHostname, locationArgs, ttl } = args;
55
- if ((args === null || args === void 0 ? void 0 : args.validation) !== false) {
56
- // TODO
57
- }
58
- const existing = yield this.store({ stores: this._dnsLookupStore, storeId }).getAsValueData(this.prefix({
59
- namespace,
60
- ipOrHostname,
61
- }));
62
- if (!existing.value || (existing.value && (args === null || args === void 0 ? void 0 : args.overwriteExisting) !== false)) {
63
- return yield this.store({ stores: this._dnsLookupStore, storeId }).set(this.prefix({
64
- namespace,
65
- ipOrHostname,
66
- }), locationArgs, ttl);
67
- }
68
- return existing;
69
- });
70
- }
71
- geolocationStoreHasLocation(args) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const { storeId, namespace, ipOrHostname } = Object.assign({}, args);
74
- return this.store({ stores: this._dnsLookupStore, storeId }).has(this.prefix({ namespace, ipOrHostname }));
75
- });
76
- }
77
- geolocationStoreRemoveLocation(args) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- const { storeId, namespace, ipOrHostname } = Object.assign({}, args);
80
- return this.store({ stores: this._dnsLookupStore, storeId }).delete(this.prefix({ namespace, ipOrHostname }));
81
- });
82
- }
83
- geolocationStoreClearAllLocations(args) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const { storeId } = Object.assign({}, args);
86
- return yield this.store({ stores: this._dnsLookupStore, storeId })
87
- .clear()
88
- .then(() => true);
89
- });
90
- }
91
- geolocationStoreGetLocation(args) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const { storeId, namespace, ipOrHostname } = Object.assign({}, args);
94
- return this.store({
95
- stores: this._dnsLookupStore,
96
- storeId,
97
- }).get(this.prefix({ namespace, ipOrHostname }));
98
- });
99
- }
100
- store(args) {
101
- const storeId = this.storeIdStr({ storeId: args.storeId });
102
- const store = args.stores.get(storeId);
103
- if (!store) {
104
- throw Error(`Could not get geolocation store: ${storeId}`);
105
- }
106
- return store;
107
- }
108
- storeIdStr({ storeId }) {
109
- return storeId !== null && storeId !== void 0 ? storeId : this.defaultStoreId;
110
- }
111
- geolocationStoreDefaultLocationStore() {
112
- return Promise.resolve(this.store({ stores: this._dnsLookupStore, storeId: this.defaultStoreId }));
113
- }
114
- namespaceStr({ namespace }) {
115
- return namespace !== null && namespace !== void 0 ? namespace : this.defaultNamespace;
116
- }
117
- prefix({ namespace, ipOrHostname }) {
118
- return `${this.namespaceStr({ namespace })}:${ipOrHostname}`;
119
- }
120
- }
121
- exports.GeolocationStore = GeolocationStore;
122
- //# sourceMappingURL=GeolocationStore.js.map