@pagopa/io-react-native-jwt 1.2.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.
|
@@ -7,8 +7,8 @@ exports.addPadding = addPadding;
|
|
|
7
7
|
exports.decodeBase64 = decodeBase64;
|
|
8
8
|
exports.encodeBase64 = encodeBase64;
|
|
9
9
|
exports.removePadding = removePadding;
|
|
10
|
-
var _abab = require("abab");
|
|
11
10
|
var _errors = require("./errors");
|
|
11
|
+
var _jsBase = require("js-base64");
|
|
12
12
|
/*
|
|
13
13
|
* In Base64 encoding, the length of an output-encoded String
|
|
14
14
|
* must be a multiple of four. If necessary, the encoder adds
|
|
@@ -22,20 +22,10 @@ var _errors = require("./errors");
|
|
|
22
22
|
* ('=') is not URL safe.
|
|
23
23
|
*/
|
|
24
24
|
function encodeBase64(value) {
|
|
25
|
-
|
|
26
|
-
if (encoded) {
|
|
27
|
-
return removePadding(encoded);
|
|
28
|
-
} else {
|
|
29
|
-
throw new _errors.JOSEError('Unable to encode string to base64');
|
|
30
|
-
}
|
|
25
|
+
return _jsBase.Base64.encode(value, true);
|
|
31
26
|
}
|
|
32
27
|
function decodeBase64(value) {
|
|
33
|
-
|
|
34
|
-
if (decoded) {
|
|
35
|
-
return decoded;
|
|
36
|
-
} else {
|
|
37
|
-
throw new _errors.JOSEError('Unable to decode base64 string');
|
|
38
|
-
}
|
|
28
|
+
return _jsBase.Base64.decode(value);
|
|
39
29
|
}
|
|
40
30
|
function removePadding(encoded) {
|
|
41
31
|
// eslint-disable-next-line no-div-regex
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_errors","require","_jsBase","encodeBase64","value","Base64","encode","decodeBase64","decode","removePadding","encoded","replace","addPadding","pad","length","JOSEError","Array","join"],"sourceRoot":"../../../src","sources":["utils/base64.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAACC,KAAa,EAAU;EAClD,OAAOC,cAAM,CAACC,MAAM,CAACF,KAAK,EAAE,IAAI,CAAC;AACnC;AAEO,SAASG,YAAYA,CAACH,KAAa,EAAU;EAClD,OAAOC,cAAM,CAACG,MAAM,CAACJ,KAAK,CAAC;AAC7B;AAEO,SAASK,aAAaA,CAACC,OAAe,EAAU;EACrD;EACA,OAAOA,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AAC1E;AAEO,SAASC,UAAUA,CAACF,OAAe,EAAU;EAClDA,OAAO,GAAGA,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EACvD,IAAIE,GAAG,GAAGH,OAAO,CAACI,MAAM,GAAG,CAAC;EAC5B,IAAID,GAAG,EAAE;IACP,IAAIA,GAAG,KAAK,CAAC,EAAE;MACb,MAAM,IAAIE,iBAAS,CACjB,qFACF,CAAC;IACH;IACAL,OAAO,IAAI,IAAIM,KAAK,CAAC,CAAC,GAAGH,GAAG,CAAC,CAACI,IAAI,CAAC,GAAG,CAAC;EACzC;EACA,OAAOP,OAAO;AAChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { btoa, atob } from 'abab';
|
|
2
1
|
import { JOSEError } from './errors';
|
|
2
|
+
import { Base64 } from 'js-base64';
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* In Base64 encoding, the length of an output-encoded String
|
|
@@ -14,20 +14,10 @@ import { JOSEError } from './errors';
|
|
|
14
14
|
* ('=') is not URL safe.
|
|
15
15
|
*/
|
|
16
16
|
export function encodeBase64(value) {
|
|
17
|
-
|
|
18
|
-
if (encoded) {
|
|
19
|
-
return removePadding(encoded);
|
|
20
|
-
} else {
|
|
21
|
-
throw new JOSEError('Unable to encode string to base64');
|
|
22
|
-
}
|
|
17
|
+
return Base64.encode(value, true);
|
|
23
18
|
}
|
|
24
19
|
export function decodeBase64(value) {
|
|
25
|
-
|
|
26
|
-
if (decoded) {
|
|
27
|
-
return decoded;
|
|
28
|
-
} else {
|
|
29
|
-
throw new JOSEError('Unable to decode base64 string');
|
|
30
|
-
}
|
|
20
|
+
return Base64.decode(value);
|
|
31
21
|
}
|
|
32
22
|
export function removePadding(encoded) {
|
|
33
23
|
// eslint-disable-next-line no-div-regex
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["JOSEError","Base64","encodeBase64","value","encode","decodeBase64","decode","removePadding","encoded","replace","addPadding","pad","length","Array","join"],"sourceRoot":"../../../src","sources":["utils/base64.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,UAAU;AACpC,SAASC,MAAM,QAAQ,WAAW;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,KAAa,EAAU;EAClD,OAAOF,MAAM,CAACG,MAAM,CAACD,KAAK,EAAE,IAAI,CAAC;AACnC;AAEA,OAAO,SAASE,YAAYA,CAACF,KAAa,EAAU;EAClD,OAAOF,MAAM,CAACK,MAAM,CAACH,KAAK,CAAC;AAC7B;AAEA,OAAO,SAASI,aAAaA,CAACC,OAAe,EAAU;EACrD;EACA,OAAOA,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AAC1E;AAEA,OAAO,SAASC,UAAUA,CAACF,OAAe,EAAU;EAClDA,OAAO,GAAGA,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;EACvD,IAAIE,GAAG,GAAGH,OAAO,CAACI,MAAM,GAAG,CAAC;EAC5B,IAAID,GAAG,EAAE;IACP,IAAIA,GAAG,KAAK,CAAC,EAAE;MACb,MAAM,IAAIX,SAAS,CACjB,qFACF,CAAC;IACH;IACAQ,OAAO,IAAI,IAAIK,KAAK,CAAC,CAAC,GAAGF,GAAG,CAAC,CAACG,IAAI,CAAC,GAAG,CAAC;EACzC;EACA,OAAON,OAAO;AAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../src/utils/base64.ts"],"names":[],"mappings":"AAeA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../src/utils/base64.ts"],"names":[],"mappings":"AAeA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/io-react-native-jwt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Native support for JWT",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
]
|
|
166
166
|
},
|
|
167
167
|
"dependencies": {
|
|
168
|
-
"
|
|
168
|
+
"js-base64": "^3.7.7",
|
|
169
169
|
"zod": "^3.22.4"
|
|
170
170
|
}
|
|
171
171
|
}
|
package/src/utils/base64.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { btoa, atob } from 'abab';
|
|
2
1
|
import { JOSEError } from './errors';
|
|
2
|
+
import { Base64 } from 'js-base64';
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* In Base64 encoding, the length of an output-encoded String
|
|
@@ -14,21 +14,11 @@ import { JOSEError } from './errors';
|
|
|
14
14
|
* ('=') is not URL safe.
|
|
15
15
|
*/
|
|
16
16
|
export function encodeBase64(value: string): string {
|
|
17
|
-
|
|
18
|
-
if (encoded) {
|
|
19
|
-
return removePadding(encoded);
|
|
20
|
-
} else {
|
|
21
|
-
throw new JOSEError('Unable to encode string to base64');
|
|
22
|
-
}
|
|
17
|
+
return Base64.encode(value, true);
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
export function decodeBase64(value: string): string {
|
|
26
|
-
|
|
27
|
-
if (decoded) {
|
|
28
|
-
return decoded;
|
|
29
|
-
} else {
|
|
30
|
-
throw new JOSEError('Unable to decode base64 string');
|
|
31
|
-
}
|
|
21
|
+
return Base64.decode(value);
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
export function removePadding(encoded: string): string {
|