@juherr/mobilityid 0.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.
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ This repository is licensed under the Apache License, Version 2.0.
2
+
3
+ Repository components:
4
+ - `scala/` contains the original Mobility ID implementation. The original license file is preserved at `scala/LICENSE`.
5
+ - `java/` contains the `mobilityid4j` Java port.
6
+
7
+ Copyright (c) 2014 The New Motion team, and respective contributors
8
+ Copyright (c) 2026 Julien Herr, and respective contributors
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
11
+ use this file except in compliance with the License. You may obtain a copy of
12
+ the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19
+ License for the specific language governing permissions and limitations under
20
+ the License.
package/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # @juherr/mobilityid
2
+
3
+ TypeScript port of the Mobility ID domain library.
4
+
5
+ ## Goals
6
+
7
+ - Keep behavior aligned with the Scala implementation during migration.
8
+ - Provide an idiomatic TypeScript API with strict/tolerant parsing.
9
+ - Enforce quality gates from day one (lint, format, typecheck, tests, license headers).
10
+
11
+ ## Tooling
12
+
13
+ - Node.js: 24 LTS primary target (CI also checks 22 and 25)
14
+ - Package manager: Bun, via `vp install`
15
+ - Unified toolchain: Vite+ (`vp`)
16
+ - TypeScript checks: `vp check`
17
+ - Tests: `vp test`
18
+ - Library packaging: `vp pack`
19
+ - License headers: Oxlint JS plugin (`@tony.ganchev/eslint-plugin-header`)
20
+
21
+ ## API design
22
+
23
+ - Tolerant parsing methods return `T | null`.
24
+ - Strict factories/parsers throw `TypeError` when inputs are invalid.
25
+ - Domain objects are immutable (`readonly` and frozen instances).
26
+ - Canonical rendering is preserved (`toString()`, compact rendering helpers).
27
+
28
+ ## Commands
29
+
30
+ Run from `ts/`:
31
+
32
+ ```bash
33
+ vp install
34
+ vp check
35
+ vp test
36
+ vp pack
37
+ bun run lint
38
+ bun run lint:fix
39
+ ```
40
+
41
+ `vite.config.ts` is the single source of truth for TypeScript checks, test execution, formatting, and package build settings.
42
+
43
+ ## Current scope
44
+
45
+ - Foundational identifiers: `CountryCode`, `PhoneCountryCode`, `ProviderId`, `OperatorIdIso`, `OperatorIdDin`, `PartyId`
46
+ - Check digits: ISO and DIN
47
+ - Contract model: `ContractId`, `ContractIdStandard`, format conversions
48
+ - EVSE model: `EvseId`, `EvseIdIso`, `EvseIdDin`
49
+ - Parser helper API: `MobilityIdParsers`
50
+
51
+ ## License header policy
52
+
53
+ All TypeScript source and test files must include the repository Apache-2.0 header.
54
+ Headers are enforced by Oxlint via the Vite+ `lint` config using `@tony.ganchev/eslint-plugin-header`. Use:
55
+
56
+ - `bun run lint` to validate
57
+ - `bun run lint:fix` to auto-fix
58
+
59
+ ## Publishing to npm
60
+
61
+ The package is `@juherr/mobilityid` (public, scoped). `package.json` keeps `0.0.0-development`;
62
+ the release version is stamped at release time. Only `dist/`, `README.md`, `LICENSE` and
63
+ `package.json` ship (`files` field).
64
+
65
+ ### Validate the package locally
66
+
67
+ ```bash
68
+ vp install
69
+ scripts/verify-package.sh # or: scripts/verify-package.sh 1.2.3
70
+ ```
71
+
72
+ It runs `bun run check` (typecheck, tests, build), `npm pack`, asserts the tarball content
73
+ (`../scripts/verify-npm-package.sh`), runs `publint`, then installs the tarball in a throw-away
74
+ project and uses it from Node (ESM) and TypeScript (declarations resolve through `exports`,
75
+ tolerant parsers are `T | null`). `package.json` is restored afterwards. The same script runs in
76
+ `ci-ts.yml` (Node 24) and in the `Release` preflight.
77
+
78
+ ### Normal releases: GitHub Actions + npm Trusted Publishing (OIDC)
79
+
80
+ Releases are cut by the dispatched `Release` workflow (`.github/workflows/release.yml`, see the
81
+ root `CONTRIBUTING.md`). The `release-ts` job publishes the tarball verified by the preflight with
82
+ `npm publish`, authenticated through GitHub OIDC (`permissions.id-token: write`, Node 24 with
83
+ `registry-url`, `package-manager-cache: false`, npm >= 11.5.1). npm generates the provenance
84
+ attestation itself. **No npm token is stored in GitHub Secrets, and none must be added**
85
+ (`NPM_TOKEN`, `NODE_AUTH_TOKEN`, granular tokens included).
86
+
87
+ ### One-time bootstrap: the first publication
88
+
89
+ Trusted publishing is configured per package on npmjs.com, so the package must exist first.
90
+ The first version is published manually, with your npm account and 2FA:
91
+
92
+ 1. Merge the packaging and workflow configuration, then on `main`:
93
+ ```bash
94
+ cd ts
95
+ vp install
96
+ scripts/verify-package.sh X.Y.Z # builds build/npm-package/juherr-mobilityid-X.Y.Z.tgz
97
+ npm login # interactive, 2FA
98
+ npm publish build/npm-package/juherr-mobilityid-X.Y.Z.tgz # add --tag next for a prerelease
99
+ npm logout
100
+ ```
101
+ `publishConfig` already sets `access: public` and the registry. Use the version you will
102
+ also record in `CHANGELOG.md` / `.github/release-notes/X.Y.Z.md` so the first Java and
103
+ TypeScript versions stay aligned.
104
+ 2. On npmjs.com → package `@juherr/mobilityid` → **Settings** → **Trusted publishing** →
105
+ **Add trusted publisher** → GitHub Actions:
106
+ - Organization or user: `juherr`
107
+ - Repository: `mobilityid`
108
+ - Workflow filename: `release.yml` (filename only; it must not be renamed)
109
+ - Environment name: `npm` (the `release-ts` job runs in this GitHub environment)
110
+ - Allowed actions: configurations created after 2026-09-03 allow `npm stage publish` only by
111
+ default; **enable direct `npm publish`** as well, since the workflow publishes directly.
112
+ 3. Still in package settings → **Publishing access**: select _Require two-factor authentication
113
+ and disallow tokens_, so only OIDC and interactive 2FA publishes are accepted.
114
+ 4. Every later version goes through the `Release` workflow only.
115
+
116
+ `repository.url` in `package.json` must keep matching `https://github.com/juherr/mobilityid`:
117
+ npm checks it against the OIDC claims.
118
+
119
+ ### Testing the pipeline without publishing
120
+
121
+ - `scripts/verify-package.sh` locally or in `ci-ts.yml` exercises everything up to, but not
122
+ including, `npm publish`.
123
+ - The `Release` workflow only runs on manual dispatch from `main` with an explicit version, after
124
+ `validate` and both preflights; a version that already exists on npm is skipped. A dry run of
125
+ the publish step itself is `npm publish <tarball> --dry-run` from a local checkout.
@@ -0,0 +1,148 @@
1
+ //#region src/check-digit-din.d.ts
2
+ declare function checkDigitDin(code: string): string;
3
+ //#endregion
4
+ //#region src/check-digit-iso.d.ts
5
+ declare function checkDigitIso(code: string): string;
6
+ //#endregion
7
+ //#region src/contract-id-standard.d.ts
8
+ declare const ContractIdStandards: {
9
+ readonly ISO: "ISO";
10
+ readonly EMI3: "EMI3";
11
+ readonly DIN: "DIN";
12
+ };
13
+ type ContractIdStandard = (typeof ContractIdStandards)[keyof typeof ContractIdStandards];
14
+ //#endregion
15
+ //#region src/country-code.d.ts
16
+ declare class CountryCode {
17
+ readonly value: string;
18
+ private constructor();
19
+ static isValid(raw: string): boolean;
20
+ static from(raw: string): CountryCode;
21
+ static parse(raw: string): CountryCode | null;
22
+ toString(): string;
23
+ }
24
+ //#endregion
25
+ //#region src/operator-id.d.ts
26
+ declare class OperatorIdIso {
27
+ readonly value: string;
28
+ private constructor();
29
+ static isValid(raw: string): boolean;
30
+ static from(raw: string): OperatorIdIso;
31
+ static parse(raw: string): OperatorIdIso | null;
32
+ toString(): string;
33
+ }
34
+ declare class OperatorIdDin {
35
+ readonly value: string;
36
+ private constructor();
37
+ static isValid(raw: string): boolean;
38
+ static from(raw: string): OperatorIdDin;
39
+ static parse(raw: string): OperatorIdDin | null;
40
+ toString(): string;
41
+ }
42
+ type OperatorId = OperatorIdIso | OperatorIdDin;
43
+ //#endregion
44
+ //#region src/provider-id.d.ts
45
+ declare class ProviderId {
46
+ readonly value: string;
47
+ private constructor();
48
+ static isValid(raw: string): boolean;
49
+ static from(raw: string): ProviderId;
50
+ static parse(raw: string): ProviderId | null;
51
+ toString(): string;
52
+ }
53
+ //#endregion
54
+ //#region src/party-id.d.ts
55
+ declare class PartyId {
56
+ readonly countryCode: CountryCode;
57
+ readonly partyCode: string;
58
+ private constructor();
59
+ static parse(raw: string): PartyId | null;
60
+ static parseStrict(raw: string): PartyId;
61
+ static fromCountryAndProvider(countryCode: CountryCode, providerId: ProviderId): PartyId;
62
+ static fromCountryAndOperator(countryCode: CountryCode, operatorId: OperatorIdIso): PartyId;
63
+ toCompactString(): string;
64
+ toString(): string;
65
+ }
66
+ //#endregion
67
+ //#region src/contract-id.d.ts
68
+ declare class ContractId {
69
+ readonly standard: ContractIdStandard;
70
+ readonly countryCode: CountryCode;
71
+ readonly providerId: ProviderId;
72
+ readonly instanceValue: string;
73
+ readonly checkDigit: string;
74
+ private constructor();
75
+ static fromParts(standard: ContractIdStandard, countryCode: string | CountryCode, providerId: string | ProviderId, instanceValue: string, checkDigit?: string): ContractId;
76
+ static parse(standard: ContractIdStandard, raw: string): ContractId | null;
77
+ static parseStrict(standard: ContractIdStandard, raw: string): ContractId;
78
+ toCompactString(): string;
79
+ toCompactStringWithoutCheckDigit(): string;
80
+ get partyId(): PartyId;
81
+ convertTo(targetStandard: ContractIdStandard): ContractId;
82
+ toString(): string;
83
+ }
84
+ //#endregion
85
+ //#region src/phone-country-code.d.ts
86
+ declare class PhoneCountryCode {
87
+ readonly value: string;
88
+ private constructor();
89
+ static isValid(raw: string): boolean;
90
+ static from(raw: string): PhoneCountryCode;
91
+ static parse(raw: string): PhoneCountryCode | null;
92
+ toString(): string;
93
+ }
94
+ //#endregion
95
+ //#region src/evse-id.d.ts
96
+ declare abstract class EvseIdBase {
97
+ abstract readonly countryCode: CountryCode | PhoneCountryCode;
98
+ abstract readonly operatorId: OperatorId;
99
+ abstract readonly powerOutletId: string;
100
+ abstract toString(): string;
101
+ }
102
+ declare class EvseIdIso extends EvseIdBase {
103
+ readonly countryCode: CountryCode;
104
+ readonly operatorId: OperatorIdIso;
105
+ readonly powerOutletId: string;
106
+ constructor(countryCode: CountryCode, operatorId: OperatorIdIso, powerOutletId: string);
107
+ static fromParts(countryCode: string, operatorId: string, powerOutletId: string): EvseIdIso;
108
+ static parse(raw: string): EvseIdIso | null;
109
+ static parseStrict(raw: string): EvseIdIso;
110
+ get partyId(): PartyId;
111
+ toCompactString(): string;
112
+ toString(): string;
113
+ }
114
+ declare class EvseIdDin extends EvseIdBase {
115
+ readonly countryCode: PhoneCountryCode;
116
+ readonly operatorId: OperatorIdDin;
117
+ readonly powerOutletId: string;
118
+ constructor(countryCode: PhoneCountryCode, operatorId: OperatorIdDin, powerOutletId: string);
119
+ static fromParts(countryCode: string, operatorId: string, powerOutletId: string): EvseIdDin;
120
+ static parse(raw: string): EvseIdDin | null;
121
+ static parseStrict(raw: string): EvseIdDin;
122
+ toString(): string;
123
+ }
124
+ type EvseId = EvseIdIso | EvseIdDin;
125
+ declare const EvseId: {
126
+ fromParts(countryCode: string, operatorId: string, powerOutletId: string): EvseId;
127
+ parse(raw: string): EvseId | null;
128
+ parseStrict(raw: string): EvseId;
129
+ };
130
+ //#endregion
131
+ //#region src/parsers.d.ts
132
+ declare const MobilityIdParsers: {
133
+ parseCountryCode(raw: string): CountryCode | null;
134
+ parsePhoneCountryCode(raw: string): PhoneCountryCode | null;
135
+ parseProviderId(raw: string): ProviderId | null;
136
+ parseOperatorIdIso(raw: string): OperatorIdIso | null;
137
+ parseOperatorIdDin(raw: string): OperatorIdDin | null;
138
+ parsePartyId(raw: string): PartyId | null;
139
+ parseContractIdIso(raw: string): ContractId | null;
140
+ parseContractIdDin(raw: string): ContractId | null;
141
+ parseContractIdEmi3(raw: string): ContractId | null;
142
+ parseEvseId(raw: string): EvseId | null;
143
+ parseEvseIdIso(raw: string): EvseIdIso | null;
144
+ parseEvseIdDin(raw: string): EvseIdDin | null;
145
+ };
146
+ //#endregion
147
+ export { ContractId, type ContractIdStandard, ContractIdStandards, CountryCode, EvseId, type EvseId as EvseIdValue, EvseIdDin, EvseIdIso, MobilityIdParsers, type OperatorId, OperatorIdDin, OperatorIdIso, PartyId, PhoneCountryCode, ProviderId, checkDigitDin, checkDigitIso };
148
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,628 @@
1
+ //#region src/check-digit-din.ts
2
+ const values = /* @__PURE__ */ new Map();
3
+ for (let index = 0; index <= 9; index += 1) values.set(String(index), index);
4
+ for (let index = 0; index < 26; index += 1) values.set(String.fromCharCode("A".charCodeAt(0) + index), 10 + index);
5
+ function checkDigitDin(code) {
6
+ const normalized = code.toUpperCase();
7
+ const lookup = Array.from(normalized, (char) => {
8
+ const value = values.get(char);
9
+ if (value === void 0) throw new TypeError(`invalid character '${char}' in code '${code}'; must consist of uppercase ASCII letters and digits`);
10
+ return value;
11
+ });
12
+ let sum = 0;
13
+ let coefficient = 0;
14
+ for (const current of lookup) {
15
+ if (current < 10) {
16
+ sum += current * 2 ** coefficient;
17
+ coefficient += 1;
18
+ continue;
19
+ }
20
+ sum += Math.floor(current / 10) * 2 ** coefficient + current % 10 * 2 ** (coefficient + 1);
21
+ coefficient += 2;
22
+ }
23
+ const mod = sum % 11;
24
+ if (mod >= 10) return "X";
25
+ return String(mod);
26
+ }
27
+ //#endregion
28
+ //#region src/check-digit-iso.ts
29
+ const checkDigitInputRegex = /^[A-Z0-9]+$/;
30
+ const matrixKey = (m) => `${m.m11},${m.m12},${m.m21},${m.m22}`;
31
+ const multiplyMatrix = (a, b) => ({
32
+ m11: a.m11 * b.m11 + a.m12 * b.m21,
33
+ m12: a.m11 * b.m12 + a.m12 * b.m22,
34
+ m21: a.m21 * b.m11 + a.m22 * b.m21,
35
+ m22: a.m21 * b.m12 + a.m22 * b.m22
36
+ });
37
+ const addVec = (a, b) => ({
38
+ v1: a.v1 + b.v1,
39
+ v2: a.v2 + b.v2
40
+ });
41
+ const multiplyVec = (v, m) => ({
42
+ v1: v.v1 * m.m11 + v.v2 * m.m21,
43
+ v2: v.v1 * m.m12 + v.v2 * m.m22
44
+ });
45
+ const decodeMatrix = (x) => ({
46
+ m11: x & 1,
47
+ m12: x >> 1 & 1,
48
+ m21: x >> 2 & 3,
49
+ m22: x >> 4
50
+ });
51
+ const encodingValues = {
52
+ "0": 0,
53
+ "1": 16,
54
+ "2": 32,
55
+ "3": 4,
56
+ "4": 20,
57
+ "5": 36,
58
+ "6": 8,
59
+ "7": 24,
60
+ "8": 40,
61
+ "9": 2,
62
+ A: 18,
63
+ B: 34,
64
+ C: 6,
65
+ D: 22,
66
+ E: 38,
67
+ F: 10,
68
+ G: 26,
69
+ H: 42,
70
+ I: 1,
71
+ J: 17,
72
+ K: 33,
73
+ L: 5,
74
+ M: 21,
75
+ N: 37,
76
+ O: 9,
77
+ P: 25,
78
+ Q: 41,
79
+ R: 3,
80
+ S: 19,
81
+ T: 35,
82
+ U: 7,
83
+ V: 23,
84
+ W: 39,
85
+ X: 11,
86
+ Y: 27,
87
+ Z: 43
88
+ };
89
+ const encoding = /* @__PURE__ */ new Map();
90
+ const decoding = /* @__PURE__ */ new Map();
91
+ for (const [char, value] of Object.entries(encodingValues)) {
92
+ const matrix = decodeMatrix(value);
93
+ encoding.set(char, matrix);
94
+ decoding.set(matrixKey(matrix), char);
95
+ }
96
+ const p1 = {
97
+ m11: 0,
98
+ m12: 1,
99
+ m21: 1,
100
+ m22: 1
101
+ };
102
+ const p2 = {
103
+ m11: 0,
104
+ m12: 1,
105
+ m21: 1,
106
+ m22: 2
107
+ };
108
+ const p1s = [];
109
+ const p2s = [];
110
+ let currentP1 = p1;
111
+ let currentP2 = p2;
112
+ for (let index = 0; index < 14; index += 1) {
113
+ p1s.push(currentP1);
114
+ p2s.push(currentP2);
115
+ currentP1 = multiplyMatrix(currentP1, p1);
116
+ currentP2 = multiplyMatrix(currentP2, p2);
117
+ }
118
+ const negP2minus15 = {
119
+ m11: 0,
120
+ m12: 2,
121
+ m21: 2,
122
+ m22: 1
123
+ };
124
+ function checkDigitIso(code) {
125
+ const normalized = code.toUpperCase();
126
+ if (normalized.length !== p1s.length || normalized.length !== p2s.length) throw new TypeError(`Code must have a length of ${p1s.length}`);
127
+ if (!checkDigitInputRegex.test(normalized)) throw new TypeError("Code must consist of uppercase ASCII letters and digits");
128
+ const sumEq = (matrices, toVec) => {
129
+ let value = {
130
+ v1: 0,
131
+ v2: 0
132
+ };
133
+ for (let index = 0; index < matrices.length; index += 1) {
134
+ const character = normalized.charAt(index);
135
+ const matrix = encoding.get(character);
136
+ if (!matrix) throw new TypeError(`Invalid character: ${character}.`);
137
+ const positionMatrix = matrices[index];
138
+ if (!positionMatrix) throw new TypeError(`Missing matrix at index: ${index}.`);
139
+ const qr = toVec(matrix);
140
+ value = addVec(value, multiplyVec(qr, positionMatrix));
141
+ }
142
+ return value;
143
+ };
144
+ const t1 = sumEq(p1s, (matrix) => ({
145
+ v1: matrix.m11,
146
+ v2: matrix.m12
147
+ }));
148
+ const t2 = multiplyVec(sumEq(p2s, (matrix) => ({
149
+ v1: matrix.m21,
150
+ v2: matrix.m22
151
+ })), negP2minus15);
152
+ const m15 = {
153
+ m11: t1.v1 & 1,
154
+ m12: t1.v2 & 1,
155
+ m21: t2.v1 % 3,
156
+ m22: t2.v2 % 3
157
+ };
158
+ const decoded = decoding.get(matrixKey(m15));
159
+ if (!decoded) throw new TypeError(`Undecodable matrix: ${matrixKey(m15)}.`);
160
+ return decoded;
161
+ }
162
+ //#endregion
163
+ //#region src/contract-id-standard.ts
164
+ const ContractIdStandards = {
165
+ ISO: "ISO",
166
+ EMI3: "EMI3",
167
+ DIN: "DIN"
168
+ };
169
+ //#endregion
170
+ //#region src/country-code.ts
171
+ const COUNTRY_CODE_REGEX = /^[A-Za-z]{2}$/;
172
+ const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
173
+ var CountryCode = class CountryCode {
174
+ value;
175
+ constructor(value) {
176
+ this.value = value;
177
+ Object.freeze(this);
178
+ }
179
+ static isValid(raw) {
180
+ if (!COUNTRY_CODE_REGEX.test(raw)) return false;
181
+ const normalized = raw.toUpperCase();
182
+ const display = regionNames.of(normalized);
183
+ return display !== void 0 && display !== normalized && display !== "Unknown Region";
184
+ }
185
+ static from(raw) {
186
+ if (!CountryCode.isValid(raw)) throw new TypeError("Country Code must be valid according to ISO 3166-1 alpha-2");
187
+ return new CountryCode(raw.toUpperCase());
188
+ }
189
+ static parse(raw) {
190
+ try {
191
+ return CountryCode.from(raw);
192
+ } catch {
193
+ return null;
194
+ }
195
+ }
196
+ toString() {
197
+ return this.value;
198
+ }
199
+ };
200
+ //#endregion
201
+ //#region src/provider-id.ts
202
+ const PARTY_CODE_REGEX = /^[A-Za-z0-9]{3}$/;
203
+ function isValidPartyCode(value) {
204
+ return PARTY_CODE_REGEX.test(value);
205
+ }
206
+ var ProviderId = class ProviderId {
207
+ value;
208
+ constructor(value) {
209
+ this.value = value;
210
+ Object.freeze(this);
211
+ }
212
+ static isValid(raw) {
213
+ return isValidPartyCode(raw);
214
+ }
215
+ static from(raw) {
216
+ if (!ProviderId.isValid(raw)) throw new TypeError("OperatorId must have a length of 3 and be ASCII letters or digits");
217
+ return new ProviderId(raw.toUpperCase());
218
+ }
219
+ static parse(raw) {
220
+ try {
221
+ return ProviderId.from(raw);
222
+ } catch {
223
+ return null;
224
+ }
225
+ }
226
+ toString() {
227
+ return this.value;
228
+ }
229
+ };
230
+ //#endregion
231
+ //#region src/party-id.ts
232
+ const PARTY_ID_REGEX = /^([A-Za-z]{2})[-*]?([A-Za-z0-9]{3})$/;
233
+ var PartyId = class PartyId {
234
+ countryCode;
235
+ partyCode;
236
+ constructor(countryCode, partyCode) {
237
+ this.countryCode = countryCode;
238
+ this.partyCode = partyCode;
239
+ Object.freeze(this);
240
+ }
241
+ static parse(raw) {
242
+ const match = PARTY_ID_REGEX.exec(raw);
243
+ if (!match) return null;
244
+ try {
245
+ const country = match[1];
246
+ const party = match[2];
247
+ if (country === void 0 || party === void 0) return null;
248
+ const countryCode = CountryCode.from(country);
249
+ const partyCode = ProviderId.from(party).value;
250
+ return new PartyId(countryCode, partyCode);
251
+ } catch {
252
+ return null;
253
+ }
254
+ }
255
+ static parseStrict(raw) {
256
+ const parsed = PartyId.parse(raw);
257
+ if (parsed === null) throw new TypeError(`Invalid party ID: ${raw}`);
258
+ return parsed;
259
+ }
260
+ static fromCountryAndProvider(countryCode, providerId) {
261
+ return new PartyId(countryCode, providerId.value);
262
+ }
263
+ static fromCountryAndOperator(countryCode, operatorId) {
264
+ return new PartyId(countryCode, operatorId.value);
265
+ }
266
+ toCompactString() {
267
+ return `${this.countryCode.toString()}${this.partyCode}`;
268
+ }
269
+ toString() {
270
+ return `${this.countryCode.toString()}-${this.partyCode}`;
271
+ }
272
+ };
273
+ //#endregion
274
+ //#region src/contract-id.ts
275
+ const parsers = {
276
+ ISO: {
277
+ instanceRegex: /^([A-Za-z0-9]{9})$/,
278
+ fullRegex: /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([A-Za-z0-9]{9})(?:(?:-?)([A-Za-z0-9]))?$/,
279
+ name: "ISO 15118-1",
280
+ computeCheckDigit: checkDigitIso
281
+ },
282
+ EMI3: {
283
+ instanceRegex: /^([Cc][A-Za-z0-9]{8})$/,
284
+ fullRegex: /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([Cc][A-Za-z0-9]{8})(?:(?:-?)([A-Za-z0-9]))?$/,
285
+ name: "EMI3",
286
+ computeCheckDigit: checkDigitIso
287
+ },
288
+ DIN: {
289
+ instanceRegex: /^([A-Za-z0-9]{6})$/,
290
+ fullRegex: /^([A-Za-z]{2})(?:[*-]?)([A-Za-z0-9]{3})(?:[*-]?)([A-Za-z0-9]{6})(?:(?:[*-]?)([A-Za-z0-9]))?$/,
291
+ name: "DIN SPEC 91286",
292
+ computeCheckDigit: checkDigitDin
293
+ }
294
+ };
295
+ var ContractId = class ContractId {
296
+ standard;
297
+ countryCode;
298
+ providerId;
299
+ instanceValue;
300
+ checkDigit;
301
+ constructor(standard, countryCode, providerId, instanceValue, checkDigit) {
302
+ this.standard = standard;
303
+ this.countryCode = countryCode;
304
+ this.providerId = providerId;
305
+ this.instanceValue = instanceValue;
306
+ this.checkDigit = checkDigit;
307
+ Object.freeze(this);
308
+ }
309
+ static fromParts(standard, countryCode, providerId, instanceValue, checkDigit) {
310
+ const parser = parsers[standard];
311
+ const cc = typeof countryCode === "string" ? CountryCode.from(countryCode) : countryCode;
312
+ const provider = typeof providerId === "string" ? ProviderId.from(providerId) : providerId;
313
+ const normalizedInstance = instanceValue.toUpperCase();
314
+ if (!parser.instanceRegex.test(normalizedInstance)) throw new TypeError(`${instanceValue} is not a valid instance value for ${parser.name} format`);
315
+ const computed = parser.computeCheckDigit(`${cc.toString()}${provider.toString()}${normalizedInstance}`);
316
+ if (checkDigit !== void 0 && checkDigit.toUpperCase() !== computed) throw new TypeError(`Given check digit '${checkDigit}' is not equal to computed '${computed}'`);
317
+ return new ContractId(standard, cc, provider, normalizedInstance, computed);
318
+ }
319
+ static parse(standard, raw) {
320
+ try {
321
+ return ContractId.parseStrict(standard, raw);
322
+ } catch {
323
+ return null;
324
+ }
325
+ }
326
+ static parseStrict(standard, raw) {
327
+ const parser = parsers[standard];
328
+ const match = parser.fullRegex.exec(raw);
329
+ if (!match || match[1] === void 0 || match[2] === void 0 || match[3] === void 0) throw new TypeError(`${raw} is not a valid Contract Id for ${parser.name}`);
330
+ const [, country, provider, instance, check] = match;
331
+ return ContractId.fromParts(standard, country, provider, instance, check);
332
+ }
333
+ toCompactString() {
334
+ return `${this.countryCode.toString()}${this.providerId.toString()}${this.instanceValue}${this.checkDigit}`;
335
+ }
336
+ toCompactStringWithoutCheckDigit() {
337
+ return `${this.countryCode.toString()}${this.providerId.toString()}${this.instanceValue}`;
338
+ }
339
+ get partyId() {
340
+ return PartyId.fromCountryAndProvider(this.countryCode, this.providerId);
341
+ }
342
+ convertTo(targetStandard) {
343
+ if (targetStandard === this.standard) return this;
344
+ if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.EMI3) return ContractId.fromParts(ContractIdStandards.EMI3, this.countryCode, this.providerId, `C0${this.instanceValue}${this.checkDigit}`);
345
+ if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.DIN) {
346
+ if (!this.instanceValue.startsWith("C0")) throw new TypeError(`${this.toString()} cannot be converted to ${parsers.DIN.name} format`);
347
+ const dinInstance = this.instanceValue.slice(2, 8);
348
+ const dinCheck = this.instanceValue.slice(8, 9);
349
+ return ContractId.fromParts(ContractIdStandards.DIN, this.countryCode, this.providerId, dinInstance, dinCheck);
350
+ }
351
+ if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.DIN) {
352
+ if (!this.instanceValue.startsWith("00")) throw new TypeError(`${this.toString()} cannot be converted to ${parsers.DIN.name} format`);
353
+ const dinInstance = this.instanceValue.slice(2, 8);
354
+ const dinCheck = this.instanceValue.slice(8, 9);
355
+ return ContractId.fromParts(ContractIdStandards.DIN, this.countryCode, this.providerId, dinInstance, dinCheck);
356
+ }
357
+ if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.ISO) return ContractId.fromParts(ContractIdStandards.ISO, this.countryCode, this.providerId, `00${this.instanceValue}${this.checkDigit}`);
358
+ if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.ISO) return ContractId.fromParts(ContractIdStandards.ISO, this.countryCode, this.providerId, this.instanceValue, this.checkDigit);
359
+ if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.EMI3) return ContractId.fromParts(ContractIdStandards.EMI3, this.countryCode, this.providerId, this.instanceValue, this.checkDigit);
360
+ throw new TypeError(`It is not possible to convert ${this.standard} to ${targetStandard}`);
361
+ }
362
+ toString() {
363
+ return `${this.countryCode.toString()}-${this.providerId.toString()}-${this.instanceValue}-${this.checkDigit}`;
364
+ }
365
+ };
366
+ //#endregion
367
+ //#region src/operator-id.ts
368
+ const OPERATOR_DIN_REGEX = /^[0-9]{3,6}$/;
369
+ var OperatorIdIso = class OperatorIdIso {
370
+ value;
371
+ constructor(value) {
372
+ this.value = value;
373
+ Object.freeze(this);
374
+ }
375
+ static isValid(raw) {
376
+ return isValidPartyCode(raw);
377
+ }
378
+ static from(raw) {
379
+ if (!OperatorIdIso.isValid(raw)) throw new TypeError("OperatorId must have a length of 3 and be ASCII letters or digits");
380
+ return new OperatorIdIso(raw.toUpperCase());
381
+ }
382
+ static parse(raw) {
383
+ try {
384
+ return OperatorIdIso.from(raw);
385
+ } catch {
386
+ return null;
387
+ }
388
+ }
389
+ toString() {
390
+ return this.value;
391
+ }
392
+ };
393
+ var OperatorIdDin = class OperatorIdDin {
394
+ value;
395
+ constructor(value) {
396
+ this.value = value;
397
+ Object.freeze(this);
398
+ }
399
+ static isValid(raw) {
400
+ return OPERATOR_DIN_REGEX.test(raw);
401
+ }
402
+ static from(raw) {
403
+ if (!OperatorIdDin.isValid(raw)) throw new TypeError("OperatorId must have a length of 3-6 chars and be digits");
404
+ return new OperatorIdDin(raw.toUpperCase());
405
+ }
406
+ static parse(raw) {
407
+ try {
408
+ return OperatorIdDin.from(raw);
409
+ } catch {
410
+ return null;
411
+ }
412
+ }
413
+ toString() {
414
+ return this.value;
415
+ }
416
+ };
417
+ //#endregion
418
+ //#region src/phone-country-code.ts
419
+ const PHONE_COUNTRY_CODE_REGEX = /^\+?[0-9]{1,3}$/;
420
+ var PhoneCountryCode = class PhoneCountryCode {
421
+ value;
422
+ constructor(value) {
423
+ this.value = value;
424
+ Object.freeze(this);
425
+ }
426
+ static isValid(raw) {
427
+ return PHONE_COUNTRY_CODE_REGEX.test(raw);
428
+ }
429
+ static from(raw) {
430
+ if (!PhoneCountryCode.isValid(raw)) throw new TypeError(`phone Country Code must start with a '+' sign and be followed by 1-3 digits. (Was: ${raw})`);
431
+ return new PhoneCountryCode(raw);
432
+ }
433
+ static parse(raw) {
434
+ try {
435
+ return PhoneCountryCode.from(raw);
436
+ } catch {
437
+ return null;
438
+ }
439
+ }
440
+ toString() {
441
+ return this.value;
442
+ }
443
+ };
444
+ //#endregion
445
+ //#region src/evse-id.ts
446
+ const ISO_COUNTRY_REGEX = /^([A-Za-z]{2})$/;
447
+ const ISO_OPERATOR_REGEX = /^([A-Za-z0-9]{3})$/;
448
+ const ISO_POWER_OUTLET_REGEX = /^([A-Za-z0-9*]{1,31})$/;
449
+ const ISO_EVSE_REGEX = /^([A-Za-z]{2})\*?([A-Za-z0-9]{3})\*?E([A-Za-z0-9*]{1,31})$/;
450
+ const DIN_COUNTRY_REGEX = /^(\+?[0-9]{1,3})$/;
451
+ const DIN_OPERATOR_REGEX = /^([0-9]{3,6})$/;
452
+ const DIN_POWER_OUTLET_REGEX = /^([0-9*]{1,32})$/;
453
+ const DIN_EVSE_REGEX = /^(\+?[0-9]{1,3})\*([0-9]{3,6})\*([0-9*]{1,32})$/;
454
+ var EvseIdBase = class {};
455
+ var EvseIdIso = class EvseIdIso extends EvseIdBase {
456
+ countryCode;
457
+ operatorId;
458
+ powerOutletId;
459
+ constructor(countryCode, operatorId, powerOutletId) {
460
+ super();
461
+ this.countryCode = countryCode;
462
+ this.operatorId = operatorId;
463
+ this.powerOutletId = powerOutletId;
464
+ Object.freeze(this);
465
+ }
466
+ static fromParts(countryCode, operatorId, powerOutletId) {
467
+ return createIso(countryCode.toUpperCase(), operatorId.toUpperCase(), powerOutletId.toUpperCase());
468
+ }
469
+ static parse(raw) {
470
+ const match = ISO_EVSE_REGEX.exec(raw);
471
+ if (!match || match[1] === void 0 || match[2] === void 0 || match[3] === void 0) return null;
472
+ try {
473
+ return createIso(match[1].toUpperCase(), match[2].toUpperCase(), match[3].toUpperCase());
474
+ } catch {
475
+ return null;
476
+ }
477
+ }
478
+ static parseStrict(raw) {
479
+ const parsed = EvseIdIso.parse(raw);
480
+ if (parsed === null) throw new TypeError(`Invalid ISO EVSE ID: ${raw}`);
481
+ return parsed;
482
+ }
483
+ get partyId() {
484
+ return PartyId.fromCountryAndOperator(this.countryCode, this.operatorId);
485
+ }
486
+ toCompactString() {
487
+ return this.toString().replaceAll("*", "");
488
+ }
489
+ toString() {
490
+ return `${this.countryCode.toString()}*${this.operatorId.toString()}*E${this.powerOutletId}`;
491
+ }
492
+ };
493
+ var EvseIdDin = class EvseIdDin extends EvseIdBase {
494
+ countryCode;
495
+ operatorId;
496
+ powerOutletId;
497
+ constructor(countryCode, operatorId, powerOutletId) {
498
+ super();
499
+ this.countryCode = countryCode;
500
+ this.operatorId = operatorId;
501
+ this.powerOutletId = powerOutletId;
502
+ Object.freeze(this);
503
+ }
504
+ static fromParts(countryCode, operatorId, powerOutletId) {
505
+ return createDin(countryCode.toUpperCase(), operatorId.toUpperCase(), powerOutletId.toUpperCase());
506
+ }
507
+ static parse(raw) {
508
+ const match = DIN_EVSE_REGEX.exec(raw);
509
+ if (!match || match[1] === void 0 || match[2] === void 0 || match[3] === void 0) return null;
510
+ try {
511
+ return createDin(match[1].toUpperCase(), match[2].toUpperCase(), match[3].toUpperCase());
512
+ } catch {
513
+ return null;
514
+ }
515
+ }
516
+ static parseStrict(raw) {
517
+ const parsed = EvseIdDin.parse(raw);
518
+ if (parsed === null) throw new TypeError(`Invalid DIN EVSE ID: ${raw}`);
519
+ return parsed;
520
+ }
521
+ toString() {
522
+ return `${this.countryCode.toString()}*${this.operatorId.toString()}*${this.powerOutletId}`;
523
+ }
524
+ };
525
+ function validateIso(countryCode, operatorId, powerOutletId) {
526
+ if (!ISO_COUNTRY_REGEX.test(countryCode)) return {
527
+ priority: 1,
528
+ description: "Invalid countryCode for ISO or DIN format"
529
+ };
530
+ if (!ISO_OPERATOR_REGEX.test(operatorId)) return {
531
+ priority: 2,
532
+ description: "Invalid operatorId for ISO format"
533
+ };
534
+ if (!ISO_POWER_OUTLET_REGEX.test(powerOutletId)) return {
535
+ priority: 3,
536
+ description: "Invalid powerOutletId for ISO format"
537
+ };
538
+ return null;
539
+ }
540
+ function validateDin(countryCode, operatorId, powerOutletId) {
541
+ if (!DIN_COUNTRY_REGEX.test(countryCode)) return {
542
+ priority: 1,
543
+ description: "Invalid countryCode for ISO or DIN format"
544
+ };
545
+ if (!DIN_OPERATOR_REGEX.test(operatorId)) return {
546
+ priority: 2,
547
+ description: "Invalid operatorId for DIN format"
548
+ };
549
+ if (!DIN_POWER_OUTLET_REGEX.test(powerOutletId)) return {
550
+ priority: 3,
551
+ description: "Invalid powerOutletId for DIN format"
552
+ };
553
+ return null;
554
+ }
555
+ function createIso(countryCode, operatorId, powerOutletId) {
556
+ return new EvseIdIso(CountryCode.from(countryCode), OperatorIdIso.from(operatorId), powerOutletId.startsWith("E") ? powerOutletId.slice(1) : powerOutletId);
557
+ }
558
+ function createDin(countryCode, operatorId, powerOutletId) {
559
+ const countryWithPlus = countryCode.startsWith("+") ? countryCode : `+${countryCode}`;
560
+ return new EvseIdDin(PhoneCountryCode.from(countryWithPlus), OperatorIdDin.from(operatorId), powerOutletId);
561
+ }
562
+ const EvseId = {
563
+ fromParts(countryCode, operatorId, powerOutletId) {
564
+ const normalizedCountry = countryCode.toUpperCase();
565
+ const normalizedOperator = operatorId.toUpperCase();
566
+ const normalizedPowerOutlet = powerOutletId.toUpperCase();
567
+ const isoError = validateIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);
568
+ if (isoError === null) return createIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);
569
+ const dinError = validateDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);
570
+ if (dinError === null) return createDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);
571
+ if (isoError.priority >= dinError.priority) throw new TypeError(isoError.description);
572
+ throw new TypeError(dinError.description);
573
+ },
574
+ parse(raw) {
575
+ const iso = EvseIdIso.parse(raw);
576
+ if (iso !== null) return iso;
577
+ return EvseIdDin.parse(raw);
578
+ },
579
+ parseStrict(raw) {
580
+ const parsed = this.parse(raw);
581
+ if (parsed === null) throw new TypeError(`Invalid EVSE ID: ${raw}`);
582
+ return parsed;
583
+ }
584
+ };
585
+ //#endregion
586
+ //#region src/parsers.ts
587
+ const MobilityIdParsers = {
588
+ parseCountryCode(raw) {
589
+ return CountryCode.parse(raw);
590
+ },
591
+ parsePhoneCountryCode(raw) {
592
+ return PhoneCountryCode.parse(raw);
593
+ },
594
+ parseProviderId(raw) {
595
+ return ProviderId.parse(raw);
596
+ },
597
+ parseOperatorIdIso(raw) {
598
+ return OperatorIdIso.parse(raw);
599
+ },
600
+ parseOperatorIdDin(raw) {
601
+ return OperatorIdDin.parse(raw);
602
+ },
603
+ parsePartyId(raw) {
604
+ return PartyId.parse(raw);
605
+ },
606
+ parseContractIdIso(raw) {
607
+ return ContractId.parse(ContractIdStandards.ISO, raw);
608
+ },
609
+ parseContractIdDin(raw) {
610
+ return ContractId.parse(ContractIdStandards.DIN, raw);
611
+ },
612
+ parseContractIdEmi3(raw) {
613
+ return ContractId.parse(ContractIdStandards.EMI3, raw);
614
+ },
615
+ parseEvseId(raw) {
616
+ return EvseId.parse(raw);
617
+ },
618
+ parseEvseIdIso(raw) {
619
+ return EvseIdIso.parse(raw);
620
+ },
621
+ parseEvseIdDin(raw) {
622
+ return EvseIdDin.parse(raw);
623
+ }
624
+ };
625
+ //#endregion
626
+ export { ContractId, ContractIdStandards, CountryCode, EvseId, EvseIdDin, EvseIdIso, MobilityIdParsers, OperatorIdDin, OperatorIdIso, PartyId, PhoneCountryCode, ProviderId, checkDigitDin, checkDigitIso };
627
+
628
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/check-digit-din.ts","../src/check-digit-iso.ts","../src/contract-id-standard.ts","../src/country-code.ts","../src/provider-id.ts","../src/party-id.ts","../src/contract-id.ts","../src/operator-id.ts","../src/phone-country-code.ts","../src/evse-id.ts","../src/parsers.ts"],"sourcesContent":["/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst values = new Map<string, number>();\n\nfor (let index = 0; index <= 9; index += 1) {\n values.set(String(index), index);\n}\n\nfor (let index = 0; index < 26; index += 1) {\n values.set(String.fromCharCode(\"A\".charCodeAt(0) + index), 10 + index);\n}\n\nexport function checkDigitDin(code: string): string {\n const normalized = code.toUpperCase();\n const lookup = Array.from(normalized, (char) => {\n const value = values.get(char);\n if (value === undefined) {\n throw new TypeError(\n `invalid character '${char}' in code '${code}'; must consist of uppercase ASCII letters and digits`,\n );\n }\n\n return value;\n });\n\n let sum = 0;\n let coefficient = 0;\n\n for (const current of lookup) {\n if (current < 10) {\n sum += current * 2 ** coefficient;\n coefficient += 1;\n continue;\n }\n\n sum += Math.floor(current / 10) * 2 ** coefficient + (current % 10) * 2 ** (coefficient + 1);\n coefficient += 2;\n }\n\n const mod = sum % 11;\n\n if (mod >= 10) {\n return \"X\";\n }\n\n return String(mod);\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype Matrix = Readonly<{ m11: number; m12: number; m21: number; m22: number }>;\ntype Vec = Readonly<{ v1: number; v2: number }>;\n\nconst checkDigitInputRegex = /^[A-Z0-9]+$/;\n\nconst matrixKey = (m: Matrix): string => `${m.m11},${m.m12},${m.m21},${m.m22}`;\n\nconst multiplyMatrix = (a: Matrix, b: Matrix): Matrix => ({\n m11: a.m11 * b.m11 + a.m12 * b.m21,\n m12: a.m11 * b.m12 + a.m12 * b.m22,\n m21: a.m21 * b.m11 + a.m22 * b.m21,\n m22: a.m21 * b.m12 + a.m22 * b.m22,\n});\n\nconst addVec = (a: Vec, b: Vec): Vec => ({\n v1: a.v1 + b.v1,\n v2: a.v2 + b.v2,\n});\n\nconst multiplyVec = (v: Vec, m: Matrix): Vec => ({\n v1: v.v1 * m.m11 + v.v2 * m.m21,\n v2: v.v1 * m.m12 + v.v2 * m.m22,\n});\n\nconst decodeMatrix = (x: number): Matrix => ({\n m11: x & 1,\n m12: (x >> 1) & 1,\n m21: (x >> 2) & 3,\n m22: x >> 4,\n});\n\nconst encodingValues: Readonly<Record<string, number>> = {\n \"0\": 0,\n \"1\": 16,\n \"2\": 32,\n \"3\": 4,\n \"4\": 20,\n \"5\": 36,\n \"6\": 8,\n \"7\": 24,\n \"8\": 40,\n \"9\": 2,\n A: 18,\n B: 34,\n C: 6,\n D: 22,\n E: 38,\n F: 10,\n G: 26,\n H: 42,\n I: 1,\n J: 17,\n K: 33,\n L: 5,\n M: 21,\n N: 37,\n O: 9,\n P: 25,\n Q: 41,\n R: 3,\n S: 19,\n T: 35,\n U: 7,\n V: 23,\n W: 39,\n X: 11,\n Y: 27,\n Z: 43,\n};\n\nconst encoding = new Map<string, Matrix>();\nconst decoding = new Map<string, string>();\n\nfor (const [char, value] of Object.entries(encodingValues)) {\n const matrix = decodeMatrix(value);\n encoding.set(char, matrix);\n decoding.set(matrixKey(matrix), char);\n}\n\nconst p1: Matrix = { m11: 0, m12: 1, m21: 1, m22: 1 };\nconst p2: Matrix = { m11: 0, m12: 1, m21: 1, m22: 2 };\n\nconst p1s: Matrix[] = [];\nconst p2s: Matrix[] = [];\n\nlet currentP1 = p1;\nlet currentP2 = p2;\nfor (let index = 0; index < 14; index += 1) {\n p1s.push(currentP1);\n p2s.push(currentP2);\n currentP1 = multiplyMatrix(currentP1, p1);\n currentP2 = multiplyMatrix(currentP2, p2);\n}\n\nconst negP2minus15: Matrix = { m11: 0, m12: 2, m21: 2, m22: 1 };\n\nexport function checkDigitIso(code: string): string {\n const normalized = code.toUpperCase();\n\n if (normalized.length !== p1s.length || normalized.length !== p2s.length) {\n throw new TypeError(`Code must have a length of ${p1s.length}`);\n }\n\n if (!checkDigitInputRegex.test(normalized)) {\n throw new TypeError(\"Code must consist of uppercase ASCII letters and digits\");\n }\n\n const sumEq = (matrices: Matrix[], toVec: (matrix: Matrix) => Vec): Vec => {\n let value: Vec = { v1: 0, v2: 0 };\n\n for (let index = 0; index < matrices.length; index += 1) {\n const character = normalized.charAt(index);\n const matrix = encoding.get(character);\n if (!matrix) {\n throw new TypeError(`Invalid character: ${character}.`);\n }\n\n const positionMatrix = matrices[index];\n if (!positionMatrix) {\n throw new TypeError(`Missing matrix at index: ${index}.`);\n }\n\n const qr = toVec(matrix);\n value = addVec(value, multiplyVec(qr, positionMatrix));\n }\n\n return value;\n };\n\n const t1 = sumEq(p1s, (matrix) => ({ v1: matrix.m11, v2: matrix.m12 }));\n const t2 = multiplyVec(\n sumEq(p2s, (matrix) => ({ v1: matrix.m21, v2: matrix.m22 })),\n negP2minus15,\n );\n\n const m15: Matrix = {\n m11: t1.v1 & 1,\n m12: t1.v2 & 1,\n m21: t2.v1 % 3,\n m22: t2.v2 % 3,\n };\n\n const decoded = decoding.get(matrixKey(m15));\n if (!decoded) {\n throw new TypeError(`Undecodable matrix: ${matrixKey(m15)}.`);\n }\n\n return decoded;\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ContractIdStandards = {\n ISO: \"ISO\",\n EMI3: \"EMI3\",\n DIN: \"DIN\",\n} as const;\n\nexport type ContractIdStandard = (typeof ContractIdStandards)[keyof typeof ContractIdStandards];\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst COUNTRY_CODE_REGEX = /^[A-Za-z]{2}$/;\n\nconst regionNames = new Intl.DisplayNames([\"en\"], { type: \"region\" });\n\nexport class CountryCode {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n if (!COUNTRY_CODE_REGEX.test(raw)) {\n return false;\n }\n\n const normalized = raw.toUpperCase();\n const display = regionNames.of(normalized);\n return display !== undefined && display !== normalized && display !== \"Unknown Region\";\n }\n\n public static from(raw: string): CountryCode {\n if (!CountryCode.isValid(raw)) {\n throw new TypeError(\"Country Code must be valid according to ISO 3166-1 alpha-2\");\n }\n\n return new CountryCode(raw.toUpperCase());\n }\n\n public static parse(raw: string): CountryCode | null {\n try {\n return CountryCode.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PARTY_CODE_REGEX = /^[A-Za-z0-9]{3}$/;\n\nexport function isValidPartyCode(value: string): boolean {\n return PARTY_CODE_REGEX.test(value);\n}\n\nexport class ProviderId {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return isValidPartyCode(raw);\n }\n\n public static from(raw: string): ProviderId {\n if (!ProviderId.isValid(raw)) {\n throw new TypeError(\"OperatorId must have a length of 3 and be ASCII letters or digits\");\n }\n\n return new ProviderId(raw.toUpperCase());\n }\n\n public static parse(raw: string): ProviderId | null {\n try {\n return ProviderId.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CountryCode } from \"./country-code.js\";\nimport type { OperatorIdIso } from \"./operator-id.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\nconst PARTY_ID_REGEX = /^([A-Za-z]{2})[-*]?([A-Za-z0-9]{3})$/;\n\nexport class PartyId {\n public readonly countryCode: CountryCode;\n public readonly partyCode: string;\n\n private constructor(countryCode: CountryCode, partyCode: string) {\n this.countryCode = countryCode;\n this.partyCode = partyCode;\n Object.freeze(this);\n }\n\n public static parse(raw: string): PartyId | null {\n const match = PARTY_ID_REGEX.exec(raw);\n if (!match) {\n return null;\n }\n\n try {\n const country = match[1];\n const party = match[2];\n if (country === undefined || party === undefined) {\n return null;\n }\n\n const countryCode = CountryCode.from(country);\n const partyCode = ProviderId.from(party).value;\n return new PartyId(countryCode, partyCode);\n } catch {\n return null;\n }\n }\n\n public static parseStrict(raw: string): PartyId {\n const parsed = PartyId.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid party ID: ${raw}`);\n }\n\n return parsed;\n }\n\n public static fromCountryAndProvider(countryCode: CountryCode, providerId: ProviderId): PartyId {\n return new PartyId(countryCode, providerId.value);\n }\n\n public static fromCountryAndOperator(\n countryCode: CountryCode,\n operatorId: OperatorIdIso,\n ): PartyId {\n return new PartyId(countryCode, operatorId.value);\n }\n\n public toCompactString(): string {\n return `${this.countryCode.toString()}${this.partyCode}`;\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}-${this.partyCode}`;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { checkDigitDin } from \"./check-digit-din.js\";\nimport { checkDigitIso } from \"./check-digit-iso.js\";\nimport { ContractIdStandards, type ContractIdStandard } from \"./contract-id-standard.js\";\nimport { CountryCode } from \"./country-code.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\ntype Parser = Readonly<{\n instanceRegex: RegExp;\n fullRegex: RegExp;\n name: string;\n computeCheckDigit: (value: string) => string;\n}>;\n\nconst parsers: Readonly<Record<ContractIdStandard, Parser>> = {\n ISO: {\n instanceRegex: /^([A-Za-z0-9]{9})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([A-Za-z0-9]{9})(?:(?:-?)([A-Za-z0-9]))?$/,\n name: \"ISO 15118-1\",\n computeCheckDigit: checkDigitIso,\n },\n EMI3: {\n instanceRegex: /^([Cc][A-Za-z0-9]{8})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:-?)([A-Za-z0-9]{3})(?:-?)([Cc][A-Za-z0-9]{8})(?:(?:-?)([A-Za-z0-9]))?$/,\n name: \"EMI3\",\n computeCheckDigit: checkDigitIso,\n },\n DIN: {\n instanceRegex: /^([A-Za-z0-9]{6})$/,\n fullRegex:\n /^([A-Za-z]{2})(?:[*-]?)([A-Za-z0-9]{3})(?:[*-]?)([A-Za-z0-9]{6})(?:(?:[*-]?)([A-Za-z0-9]))?$/,\n name: \"DIN SPEC 91286\",\n computeCheckDigit: checkDigitDin,\n },\n};\n\nexport class ContractId {\n public readonly standard: ContractIdStandard;\n public readonly countryCode: CountryCode;\n public readonly providerId: ProviderId;\n public readonly instanceValue: string;\n public readonly checkDigit: string;\n\n private constructor(\n standard: ContractIdStandard,\n countryCode: CountryCode,\n providerId: ProviderId,\n instanceValue: string,\n checkDigit: string,\n ) {\n this.standard = standard;\n this.countryCode = countryCode;\n this.providerId = providerId;\n this.instanceValue = instanceValue;\n this.checkDigit = checkDigit;\n Object.freeze(this);\n }\n\n public static fromParts(\n standard: ContractIdStandard,\n countryCode: string | CountryCode,\n providerId: string | ProviderId,\n instanceValue: string,\n checkDigit?: string,\n ): ContractId {\n const parser = parsers[standard];\n const cc = typeof countryCode === \"string\" ? CountryCode.from(countryCode) : countryCode;\n const provider = typeof providerId === \"string\" ? ProviderId.from(providerId) : providerId;\n const normalizedInstance = instanceValue.toUpperCase();\n\n if (!parser.instanceRegex.test(normalizedInstance)) {\n throw new TypeError(\n `${instanceValue} is not a valid instance value for ${parser.name} format`,\n );\n }\n\n const computed = parser.computeCheckDigit(\n `${cc.toString()}${provider.toString()}${normalizedInstance}`,\n );\n if (checkDigit !== undefined && checkDigit.toUpperCase() !== computed) {\n throw new TypeError(\n `Given check digit '${checkDigit}' is not equal to computed '${computed}'`,\n );\n }\n\n return new ContractId(standard, cc, provider, normalizedInstance, computed);\n }\n\n public static parse(standard: ContractIdStandard, raw: string): ContractId | null {\n try {\n return ContractId.parseStrict(standard, raw);\n } catch {\n return null;\n }\n }\n\n public static parseStrict(standard: ContractIdStandard, raw: string): ContractId {\n const parser = parsers[standard];\n const match = parser.fullRegex.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n throw new TypeError(`${raw} is not a valid Contract Id for ${parser.name}`);\n }\n\n const [, country, provider, instance, check] = match;\n return ContractId.fromParts(standard, country, provider, instance, check);\n }\n\n public toCompactString(): string {\n return `${this.countryCode.toString()}${this.providerId.toString()}${this.instanceValue}${this.checkDigit}`;\n }\n\n public toCompactStringWithoutCheckDigit(): string {\n return `${this.countryCode.toString()}${this.providerId.toString()}${this.instanceValue}`;\n }\n\n public get partyId(): PartyId {\n return PartyId.fromCountryAndProvider(this.countryCode, this.providerId);\n }\n\n public convertTo(targetStandard: ContractIdStandard): ContractId {\n if (targetStandard === this.standard) {\n return this;\n }\n\n if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.EMI3) {\n return ContractId.fromParts(\n ContractIdStandards.EMI3,\n this.countryCode,\n this.providerId,\n `C0${this.instanceValue}${this.checkDigit}`,\n );\n }\n\n if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.DIN) {\n if (!this.instanceValue.startsWith(\"C0\")) {\n throw new TypeError(`${this.toString()} cannot be converted to ${parsers.DIN.name} format`);\n }\n\n const dinInstance = this.instanceValue.slice(2, 8);\n const dinCheck = this.instanceValue.slice(8, 9);\n return ContractId.fromParts(\n ContractIdStandards.DIN,\n this.countryCode,\n this.providerId,\n dinInstance,\n dinCheck,\n );\n }\n\n if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.DIN) {\n if (!this.instanceValue.startsWith(\"00\")) {\n throw new TypeError(`${this.toString()} cannot be converted to ${parsers.DIN.name} format`);\n }\n\n const dinInstance = this.instanceValue.slice(2, 8);\n const dinCheck = this.instanceValue.slice(8, 9);\n return ContractId.fromParts(\n ContractIdStandards.DIN,\n this.countryCode,\n this.providerId,\n dinInstance,\n dinCheck,\n );\n }\n\n if (this.standard === ContractIdStandards.DIN && targetStandard === ContractIdStandards.ISO) {\n return ContractId.fromParts(\n ContractIdStandards.ISO,\n this.countryCode,\n this.providerId,\n `00${this.instanceValue}${this.checkDigit}`,\n );\n }\n\n if (this.standard === ContractIdStandards.EMI3 && targetStandard === ContractIdStandards.ISO) {\n return ContractId.fromParts(\n ContractIdStandards.ISO,\n this.countryCode,\n this.providerId,\n this.instanceValue,\n this.checkDigit,\n );\n }\n\n if (this.standard === ContractIdStandards.ISO && targetStandard === ContractIdStandards.EMI3) {\n return ContractId.fromParts(\n ContractIdStandards.EMI3,\n this.countryCode,\n this.providerId,\n this.instanceValue,\n this.checkDigit,\n );\n }\n\n throw new TypeError(`It is not possible to convert ${this.standard} to ${targetStandard}`);\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}-${this.providerId.toString()}-${this.instanceValue}-${this.checkDigit}`;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isValidPartyCode } from \"./provider-id.js\";\n\nconst OPERATOR_DIN_REGEX = /^[0-9]{3,6}$/;\n\nexport class OperatorIdIso {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return isValidPartyCode(raw);\n }\n\n public static from(raw: string): OperatorIdIso {\n if (!OperatorIdIso.isValid(raw)) {\n throw new TypeError(\"OperatorId must have a length of 3 and be ASCII letters or digits\");\n }\n\n return new OperatorIdIso(raw.toUpperCase());\n }\n\n public static parse(raw: string): OperatorIdIso | null {\n try {\n return OperatorIdIso.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n\nexport class OperatorIdDin {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return OPERATOR_DIN_REGEX.test(raw);\n }\n\n public static from(raw: string): OperatorIdDin {\n if (!OperatorIdDin.isValid(raw)) {\n throw new TypeError(\"OperatorId must have a length of 3-6 chars and be digits\");\n }\n\n return new OperatorIdDin(raw.toUpperCase());\n }\n\n public static parse(raw: string): OperatorIdDin | null {\n try {\n return OperatorIdDin.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n\nexport type OperatorId = OperatorIdIso | OperatorIdDin;\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst PHONE_COUNTRY_CODE_REGEX = /^\\+?[0-9]{1,3}$/;\n\nexport class PhoneCountryCode {\n public readonly value: string;\n\n private constructor(value: string) {\n this.value = value;\n Object.freeze(this);\n }\n\n public static isValid(raw: string): boolean {\n return PHONE_COUNTRY_CODE_REGEX.test(raw);\n }\n\n public static from(raw: string): PhoneCountryCode {\n if (!PhoneCountryCode.isValid(raw)) {\n throw new TypeError(\n `phone Country Code must start with a '+' sign and be followed by 1-3 digits. (Was: ${raw})`,\n );\n }\n\n return new PhoneCountryCode(raw);\n }\n\n public static parse(raw: string): PhoneCountryCode | null {\n try {\n return PhoneCountryCode.from(raw);\n } catch {\n return null;\n }\n }\n\n public toString(): string {\n return this.value;\n }\n}\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CountryCode } from \"./country-code.js\";\nimport { OperatorIdDin, OperatorIdIso, type OperatorId } from \"./operator-id.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { PhoneCountryCode } from \"./phone-country-code.js\";\n\ntype ValidationError = Readonly<{ priority: number; description: string }>;\n\nconst ISO_COUNTRY_REGEX = /^([A-Za-z]{2})$/;\nconst ISO_OPERATOR_REGEX = /^([A-Za-z0-9]{3})$/;\nconst ISO_POWER_OUTLET_REGEX = /^([A-Za-z0-9*]{1,31})$/;\nconst ISO_EVSE_REGEX = /^([A-Za-z]{2})\\*?([A-Za-z0-9]{3})\\*?E([A-Za-z0-9*]{1,31})$/;\n\nconst DIN_COUNTRY_REGEX = /^(\\+?[0-9]{1,3})$/;\nconst DIN_OPERATOR_REGEX = /^([0-9]{3,6})$/;\nconst DIN_POWER_OUTLET_REGEX = /^([0-9*]{1,32})$/;\nconst DIN_EVSE_REGEX = /^(\\+?[0-9]{1,3})\\*([0-9]{3,6})\\*([0-9*]{1,32})$/;\n\nabstract class EvseIdBase {\n public abstract readonly countryCode: CountryCode | PhoneCountryCode;\n public abstract readonly operatorId: OperatorId;\n public abstract readonly powerOutletId: string;\n\n public abstract toString(): string;\n}\n\nexport class EvseIdIso extends EvseIdBase {\n public readonly countryCode: CountryCode;\n public readonly operatorId: OperatorIdIso;\n public readonly powerOutletId: string;\n\n public constructor(countryCode: CountryCode, operatorId: OperatorIdIso, powerOutletId: string) {\n super();\n this.countryCode = countryCode;\n this.operatorId = operatorId;\n this.powerOutletId = powerOutletId;\n Object.freeze(this);\n }\n\n public static fromParts(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n ): EvseIdIso {\n return createIso(\n countryCode.toUpperCase(),\n operatorId.toUpperCase(),\n powerOutletId.toUpperCase(),\n );\n }\n\n public static parse(raw: string): EvseIdIso | null {\n const match = ISO_EVSE_REGEX.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n return null;\n }\n\n try {\n return createIso(match[1].toUpperCase(), match[2].toUpperCase(), match[3].toUpperCase());\n } catch {\n return null;\n }\n }\n\n public static parseStrict(raw: string): EvseIdIso {\n const parsed = EvseIdIso.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid ISO EVSE ID: ${raw}`);\n }\n\n return parsed;\n }\n\n public get partyId(): PartyId {\n return PartyId.fromCountryAndOperator(this.countryCode, this.operatorId);\n }\n\n public toCompactString(): string {\n return this.toString().replaceAll(\"*\", \"\");\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}*${this.operatorId.toString()}*E${this.powerOutletId}`;\n }\n}\n\nexport class EvseIdDin extends EvseIdBase {\n public readonly countryCode: PhoneCountryCode;\n public readonly operatorId: OperatorIdDin;\n public readonly powerOutletId: string;\n\n public constructor(\n countryCode: PhoneCountryCode,\n operatorId: OperatorIdDin,\n powerOutletId: string,\n ) {\n super();\n this.countryCode = countryCode;\n this.operatorId = operatorId;\n this.powerOutletId = powerOutletId;\n Object.freeze(this);\n }\n\n public static fromParts(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n ): EvseIdDin {\n return createDin(\n countryCode.toUpperCase(),\n operatorId.toUpperCase(),\n powerOutletId.toUpperCase(),\n );\n }\n\n public static parse(raw: string): EvseIdDin | null {\n const match = DIN_EVSE_REGEX.exec(raw);\n if (!match || match[1] === undefined || match[2] === undefined || match[3] === undefined) {\n return null;\n }\n\n try {\n return createDin(match[1].toUpperCase(), match[2].toUpperCase(), match[3].toUpperCase());\n } catch {\n return null;\n }\n }\n\n public static parseStrict(raw: string): EvseIdDin {\n const parsed = EvseIdDin.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid DIN EVSE ID: ${raw}`);\n }\n\n return parsed;\n }\n\n public toString(): string {\n return `${this.countryCode.toString()}*${this.operatorId.toString()}*${this.powerOutletId}`;\n }\n}\n\nfunction validateIso(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n): ValidationError | null {\n if (!ISO_COUNTRY_REGEX.test(countryCode)) {\n return { priority: 1, description: \"Invalid countryCode for ISO or DIN format\" };\n }\n if (!ISO_OPERATOR_REGEX.test(operatorId)) {\n return { priority: 2, description: \"Invalid operatorId for ISO format\" };\n }\n if (!ISO_POWER_OUTLET_REGEX.test(powerOutletId)) {\n return { priority: 3, description: \"Invalid powerOutletId for ISO format\" };\n }\n\n return null;\n}\n\nfunction validateDin(\n countryCode: string,\n operatorId: string,\n powerOutletId: string,\n): ValidationError | null {\n if (!DIN_COUNTRY_REGEX.test(countryCode)) {\n return { priority: 1, description: \"Invalid countryCode for ISO or DIN format\" };\n }\n if (!DIN_OPERATOR_REGEX.test(operatorId)) {\n return { priority: 2, description: \"Invalid operatorId for DIN format\" };\n }\n if (!DIN_POWER_OUTLET_REGEX.test(powerOutletId)) {\n return { priority: 3, description: \"Invalid powerOutletId for DIN format\" };\n }\n\n return null;\n}\n\nfunction createIso(countryCode: string, operatorId: string, powerOutletId: string): EvseIdIso {\n const country = CountryCode.from(countryCode);\n const operator = OperatorIdIso.from(operatorId);\n const normalizedPowerOutletId = powerOutletId.startsWith(\"E\")\n ? powerOutletId.slice(1)\n : powerOutletId;\n return new EvseIdIso(country, operator, normalizedPowerOutletId);\n}\n\nfunction createDin(countryCode: string, operatorId: string, powerOutletId: string): EvseIdDin {\n const countryWithPlus = countryCode.startsWith(\"+\") ? countryCode : `+${countryCode}`;\n const country = PhoneCountryCode.from(countryWithPlus);\n const operator = OperatorIdDin.from(operatorId);\n return new EvseIdDin(country, operator, powerOutletId);\n}\n\nexport type EvseId = EvseIdIso | EvseIdDin;\n\nexport const EvseId = {\n fromParts(countryCode: string, operatorId: string, powerOutletId: string): EvseId {\n const normalizedCountry = countryCode.toUpperCase();\n const normalizedOperator = operatorId.toUpperCase();\n const normalizedPowerOutlet = powerOutletId.toUpperCase();\n\n const isoError = validateIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n if (isoError === null) {\n return createIso(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n }\n\n const dinError = validateDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n if (dinError === null) {\n return createDin(normalizedCountry, normalizedOperator, normalizedPowerOutlet);\n }\n\n if (isoError.priority >= dinError.priority) {\n throw new TypeError(isoError.description);\n }\n\n throw new TypeError(dinError.description);\n },\n\n parse(raw: string): EvseId | null {\n const iso = EvseIdIso.parse(raw);\n if (iso !== null) {\n return iso;\n }\n\n return EvseIdDin.parse(raw);\n },\n\n parseStrict(raw: string): EvseId {\n const parsed = this.parse(raw);\n if (parsed === null) {\n throw new TypeError(`Invalid EVSE ID: ${raw}`);\n }\n\n return parsed;\n },\n};\n","/*\n * Copyright (c) 2014 The New Motion team, and respective contributors\n * Copyright (c) 2026 Julien Herr, and respective contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ContractId } from \"./contract-id.js\";\nimport { ContractIdStandards } from \"./contract-id-standard.js\";\nimport { CountryCode } from \"./country-code.js\";\nimport { EvseId, EvseIdDin, EvseIdIso } from \"./evse-id.js\";\nimport { OperatorIdDin, OperatorIdIso } from \"./operator-id.js\";\nimport { PartyId } from \"./party-id.js\";\nimport { PhoneCountryCode } from \"./phone-country-code.js\";\nimport { ProviderId } from \"./provider-id.js\";\n\nexport const MobilityIdParsers = {\n parseCountryCode(raw: string): CountryCode | null {\n return CountryCode.parse(raw);\n },\n\n parsePhoneCountryCode(raw: string): PhoneCountryCode | null {\n return PhoneCountryCode.parse(raw);\n },\n\n parseProviderId(raw: string): ProviderId | null {\n return ProviderId.parse(raw);\n },\n\n parseOperatorIdIso(raw: string): OperatorIdIso | null {\n return OperatorIdIso.parse(raw);\n },\n\n parseOperatorIdDin(raw: string): OperatorIdDin | null {\n return OperatorIdDin.parse(raw);\n },\n\n parsePartyId(raw: string): PartyId | null {\n return PartyId.parse(raw);\n },\n\n parseContractIdIso(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.ISO, raw);\n },\n\n parseContractIdDin(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.DIN, raw);\n },\n\n parseContractIdEmi3(raw: string): ContractId | null {\n return ContractId.parse(ContractIdStandards.EMI3, raw);\n },\n\n parseEvseId(raw: string): EvseId | null {\n return EvseId.parse(raw);\n },\n\n parseEvseIdIso(raw: string): EvseIdIso | null {\n return EvseIdIso.parse(raw);\n },\n\n parseEvseIdDin(raw: string): EvseIdDin | null {\n return EvseIdDin.parse(raw);\n },\n};\n"],"mappings":";AAiBA,MAAM,yBAAS,IAAI,KAAqB;AAExC,KAAK,IAAI,QAAQ,GAAG,SAAS,GAAG,SAAS,EACvC,QAAO,IAAI,OAAO,MAAM,EAAE,MAAM;AAGlC,KAAK,IAAI,QAAQ,GAAG,QAAQ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 "version": "0.0.1",
4
+ "description": "TypeScript mobility ID domain model, validation, and parsers",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/juherr/mobilityid.git",
9
+ "directory": "ts"
10
+ },
11
+ "homepage": "https://github.com/juherr/mobilityid/tree/main/ts#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/juherr/mobilityid/issues"
14
+ },
15
+ "keywords": [
16
+ "mobility",
17
+ "ev",
18
+ "evse",
19
+ "contract-id",
20
+ "emaid",
21
+ "iso-15118",
22
+ "din-91286",
23
+ "ocpi"
24
+ ],
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://registry.npmjs.org/"
42
+ },
43
+ "packageManager": "bun@1.3.12",
44
+ "engines": {
45
+ "node": ">=22",
46
+ "bun": ">=1.3.12"
47
+ },
48
+ "scripts": {
49
+ "build": "vp pack",
50
+ "lint": "vp lint src test",
51
+ "lint:fix": "vp lint --fix src test",
52
+ "format": "vp fmt . --write",
53
+ "format:check": "vp fmt --check",
54
+ "typecheck": "vp check",
55
+ "test": "vp test",
56
+ "check": "vp check && vp test && vp pack"
57
+ },
58
+ "devDependencies": {
59
+ "@tony.ganchev/eslint-plugin-header": "^3.4.3",
60
+ "@types/node": "^24.0.0",
61
+ "vite-plus": "^0.1.16"
62
+ }
63
+ }