redsys-easy 3.1.0 → 4.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  Redsys Easy
2
2
  ---
3
3
 
4
- Node JS interface for Redsys payment gateway
4
+ Node JS client and utilities for implementing a redsys payment gateway
5
5
 
6
6
  ## Install
7
7
 
@@ -9,455 +9,130 @@ Node JS interface for Redsys payment gateway
9
9
  npm install redsys-easy
10
10
  ```
11
11
 
12
- ## Usage
13
-
14
- When creating a `Redsys` instance, you are required to pass some options. `secretKey` is your Redsys key. The `urls` property should be an Object with the urls of Redsys endpoints.
15
-
16
- ```js
17
- const {
18
- SANDBOX_URLS,
19
- PRODUCTION_URLS,
20
- Redsys
21
- } = require('redsys-easy')
12
+ ## API documentation
22
13
 
23
- const redsys = new Redsys({
24
- secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
25
- urls: SANDBOX_URLS,
26
- });
27
-
28
- // PRODUCTION_URLS
29
- {
30
- redirect: 'https://sis.redsys.es/sis/realizarPago',
31
- ws: 'https://sis.redsys.es/sis/services/SerClsWSEntrada/wsdl/SerClsWSEntrada.wsdl'
32
- }
33
- ```
14
+ Checkout the [api documentation](./docs/redsys-easy.md) to explore the utilities exported by this package.
34
15
 
35
- ### Redirection Requests
16
+ ## Usage
36
17
 
37
- Generate the parameters to create a transaction:
18
+ These are the most important utilities that redsys-easy provides.
38
19
 
39
- ```js
40
- const {
41
- Redsys,
20
+ <!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/__readme__/usage.ts) -->
21
+ <!-- The below code snippet is automatically added from ./examples/__readme__/usage.ts -->
22
+ ```ts
23
+ import {
24
+ createRedsysAPI,
42
25
  SANDBOX_URLS,
43
26
  PRODUCTION_URLS,
44
- TRANSACTION_TYPES,
45
- randomTransactionId
46
- } = require('redsys-easy')
47
-
48
- const redsys = new Redsys({
49
- secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
50
- urls: SANDBOX_URLS, // Also PRODUCTION_URLS
51
- });
52
-
53
- const obj = {
54
- // amount in smallest currency unit(cents)
55
- // 49.99€
56
- amount: 4999,
57
- currency: 'EUR',
58
- order: randomTransactionId(),
59
- merchantName: 'MI COMERCIO',
60
- merchantCode: '999008881',
61
- terminal: '1',
62
- transactionType: TRANSACTION_TYPES.AUTHORIZATION, // '0'
63
- merchantURL: 'http://micomercio.com/payments/redsys/notification',
64
- successURL: 'http://micomercio.com/compra/success',
65
- errorURL: 'http://micomercio.com/compra/error',
66
- // Raw parameters
67
- raw: {
68
- // merchantData
69
- DS_MERCHANT_MERCHANTDATA: 'foo',
70
- },
71
- }
72
-
73
- const form = redsys.redirectPetition(obj)
74
- console.log(form);
75
- ```
76
-
77
- The above will produce an object similar to
78
-
79
- ```js
80
- {
81
- url: 'https://sis-t.redsys.es:25443/sis/realizarPago',
82
- body: {
83
- Ds_MerchantParameters: 'eyJEU19NRVJDSEFOVF9BTU9VTlQiOiIxMDAiLCJEU19NRVJDSEFOVF9PUkRFUiI6IjE1MDg0MjgzNjAiLCJEU19NRVJDSEFOVF9NRVJDSEFOVE5BTUUiOiJUZXN0aW5nIFNob3AiLCJEU19NRVJDSEFOVF9NRVJDSEFOVENPREUiOiIzMjcyMzQ2ODgiLCJEU19NRVJDSEFOVF9DVVJSRU5DWSI6Ijk3OCIsIkRTX01FUkNIQU5UX1RSQU5TQUNUSU9OVFlQRSI6IjAiLCJEU19NRVJDSEFOVF9URVJNSU5BTCI6IjEiLCJEU19NRVJDSEFOVF9NRVJDSEFOVFVSTCI6IiIsIkRTX01FUkNIQU5UX1VSTE9LIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwL3N1Y2Nlc3MiLCJEU19NRVJDSEFOVF9VUkxLTyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9lcnJvciJ9',
84
- Ds_SignatureVersion: 'HMAC_SHA256_V1',
85
- Ds_Signature: 'qkMJMWR6Dq32xwbQuguTv39OvXv4KdD1Xg7pZ8phGZI='
86
- }
87
- }
88
- ```
89
-
90
- Which can be used to create a payment form
91
-
92
- ### Process REST Notifications
27
+ // Create a new orderId
28
+ randomTransactionId,
29
+ // Utilities for 3DS forms
30
+ create3DSMethodForm,
31
+ create3DSv1ChallengeForm,
32
+ create3DSv2ChallengeForm,
33
+ deserializeThreeDSMethodData,
34
+ deserializeCres
35
+ } from 'redsys-easy';
93
36
 
94
- ```js
95
37
  const {
96
- Redsys,
97
- SANDBOX_URLS,
98
- PRODUCTION_URLS,
99
- TRANSACTION_TYPES
100
- } = require('redsys-easy')
101
-
102
- const redsys = new Redsys({
38
+ // REST integration
39
+ restIniciaPeticion,
40
+ restTrataPeticion,
41
+ // Redirect integration
42
+ createRedirectForm,
43
+ processRestNotification,
44
+ processSoapNotification,
45
+ createSoapNotificationAnswer
46
+ }= createRedsysAPI({
103
47
  secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
104
- urls: SANDBOX_URLS, // Also PRODUCTION_URLS
48
+ urls: SANDBOX_URLS
105
49
  });
106
-
107
- const result = redsys.processNotification(req.body)
108
- console.log(result)
109
- ```
110
-
111
- If the signature is not correct, it will throw an error. Otherwise it will return an object like this.
112
-
113
- ```js
114
- {
115
- date: '2017-10-20',
116
- hour: '18:20',
117
- // Already timezone aware
118
- timestamp: new Date('2017-10-20 17:20 Z'),
119
- securePayment: true,
120
- // amount in smallest currency unit(cents)
121
- // 49.99€
122
- amount: 4999,
123
- currency: 'EUR',
124
- order: '000079d1Zr9',
125
- merchantCode: '327234688',
126
- terminal: '001',
127
- response: 0,
128
- transactionType: '0',
129
- authorisationCode: '678746',
130
- lang: 'es',
131
- cardCountry: 'es',
132
- cardBrand: 'VISA',
133
- // Raw response parameters
134
- raw: {
135
- Ds_Date: '20/10/2017',
136
- Ds_Hour: '18:20',
137
- Ds_SecurePayment: '1',
138
- Ds_Amount: '100',
139
- Ds_Currency: '978',
140
- Ds_Order: '00007921799',
141
- Ds_MerchantCode: '327234688',
142
- Ds_Terminal: '001',
143
- Ds_Response: '0000',
144
- Ds_TransactionType: '0',
145
- Ds_MerchantData: '',
146
- Ds_AuthorisationCode: '678746',
147
- Ds_ConsumerLanguage: '1',
148
- Ds_Card_Country: '724',
149
- Ds_Card_Brand: '1'
150
- }
151
- }
152
- ```
153
-
154
- ### Response code messages
155
-
156
- ```js
157
- const { getResponseCodeMessage } = require('redsys-easy')
158
-
159
- getResponseCodeMessage('0180')
160
- // 'Operación no permitida para ese tipo de tarjeta.'
161
-
162
- getResponseCodeMessage('xyz')
163
- // null
164
50
  ```
51
+ <!-- AUTO-GENERATED-CONTENT:END -->
165
52
 
166
- ### Web Service Requests
53
+ ## Examples
167
54
 
168
- ```js
169
- const {
170
- Redsys,
171
- TRANSACTION_TYPES,
172
- SANDBOX_URLS,
173
- PRODUCTION_URLS,
174
- randomTransactionId,
175
- } = require('redsys-easy')
176
-
177
- const redsys = new Redsys({
178
- secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
179
- urls: SANDBOX_URLS, // Also PRODUCTION_URLS
180
- })
55
+ Despite the name, a redsys payment gateway with 3DS support is quite complex. Don't despair, these examples show how it can be implemented.
56
+ - [INSITE client](./examples/insite-client) implemented using a [solid](https://github.com/solidjs/solid) web app.
57
+ - [REST 3DS server](./examples/rest-3ds-server) implemented using a [koa](https://koajs.com/) http server.
181
58
 
182
- const params = {
183
- // amount in smallest currency unit(cents)
184
- // 33.50€
185
- amount: 3350,
186
- order: '000079d1Zr9',
187
- merchantCode: '999008881',
188
- currency: 'EUR',
189
- pan: '4548812049400004',
190
- cvv: '123',
191
- expiryDate: '1220', // MMYY format
192
- transactionType: TRANSACTION_TYPES.NO_AUTHENTICATION,
193
- terminal: '1',
194
- // Raw parameters
195
- raw: {
196
- // merchantData
197
- DS_MERCHANT_MERCHANTDATA: 'foo',
198
- },
199
- }
59
+ Redirection is much simpler but less customizable
60
+ - [Redirection integration](./examples/redirection)
200
61
 
201
- redsys.wsPetition(params).then(result => {
202
- console.log(result);
203
- })
204
- ```
62
+ ## Formatters
205
63
 
206
- Redsys SIS errors will raise errors in Node JS, but failed transactions will not. You can check the transaction status in this way.
64
+ By default, the main functions exported by this package use the API specified by redsys. To smooth out the corners of this API, it's also possible to wrap them with custom formatters.
207
65
 
208
- ```js
209
- const {
210
- getResponseCodeMessage,
211
- } = require('redsys-easy')
66
+ As an example, redsys-easy provides some basic typescript-ready formatters.
212
67
 
213
- // Get response code
214
- result.response
215
- result.raw.Ds_Response
68
+ > :warning: **Format has changed**: Previous versions of redsys-easy used a different format, particularly the `amount` field.
216
69
 
217
- // Get code message
218
- getResponseCodeMessage(response);
219
- getResponseCodeMessage(result.raw.Ds_Response);
220
- ```
221
-
222
- ### Basic SOAP Notification functions
223
-
224
- ```js
225
- const {
226
- Redsys,
70
+ <!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/__readme__/formatters.ts) -->
71
+ <!-- The below code snippet is automatically added from ./examples/__readme__/formatters.ts -->
72
+ ```ts
73
+ import {
74
+ createRedsysAPI,
227
75
  SANDBOX_URLS,
228
- PRODUCTION_URLS,
229
- } = require('redsys-easy')
230
-
231
- const redsys = new Redsys({
232
- secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
233
- urls: SANDBOX_URLS, // Also PRODUCTION_URLS
234
- });
235
-
236
- // Get the parameters from a message/request xml
237
- // Throws an error if signature is not valid
238
- const params = processSoapNotification(requestXml);
239
-
240
- // Build your signed answer/response.
241
- // Second arg dedices whether the transaction is approved
242
- const answer = soapNotificationAnswer(params.Ds_Order, true);
243
- ```
244
-
245
- ### Mimic a SOAP Notification server
76
+ // Formatter utils
77
+ useSingleInputFormatter,
78
+ useOutputFormatter,
79
+ usePromiseOutputFormatter,
80
+ // Input formatters
81
+ redirectInputFormatter,
82
+ restIniciaPeticionInputFormatter,
83
+ restTrataPeticionInputFormatter,
84
+ // Output formatters
85
+ restNotificationOutputFormatter,
86
+ soapNotificationOutputFormatter,
87
+ restIniciaPeticionOutputFormatter,
88
+ restTrataPeticionOutputFormatter
89
+ } from 'redsys-easy';
246
90
 
247
- Now you can receive synchronous notifications and kill the transaction if you want. No need to run a full-fledged SOAP server.
248
-
249
- ```js
250
91
  const {
251
- Redsys,
252
- SANDBOX_URLS,
253
- PRODUCTION_URLS,
254
- detectSoapVersion,
255
- mimicSoapNotificationReceiver,
256
- mimicSoap11NotificationResponse,
257
- mimicSoap12NotificationResponse,
258
- } = require('redsys-easy')
259
-
260
- const redsys = new Redsys({
92
+ restIniciaPeticion: baseRestIniciaPeticion,
93
+ restTrataPeticion: baseRestTrataPeticion,
94
+ createRedirectForm: baseCreateRedirectForm,
95
+ processRestNotification: baseProcessRestNotification,
96
+ processSoapNotification: baseProcessSoapNotification
97
+ } = createRedsysAPI({
261
98
  secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
262
- urls: SANDBOX_URLS, // Also PRODUCTION_URLS
263
- });
264
- ```
265
-
266
- In koa
267
-
268
- ```js
269
- app.post('/soapNotification', ctx => {
270
- // Simulate processing raw xml by a SOAP server
271
- const requestXml = mimicSoapNotificationReceiver(ctx.request.body),
272
-
273
- // Throws an error if signature is not valid
274
- const params = processSoapNotification(requestXml);
275
-
276
- // Build your answer
277
- // Second arg dedices whether the transaction is approved
278
- const answer = soapNotificationAnswer(params.order, true);
279
-
280
- // Simulate a full SOAP server response
281
- const soapVersion = detectSoapVersion({
282
- headers: ctx.request.headers,
283
- body: ctx.request.body,
284
- });
285
-
286
- if (soapVersion === '1.2') {
287
- ctx.type = 'application/soap+xml; charset=utf-8';
288
- ctx.body = mimicSoap12NotificationResponse(answer);
289
- } else {
290
- ctx.type = 'text/xml; charset=utf-8';
291
- ctx.body = mimicSoap11NotificationResponse(answer);
292
- }
293
- });
294
- ```
295
-
296
- In express
297
-
298
- ```js
299
- app.post('/soapNotification', (req, res) => {
300
- // Simulate processing raw xml by a SOAP server
301
- const requestXml = mimicSoapNotificationReceiver(req.body),
302
-
303
- // Throws an error if signature is not valid
304
- const params = processSoapNotification(requestXml);
305
-
306
- // Build your answer
307
- // Second arg dedices whether the transaction is approved
308
- const answer = soapNotificationAnswer(params.order, true);
309
-
310
- // Simulate a full SOAP server response
311
- const soapVersion = detectSoapVersion({
312
- headers: req.headers,
313
- body: req.body,
314
- });
315
-
316
- if (soapVersion === '1.2') {
317
- res.set('Content-Type', 'application/soap+xml; charset=utf-8');
318
- res.send(mimicSoap12NotificationResponse(answer));
319
- } else {
320
- res.set('Content-Type', 'text/xml; charset=utf-8');
321
- res.send(mimicSoap11NotificationResponse(answer));
322
- }
99
+ urls: SANDBOX_URLS
323
100
  });
324
- ```
325
-
326
-
327
- ### Accepted parameters for redirectPetition and wsPetition
328
-
329
- Numbers
330
-
331
- * amount: integer in the smallest currency unit.
332
-
333
- Strings
334
-
335
- * order
336
- * merchantCode
337
- * currency: Uppercase ISO 4217 alpha-3 code, e.g 'EUR'
338
- * transactionType
339
- * terminal
340
- * merchantName
341
- * merchantURL
342
- * errorURL
343
- * successURL
344
- * dateFrequency
345
- * chargeExpiryDate
346
- * sumTotal
347
- * directPayment
348
- * identifier
349
- * group
350
- * pan: credit card number
351
- * expiryDate: As printed in your credit card, MMYY, has priority over expiryYear and expiryMonth
352
- * expiryYear: YY
353
- * expiryMonth: MM
354
- * cvv
355
- * partialPayment
356
- * cardCountry: Lowercase ISO 3166 Alpha 2 country code, e.g. 'es'
357
- * merchantData
358
- * clientIp
359
- * lang: Lowercase ISO 639-1 lang code
360
- * operationId
361
- * payMethods
362
- * productDescription
363
- * taxReference
364
- * transactionDate
365
- * merchantDescriptor
366
- * customerMobile: Mobile phone number
367
- * customerMail: Email address
368
- * cardHolder: Name of credit card holder
369
- * smsTemplate: Paygold sms template like `'@COMERCIO@. Ya puede pagar su recibo de @IMPORTE@ @MONEDA@ en la siguiente url: @URL@'`
370
-
371
- Other
372
-
373
- * raw: Object with parameters that will not formatted. E.g. `raw: { DS_MERCHANTDATA: 'foo', ... }`
374
-
375
- ### Response
376
101
 
377
- Numbers
378
-
379
- * amount: integer in the smallest currency unit.
380
- * response: response code
381
-
382
- Booleans
383
- * securePayment
384
-
385
- Strings
386
-
387
- * hour: HH:MM
388
- * date: YYYY-MM-DD
389
- * timestamp: javascript date object, with date and hour information
390
- * order
391
- * merchantCode
392
- * currency: Uppercase ISO 4217 alpha-3 code, e.g 'EUR'
393
- * transactionType
394
- * terminal
395
- * identifier
396
- * cardNumber: Partial credit card number
397
- * expiryDate: As printed in your credit card, MMYY
398
- * expiryYear: YY
399
- * expiryMonth: MM
400
- * cardBrand: E.g. 'VISA'
401
- * cardType: 'C' (Credit) or 'D' (Debit)
402
- * cardCountry: Lowercase ISO 3166 Alpha 2 country code, e.g. 'es'
403
- * authorisationCode
404
- * merchantData
405
- * clientIp
406
- * lang: Lowercase ISO 639-1 lang code
407
- * operationId
408
- * transactionDate
409
- * merchantDescriptor
410
- * payURL: Paygold 2 phase payment URL to send to the client
411
-
412
- Other
413
-
414
- * raw: Full response as received from the server. E.g. `{ DS_MERCHANTDATA: 'foo', ... }`
415
-
416
- ### Transaction Types
417
-
418
- * AUTHORIZATION: "0"
419
- * PRE_AUTHORIZATION: "1"
420
- * CONFIRMATION: "2"
421
- * AUTO_REFUND: "3"
422
- * RECURRING_TRANSACTION: "5"
423
- * SUCCESSIVE_TRANSACTION: "6"
424
- * PRE_AUTHENTICATION: "7"
425
- * PRE_AUTHENTICATION_CONFIRMATION: "8"
426
- * PRE_AUTHORIZATION_CANCEL: "9"
427
- * DEFERRED_AUTHORIZATION: "O"
428
- * PAYLINK: "F". Also known as paygold.
429
- * DEFERRED_AUTHORIZATION_CONFIRMATION: "P"
430
- * DEFERRED_AUTHORIZATION_CANCEL: "Q"
431
- * DEFERRED_INITIAL_FEE: "R"
432
- * DEFERRED_SUCCESSIVE_FEE: "S"
433
- * NO_AUTHENTICATION: "A"
434
- * DELETE_REFERENCE: "44"
435
-
436
- ### Errors
437
-
438
- * RedsysError: Super class from which all errors inherit. Unclassified errors.
439
- * ValidationError: Error validating input parameters.
440
- * ParseError: Error parsing response.
441
- * GatewayError: Redsys gateway returned an error code. Note that only webservice requests trigger this error, notification processors don't.
442
-
443
- ```js
444
- const {
445
- RedsysError,
446
- ValidationError,
447
- ParseError,
448
- GatewayError,
449
- } = require('redsys-easy');
102
+ /*
103
+ * External Internal
104
+ * amount '33.5' <-> '3350'
105
+ * currency 'EUR' <-> '978'
106
+ *
107
+ * expiryYear '34'
108
+ * expiryMonth '12'
109
+ * <-> '3412'
110
+ *
111
+ * lang 'es' <-> '1'
112
+ * cardBrand 'VISA' <- '1'
113
+ * cardCountry 'es' <- '724'
114
+ */
115
+ export const createRedirectForm = useSingleInputFormatter(baseCreateRedirectForm, redirectInputFormatter);
116
+ export const restIniciaPeticion = useSingleInputFormatter(
117
+ usePromiseOutputFormatter(baseRestIniciaPeticion, restIniciaPeticionOutputFormatter),
118
+ restIniciaPeticionInputFormatter
119
+ )
120
+ export const restTrataPeticion = useSingleInputFormatter(
121
+ usePromiseOutputFormatter(baseRestTrataPeticion, restTrataPeticionOutputFormatter),
122
+ restTrataPeticionInputFormatter
123
+ )
124
+ export const processRestNotification = useOutputFormatter(baseProcessRestNotification, restNotificationOutputFormatter);
125
+ export const processSoapNotification = useOutputFormatter(baseProcessSoapNotification, soapNotificationOutputFormatter);
450
126
  ```
127
+ <!-- AUTO-GENERATED-CONTENT:END -->
451
128
 
452
129
  ## FAQ
453
130
 
454
- ### What is the smallest unit of a currency?
455
-
456
- The smallest unit of a currency, is the smallest integer amount of said currency. For euros, it is cents. So 1.99 EUR would be 199 of the smallest unit.
131
+ ### How should I format the amount?
457
132
 
458
- ### Why are amounts denominated in the smallest unit of a currency?
133
+ Redsys API uses expects amounts denominated in the smallest unit of a currency. The exported core functions of redsys-easy also follows this convention. The smallest unit of a currency is the smallest integer amount of said currency. For euros, it is cents. So 1.99 EUR would be 199 of the smallest unit.
459
134
 
460
- To avoid floats and precision losses. In javascript `0.1 + 0.2 !== 0.3`, but `1 + 2 === 3`. Also, this is a convention for payment processors and POS terminals.
135
+ However you are free to wrap these core functions with a custom formatter. Particularly, redsys-easy optional formatters expect the amount to be formatted as a decimal string currency unit. For euros, it would be '1.99'.
461
136
 
462
137
  ## Acknowledgments
463
138
 
@@ -1,4 +1,28 @@
1
+ /**
2
+ * Card brand name
3
+ *
4
+ * @public
5
+ */
1
6
  export declare type CardBrand = 'VISA' | 'MASTERCARD' | 'DINERS' | 'PRIVATE' | 'AMEX' | 'JCB' | 'UPI';
2
- export declare const CARDBRANDS: Record<CardBrand, string>;
3
- declare const REV_CARDBRANDS: Record<string, CardBrand>;
7
+ /**
8
+ * Card brand number
9
+ *
10
+ * @public
11
+ */
12
+ export declare type CardBrandNum = '1' | '2' | '6' | '7' | '8' | '9' | '22';
13
+ /**
14
+ * Card brand name to number
15
+ *
16
+ * @public
17
+ */
18
+ export declare const CARDBRANDS: Record<CardBrand, CardBrandNum>;
19
+ /**
20
+ * Card brand number to name
21
+ *
22
+ * @remarks
23
+ * @see {@link CARDBRANDS}
24
+ *
25
+ * @public
26
+ */
27
+ declare const REV_CARDBRANDS: Record<CardBrandNum, CardBrand>;
4
28
  export { REV_CARDBRANDS };
@@ -1,4 +1,31 @@
1
+ /**
2
+ * Country ISO 3166 Alpha 2 code
3
+ *
4
+ * @public
5
+ */
1
6
  export declare type Country = 'af' | 'al' | 'aq' | 'dz' | 'as' | 'ad' | 'ao' | 'ag' | 'az' | 'ar' | 'au' | 'at' | 'bs' | 'bh' | 'bd' | 'am' | 'bb' | 'be' | 'bm' | 'bt' | 'bo' | 'ba' | 'bw' | 'bv' | 'br' | 'bz' | 'io' | 'sb' | 'vg' | 'bn' | 'bg' | 'mm' | 'bi' | 'by' | 'kh' | 'cm' | 'ca' | 'cv' | 'ky' | 'cf' | 'lk' | 'td' | 'cl' | 'cn' | 'tw' | 'cx' | 'cc' | 'co' | 'km' | 'yt' | 'cg' | 'cd' | 'ck' | 'cr' | 'hr' | 'cu' | 'cy' | 'cz' | 'bj' | 'dk' | 'dm' | 'do' | 'ec' | 'sv' | 'gq' | 'et' | 'er' | 'ee' | 'fo' | 'fk' | 'gs' | 'fj' | 'fi' | 'ax' | 'fr' | 'gf' | 'pf' | 'tf' | 'dj' | 'ga' | 'ge' | 'gm' | 'ps' | 'de' | 'gh' | 'gi' | 'ki' | 'gr' | 'gl' | 'gd' | 'gp' | 'gu' | 'gt' | 'gn' | 'gy' | 'ht' | 'hm' | 'va' | 'hn' | 'hk' | 'hu' | 'is' | 'in' | 'id' | 'ir' | 'iq' | 'ie' | 'il' | 'it' | 'ci' | 'jm' | 'jp' | 'kz' | 'jo' | 'ke' | 'kp' | 'kr' | 'kw' | 'kg' | 'la' | 'lb' | 'ls' | 'lv' | 'lr' | 'ly' | 'li' | 'lt' | 'lu' | 'mo' | 'mg' | 'mw' | 'my' | 'mv' | 'ml' | 'mt' | 'mq' | 'mr' | 'mu' | 'mx' | 'mc' | 'mn' | 'md' | 'me' | 'ms' | 'ma' | 'mz' | 'om' | 'na' | 'nr' | 'np' | 'nl' | 'cw' | 'aw' | 'sx' | 'bq' | 'nc' | 'vu' | 'nz' | 'ni' | 'ne' | 'ng' | 'nu' | 'nf' | 'no' | 'mp' | 'um' | 'fm' | 'mh' | 'pw' | 'pk' | 'pa' | 'pg' | 'py' | 'pe' | 'ph' | 'pn' | 'pl' | 'pt' | 'gw' | 'tl' | 'pr' | 'qa' | 're' | 'ro' | 'ru' | 'rw' | 'bl' | 'sh' | 'kn' | 'ai' | 'lc' | 'mf' | 'pm' | 'vc' | 'sm' | 'st' | 'sa' | 'sn' | 'rs' | 'sc' | 'sl' | 'sg' | 'sk' | 'vn' | 'si' | 'so' | 'za' | 'zw' | 'es' | 'ss' | 'sd' | 'eh' | 'sr' | 'sj' | 'sz' | 'se' | 'ch' | 'sy' | 'tj' | 'th' | 'tg' | 'tk' | 'to' | 'tt' | 'ae' | 'tn' | 'tr' | 'tm' | 'tc' | 'tv' | 'ug' | 'ua' | 'mk' | 'eg' | 'gb' | 'gg' | 'je' | 'im' | 'tz' | 'us' | 'vi' | 'bf' | 'uy' | 'uz' | 've' | 'wf' | 'ws' | 'ye' | 'zm';
2
- export declare const COUNTRIES: Record<Country, string>;
3
- declare const REV_COUNTRIES: Record<string, Country>;
7
+ /**
8
+ * Country UN M49 number
9
+ *
10
+ * @public
11
+ */
12
+ export declare type CountryNum = '4' | '8' | '10' | '12' | '16' | '20' | '24' | '28' | '31' | '32' | '36' | '40' | '44' | '48' | '50' | '51' | '52' | '56' | '60' | '64' | '68' | '70' | '72' | '74' | '76' | '84' | '86' | '90' | '92' | '96' | '100' | '104' | '108' | '112' | '116' | '120' | '124' | '132' | '136' | '140' | '144' | '148' | '152' | '156' | '158' | '162' | '166' | '170' | '174' | '175' | '178' | '180' | '184' | '188' | '191' | '192' | '196' | '203' | '204' | '208' | '212' | '214' | '218' | '222' | '226' | '231' | '232' | '233' | '234' | '238' | '239' | '242' | '246' | '248' | '250' | '254' | '258' | '260' | '262' | '266' | '268' | '270' | '275' | '276' | '288' | '292' | '296' | '300' | '304' | '308' | '312' | '316' | '320' | '324' | '328' | '332' | '334' | '336' | '340' | '344' | '348' | '352' | '356' | '360' | '364' | '368' | '372' | '376' | '380' | '384' | '388' | '392' | '398' | '400' | '404' | '408' | '410' | '414' | '417' | '418' | '422' | '426' | '428' | '430' | '434' | '438' | '440' | '442' | '446' | '450' | '454' | '458' | '462' | '466' | '470' | '474' | '478' | '480' | '484' | '492' | '496' | '498' | '499' | '500' | '504' | '508' | '512' | '516' | '520' | '524' | '528' | '531' | '533' | '534' | '535' | '540' | '548' | '554' | '558' | '562' | '566' | '570' | '574' | '578' | '580' | '581' | '583' | '584' | '585' | '586' | '591' | '598' | '600' | '604' | '608' | '612' | '616' | '620' | '624' | '626' | '630' | '634' | '638' | '642' | '643' | '646' | '652' | '654' | '659' | '660' | '662' | '663' | '666' | '670' | '674' | '678' | '682' | '686' | '688' | '690' | '694' | '702' | '703' | '704' | '705' | '706' | '710' | '716' | '724' | '728' | '729' | '732' | '740' | '744' | '748' | '752' | '756' | '760' | '762' | '764' | '768' | '772' | '776' | '780' | '784' | '788' | '792' | '795' | '796' | '798' | '800' | '804' | '807' | '818' | '826' | '831' | '832' | '833' | '834' | '840' | '850' | '854' | '858' | '860' | '862' | '876' | '882' | '887' | '894';
13
+ /**
14
+ * Maps ISO 3166 Alpha 2 codes to UN M49 numbers
15
+ *
16
+ * @remarks
17
+ * [UN M49 to ISO 3166 information](https://unstats.un.org/unsd/methodology/m49/)
18
+ *
19
+ * @public
20
+ */
21
+ export declare const COUNTRIES: Record<Country, CountryNum>;
22
+ /**
23
+ * Maps UN M49 numbers to ISO 3166 Alpha 2 codes
24
+ *
25
+ * @remarks
26
+ * @see {@link COUNTRIES}
27
+ *
28
+ * @public
29
+ */
30
+ declare const REV_COUNTRIES: Record<CountryNum, Country>;
4
31
  export { REV_COUNTRIES };