@sphereon/ssi-sdk.anomaly-detection 0.30.2-fix.367 → 0.30.2-fix.393

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/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ---
14
14
 
15
- A Veramo anomaly detection plugin. This plugin identifies the location of an URL
15
+ A Sphereon anomaly detection plugin. This plugin identifies the location of an URL
16
16
 
17
17
  ## Available functions
18
18
 
@@ -38,14 +38,14 @@ const agent = createAgent<IAnomalyDetection>({
38
38
 
39
39
  ```typescript
40
40
  const result = await agent.lookupLocation({
41
- ipOrHostname: '2001:0000:130F:0000:0000:09C0:876A:130B'
41
+ ipOrHostname: '2001:0000:130F:0000:0000:09C0:876A:130B',
42
42
  })
43
43
  ```
44
44
 
45
45
  ## Installation
46
46
 
47
47
  ```shell
48
- yarn add @sphereon/ssi-sdk.contact-manager
48
+ yarn add @sphereon/ssi-sdk.anomaly-detection
49
49
  ```
50
50
 
51
51
  ## Build
@@ -1 +1 @@
1
- {"version":3,"file":"AnomalyDetection.d.ts","sourceRoot":"","sources":["../../src/agent/AnomalyDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAA;AACzC,OAAO,EACL,iBAAiB,EAIlB,MAAM,UAAU,CAAA;AAGjB,KAAK,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAExD,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAAsB,CAAA;AAExE;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,MAAM,MAA2B;IAC1C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAa;IACxC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAElC;gBAEW,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,WAAW,CAAA;KAAE;YASxD,8BAA8B;YA+B9B,UAAU;CA0BzB"}
1
+ {"version":3,"file":"AnomalyDetection.d.ts","sourceRoot":"","sources":["../../src/agent/AnomalyDetection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAGL,iBAAiB,EAGlB,MAAM,UAAU,CAAA;AAEjB,KAAK,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAExD,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAAsB,CAAA;AAExE;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,MAAM,MAA2B;IAC1C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAa;IACxC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAElC;gBAEW,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,WAAW,CAAA;KAAE;YASxD,8BAA8B;YAiC9B,UAAU;CA0BzB"}
@@ -10,8 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AnomalyDetection = exports.anomalyDetectionMethods = void 0;
13
- const index_1 = require("../index");
13
+ const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
14
14
  const mmdb_lib_1 = require("mmdb-lib");
15
+ const index_1 = require("../index");
15
16
  exports.anomalyDetectionMethods = ['lookupLocation'];
16
17
  /**
17
18
  * {@inheritDoc IAnomalyDetection}
@@ -20,7 +21,7 @@ class AnomalyDetection {
20
21
  constructor(args) {
21
22
  this.schema = index_1.schema.IAnomalyDetection;
22
23
  this.methods = {
23
- anomalyDetectionLookupLocation: this.anomalyDetectionLookupLocation.bind(this),
24
+ anomalyDetectionLookupLocation: this.anomalyDetectionLookupLocation.bind(this)
24
25
  };
25
26
  const { geoIpDB, dnsLookupCallback } = Object.assign({}, args);
26
27
  if (geoIpDB === undefined || geoIpDB === null) {
@@ -31,7 +32,7 @@ class AnomalyDetection {
31
32
  }
32
33
  anomalyDetectionLookupLocation(args, context) {
33
34
  return __awaiter(this, void 0, void 0, function* () {
34
- var _a, _b, _c, _d;
35
+ var _a, _b;
35
36
  const { ipOrHostname, storeId, namespace } = Object.assign({}, args);
36
37
  const reader = new mmdb_lib_1.Reader(this.db);
37
38
  const ipv4Reg = '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
@@ -46,16 +47,15 @@ class AnomalyDetection {
46
47
  }
47
48
  const lookupResult = {
48
49
  continent: (_a = result === null || result === void 0 ? void 0 : result.continent) === null || _a === void 0 ? void 0 : _a.code,
49
- country: (_b = result === null || result === void 0 ? void 0 : result.country) === null || _b === void 0 ? void 0 : _b.iso_code,
50
+ country: (_b = result === null || result === void 0 ? void 0 : result.country) === null || _b === void 0 ? void 0 : _b.iso_code
50
51
  };
51
- if (((_c = context.agent) === null || _c === void 0 ? void 0 : _c.anomalyDetectionStorePersistLocation) !== undefined && ((_d = context.agent) === null || _d === void 0 ? void 0 : _d.anomalyDetectionStorePersistLocation) !== null) {
52
- yield context.agent.anomalyDetectionStorePersistLocation({
52
+ if ((0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'geolocationStorePersistLocation'))
53
+ yield context.agent.geolocationStorePersistLocation({
53
54
  namespace,
54
55
  storeId,
55
56
  ipOrHostname,
56
- locationArgs: lookupResult,
57
+ locationArgs: lookupResult
57
58
  });
58
- }
59
59
  return Promise.resolve(lookupResult);
60
60
  });
61
61
  }
@@ -1 +1 @@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CAAC,CAAA;gBAChB,MAAM,IAAI,KAAK,CACb,kKAAkK,CAAC,CAAC,OAAO,EAAE,CAC9K,CAAA;YACH,CAAC;YAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAmC,EAAE,OAAe,EAAE,MAAc,EAAE,EAAE;oBAC5F,IAAI,KAAK,EAAE,CAAC;wBACV,MAAM,CAAC,KAAK,CAAC,CAAA;wBACb,OAAM;oBACR,CAAC;oBACD,OAAO,CAAC,OAAO,CAAC,CAAA;gBAClB,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AA5ED,4CA4EC"}
@@ -1,7 +1,7 @@
1
- import { AnomalyDetectionStoreArgs } from '@sphereon/ssi-sdk.anomaly-detection-store';
1
+ import { GeolocationStoreArgs } from '@sphereon/ssi-sdk.geolocation-store';
2
2
  import { IAgentContext } from '@veramo/core';
3
3
  import { IAgentPlugin } from '@veramo/core';
4
- import { IAnomalyDetectionStore } from '@sphereon/ssi-sdk.anomaly-detection-store';
4
+ import { IGeolocationStore } from '@sphereon/ssi-sdk.geolocation-store';
5
5
  import { IPluginMethodMap } from '@veramo/core';
6
6
 
7
7
  /**
@@ -20,7 +20,7 @@ export declare class AnomalyDetection implements IAgentPlugin {
20
20
  private resolveDns;
21
21
  }
22
22
 
23
- export declare type AnomalyDetectionLookupLocationArgs = PartialBy<AnomalyDetectionStoreArgs, 'storeId' | 'namespace'>;
23
+ export declare type AnomalyDetectionLookupLocationArgs = PartialBy<GeolocationStoreArgs, 'storeId' | 'namespace'>;
24
24
 
25
25
  export declare type AnomalyDetectionLookupLocationResult = {
26
26
  continent?: string;
@@ -35,7 +35,7 @@ export declare interface IAnomalyDetection extends IPluginMethodMap {
35
35
  anomalyDetectionLookupLocation(args: AnomalyDetectionLookupLocationArgs, context: IRequiredContext): Promise<AnomalyDetectionLookupLocationResult>;
36
36
  }
37
37
 
38
- export declare type IRequiredContext = IAgentContext<IAnomalyDetectionStore>;
38
+ export declare type IRequiredContext = IAgentContext<IGeolocationStore>;
39
39
 
40
40
  export declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
41
41
 
@@ -1,13 +1,13 @@
1
1
  import { IAgentContext, IPluginMethodMap } from '@veramo/core';
2
- import { AnomalyDetectionStoreArgs, IAnomalyDetectionStore } from "@sphereon/ssi-sdk.anomaly-detection-store";
2
+ import { GeolocationStoreArgs, IGeolocationStore } from "@sphereon/ssi-sdk.geolocation-store";
3
3
  export interface IAnomalyDetection extends IPluginMethodMap {
4
4
  anomalyDetectionLookupLocation(args: AnomalyDetectionLookupLocationArgs, context: IRequiredContext): Promise<AnomalyDetectionLookupLocationResult>;
5
5
  }
6
6
  export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
7
- export type AnomalyDetectionLookupLocationArgs = PartialBy<AnomalyDetectionStoreArgs, 'storeId' | 'namespace'>;
7
+ export type AnomalyDetectionLookupLocationArgs = PartialBy<GeolocationStoreArgs, 'storeId' | 'namespace'>;
8
8
  export type AnomalyDetectionLookupLocationResult = {
9
9
  continent?: string;
10
10
  country?: string;
11
11
  };
12
- export type IRequiredContext = IAgentContext<IAnomalyDetectionStore>;
12
+ export type IRequiredContext = IAgentContext<IGeolocationStore>;
13
13
  //# sourceMappingURL=IAnomalyDetection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IAnomalyDetection.d.ts","sourceRoot":"","sources":["../../src/types/IAnomalyDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAC,yBAAyB,EAAE,sBAAsB,EAAC,MAAM,2CAA2C,CAAC;AAE5G,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,8BAA8B,CAAC,IAAI,EAAE,kCAAkC,EAAE,O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,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.anomaly-detection",
3
- "version": "0.30.2-fix.367+610d99ea",
3
+ "version": "0.30.2-fix.393+78916488",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,8 +15,8 @@
15
15
  "generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
16
16
  },
17
17
  "dependencies": {
18
- "@sphereon/ssi-sdk.anomaly-detection-store": "0.30.2-fix.367+610d99ea",
19
- "@sphereon/ssi-sdk.kv-store-temp": "0.30.2-fix.367+610d99ea",
18
+ "@sphereon/ssi-sdk.geolocation-store": "0.30.2-fix.393+78916488",
19
+ "@sphereon/ssi-sdk.kv-store-temp": "0.30.2-fix.393+78916488",
20
20
  "cross-fetch": "^3.1.8",
21
21
  "debug": "^4.3.5",
22
22
  "dns-query": "^0.11.2",
@@ -24,7 +24,7 @@
24
24
  "typeorm": "^0.3.20"
25
25
  },
26
26
  "devDependencies": {
27
- "@sphereon/ssi-sdk.agent-config": "0.30.2-fix.367+610d99ea",
27
+ "@sphereon/ssi-sdk.agent-config": "0.30.2-fix.393+78916488",
28
28
  "@types/node": "^20.17.1",
29
29
  "@veramo/remote-client": "4.2.0",
30
30
  "@veramo/remote-server": "4.2.0"
@@ -50,5 +50,5 @@
50
50
  "Anomaly Detection"
51
51
  ],
52
52
  "nx": {},
53
- "gitHead": "610d99ea0034348aeffd778b36ecefb81863bd18"
53
+ "gitHead": "7891648801584cccc16cc525127df7063c7ed806"
54
54
  }
@@ -3,9 +3,9 @@
3
3
  "components": {
4
4
  "schemas": {
5
5
  "AnomalyDetectionLookupLocationArgs": {
6
- "$ref": "#/components/schemas/PartialBy<AnomalyDetectionStoreArgs,(\"storeId\"|\"namespace\")>"
6
+ "$ref": "#/components/schemas/PartialBy<GeolocationStoreArgs,(\"storeId\"|\"namespace\")>"
7
7
  },
8
- "PartialBy<AnomalyDetectionStoreArgs,(\"storeId\"|\"namespace\")>": {
8
+ "PartialBy<GeolocationStoreArgs,(\"storeId\"|\"namespace\")>": {
9
9
  "type": "object",
10
10
  "properties": {
11
11
  "storeId": {
@@ -1,11 +1,13 @@
1
- import {IAgentPlugin} from '@veramo/core'
1
+ import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
2
+ import { IAgentPlugin } from '@veramo/core'
3
+ import { CountryResponse, Reader } from 'mmdb-lib'
2
4
  import {
3
- IAnomalyDetection,
4
5
  AnomalyDetectionLookupLocationArgs,
5
- schema,
6
- AnomalyDetectionLookupLocationResult, IRequiredContext
6
+ AnomalyDetectionLookupLocationResult,
7
+ IAnomalyDetection,
8
+ IRequiredContext,
9
+ schema
7
10
  } from '../index'
8
- import {CountryResponse, Reader} from 'mmdb-lib'
9
11
 
10
12
  type DnsLookupFn = (hostname: string) => Promise<string>
11
13
 
@@ -19,7 +21,7 @@ export class AnomalyDetection implements IAgentPlugin {
19
21
  private readonly db: Buffer
20
22
  private readonly dnsLookup?: DnsLookupFn
21
23
  readonly methods: IAnomalyDetection = {
22
- anomalyDetectionLookupLocation: this.anomalyDetectionLookupLocation.bind(this),
24
+ anomalyDetectionLookupLocation: this.anomalyDetectionLookupLocation.bind(this)
23
25
  }
24
26
 
25
27
  constructor(args: { geoIpDB: Buffer; dnsLookupCallback?: DnsLookupFn }) {
@@ -31,7 +33,10 @@ export class AnomalyDetection implements IAgentPlugin {
31
33
  this.dnsLookup = dnsLookupCallback
32
34
  }
33
35
 
34
- private async anomalyDetectionLookupLocation(args: AnomalyDetectionLookupLocationArgs, context: IRequiredContext): Promise<AnomalyDetectionLookupLocationResult> {
36
+ private async anomalyDetectionLookupLocation(
37
+ args: AnomalyDetectionLookupLocationArgs,
38
+ context: IRequiredContext
39
+ ): Promise<AnomalyDetectionLookupLocationResult> {
35
40
  const { ipOrHostname, storeId, namespace } = { ...args }
36
41
  const reader = new Reader<CountryResponse>(this.db)
37
42
  const ipv4Reg = '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
@@ -48,17 +53,16 @@ export class AnomalyDetection implements IAgentPlugin {
48
53
 
49
54
  const lookupResult = {
50
55
  continent: result?.continent?.code,
51
- country: result?.country?.iso_code,
56
+ country: result?.country?.iso_code
52
57
  }
53
58
 
54
- if (context.agent?.anomalyDetectionStorePersistLocation !== undefined && context.agent?.anomalyDetectionStorePersistLocation !== null) {
55
- await context.agent.anomalyDetectionStorePersistLocation({
59
+ if (contextHasPlugin(context, 'geolocationStorePersistLocation'))
60
+ await context.agent.geolocationStorePersistLocation({
56
61
  namespace,
57
62
  storeId,
58
63
  ipOrHostname,
59
- locationArgs: lookupResult,
64
+ locationArgs: lookupResult
60
65
  })
61
- }
62
66
  return Promise.resolve(lookupResult)
63
67
  }
64
68
 
@@ -74,7 +78,7 @@ export class AnomalyDetection implements IAgentPlugin {
74
78
  } catch (e) {
75
79
  console.error(e)
76
80
  throw new Error(
77
- `DNS resolution not available on this platform, use the dnsLookupCallback in the AnomalyDetection constructor to implement DNS resolution for your platform.\r\n${e.message}`,
81
+ `DNS resolution not available on this platform, use the dnsLookupCallback in the AnomalyDetection constructor to implement DNS resolution for your platform.\r\n${e.message}`
78
82
  )
79
83
  }
80
84
 
@@ -1,5 +1,5 @@
1
1
  import {IAgentContext, IPluginMethodMap} from '@veramo/core'
2
- import {AnomalyDetectionStoreArgs, IAnomalyDetectionStore} from "@sphereon/ssi-sdk.anomaly-detection-store";
2
+ import {GeolocationStoreArgs, IGeolocationStore} from "@sphereon/ssi-sdk.geolocation-store";
3
3
 
4
4
  export interface IAnomalyDetection extends IPluginMethodMap {
5
5
  anomalyDetectionLookupLocation(args: AnomalyDetectionLookupLocationArgs, context: IRequiredContext): Promise<AnomalyDetectionLookupLocationResult>
@@ -7,11 +7,11 @@ export interface IAnomalyDetection extends IPluginMethodMap {
7
7
 
8
8
  export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
9
9
 
10
- export type AnomalyDetectionLookupLocationArgs = PartialBy<AnomalyDetectionStoreArgs, 'storeId' | 'namespace'>
10
+ export type AnomalyDetectionLookupLocationArgs = PartialBy<GeolocationStoreArgs, 'storeId' | 'namespace'>
11
11
 
12
12
  export type AnomalyDetectionLookupLocationResult = {
13
13
  continent?: string
14
14
  country?: string
15
15
  }
16
16
 
17
- export type IRequiredContext = IAgentContext<IAnomalyDetectionStore>
17
+ export type IRequiredContext = IAgentContext<IGeolocationStore>