pixel-react 1.15.81 → 1.15.82

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.
@@ -1 +1 @@
1
- export declare function getEncryptedData(data: string, base64PublicKey: string): Promise<string>;
1
+ export declare function getEncryptedData(data: string, base64PublicKey: string, requestProtocol?: string): Promise<string>;
@@ -1,18 +1,30 @@
1
- export async function getEncryptedData(data, base64PublicKey) {
2
- // Decode the base64-encoded public key
3
- const keyBytes = Uint8Array.from(atob(base64PublicKey), c => c.charCodeAt(0));
4
- // Import the public key in SPKI format
5
- const publicKey = await crypto.subtle.importKey('spki', keyBytes, {
6
- name: 'RSA-OAEP',
7
- hash: 'SHA-256',
8
- }, false, ['encrypt']);
9
- // Convert data to Uint8Array
10
- const encodedData = new TextEncoder().encode(data);
11
- // Encrypt the data using RSA-OAEP
12
- const encryptedData = await crypto.subtle.encrypt({
13
- name: 'RSA-OAEP',
14
- }, publicKey, encodedData);
15
- // Convert encrypted data to base64
16
- return btoa(String.fromCharCode(...new Uint8Array(encryptedData)));
1
+ import JSEncrypt from 'jsencrypt';
2
+ export async function getEncryptedData(data, base64PublicKey, requestProtocol = 'https') {
3
+ if (requestProtocol === 'http') {
4
+ const encrypt = new JSEncrypt();
5
+ encrypt.setPublicKey(base64PublicKey);
6
+ const enData = encrypt.encrypt(data);
7
+ if (!enData) {
8
+ throw new Error('JSEncrypt failed: Encryption returned false (check key or data length).');
9
+ }
10
+ return enData;
11
+ }
12
+ else {
13
+ // Decode the base64-encoded public key
14
+ const keyBytes = Uint8Array.from(atob(base64PublicKey), (c) => c.charCodeAt(0));
15
+ // Import the public key in SPKI format
16
+ const publicKey = await crypto.subtle.importKey('spki', keyBytes, {
17
+ name: 'RSA-OAEP',
18
+ hash: 'SHA-256',
19
+ }, false, ['encrypt']);
20
+ // Convert data to Uint8Array
21
+ const encodedData = new TextEncoder().encode(data);
22
+ // Encrypt the data using RSA-OAEP
23
+ const encryptedData = await crypto.subtle.encrypt({
24
+ name: 'RSA-OAEP',
25
+ }, publicKey, encodedData);
26
+ // Convert encrypted data to base64
27
+ return btoa(String.fromCharCode(...new Uint8Array(encryptedData)));
28
+ }
17
29
  }
18
30
  //# sourceMappingURL=getEncryptedData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEncryptedData.js","sourceRoot":"","sources":["../../../src/utils/getEncryptedData/getEncryptedData.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAY,EAAE,eAAuB;IAC1E,uCAAuC;IACvC,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9E,uCAAuC;IACvC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAC7C,MAAM,EACN,QAAQ,EACR;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;KAChB,EACD,KAAK,EACL,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,6BAA6B;IAC7B,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEnD,kCAAkC;IAClC,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,CAC/C;QACE,IAAI,EAAE,UAAU;KACjB,EACD,SAAS,EACT,WAAW,CACZ,CAAC;IAEF,mCAAmC;IACnC,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC"}
1
+ {"version":3,"file":"getEncryptedData.js","sourceRoot":"","sources":["../../../src/utils/getEncryptedData/getEncryptedData.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,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  "description": "Great for pixel-perfect, design-focused components in React",
4
- "version": "1.15.81",
4
+ "version": "1.15.82",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
7
7
  "types": "lib/index.d.ts",