@opensanctions/followthemoney 3.8.4 → 4.0.0

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,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('crypto')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'crypto'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.followthemoney = {}, global.crypto));
5
- })(this, (function (exports, crypto$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.followthemoney = {}));
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  /**
8
8
  * An entity proxy which provides simplified access to the
@@ -213,6 +213,94 @@
213
213
  }
214
214
  }
215
215
 
216
+ /******************************************************************************
217
+ Copyright (c) Microsoft Corporation.
218
+
219
+ Permission to use, copy, modify, and/or distribute this software for any
220
+ purpose with or without fee is hereby granted.
221
+
222
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
223
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
224
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
225
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
226
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
227
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
228
+ PERFORMANCE OF THIS SOFTWARE.
229
+ ***************************************************************************** */
230
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
231
+
232
+
233
+ function __awaiter(thisArg, _arguments, P, generator) {
234
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
235
+ return new (P || (P = Promise))(function (resolve, reject) {
236
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
237
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
238
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
239
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
240
+ });
241
+ }
242
+
243
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
244
+ var e = new Error(message);
245
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
246
+ };
247
+
248
+ const byteToHex = [];
249
+ for (let i = 0; i < 256; ++i) {
250
+ byteToHex.push((i + 0x100).toString(16).slice(1));
251
+ }
252
+ function unsafeStringify(arr, offset = 0) {
253
+ return (byteToHex[arr[offset + 0]] +
254
+ byteToHex[arr[offset + 1]] +
255
+ byteToHex[arr[offset + 2]] +
256
+ byteToHex[arr[offset + 3]] +
257
+ '-' +
258
+ byteToHex[arr[offset + 4]] +
259
+ byteToHex[arr[offset + 5]] +
260
+ '-' +
261
+ byteToHex[arr[offset + 6]] +
262
+ byteToHex[arr[offset + 7]] +
263
+ '-' +
264
+ byteToHex[arr[offset + 8]] +
265
+ byteToHex[arr[offset + 9]] +
266
+ '-' +
267
+ byteToHex[arr[offset + 10]] +
268
+ byteToHex[arr[offset + 11]] +
269
+ byteToHex[arr[offset + 12]] +
270
+ byteToHex[arr[offset + 13]] +
271
+ byteToHex[arr[offset + 14]] +
272
+ byteToHex[arr[offset + 15]]).toLowerCase();
273
+ }
274
+
275
+ let getRandomValues;
276
+ const rnds8 = new Uint8Array(16);
277
+ function rng() {
278
+ if (!getRandomValues) {
279
+ if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
280
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
281
+ }
282
+ getRandomValues = crypto.getRandomValues.bind(crypto);
283
+ }
284
+ return getRandomValues(rnds8);
285
+ }
286
+
287
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
288
+ var native = { randomUUID };
289
+
290
+ function v4(options, buf, offset) {
291
+ if (native.randomUUID && true && !options) {
292
+ return native.randomUUID();
293
+ }
294
+ options = options || {};
295
+ const rnds = options.random ?? options.rng?.() ?? rng();
296
+ if (rnds.length < 16) {
297
+ throw new Error('Random bytes length must be >= 16');
298
+ }
299
+ rnds[6] = (rnds[6] & 0x0f) | 0x40;
300
+ rnds[8] = (rnds[8] & 0x3f) | 0x80;
301
+ return unsafeStringify(rnds);
302
+ }
303
+
216
304
  /**
217
305
  * Definition of a property, with relevant metadata for type,
218
306
  * labels and other useful criteria.
@@ -431,62 +519,6 @@
431
519
  }
432
520
  PropertyType.ENTITY = 'entity';
433
521
 
434
- const byteToHex = [];
435
- for (let i = 0; i < 256; ++i) {
436
- byteToHex.push((i + 0x100).toString(16).slice(1));
437
- }
438
- function unsafeStringify(arr, offset = 0) {
439
- return (byteToHex[arr[offset + 0]] +
440
- byteToHex[arr[offset + 1]] +
441
- byteToHex[arr[offset + 2]] +
442
- byteToHex[arr[offset + 3]] +
443
- '-' +
444
- byteToHex[arr[offset + 4]] +
445
- byteToHex[arr[offset + 5]] +
446
- '-' +
447
- byteToHex[arr[offset + 6]] +
448
- byteToHex[arr[offset + 7]] +
449
- '-' +
450
- byteToHex[arr[offset + 8]] +
451
- byteToHex[arr[offset + 9]] +
452
- '-' +
453
- byteToHex[arr[offset + 10]] +
454
- byteToHex[arr[offset + 11]] +
455
- byteToHex[arr[offset + 12]] +
456
- byteToHex[arr[offset + 13]] +
457
- byteToHex[arr[offset + 14]] +
458
- byteToHex[arr[offset + 15]]).toLowerCase();
459
- }
460
-
461
- let getRandomValues;
462
- const rnds8 = new Uint8Array(16);
463
- function rng() {
464
- if (!getRandomValues) {
465
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
466
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
467
- }
468
- getRandomValues = crypto.getRandomValues.bind(crypto);
469
- }
470
- return getRandomValues(rnds8);
471
- }
472
-
473
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
474
- var native = { randomUUID };
475
-
476
- function v4(options, buf, offset) {
477
- if (native.randomUUID && true && !options) {
478
- return native.randomUUID();
479
- }
480
- options = options || {};
481
- const rnds = options.random ?? options.rng?.() ?? rng();
482
- if (rnds.length < 16) {
483
- throw new Error('Random bytes length must be >= 16');
484
- }
485
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
486
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
487
- return unsafeStringify(rnds);
488
- }
489
-
490
522
  class Model {
491
523
  constructor(config) {
492
524
  this.schemata = {};
@@ -564,12 +596,14 @@
564
596
  * @param schema Schema name or object
565
597
  */
566
598
  createEntity(schema, namespace) {
567
- const rawId = v4();
568
- const id = namespace ? namespace.sign(rawId) : rawId;
569
- return this.getEntity({
570
- id,
571
- schema: schema,
572
- properties: {}
599
+ return __awaiter(this, void 0, void 0, function* () {
600
+ const rawId = v4();
601
+ const id = namespace ? yield namespace.sign(rawId) : rawId;
602
+ return this.getEntity({
603
+ id,
604
+ schema: schema,
605
+ properties: {}
606
+ });
573
607
  });
574
608
  }
575
609
  }
@@ -583,20 +617,39 @@
583
617
  return id.split(this.separator);
584
618
  }
585
619
  signature(id) {
586
- return crypto$1.createHmac('sha1', this.namespaceKey)
587
- .update(id)
588
- .digest('hex');
620
+ return __awaiter(this, void 0, void 0, function* () {
621
+ // Generate an HMAC signature for the given ID using the namespace key, using
622
+ // SHA-1 as the hashing algorithm and returning the result as a hexadecimal string.
623
+ // Use in-browser crypto library for compatibility with browsers.
624
+ if (!this.namespaceKey.length) {
625
+ return id;
626
+ }
627
+ // Convert strings to ArrayBuffers
628
+ const encoder = new TextEncoder();
629
+ const keyData = encoder.encode(this.namespaceKey);
630
+ const data = encoder.encode(id);
631
+ // Import the key
632
+ const key = yield crypto.subtle.importKey('raw', keyData, { name: 'HMAC', hash: 'SHA-1' }, false, ['sign']);
633
+ // Generate the signature
634
+ const signature = yield crypto.subtle.sign('HMAC', key, data);
635
+ // Convert to hexadecimal string
636
+ const hashArray = Array.from(new Uint8Array(signature));
637
+ const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
638
+ return hashHex;
639
+ });
589
640
  }
590
641
  sign(id) {
591
- const entityId = this.parse(id)[0];
592
- if (!entityId) {
593
- return id;
594
- }
595
- if (!this.namespaceKey.length) {
596
- return entityId;
597
- }
598
- const digest = this.signature(entityId);
599
- return [entityId, digest].join(this.separator);
642
+ return __awaiter(this, void 0, void 0, function* () {
643
+ const entityId = this.parse(id)[0];
644
+ if (!entityId) {
645
+ return id;
646
+ }
647
+ if (!this.namespaceKey.length) {
648
+ return entityId;
649
+ }
650
+ const digest = yield this.signature(entityId);
651
+ return [entityId, digest].join(this.separator);
652
+ });
600
653
  }
601
654
  }
602
655
 
@@ -1509,13 +1562,14 @@
1509
1562
  type: "email"
1510
1563
  },
1511
1564
  ibanMentioned: {
1565
+ format: "iban",
1512
1566
  hidden: true,
1513
1567
  label: "Detected IBANs",
1514
1568
  matchable: true,
1515
1569
  maxLength: 64,
1516
1570
  name: "ibanMentioned",
1517
1571
  qname: "Analyzable:ibanMentioned",
1518
- type: "iban"
1572
+ type: "identifier"
1519
1573
  },
1520
1574
  ipMentioned: {
1521
1575
  hidden: true,
@@ -1601,62 +1655,6 @@
1601
1655
  ]
1602
1656
  }
1603
1657
  },
1604
- Assessment: {
1605
- caption: [
1606
- "name"
1607
- ],
1608
- "extends": [
1609
- "Thing"
1610
- ],
1611
- featured: [
1612
- "name",
1613
- "publishDate",
1614
- "author"
1615
- ],
1616
- label: "Assessment",
1617
- plural: "Assessments",
1618
- properties: {
1619
- assessmentId: {
1620
- label: "Assessment ID",
1621
- maxLength: 1024,
1622
- name: "assessmentId",
1623
- qname: "Assessment:assessmentId",
1624
- type: "string"
1625
- },
1626
- author: {
1627
- label: "Author",
1628
- matchable: true,
1629
- maxLength: 200,
1630
- name: "author",
1631
- qname: "Assessment:author",
1632
- range: "LegalEntity",
1633
- reverse: "authoredAssessments",
1634
- type: "entity"
1635
- },
1636
- publishDate: {
1637
- label: "Date of publishing",
1638
- matchable: true,
1639
- maxLength: 32,
1640
- name: "publishDate",
1641
- qname: "Assessment:publishDate",
1642
- type: "date"
1643
- }
1644
- },
1645
- required: [
1646
- "name"
1647
- ],
1648
- schemata: [
1649
- "Assessment",
1650
- "Thing"
1651
- ],
1652
- temporalExtent: {
1653
- end: [
1654
- ],
1655
- start: [
1656
- "publishDate"
1657
- ]
1658
- }
1659
- },
1660
1658
  Asset: {
1661
1659
  caption: [
1662
1660
  "name"
@@ -1925,12 +1923,13 @@
1925
1923
  type: "entity"
1926
1924
  },
1927
1925
  iban: {
1926
+ format: "iban",
1928
1927
  label: "IBAN",
1929
1928
  matchable: true,
1930
1929
  maxLength: 64,
1931
1930
  name: "iban",
1932
1931
  qname: "BankAccount:iban",
1933
- type: "iban"
1932
+ type: "identifier"
1934
1933
  },
1935
1934
  maxBalance: {
1936
1935
  label: "Maximum balance",
@@ -2451,15 +2450,6 @@
2451
2450
  qname: "Company:fssCode",
2452
2451
  type: "string"
2453
2452
  },
2454
- ibcRuc: {
2455
- deprecated: true,
2456
- label: "ibcRUC",
2457
- matchable: true,
2458
- maxLength: 64,
2459
- name: "ibcRuc",
2460
- qname: "Company:ibcRuc",
2461
- type: "identifier"
2462
- },
2463
2453
  ipoCode: {
2464
2454
  label: "IPO",
2465
2455
  maxLength: 64,
@@ -3135,11 +3125,11 @@
3135
3125
  reverse: "cryptoWallets",
3136
3126
  type: "entity"
3137
3127
  },
3138
- mangingExchange: {
3128
+ managingExchange: {
3139
3129
  label: "Managing exchange",
3140
3130
  maxLength: 1024,
3141
- name: "mangingExchange",
3142
- qname: "CryptoWallet:mangingExchange",
3131
+ name: "managingExchange",
3132
+ qname: "CryptoWallet:managingExchange",
3143
3133
  type: "string"
3144
3134
  },
3145
3135
  privateKey: {
@@ -3511,6 +3501,17 @@
3511
3501
  stub: true,
3512
3502
  type: "entity"
3513
3503
  },
3504
+ provenIntervals: {
3505
+ label: "Derived relationships",
3506
+ matchable: true,
3507
+ maxLength: 200,
3508
+ name: "provenIntervals",
3509
+ qname: "Document:provenIntervals",
3510
+ range: "Interval",
3511
+ reverse: "proof",
3512
+ stub: true,
3513
+ type: "entity"
3514
+ },
3514
3515
  publishedAt: {
3515
3516
  label: "Published on",
3516
3517
  maxLength: 32,
@@ -4580,6 +4581,16 @@
4580
4581
  qname: "Interval:namesMentioned",
4581
4582
  type: "name"
4582
4583
  },
4584
+ proof: {
4585
+ label: "Source document",
4586
+ matchable: true,
4587
+ maxLength: 200,
4588
+ name: "proof",
4589
+ qname: "Interval:proof",
4590
+ range: "Document",
4591
+ reverse: "provenIntervals",
4592
+ type: "entity"
4593
+ },
4583
4594
  publisher: {
4584
4595
  label: "Publishing source",
4585
4596
  maxLength: 1024,
@@ -4687,17 +4698,6 @@
4687
4698
  stub: true,
4688
4699
  type: "entity"
4689
4700
  },
4690
- authoredAssessments: {
4691
- label: "Assessments authored",
4692
- matchable: true,
4693
- maxLength: 200,
4694
- name: "authoredAssessments",
4695
- qname: "LegalEntity:authoredAssessments",
4696
- range: "Assessment",
4697
- reverse: "author",
4698
- stub: true,
4699
- type: "entity"
4700
- },
4701
4701
  bvdId: {
4702
4702
  label: "Bureau van Dijk ID",
4703
4703
  matchable: true,
@@ -5310,6 +5310,16 @@
5310
5310
  qname: "LegalEntity:uniqueEntityId",
5311
5311
  type: "identifier"
5312
5312
  },
5313
+ uscCode: {
5314
+ description: "Unified Social Credit Identifier",
5315
+ format: "uscc",
5316
+ label: "USCC",
5317
+ matchable: true,
5318
+ maxLength: 64,
5319
+ name: "uscCode",
5320
+ qname: "LegalEntity:uscCode",
5321
+ type: "identifier"
5322
+ },
5313
5323
  userAccounts: {
5314
5324
  label: "User accounts",
5315
5325
  matchable: true,
@@ -5375,11 +5385,12 @@
5375
5385
  plural: "Licenses",
5376
5386
  properties: {
5377
5387
  area: {
5388
+ description: "Spatial area of the license or concession",
5378
5389
  label: "Area",
5379
- maxLength: 1024,
5390
+ maxLength: 250,
5380
5391
  name: "area",
5381
5392
  qname: "License:area",
5382
- type: "string"
5393
+ type: "number"
5383
5394
  },
5384
5395
  commodities: {
5385
5396
  label: "Commodities",
@@ -6707,17 +6718,6 @@
6707
6718
  stub: true,
6708
6719
  type: "entity"
6709
6720
  },
6710
- posts: {
6711
- label: "Posts held",
6712
- matchable: true,
6713
- maxLength: 200,
6714
- name: "posts",
6715
- qname: "Person:posts",
6716
- range: "Post",
6717
- reverse: "holder",
6718
- stub: true,
6719
- type: "entity"
6720
- },
6721
6721
  religion: {
6722
6722
  label: "Religion",
6723
6723
  maxLength: 1024,
@@ -6901,72 +6901,6 @@
6901
6901
  ]
6902
6902
  }
6903
6903
  },
6904
- Post: {
6905
- caption: [
6906
- "summary",
6907
- "organization",
6908
- "role"
6909
- ],
6910
- deprecated: true,
6911
- description: "A post, role or position held by an individual within an organization or body. This describes the period for which the position is held, not the abstract concept of the post.\n",
6912
- "extends": [
6913
- "Interest"
6914
- ],
6915
- featured: [
6916
- "holder",
6917
- "organization",
6918
- "role",
6919
- "startDate",
6920
- "endDate"
6921
- ],
6922
- label: "Post",
6923
- plural: "Posts",
6924
- properties: {
6925
- holder: {
6926
- label: "Holder",
6927
- matchable: true,
6928
- maxLength: 200,
6929
- name: "holder",
6930
- qname: "Post:holder",
6931
- range: "Person",
6932
- reverse: "posts",
6933
- type: "entity"
6934
- },
6935
- organization: {
6936
- label: "Organization",
6937
- maxLength: 1024,
6938
- name: "organization",
6939
- qname: "Post:organization",
6940
- type: "string"
6941
- },
6942
- wikidataId: {
6943
- hidden: true,
6944
- label: "Wikidata ID",
6945
- matchable: true,
6946
- maxLength: 64,
6947
- name: "wikidataId",
6948
- qname: "Post:wikidataId",
6949
- type: "identifier"
6950
- }
6951
- },
6952
- required: [
6953
- "holder"
6954
- ],
6955
- schemata: [
6956
- "Interest",
6957
- "Interval",
6958
- "Post"
6959
- ],
6960
- temporalExtent: {
6961
- end: [
6962
- "endDate"
6963
- ],
6964
- start: [
6965
- "startDate",
6966
- "date"
6967
- ]
6968
- }
6969
- },
6970
6904
  Project: {
6971
6905
  caption: [
6972
6906
  "name",
@@ -7405,10 +7339,10 @@
7405
7339
  },
7406
7340
  duration: {
7407
7341
  label: "Duration",
7408
- maxLength: 1024,
7342
+ maxLength: 250,
7409
7343
  name: "duration",
7410
7344
  qname: "Sanction:duration",
7411
- type: "string"
7345
+ type: "number"
7412
7346
  },
7413
7347
  entity: {
7414
7348
  label: "Entity",
@@ -8352,6 +8286,7 @@
8352
8286
  plural: "User accounts",
8353
8287
  properties: {
8354
8288
  email: {
8289
+ description: "Email address",
8355
8290
  label: "E-Mail",
8356
8291
  matchable: true,
8357
8292
  maxLength: 250,
@@ -8389,14 +8324,6 @@
8389
8324
  stub: true,
8390
8325
  type: "entity"
8391
8326
  },
8392
- number: {
8393
- label: "Phone Number",
8394
- matchable: true,
8395
- maxLength: 64,
8396
- name: "number",
8397
- qname: "UserAccount:number",
8398
- type: "phone"
8399
- },
8400
8327
  owner: {
8401
8328
  label: "Owner",
8402
8329
  matchable: true,
@@ -8414,6 +8341,15 @@
8414
8341
  qname: "UserAccount:password",
8415
8342
  type: "string"
8416
8343
  },
8344
+ phone: {
8345
+ description: "Phone number",
8346
+ label: "Phone",
8347
+ matchable: true,
8348
+ maxLength: 32,
8349
+ name: "phone",
8350
+ qname: "UserAccount:phone",
8351
+ type: "phone"
8352
+ },
8417
8353
  service: {
8418
8354
  label: "Service",
8419
8355
  maxLength: 1024,
@@ -9166,15 +9102,6 @@
9166
9102
  maxLength: 65000,
9167
9103
  plural: "HTMLs"
9168
9104
  },
9169
- iban: {
9170
- description: "An international bank account number, as defined in ISO 13616. IBANs are\nmanaged by SWIFT used in the European SEPA payment system.\n\nA notable aspect of IBANs is that they share a country prefix and validation\nmechanism, but the specific length of an IBAN is dependent on the country\ncode defined in the first two characters: `NO8330001234567` and\n`CY21002001950000357001234567` are both valid values.",
9171
- group: "ibans",
9172
- label: "IBAN",
9173
- matchable: true,
9174
- maxLength: 64,
9175
- pivot: true,
9176
- plural: "IBANs"
9177
- },
9178
9105
  identifier: {
9179
9106
  description: "Used for registration numbers and other codes assigned by an authority\nto identify an entity. This might include tax identifiers and statistical\ncodes.\n\nSince identifiers are high-value criteria when comparing two entities, numbers\nshould only be modelled as identifiers if they are long enough to be meaningful.\nFour- or five-digit industry classifiers create more noise than value.",
9180
9107
  group: "identifiers",
@@ -9187,11 +9114,11 @@
9187
9114
  ip: {
9188
9115
  description: "Internet protocol addresses. This supports both addresses used\nby the protocol versions 4 (e.g. `192.168.1.143`) and 6\n(e.g. `0:0:0:0:0:ffff:c0a8:18f`).",
9189
9116
  group: "ips",
9190
- label: "IP-Address",
9117
+ label: "IP Address",
9191
9118
  matchable: true,
9192
9119
  maxLength: 64,
9193
9120
  pivot: true,
9194
- plural: "IP-Addresses"
9121
+ plural: "IP Addresses"
9195
9122
  },
9196
9123
  json: {
9197
9124
  description: "An encoded JSON object. This is used to store raw HTTP headers for documents\nand some other edge cases. It's a really bad idea and we should try to get rid\nof JSON properties.",