@ekwo-ai/peppol-ubl 0.11.0 → 0.12.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ All notable changes to this project are documented here. The format follows
7
7
  ## [Unreleased]
8
8
 
9
9
  ### Added
10
+ - **Reading a received invoice.** `readUbl()` reads a UBL 2.1 `Invoice` or
11
+ `CreditNote`, bare or in the envelope of an access point, into a
12
+ `ReceivedInvoice`: parties with their schemes, dates, references, lines, VAT
13
+ breakdown, totals, payment means and the documents attached, an embedded PDF
14
+ as bytes. Figures stay the decimal text the file wrote; the arithmetic of
15
+ EN 16931 (BR-CO-10 to BR-CO-17) is reported in `violations`, never
16
+ corrected. A file that is not an invoice throws an `InvoiceFileError` with a
17
+ code, read by a strict XML reader of the package's own (no DOCTYPE, size,
18
+ depth and element limits). `@ekwo-ai/factur-x` returns the same shape from
19
+ CII.
20
+ - **Participant identifiers.** `validateParticipantId()` checks a Peppol
21
+ participant identifier — scheme of the EAS list Peppol delivers to, numeric
22
+ or symbolic spelling, and the check digits of seven schemes whose rule is
23
+ published. `smlHostname()` computes the DNS name of a participant on an SML,
24
+ for the CNAME and the NAPTR lookups, without any network call.
10
25
  - **The first version.** A sales invoice or credit note as Peppol BIS Billing
11
26
  3.0 (UBL 2.1), from a posted document as three row shapes — header, lines,
12
27
  VAT breakdown — with the figures written as they were posted and never
package/README.md CHANGED
@@ -21,7 +21,8 @@ VAT rounded once per tax. They are declared in this package's own types, so
21
21
  any invoicing system that can produce the same three things can use it. It
22
22
  reads no database and knows no accounting.
23
23
 
24
- Writing the file is all it does. **Sending it takes a certified access point**,
24
+ Writing the file, and [reading one received](#reading), is all it does.
25
+ **Sending it takes a certified access point**,
25
26
  a certificate and somebody on call, and this package has none of the three: you
26
27
  get the same UBL anybody gets, and you send it through the access point you
27
28
  chose.
@@ -229,6 +230,93 @@ against it found what reading had not:
229
230
  found it to be an address scheme, which for two of the four countries that
230
231
  declare this profile is not an ISO 6523 identifier scheme at all (BR-CL-11).
231
232
 
233
+ ## Reading
234
+
235
+ The other half of e-invoicing: the invoice a supplier sends you, turned into a
236
+ plain object a purchase draft can be made from.
237
+
238
+ ```ts
239
+ import { readUbl, InvoiceFileError } from '@ekwo-ai/peppol-ubl';
240
+
241
+ const { invoice, violations } = readUbl(bytesOrText);
242
+ invoice.kind; // 'invoice' | 'credit_note'
243
+ invoice.seller.vatId; // 'BE0999999031'
244
+ invoice.totals.payable; // '648.40', a decimal as text, never a number
245
+ invoice.attachments[0]; // { filename: 'RCV-2026-0107.pdf', mimeType: 'application/pdf', content: Uint8Array, … }
246
+ ```
247
+
248
+ `readUbl(input: string | Uint8Array, options?: ReadOptions): ReceivedInvoiceFile`
249
+ reads a UBL 2.1 `Invoice` or `CreditNote` — bare, or inside the
250
+ `StandardBusinessDocument` envelope an access point hands it over in — and
251
+ returns a `ReceivedInvoice`: the seller and the buyer (legal and trading
252
+ names, VAT and legal identifiers, electronic addresses with their schemes,
253
+ postal addresses, contacts), number, type code, dates, currency, references,
254
+ notes, lines (quantity and unit, net amount, prices, VAT category and rate,
255
+ item identifiers), document allowances and charges, the VAT breakdown, the
256
+ totals, the payment means (an IBAN, told from another account by its check
257
+ digits) and the documents attached — an embedded PDF comes back as bytes, with
258
+ its MIME type and its file name. Every field names the business term of
259
+ EN 16931 it holds.
260
+
261
+ **The shape is shared.** `@ekwo-ai/factur-x` returns the same
262
+ `ReceivedInvoice` from a CII invoice (`readCii`, `readFacturX`), so whoever
263
+ turns a received invoice into a purchase does it once for both syntaxes. The
264
+ two bricks hold byte-for-byte copies of the files that define it, and a test
265
+ keeps them identical.
266
+
267
+ **Nothing is recomputed, nothing is defaulted.** A figure is the text the file
268
+ wrote, checked to be a decimal, compared on exact decimals; an absent element
269
+ is `null`. The arithmetic of EN 16931 (BR-CO-10 to BR-CO-17) is checked and
270
+ what does not add up comes back in `violations`, next to the figures as the
271
+ file wrote them. A credit note's figures are positive, as written: the sign is
272
+ `kind`.
273
+
274
+ **A file that is not an invoice throws an `InvoiceFileError`**, with a `code`:
275
+ `malformed_xml`, `unsupported_encoding` (UTF-8 only), `doctype_forbidden`,
276
+ `undefined_entity`, `too_large`, `too_deep`, `too_many_elements`,
277
+ `not_an_invoice` (another root; a CII file is pointed at the CII reader),
278
+ `missing_element` (no number, date, currency, totals or line), `invalid_value`
279
+ (a date that is not one, an amount that is not a decimal). No raw parser error
280
+ escapes. The XML is read by a strict reader of the package's own — no DOCTYPE
281
+ and so no entity expansion, the five predefined entities only, a size limit
282
+ before reading (`maxBytes`, 64 MiB by default), a depth and an element limit
283
+ while reading — because a received file is hostile until read.
284
+
285
+ What it does not do: validate against the schemas or the Schematron (whether
286
+ the file is valid on the network was the sending access point's question),
287
+ check signatures, or read UBL extensions.
288
+
289
+ ### Participant identifiers and the SML
290
+
291
+ ```ts
292
+ import { validateParticipantId, smlHostname, SML_ZONES } from '@ekwo-ai/peppol-ubl';
293
+
294
+ validateParticipantId('BE:EN:0999999031');
295
+ // { valid: true, scheme: '0208', value: '0999999031', identifier: '0208:0999999031', canonical: '0208:0999999031', problems: [] }
296
+
297
+ smlHostname('0208:0999999031', SML_ZONES.production, 'naptr');
298
+ // '<base32 of SHA-256>.iso6523-actorid-upis.edelivery.tech.ec.europa.eu'
299
+ ```
300
+
301
+ `validateParticipantId(input: string): ParticipantIdCheck` takes
302
+ `scheme:value`, with or without `iso6523-actorid-upis::` in front, and the
303
+ symbolic scheme names of the Peppol code list (`BE:EN`, `GLN`, `NO:ORG`…),
304
+ returned as the numeric code. It checks that the scheme is an electronic
305
+ address scheme (EAS) Peppol delivers to, and the check digits of the schemes
306
+ whose rule is published by their issuer: GLN (0088), Belgian enterprise number
307
+ (0208), SIREN (0002), Swedish (0007) and Norwegian (0192) organisation
308
+ numbers, Australian Business Number (0151) and LEI (0199) — `CHECKED_SCHEMES`.
309
+ Other schemes are checked for nothing but being non-empty: a rule written from
310
+ a guess would refuse somebody's real address. The SIRET (0009) is one of them,
311
+ for the published exception to its Luhn rule this package could not source
312
+ exactly.
313
+
314
+ `smlHostname(participant, zone, lookup)` computes the DNS name under which the
315
+ SML publishes a participant: `B-` and the MD5 of the lower-cased identifier for
316
+ the `cname` lookup, the unpadded base32 of its SHA-256 for the `naptr` lookup
317
+ of BDXL. It is pure — the hashes are written out in the package, there is no
318
+ default zone, and nothing is resolved: the lookup belongs to a transport.
319
+
232
320
  ## Sources
233
321
 
234
322
  - OASIS, *Universal Business Language 2.1*, schemas of 4 November 2013:
@@ -239,6 +327,17 @@ against it found what reading had not:
239
327
  tag `v3.0.20`.
240
328
  - CEN/TC 434, the validation artefacts of EN 16931:
241
329
  <https://github.com/ConnectingEurope/eInvoicing-EN16931>.
330
+ - OpenPeppol, *Policy for use of Identifiers*, version 4, and the code list
331
+ *Participant identifier schemes*: <https://docs.peppol.eu/edelivery/> —
332
+ the identifier scheme, case-insensitive comparison, symbolic scheme names.
333
+ - OpenPeppol, *Service Metadata Locator (SML)* specification, and OASIS
334
+ *Business Document Metadata Service Location (BDXL) 1.0* — the DNS names
335
+ of a participant. RFC 1321 (MD5), FIPS 180-4 (SHA-256), RFC 4648 (base32).
336
+ - The check digit rules, each cited where it is implemented in
337
+ `src/participant.ts`: GS1 General Specifications (GLN), the Crossroads Bank
338
+ for Enterprises (Belgian enterprise number), INSEE (SIREN), Skatteverket and
339
+ the Brønnøysund Register Centre (organisation numbers), the Australian
340
+ Business Register (ABN), ISO 17442 (LEI), ISO 13616 (IBAN).
242
341
 
243
342
  ## Licence
244
343
 
package/dist/decimal.d.ts CHANGED
@@ -8,6 +8,9 @@
8
8
  * that is right. So nothing here is a `number`. A decimal is an integer and a
9
9
  * scale, the integer is a `bigint`, and the four operations the rules need are
10
10
  * exact.
11
+ *
12
+ * The Factur-X brick holds a copy of this file, byte for byte, for the reader
13
+ * of `received-checks.ts`; a test there compares the two.
11
14
  */
12
15
  export interface Decimal {
13
16
  /** The digits, as an integer: 12.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GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAS9D;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAOnD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,SAAI,GAAG,MAAM,CAe9D"}
package/dist/decimal.js CHANGED
@@ -8,6 +8,9 @@
8
8
  * that is right. So nothing here is a `number`. A decimal is an integer and a
9
9
  * scale, the integer is a `bigint`, and the four operations the rules need are
10
10
  * exact.
11
+ *
12
+ * The Factur-X brick holds a copy of this file, byte for byte, for the reader
13
+ * of `received-checks.ts`; a test there compares the two.
11
14
  */
12
15
  const SYNTAX = /^[+-]?(\d+)(\.\d+)?$|^[+-]?(\.\d+)$/;
13
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"decimal.js","sourceRoot":"","sources":["../src/decimal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,MAAM,MAAM,GAAG,qCAAqC,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAyC;IACpE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,IAAY,CAAC;IACjB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACzC,sEAAsE;QACtE,oEAAoE;QACpE,oEAAoE;QACpE,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;I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;IACpD,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACzB,OAAO,KAAK,GAAG,QAAQ,IAAI,KAAK,GAAG,GAAG,KAAK,EAAE,EAAE,CAAC;QAC9C,KAAK,IAAI,GAAG,CAAC;QACb,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IACD,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;QACrB,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC;QACzC,KAAK,GAAG,QAAQ,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,GAAG,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,QAAQ,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * What makes a received file unreadable, as opposed to an invoice that reads
3
+ * and does not add up. The second comes back in `violations`; the first is
4
+ * thrown, because a file that is not an invoice has nothing to hang a
5
+ * violation on.
6
+ *
7
+ * The same file, byte for byte, in the two e-invoicing bricks that read, so
8
+ * that a caller handles a refusal of either by the same codes.
9
+ */
10
+ export type InvoiceFileErrorCode =
11
+ /** Larger than `maxBytes`. Refused before a single character is read. */
12
+ 'too_large'
13
+ /** Bytes that are not UTF-8, or a declaration that names another encoding. */
14
+ | 'unsupported_encoding'
15
+ /** A `<!DOCTYPE`. No invoice needs one, and every entity attack does. */
16
+ | 'doctype_forbidden'
17
+ /** An entity other than the five XML predefines and character references. */
18
+ | 'undefined_entity'
19
+ /** Elements nested deeper than `maxDepth`. */
20
+ | 'too_deep'
21
+ /** More elements than `maxElements`. */
22
+ | 'too_many_elements'
23
+ /** Not well-formed XML, in the subset this reader takes. */
24
+ | 'malformed_xml'
25
+ /** Well-formed, and not a UBL 2.1 `Invoice` or `CreditNote`: another root, another namespace. */
26
+ | 'not_an_invoice'
27
+ /** An element without which there is no invoice to book: its number, its date, its currency, its totals, a line. */
28
+ | 'missing_element'
29
+ /** A value that is not what its element holds: a date that is not a date, an amount that is not a number. */
30
+ | 'invalid_value'
31
+ /** Factur-X only: the bytes are not a PDF that can be opened. */
32
+ | 'not_a_pdf'
33
+ /** Factur-X only: a PDF that carries no `factur-x.xml`, `zugferd-invoice.xml` or `xrechnung.xml`. */
34
+ | 'no_embedded_invoice';
35
+ export declare class InvoiceFileError extends Error {
36
+ readonly code: InvoiceFileErrorCode;
37
+ constructor(code: InvoiceFileErrorCode, message: string);
38
+ }
39
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB;AAC9B,yEAAyE;AACvE,WAAW;AACb,8EAA8E;GAC5E,sBAAsB;AACxB,yEAAyE;GACvE,mBAAmB;AACrB,6EAA6E;GAC3E,kBAAkB;AACpB,8CAA8C;GAC5C,UAAU;AACZ,wCAAwC;GACtC,mBAAmB;AACrB,4DAA4D;GAC1D,eAAe;AACjB,iGAAiG;GAC/F,gBAAgB;AAClB,oHAAoH;GAClH,iBAAiB;AACnB,6GAA6G;GAC3G,eAAe;AACjB,iEAAiE;GAC/D,WAAW;AACb,qGAAqG;GACnG,qBAAqB,CAAC;AAE1B,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;gBAExB,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM;CAKxD"}
package/dist/errors.js ADDED
@@ -0,0 +1,9 @@
1
+ export class InvoiceFileError extends Error {
2
+ code;
3
+ constructor(code, message) {
4
+ super(message);
5
+ this.name = 'InvoiceFileError';
6
+ this.code = code;
7
+ }
8
+ }
9
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAmCA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,CAAuB;IAEpC,YAAY,IAA0B,EAAE,OAAe;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -31,4 +31,10 @@ export type { DocumentHeaderRow, DocumentLineRow, DocumentTaxRow, ElectronicAddr
31
31
  * as a violation, beside a file that says what it was given.
32
32
  */
33
33
  export declare function generatePeppolUbl(input: PeppolUblInput, options?: PeppolUblOptions): PeppolUbl;
34
+ export { readUbl } from './read.js';
35
+ export { InvoiceFileError, type InvoiceFileErrorCode } from './errors.js';
36
+ export { CREDIT_NOTE_TYPE_CODES, checkReceived, isValidIban } from './received-checks.js';
37
+ export type { DateText, DecimalText, ReadOptions, ReceivedAccount, ReceivedAddress, ReceivedAllowanceCharge, ReceivedAttachment, ReceivedContact, ReceivedIdentifier, ReceivedInvoice, ReceivedInvoiceFile, ReceivedLine, ReceivedParty, ReceivedPaymentMeans, ReceivedTax, ReceivedTotals, ReceivedViolation, } from './received.js';
38
+ export { CHECKED_SCHEMES, PARTICIPANT_IDENTIFIER_SCHEME, ParticipantIdError, SYMBOLIC_SCHEMES, validateParticipantId, type ParticipantIdCheck, type ParticipantIdProblem, } from './participant.js';
39
+ export { SML_ZONES, smlHostname, type SmlLookup } from './sml.js';
34
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,aAAa,EACb,cAAc,EACd,0BAA0B,EAC1B,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,OAAO,EACP,OAAO,EACP,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,SAAS,GACV,MAAM,YAAY,CAAC;AAYpB;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAQlG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,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ePeppolUbl(input, options = {}) {
50
50
  violations: check(model),
51
51
  };
52
52
  }
53
+ // --- reading ---------------------------------------------------------------
54
+ export { readUbl } from './read.js';
55
+ export { InvoiceFileError } from './errors.js';
56
+ export { CREDIT_NOTE_TYPE_CODES, checkReceived, isValidIban } from './received-checks.js';
57
+ // --- participants ----------------------------------------------------------
58
+ export { CHECKED_SCHEMES, PARTICIPANT_IDENTIFIER_SCHEME, ParticipantIdError, SYMBOLIC_SCHEMES, validateParticipantId, } from './participant.js';
59
+ export { SML_ZONES, smlHostname } from './sml.js';
53
60
  //# 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;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,aAAa,EACb,cAAc,EACd,0BAA0B,EAC1B,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAcxB;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAc,EAAE,IAA8B;IAChE,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC9E,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CA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OAAO,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC9E,OAAO,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AACpG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAqB,EAAE,UAA4B,EAAE;IACrF,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,MAAM,IAAI,cAAc,CAAC,uBAAuB,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC;QACrB,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC;QAC9C,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC;KACzB,CAAC;AACJ,CAAC;AAED,8EAA8E;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAqB1F,8EAA8E;AAE9E,OAAO,EACL,eAAe,EACf,6BAA6B,EAC7B,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GAGtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAkB,MAAM,UAAU,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Peppol participant identifiers: `scheme:value`, the address a business is
3
+ * registered under on the network and the one an invoice is delivered to.
4
+ *
5
+ * What is checked, and where it comes from:
6
+ *
7
+ * - **the scheme** is a code of the electronic address scheme list (EAS) that
8
+ * EN 16931 publishes, as the Schematron Peppol ships carries it
9
+ * (`ELECTRONIC_ADDRESS_SCHEMES`, generated from that file), less the schemes
10
+ * Peppol does not deliver to (`SCHEMES_NOT_ON_PEPPOL`);
11
+ * - **the spelling**: the numeric code is the identifier. Some registrations
12
+ * and older documents write a symbolic name instead (`BE:EN` for `0208`);
13
+ * those of {@link SYMBOLIC_SCHEMES} are read and returned as the code;
14
+ * - **the value**, for the schemes whose number carries check digits under a
15
+ * published, well-defined rule — each one cites where the rule is
16
+ * published. A scheme that is not listed there is not checked beyond being
17
+ * non-empty: a rule written from a guess would refuse somebody's real
18
+ * address. The French SIRET (0009) is one: its Luhn rule has a published
19
+ * exception for one issuer whose exact extent this package could not
20
+ * source, so it is not checked at all rather than checked wrongly.
21
+ *
22
+ * The comparison is the network's: a participant identifier is
23
+ * case-insensitive (OpenPEPPOL, *Policy for use of Identifiers*, version 4,
24
+ * policy 1), which is why {@link validateParticipantId} returns it lower-cased
25
+ * beside the form it was given in.
26
+ */
27
+ /** The identifier scheme of every participant identifier on Peppol (Policy for use of Identifiers, policy 2). */
28
+ export declare const PARTICIPANT_IDENTIFIER_SCHEME = "iso6523-actorid-upis";
29
+ /**
30
+ * Symbolic names of participant identifier schemes, and the numeric code each
31
+ * stands for, transcribed from the "Scheme ID" column of the Peppol code list
32
+ * *Participant identifier schemes* (docs.peppol.eu, Peppol Code Lists). Only
33
+ * the names that list gives are here; a name that is not is refused, not
34
+ * guessed.
35
+ */
36
+ export declare const SYMBOLIC_SCHEMES: Readonly<Record<string, string>>;
37
+ /** Why an identifier is not one Peppol can deliver to. */
38
+ export type ParticipantIdProblem =
39
+ /** Not `scheme:value`: no separator, an empty side, or another identifier scheme than `iso6523-actorid-upis`. */
40
+ 'malformed'
41
+ /** A scheme of no list: neither an EAS code nor a symbolic name of {@link SYMBOLIC_SCHEMES}. */
42
+ | 'unknown_scheme'
43
+ /** An EAS code of EN 16931 that Peppol does not deliver to (an e-mail address, a telephone number…). */
44
+ | 'scheme_not_on_peppol'
45
+ /** A value that is not written the way its scheme writes numbers. */
46
+ | 'invalid_format'
47
+ /** A value whose check digits are wrong. */
48
+ | 'invalid_check_digits';
49
+ export interface ParticipantIdCheck {
50
+ /** True when nothing below is wrong. */
51
+ valid: boolean;
52
+ /** The numeric scheme, `0208`, whatever spelling it was given in. Null where it could not be read. */
53
+ scheme: string | null;
54
+ /** The value, as given, trimmed. */
55
+ value: string | null;
56
+ /** `scheme:value`, numeric scheme, as given. Null where either side is. */
57
+ identifier: string | null;
58
+ /** The same, lower-cased: the form the network compares and hashes. */
59
+ canonical: string | null;
60
+ /** Empty when `valid`. */
61
+ problems: {
62
+ code: ParticipantIdProblem;
63
+ message: string;
64
+ }[];
65
+ }
66
+ /** The schemes whose values {@link validateParticipantId} checks digit by digit. */
67
+ export declare const CHECKED_SCHEMES: readonly string[];
68
+ /** Thrown where a participant identifier is needed and the one given is not one. */
69
+ export declare class ParticipantIdError extends Error {
70
+ name: string;
71
+ readonly problems: ParticipantIdCheck['problems'];
72
+ constructor(problems: ParticipantIdCheck['problems']);
73
+ }
74
+ /**
75
+ * Checks a participant identifier: `0208:0999999922`, with or without the
76
+ * `iso6523-actorid-upis::` in front of it, or with a symbolic scheme
77
+ * (`BE:EN:0999999922`).
78
+ *
79
+ * Pure: the question whether the participant is *registered* is the SML's,
80
+ * and {@link smlHostname} computes where to ask it.
81
+ */
82
+ export declare function validateParticipantId(input: string): ParticipantIdCheck;
83
+ //# sourceMappingURL=participant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"participant.d.ts","sourceRoot":"","sources":["../src/participant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,iHAAiH;AACjH,eAAO,MAAM,6BAA6B,yBAAyB,CAAC;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MA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