@particle/esim-tooling 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +187 -0
  2. package/dist/activation-code.d.ts +11 -0
  3. package/dist/activation-code.d.ts.map +1 -0
  4. package/dist/activation-code.js +56 -0
  5. package/dist/activation-code.js.map +1 -0
  6. package/dist/apdu.d.ts +73 -0
  7. package/dist/apdu.d.ts.map +1 -0
  8. package/dist/apdu.js +357 -0
  9. package/dist/apdu.js.map +1 -0
  10. package/dist/errors.d.ts +32 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +52 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/es10/es10b-notifications.d.ts +30 -0
  15. package/dist/es10/es10b-notifications.d.ts.map +1 -0
  16. package/dist/es10/es10b-notifications.js +294 -0
  17. package/dist/es10/es10b-notifications.js.map +1 -0
  18. package/dist/es10/es10b.d.ts +34 -0
  19. package/dist/es10/es10b.d.ts.map +1 -0
  20. package/dist/es10/es10b.js +108 -0
  21. package/dist/es10/es10b.js.map +1 -0
  22. package/dist/es10/es10c.d.ts +12 -0
  23. package/dist/es10/es10c.d.ts.map +1 -0
  24. package/dist/es10/es10c.js +133 -0
  25. package/dist/es10/es10c.js.map +1 -0
  26. package/dist/es10/iccid.d.ts +9 -0
  27. package/dist/es10/iccid.d.ts.map +1 -0
  28. package/dist/es10/iccid.js +31 -0
  29. package/dist/es10/iccid.js.map +1 -0
  30. package/dist/es10/index.d.ts +5 -0
  31. package/dist/es10/index.d.ts.map +1 -0
  32. package/dist/es10/index.js +4 -0
  33. package/dist/es10/index.js.map +1 -0
  34. package/dist/es10/tags.d.ts +55 -0
  35. package/dist/es10/tags.d.ts.map +1 -0
  36. package/dist/es10/tags.js +63 -0
  37. package/dist/es10/tags.js.map +1 -0
  38. package/dist/es9plus.d.ts +52 -0
  39. package/dist/es9plus.d.ts.map +1 -0
  40. package/dist/es9plus.js +227 -0
  41. package/dist/es9plus.js.map +1 -0
  42. package/dist/gsma-rsp2-root-ci1.d.ts +38 -0
  43. package/dist/gsma-rsp2-root-ci1.d.ts.map +1 -0
  44. package/dist/gsma-rsp2-root-ci1.js +52 -0
  45. package/dist/gsma-rsp2-root-ci1.js.map +1 -0
  46. package/dist/index.d.ts +6 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +5 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/lpa.d.ts +15 -0
  51. package/dist/lpa.d.ts.map +1 -0
  52. package/dist/lpa.js +283 -0
  53. package/dist/lpa.js.map +1 -0
  54. package/dist/tlv.d.ts +14 -0
  55. package/dist/tlv.d.ts.map +1 -0
  56. package/dist/tlv.js +132 -0
  57. package/dist/tlv.js.map +1 -0
  58. package/dist/types.d.ts +230 -0
  59. package/dist/types.d.ts.map +1 -0
  60. package/dist/types.js +108 -0
  61. package/dist/types.js.map +1 -0
  62. package/package.json +50 -0
  63. package/src/activation-code.ts +64 -0
  64. package/src/apdu.ts +419 -0
  65. package/src/errors.ts +69 -0
  66. package/src/es10/es10b-notifications.ts +331 -0
  67. package/src/es10/es10b.ts +163 -0
  68. package/src/es10/es10c.ts +168 -0
  69. package/src/es10/iccid.ts +32 -0
  70. package/src/es10/index.ts +42 -0
  71. package/src/es10/tags.ts +69 -0
  72. package/src/es9plus.ts +331 -0
  73. package/src/gsma-rsp2-root-ci1.ts +53 -0
  74. package/src/index.ts +43 -0
  75. package/src/lpa.ts +346 -0
  76. package/src/tlv.ts +137 -0
  77. package/src/types.ts +264 -0
package/dist/apdu.js ADDED
@@ -0,0 +1,357 @@
1
+ import { DeviceError } from './errors.js';
2
+ import { tlvDecode, tlvFind, tlvConcat } from './tlv.js';
3
+ // ISD-R AID per SGP.22
4
+ const ISD_R_AID = new Uint8Array([
5
+ 0xa0, 0x00, 0x00, 0x05, 0x59, 0x10, 0x10,
6
+ 0xff, 0xff, 0xff, 0xff, 0x89, 0x00, 0x00, 0x01, 0x00,
7
+ ]);
8
+ const STORE_DATA_MSS = 255; // max APDU data size per SGP.22
9
+ // BPP segment tags (children of BF36 BoundProfilePackage)
10
+ const TAG_BPP_INIT_SECURE_CHANNEL = 0xbf23;
11
+ const TAG_BPP_FIRST_SEQ_OF_87 = 0xa0;
12
+ const TAG_BPP_SEQ_OF_88 = 0xa1;
13
+ const TAG_BPP_SECOND_SEQ_OF_87 = 0xa2;
14
+ const TAG_BPP_SEQ_OF_86 = 0xa3;
15
+ /**
16
+ * APDU transport layer — handles logical channel management, STORE DATA
17
+ * chunking, GET RESPONSE chaining, and BPP segmentation over a DeviceAdapter
18
+ * that sends individual APDUs.
19
+ */
20
+ export class ApduTransport {
21
+ device;
22
+ channel = -1;
23
+ constructor(device) {
24
+ this.device = device;
25
+ }
26
+ /**
27
+ * Send a complete SGP.22 TLV payload to the eUICC and return the complete
28
+ * TLV response. Handles STORE DATA chunking and GET RESPONSE chaining.
29
+ */
30
+ async sendCommand(data) {
31
+ await this.ensureChannel();
32
+ return this.storeDataAndGetResponse(data);
33
+ }
34
+ /**
35
+ * Load BPP per SGP.22 Section 2.5.5 Segmented BPP loading.
36
+ *
37
+ * Segmentation order:
38
+ * 1. BF36 header + BF23 (InitialiseSecureChannel)
39
+ * 2. A0 complete (firstSequenceOf87)
40
+ * 3. A1 header only (sequenceOf88)
41
+ * 4. Each 88 TLV individually
42
+ * 5. A2 complete if present (secondSequenceOf87)
43
+ * 6. A3 header only (sequenceOf86)
44
+ * 7. Each 86 TLV individually
45
+ *
46
+ * Critical: P1=0x91 only on the VERY LAST APDU of entire BPP.
47
+ * Block number (P2) resets at each segment boundary.
48
+ */
49
+ async loadBoundProfilePackage(bpp) {
50
+ await this.ensureChannel();
51
+ const bppNode = tlvDecode(bpp);
52
+ if (bppNode.tag !== 0xbf36) {
53
+ throw new DeviceError(-1, `Expected BPP tag BF36, got ${bppNode.tag.toString(16)}`);
54
+ }
55
+ if (!bppNode.children || bppNode.children.length === 0) {
56
+ throw new DeviceError(-1, 'BPP has no children');
57
+ }
58
+ // Extract required children
59
+ const initSecureChannel = tlvFind(bppNode, TAG_BPP_INIT_SECURE_CHANNEL);
60
+ const firstSeq87 = tlvFind(bppNode, TAG_BPP_FIRST_SEQ_OF_87);
61
+ const seq88 = tlvFind(bppNode, TAG_BPP_SEQ_OF_88);
62
+ const secondSeq87 = tlvFind(bppNode, TAG_BPP_SECOND_SEQ_OF_87);
63
+ const seq86 = tlvFind(bppNode, TAG_BPP_SEQ_OF_86);
64
+ if (!initSecureChannel || !firstSeq87 || !seq88 || !seq86) {
65
+ throw new DeviceError(-1, 'Invalid BPP structure: missing required segments');
66
+ }
67
+ // Build list of segments per SGP.22 Section 2.5.5
68
+ const segments = [];
69
+ // Segment 1: BF36 header + BF23 (InitialiseSecureChannel)
70
+ segments.push(this.buildBppSegment1(bppNode, initSecureChannel));
71
+ // Segment 2: A0 complete (firstSequenceOf87)
72
+ if (firstSeq87.raw) {
73
+ segments.push(firstSeq87.raw);
74
+ }
75
+ // Segment 3: A1 header only (sequenceOf88)
76
+ segments.push(this.buildSequenceHeader(seq88));
77
+ // Segment 4-N: Each 88 TLV individually
78
+ if (seq88.children) {
79
+ for (const child of seq88.children) {
80
+ if (child.raw) {
81
+ segments.push(child.raw);
82
+ }
83
+ }
84
+ }
85
+ // Segment N+1: A2 complete if present (secondSequenceOf87)
86
+ if (secondSeq87?.raw) {
87
+ segments.push(secondSeq87.raw);
88
+ }
89
+ // Segment N+2: A3 header only (sequenceOf86)
90
+ segments.push(this.buildSequenceHeader(seq86));
91
+ // Remaining segments: Each 86 TLV individually
92
+ if (seq86.children) {
93
+ for (const child of seq86.children) {
94
+ if (child.raw) {
95
+ segments.push(child.raw);
96
+ }
97
+ }
98
+ }
99
+ // Send all segments with proper P1 handling
100
+ // Returns ProfileInstallationResult (BF37) from the last APDU
101
+ return await this.sendBppSegments(segments);
102
+ }
103
+ /**
104
+ * Build Segment 1: BF36 header (tag+length) + complete BF23
105
+ */
106
+ buildBppSegment1(bppNode, initSecureChannel) {
107
+ if (!bppNode.raw || !initSecureChannel.raw) {
108
+ throw new DeviceError(-1, 'BPP or InitialiseSecureChannel missing raw data');
109
+ }
110
+ // BF36 header = raw minus value
111
+ const headerSize = bppNode.raw.length - bppNode.value.length;
112
+ const bppHeader = bppNode.raw.slice(0, headerSize);
113
+ return tlvConcat(bppHeader, initSecureChannel.raw);
114
+ }
115
+ /**
116
+ * Build sequence header (tag+length only, no children)
117
+ */
118
+ buildSequenceHeader(node) {
119
+ if (!node.raw) {
120
+ throw new DeviceError(-1, 'Node missing raw data');
121
+ }
122
+ const headerSize = node.raw.length - node.value.length;
123
+ return node.raw.slice(0, headerSize);
124
+ }
125
+ /**
126
+ * Send BPP segments with correct P1 handling:
127
+ * - P1=0x11 for all APDUs except the very last
128
+ * - P1=0x91 only on the VERY LAST APDU of the entire BPP
129
+ * - P2 resets at each segment boundary
130
+ *
131
+ * Returns the ProfileInstallationResult (BF37) from the last APDU response.
132
+ */
133
+ async sendBppSegments(segments) {
134
+ const cla = this.gpCla();
135
+ let installationResult;
136
+ for (let segIdx = 0; segIdx < segments.length; segIdx++) {
137
+ const segment = segments[segIdx];
138
+ const isLastSegment = segIdx === segments.length - 1;
139
+ const numChunks = Math.max(1, Math.ceil(segment.length / STORE_DATA_MSS));
140
+ for (let chunkIdx = 0; chunkIdx < numChunks; chunkIdx++) {
141
+ const offset = chunkIdx * STORE_DATA_MSS;
142
+ const chunkLen = Math.min(STORE_DATA_MSS, segment.length - offset);
143
+ const isLastChunk = chunkIdx === numChunks - 1;
144
+ const isVeryLastApdu = isLastSegment && isLastChunk;
145
+ const apdu = new Uint8Array(5 + chunkLen);
146
+ apdu[0] = cla;
147
+ apdu[1] = 0xe2; // STORE DATA
148
+ apdu[2] = isVeryLastApdu ? 0x91 : 0x11; // P1: only 0x91 on very last APDU
149
+ apdu[3] = chunkIdx & 0xff; // P2: resets at each segment
150
+ apdu[4] = chunkLen;
151
+ apdu.set(segment.subarray(offset, offset + chunkLen), 5);
152
+ const resp = await this.device.sendApdu(apdu);
153
+ if (resp.length < 2) {
154
+ throw new DeviceError(-1, `BPP STORE DATA: response too short (segment ${segIdx}, chunk ${chunkIdx})`);
155
+ }
156
+ let sw1 = resp[resp.length - 2];
157
+ let sw2 = resp[resp.length - 1];
158
+ // Collect response data for ProfileInstallationResult
159
+ const responseChunks = [];
160
+ const initialData = resp.subarray(0, resp.length - 2);
161
+ if (initialData.length > 0) {
162
+ responseChunks.push(initialData);
163
+ }
164
+ // Handle SW=61XX (more data available) by draining with GET RESPONSE
165
+ while (sw1 === 0x61) {
166
+ const getResp = await this.device.sendApdu(new Uint8Array([cla, 0xc0, 0x00, 0x00, sw2]));
167
+ if (getResp.length < 2) {
168
+ throw new DeviceError(-1, `BPP GET RESPONSE too short (segment ${segIdx}, chunk ${chunkIdx})`);
169
+ }
170
+ const respData = getResp.subarray(0, getResp.length - 2);
171
+ if (respData.length > 0) {
172
+ responseChunks.push(respData);
173
+ }
174
+ sw1 = getResp[getResp.length - 2];
175
+ sw2 = getResp[getResp.length - 1];
176
+ }
177
+ // Per SGP.22: accept SW 90XX or 91XX
178
+ if (sw1 !== 0x90 && sw1 !== 0x91) {
179
+ throw new DeviceError(-1, `BPP segment ${segIdx} chunk ${chunkIdx} failed: SW=${sw1.toString(16)}${sw2.toString(16)}`);
180
+ }
181
+ // Collect response data if present
182
+ if (responseChunks.length > 0) {
183
+ const totalLen = responseChunks.reduce((sum, c) => sum + c.length, 0);
184
+ installationResult = new Uint8Array(totalLen);
185
+ let pos = 0;
186
+ for (const chunk of responseChunks) {
187
+ installationResult.set(chunk, pos);
188
+ pos += chunk.length;
189
+ }
190
+ // If we got a ProfileInstallationResult (BF37), stop sending - eUICC has responded
191
+ // This handles both early errors and final success/failure
192
+ if (this.isBppResult(installationResult)) {
193
+ return installationResult;
194
+ }
195
+ }
196
+ }
197
+ }
198
+ return installationResult;
199
+ }
200
+ /**
201
+ * Check if BPP response data contains a ProfileInstallationResult (BF37).
202
+ * Returns true if BF37 is detected (caller should stop sending and return the data).
203
+ */
204
+ isBppResult(data) {
205
+ // Look for BF37 tag (ProfileInstallationResult)
206
+ // BF37 = 0xBF 0x37
207
+ if (data.length < 4)
208
+ return false;
209
+ return data[0] === 0xbf && data[1] === 0x37;
210
+ }
211
+ /**
212
+ * Close the logical channel if open.
213
+ */
214
+ async close() {
215
+ if (this.channel >= 0) {
216
+ await this.closeChannel(this.channel);
217
+ this.channel = -1;
218
+ }
219
+ }
220
+ // ---------------------------------------------------------------------------
221
+ // Logical channel management
222
+ // ---------------------------------------------------------------------------
223
+ async ensureChannel() {
224
+ if (this.channel >= 0)
225
+ return;
226
+ let ch = await this.openChannel();
227
+ if (ch < 0) {
228
+ // Stale channels from a previous run — close all and retry
229
+ await this.closeAllChannels();
230
+ ch = await this.openChannel();
231
+ if (ch < 0) {
232
+ throw new DeviceError(-1, 'Failed to open logical channel');
233
+ }
234
+ }
235
+ await this.selectIsdR(ch);
236
+ this.channel = ch;
237
+ }
238
+ async openChannel() {
239
+ // MANAGE CHANNEL OPEN: 00 70 00 00 01
240
+ const resp = await this.device.sendApdu(new Uint8Array([0x00, 0x70, 0x00, 0x00, 0x01]));
241
+ if (resp.length < 3)
242
+ return -1;
243
+ const sw1 = resp[resp.length - 2];
244
+ const sw2 = resp[resp.length - 1];
245
+ if (sw1 !== 0x90 || sw2 !== 0x00)
246
+ return -1;
247
+ return resp[0];
248
+ }
249
+ async selectIsdR(channel) {
250
+ // SELECT: CLA=channel, INS=A4, P1=04, P2=00, Lc=AID_len, Data=AID, Le=00
251
+ const cmd = new Uint8Array(5 + ISD_R_AID.length + 1);
252
+ cmd[0] = channel <= 3 ? (0x00 | channel) : (0x40 | (channel - 4));
253
+ cmd[1] = 0xa4;
254
+ cmd[2] = 0x04;
255
+ cmd[3] = 0x00;
256
+ cmd[4] = ISD_R_AID.length;
257
+ cmd.set(ISD_R_AID, 5);
258
+ cmd[5 + ISD_R_AID.length] = 0x00; // Le
259
+ const resp = await this.device.sendApdu(cmd);
260
+ if (resp.length < 2) {
261
+ throw new DeviceError(-1, 'SELECT ISD-R: response too short');
262
+ }
263
+ const sw1 = resp[resp.length - 2];
264
+ if (sw1 !== 0x90 && sw1 !== 0x61) {
265
+ const sw2 = resp[resp.length - 1];
266
+ throw new DeviceError(-1, `SELECT ISD-R failed: SW=${sw1.toString(16)}${sw2.toString(16)}`);
267
+ }
268
+ }
269
+ async closeChannel(channel) {
270
+ // MANAGE CHANNEL CLOSE
271
+ await this.device.sendApdu(new Uint8Array([0x00, 0x70, 0x80, channel, 0x00]));
272
+ }
273
+ async closeAllChannels() {
274
+ for (let ch = 1; ch <= 3; ch++) {
275
+ try {
276
+ await this.closeChannel(ch);
277
+ }
278
+ catch {
279
+ // Ignore errors — channel may not be open
280
+ }
281
+ }
282
+ }
283
+ // ---------------------------------------------------------------------------
284
+ // STORE DATA + GET RESPONSE
285
+ // ---------------------------------------------------------------------------
286
+ /**
287
+ * GlobalPlatform CLA byte for the current logical channel.
288
+ */
289
+ gpCla() {
290
+ return this.channel <= 3 ? (0x80 | this.channel) : (0xc0 | (this.channel - 4));
291
+ }
292
+ /**
293
+ * Send data via STORE DATA chunking and collect the response via
294
+ * GET RESPONSE chaining.
295
+ */
296
+ async storeDataAndGetResponse(data) {
297
+ const cla = this.gpCla();
298
+ const numChunks = Math.max(1, Math.ceil(data.length / STORE_DATA_MSS));
299
+ let lastResp = new Uint8Array(0);
300
+ for (let i = 0; i < numChunks; i++) {
301
+ const offset = i * STORE_DATA_MSS;
302
+ const chunkLen = Math.min(STORE_DATA_MSS, data.length - offset);
303
+ const isLast = i === numChunks - 1;
304
+ const apdu = new Uint8Array(5 + chunkLen);
305
+ apdu[0] = cla;
306
+ apdu[1] = 0xe2; // STORE DATA
307
+ apdu[2] = isLast ? 0x91 : 0x11; // P1: last or continue
308
+ apdu[3] = i & 0xff; // P2: sequence number
309
+ apdu[4] = chunkLen;
310
+ apdu.set(data.subarray(offset, offset + chunkLen), 5);
311
+ lastResp = await this.device.sendApdu(apdu);
312
+ if (lastResp.length < 2) {
313
+ throw new DeviceError(-1, 'STORE DATA: response too short');
314
+ }
315
+ if (!isLast) {
316
+ const sw1 = lastResp[lastResp.length - 2];
317
+ const sw2 = lastResp[lastResp.length - 1];
318
+ if (sw1 !== 0x90 || sw2 !== 0x00) {
319
+ throw new DeviceError(-1, `STORE DATA chunk ${i} failed: SW=${sw1.toString(16)}${sw2.toString(16)}`);
320
+ }
321
+ }
322
+ }
323
+ // Collect response data from last STORE DATA and GET RESPONSE chains
324
+ const parts = [];
325
+ // Data from last STORE DATA (excluding SW)
326
+ if (lastResp.length > 2) {
327
+ parts.push(lastResp.subarray(0, lastResp.length - 2));
328
+ }
329
+ let sw1 = lastResp[lastResp.length - 2];
330
+ let sw2 = lastResp[lastResp.length - 1];
331
+ // GET RESPONSE chaining
332
+ while (sw1 === 0x61) {
333
+ const getResp = await this.device.sendApdu(new Uint8Array([cla, 0xc0, 0x00, 0x00, sw2]));
334
+ if (getResp.length < 2) {
335
+ throw new DeviceError(-1, 'GET RESPONSE: response too short');
336
+ }
337
+ if (getResp.length > 2) {
338
+ parts.push(getResp.subarray(0, getResp.length - 2));
339
+ }
340
+ sw1 = getResp[getResp.length - 2];
341
+ sw2 = getResp[getResp.length - 1];
342
+ }
343
+ if (sw1 !== 0x90) {
344
+ throw new DeviceError(-1, `Final SW=${sw1.toString(16)}${sw2.toString(16)}`);
345
+ }
346
+ // Concatenate all response parts
347
+ const totalLen = parts.reduce((sum, p) => sum + p.length, 0);
348
+ const result = new Uint8Array(totalLen);
349
+ let pos = 0;
350
+ for (const part of parts) {
351
+ result.set(part, pos);
352
+ pos += part.length;
353
+ }
354
+ return result;
355
+ }
356
+ }
357
+ //# sourceMappingURL=apdu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apdu.js","sourceRoot":"","sources":["../src/apdu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa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/E,CAAC;QAED,iCAAiC;QACjC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACtB,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ export declare class EsimError extends Error {
2
+ readonly code: string;
3
+ constructor(code: string, message: string);
4
+ }
5
+ export declare class DeviceError extends EsimError {
6
+ readonly result: number;
7
+ constructor(result: number, message?: string);
8
+ }
9
+ export declare class Es10Error extends EsimError {
10
+ readonly resultCode: number;
11
+ constructor(resultCode: number, message?: string);
12
+ }
13
+ export declare class Es9PlusError extends EsimError {
14
+ readonly statusCode: number;
15
+ readonly serverStatus?: string;
16
+ readonly subjectCode?: string;
17
+ readonly reasonCode?: string;
18
+ constructor(params: {
19
+ statusCode: number;
20
+ serverStatus?: string;
21
+ subjectCode?: string;
22
+ reasonCode?: string;
23
+ message?: string;
24
+ });
25
+ }
26
+ export declare class TlvError extends EsimError {
27
+ constructor(message: string);
28
+ }
29
+ export declare class ActivationCodeError extends EsimError {
30
+ constructor(message: string);
31
+ }
32
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,qBAAa,WAAY,SAAQ,SAAS;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAK7C;AAED,qBAAa,SAAU,SAAQ,SAAS;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAKjD;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;CAYF;AAED,qBAAa,QAAS,SAAQ,SAAS;gBACzB,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,EAAE,MAAM;CAI5B"}
package/dist/errors.js ADDED
@@ -0,0 +1,52 @@
1
+ export class EsimError extends Error {
2
+ code;
3
+ constructor(code, message) {
4
+ super(message);
5
+ this.name = 'EsimError';
6
+ this.code = code;
7
+ }
8
+ }
9
+ export class DeviceError extends EsimError {
10
+ result;
11
+ constructor(result, message) {
12
+ super('DEVICE_ERROR', message ?? `Device error: ${result}`);
13
+ this.name = 'DeviceError';
14
+ this.result = result;
15
+ }
16
+ }
17
+ export class Es10Error extends EsimError {
18
+ resultCode;
19
+ constructor(resultCode, message) {
20
+ super('ES10_ERROR', message ?? `eUICC error: ${resultCode}`);
21
+ this.name = 'Es10Error';
22
+ this.resultCode = resultCode;
23
+ }
24
+ }
25
+ export class Es9PlusError extends EsimError {
26
+ statusCode;
27
+ serverStatus;
28
+ subjectCode;
29
+ reasonCode;
30
+ constructor(params) {
31
+ super('ES9PLUS_ERROR', params.message ??
32
+ `SM-DP+ error: HTTP ${params.statusCode}${params.serverStatus ? ` (${params.serverStatus})` : ''}`);
33
+ this.name = 'Es9PlusError';
34
+ this.statusCode = params.statusCode;
35
+ this.serverStatus = params.serverStatus;
36
+ this.subjectCode = params.subjectCode;
37
+ this.reasonCode = params.reasonCode;
38
+ }
39
+ }
40
+ export class TlvError extends EsimError {
41
+ constructor(message) {
42
+ super('TLV_ERROR', message);
43
+ this.name = 'TlvError';
44
+ }
45
+ }
46
+ export class ActivationCodeError extends EsimError {
47
+ constructor(message) {
48
+ super('ACTIVATION_CODE_ERROR', message);
49
+ this.name = 'ActivationCodeError';
50
+ }
51
+ }
52
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,SAAS;IAC/B,MAAM,CAAS;IAExB,YAAY,MAAc,EAAE,OAAgB;QAC1C,KAAK,CAAC,cAAc,EAAE,OAAO,IAAI,iBAAiB,MAAM,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,OAAO,SAAU,SAAQ,SAAS;IAC7B,UAAU,CAAS;IAE5B,YAAY,UAAkB,EAAE,OAAgB;QAC9C,KAAK,CAAC,YAAY,EAAE,OAAO,IAAI,gBAAgB,UAAU,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,SAAS;IAChC,UAAU,CAAS;IACnB,YAAY,CAAU;IACtB,WAAW,CAAU;IACrB,UAAU,CAAU;IAE7B,YAAY,MAMX;QACC,KAAK,CACH,eAAe,EACf,MAAM,CAAC,OAAO;YACZ,sBAAsB,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACrG,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,QAAS,SAAQ,SAAS;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { DeleteNotificationStatus, type NotificationMetadata, type Notification, type ProfileInstallationResult } from '../types.js';
2
+ /**
3
+ * Notification with raw PendingNotification bytes for sending to SM-DP+.
4
+ * Internal type used by processNotifications.
5
+ */
6
+ export interface NotificationWithRaw extends Notification {
7
+ /** Raw PendingNotification bytes (BF37 or 30) to send to SM-DP+ handleNotification */
8
+ raw: Uint8Array;
9
+ }
10
+ export declare function encodeListNotificationRequest(): Uint8Array;
11
+ export declare function decodeListNotificationResponse(data: Uint8Array): NotificationMetadata[];
12
+ export declare function encodeRetrieveNotificationsListRequest(seqNumber?: number): Uint8Array;
13
+ /**
14
+ * Decode RetrieveNotificationsList response returning raw bytes for a single notification.
15
+ * Used by processNotifications to forward to SM-DP+.
16
+ */
17
+ export declare function decodeRetrieveNotificationsListResponse(data: Uint8Array): Uint8Array;
18
+ /**
19
+ * Decode RetrieveNotificationsList response returning full Notification objects
20
+ * with raw bytes for sending to SM-DP+.
21
+ */
22
+ export declare function decodeRetrieveNotificationsListFull(data: Uint8Array): NotificationWithRaw[];
23
+ /**
24
+ * Decode ProfileInstallationResult (BF37) from BPP loading response.
25
+ * Returns success/failure status and ICCID or error codes.
26
+ */
27
+ export declare function decodeBppInstallationResult(data: Uint8Array): ProfileInstallationResult;
28
+ export declare function encodeRemoveNotificationRequest(seqNumber: number): Uint8Array;
29
+ export declare function decodeRemoveNotificationResponse(data: Uint8Array): DeleteNotificationStatus;
30
+ //# sourceMappingURL=es10b-notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"es10b-notifications.d.ts","sourceRoot":"","sources":["../../src/es10/es10b-notifications.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,wBAAwB,EAAE,KAAK,oBAAoB,EAAE,KAAK,YAAY,EAAE,KAAK,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAIxJ;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,sFAAsF;IACtF,GAAG,EAAE,UAAU,CAAC;CACjB;AAED,wBAAgB,6BAA6B,IAAI,UAAU,CAE1D;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,UAAU,GAAG,oBAAoB,EAAE,CAoBvF;AAmBD,wBAAgB,sCAAsC,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAQrF;AAED;;;GAGG;AACH,wBAAgB,uCAAuC,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CA8BpF;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,UAAU,GAAG,mBAAmB,EAAE,CA4C3F;AA6ED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,UAAU,GAAG,yBAAyB,CAoDvF;AAED,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAG7E;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,UAAU,GAAG,wBAAwB,CAU3F"}