dosipas-ts 1.1.0 → 1.3.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/README.md +76 -54
- package/dist/encoder.d.ts +57 -5
- package/dist/encoder.d.ts.map +1 -1
- package/dist/encoder.js +231 -90
- package/dist/encoder.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/signer.d.ts +24 -11
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +85 -48
- package/dist/signer.js.map +1 -1
- package/dist/types.d.ts +4 -98
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/dosipas-ts)
|
|
2
|
+
|
|
1
3
|
# dosipas-ts
|
|
2
4
|
|
|
3
5
|
> **[Try the online playground](https://sysdevrun.github.io/dosipas-ts/)** — decode, encode, sign, verify, and control UIC barcode tickets in your browser.
|
|
@@ -86,48 +88,57 @@ l2.decoded // UicDynamicContentData (FDC1) or IntercodeDynamicData (Intercod
|
|
|
86
88
|
|
|
87
89
|
## Encoding
|
|
88
90
|
|
|
91
|
+
`encodeTicket` accepts the same `UicBarcodeTicket` type returned by `decodeTicket`, so round-tripping works directly:
|
|
92
|
+
|
|
89
93
|
```ts
|
|
90
|
-
import { encodeTicket, encodeTicketToBytes } from 'dosipas-ts';
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
level2PublicKey: publicKeyBytes,
|
|
102
|
-
level1Signature: level1SigBytes,
|
|
103
|
-
level2Signature: level2SigBytes,
|
|
104
|
-
railTicket: {
|
|
105
|
-
issuingDetail: {
|
|
94
|
+
import { decodeTicket, encodeTicket, encodeTicketToBytes } from 'dosipas-ts';
|
|
95
|
+
import type { UicBarcodeTicket } from 'dosipas-ts';
|
|
96
|
+
|
|
97
|
+
// Round-trip: decode → encode
|
|
98
|
+
const hex = encodeTicket(decodeTicket(originalHex));
|
|
99
|
+
|
|
100
|
+
// Build a ticket from scratch
|
|
101
|
+
const ticket: UicBarcodeTicket = {
|
|
102
|
+
format: 'U2',
|
|
103
|
+
level2SignedData: {
|
|
104
|
+
level1Data: {
|
|
106
105
|
securityProviderNum: 3703,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
keyId: 1,
|
|
107
|
+
level1KeyAlg: '1.2.840.10045.3.1.7',
|
|
108
|
+
level1SigningAlg: '1.2.840.10045.4.3.2',
|
|
109
|
+
level2KeyAlg: '1.2.840.10045.3.1.7',
|
|
110
|
+
level2SigningAlg: '1.2.840.10045.4.3.2',
|
|
111
|
+
level2PublicKey: publicKeyBytes,
|
|
112
|
+
dataSequence: [{
|
|
113
|
+
dataFormat: 'FCB3',
|
|
114
|
+
decoded: {
|
|
115
|
+
issuingDetail: {
|
|
116
|
+
issuerNum: 3703,
|
|
117
|
+
issuingYear: 2025,
|
|
118
|
+
issuingDay: 44,
|
|
119
|
+
activated: true,
|
|
120
|
+
specimen: false,
|
|
121
|
+
securePaperTicket: false,
|
|
122
|
+
},
|
|
123
|
+
transportDocument: [
|
|
124
|
+
{ ticket: { key: 'openTicket', value: { returnIncluded: false } } },
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
}],
|
|
128
|
+
},
|
|
129
|
+
level1Signature: level1SigBytes,
|
|
130
|
+
level2Data: {
|
|
131
|
+
dataFormat: 'FDC1',
|
|
132
|
+
decoded: { dynamicContentDay: 0, dynamicContentTime: 720 },
|
|
117
133
|
},
|
|
118
|
-
transportDocument: [
|
|
119
|
-
{ ticketType: 'openTicket', ticket: { /* ... */ } },
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
dynamicData: {
|
|
123
|
-
rics: 3703,
|
|
124
|
-
dynamicContentDay: 0,
|
|
125
|
-
dynamicContentTime: 720,
|
|
126
134
|
},
|
|
127
|
-
|
|
135
|
+
level2Signature: level2SigBytes,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const encoded = encodeTicket(ticket);
|
|
128
139
|
|
|
129
140
|
// Or get bytes directly
|
|
130
|
-
const bytes = encodeTicketToBytes(
|
|
141
|
+
const bytes = encodeTicketToBytes(ticket);
|
|
131
142
|
```
|
|
132
143
|
|
|
133
144
|
## Signing
|
|
@@ -136,28 +147,39 @@ Sign tickets with ECDSA using the two-pass signing flow (Level 1, then Level 2):
|
|
|
136
147
|
|
|
137
148
|
```ts
|
|
138
149
|
import { signAndEncodeTicket, generateKeyPair } from 'dosipas-ts';
|
|
150
|
+
import type { UicBarcodeTicket } from 'dosipas-ts';
|
|
139
151
|
|
|
140
152
|
const level1Key = generateKeyPair('P-256');
|
|
141
153
|
const level2Key = generateKeyPair('P-256');
|
|
142
154
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
const ticket: UicBarcodeTicket = {
|
|
156
|
+
format: 'U2',
|
|
157
|
+
level2SignedData: {
|
|
158
|
+
level1Data: {
|
|
159
|
+
securityProviderNum: 3703,
|
|
160
|
+
keyId: 1,
|
|
161
|
+
dataSequence: [{
|
|
162
|
+
dataFormat: 'FCB3',
|
|
163
|
+
decoded: {
|
|
164
|
+
issuingDetail: {
|
|
165
|
+
issuerNum: 3703,
|
|
166
|
+
issuingYear: 2025,
|
|
167
|
+
issuingDay: 44,
|
|
168
|
+
activated: true,
|
|
169
|
+
specimen: false,
|
|
170
|
+
securePaperTicket: false,
|
|
171
|
+
},
|
|
172
|
+
transportDocument: [
|
|
173
|
+
{ ticket: { key: 'openTicket', value: { returnIncluded: false } } },
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
}],
|
|
159
177
|
},
|
|
160
178
|
},
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const ticketBytes = signAndEncodeTicket(
|
|
182
|
+
ticket,
|
|
161
183
|
level1Key,
|
|
162
184
|
level2Key, // omit for static barcodes (Level 1 only)
|
|
163
185
|
);
|
|
@@ -168,9 +190,9 @@ For finer control, sign each level independently:
|
|
|
168
190
|
```ts
|
|
169
191
|
import { signLevel1, signLevel2 } from 'dosipas-ts';
|
|
170
192
|
|
|
171
|
-
const level1Sig = signLevel1(
|
|
193
|
+
const level1Sig = signLevel1(ticket, privateKey, 'P-256');
|
|
172
194
|
const level2Sig = signLevel2(
|
|
173
|
-
{ ...
|
|
195
|
+
{ ...ticket, level2SignedData: { ...ticket.level2SignedData, level1Signature: level1Sig } },
|
|
174
196
|
level2PrivateKey,
|
|
175
197
|
'P-256',
|
|
176
198
|
);
|
package/dist/encoder.d.ts
CHANGED
|
@@ -1,16 +1,68 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RawBytes } from 'asn1-per-ts';
|
|
2
|
+
import type { UicBarcodeTicket, Level1Data, Level2Data } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Encode a UIC barcode ticket to a hex string.
|
|
4
5
|
*
|
|
5
|
-
* @param
|
|
6
|
+
* @param ticket - The decoded ticket structure to encode.
|
|
6
7
|
* @returns Hex string of the encoded barcode payload.
|
|
7
8
|
*/
|
|
8
|
-
export declare function encodeTicket(
|
|
9
|
+
export declare function encodeTicket(ticket: UicBarcodeTicket): string;
|
|
9
10
|
/**
|
|
10
11
|
* Encode a UIC barcode ticket to bytes.
|
|
11
12
|
*
|
|
12
|
-
* @param
|
|
13
|
+
* @param ticket - The decoded ticket structure to encode.
|
|
13
14
|
* @returns Uint8Array of the encoded barcode payload.
|
|
14
15
|
*/
|
|
15
|
-
export declare function encodeTicketToBytes(
|
|
16
|
+
export declare function encodeTicketToBytes(ticket: UicBarcodeTicket): Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Encode a Level 2 data block from a {@link Level2Data} structure.
|
|
19
|
+
*
|
|
20
|
+
* If the `data` field is present, it is used as-is. Otherwise the `decoded`
|
|
21
|
+
* field is PER-encoded based on the `dataFormat`.
|
|
22
|
+
*
|
|
23
|
+
* @param l2Data - Level 2 data with either raw `data` or `decoded` content.
|
|
24
|
+
* @returns Object with `dataFormat` string and encoded `data` bytes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function encodeLevel2Data(l2Data: Level2Data): {
|
|
27
|
+
dataFormat: string;
|
|
28
|
+
data: Uint8Array;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Encode the `level1Data` SEQUENCE in isolation.
|
|
32
|
+
*
|
|
33
|
+
* Returns a {@link RawBytes} with the exact PER-encoded bits. The `.data`
|
|
34
|
+
* property gives the `Uint8Array` suitable for signing; the `RawBytes` itself
|
|
35
|
+
* is passed to {@link encodeLevel2SignedData} for bit-precise embedding.
|
|
36
|
+
*
|
|
37
|
+
* @param level1Data - The Level 1 data to encode.
|
|
38
|
+
* @param format - Header format string (e.g. "U1" or "U2").
|
|
39
|
+
*/
|
|
40
|
+
export declare function encodeLevel1Data(level1Data: Level1Data, format: string): RawBytes;
|
|
41
|
+
/**
|
|
42
|
+
* Encode the `level2SignedData` SEQUENCE.
|
|
43
|
+
*
|
|
44
|
+
* Embeds pre-encoded `level1Data` bytes verbatim via {@link RawBytes}
|
|
45
|
+
* passthrough. Returns a `RawBytes` for signing and embedding into
|
|
46
|
+
* {@link encodeUicBarcode}.
|
|
47
|
+
*/
|
|
48
|
+
export declare function encodeLevel2SignedData(input: {
|
|
49
|
+
headerVersion?: number;
|
|
50
|
+
level1Data: RawBytes;
|
|
51
|
+
level1Signature: Uint8Array;
|
|
52
|
+
level2Data?: {
|
|
53
|
+
dataFormat: string;
|
|
54
|
+
data: Uint8Array;
|
|
55
|
+
};
|
|
56
|
+
}): RawBytes;
|
|
57
|
+
/**
|
|
58
|
+
* Encode the outermost `UicBarcodeHeader` SEQUENCE.
|
|
59
|
+
*
|
|
60
|
+
* Embeds pre-encoded `level2SignedData` bytes verbatim via {@link RawBytes}
|
|
61
|
+
* passthrough. Returns the final barcode payload bytes.
|
|
62
|
+
*/
|
|
63
|
+
export declare function encodeUicBarcode(input: {
|
|
64
|
+
format: string;
|
|
65
|
+
level2SignedData: RawBytes;
|
|
66
|
+
level2Signature?: Uint8Array;
|
|
67
|
+
}): Uint8Array;
|
|
16
68
|
//# sourceMappingURL=encoder.d.ts.map
|
package/dist/encoder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../src/encoder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../src/encoder.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,EACV,UAAU,EAIX,MAAM,SAAS,CAAC;AA6FjB;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAwD7D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAGxE;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,UAAU,GACjB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAO1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAgCjF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,QAAQ,CAAC;IACrB,eAAe,EAAE,UAAU,CAAC;IAC5B,UAAU,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC;CACvD,GAAG,QAAQ,CAWX;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,eAAe,CAAC,EAAE,UAAU,CAAC;CAC9B,GAAG,UAAU,CAWb"}
|
package/dist/encoder.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Encoder for UIC barcode tickets with Intercode 6 extensions.
|
|
3
3
|
*
|
|
4
|
-
* Encodes a {@link
|
|
4
|
+
* Encodes a {@link UicBarcodeTicket} object into a hex string suitable
|
|
5
5
|
* for embedding in an Aztec barcode.
|
|
6
6
|
*/
|
|
7
7
|
import { SchemaCodec, SchemaBuilder, BitBuffer, } from 'asn1-per-ts';
|
|
@@ -10,6 +10,8 @@ import { HEADER_SCHEMAS, RAIL_TICKET_SCHEMAS, INTERCODE_SCHEMAS, DYNAMIC_CONTENT
|
|
|
10
10
|
// Codec caches (separate from decoder to avoid coupling)
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
const headerCodecCache = new Map();
|
|
13
|
+
const level1DataCodecCache = new Map();
|
|
14
|
+
const level2DataCodecCache = new Map();
|
|
13
15
|
const ticketCodecCache = new Map();
|
|
14
16
|
let intercodeIssuingCodec;
|
|
15
17
|
let intercodeDynamicCodec;
|
|
@@ -25,6 +27,28 @@ function getHeaderCodec(version) {
|
|
|
25
27
|
headerCodecCache.set(version, codec);
|
|
26
28
|
return codec;
|
|
27
29
|
}
|
|
30
|
+
function getLevel1DataCodec(version) {
|
|
31
|
+
let codec = level1DataCodecCache.get(version);
|
|
32
|
+
if (codec)
|
|
33
|
+
return codec;
|
|
34
|
+
const schemas = HEADER_SCHEMAS[version];
|
|
35
|
+
if (!schemas)
|
|
36
|
+
throw new Error(`No schema for header v${version}`);
|
|
37
|
+
codec = new SchemaCodec(schemas.Level1DataType);
|
|
38
|
+
level1DataCodecCache.set(version, codec);
|
|
39
|
+
return codec;
|
|
40
|
+
}
|
|
41
|
+
function getLevel2DataCodec(version) {
|
|
42
|
+
let codec = level2DataCodecCache.get(version);
|
|
43
|
+
if (codec)
|
|
44
|
+
return codec;
|
|
45
|
+
const schemas = HEADER_SCHEMAS[version];
|
|
46
|
+
if (!schemas)
|
|
47
|
+
throw new Error(`No schema for header v${version}`);
|
|
48
|
+
codec = new SchemaCodec(schemas.Level2DataType);
|
|
49
|
+
level2DataCodecCache.set(version, codec);
|
|
50
|
+
return codec;
|
|
51
|
+
}
|
|
28
52
|
function getTicketCodecs(version) {
|
|
29
53
|
let codecs = ticketCodecCache.get(version);
|
|
30
54
|
if (codecs)
|
|
@@ -55,8 +79,20 @@ function getFdc1Codec() {
|
|
|
55
79
|
fdc1Codec = new SchemaCodec(DYNAMIC_CONTENT_SCHEMAS.UicDynamicContentData);
|
|
56
80
|
return fdc1Codec;
|
|
57
81
|
}
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Internal helpers
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
function parseHeaderVersion(format) {
|
|
86
|
+
const match = format.match(/^U(\d+)$/);
|
|
87
|
+
if (!match)
|
|
88
|
+
throw new Error(`Invalid format "${format}", expected "U1" or "U2"`);
|
|
89
|
+
return parseInt(match[1], 10);
|
|
90
|
+
}
|
|
91
|
+
function parseFcbVersion(dataFormat) {
|
|
92
|
+
const match = dataFormat.match(/^FCB(\d+)$/);
|
|
93
|
+
if (!match)
|
|
94
|
+
throw new Error(`Unsupported dataFormat "${dataFormat}"`);
|
|
95
|
+
return parseInt(match[1], 10);
|
|
60
96
|
}
|
|
61
97
|
// ---------------------------------------------------------------------------
|
|
62
98
|
// Public API
|
|
@@ -64,116 +100,221 @@ function toHex(bytes) {
|
|
|
64
100
|
/**
|
|
65
101
|
* Encode a UIC barcode ticket to a hex string.
|
|
66
102
|
*
|
|
67
|
-
* @param
|
|
103
|
+
* @param ticket - The decoded ticket structure to encode.
|
|
68
104
|
* @returns Hex string of the encoded barcode payload.
|
|
69
105
|
*/
|
|
70
|
-
export function encodeTicket(
|
|
71
|
-
const headerVersion =
|
|
72
|
-
const
|
|
73
|
-
//
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
level2Data = { dataFormat: 'FDC1', data: fdc1Bytes };
|
|
84
|
-
}
|
|
85
|
-
else if (input.dynamicData) {
|
|
86
|
-
const dynamicBytes = getIntercodeDynamicCodec().encode({
|
|
87
|
-
dynamicContentDay: input.dynamicData.dynamicContentDay ?? 0,
|
|
88
|
-
dynamicContentTime: input.dynamicData.dynamicContentTime,
|
|
89
|
-
dynamicContentUTCOffset: input.dynamicData.dynamicContentUTCOffset,
|
|
90
|
-
dynamicContentDuration: input.dynamicData.dynamicContentDuration,
|
|
91
|
-
});
|
|
92
|
-
level2Data = {
|
|
93
|
-
dataFormat: `_${input.dynamicData.rics}.ID1`,
|
|
94
|
-
data: dynamicBytes,
|
|
106
|
+
export function encodeTicket(ticket) {
|
|
107
|
+
const headerVersion = parseHeaderVersion(ticket.format);
|
|
108
|
+
const l1 = ticket.level2SignedData.level1Data;
|
|
109
|
+
// Encode each data sequence entry
|
|
110
|
+
const dataSequence = l1.dataSequence.map(entry => {
|
|
111
|
+
if (entry.data)
|
|
112
|
+
return { dataFormat: entry.dataFormat, data: entry.data };
|
|
113
|
+
if (!entry.decoded)
|
|
114
|
+
throw new Error('DataSequenceEntry must have data or decoded');
|
|
115
|
+
const fcbVersion = parseFcbVersion(entry.dataFormat);
|
|
116
|
+
return {
|
|
117
|
+
dataFormat: entry.dataFormat,
|
|
118
|
+
data: encodeRailTicket(fcbVersion, entry.decoded, l1.securityProviderNum),
|
|
95
119
|
};
|
|
120
|
+
});
|
|
121
|
+
// Encode level2Data if present
|
|
122
|
+
let level2Data;
|
|
123
|
+
const l2 = ticket.level2SignedData.level2Data;
|
|
124
|
+
if (l2) {
|
|
125
|
+
if (l2.data) {
|
|
126
|
+
level2Data = { dataFormat: l2.dataFormat, data: l2.data };
|
|
127
|
+
}
|
|
128
|
+
else if (l2.decoded) {
|
|
129
|
+
level2Data = {
|
|
130
|
+
dataFormat: l2.dataFormat,
|
|
131
|
+
data: encodeLevel2DataDecoded(l2.dataFormat, l2.decoded),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
96
134
|
}
|
|
97
|
-
//
|
|
135
|
+
// Build the full header structure
|
|
98
136
|
const headerData = {
|
|
99
|
-
format:
|
|
137
|
+
format: ticket.format,
|
|
100
138
|
level2SignedData: {
|
|
101
139
|
level1Data: {
|
|
102
|
-
securityProviderNum:
|
|
103
|
-
|
|
140
|
+
securityProviderNum: l1.securityProviderNum,
|
|
141
|
+
securityProviderIA5: l1.securityProviderIA5,
|
|
142
|
+
keyId: l1.keyId,
|
|
104
143
|
dataSequence,
|
|
105
|
-
level1KeyAlg:
|
|
106
|
-
level2KeyAlg:
|
|
107
|
-
level1SigningAlg:
|
|
108
|
-
level2SigningAlg:
|
|
109
|
-
level2PublicKey:
|
|
110
|
-
endOfValidityYear:
|
|
111
|
-
endOfValidityDay:
|
|
112
|
-
endOfValidityTime:
|
|
113
|
-
validityDuration:
|
|
144
|
+
level1KeyAlg: l1.level1KeyAlg,
|
|
145
|
+
level2KeyAlg: l1.level2KeyAlg,
|
|
146
|
+
level1SigningAlg: l1.level1SigningAlg,
|
|
147
|
+
level2SigningAlg: l1.level2SigningAlg,
|
|
148
|
+
level2PublicKey: l1.level2PublicKey,
|
|
149
|
+
endOfValidityYear: l1.endOfValidityYear,
|
|
150
|
+
endOfValidityDay: l1.endOfValidityDay,
|
|
151
|
+
endOfValidityTime: l1.endOfValidityTime,
|
|
152
|
+
validityDuration: l1.validityDuration,
|
|
114
153
|
},
|
|
115
|
-
level1Signature:
|
|
154
|
+
level1Signature: ticket.level2SignedData.level1Signature,
|
|
116
155
|
level2Data,
|
|
117
156
|
},
|
|
118
|
-
level2Signature:
|
|
157
|
+
level2Signature: ticket.level2Signature,
|
|
119
158
|
};
|
|
120
|
-
// Step 5: Encode the header
|
|
121
159
|
const codec = getHeaderCodec(headerVersion);
|
|
122
160
|
return codec.encodeToHex(headerData);
|
|
123
161
|
}
|
|
124
162
|
/**
|
|
125
163
|
* Encode a UIC barcode ticket to bytes.
|
|
126
164
|
*
|
|
127
|
-
* @param
|
|
165
|
+
* @param ticket - The decoded ticket structure to encode.
|
|
128
166
|
* @returns Uint8Array of the encoded barcode payload.
|
|
129
167
|
*/
|
|
130
|
-
export function encodeTicketToBytes(
|
|
131
|
-
const hex = encodeTicket(
|
|
168
|
+
export function encodeTicketToBytes(ticket) {
|
|
169
|
+
const hex = encodeTicket(ticket);
|
|
132
170
|
return new Uint8Array(hex.match(/.{1,2}/g).map(b => parseInt(b, 16)));
|
|
133
171
|
}
|
|
134
172
|
// ---------------------------------------------------------------------------
|
|
135
|
-
//
|
|
173
|
+
// Composable encoding primitives
|
|
136
174
|
// ---------------------------------------------------------------------------
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Encode a Level 2 data block from a {@link Level2Data} structure.
|
|
177
|
+
*
|
|
178
|
+
* If the `data` field is present, it is used as-is. Otherwise the `decoded`
|
|
179
|
+
* field is PER-encoded based on the `dataFormat`.
|
|
180
|
+
*
|
|
181
|
+
* @param l2Data - Level 2 data with either raw `data` or `decoded` content.
|
|
182
|
+
* @returns Object with `dataFormat` string and encoded `data` bytes.
|
|
183
|
+
*/
|
|
184
|
+
export function encodeLevel2Data(l2Data) {
|
|
185
|
+
if (l2Data.data)
|
|
186
|
+
return { dataFormat: l2Data.dataFormat, data: l2Data.data };
|
|
187
|
+
if (!l2Data.decoded)
|
|
188
|
+
throw new Error('Level2Data must have data or decoded');
|
|
189
|
+
return {
|
|
190
|
+
dataFormat: l2Data.dataFormat,
|
|
191
|
+
data: encodeLevel2DataDecoded(l2Data.dataFormat, l2Data.decoded),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Encode the `level1Data` SEQUENCE in isolation.
|
|
196
|
+
*
|
|
197
|
+
* Returns a {@link RawBytes} with the exact PER-encoded bits. The `.data`
|
|
198
|
+
* property gives the `Uint8Array` suitable for signing; the `RawBytes` itself
|
|
199
|
+
* is passed to {@link encodeLevel2SignedData} for bit-precise embedding.
|
|
200
|
+
*
|
|
201
|
+
* @param level1Data - The Level 1 data to encode.
|
|
202
|
+
* @param format - Header format string (e.g. "U1" or "U2").
|
|
203
|
+
*/
|
|
204
|
+
export function encodeLevel1Data(level1Data, format) {
|
|
205
|
+
const headerVersion = parseHeaderVersion(format);
|
|
206
|
+
// Encode each data sequence entry
|
|
207
|
+
const dataSequence = level1Data.dataSequence.map(entry => {
|
|
208
|
+
if (entry.data)
|
|
209
|
+
return { dataFormat: entry.dataFormat, data: entry.data };
|
|
210
|
+
if (!entry.decoded)
|
|
211
|
+
throw new Error('DataSequenceEntry must have data or decoded');
|
|
212
|
+
const fcbVersion = parseFcbVersion(entry.dataFormat);
|
|
213
|
+
return {
|
|
214
|
+
dataFormat: entry.dataFormat,
|
|
215
|
+
data: encodeRailTicket(fcbVersion, entry.decoded, level1Data.securityProviderNum),
|
|
152
216
|
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
217
|
+
});
|
|
218
|
+
const l1Data = {
|
|
219
|
+
securityProviderNum: level1Data.securityProviderNum,
|
|
220
|
+
securityProviderIA5: level1Data.securityProviderIA5,
|
|
221
|
+
keyId: level1Data.keyId,
|
|
222
|
+
dataSequence,
|
|
223
|
+
level1KeyAlg: level1Data.level1KeyAlg,
|
|
224
|
+
level2KeyAlg: level1Data.level2KeyAlg,
|
|
225
|
+
level1SigningAlg: level1Data.level1SigningAlg,
|
|
226
|
+
level2SigningAlg: level1Data.level2SigningAlg,
|
|
227
|
+
level2PublicKey: level1Data.level2PublicKey,
|
|
228
|
+
endOfValidityYear: level1Data.endOfValidityYear,
|
|
229
|
+
endOfValidityDay: level1Data.endOfValidityDay,
|
|
230
|
+
endOfValidityTime: level1Data.endOfValidityTime,
|
|
231
|
+
validityDuration: level1Data.validityDuration,
|
|
232
|
+
};
|
|
233
|
+
const codec = getLevel1DataCodec(headerVersion);
|
|
234
|
+
return codec.encodeToRawBytes(l1Data);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Encode the `level2SignedData` SEQUENCE.
|
|
238
|
+
*
|
|
239
|
+
* Embeds pre-encoded `level1Data` bytes verbatim via {@link RawBytes}
|
|
240
|
+
* passthrough. Returns a `RawBytes` for signing and embedding into
|
|
241
|
+
* {@link encodeUicBarcode}.
|
|
242
|
+
*/
|
|
243
|
+
export function encodeLevel2SignedData(input) {
|
|
244
|
+
const headerVersion = input.headerVersion ?? 2;
|
|
245
|
+
const level2SignedData = {
|
|
246
|
+
level1Data: input.level1Data,
|
|
247
|
+
level1Signature: input.level1Signature,
|
|
248
|
+
level2Data: input.level2Data,
|
|
249
|
+
};
|
|
250
|
+
const codec = getLevel2DataCodec(headerVersion);
|
|
251
|
+
return codec.encodeToRawBytes(level2SignedData);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Encode the outermost `UicBarcodeHeader` SEQUENCE.
|
|
255
|
+
*
|
|
256
|
+
* Embeds pre-encoded `level2SignedData` bytes verbatim via {@link RawBytes}
|
|
257
|
+
* passthrough. Returns the final barcode payload bytes.
|
|
258
|
+
*/
|
|
259
|
+
export function encodeUicBarcode(input) {
|
|
260
|
+
const headerVersion = parseHeaderVersion(input.format);
|
|
261
|
+
const headerData = {
|
|
262
|
+
format: input.format,
|
|
263
|
+
level2SignedData: input.level2SignedData,
|
|
264
|
+
level2Signature: input.level2Signature,
|
|
169
265
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
266
|
+
const codec = getHeaderCodec(headerVersion);
|
|
267
|
+
return codec.encode(headerData);
|
|
268
|
+
}
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
// Internal encoding helpers
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
/**
|
|
273
|
+
* Encode the decoded content of a Level 2 data block.
|
|
274
|
+
*/
|
|
275
|
+
function encodeLevel2DataDecoded(dataFormat, decoded) {
|
|
276
|
+
if (dataFormat === 'FDC1') {
|
|
277
|
+
return getFdc1Codec().encode(decoded);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
// Intercode dynamic data
|
|
281
|
+
return getIntercodeDynamicCodec().encode(decoded);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Encode rail ticket data (UicRailTicketData) to PER bytes.
|
|
286
|
+
*/
|
|
287
|
+
function encodeRailTicket(fcbVersion, railTicket, securityProviderNum) {
|
|
288
|
+
const iss = railTicket.issuingDetail;
|
|
289
|
+
let issuingDetail;
|
|
290
|
+
if (iss) {
|
|
291
|
+
// Handle extension: re-encode intercode if present, otherwise pass through raw
|
|
292
|
+
const { intercodeIssuing, extension: rawExtension, ...issuingRest } = iss;
|
|
293
|
+
let extension;
|
|
294
|
+
if (intercodeIssuing) {
|
|
295
|
+
const issuingBytes = getIntercodeIssuingCodec().encode({
|
|
296
|
+
intercodeVersion: intercodeIssuing.intercodeVersion ?? 1,
|
|
297
|
+
intercodeInstanciation: intercodeIssuing.intercodeInstanciation ?? 1,
|
|
298
|
+
networkId: intercodeIssuing.networkId,
|
|
299
|
+
productRetailer: intercodeIssuing.productRetailer,
|
|
300
|
+
});
|
|
301
|
+
extension = {
|
|
302
|
+
extensionId: intercodeIssuing.extensionId ?? `_${iss.securityProviderNum ?? securityProviderNum ?? 0}II1`,
|
|
303
|
+
extensionData: issuingBytes,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
extension = rawExtension;
|
|
308
|
+
}
|
|
309
|
+
issuingDetail = { ...issuingRest, extension };
|
|
310
|
+
// FCB3 requires issuingTime as mandatory — default to 0 if not provided
|
|
311
|
+
if (fcbVersion >= 3 && issuingDetail.issuingTime == null) {
|
|
312
|
+
issuingDetail.issuingTime = 0;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
174
315
|
// Validate traveler birth-day fields match the target FCB version
|
|
175
|
-
if (
|
|
176
|
-
for (const t of
|
|
316
|
+
if (railTicket.travelerDetail?.traveler) {
|
|
317
|
+
for (const t of railTicket.travelerDetail.traveler) {
|
|
177
318
|
if (fcbVersion >= 2 && t.dayOfBirth !== undefined) {
|
|
178
319
|
throw new Error(`Traveler field "dayOfBirth" is not valid for FCB v${fcbVersion}. Use "dayOfBirthInMonth" instead.`);
|
|
179
320
|
}
|
|
@@ -182,12 +323,12 @@ function encodeRailTicket(fcbVersion, input) {
|
|
|
182
323
|
}
|
|
183
324
|
}
|
|
184
325
|
}
|
|
185
|
-
//
|
|
326
|
+
// Transport documents pass through directly (already { ticket: { key, value } } format)
|
|
186
327
|
const ticketData = {
|
|
187
328
|
issuingDetail,
|
|
188
|
-
travelerDetail:
|
|
189
|
-
transportDocument,
|
|
190
|
-
controlDetail:
|
|
329
|
+
travelerDetail: railTicket.travelerDetail,
|
|
330
|
+
transportDocument: railTicket.transportDocument,
|
|
331
|
+
controlDetail: railTicket.controlDetail,
|
|
191
332
|
};
|
|
192
333
|
const codecs = getTicketCodecs(fcbVersion);
|
|
193
334
|
const buf = BitBuffer.alloc();
|
package/dist/encoder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../src/encoder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,GAEV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../src/encoder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,GAEV,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAU5G,8EAA8E;AAC9E,yDAAyD;AACzD,8EAA8E;AAE9E,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAuB,CAAC;AACxD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC5D,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC5D,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA0C,CAAC;AAC3E,IAAI,qBAA8C,CAAC;AACnD,IAAI,qBAA8C,CAAC;AACnD,IAAI,SAAkC,CAAC;AAEvC,SAAS,cAAc,CAAC,OAAe;IACrC,IAAI,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;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/C,aAAa,EAAE,UAAU,CAAC,aAAa;KACxC,CAAC;IAEF,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC;IAC9B,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACjD,OAAO,GAAG,CAAC,YAAY,EAAE,CAAC;AAC5B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export { decodeTicket, decodeTicketFromBytes } from './decoder';
|
|
2
|
-
export { encodeTicket, encodeTicketToBytes } from './encoder';
|
|
2
|
+
export { encodeTicket, encodeTicketToBytes, encodeLevel2Data, encodeLevel1Data, encodeLevel2SignedData, encodeUicBarcode } from './encoder';
|
|
3
3
|
export { verifySignatures, verifyLevel1Signature, verifyLevel2Signature, findKeyInXml, parseKeysXml } from './verifier';
|
|
4
4
|
export { controlTicket } from './control';
|
|
5
5
|
export { getIssuingTime, getEndOfValidityTime, getDynamicContentTime } from './time-helpers';
|
|
6
6
|
export { extractSignedData } from './signed-data';
|
|
7
|
-
export { signLevel1, signLevel2, signAndEncodeTicket, generateKeyPair, getPublicKey, CURVES } from './signer';
|
|
7
|
+
export { signLevel1, signLevel2, signAndEncodeTicket, signPayload, generateKeyPair, getPublicKey, CURVES } from './signer';
|
|
8
8
|
export { SAMPLE_TICKET_HEX, SNCF_TER_TICKET_HEX, SOLEA_TICKET_HEX, BUS_ARDECHE_TICKET_HEX, BUS_AIN_TICKET_HEX, DROME_BUS_TICKET_HEX, CTS_TICKET_HEX, GRAND_EST_U1_FCB3_HEX } from './fixtures';
|
|
9
9
|
export { SNCF_TER_SIGNATURES, SOLEA_SIGNATURES, CTS_SIGNATURES } from './signature-fixtures';
|
|
10
|
-
export type { UicBarcodeTicket, Level2SignedData, Level1Data, DataSequenceEntry, Level2Data, UicRailTicketData, IssuingDetail, GeoCoordinate, ExtensionData, TransportDocumentData, IntercodeIssuingData, IntercodeDynamicData, UicDynamicContentData, TimeStampData, DynamicContentGeoCoordinate, DynamicContentExtensionData, RetailChannel, ProductRetailerData, TravelerDetail, TravelerInfo, CustomerStatus, ControlDetail, CardReference, TicketLink,
|
|
10
|
+
export type { UicBarcodeTicket, Level2SignedData, Level1Data, DataSequenceEntry, Level2Data, UicRailTicketData, IssuingDetail, GeoCoordinate, ExtensionData, TransportDocumentData, IntercodeIssuingData, IntercodeDynamicData, UicDynamicContentData, TimeStampData, DynamicContentGeoCoordinate, DynamicContentExtensionData, RetailChannel, ProductRetailerData, TravelerDetail, TravelerInfo, CustomerStatus, ControlDetail, CardReference, TicketLink, SignatureVerificationResult, SignatureLevelResult, VerifyOptions, Level1KeyProvider, ControlOptions, ControlResult, CheckResult, } from './types';
|
|
11
11
|
export type { UicPublicKeyEntry } from './verifier';
|
|
12
12
|
export type { ExtractedSignedData } from './signed-data';
|
|
13
13
|
export type { CurveName, CurveConfig, SigningKeyPair } from './signer';
|
|
14
|
+
export { RawBytes } from 'asn1-per-ts';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC5I,OAAO,EAAE,gBA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EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { decodeTicket, decodeTicketFromBytes } from './decoder';
|
|
2
|
-
export { encodeTicket, encodeTicketToBytes } from './encoder';
|
|
2
|
+
export { encodeTicket, encodeTicketToBytes, encodeLevel2Data, encodeLevel1Data, encodeLevel2SignedData, encodeUicBarcode } from './encoder';
|
|
3
3
|
export { verifySignatures, verifyLevel1Signature, verifyLevel2Signature, findKeyInXml, parseKeysXml } from './verifier';
|
|
4
4
|
export { controlTicket } from './control';
|
|
5
5
|
export { getIssuingTime, getEndOfValidityTime, getDynamicContentTime } from './time-helpers';
|
|
6
6
|
export { extractSignedData } from './signed-data';
|
|
7
|
-
export { signLevel1, signLevel2, signAndEncodeTicket, generateKeyPair, getPublicKey, CURVES } from './signer';
|
|
7
|
+
export { signLevel1, signLevel2, signAndEncodeTicket, signPayload, generateKeyPair, getPublicKey, CURVES } from './signer';
|
|
8
8
|
export { SAMPLE_TICKET_HEX, SNCF_TER_TICKET_HEX, SOLEA_TICKET_HEX, BUS_ARDECHE_TICKET_HEX, BUS_AIN_TICKET_HEX, DROME_BUS_TICKET_HEX, CTS_TICKET_HEX, GRAND_EST_U1_FCB3_HEX } from './fixtures';
|
|
9
9
|
export { SNCF_TER_SIGNATURES, SOLEA_SIGNATURES, CTS_SIGNATURES } from './signature-fixtures';
|
|
10
|
+
export { RawBytes } from 'asn1-per-ts';
|
|
10
11
|
//# 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,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC5I,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxH,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC3H,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC/L,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAwC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/signer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UicBarcodeTicket } from './types';
|
|
2
2
|
/** Supported ECDSA curve names. */
|
|
3
3
|
export type CurveName = 'P-256' | 'P-384' | 'P-521';
|
|
4
4
|
/** Curve configuration with OIDs for encoding into ticket headers. */
|
|
@@ -17,6 +17,19 @@ export interface SigningKeyPair {
|
|
|
17
17
|
}
|
|
18
18
|
/** Curve configurations indexed by curve name. */
|
|
19
19
|
export declare const CURVES: Record<CurveName, CurveConfig>;
|
|
20
|
+
/**
|
|
21
|
+
* Sign arbitrary data with ECDSA and return a DER-encoded signature.
|
|
22
|
+
*
|
|
23
|
+
* This is the low-level signing primitive used by the composable encoding flow.
|
|
24
|
+
* It hashes the data with the curve's associated hash (SHA-256 for P-256, etc.)
|
|
25
|
+
* and returns a DER-encoded ECDSA signature.
|
|
26
|
+
*
|
|
27
|
+
* @param data - The bytes to sign (will be hashed internally).
|
|
28
|
+
* @param privateKey - The ECDSA private key bytes.
|
|
29
|
+
* @param curve - The ECDSA curve to use.
|
|
30
|
+
* @returns DER-encoded signature bytes.
|
|
31
|
+
*/
|
|
32
|
+
export declare function signPayload(data: Uint8Array, privateKey: Uint8Array, curve: CurveName): Uint8Array;
|
|
20
33
|
/**
|
|
21
34
|
* Generate a new random ECDSA key pair.
|
|
22
35
|
*
|
|
@@ -38,12 +51,12 @@ export declare function getPublicKey(privateKey: Uint8Array, curve: CurveName):
|
|
|
38
51
|
* Encodes the ticket with a zero-filled Level 1 signature placeholder,
|
|
39
52
|
* extracts the Level 1 signed data, and produces the DER signature.
|
|
40
53
|
*
|
|
41
|
-
* @param
|
|
54
|
+
* @param ticket - Ticket (level1Signature will be overwritten with a zero placeholder).
|
|
42
55
|
* @param privateKey - Level 1 private key bytes.
|
|
43
56
|
* @param curve - The ECDSA curve.
|
|
44
57
|
* @returns DER-encoded Level 1 signature bytes.
|
|
45
58
|
*/
|
|
46
|
-
export declare function signLevel1(
|
|
59
|
+
export declare function signLevel1(ticket: UicBarcodeTicket, privateKey: Uint8Array, curve: CurveName): Uint8Array;
|
|
47
60
|
/**
|
|
48
61
|
* Sign Level 2 data of a ticket.
|
|
49
62
|
*
|
|
@@ -51,26 +64,26 @@ export declare function signLevel1(input: UicBarcodeTicketInput, privateKey: Uin
|
|
|
51
64
|
* Level 2 placeholder, extracts the Level 2 signed data, and produces the
|
|
52
65
|
* DER signature.
|
|
53
66
|
*
|
|
54
|
-
* @param
|
|
67
|
+
* @param ticket - Ticket with `level2SignedData.level1Signature` already set.
|
|
55
68
|
* @param privateKey - Level 2 private key bytes.
|
|
56
69
|
* @param curve - The ECDSA curve.
|
|
57
70
|
* @returns DER-encoded Level 2 signature bytes.
|
|
58
71
|
*/
|
|
59
|
-
export declare function signLevel2(
|
|
72
|
+
export declare function signLevel2(ticket: UicBarcodeTicket, privateKey: Uint8Array, curve: CurveName): Uint8Array;
|
|
60
73
|
/**
|
|
61
74
|
* Sign and encode a complete ticket with both Level 1 and Level 2 signatures.
|
|
62
75
|
*
|
|
63
|
-
*
|
|
64
|
-
* 1. Encode
|
|
65
|
-
* 2. Encode with
|
|
66
|
-
* 3. Encode final
|
|
76
|
+
* Uses the composable encoding primitives:
|
|
77
|
+
* 1. Encode level1Data → sign → level1Signature
|
|
78
|
+
* 2. Encode level2SignedData (with level1Data + signature) → sign → level2Signature
|
|
79
|
+
* 3. Encode final UicBarcodeHeader
|
|
67
80
|
*
|
|
68
81
|
* When `level2Key` is omitted, only Level 1 signing is performed (static barcode mode).
|
|
69
82
|
*
|
|
70
|
-
* @param
|
|
83
|
+
* @param ticket - Ticket data to encode (signature fields are overwritten).
|
|
71
84
|
* @param level1Key - Level 1 signing key pair.
|
|
72
85
|
* @param level2Key - Optional Level 2 signing key pair.
|
|
73
86
|
* @returns Encoded ticket bytes with valid signatures.
|
|
74
87
|
*/
|
|
75
|
-
export declare function signAndEncodeTicket(
|
|
88
|
+
export declare function signAndEncodeTicket(ticket: UicBarcodeTicket, level1Key: SigningKeyPair, level2Key?: SigningKeyPair): Uint8Array;
|
|
76
89
|
//# sourceMappingURL=signer.d.ts.map
|
package/dist/signer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"A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AC,EAAE,cAAc,GACzB,UAAU,CAiDZ"}
|
package/dist/signer.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* 5. Final encode with both real signatures
|
|
12
12
|
*/
|
|
13
13
|
import { p256, p384, p521 } from '@noble/curves/nist.js';
|
|
14
|
-
import { encodeTicketToBytes } from './encoder';
|
|
14
|
+
import { encodeLevel1Data, encodeLevel2Data, encodeLevel2SignedData, encodeUicBarcode, encodeTicketToBytes } from './encoder';
|
|
15
15
|
import { extractSignedData } from './signed-data';
|
|
16
16
|
import { rawToDer } from './signature-utils';
|
|
17
17
|
// ---------------------------------------------------------------------------
|
|
@@ -70,6 +70,24 @@ function ecSign(data, privateKey, curve) {
|
|
|
70
70
|
return rawToDer(compactSig, componentLength(curve));
|
|
71
71
|
}
|
|
72
72
|
// ---------------------------------------------------------------------------
|
|
73
|
+
// Public signing primitive
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
/**
|
|
76
|
+
* Sign arbitrary data with ECDSA and return a DER-encoded signature.
|
|
77
|
+
*
|
|
78
|
+
* This is the low-level signing primitive used by the composable encoding flow.
|
|
79
|
+
* It hashes the data with the curve's associated hash (SHA-256 for P-256, etc.)
|
|
80
|
+
* and returns a DER-encoded ECDSA signature.
|
|
81
|
+
*
|
|
82
|
+
* @param data - The bytes to sign (will be hashed internally).
|
|
83
|
+
* @param privateKey - The ECDSA private key bytes.
|
|
84
|
+
* @param curve - The ECDSA curve to use.
|
|
85
|
+
* @returns DER-encoded signature bytes.
|
|
86
|
+
*/
|
|
87
|
+
export function signPayload(data, privateKey, curve) {
|
|
88
|
+
return ecSign(data, privateKey, curve);
|
|
89
|
+
}
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
73
91
|
// Key generation helper
|
|
74
92
|
// ---------------------------------------------------------------------------
|
|
75
93
|
/**
|
|
@@ -104,22 +122,27 @@ export function getPublicKey(privateKey, curve) {
|
|
|
104
122
|
* Encodes the ticket with a zero-filled Level 1 signature placeholder,
|
|
105
123
|
* extracts the Level 1 signed data, and produces the DER signature.
|
|
106
124
|
*
|
|
107
|
-
* @param
|
|
125
|
+
* @param ticket - Ticket (level1Signature will be overwritten with a zero placeholder).
|
|
108
126
|
* @param privateKey - Level 1 private key bytes.
|
|
109
127
|
* @param curve - The ECDSA curve.
|
|
110
128
|
* @returns DER-encoded Level 1 signature bytes.
|
|
111
129
|
*/
|
|
112
|
-
export function signLevel1(
|
|
130
|
+
export function signLevel1(ticket, privateKey, curve) {
|
|
113
131
|
const curveConfig = CURVES[curve];
|
|
114
132
|
const zeroSig = new Uint8Array(maxDerSigSize(curve));
|
|
115
|
-
|
|
133
|
+
const l1 = ticket.level2SignedData.level1Data;
|
|
116
134
|
const prepared = {
|
|
117
|
-
...
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
135
|
+
...ticket,
|
|
136
|
+
level2SignedData: {
|
|
137
|
+
...ticket.level2SignedData,
|
|
138
|
+
level1Data: {
|
|
139
|
+
...l1,
|
|
140
|
+
level1KeyAlg: l1.level1KeyAlg ?? curveConfig.keyAlgOid,
|
|
141
|
+
level1SigningAlg: l1.level1SigningAlg ?? curveConfig.sigAlgOid,
|
|
142
|
+
},
|
|
143
|
+
level1Signature: zeroSig,
|
|
144
|
+
},
|
|
145
|
+
level2Signature: ticket.level2Signature ?? new Uint8Array(0),
|
|
123
146
|
};
|
|
124
147
|
const bytes = encodeTicketToBytes(prepared);
|
|
125
148
|
const extracted = extractSignedData(bytes);
|
|
@@ -132,21 +155,28 @@ export function signLevel1(input, privateKey, curve) {
|
|
|
132
155
|
* Level 2 placeholder, extracts the Level 2 signed data, and produces the
|
|
133
156
|
* DER signature.
|
|
134
157
|
*
|
|
135
|
-
* @param
|
|
158
|
+
* @param ticket - Ticket with `level2SignedData.level1Signature` already set.
|
|
136
159
|
* @param privateKey - Level 2 private key bytes.
|
|
137
160
|
* @param curve - The ECDSA curve.
|
|
138
161
|
* @returns DER-encoded Level 2 signature bytes.
|
|
139
162
|
*/
|
|
140
|
-
export function signLevel2(
|
|
141
|
-
if (!
|
|
163
|
+
export function signLevel2(ticket, privateKey, curve) {
|
|
164
|
+
if (!ticket.level2SignedData.level1Signature) {
|
|
142
165
|
throw new Error('Level 1 signature must be set before signing Level 2');
|
|
143
166
|
}
|
|
144
167
|
const curveConfig = CURVES[curve];
|
|
145
168
|
const zeroSig = new Uint8Array(maxDerSigSize(curve));
|
|
169
|
+
const l1 = ticket.level2SignedData.level1Data;
|
|
146
170
|
const prepared = {
|
|
147
|
-
...
|
|
148
|
-
|
|
149
|
-
|
|
171
|
+
...ticket,
|
|
172
|
+
level2SignedData: {
|
|
173
|
+
...ticket.level2SignedData,
|
|
174
|
+
level1Data: {
|
|
175
|
+
...l1,
|
|
176
|
+
level2KeyAlg: l1.level2KeyAlg ?? curveConfig.keyAlgOid,
|
|
177
|
+
level2SigningAlg: l1.level2SigningAlg ?? curveConfig.sigAlgOid,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
150
180
|
level2Signature: zeroSig,
|
|
151
181
|
};
|
|
152
182
|
const bytes = encodeTicketToBytes(prepared);
|
|
@@ -156,51 +186,58 @@ export function signLevel2(input, privateKey, curve) {
|
|
|
156
186
|
/**
|
|
157
187
|
* Sign and encode a complete ticket with both Level 1 and Level 2 signatures.
|
|
158
188
|
*
|
|
159
|
-
*
|
|
160
|
-
* 1. Encode
|
|
161
|
-
* 2. Encode with
|
|
162
|
-
* 3. Encode final
|
|
189
|
+
* Uses the composable encoding primitives:
|
|
190
|
+
* 1. Encode level1Data → sign → level1Signature
|
|
191
|
+
* 2. Encode level2SignedData (with level1Data + signature) → sign → level2Signature
|
|
192
|
+
* 3. Encode final UicBarcodeHeader
|
|
163
193
|
*
|
|
164
194
|
* When `level2Key` is omitted, only Level 1 signing is performed (static barcode mode).
|
|
165
195
|
*
|
|
166
|
-
* @param
|
|
196
|
+
* @param ticket - Ticket data to encode (signature fields are overwritten).
|
|
167
197
|
* @param level1Key - Level 1 signing key pair.
|
|
168
198
|
* @param level2Key - Optional Level 2 signing key pair.
|
|
169
199
|
* @returns Encoded ticket bytes with valid signatures.
|
|
170
200
|
*/
|
|
171
|
-
export function signAndEncodeTicket(
|
|
201
|
+
export function signAndEncodeTicket(ticket, level1Key, level2Key) {
|
|
172
202
|
const l1Curve = CURVES[level1Key.curve];
|
|
173
|
-
const
|
|
174
|
-
|
|
203
|
+
const l1 = ticket.level2SignedData.level1Data;
|
|
204
|
+
// Build level1Data with algorithm OIDs and L2 public key.
|
|
205
|
+
// Always set OIDs from the key pair (overriding any existing values from a decoded ticket).
|
|
206
|
+
const level1Data = {
|
|
207
|
+
...l1,
|
|
175
208
|
level1KeyAlg: l1Curve.keyAlgOid,
|
|
209
|
+
level2KeyAlg: level2Key ? CURVES[level2Key.curve].keyAlgOid : l1.level2KeyAlg,
|
|
176
210
|
level1SigningAlg: l1Curve.sigAlgOid,
|
|
211
|
+
level2SigningAlg: level2Key ? CURVES[level2Key.curve].sigAlgOid : l1.level2SigningAlg,
|
|
212
|
+
level2PublicKey: level2Key ? level2Key.publicKey : l1.level2PublicKey,
|
|
177
213
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
// Static barcode: only L1 signed, L2 signature is empty
|
|
188
|
-
return encodeTicketToBytes({
|
|
189
|
-
...baseInput,
|
|
190
|
-
level1Signature: level1Sig,
|
|
191
|
-
level2Signature: new Uint8Array(0),
|
|
192
|
-
});
|
|
214
|
+
// Step 1: Encode level1Data
|
|
215
|
+
const level1Raw = encodeLevel1Data(level1Data, ticket.format);
|
|
216
|
+
// Step 2: Sign level1Data
|
|
217
|
+
const level1Sig = signPayload(level1Raw.data, level1Key.privateKey, level1Key.curve);
|
|
218
|
+
// Step 3: Build level2Data if present
|
|
219
|
+
let level2DataEncoded;
|
|
220
|
+
const l2 = ticket.level2SignedData.level2Data;
|
|
221
|
+
if (l2) {
|
|
222
|
+
level2DataEncoded = encodeLevel2Data(l2);
|
|
193
223
|
}
|
|
194
|
-
//
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const level2Sig = signLevel2(inputWithL1, level2Key.privateKey, level2Key.curve);
|
|
200
|
-
// Final encode with both real signatures
|
|
201
|
-
return encodeTicketToBytes({
|
|
202
|
-
...baseInput,
|
|
224
|
+
// Step 4: Encode level2SignedData
|
|
225
|
+
const headerVersion = parseInt(ticket.format.replace('U', ''), 10);
|
|
226
|
+
const level2Raw = encodeLevel2SignedData({
|
|
227
|
+
headerVersion,
|
|
228
|
+
level1Data: level1Raw,
|
|
203
229
|
level1Signature: level1Sig,
|
|
230
|
+
level2Data: level2DataEncoded,
|
|
231
|
+
});
|
|
232
|
+
// Step 5: Sign level2SignedData (if level2Key provided)
|
|
233
|
+
let level2Sig;
|
|
234
|
+
if (level2Key) {
|
|
235
|
+
level2Sig = signPayload(level2Raw.data, level2Key.privateKey, level2Key.curve);
|
|
236
|
+
}
|
|
237
|
+
// Step 6: Encode final barcode
|
|
238
|
+
return encodeUicBarcode({
|
|
239
|
+
format: ticket.format,
|
|
240
|
+
level2SignedData: level2Raw,
|
|
204
241
|
level2Signature: level2Sig,
|
|
205
242
|
});
|
|
206
243
|
}
|
package/dist/signer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,IAAI,EAAE,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/dist/types.d.ts
CHANGED
|
@@ -43,8 +43,8 @@ export interface Level1Data {
|
|
|
43
43
|
export interface DataSequenceEntry {
|
|
44
44
|
/** Data format identifier (e.g. "FCB1", "FCB2", "FCB3"). */
|
|
45
45
|
dataFormat: string;
|
|
46
|
-
/** Raw PER-encoded data bytes. */
|
|
47
|
-
data
|
|
46
|
+
/** Raw PER-encoded data bytes (produced by the encoder when absent). */
|
|
47
|
+
data?: Uint8Array;
|
|
48
48
|
/** Decoded UicRailTicketData (when dataFormat is FCBn). */
|
|
49
49
|
decoded?: UicRailTicketData;
|
|
50
50
|
}
|
|
@@ -52,8 +52,8 @@ export interface DataSequenceEntry {
|
|
|
52
52
|
export interface Level2Data {
|
|
53
53
|
/** Data format identifier (e.g. "FDC1", "_3703.ID1"). */
|
|
54
54
|
dataFormat: string;
|
|
55
|
-
/** Raw PER-encoded data bytes. */
|
|
56
|
-
data
|
|
55
|
+
/** Raw PER-encoded data bytes (produced by the encoder when absent). */
|
|
56
|
+
data?: Uint8Array;
|
|
57
57
|
/** Decoded dynamic content data (UicDynamicContentData for FDC1, IntercodeDynamicData for _RICS.ID1). */
|
|
58
58
|
decoded?: UicDynamicContentData | IntercodeDynamicData;
|
|
59
59
|
}
|
|
@@ -229,100 +229,6 @@ export interface UicDynamicContentData {
|
|
|
229
229
|
dynamicContentResponseToChallenge?: DynamicContentExtensionData[];
|
|
230
230
|
dynamicContentExtension?: DynamicContentExtensionData;
|
|
231
231
|
}
|
|
232
|
-
/** Input for encoding a UIC barcode ticket. */
|
|
233
|
-
export interface UicBarcodeTicketInput {
|
|
234
|
-
/** Header version (1 or 2). Default: 2. */
|
|
235
|
-
headerVersion?: number;
|
|
236
|
-
/** RICS code of the security provider. */
|
|
237
|
-
securityProviderNum?: number;
|
|
238
|
-
/** Key ID for signature verification. */
|
|
239
|
-
keyId?: number;
|
|
240
|
-
/** Level 1 key algorithm OID. */
|
|
241
|
-
level1KeyAlg?: string;
|
|
242
|
-
/** Level 2 key algorithm OID. */
|
|
243
|
-
level2KeyAlg?: string;
|
|
244
|
-
/** Level 1 signing algorithm OID. */
|
|
245
|
-
level1SigningAlg?: string;
|
|
246
|
-
/** Level 2 signing algorithm OID. */
|
|
247
|
-
level2SigningAlg?: string;
|
|
248
|
-
/** Level 2 public key bytes. */
|
|
249
|
-
level2PublicKey?: Uint8Array;
|
|
250
|
-
/** Level 1 signature bytes (placeholder). */
|
|
251
|
-
level1Signature?: Uint8Array;
|
|
252
|
-
/** Level 2 signature bytes (placeholder). */
|
|
253
|
-
level2Signature?: Uint8Array;
|
|
254
|
-
/** End of validity year (2016-2269, v2 header only). */
|
|
255
|
-
endOfValidityYear?: number;
|
|
256
|
-
/** End of validity day (1-366). */
|
|
257
|
-
endOfValidityDay?: number;
|
|
258
|
-
/** End of validity time in minutes (0-1439). */
|
|
259
|
-
endOfValidityTime?: number;
|
|
260
|
-
/** Validity duration in seconds (1-3600). */
|
|
261
|
-
validityDuration?: number;
|
|
262
|
-
/** FCB version (1, 2 or 3). Default: 2. */
|
|
263
|
-
fcbVersion?: number;
|
|
264
|
-
/** The rail ticket data to encode. */
|
|
265
|
-
railTicket: RailTicketInput;
|
|
266
|
-
/** Intercode 6 dynamic data for Level 2 (encoded as _RICS.ID1). */
|
|
267
|
-
dynamicData?: IntercodeDynamicDataInput;
|
|
268
|
-
/** UIC Dynamic Content Data for Level 2 (encoded as FDC1). */
|
|
269
|
-
dynamicContentData?: UicDynamicContentDataInput;
|
|
270
|
-
}
|
|
271
|
-
export interface RailTicketInput {
|
|
272
|
-
issuingDetail: IssuingDetailInput;
|
|
273
|
-
travelerDetail?: TravelerDetailInput;
|
|
274
|
-
transportDocument?: TransportDocumentInput[];
|
|
275
|
-
controlDetail?: Record<string, unknown>;
|
|
276
|
-
}
|
|
277
|
-
export interface IssuingDetailInput {
|
|
278
|
-
securityProviderNum?: number;
|
|
279
|
-
issuerNum?: number;
|
|
280
|
-
issuingYear: number;
|
|
281
|
-
issuingDay: number;
|
|
282
|
-
issuingTime?: number;
|
|
283
|
-
issuerName?: string;
|
|
284
|
-
specimen?: boolean;
|
|
285
|
-
securePaperTicket?: boolean;
|
|
286
|
-
activated?: boolean;
|
|
287
|
-
currency?: string;
|
|
288
|
-
currencyFract?: number;
|
|
289
|
-
issuerPNR?: string;
|
|
290
|
-
/** Intercode 6 issuing extension data. */
|
|
291
|
-
intercodeIssuing?: IntercodeIssuingDataInput;
|
|
292
|
-
}
|
|
293
|
-
export interface IntercodeIssuingDataInput {
|
|
294
|
-
/** Override the generated extension ID (e.g. "+FRII1"). When omitted, defaults to `_<RICS>II1`. */
|
|
295
|
-
extensionId?: string;
|
|
296
|
-
intercodeVersion?: number;
|
|
297
|
-
intercodeInstanciation?: number;
|
|
298
|
-
networkId: Uint8Array;
|
|
299
|
-
productRetailer?: ProductRetailerData;
|
|
300
|
-
}
|
|
301
|
-
export interface IntercodeDynamicDataInput {
|
|
302
|
-
/** RICS code for the dataFormat field (e.g. 3703 -> "_3703.ID1"). */
|
|
303
|
-
rics: number;
|
|
304
|
-
dynamicContentDay?: number;
|
|
305
|
-
dynamicContentTime?: number;
|
|
306
|
-
dynamicContentUTCOffset?: number;
|
|
307
|
-
dynamicContentDuration?: number;
|
|
308
|
-
}
|
|
309
|
-
/** Input for encoding UIC Dynamic Content Data (FDC1 format). */
|
|
310
|
-
export interface UicDynamicContentDataInput {
|
|
311
|
-
dynamicContentMobileAppId?: string;
|
|
312
|
-
dynamicContentTimeStamp?: TimeStampData;
|
|
313
|
-
dynamicContentGeoCoordinate?: DynamicContentGeoCoordinate;
|
|
314
|
-
dynamicContentResponseToChallenge?: DynamicContentExtensionData[];
|
|
315
|
-
dynamicContentExtension?: DynamicContentExtensionData;
|
|
316
|
-
}
|
|
317
|
-
export interface TravelerDetailInput {
|
|
318
|
-
traveler?: Partial<TravelerInfo>[];
|
|
319
|
-
preferredLanguage?: string;
|
|
320
|
-
groupName?: string;
|
|
321
|
-
}
|
|
322
|
-
export interface TransportDocumentInput {
|
|
323
|
-
ticketType: string;
|
|
324
|
-
ticket: Record<string, unknown>;
|
|
325
|
-
}
|
|
326
232
|
/** Options for ticket control / validation. */
|
|
327
233
|
export interface ControlOptions {
|
|
328
234
|
/** Reference date/time for temporal checks. Defaults to `new Date()`. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,mDAAmD;IACnD,eAAe,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC/B,wDAAwD;IACxD,UAAU,EAAE,UAAU,CAAC;IACvB,uCAAuC;IACvC,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,4CAA4C;IAC5C,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;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AAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,KAAK,EAAE,OAAO,CAAC;IACf,yDAAyD;IACzD,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACrC;AAMD,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wDAAwD;AACxD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,oBAAoB,CAAC;IAC7B,MAAM,EAAE,oBAAoB,CAAC;CAC9B;AAED,0CAA0C;AAC1C,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,4EAA4E;IAC5E,eAAe,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,YAAY,CACV,gBAAgB,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAChD,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dosipas-ts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "UIC barcode ticket encoder/decoder/verifier with Intercode 6 extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@noble/curves": "^2.0.1",
|
|
46
46
|
"@noble/hashes": "^2.0.1",
|
|
47
|
-
"asn1-per-ts": "^1.
|
|
47
|
+
"asn1-per-ts": "^1.4.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^25.2.3",
|