@sphereon/ssi-sdk.geolocation-store 0.33.1-next.3 → 0.33.1-next.68

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,324 @@
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: ["storeId"],
26
+ additionalProperties: false
27
+ },
28
+ GeolocationStoreLocationResult: {
29
+ $ref: "#/components/schemas/IKeyValueStore<GeolocationStoreLocation>"
30
+ },
31
+ "IKeyValueStore<GeolocationStoreLocation>": {
32
+ type: "object",
33
+ additionalProperties: false,
34
+ description: "A Key Value store is responsible for managing Values identified by keys."
35
+ },
36
+ GeolocationStoreArgs: {
37
+ type: "object",
38
+ properties: {
39
+ ipOrHostname: {
40
+ type: "string"
41
+ },
42
+ storeId: {
43
+ type: "string"
44
+ },
45
+ namespace: {
46
+ type: "string"
47
+ }
48
+ },
49
+ required: ["ipOrHostname", "storeId", "namespace"],
50
+ additionalProperties: false
51
+ },
52
+ GeolocationStoreLocationResultOrUndefined: {
53
+ anyOf: [
54
+ {
55
+ $ref: "#/components/schemas/GeolocationStoreLocation"
56
+ },
57
+ {
58
+ not: {}
59
+ }
60
+ ]
61
+ },
62
+ GeolocationStoreLocation: {
63
+ type: "object",
64
+ properties: {
65
+ continent: {
66
+ type: "string"
67
+ },
68
+ country: {
69
+ type: "string"
70
+ }
71
+ },
72
+ additionalProperties: false
73
+ },
74
+ GeolocationStoreLocationPersistArgs: {
75
+ type: "object",
76
+ additionalProperties: false,
77
+ properties: {
78
+ locationArgs: {
79
+ $ref: "#/components/schemas/GeolocationStoreLocation"
80
+ },
81
+ ipOrHostname: {
82
+ type: "string"
83
+ },
84
+ overwriteExisting: {
85
+ type: "boolean"
86
+ },
87
+ validation: {
88
+ type: "boolean"
89
+ },
90
+ ttl: {
91
+ type: "number"
92
+ },
93
+ storeId: {
94
+ type: "string"
95
+ },
96
+ namespace: {
97
+ type: "string"
98
+ }
99
+ },
100
+ required: ["ipOrHostname", "locationArgs"]
101
+ },
102
+ GeolocationStoreLocationResultIValueData: {
103
+ $ref: "#/components/schemas/IValueData<GeolocationStoreLocation>"
104
+ },
105
+ "IValueData<GeolocationStoreLocation>": {
106
+ type: "object",
107
+ properties: {
108
+ value: {
109
+ $ref: "#/components/schemas/GeolocationStoreLocation"
110
+ },
111
+ expires: {
112
+ type: "number"
113
+ }
114
+ },
115
+ additionalProperties: false,
116
+ description: "This is how the store will actually store the value. It contains an optional `expires` property, which indicates when the value would expire"
117
+ }
118
+ },
119
+ methods: {
120
+ geolocationStoreClearAllLocations: {
121
+ description: "",
122
+ arguments: {
123
+ $ref: "#/components/schemas/GeolocationStoreClearAllLocationsArgs"
124
+ },
125
+ returnType: {
126
+ type: "boolean"
127
+ }
128
+ },
129
+ geolocationStoreDefaultLocationStore: {
130
+ description: "",
131
+ arguments: {
132
+ type: "object"
133
+ },
134
+ returnType: {
135
+ $ref: "#/components/schemas/GeolocationStoreLocationResult"
136
+ }
137
+ },
138
+ geolocationStoreGetLocation: {
139
+ description: "",
140
+ arguments: {
141
+ $ref: "#/components/schemas/GeolocationStoreArgs"
142
+ },
143
+ returnType: {
144
+ $ref: "#/components/schemas/GeolocationStoreLocationResultOrUndefined"
145
+ }
146
+ },
147
+ geolocationStoreHasLocation: {
148
+ description: "",
149
+ arguments: {
150
+ $ref: "#/components/schemas/GeolocationStoreArgs"
151
+ },
152
+ returnType: {
153
+ type: "boolean"
154
+ }
155
+ },
156
+ geolocationStorePersistLocation: {
157
+ description: "",
158
+ arguments: {
159
+ $ref: "#/components/schemas/GeolocationStoreLocationPersistArgs"
160
+ },
161
+ returnType: {
162
+ $ref: "#/components/schemas/GeolocationStoreLocationResultIValueData"
163
+ }
164
+ },
165
+ geolocationStoreRemoveLocation: {
166
+ description: "",
167
+ arguments: {
168
+ $ref: "#/components/schemas/GeolocationStoreArgs"
169
+ },
170
+ returnType: {
171
+ type: "boolean"
172
+ }
173
+ }
174
+ }
175
+ }
176
+ }
177
+ };
178
+ }
179
+ });
180
+
181
+ // src/agent/GeolocationStore.ts
182
+ import { KeyValueStore } from "@sphereon/ssi-sdk.kv-store-temp";
183
+ var geolocationStoreMethods = [
184
+ "geolocationStorePersistLocation",
185
+ "geolocationStoreHasLocation",
186
+ "geolocationStoreRemoveLocation",
187
+ "geolocationStoreClearAllLocations",
188
+ "geolocationStoreGetLocation",
189
+ "geolocationStoreDefaultLocationStore"
190
+ ];
191
+ var GeolocationStore = class {
192
+ static {
193
+ __name(this, "GeolocationStore");
194
+ }
195
+ schema = schema.IAnomalyDetectionStore;
196
+ defaultStoreId;
197
+ defaultNamespace;
198
+ _dnsLookupStore;
199
+ methods = {
200
+ geolocationStorePersistLocation: this.geolocationStorePersistLocation.bind(this),
201
+ geolocationStoreHasLocation: this.geolocationStoreHasLocation.bind(this),
202
+ geolocationStoreRemoveLocation: this.geolocationStoreRemoveLocation.bind(this),
203
+ geolocationStoreClearAllLocations: this.geolocationStoreClearAllLocations.bind(this),
204
+ geolocationStoreGetLocation: this.geolocationStoreGetLocation.bind(this),
205
+ geolocationStoreDefaultLocationStore: this.geolocationStoreDefaultLocationStore.bind(this)
206
+ };
207
+ constructor(args) {
208
+ this.defaultStoreId = args?.defaultStoreId ?? "_default";
209
+ this.defaultNamespace = args?.defaultNamespace ?? "anomaly-detection";
210
+ if (args?.dnsLookupStore !== void 0 && args?.dnsLookupStore !== null && args.dnsLookupStore instanceof Map) {
211
+ this._dnsLookupStore = args.dnsLookupStore;
212
+ } else {
213
+ this._dnsLookupStore = (/* @__PURE__ */ new Map()).set(this.defaultStoreId, new KeyValueStore({
214
+ namespace: this.defaultNamespace,
215
+ store: /* @__PURE__ */ new Map()
216
+ }));
217
+ }
218
+ }
219
+ async geolocationStorePersistLocation(args) {
220
+ const storeId = this.storeIdStr(args);
221
+ const namespace = this.namespaceStr(args);
222
+ const { ipOrHostname, locationArgs, ttl } = args;
223
+ if (args?.validation !== false) {
224
+ }
225
+ const existing = await this.store({
226
+ stores: this._dnsLookupStore,
227
+ storeId
228
+ }).getAsValueData(this.prefix({
229
+ namespace,
230
+ ipOrHostname
231
+ }));
232
+ if (!existing.value || existing.value && args?.overwriteExisting !== false) {
233
+ return await this.store({
234
+ stores: this._dnsLookupStore,
235
+ storeId
236
+ }).set(this.prefix({
237
+ namespace,
238
+ ipOrHostname
239
+ }), locationArgs, ttl);
7
240
  }
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);
241
+ return existing;
242
+ }
243
+ async geolocationStoreHasLocation(args) {
244
+ const { storeId, namespace, ipOrHostname } = {
245
+ ...args
246
+ };
247
+ return this.store({
248
+ stores: this._dnsLookupStore,
249
+ storeId
250
+ }).has(this.prefix({
251
+ namespace,
252
+ ipOrHostname
253
+ }));
254
+ }
255
+ async geolocationStoreRemoveLocation(args) {
256
+ const { storeId, namespace, ipOrHostname } = {
257
+ ...args
258
+ };
259
+ return this.store({
260
+ stores: this._dnsLookupStore,
261
+ storeId
262
+ }).delete(this.prefix({
263
+ namespace,
264
+ ipOrHostname
265
+ }));
266
+ }
267
+ async geolocationStoreClearAllLocations(args) {
268
+ const { storeId } = {
269
+ ...args
270
+ };
271
+ return await this.store({
272
+ stores: this._dnsLookupStore,
273
+ storeId
274
+ }).clear().then(() => true);
275
+ }
276
+ async geolocationStoreGetLocation(args) {
277
+ const { storeId, namespace, ipOrHostname } = {
278
+ ...args
279
+ };
280
+ return this.store({
281
+ stores: this._dnsLookupStore,
282
+ storeId
283
+ }).get(this.prefix({
284
+ namespace,
285
+ ipOrHostname
286
+ }));
287
+ }
288
+ store(args) {
289
+ const storeId = this.storeIdStr({
290
+ storeId: args.storeId
291
+ });
292
+ const store = args.stores.get(storeId);
293
+ if (!store) {
294
+ throw Error(`Could not get geolocation store: ${storeId}`);
295
+ }
296
+ return store;
297
+ }
298
+ storeIdStr({ storeId }) {
299
+ return storeId ?? this.defaultStoreId;
300
+ }
301
+ geolocationStoreDefaultLocationStore() {
302
+ return Promise.resolve(this.store({
303
+ stores: this._dnsLookupStore,
304
+ storeId: this.defaultStoreId
305
+ }));
306
+ }
307
+ namespaceStr({ namespace }) {
308
+ return namespace ?? this.defaultNamespace;
309
+ }
310
+ prefix({ namespace, ipOrHostname }) {
311
+ return `${this.namespaceStr({
312
+ namespace
313
+ })}:${ipOrHostname}`;
314
+ }
315
+ };
316
+
317
+ // src/index.ts
318
+ var schema = require_plugin_schema();
319
+ export {
320
+ GeolocationStore,
321
+ geolocationStoreMethods,
322
+ schema
15
323
  };
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
324
  //# 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\": [\"storeId\"],\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\": [\"ipOrHostname\", \"storeId\", \"namespace\"],\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\": [\"ipOrHostname\", \"locationArgs\"]\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}\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/GeolocationStore'\nexport * from './types/IGeolocationStore'\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,mBAAqB;AAAA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AGX;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.33.1-next.3+fd1a6fba",
3
+ "version": "0.33.1-next.68+b6c8b366",
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.33.1-next.3+fd1a6fba"
30
+ "@sphereon/ssi-sdk.kv-store-temp": "0.33.1-next.68+b6c8b366"
19
31
  },
20
32
  "devDependencies": {
21
- "@sphereon/ssi-sdk.agent-config": "0.33.1-next.3+fd1a6fba",
33
+ "@sphereon/ssi-sdk.agent-config": "0.33.1-next.68+b6c8b366",
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.21"
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": "fd1a6fba306a83a73ff7c531db87fa207dbf436d"
60
+ "gitHead": "b6c8b36636fa3777494f55860d6a75f2e5a5611e"
50
61
  }
@@ -3,15 +3,16 @@
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": {
9
12
  "type": "string"
10
13
  }
11
14
  },
12
- "required": [
13
- "storeId"
14
- ],
15
+ "required": ["storeId"],
15
16
  "additionalProperties": false
16
17
  },
17
18
  "GeolocationStoreLocationResult": {
@@ -19,6 +20,7 @@
19
20
  },
20
21
  "IKeyValueStore<GeolocationStoreLocation>": {
21
22
  "type": "object",
23
+ "additionalProperties": false,
22
24
  "description": "A Key Value store is responsible for managing Values identified by keys."
23
25
  },
24
26
  "GeolocationStoreArgs": {
@@ -34,11 +36,8 @@
34
36
  "type": "string"
35
37
  }
36
38
  },
37
- "required": [
38
- "ipOrHostname",
39
- "storeId",
40
- "namespace"
41
- ]
39
+ "required": ["ipOrHostname", "storeId", "namespace"],
40
+ "additionalProperties": false
42
41
  },
43
42
  "GeolocationStoreLocationResultOrUndefined": {
44
43
  "anyOf": [
@@ -59,10 +58,12 @@
59
58
  "country": {
60
59
  "type": "string"
61
60
  }
62
- }
61
+ },
62
+ "additionalProperties": false
63
63
  },
64
64
  "GeolocationStoreLocationPersistArgs": {
65
65
  "type": "object",
66
+ "additionalProperties": false,
66
67
  "properties": {
67
68
  "locationArgs": {
68
69
  "$ref": "#/components/schemas/GeolocationStoreLocation"
@@ -86,10 +87,7 @@
86
87
  "type": "string"
87
88
  }
88
89
  },
89
- "required": [
90
- "ipOrHostname",
91
- "locationArgs"
92
- ]
90
+ "required": ["ipOrHostname", "locationArgs"]
93
91
  },
94
92
  "GeolocationStoreLocationResultIValueData": {
95
93
  "$ref": "#/components/schemas/IValueData<GeolocationStoreLocation>"
@@ -104,6 +102,7 @@
104
102
  "type": "number"
105
103
  }
106
104
  },
105
+ "additionalProperties": false,
107
106
  "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
107
  }
109
108
  },
@@ -165,4 +164,4 @@
165
164
  }
166
165
  }
167
166
  }
168
- }
167
+ }
@@ -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"}