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

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.
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"GeolocationStore.js","sourceRoot":"","sources":["../../src/agent/GeolocationStore.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,oCAUiB;AAEjB,2EAA+F;AAElF,QAAA,uBAAuB,GAAkB;IACpD,iCAAiC;IACjC,6BAA6B;IAC7B,gCAAgC;IAChC,mCAAmC;IACnC,6BAA6B;IAC7B,sCAAsC;CACvC,CAAA;AAED;;GAEG;AACH,MAAa,gBAAgB;IAe3B,YAAY,IAIX;;QAlBQ,WAAM,GAAG,cAAM,CAAC,sBAAsB,CAAA;QAKt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,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,UAAU,CAAC,EAAE,OAAO,EAAwB;QAClD,OAAO,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,cAAc,CAAA;IACvC,CAAC;IAEO,oCAAoC;QAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;IACpG,CAAC;IAEO,YAAY,CAAC,EAAE,SAAS,EAA0B;QACxD,OAAO,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,gBAAgB,CAAA;IAC3C,CAAC;IAEO,MAAM,CAAC,EAAE,SAAS,EAAE,YAAY,EAAgD;QACtF,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,YAAY,EAAE,CAAA;IAC9D,CAAC;CACF;AAhHD,4CAgHC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AACpF,cAAc,2BAA2B,CAAA"}
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.5"
9
- }
10
- ]
11
- }
@@ -1,35 +0,0 @@
1
- import { IPluginMethodMap } from '@veramo/core';
2
- import { IKeyValueStore, IValueData } from '@sphereon/ssi-sdk.kv-store-temp';
3
- export interface IGeolocationStore extends IPluginMethodMap {
4
- geolocationStoreDefaultLocationStore(): Promise<GeolocationStoreLocationResult>;
5
- geolocationStorePersistLocation(args: GeolocationStoreLocationPersistArgs): Promise<GeolocationStoreLocationResultIValueData>;
6
- geolocationStoreHasLocation(args: GeolocationStoreArgs): Promise<boolean>;
7
- geolocationStoreRemoveLocation(args: GeolocationStoreArgs): Promise<boolean>;
8
- geolocationStoreClearAllLocations(args: GeolocationStoreClearAllLocationsArgs): Promise<boolean>;
9
- geolocationStoreGetLocation(args: GeolocationStoreArgs): Promise<GeolocationStoreLocationResultOrUndefined>;
10
- }
11
- export type GeolocationStoreLocation = {
12
- continent?: string;
13
- country?: string;
14
- };
15
- export type GeolocationStorePersistArgs = {
16
- ipOrHostname: string;
17
- overwriteExisting?: boolean;
18
- validation?: boolean;
19
- ttl?: number;
20
- storeId?: string;
21
- namespace?: string;
22
- };
23
- export type GeolocationStoreArgs = {
24
- ipOrHostname: string;
25
- storeId: string;
26
- namespace: string;
27
- };
28
- export type GeolocationStoreClearAllLocationsArgs = Pick<GeolocationStoreArgs, 'storeId'>;
29
- export type GeolocationStoreLocationPersistArgs = GeolocationStorePersistArgs & {
30
- locationArgs: GeolocationStoreLocation;
31
- };
32
- export type GeolocationStoreLocationResult = IKeyValueStore<GeolocationStoreLocation>;
33
- export type GeolocationStoreLocationResultOrUndefined = GeolocationStoreLocation | undefined;
34
- export type GeolocationStoreLocationResultIValueData = IValueData<GeolocationStoreLocation>;
35
- //# sourceMappingURL=IGeolocationStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IGeolocationStore.d.ts","sourceRoot":"","sources":["../../src/types/IGeolocationStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE5E,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,oCAAoC,IAAI,OAAO,CAAC,8BAA8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wCAAwC,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAA"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IGeolocationStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IGeolocationStore.js","sourceRoot":"","sources":["../../src/types/IGeolocationStore.ts"],"names":[],"mappings":""}