diff --git a/docs/interfaces/types.JWEHeaderParameters.md b/docs/interfaces/types.JWEHeaderParameters.md index 9008c53..3b82996 100644 --- a/docs/interfaces/types.JWEHeaderParameters.md +++ b/docs/interfaces/types.JWEHeaderParameters.md @@ -53,7 +53,7 @@ ___ ### enc -• `Optional` **enc**: ``"A256CBC-HS512"`` \| ``"A128CBC-HS256"`` +• `Optional` **enc**: ``"A256CBC-HS512"`` \| ``"A128CBC-HS256"``| ``"A256GCM"`` JWE "enc" (Encryption Algorithm) Header Parameter. diff --git a/example/.ruby-version b/example/.ruby-version new file mode 100644 index 0000000..06eda28 --- /dev/null +++ b/example/.ruby-version @@ -0,0 +1 @@ +3.2.3 \ No newline at end of file diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f9ac0fc..f943e91 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -7,7 +7,7 @@ PODS: - hermes-engine (0.76.1): - hermes-engine/Pre-built (= 0.76.1) - hermes-engine/Pre-built (0.76.1) - - JOSESwift (2.4.0) + - JOSESwift (3.0.0) - pagopa-io-react-native-crypto (0.2.3): - RCT-Folly - RCTRequired @@ -15,11 +15,11 @@ PODS: - React-Codegen - React-Core - ReactCommon/turbomodule/core - - pagopa-io-react-native-jwt (1.2.0): + - pagopa-io-react-native-jwt (2.1.0): - DoubleConversion - glog - hermes-engine - - JOSESwift (~> 2.3) + - JOSESwift (~> 3.0) - RCT-Folly (= 2024.01.01.00) - RCTRequired - RCTTypeSafety @@ -1758,9 +1758,9 @@ SPEC CHECKSUMS: fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 46f1ffbf0297f4298862068dd4c274d4ac17a1fd - JOSESwift: 7ff178bb9173ff42c6e990929a9f2fa702a34f69 + JOSESwift: 7784b1b844194d0f534eb6ac4fba5af683bccc79 pagopa-io-react-native-crypto: 4f58db16d6100eb26155948bd7517e5e5f6053f4 - pagopa-io-react-native-jwt: f7d3312ef152b8c045be6ddc0b2afe2e5b1e8fd8 + pagopa-io-react-native-jwt: 504efa2b740fc5f143b9b08c19be5532dfe52d31 RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648 RCTDeprecation: fde92935b3caa6cb65cbff9fbb7d3a9867ffb259 RCTRequired: 75c6cee42d21c1530a6f204ba32ff57335d19007 @@ -1819,7 +1819,7 @@ SPEC CHECKSUMS: ReactCodegen: 865bafc5c17ec2181620ced1a32c39c38ab2951d ReactCommon: 422e364463f33e336fc4db196aeb50fd801d90d6 SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 - Yoga: 157bed1c62656587df4639d4dc29714898f8fb10 + Yoga: db69236006b8b1c6d55ab453390c882306cbf219 PODFILE CHECKSUM: a2c9d49bbf8a792d10e8a2f8dfebd03cf31e351c diff --git a/example/src/App.tsx b/example/src/App.tsx index 28578b8..e0448d9 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -46,6 +46,16 @@ export default function App() { n: 'vpR83qn-xSu5asxFeKjl6rAMNNxze2R7Ut_oDTw2ERoAwRuIrrAceH_JU0bUiPD9Rwjo1000W7yN1T_w8N2cIh2uk3qll-CT9tUO1rifER7BsLbNHHpPDKYxuDZknLp7Ml-OMlb75i9WvHgRVqXVrIepfS-BM30u1eoxNygetWz_X-qkRv-5JXyGtL54Tc0x8oARsD-cMM6_rhgBJsx494cvwV5hw80j260WVtI8at727ZpXL1SpHVTI3R2m8g-xDkrRrlW8GbRbZ1WgJDVBJH5TAFGxEAd-Fva7ig2XC_zxrNpAupLDvwShIeIVpfmqkLsHlWGbIFU_v9bvgNmvHQ', }; + const ecEncJwk = { + kty: 'EC', + use: 'enc', + crv: 'P-256', + kid: 'ebedaab1-4df4-44a7-8588-7dcf07434a6d', + x: 'IrxU7LHlxBligUjnQnra-Lfx2gKGGMDgZwQQE7RszPo', + y: 'yRBrbX_0iMlsrDKEh5g8xfGgadBr0VnVQQWk4SGq71Y', + alg: 'ECDH-ES', + }; + const generateAndSign = async () => { loading(); const randomKeyTag = Math.random().toString(36).substr(2, 5); @@ -106,7 +116,7 @@ export default function App() { .catch(showError); }; - const encryptPlaintext = (plaintext: String, encKey: JWK) => { + const encryptPlaintextRsa = (plaintext: String, encKey: JWK) => { loading(); const jwe = new EncryptJwe(plaintext, { alg: 'RSA-OAEP-256', @@ -115,6 +125,19 @@ export default function App() { jwe.then(setResult).catch(showError); }; + const encryptPlaintextEcdh = (plaintext: String, encKey: JWK) => { + loading(); + const jwe = new EncryptJwe(plaintext, { + alg: 'ECDH-ES', + enc: 'A256GCM', + }).encrypt(encKey); + jwe.then(setResult).catch(showError); + }; + + React.useEffect(() => { + console.log(result); + }, [result]); + const verifyWithJwks = () => { loading(); const metadataUrl = @@ -180,8 +203,20 @@ export default function App() { } />