@opensanctions/followthemoney 3.8.5 → 4.0.1

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,5 +1,3 @@
1
- import crypto$1 from 'crypto';
2
-
3
1
  /**
4
2
  * An entity proxy which provides simplified access to the
5
3
  * properties and schema associated with an entity.
@@ -209,6 +207,94 @@ class Entity {
209
207
  }
210
208
  }
211
209
 
210
+ /******************************************************************************
211
+ Copyright (c) Microsoft Corporation.
212
+
213
+ Permission to use, copy, modify, and/or distribute this software for any
214
+ purpose with or without fee is hereby granted.
215
+
216
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
217
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
218
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
219
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
220
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
221
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
222
+ PERFORMANCE OF THIS SOFTWARE.
223
+ ***************************************************************************** */
224
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
225
+
226
+
227
+ function __awaiter(thisArg, _arguments, P, generator) {
228
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
229
+ return new (P || (P = Promise))(function (resolve, reject) {
230
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
231
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
232
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
233
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
234
+ });
235
+ }
236
+
237
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
238
+ var e = new Error(message);
239
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
240
+ };
241
+
242
+ const byteToHex = [];
243
+ for (let i = 0; i < 256; ++i) {
244
+ byteToHex.push((i + 0x100).toString(16).slice(1));
245
+ }
246
+ function unsafeStringify(arr, offset = 0) {
247
+ return (byteToHex[arr[offset + 0]] +
248
+ byteToHex[arr[offset + 1]] +
249
+ byteToHex[arr[offset + 2]] +
250
+ byteToHex[arr[offset + 3]] +
251
+ '-' +
252
+ byteToHex[arr[offset + 4]] +
253
+ byteToHex[arr[offset + 5]] +
254
+ '-' +
255
+ byteToHex[arr[offset + 6]] +
256
+ byteToHex[arr[offset + 7]] +
257
+ '-' +
258
+ byteToHex[arr[offset + 8]] +
259
+ byteToHex[arr[offset + 9]] +
260
+ '-' +
261
+ byteToHex[arr[offset + 10]] +
262
+ byteToHex[arr[offset + 11]] +
263
+ byteToHex[arr[offset + 12]] +
264
+ byteToHex[arr[offset + 13]] +
265
+ byteToHex[arr[offset + 14]] +
266
+ byteToHex[arr[offset + 15]]).toLowerCase();
267
+ }
268
+
269
+ let getRandomValues;
270
+ const rnds8 = new Uint8Array(16);
271
+ function rng() {
272
+ if (!getRandomValues) {
273
+ if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
274
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
275
+ }
276
+ getRandomValues = crypto.getRandomValues.bind(crypto);
277
+ }
278
+ return getRandomValues(rnds8);
279
+ }
280
+
281
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
282
+ var native = { randomUUID };
283
+
284
+ function v4(options, buf, offset) {
285
+ if (native.randomUUID && true && !options) {
286
+ return native.randomUUID();
287
+ }
288
+ options = options || {};
289
+ const rnds = options.random ?? options.rng?.() ?? rng();
290
+ if (rnds.length < 16) {
291
+ throw new Error('Random bytes length must be >= 16');
292
+ }
293
+ rnds[6] = (rnds[6] & 0x0f) | 0x40;
294
+ rnds[8] = (rnds[8] & 0x3f) | 0x80;
295
+ return unsafeStringify(rnds);
296
+ }
297
+
212
298
  /**
213
299
  * Definition of a property, with relevant metadata for type,
214
300
  * labels and other useful criteria.
@@ -427,62 +513,6 @@ class PropertyType {
427
513
  }
428
514
  PropertyType.ENTITY = 'entity';
429
515
 
430
- const byteToHex = [];
431
- for (let i = 0; i < 256; ++i) {
432
- byteToHex.push((i + 0x100).toString(16).slice(1));
433
- }
434
- function unsafeStringify(arr, offset = 0) {
435
- return (byteToHex[arr[offset + 0]] +
436
- byteToHex[arr[offset + 1]] +
437
- byteToHex[arr[offset + 2]] +
438
- byteToHex[arr[offset + 3]] +
439
- '-' +
440
- byteToHex[arr[offset + 4]] +
441
- byteToHex[arr[offset + 5]] +
442
- '-' +
443
- byteToHex[arr[offset + 6]] +
444
- byteToHex[arr[offset + 7]] +
445
- '-' +
446
- byteToHex[arr[offset + 8]] +
447
- byteToHex[arr[offset + 9]] +
448
- '-' +
449
- byteToHex[arr[offset + 10]] +
450
- byteToHex[arr[offset + 11]] +
451
- byteToHex[arr[offset + 12]] +
452
- byteToHex[arr[offset + 13]] +
453
- byteToHex[arr[offset + 14]] +
454
- byteToHex[arr[offset + 15]]).toLowerCase();
455
- }
456
-
457
- let getRandomValues;
458
- const rnds8 = new Uint8Array(16);
459
- function rng() {
460
- if (!getRandomValues) {
461
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
462
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
463
- }
464
- getRandomValues = crypto.getRandomValues.bind(crypto);
465
- }
466
- return getRandomValues(rnds8);
467
- }
468
-
469
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
470
- var native = { randomUUID };
471
-
472
- function v4(options, buf, offset) {
473
- if (native.randomUUID && true && !options) {
474
- return native.randomUUID();
475
- }
476
- options = options || {};
477
- const rnds = options.random ?? options.rng?.() ?? rng();
478
- if (rnds.length < 16) {
479
- throw new Error('Random bytes length must be >= 16');
480
- }
481
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
482
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
483
- return unsafeStringify(rnds);
484
- }
485
-
486
516
  class Model {
487
517
  constructor(config) {
488
518
  this.schemata = {};
@@ -560,12 +590,14 @@ class Model {
560
590
  * @param schema Schema name or object
561
591
  */
562
592
  createEntity(schema, namespace) {
563
- const rawId = v4();
564
- const id = namespace ? namespace.sign(rawId) : rawId;
565
- return this.getEntity({
566
- id,
567
- schema: schema,
568
- properties: {}
593
+ return __awaiter(this, void 0, void 0, function* () {
594
+ const rawId = v4();
595
+ const id = namespace ? yield namespace.sign(rawId) : rawId;
596
+ return this.getEntity({
597
+ id,
598
+ schema: schema,
599
+ properties: {}
600
+ });
569
601
  });
570
602
  }
571
603
  }
@@ -579,20 +611,39 @@ class Namespace {
579
611
  return id.split(this.separator);
580
612
  }
581
613
  signature(id) {
582
- return crypto$1.createHmac('sha1', this.namespaceKey)
583
- .update(id)
584
- .digest('hex');
614
+ return __awaiter(this, void 0, void 0, function* () {
615
+ // Generate an HMAC signature for the given ID using the namespace key, using
616
+ // SHA-1 as the hashing algorithm and returning the result as a hexadecimal string.
617
+ // Use in-browser crypto library for compatibility with browsers.
618
+ if (!this.namespaceKey.length) {
619
+ return id;
620
+ }
621
+ // Convert strings to ArrayBuffers
622
+ const encoder = new TextEncoder();
623
+ const keyData = encoder.encode(this.namespaceKey);
624
+ const data = encoder.encode(id);
625
+ // Import the key
626
+ const key = yield crypto.subtle.importKey('raw', keyData, { name: 'HMAC', hash: 'SHA-1' }, false, ['sign']);
627
+ // Generate the signature
628
+ const signature = yield crypto.subtle.sign('HMAC', key, data);
629
+ // Convert to hexadecimal string
630
+ const hashArray = Array.from(new Uint8Array(signature));
631
+ const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
632
+ return hashHex;
633
+ });
585
634
  }
586
635
  sign(id) {
587
- const entityId = this.parse(id)[0];
588
- if (!entityId) {
589
- return id;
590
- }
591
- if (!this.namespaceKey.length) {
592
- return entityId;
593
- }
594
- const digest = this.signature(entityId);
595
- return [entityId, digest].join(this.separator);
636
+ return __awaiter(this, void 0, void 0, function* () {
637
+ const entityId = this.parse(id)[0];
638
+ if (!entityId) {
639
+ return id;
640
+ }
641
+ if (!this.namespaceKey.length) {
642
+ return entityId;
643
+ }
644
+ const digest = yield this.signature(entityId);
645
+ return [entityId, digest].join(this.separator);
646
+ });
596
647
  }
597
648
  }
598
649
 
@@ -1505,13 +1556,14 @@ var schemata = {
1505
1556
  type: "email"
1506
1557
  },
1507
1558
  ibanMentioned: {
1559
+ format: "iban",
1508
1560
  hidden: true,
1509
1561
  label: "Detected IBANs",
1510
1562
  matchable: true,
1511
1563
  maxLength: 64,
1512
1564
  name: "ibanMentioned",
1513
1565
  qname: "Analyzable:ibanMentioned",
1514
- type: "iban"
1566
+ type: "identifier"
1515
1567
  },
1516
1568
  ipMentioned: {
1517
1569
  hidden: true,
@@ -1597,62 +1649,6 @@ var schemata = {
1597
1649
  ]
1598
1650
  }
1599
1651
  },
1600
- Assessment: {
1601
- caption: [
1602
- "name"
1603
- ],
1604
- "extends": [
1605
- "Thing"
1606
- ],
1607
- featured: [
1608
- "name",
1609
- "publishDate",
1610
- "author"
1611
- ],
1612
- label: "Assessment",
1613
- plural: "Assessments",
1614
- properties: {
1615
- assessmentId: {
1616
- label: "Assessment ID",
1617
- maxLength: 1024,
1618
- name: "assessmentId",
1619
- qname: "Assessment:assessmentId",
1620
- type: "string"
1621
- },
1622
- author: {
1623
- label: "Author",
1624
- matchable: true,
1625
- maxLength: 200,
1626
- name: "author",
1627
- qname: "Assessment:author",
1628
- range: "LegalEntity",
1629
- reverse: "authoredAssessments",
1630
- type: "entity"
1631
- },
1632
- publishDate: {
1633
- label: "Date of publishing",
1634
- matchable: true,
1635
- maxLength: 32,
1636
- name: "publishDate",
1637
- qname: "Assessment:publishDate",
1638
- type: "date"
1639
- }
1640
- },
1641
- required: [
1642
- "name"
1643
- ],
1644
- schemata: [
1645
- "Assessment",
1646
- "Thing"
1647
- ],
1648
- temporalExtent: {
1649
- end: [
1650
- ],
1651
- start: [
1652
- "publishDate"
1653
- ]
1654
- }
1655
- },
1656
1652
  Asset: {
1657
1653
  caption: [
1658
1654
  "name"
@@ -1921,12 +1917,13 @@ var schemata = {
1921
1917
  type: "entity"
1922
1918
  },
1923
1919
  iban: {
1920
+ format: "iban",
1924
1921
  label: "IBAN",
1925
1922
  matchable: true,
1926
1923
  maxLength: 64,
1927
1924
  name: "iban",
1928
1925
  qname: "BankAccount:iban",
1929
- type: "iban"
1926
+ type: "identifier"
1930
1927
  },
1931
1928
  maxBalance: {
1932
1929
  label: "Maximum balance",
@@ -2447,15 +2444,6 @@ var schemata = {
2447
2444
  qname: "Company:fssCode",
2448
2445
  type: "string"
2449
2446
  },
2450
- ibcRuc: {
2451
- deprecated: true,
2452
- label: "ibcRUC",
2453
- matchable: true,
2454
- maxLength: 64,
2455
- name: "ibcRuc",
2456
- qname: "Company:ibcRuc",
2457
- type: "identifier"
2458
- },
2459
2447
  ipoCode: {
2460
2448
  label: "IPO",
2461
2449
  maxLength: 64,
@@ -3131,11 +3119,11 @@ var schemata = {
3131
3119
  reverse: "cryptoWallets",
3132
3120
  type: "entity"
3133
3121
  },
3134
- mangingExchange: {
3122
+ managingExchange: {
3135
3123
  label: "Managing exchange",
3136
3124
  maxLength: 1024,
3137
- name: "mangingExchange",
3138
- qname: "CryptoWallet:mangingExchange",
3125
+ name: "managingExchange",
3126
+ qname: "CryptoWallet:managingExchange",
3139
3127
  type: "string"
3140
3128
  },
3141
3129
  privateKey: {
@@ -3507,6 +3495,17 @@ var schemata = {
3507
3495
  stub: true,
3508
3496
  type: "entity"
3509
3497
  },
3498
+ provenIntervals: {
3499
+ label: "Derived relationships",
3500
+ matchable: true,
3501
+ maxLength: 200,
3502
+ name: "provenIntervals",
3503
+ qname: "Document:provenIntervals",
3504
+ range: "Interval",
3505
+ reverse: "proof",
3506
+ stub: true,
3507
+ type: "entity"
3508
+ },
3510
3509
  publishedAt: {
3511
3510
  label: "Published on",
3512
3511
  maxLength: 32,
@@ -4576,6 +4575,16 @@ var schemata = {
4576
4575
  qname: "Interval:namesMentioned",
4577
4576
  type: "name"
4578
4577
  },
4578
+ proof: {
4579
+ label: "Source document",
4580
+ matchable: true,
4581
+ maxLength: 200,
4582
+ name: "proof",
4583
+ qname: "Interval:proof",
4584
+ range: "Document",
4585
+ reverse: "provenIntervals",
4586
+ type: "entity"
4587
+ },
4579
4588
  publisher: {
4580
4589
  label: "Publishing source",
4581
4590
  maxLength: 1024,
@@ -4683,17 +4692,6 @@ var schemata = {
4683
4692
  stub: true,
4684
4693
  type: "entity"
4685
4694
  },
4686
- authoredAssessments: {
4687
- label: "Assessments authored",
4688
- matchable: true,
4689
- maxLength: 200,
4690
- name: "authoredAssessments",
4691
- qname: "LegalEntity:authoredAssessments",
4692
- range: "Assessment",
4693
- reverse: "author",
4694
- stub: true,
4695
- type: "entity"
4696
- },
4697
4695
  bvdId: {
4698
4696
  label: "Bureau van Dijk ID",
4699
4697
  matchable: true,
@@ -5306,6 +5304,16 @@ var schemata = {
5306
5304
  qname: "LegalEntity:uniqueEntityId",
5307
5305
  type: "identifier"
5308
5306
  },
5307
+ uscCode: {
5308
+ description: "Unified Social Credit Identifier",
5309
+ format: "uscc",
5310
+ label: "USCC",
5311
+ matchable: true,
5312
+ maxLength: 64,
5313
+ name: "uscCode",
5314
+ qname: "LegalEntity:uscCode",
5315
+ type: "identifier"
5316
+ },
5309
5317
  userAccounts: {
5310
5318
  label: "User accounts",
5311
5319
  matchable: true,
@@ -5371,11 +5379,12 @@ var schemata = {
5371
5379
  plural: "Licenses",
5372
5380
  properties: {
5373
5381
  area: {
5382
+ description: "Spatial area of the license or concession",
5374
5383
  label: "Area",
5375
- maxLength: 1024,
5384
+ maxLength: 250,
5376
5385
  name: "area",
5377
5386
  qname: "License:area",
5378
- type: "string"
5387
+ type: "number"
5379
5388
  },
5380
5389
  commodities: {
5381
5390
  label: "Commodities",
@@ -6703,17 +6712,6 @@ var schemata = {
6703
6712
  stub: true,
6704
6713
  type: "entity"
6705
6714
  },
6706
- posts: {
6707
- label: "Posts held",
6708
- matchable: true,
6709
- maxLength: 200,
6710
- name: "posts",
6711
- qname: "Person:posts",
6712
- range: "Post",
6713
- reverse: "holder",
6714
- stub: true,
6715
- type: "entity"
6716
- },
6717
6715
  religion: {
6718
6716
  label: "Religion",
6719
6717
  maxLength: 1024,
@@ -6897,72 +6895,6 @@ var schemata = {
6897
6895
  ]
6898
6896
  }
6899
6897
  },
6900
- Post: {
6901
- caption: [
6902
- "summary",
6903
- "organization",
6904
- "role"
6905
- ],
6906
- deprecated: true,
6907
- 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",
6908
- "extends": [
6909
- "Interest"
6910
- ],
6911
- featured: [
6912
- "holder",
6913
- "organization",
6914
- "role",
6915
- "startDate",
6916
- "endDate"
6917
- ],
6918
- label: "Post",
6919
- plural: "Posts",
6920
- properties: {
6921
- holder: {
6922
- label: "Holder",
6923
- matchable: true,
6924
- maxLength: 200,
6925
- name: "holder",
6926
- qname: "Post:holder",
6927
- range: "Person",
6928
- reverse: "posts",
6929
- type: "entity"
6930
- },
6931
- organization: {
6932
- label: "Organization",
6933
- maxLength: 1024,
6934
- name: "organization",
6935
- qname: "Post:organization",
6936
- type: "string"
6937
- },
6938
- wikidataId: {
6939
- hidden: true,
6940
- label: "Wikidata ID",
6941
- matchable: true,
6942
- maxLength: 64,
6943
- name: "wikidataId",
6944
- qname: "Post:wikidataId",
6945
- type: "identifier"
6946
- }
6947
- },
6948
- required: [
6949
- "holder"
6950
- ],
6951
- schemata: [
6952
- "Interest",
6953
- "Interval",
6954
- "Post"
6955
- ],
6956
- temporalExtent: {
6957
- end: [
6958
- "endDate"
6959
- ],
6960
- start: [
6961
- "startDate",
6962
- "date"
6963
- ]
6964
- }
6965
- },
6966
6898
  Project: {
6967
6899
  caption: [
6968
6900
  "name",
@@ -7401,10 +7333,10 @@ var schemata = {
7401
7333
  },
7402
7334
  duration: {
7403
7335
  label: "Duration",
7404
- maxLength: 1024,
7336
+ maxLength: 250,
7405
7337
  name: "duration",
7406
7338
  qname: "Sanction:duration",
7407
- type: "string"
7339
+ type: "number"
7408
7340
  },
7409
7341
  entity: {
7410
7342
  label: "Entity",
@@ -8348,6 +8280,7 @@ var schemata = {
8348
8280
  plural: "User accounts",
8349
8281
  properties: {
8350
8282
  email: {
8283
+ description: "Email address",
8351
8284
  label: "E-Mail",
8352
8285
  matchable: true,
8353
8286
  maxLength: 250,
@@ -8385,14 +8318,6 @@ var schemata = {
8385
8318
  stub: true,
8386
8319
  type: "entity"
8387
8320
  },
8388
- number: {
8389
- label: "Phone Number",
8390
- matchable: true,
8391
- maxLength: 64,
8392
- name: "number",
8393
- qname: "UserAccount:number",
8394
- type: "phone"
8395
- },
8396
8321
  owner: {
8397
8322
  label: "Owner",
8398
8323
  matchable: true,
@@ -8410,6 +8335,15 @@ var schemata = {
8410
8335
  qname: "UserAccount:password",
8411
8336
  type: "string"
8412
8337
  },
8338
+ phone: {
8339
+ description: "Phone number",
8340
+ label: "Phone",
8341
+ matchable: true,
8342
+ maxLength: 32,
8343
+ name: "phone",
8344
+ qname: "UserAccount:phone",
8345
+ type: "phone"
8346
+ },
8413
8347
  service: {
8414
8348
  label: "Service",
8415
8349
  maxLength: 1024,
@@ -9162,15 +9096,6 @@ var types = {
9162
9096
  maxLength: 65000,
9163
9097
  plural: "HTMLs"
9164
9098
  },
9165
- iban: {
9166
- 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.",
9167
- group: "ibans",
9168
- label: "IBAN",
9169
- matchable: true,
9170
- maxLength: 64,
9171
- pivot: true,
9172
- plural: "IBANs"
9173
- },
9174
9099
  identifier: {
9175
9100
  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.",
9176
9101
  group: "identifiers",
@@ -9183,11 +9108,11 @@ var types = {
9183
9108
  ip: {
9184
9109
  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`).",
9185
9110
  group: "ips",
9186
- label: "IP-Address",
9111
+ label: "IP Address",
9187
9112
  matchable: true,
9188
9113
  maxLength: 64,
9189
9114
  pivot: true,
9190
- plural: "IP-Addresses"
9115
+ plural: "IP Addresses"
9191
9116
  },
9192
9117
  json: {
9193
9118
  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.",