@avieldr/react-native-rsa 1.0.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.
- package/LICENSE +20 -0
- package/README.md +453 -0
- package/Rsa.podspec +23 -0
- package/android/build.gradle +69 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/rsa/RsaModule.kt +129 -0
- package/android/src/main/java/com/rsa/RsaPackage.kt +33 -0
- package/android/src/main/java/com/rsa/core/ASN1Utils.kt +201 -0
- package/android/src/main/java/com/rsa/core/Algorithms.kt +126 -0
- package/android/src/main/java/com/rsa/core/KeyUtils.kt +83 -0
- package/android/src/main/java/com/rsa/core/RSACipher.kt +71 -0
- package/android/src/main/java/com/rsa/core/RSAKeyGenerator.kt +125 -0
- package/android/src/main/java/com/rsa/core/RSASigner.kt +70 -0
- package/ios/ASN1Utils.swift +225 -0
- package/ios/Algorithms.swift +89 -0
- package/ios/KeyUtils.swift +125 -0
- package/ios/RSACipher.swift +77 -0
- package/ios/RSAKeyGenerator.swift +164 -0
- package/ios/RSASigner.swift +101 -0
- package/ios/Rsa.h +61 -0
- package/ios/Rsa.mm +216 -0
- package/lib/module/NativeRsa.js +16 -0
- package/lib/module/NativeRsa.js.map +1 -0
- package/lib/module/constants.js +24 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/encoding.js +116 -0
- package/lib/module/encoding.js.map +1 -0
- package/lib/module/errors.js +135 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +232 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/keyInfo.js +286 -0
- package/lib/module/keyInfo.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeRsa.d.ts +32 -0
- package/lib/typescript/src/NativeRsa.d.ts.map +1 -0
- package/lib/typescript/src/constants.d.ts +21 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/lib/typescript/src/encoding.d.ts +30 -0
- package/lib/typescript/src/encoding.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +47 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +122 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/keyInfo.d.ts +7 -0
- package/lib/typescript/src/keyInfo.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +63 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +133 -0
- package/src/NativeRsa.ts +59 -0
- package/src/constants.ts +25 -0
- package/src/encoding.ts +139 -0
- package/src/errors.ts +206 -0
- package/src/index.ts +305 -0
- package/src/keyInfo.ts +334 -0
- package/src/types.ts +85 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// --- Key Format Types ---
|
|
2
|
+
|
|
3
|
+
/** Private key encoding format */
|
|
4
|
+
export type KeyFormat = 'pkcs1' | 'pkcs8';
|
|
5
|
+
|
|
6
|
+
// --- Crypto Option Types ---
|
|
7
|
+
|
|
8
|
+
/** Padding mode for encrypt/decrypt operations */
|
|
9
|
+
export type EncryptionPadding = 'oaep' | 'pkcs1';
|
|
10
|
+
|
|
11
|
+
/** Padding mode for sign/verify operations */
|
|
12
|
+
export type SignaturePadding = 'pss' | 'pkcs1';
|
|
13
|
+
|
|
14
|
+
/** Hash algorithm used for padding schemes */
|
|
15
|
+
export type HashAlgorithm = 'sha256' | 'sha1' | 'sha384' | 'sha512';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Controls how the JS input string is interpreted before sending to native.
|
|
19
|
+
* - 'utf8': the string is UTF-8 text (will be encoded to base64 before bridging)
|
|
20
|
+
* - 'base64': the string is already base64-encoded binary data
|
|
21
|
+
*/
|
|
22
|
+
export type InputEncoding = 'utf8' | 'base64';
|
|
23
|
+
|
|
24
|
+
// --- Key Generation Types ---
|
|
25
|
+
|
|
26
|
+
export interface GenerateKeyPairOptions {
|
|
27
|
+
/** Output format for the private key. Default: 'pkcs1' */
|
|
28
|
+
format?: KeyFormat;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RSAKeyPair {
|
|
32
|
+
/** Public key in PEM format (SPKI/X.509) */
|
|
33
|
+
publicKey: string;
|
|
34
|
+
/** Private key in PEM format (PKCS#1 or PKCS#8 depending on options) */
|
|
35
|
+
privateKey: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// --- Key Info Types ---
|
|
39
|
+
|
|
40
|
+
export interface RSAKeyInfo {
|
|
41
|
+
isValid: boolean;
|
|
42
|
+
format: 'pkcs1' | 'pkcs8' | 'public' | 'unknown';
|
|
43
|
+
keyType: 'private' | 'public' | 'unknown';
|
|
44
|
+
pemLineCount: number;
|
|
45
|
+
derByteLength: number;
|
|
46
|
+
errors: string[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// --- Encrypt / Decrypt Options ---
|
|
50
|
+
|
|
51
|
+
export interface EncryptOptions {
|
|
52
|
+
/** Padding mode. Default: 'oaep' */
|
|
53
|
+
padding?: EncryptionPadding;
|
|
54
|
+
/** Hash algorithm (used with OAEP). Default: 'sha256' */
|
|
55
|
+
hash?: HashAlgorithm;
|
|
56
|
+
/** How to interpret the input string. Default: 'utf8' */
|
|
57
|
+
encoding?: InputEncoding;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface DecryptOptions {
|
|
61
|
+
/** Padding mode — must match encryption. Default: 'oaep' */
|
|
62
|
+
padding?: EncryptionPadding;
|
|
63
|
+
/** Hash algorithm — must match encryption. Default: 'sha256' */
|
|
64
|
+
hash?: HashAlgorithm;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// --- Sign / Verify Options ---
|
|
68
|
+
|
|
69
|
+
export interface SignOptions {
|
|
70
|
+
/** Padding mode. Default: 'pss' */
|
|
71
|
+
padding?: SignaturePadding;
|
|
72
|
+
/** Hash algorithm. Default: 'sha256' */
|
|
73
|
+
hash?: HashAlgorithm;
|
|
74
|
+
/** How to interpret the input string. Default: 'utf8' */
|
|
75
|
+
encoding?: InputEncoding;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface VerifyOptions {
|
|
79
|
+
/** Padding mode — must match signing. Default: 'pss' */
|
|
80
|
+
padding?: SignaturePadding;
|
|
81
|
+
/** Hash algorithm — must match signing. Default: 'sha256' */
|
|
82
|
+
hash?: HashAlgorithm;
|
|
83
|
+
/** How to interpret the input string. Default: 'utf8' */
|
|
84
|
+
encoding?: InputEncoding;
|
|
85
|
+
}
|