@pagopa/io-react-native-jwt 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +145 -0
  3. package/android/build.gradle +97 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/com/pagopa/ioreactnativejwt/IoReactNativeJwtModule.kt +114 -0
  7. package/android/src/main/java/com/pagopa/ioreactnativejwt/IoReactNativeJwtPackage.kt +17 -0
  8. package/android/src/main/java/com/pagopa/ioreactnativejwt/Utils.kt +95 -0
  9. package/ios/ASN1DERParsing.swift +226 -0
  10. package/ios/IoReactNativeJwt-Bridging-Header.h +2 -0
  11. package/ios/IoReactNativeJwt.mm +28 -0
  12. package/ios/IoReactNativeJwt.swift +156 -0
  13. package/ios/IoReactNativeJwt.xcodeproj/project.pbxproj +283 -0
  14. package/lib/commonjs/algorithms.js +39 -0
  15. package/lib/commonjs/algorithms.js.map +1 -0
  16. package/lib/commonjs/hash.js +17 -0
  17. package/lib/commonjs/hash.js.map +1 -0
  18. package/lib/commonjs/index.js +194 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/jwt_claims_set.js +112 -0
  21. package/lib/commonjs/jwt_claims_set.js.map +1 -0
  22. package/lib/commonjs/produce.js +140 -0
  23. package/lib/commonjs/produce.js.map +1 -0
  24. package/lib/commonjs/sign.js +159 -0
  25. package/lib/commonjs/sign.js.map +1 -0
  26. package/lib/commonjs/types.js +2 -0
  27. package/lib/commonjs/types.js.map +1 -0
  28. package/lib/commonjs/unsecured.js +118 -0
  29. package/lib/commonjs/unsecured.js.map +1 -0
  30. package/lib/commonjs/utils/asn1.js +37 -0
  31. package/lib/commonjs/utils/asn1.js.map +1 -0
  32. package/lib/commonjs/utils/base64.js +43 -0
  33. package/lib/commonjs/utils/base64.js.map +1 -0
  34. package/lib/commonjs/utils/errors.js +214 -0
  35. package/lib/commonjs/utils/errors.js.map +1 -0
  36. package/lib/commonjs/utils/is_object.js +23 -0
  37. package/lib/commonjs/utils/is_object.js.map +1 -0
  38. package/lib/commonjs/utils/proxy.js +17 -0
  39. package/lib/commonjs/utils/proxy.js.map +1 -0
  40. package/lib/commonjs/utils/secs.js +61 -0
  41. package/lib/commonjs/utils/secs.js.map +1 -0
  42. package/lib/module/algorithms.js +29 -0
  43. package/lib/module/algorithms.js.map +1 -0
  44. package/lib/module/hash.js +11 -0
  45. package/lib/module/hash.js.map +1 -0
  46. package/lib/module/index.js +115 -0
  47. package/lib/module/index.js.map +1 -0
  48. package/lib/module/jwt_claims_set.js +103 -0
  49. package/lib/module/jwt_claims_set.js.map +1 -0
  50. package/lib/module/produce.js +131 -0
  51. package/lib/module/produce.js.map +1 -0
  52. package/lib/module/sign.js +153 -0
  53. package/lib/module/sign.js.map +1 -0
  54. package/lib/module/types.js +2 -0
  55. package/lib/module/types.js.map +1 -0
  56. package/lib/module/unsecured.js +110 -0
  57. package/lib/module/unsecured.js.map +1 -0
  58. package/lib/module/utils/asn1.js +31 -0
  59. package/lib/module/utils/asn1.js.map +1 -0
  60. package/lib/module/utils/base64.js +36 -0
  61. package/lib/module/utils/base64.js.map +1 -0
  62. package/lib/module/utils/errors.js +200 -0
  63. package/lib/module/utils/errors.js.map +1 -0
  64. package/lib/module/utils/is_object.js +17 -0
  65. package/lib/module/utils/is_object.js.map +1 -0
  66. package/lib/module/utils/proxy.js +10 -0
  67. package/lib/module/utils/proxy.js.map +1 -0
  68. package/lib/module/utils/secs.js +53 -0
  69. package/lib/module/utils/secs.js.map +1 -0
  70. package/lib/typescript/algorithms.d.ts +5 -0
  71. package/lib/typescript/algorithms.d.ts.map +1 -0
  72. package/lib/typescript/hash.d.ts +5 -0
  73. package/lib/typescript/hash.d.ts.map +1 -0
  74. package/lib/typescript/index.d.ts +93 -0
  75. package/lib/typescript/index.d.ts.map +1 -0
  76. package/lib/typescript/jwt_claims_set.d.ts +4 -0
  77. package/lib/typescript/jwt_claims_set.d.ts.map +1 -0
  78. package/lib/typescript/produce.d.ts +55 -0
  79. package/lib/typescript/produce.d.ts.map +1 -0
  80. package/lib/typescript/sign.d.ts +61 -0
  81. package/lib/typescript/sign.d.ts.map +1 -0
  82. package/lib/typescript/types.d.ts +172 -0
  83. package/lib/typescript/types.d.ts.map +1 -0
  84. package/lib/typescript/unsecured.d.ts +64 -0
  85. package/lib/typescript/unsecured.d.ts.map +1 -0
  86. package/lib/typescript/utils/asn1.d.ts +2 -0
  87. package/lib/typescript/utils/asn1.d.ts.map +1 -0
  88. package/lib/typescript/utils/base64.d.ts +4 -0
  89. package/lib/typescript/utils/base64.d.ts.map +1 -0
  90. package/lib/typescript/utils/errors.d.ts +157 -0
  91. package/lib/typescript/utils/errors.d.ts.map +1 -0
  92. package/lib/typescript/utils/is_object.d.ts +2 -0
  93. package/lib/typescript/utils/is_object.d.ts.map +1 -0
  94. package/lib/typescript/utils/proxy.d.ts +2 -0
  95. package/lib/typescript/utils/proxy.d.ts.map +1 -0
  96. package/lib/typescript/utils/secs.d.ts +4 -0
  97. package/lib/typescript/utils/secs.d.ts.map +1 -0
  98. package/package.json +170 -0
  99. package/pagopa-io-react-native-jwt.podspec +44 -0
  100. package/src/algorithms.ts +46 -0
  101. package/src/hash.ts +10 -0
  102. package/src/index.tsx +120 -0
  103. package/src/jwt_claims_set.ts +194 -0
  104. package/src/produce.ts +109 -0
  105. package/src/sign.ts +180 -0
  106. package/src/types.ts +203 -0
  107. package/src/unsecured.ts +127 -0
  108. package/src/utils/asn1.ts +36 -0
  109. package/src/utils/base64.ts +37 -0
  110. package/src/utils/errors.ts +206 -0
  111. package/src/utils/is_object.ts +20 -0
  112. package/src/utils/proxy.ts +15 -0
  113. package/src/utils/secs.ts +58 -0
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SignJWT = void 0;
7
+ var _errors = require("./utils/errors");
8
+ var _produce = require("./produce");
9
+ var _base = require("./utils/base64");
10
+ var _algorithms = require("./algorithms");
11
+ var _asn = require("./utils/asn1");
12
+ /**
13
+ * The SignJWT class is used to build and sign Compact JWS formatted JSON Web Tokens.
14
+ *
15
+ * @example Usage with a given signature
16
+ *
17
+ * ```js
18
+ * const alg = 'RS256'
19
+ * const signature = 'Axy0....'
20
+ *
21
+ * const jwt = new SignJWT({ 'urn:example:claim': true })
22
+ * .setProtectedHeader({ alg })
23
+ * .setIssuedAt()
24
+ * .setIssuer('urn:example:issuer')
25
+ * .setAudience('urn:example:audience')
26
+ * .setExpirationTime('2h')
27
+ * .sign(signature)
28
+ *
29
+ * console.log(jwt)
30
+ * ```
31
+ */
32
+ class SignJWT extends _produce.ProduceJWT {
33
+ /**
34
+ * Sets the JWS Protected Header on the SignJWT object.
35
+ *
36
+ * @param protectedHeader JWS Protected Header. Must contain an "alg" (JWS Algorithm) property.
37
+ */
38
+ setProtectedHeader(protectedHeader) {
39
+ if (protectedHeader.alg && (0, _algorithms.isAlgSupported)(protectedHeader.alg)) {
40
+ this._protectedHeader = protectedHeader;
41
+ return this;
42
+ }
43
+ throw new _errors.JOSENotSupported('Unsupported "alg" value');
44
+ }
45
+
46
+ /**
47
+ * Return a JWT without signature (`header.payload`) to sign.
48
+ *
49
+ */
50
+ toSign() {
51
+ if (!this._protectedHeader || !this._protectedHeader.alg) {
52
+ throw new _errors.JWSInvalid('Missing signature algorithm. Specify the `alg` field');
53
+ }
54
+ const protectedHeader = (0, _base.encodeBase64)(JSON.stringify(this._protectedHeader));
55
+ const payload = (0, _base.encodeBase64)(JSON.stringify(this._payload));
56
+ if (payload && protectedHeader) {
57
+ return `${protectedHeader}.${payload}`;
58
+ } else {
59
+ throw new _errors.JWSInvalid();
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Append signature to unsigned JWT.
65
+ * For an ECDSA signature it is required that this is in ASN.1/DER encoded format.
66
+ * The same format used by the TEE. Conversion to JWS is handled automatically.
67
+ *
68
+ * @param jwtWithoutSignature
69
+ * @param signature
70
+ */
71
+ static async appendSignature(jwtWithoutSignature, signature) {
72
+ if (typeof jwtWithoutSignature !== 'string' || typeof signature !== 'string') {
73
+ throw new _errors.JWTInvalid('JWS must be a string');
74
+ }
75
+ if (signature === '') throw new _errors.JWSInvalid('Invalid signature');
76
+ const jwtDecoded = SignJWT.decodeJwtWithoutSignature(jwtWithoutSignature);
77
+ const alg = jwtDecoded.header.alg;
78
+ try {
79
+ const encodedJws = await (0, _asn.derToJose)(signature, alg);
80
+ return `${jwtWithoutSignature}.${encodedJws}`;
81
+ } catch {
82
+ const encodedJws = (0, _base.removePadding)(signature);
83
+ return `${jwtWithoutSignature}.${encodedJws}`;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Decodes a JWT without signature
89
+ *
90
+ * @param jwtWithoutSignature JWT to sign that needs to be decoded.
91
+ */
92
+ static decodeJwtWithoutSignature(jwtWithoutSignature) {
93
+ if (typeof jwtWithoutSignature !== 'string') {
94
+ throw new _errors.JWTInvalid('JWT must be a string');
95
+ }
96
+ const {
97
+ 0: encodedHeader,
98
+ 1: encodedPayload,
99
+ length
100
+ } = jwtWithoutSignature.split('.');
101
+ let header;
102
+ try {
103
+ let decoded = (0, _base.decodeBase64)(encodedHeader);
104
+ header = JSON.parse(decoded);
105
+ if (!header.alg || !(0, _algorithms.isAlgSupported)(header.alg)) {
106
+ throw new _errors.JOSENotSupported('Unsupported "alg" value');
107
+ }
108
+ } catch {
109
+ throw new _errors.JWTInvalid('Unable to decode JWT header');
110
+ }
111
+ if (length !== 2 || encodedPayload === '') {
112
+ throw new _errors.JWTInvalid('Invalid JWT to sign');
113
+ }
114
+ let decodedPayload = (0, _base.decodeBase64)(encodedPayload);
115
+ const payload = JSON.parse(decodedPayload);
116
+ return {
117
+ payload,
118
+ header
119
+ };
120
+ }
121
+
122
+ /**
123
+ * Decodes a JWT without signature
124
+ *
125
+ * @param jwtWithoutSignature JWT to sign that needs to be decoded.
126
+ */
127
+ static decode(jwt) {
128
+ if (typeof jwt !== 'string') {
129
+ throw new _errors.JWTInvalid('JWT must be a string');
130
+ }
131
+ const {
132
+ 0: encodedHeader,
133
+ 1: encodedPayload,
134
+ 2: signature,
135
+ length
136
+ } = jwt.split('.');
137
+ let protectedHeader;
138
+ try {
139
+ let decoded = (0, _base.decodeBase64)(encodedHeader);
140
+ protectedHeader = JSON.parse(decoded);
141
+ if (!protectedHeader.alg || !(0, _algorithms.isAlgSupported)(protectedHeader.alg)) {
142
+ throw new _errors.JOSENotSupported('Unsupported "alg" value');
143
+ }
144
+ } catch {
145
+ throw new _errors.JWTInvalid('Unable to decode JWT header');
146
+ }
147
+ if (length !== 3 || encodedPayload === '' || signature === '') {
148
+ throw new _errors.JWTInvalid('Invalid JWT');
149
+ }
150
+ let decodedPayload = (0, _base.decodeBase64)(encodedPayload);
151
+ const payload = JSON.parse(decodedPayload);
152
+ return {
153
+ payload,
154
+ protectedHeader
155
+ };
156
+ }
157
+ }
158
+ exports.SignJWT = SignJWT;
159
+ //# sourceMappingURL=sign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_produce","_base","_algorithms","_asn","SignJWT","ProduceJWT","setProtectedHeader","protectedHeader","alg","isAlgSupported","_protectedHeader","JOSENotSupported","toSign","JWSInvalid","encodeBase64","JSON","stringify","payload","_payload","appendSignature","jwtWithoutSignature","signature","JWTInvalid","jwtDecoded","decodeJwtWithoutSignature","header","encodedJws","derToJose","removePadding","encodedHeader","encodedPayload","length","split","decoded","decodeBase64","parse","decodedPayload","decode","jwt","exports"],"sourceRoot":"../../src","sources":["sign.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAMA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,IAAA,GAAAJ,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA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types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":""}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnsecuredJWT = void 0;
7
+ var _errors = require("./utils/errors");
8
+ var _jwt_claims_set = _interopRequireDefault(require("./jwt_claims_set"));
9
+ var _produce = require("./produce");
10
+ var _base = require("./utils/base64");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /**
13
+ * The UnsecuredJWT class is a utility for dealing with `{ "alg": "none" }` Unsecured JWTs.
14
+ *
15
+ * @example Encoding
16
+ *
17
+ * ```js
18
+ * const unsecuredJwt = new UnsecuredJWT({ 'urn:example:claim': true })
19
+ * .setIssuedAt()
20
+ * .setIssuer('urn:example:issuer')
21
+ * .setAudience('urn:example:audience')
22
+ * .setExpirationTime('2h')
23
+ * .encode()
24
+ *
25
+ * console.log(unsecuredJwt)
26
+ * ```
27
+ *
28
+ * @example Decoding
29
+ *
30
+ * ```js
31
+ * const payload = UnsecuredJWT.decode(jwt, {
32
+ * issuer: 'urn:example:issuer',
33
+ * audience: 'urn:example:audience',
34
+ * })
35
+ *
36
+ * console.log(payload)
37
+ * ```
38
+ * * @example JWT content ToSign
39
+ *
40
+ * ```js
41
+ * const jwtToSign = new UnsecuredJWT({ 'urn:example:claim': true })
42
+ * .setIssuedAt()
43
+ * .setIssuer('urn:example:issuer')
44
+ * .setAudience('urn:example:audience')
45
+ * .setExpirationTime('2h')
46
+ * .toSign()
47
+ *
48
+ * console.log(jwtToSign)
49
+ * ```
50
+ */
51
+ class UnsecuredJWT extends _produce.ProduceJWT {
52
+ /** Encodes the Unsecured JWT. */
53
+ encode() {
54
+ const header = (0, _base.encodeBase64)(JSON.stringify({
55
+ alg: 'none'
56
+ }));
57
+ const payload = (0, _base.encodeBase64)(JSON.stringify(this._payload));
58
+ return `${header}.${payload}.`;
59
+ }
60
+
61
+ /**
62
+ * Decodes an unsecured JWT.
63
+ *
64
+ * @param jwt Unsecured JWT to decode the payload of.
65
+ * @param options JWT Claims Set validation options.
66
+ */
67
+ static decode(jwt, options) {
68
+ if (typeof jwt !== 'string') {
69
+ throw new _errors.JWTInvalid('Unsecured JWT must be a string');
70
+ }
71
+ const {
72
+ 0: encodedHeader,
73
+ 1: encodedPayload,
74
+ 2: signature,
75
+ length
76
+ } = jwt.split('.');
77
+ if (length !== 3 || signature !== '' || !encodedPayload) {
78
+ throw new _errors.JWTInvalid('Invalid Unsecured JWT');
79
+ }
80
+ let header;
81
+ try {
82
+ let decoded = (0, _base.decodeBase64)(encodedHeader);
83
+ header = JSON.parse(decoded);
84
+ if (header.alg !== 'none') throw new Error();
85
+ } catch {
86
+ throw new _errors.JWTInvalid('Invalid Unsecured JWT');
87
+ }
88
+ let payload = UnsecuredJWT.decodePayload(encodedPayload, options);
89
+ return {
90
+ payload,
91
+ header
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Decodes an unsecured JWT payload.
97
+ *
98
+ * @param jwt Unsecured JWT payload to decode.
99
+ * @param options JWT Claims Set validation options.
100
+ */
101
+ static decodePayload(jwt, options) {
102
+ if (typeof jwt !== 'string') {
103
+ throw new _errors.JWTInvalid('Unsecured JWT must be a string');
104
+ }
105
+ const {
106
+ 0: encodedPayload,
107
+ length
108
+ } = jwt.split('.');
109
+ if (length !== 1 || encodedPayload === '') {
110
+ throw new _errors.JWTInvalid('Invalid Unsecured JWT');
111
+ }
112
+ let decodedPayload = (0, _base.decodeBase64)(encodedPayload);
113
+ const payload = (0, _jwt_claims_set.default)({}, JSON.parse(decodedPayload), options);
114
+ return payload;
115
+ }
116
+ }
117
+ exports.UnsecuredJWT = UnsecuredJWT;
118
+ //# sourceMappingURL=unsecured.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_jwt_claims_set","_interopRequireDefault","_produce","_base","obj","__esModule","default","UnsecuredJWT","ProduceJWT","encode","header","encodeBase64","JSON","stringify","alg","payload","_payload","decode","jwt","options","JWTInvalid","encodedHeader","encodedPayload","signature","length","split","decoded","decodeBase64","parse","Error","decodePayload","decodedPayload","jwtPayload","exports"],"sourceRoot":"../../src","sources":["unsecured.ts"],"mappings":";;;;;;AAMA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAA4D,SAAAE,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAO5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,YAAY,SAASC,mBAAU,CAAC;EAC3C;EACAC,MAAMA,CAAA,EAAW;IACf,MAAMC,MAAM,GAAG,IAAAC,kBAAY,EAACC,IAAI,CAACC,SAAS,CAAC;MAAEC,GAAG,EAAE;IAAO,CAAC,CAAC,CAAC;IAC5D,MAAMC,OAAO,GAAG,IAAAJ,kBAAY,EAACC,IAAI,CAACC,SAAS,CAAC,IAAI,CAACG,QAAQ,CAAC,CAAC;IAE3D,OAAQ,GAAEN,MAAO,IAAGK,OAAQ,GAAE;EAChC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOE,MAAMA,CACXC,GAAW,EACXC,OAAqC,EACpB;IACjB,IAAI,OAAOD,GAAG,KAAK,QAAQ,EAAE;MAC3B,MAAM,IAAIE,kBAAU,CAAC,gCAAgC,CAAC;IACxD;IACA,MAAM;MACJ,CAAC,EAAEC,aAAa;MAChB,CAAC,EAAEC,cAAc;MACjB,CAAC,EAAEC,SAAS;MACZ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AAO;EAChB;AACF;AAACkB,OAAA,CAAA1B,YAAA,GAAAA,YAAA"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.derToJose = void 0;
7
+ var _algorithms = require("../algorithms");
8
+ var _proxy = require("./proxy");
9
+ var _base = require("./base64");
10
+ var _errors = require("./errors");
11
+ /*
12
+ * Transcodes the JCA ASN.1/DER-encoded signature into the concatenated R + S format expected by ECDSA JWS.
13
+ * Returns a base64 url encoded String.
14
+ *
15
+ * @example Usage with an ASN.1/DER-encoded
16
+ *
17
+ * ```js
18
+ * const asn1Signature = 'Yw1xTT....'
19
+ * const plainSignature = await derToJose(asn1Signature, "ECDSA256")
20
+ *
21
+ * ```
22
+ *
23
+ * @param asn1Signature ASN.1/DER-encoded signature
24
+ * @param alg Algorithm used to sign
25
+ */
26
+ const derToJose = async (asn1Signature, alg) => {
27
+ const kty = (0, _algorithms.getKtyFromAlg)(alg);
28
+ if (kty === 'EC') {
29
+ const unpackedJws = await _proxy.IoReactNativeJwt.unpackBerEncodedASN1(asn1Signature, (0, _algorithms.getCoordinateOctetLength)(alg));
30
+ const encodedJws = (0, _base.removePadding)(unpackedJws);
31
+ return encodedJws;
32
+ } else {
33
+ throw new _errors.JOSENotSupported('Unsupported "alg" value');
34
+ }
35
+ };
36
+ exports.derToJose = derToJose;
37
+ //# sourceMappingURL=asn1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_algorithms","require","_proxy","_base","_errors","derToJose","asn1Signature","alg","kty","getKtyFromAlg","unpackedJws","IoReactNativeJwt","unpackBerEncodedASN1","getCoordinateOctetLength","encodedJws","removePadding","JOSENotSupported","exports"],"sourceRoot":"../../../src","sources":["utils/asn1.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,SAAS,GAAG,MAAAA,CACvBC,aAAqB,EACrBC,GAAW,KACS;EACpB,MAAMC,GAAG,GAAG,IAAAC,yBAAa,EAACF,GAAG,CAAC;EAC9B,IAAIC,GAAG,KAAK,IAAI,EAAE;IAChB,MAAME,WAAW,GAAG,MAAMC,uBAAgB,CAACC,oBAAoB,CAC7DN,aAAa,EACb,IAAAO,oCAAwB,EAACN,GAAG,CAC9B,CAAC;IACD,MAAMO,UAAU,GAAG,IAAAC,mBAAa,EAACL,WAAW,CAAC;IAC7C,OAAOI,UAAU;EACnB,CAAC,MAAM;IACL,MAAM,IAAIE,wBAAgB,CAAC,yBAAyB,CAAC;EACvD;AACF,CAAC;AAACC,OAAA,CAAAZ,SAAA,GAAAA,SAAA"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.decodeBase64 = decodeBase64;
7
+ exports.encodeBase64 = encodeBase64;
8
+ exports.removePadding = removePadding;
9
+ var _abab = require("abab");
10
+ var _errors = require("./errors");
11
+ /*
12
+ * In Base64 encoding, the length of an output-encoded String
13
+ * must be a multiple of four. If necessary, the encoder adds
14
+ * one or two padding characters (=) at the end of the output
15
+ * as needed in order to meet this requirement.
16
+ *
17
+ * JWTs make use of the base64url encoding as defined in RFC 4648.
18
+ * As allowed by Section 3.2 of the RFC, this specification mandates
19
+ * that base64url encoding when used with JWTs MUST NOT use padding.
20
+ * The reason for this restriction is that the padding character
21
+ * ('=') is not URL safe.
22
+ */
23
+ function encodeBase64(value) {
24
+ let encoded = (0, _abab.btoa)(value);
25
+ if (encoded) {
26
+ return removePadding(encoded);
27
+ } else {
28
+ throw new _errors.JOSEError('Unable to encode string to base64');
29
+ }
30
+ }
31
+ function decodeBase64(value) {
32
+ let decoded = (0, _abab.atob)(value);
33
+ if (decoded) {
34
+ return decoded;
35
+ } else {
36
+ throw new _errors.JOSEError('Unable to decode base64 string');
37
+ }
38
+ }
39
+ function removePadding(encoded) {
40
+ // eslint-disable-next-line no-div-regex
41
+ return encoded.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
42
+ }
43
+ //# sourceMappingURL=base64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_abab","require","_errors","encodeBase64","value","encoded","btoa","removePadding","JOSEError","decodeBase64","decoded","atob","replace"],"sourceRoot":"../../../src","sources":["utils/base64.ts"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,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,IAAIC,OAAO,GAAG,IAAAC,UAAI,EAACF,KAAK,CAAC;EACzB,IAAIC,OAAO,EAAE;IACX,OAAOE,aAAa,CAACF,OAAO,CAAC;EAC/B,CAAC,MAAM;IACL,MAAM,IAAIG,iBAAS,CAAC,mCAAmC,CAAC;EAC1D;AACF;AAEO,SAASC,YAAYA,CAACL,KAAa,EAAU;EAClD,IAAIM,OAAO,GAAG,IAAAC,UAAI,EAACP,KAAK,CAAC;EACzB,IAAIM,OAAO,EAAE;IACX,OAAOA,OAAO;EAChB,CAAC,MAAM;IACL,MAAM,IAAIF,iBAAS,CAAC,gCAAgC,CAAC;EACvD;AACF;AAEO,SAASD,aAAaA,CAACF,OAAe,EAAU;EACrD;EACA,OAAOA,OAAO,CAACO,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AAC1E"}
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JWTInvalid = exports.JWTExpired = exports.JWTClaimValidationFailed = exports.JWSSignatureVerificationFailed = exports.JWSInvalid = exports.JOSENotSupported = exports.JOSEError = exports.JOSEAlgNotAllowed = void 0;
7
+ /**
8
+ * A generic Error that all other JOSE specific Error subclasses extend.
9
+ *
10
+ * @example Checking thrown error is a JOSE one
11
+ *
12
+ * ```js
13
+ * if (err instanceof errors.JOSEError) {
14
+ * // ...
15
+ * }
16
+ * ```
17
+ */
18
+ class JOSEError extends Error {
19
+ /** A unique error code for the particular error subclass. */
20
+ static get code() {
21
+ return 'ERR_JOSE_GENERIC';
22
+ }
23
+
24
+ /** A unique error code for the particular error subclass. */
25
+ code = 'ERR_JOSE_GENERIC';
26
+ constructor(message) {
27
+ var _Error$captureStackTr;
28
+ super(message);
29
+ this.name = this.constructor.name;
30
+ // @ts-ignore
31
+ (_Error$captureStackTr = Error.captureStackTrace) === null || _Error$captureStackTr === void 0 ? void 0 : _Error$captureStackTr.call(Error, this, this.constructor);
32
+ }
33
+ }
34
+ exports.JOSEError = JOSEError;
35
+ class JWTClaimValidationFailed extends JOSEError {
36
+ static get code() {
37
+ return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
38
+ }
39
+ code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
40
+
41
+ /** The Claim for which the validation failed. */
42
+
43
+ /** Reason code for the validation failure. */
44
+
45
+ constructor(message) {
46
+ let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unspecified';
47
+ let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unspecified';
48
+ super(message);
49
+ this.claim = claim;
50
+ this.reason = reason;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * An error subclass thrown when a JWT is expired.
56
+ *
57
+ * @example Checking thrown error is this one using a stable error code
58
+ *
59
+ * ```js
60
+ * if (err.code === 'ERR_JWT_EXPIRED') {
61
+ * // ...
62
+ * }
63
+ * ```
64
+ *
65
+ * @example Checking thrown error is this one using `instanceof`
66
+ *
67
+ * ```js
68
+ * if (err instanceof errors.JWTExpired) {
69
+ * // ...
70
+ * }
71
+ * ```
72
+ */
73
+ exports.JWTClaimValidationFailed = JWTClaimValidationFailed;
74
+ class JWTExpired extends JOSEError {
75
+ static get code() {
76
+ return 'ERR_JWT_EXPIRED';
77
+ }
78
+ code = 'ERR_JWT_EXPIRED';
79
+
80
+ /** The Claim for which the validation failed. */
81
+
82
+ /** Reason code for the validation failure. */
83
+
84
+ constructor(message) {
85
+ let claim = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unspecified';
86
+ let reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'unspecified';
87
+ super(message);
88
+ this.claim = claim;
89
+ this.reason = reason;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * An error subclass thrown when a JOSE Algorithm is not allowed per developer preference.
95
+ *
96
+ * @example Checking thrown error is this one using a stable error code
97
+ *
98
+ * ```js
99
+ * if (err.code === 'ERR_JOSE_ALG_NOT_ALLOWED') {
100
+ * // ...
101
+ * }
102
+ * ```
103
+ *
104
+ * @example Checking thrown error is this one using `instanceof`
105
+ *
106
+ * ```js
107
+ * if (err instanceof errors.JOSEAlgNotAllowed) {
108
+ * // ...
109
+ * }
110
+ * ```
111
+ */
112
+ exports.JWTExpired = JWTExpired;
113
+ class JOSEAlgNotAllowed extends JOSEError {
114
+ static get code() {
115
+ return 'ERR_JOSE_ALG_NOT_ALLOWED';
116
+ }
117
+ code = 'ERR_JOSE_ALG_NOT_ALLOWED';
118
+ }
119
+
120
+ /**
121
+ * An error subclass thrown when a particular feature or algorithm is not supported by this
122
+ * implementation or JOSE in general.
123
+ *
124
+ * @example Checking thrown error is this one using a stable error code
125
+ *
126
+ * ```js
127
+ * if (err.code === 'ERR_JOSE_NOT_SUPPORTED') {
128
+ * // ...
129
+ * }
130
+ * ```
131
+ *
132
+ * @example Checking thrown error is this one using `instanceof`
133
+ *
134
+ * ```js
135
+ * if (err instanceof errors.JOSENotSupported) {
136
+ * // ...
137
+ * }
138
+ * ```
139
+ */
140
+ exports.JOSEAlgNotAllowed = JOSEAlgNotAllowed;
141
+ class JOSENotSupported extends JOSEError {
142
+ static get code() {
143
+ return 'ERR_JOSE_NOT_SUPPORTED';
144
+ }
145
+ code = 'ERR_JOSE_NOT_SUPPORTED';
146
+ }
147
+
148
+ /**
149
+ * An error subclass thrown when a JWT is invalid.
150
+ *
151
+ * @example Checking thrown error is this one using a stable error code
152
+ *
153
+ * ```js
154
+ * if (err.code === 'ERR_JWT_INVALID') {
155
+ * // ...
156
+ * }
157
+ * ```
158
+ *
159
+ * @example Checking thrown error is this one using `instanceof`
160
+ *
161
+ * ```js
162
+ * if (err instanceof errors.JWTInvalid) {
163
+ * // ...
164
+ * }
165
+ * ```
166
+ */
167
+ exports.JOSENotSupported = JOSENotSupported;
168
+ class JWTInvalid extends JOSEError {
169
+ static get code() {
170
+ return 'ERR_JWT_INVALID';
171
+ }
172
+ code = 'ERR_JWT_INVALID';
173
+ }
174
+
175
+ /**
176
+ * An error subclass thrown when a JWT signature (JWS) is invalid.
177
+ */
178
+ exports.JWTInvalid = JWTInvalid;
179
+ class JWSInvalid extends JOSEError {
180
+ static get code() {
181
+ return 'ERR_JWS_INVALID';
182
+ }
183
+ code = 'ERR_JWS_INVALID';
184
+ }
185
+
186
+ /**
187
+ * An error subclass thrown when JWS signature verification fails.
188
+ *
189
+ * @example Checking thrown error is this one using a stable error code
190
+ *
191
+ * ```js
192
+ * if (err.code === 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED') {
193
+ * // ...
194
+ * }
195
+ * ```
196
+ *
197
+ * @example Checking thrown error is this one using `instanceof`
198
+ *
199
+ * ```js
200
+ * if (err instanceof errors.JWSSignatureVerificationFailed) {
201
+ * // ...
202
+ * }
203
+ * ```
204
+ */
205
+ exports.JWSInvalid = JWSInvalid;
206
+ class JWSSignatureVerificationFailed extends JOSEError {
207
+ static get code() {
208
+ return 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
209
+ }
210
+ code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
211
+ message = 'signature verification failed';
212
+ }
213
+ exports.JWSSignatureVerificationFailed = JWSSignatureVerificationFailed;
214
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JOSEError","Error","code","constructor","message","_Error$captureStackTr","name","captureStackTrace","call","exports","JWTClaimValidationFailed","claim","arguments","length","undefined","reason","JWTExpired","JOSEAlgNotAllowed","JOSENotSupported","JWTInvalid","JWSInvalid","JWSSignatureVerificationFailed"],"sourceRoot":"../../../src","sources":["utils/errors.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,SAASC,KAAK,CAAC;EACnC;EACA,WAAWC,IAAIA,CAAA,EAAW;IACxB,OAAO,kBAAkB;EAC3B;;EAEA;EACAA,IAAI,GAAW,kBAAkB;EAEjCC,WAAWA,CAACC,OAAgB,EAAE;IAAA,IAAAC,qBAAA;IAC5B,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,IAAI,CAACH,WAAW,CAACG,IAAI;IACjC;IACA,CAAAD,qBAAA,GAAAJ,KAAK,CAACM,iBAAiB,cAAAF,qBAAA,uBAAvBA,qBAAA,CAAAG,IAAA,CAAAP,KAAK,EAAqB,IAAI,EAAE,IAAI,CAACE,WAAW,CAAC;EACnD;AACF;AAACM,OAAA,CAAAT,SAAA,GAAAA,SAAA;AACM,MAAMU,wBAAwB,SAASV,SAAS,CAAC;EACtD,WAAWE,IAAIA,CAAA,EAAsC;IACnD,OAAO,iCAAiC;EAC1C;EAEAA,IAAI,GAAG,iCAAiC;;EAExC;;EAGA;;EAGAC,WAAWA,CAACC,OAAe,EAAiD;IAAA,IAA/CO,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAAA,IAAEG,MAAM,GAAAH,SAAA,CAAAC,MAAA,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,SAASlB,SAAS,CAAC;EAC9C,WAAWE,IAAIA,CAAA,EAA6B;IAC1C,OAAO,wBAAwB;EACjC;EAEAA,IAAI,GAAG,wBAAwB;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlBAO,OAAA,CAAAS,gBAAA,GAAAA,gBAAA;AAmBO,MAAMC,UAAU,SAASnB,SAAS,CAAC;EACxC,WAAWE,IAAIA,CAAA,EAAsB;IACnC,OAAO,iBAAiB;EAC1B;EAEAA,IAAI,GAAG,iBAAiB;AAC1B;;AAEA;AACA;AACA;AAFAO,OAAA,CAAAU,UAAA,GAAAA,UAAA;AAGO,MAAMC,UAAU,SAASpB,SAAS,CAAC;EACxC,WAAWE,IAAIA,CAAA,EAAsB;IACnC,OAAO,iBAAiB;EAC1B;EACAA,IAAI,GAAG,iBAAiB;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlBAO,OAAA,CAAAW,UAAA,GAAAA,UAAA;AAmBO,MAAMC,8BAA8B,SAASrB,SAAS,CAAC;EAC5D,WAAWE,IAAIA,CAAA,EAA4C;IACzD,OAAO,uCAAuC;EAChD;EAEAA,IAAI,GAAG,uCAAuC;EAE9CE,OAAO,GAAG,+BAA+B;AAC3C;AAACK,OAAA,CAAAY,8BAAA,GAAAA,8BAAA"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isObject;
7
+ function isObjectLike(value) {
8
+ return typeof value === 'object' && value !== null;
9
+ }
10
+ function isObject(input) {
11
+ if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {
12
+ return false;
13
+ }
14
+ if (Object.getPrototypeOf(input) === null) {
15
+ return true;
16
+ }
17
+ let proto = input;
18
+ while (Object.getPrototypeOf(proto) !== null) {
19
+ proto = Object.getPrototypeOf(proto);
20
+ }
21
+ return Object.getPrototypeOf(input) === proto;
22
+ }
23
+ //# sourceMappingURL=is_object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isObjectLike","value","isObject","input","Object","prototype","toString","call","getPrototypeOf","proto"],"sourceRoot":"../../../src","sources":["utils/is_object.ts"],"mappings":";;;;;;AAAA,SAASA,YAAYA,CAACC,KAAc,EAAE;EACpC,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI;AACpD;AAEe,SAASC,QAAQA,CAAaC,KAAc,EAAc;EACvE,IACE,CAACH,YAAY,CAACG,KAAK,CAAC,IACpBC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACJ,KAAK,CAAC,KAAK,iBAAiB,EAC3D;IACA,OAAO,KAAK;EACd;EACA,IAAIC,MAAM,CAACI,cAAc,CAACL,KAAK,CAAC,KAAK,IAAI,EAAE;IACzC,OAAO,IAAI;EACb;EACA,IAAIM,KAAK,GAAGN,KAAK;EACjB,OAAOC,MAAM,CAACI,cAAc,CAACC,KAAK,CAAC,KAAK,IAAI,EAAE;IAC5CA,KAAK,GAAGL,MAAM,CAACI,cAAc,CAACC,KAAK,CAAC;EACtC;EACA,OAAOL,MAAM,CAACI,cAAc,CAACL,KAAK,CAAC,KAAKM,KAAK;AAC/C"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.IoReactNativeJwt = void 0;
7
+ var _reactNative = require("react-native");
8
+ const IoReactNativeJwt = _reactNative.NativeModules.IoReactNativeJwt ? _reactNative.NativeModules.IoReactNativeJwt : new Proxy({
9
+ //this is a fake implementation to allow local deviceless testing
10
+ unpackBerEncodedASN1: (a, _b) => a
11
+ }, {
12
+ get: function (target, prop) {
13
+ return Reflect.get(target, prop);
14
+ }
15
+ });
16
+ exports.IoReactNativeJwt = IoReactNativeJwt;
17
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","IoReactNativeJwt","NativeModules","Proxy","unpackBerEncodedASN1","a","_b","get","target","prop","Reflect","exports"],"sourceRoot":"../../../src","sources":["utils/proxy.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,gBAAgB,GAAGC,0BAAa,CAACD,gBAAgB,GAC1DC,0BAAa,CAACD,gBAAgB,GAC9B,IAAIE,KAAK,CACP;EACE;EACAC,oBAAoB,EAAEA,CAACC,CAAS,EAAEC,EAAU,KAAKD;AACnD,CAAC,EACD;EACEE,GAAG,EAAE,SAAAA,CAAUC,MAAM,EAAEC,IAAI,EAAE;IAC3B,OAAOC,OAAO,CAACH,GAAG,CAACC,MAAM,EAAEC,IAAI,CAAC;EAClC;AACF,CACF,CAAC;AAACE,OAAA,CAAAV,gBAAA,GAAAA,gBAAA"}