@xdcobra/react-native-grpc 1.1.0 → 2.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.md +22 -22
- package/README.md +302 -284
- package/android/build.gradle +31 -127
- package/android/src/main/AndroidManifest.xml +3 -3
- package/android/src/main/java/com/reactnativegrpc/GrpcMarshaller.java +27 -27
- package/android/src/main/java/com/reactnativegrpc/GrpcModule.java +730 -730
- package/android/src/main/java/com/reactnativegrpc/GrpcPackage.java +27 -27
- package/android/src/main/java/com/reactnativegrpc/SpkiPinTrustManager.java +101 -101
- package/android/src/main/java/com/reactnativegrpc/TrustManagers.java +51 -51
- package/ios/Grpc.h +22 -22
- package/ios/Grpc.m +627 -625
- package/ios/SpkiPinning.h +22 -22
- package/ios/SpkiPinning.m +162 -114
- package/lib/commonjs/bidi-streaming.js.map +1 -1
- package/lib/commonjs/channel.js +9 -9
- package/lib/commonjs/channel.js.map +1 -1
- package/lib/commonjs/client-streaming.js +3 -3
- package/lib/commonjs/client-streaming.js.map +1 -1
- package/lib/commonjs/client.js +24 -24
- package/lib/commonjs/client.js.map +1 -1
- package/lib/commonjs/create-client.js +5 -5
- package/lib/commonjs/create-client.js.map +1 -1
- package/lib/commonjs/errors.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interceptors.js +3 -3
- package/lib/commonjs/interceptors.js.map +1 -1
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/retry.js.map +1 -1
- package/lib/commonjs/server-streaming.js.map +1 -1
- package/lib/commonjs/status.js.map +1 -1
- package/lib/commonjs/types.js +5 -5
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/unary.js.map +1 -1
- package/lib/module/bidi-streaming.js.map +1 -1
- package/lib/module/channel.js +9 -9
- package/lib/module/channel.js.map +1 -1
- package/lib/module/client-streaming.js +3 -3
- package/lib/module/client-streaming.js.map +1 -1
- package/lib/module/client.js +24 -24
- package/lib/module/client.js.map +1 -1
- package/lib/module/create-client.js +5 -5
- package/lib/module/create-client.js.map +1 -1
- package/lib/module/errors.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/interceptors.js +3 -3
- package/lib/module/interceptors.js.map +1 -1
- package/lib/module/native.js.map +1 -1
- package/lib/module/retry.js.map +1 -1
- package/lib/module/server-streaming.js.map +1 -1
- package/lib/module/status.js.map +1 -1
- package/lib/module/types.js +5 -5
- package/lib/module/types.js.map +1 -1
- package/lib/module/unary.js.map +1 -1
- package/lib/typescript/src/bidi-streaming.d.ts.map +1 -0
- package/lib/typescript/src/channel.d.ts.map +1 -0
- package/lib/typescript/src/client-streaming.d.ts.map +1 -0
- package/lib/typescript/src/client.d.ts.map +1 -0
- package/lib/typescript/src/create-client.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/interceptors.d.ts.map +1 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/retry.d.ts.map +1 -0
- package/lib/typescript/src/server-streaming.d.ts.map +1 -0
- package/lib/typescript/src/status.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/unary.d.ts.map +1 -0
- package/lib/typescript/test/app/App.d.ts +3 -0
- package/lib/typescript/test/app/App.d.ts.map +1 -0
- package/package.json +209 -210
- package/react-native-grpc.podspec +33 -29
- package/src/bidi-streaming.ts +78 -78
- package/src/channel.ts +110 -110
- package/src/client-streaming.ts +106 -106
- package/src/client.ts +1046 -1046
- package/src/create-client.ts +391 -391
- package/src/errors.ts +11 -11
- package/src/index.ts +28 -28
- package/src/interceptors.ts +167 -167
- package/src/native.ts +99 -99
- package/src/retry.ts +208 -208
- package/src/server-streaming.ts +105 -105
- package/src/status.ts +50 -50
- package/src/types.ts +171 -171
- package/src/unary.ts +71 -71
- package/android/gradle.properties +0 -4
- package/lib/typescript/bidi-streaming.d.ts.map +0 -1
- package/lib/typescript/channel.d.ts.map +0 -1
- package/lib/typescript/client-streaming.d.ts.map +0 -1
- package/lib/typescript/client.d.ts.map +0 -1
- package/lib/typescript/create-client.d.ts.map +0 -1
- package/lib/typescript/errors.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/interceptors.d.ts.map +0 -1
- package/lib/typescript/native.d.ts.map +0 -1
- package/lib/typescript/retry.d.ts.map +0 -1
- package/lib/typescript/server-streaming.d.ts.map +0 -1
- package/lib/typescript/status.d.ts.map +0 -1
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/unary.d.ts.map +0 -1
- /package/lib/typescript/{bidi-streaming.d.ts → src/bidi-streaming.d.ts} +0 -0
- /package/lib/typescript/{channel.d.ts → src/channel.d.ts} +0 -0
- /package/lib/typescript/{client-streaming.d.ts → src/client-streaming.d.ts} +0 -0
- /package/lib/typescript/{client.d.ts → src/client.d.ts} +0 -0
- /package/lib/typescript/{create-client.d.ts → src/create-client.d.ts} +0 -0
- /package/lib/typescript/{errors.d.ts → src/errors.d.ts} +0 -0
- /package/lib/typescript/{index.d.ts → src/index.d.ts} +0 -0
- /package/lib/typescript/{interceptors.d.ts → src/interceptors.d.ts} +0 -0
- /package/lib/typescript/{native.d.ts → src/native.d.ts} +0 -0
- /package/lib/typescript/{retry.d.ts → src/retry.d.ts} +0 -0
- /package/lib/typescript/{server-streaming.d.ts → src/server-streaming.d.ts} +0 -0
- /package/lib/typescript/{status.d.ts → src/status.d.ts} +0 -0
- /package/lib/typescript/{types.d.ts → src/types.d.ts} +0 -0
- /package/lib/typescript/{unary.d.ts → src/unary.d.ts} +0 -0
package/ios/SpkiPinning.h
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
|
|
3
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
-
|
|
5
|
-
/** Strip optional `sha256/` prefix; return nil if empty. */
|
|
6
|
-
NSArray<NSString *> *_Nullable SpkiNormalizePins(NSArray *_Nullable rawPins);
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* SHA-256 SPKI pin (standard base64) for a DER-encoded X.509 certificate.
|
|
10
|
-
* Returns nil if the public key cannot be exported as SPKI.
|
|
11
|
-
*/
|
|
12
|
-
NSString *_Nullable SpkiSha256Base64FromCertificateData(NSData *certDer);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* True if at least one certificate in the PEM bundle matches a pin.
|
|
16
|
-
* On iOS, SPKI pins are enforced together with rootCertsPem (trust store).
|
|
17
|
-
*/
|
|
18
|
-
BOOL SpkiPemCertificatesMatchPins(NSString *_Nullable pem,
|
|
19
|
-
NSArray<NSString *> *pins,
|
|
20
|
-
NSError *_Nullable *_Nullable error);
|
|
21
|
-
|
|
22
|
-
NS_ASSUME_NONNULL_END
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/** Strip optional `sha256/` prefix; return nil if empty. */
|
|
6
|
+
NSArray<NSString *> *_Nullable SpkiNormalizePins(NSArray *_Nullable rawPins);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SHA-256 SPKI pin (standard base64) for a DER-encoded X.509 certificate.
|
|
10
|
+
* Returns nil if the public key cannot be exported as SPKI.
|
|
11
|
+
*/
|
|
12
|
+
NSString *_Nullable SpkiSha256Base64FromCertificateData(NSData *certDer);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* True if at least one certificate in the PEM bundle matches a pin.
|
|
16
|
+
* On iOS, SPKI pins are enforced together with rootCertsPem (trust store).
|
|
17
|
+
*/
|
|
18
|
+
BOOL SpkiPemCertificatesMatchPins(NSString *_Nullable pem,
|
|
19
|
+
NSArray<NSString *> *pins,
|
|
20
|
+
NSError *_Nullable *_Nullable error);
|
|
21
|
+
|
|
22
|
+
NS_ASSUME_NONNULL_END
|
package/ios/SpkiPinning.m
CHANGED
|
@@ -1,114 +1,162 @@
|
|
|
1
|
-
#import "SpkiPinning.h"
|
|
2
|
-
#import <CommonCrypto/CommonDigest.h>
|
|
3
|
-
#import <Security/Security.h>
|
|
4
|
-
|
|
5
|
-
NSArray<NSString *> *SpkiNormalizePins(NSArray *rawPins) {
|
|
6
|
-
if (rawPins == nil || rawPins.count == 0) {
|
|
7
|
-
return nil;
|
|
8
|
-
}
|
|
9
|
-
NSMutableArray<NSString *> *out = [NSMutableArray array];
|
|
10
|
-
for (id item in rawPins) {
|
|
11
|
-
if (![item isKindOfClass:[NSString class]]) {
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
NSString *pin = [(NSString *)item
|
|
15
|
-
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
16
|
-
if (pin.length == 0) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
if ([pin.lowercaseString hasPrefix:@"sha256/"]) {
|
|
20
|
-
pin = [[pin substringFromIndex:7]
|
|
21
|
-
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
22
|
-
}
|
|
23
|
-
if (pin.length > 0) {
|
|
24
|
-
[out addObject:pin];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return out.count > 0 ? [out copy] : nil;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
NSString *SpkiSha256Base64FromCertificateData(NSData *certDer) {
|
|
31
|
-
if (certDer.length == 0) {
|
|
32
|
-
return nil;
|
|
33
|
-
}
|
|
34
|
-
SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certDer);
|
|
35
|
-
if (cert == NULL) {
|
|
36
|
-
return nil;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
SecKeyRef key = SecCertificateCopyKey(cert);
|
|
40
|
-
CFRelease(cert);
|
|
41
|
-
if (key == NULL) {
|
|
42
|
-
return nil;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
1
|
+
#import "SpkiPinning.h"
|
|
2
|
+
#import <CommonCrypto/CommonDigest.h>
|
|
3
|
+
#import <Security/Security.h>
|
|
4
|
+
|
|
5
|
+
NSArray<NSString *> *SpkiNormalizePins(NSArray *rawPins) {
|
|
6
|
+
if (rawPins == nil || rawPins.count == 0) {
|
|
7
|
+
return nil;
|
|
8
|
+
}
|
|
9
|
+
NSMutableArray<NSString *> *out = [NSMutableArray array];
|
|
10
|
+
for (id item in rawPins) {
|
|
11
|
+
if (![item isKindOfClass:[NSString class]]) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
NSString *pin = [(NSString *)item
|
|
15
|
+
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
16
|
+
if (pin.length == 0) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if ([pin.lowercaseString hasPrefix:@"sha256/"]) {
|
|
20
|
+
pin = [[pin substringFromIndex:7]
|
|
21
|
+
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
22
|
+
}
|
|
23
|
+
if (pin.length > 0) {
|
|
24
|
+
[out addObject:pin];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return out.count > 0 ? [out copy] : nil;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
NSString *SpkiSha256Base64FromCertificateData(NSData *certDer) {
|
|
31
|
+
if (certDer.length == 0) {
|
|
32
|
+
return nil;
|
|
33
|
+
}
|
|
34
|
+
SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certDer);
|
|
35
|
+
if (cert == NULL) {
|
|
36
|
+
return nil;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
SecKeyRef key = SecCertificateCopyKey(cert);
|
|
40
|
+
CFRelease(cert);
|
|
41
|
+
if (key == NULL) {
|
|
42
|
+
return nil;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// SubjectPublicKeyInfo DER of the public key (matches Android PublicKey.getEncoded()).
|
|
46
|
+
// SecItemExport / kSecFormatOpenSSL exist on macOS only. On iOS the key is exported
|
|
47
|
+
// raw (PKCS#1 for RSA, X9.63 for EC) and the fixed ASN.1 SPKI header for its type
|
|
48
|
+
// and size is prepended.
|
|
49
|
+
static const uint8_t kRsa2048[] = {0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
|
|
50
|
+
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00};
|
|
51
|
+
static const uint8_t kRsa3072[] = {0x30, 0x82, 0x01, 0xa2, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
|
|
52
|
+
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x8f, 0x00};
|
|
53
|
+
static const uint8_t kRsa4096[] = {0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
|
|
54
|
+
0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00};
|
|
55
|
+
static const uint8_t kEc256[] = {0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01,
|
|
56
|
+
0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00};
|
|
57
|
+
static const uint8_t kEc384[] = {0x30, 0x76, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
|
|
58
|
+
0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, 0x03, 0x62, 0x00};
|
|
59
|
+
|
|
60
|
+
NSDictionary *attrs = (__bridge_transfer NSDictionary *)SecKeyCopyAttributes(key);
|
|
61
|
+
NSString *keyType = attrs[(__bridge NSString *)kSecAttrKeyType];
|
|
62
|
+
NSInteger keyBits = [attrs[(__bridge NSString *)kSecAttrKeySizeInBits] integerValue];
|
|
63
|
+
CFDataRef rawKey = SecKeyCopyExternalRepresentation(key, NULL);
|
|
64
|
+
CFRelease(key);
|
|
65
|
+
if (rawKey == NULL) {
|
|
66
|
+
return nil;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const uint8_t *header = NULL;
|
|
70
|
+
size_t headerLength = 0;
|
|
71
|
+
if ([keyType isEqualToString:(__bridge NSString *)kSecAttrKeyTypeRSA]) {
|
|
72
|
+
if (keyBits == 2048) {
|
|
73
|
+
header = kRsa2048;
|
|
74
|
+
headerLength = sizeof(kRsa2048);
|
|
75
|
+
} else if (keyBits == 3072) {
|
|
76
|
+
header = kRsa3072;
|
|
77
|
+
headerLength = sizeof(kRsa3072);
|
|
78
|
+
} else if (keyBits == 4096) {
|
|
79
|
+
header = kRsa4096;
|
|
80
|
+
headerLength = sizeof(kRsa4096);
|
|
81
|
+
}
|
|
82
|
+
} else if ([keyType isEqualToString:(__bridge NSString *)kSecAttrKeyTypeECSECPrimeRandom]) {
|
|
83
|
+
if (keyBits == 256) {
|
|
84
|
+
header = kEc256;
|
|
85
|
+
headerLength = sizeof(kEc256);
|
|
86
|
+
} else if (keyBits == 384) {
|
|
87
|
+
header = kEc384;
|
|
88
|
+
headerLength = sizeof(kEc384);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (header == NULL) {
|
|
92
|
+
// Unsupported key type or size: no pin can match.
|
|
93
|
+
CFRelease(rawKey);
|
|
94
|
+
return nil;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
NSMutableData *spkiBytes = [NSMutableData dataWithBytes:header length:headerLength];
|
|
98
|
+
[spkiBytes appendData:(__bridge NSData *)rawKey];
|
|
99
|
+
CFRelease(rawKey);
|
|
100
|
+
|
|
101
|
+
NSData *spki = spkiBytes;
|
|
102
|
+
uint8_t digest[CC_SHA256_DIGEST_LENGTH];
|
|
103
|
+
CC_SHA256(spki.bytes, (CC_LONG)spki.length, digest);
|
|
104
|
+
return [[NSData dataWithBytes:digest length:CC_SHA256_DIGEST_LENGTH]
|
|
105
|
+
base64EncodedStringWithOptions:0];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static NSArray<NSData *> *CertificatesFromPem(NSString *pem) {
|
|
109
|
+
if (pem.length == 0) {
|
|
110
|
+
return @[];
|
|
111
|
+
}
|
|
112
|
+
NSMutableArray<NSData *> *certs = [NSMutableArray array];
|
|
113
|
+
NSArray<NSString *> *parts = [pem componentsSeparatedByString:@"-----BEGIN CERTIFICATE-----"];
|
|
114
|
+
for (NSString *part in parts) {
|
|
115
|
+
NSRange end = [part rangeOfString:@"-----END CERTIFICATE-----"];
|
|
116
|
+
if (end.location == NSNotFound) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
NSString *b64 = [[part substringToIndex:end.location]
|
|
120
|
+
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
121
|
+
b64 = [[b64 componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
|
|
122
|
+
componentsJoinedByString:@""];
|
|
123
|
+
NSData *der = [[NSData alloc] initWithBase64EncodedString:b64 options:0];
|
|
124
|
+
if (der.length > 0) {
|
|
125
|
+
[certs addObject:der];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return certs;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
BOOL SpkiPemCertificatesMatchPins(NSString *pem, NSArray<NSString *> *pins, NSError **error) {
|
|
132
|
+
if (pins.count == 0) {
|
|
133
|
+
return YES;
|
|
134
|
+
}
|
|
135
|
+
NSArray<NSData *> *certs = CertificatesFromPem(pem);
|
|
136
|
+
if (certs.count == 0) {
|
|
137
|
+
if (error) {
|
|
138
|
+
*error = [NSError errorWithDomain:@"SpkiPinning"
|
|
139
|
+
code:1
|
|
140
|
+
userInfo:@{
|
|
141
|
+
NSLocalizedDescriptionKey : @"rootCertsPem contained no certificates"
|
|
142
|
+
}];
|
|
143
|
+
}
|
|
144
|
+
return NO;
|
|
145
|
+
}
|
|
146
|
+
NSSet<NSString *> *pinSet = [NSSet setWithArray:pins];
|
|
147
|
+
for (NSData *der in certs) {
|
|
148
|
+
NSString *pin = SpkiSha256Base64FromCertificateData(der);
|
|
149
|
+
if (pin != nil && [pinSet containsObject:pin]) {
|
|
150
|
+
return YES;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (error) {
|
|
154
|
+
*error = [NSError errorWithDomain:@"SpkiPinning"
|
|
155
|
+
code:2
|
|
156
|
+
userInfo:@{
|
|
157
|
+
NSLocalizedDescriptionKey :
|
|
158
|
+
@"spkiSha256Pins do not match any certificate in rootCertsPem"
|
|
159
|
+
}];
|
|
160
|
+
}
|
|
161
|
+
return NO;
|
|
162
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GrpcBidiStreamingCall","abort","constructor","method","requestHeaders","requests","headers","responses","trailers","then","onfulfilled","onrejected","completedPromise","value","Promise","resolve","reason","reject","cancel","all","status","exports"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["GrpcBidiStreamingCall","abort","constructor","method","requestHeaders","requests","headers","responses","trailers","then","onfulfilled","onrejected","completedPromise","value","Promise","resolve","reason","reject","cancel","all","status","exports"],"sourceRoot":"../../src","sources":["bidi-streaming.ts"],"mappings":";;;;;;AAQO,MAAMA,qBAAqB,CAElC;EAQE,CAACC,KAAK;EAENC,WAAWA,CACTC,MAAc,EACdC,cAA4B,EAC5BC,QAA+B,EAC/BC,OAA8B,EAC9BC,SAAiC,EACjCC,QAA+B,EAC/BP,KAAsB,EACtB;IACA,IAAI,CAACE,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAAC,CAACP,KAAK,GAAGA,KAAK;EACrB;EAEAQ,IAAIA,CACFC,WAIQ,EACRC,UAAuE,EACrC;IAClC,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAACH,IAAI,CAChCI,KAAK,IACJH,WAAW,GACPI,OAAO,CAACC,OAAO,CAACL,WAAW,CAACG,KAAK,CAAC,CAAC,GAClCA,KAA6B,EACnCG,MAAM,IACLL,UAAU,GACNG,OAAO,CAACC,OAAO,CAACJ,UAAU,CAACK,MAAM,CAAC,CAAC,GACnCF,OAAO,CAACG,MAAM,CAACD,MAAM,CAC7B,CAAC;EACH;EAEAE,MAAMA,CAAA,EAAG;IACP,IAAI,CAAC,CAACjB,KAAK,CAACA,KAAK,CAAC,CAAC;EACrB;EAEA,MAAcW,gBAAgBA,CAAA,EAA4C;IACxE,MAAM,CAACN,OAAO,EAAEE,QAAQ,CAAC,GAAG,MAAMM,OAAO,CAACK,GAAG,CAAC,CAC5C,IAAI,CAACb,OAAO,EACZ,IAAI,CAACE,QAAQ,CACd,CAAC;IAEF,OAAO;MACLL,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBC,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCE,OAAO;MACPC,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBC,QAAQ;MACRY,MAAM,EAAE;IACV,CAAC;EACH;AACF;AAACC,OAAA,CAAArB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
package/lib/commonjs/channel.js
CHANGED
|
@@ -10,9 +10,9 @@ var _native = require("./native");
|
|
|
10
10
|
var _retry = require("./retry");
|
|
11
11
|
let channelCtr = 1;
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Independent gRPC channel bound to a host (and optional TLS / deadline / keepalive).
|
|
15
|
-
* Create via {@link createChannel}; close when finished. Concurrent channels are supported.
|
|
13
|
+
/**
|
|
14
|
+
* Independent gRPC channel bound to a host (and optional TLS / deadline / keepalive).
|
|
15
|
+
* Create via {@link createChannel}; close when finished. Concurrent channels are supported.
|
|
16
16
|
*/
|
|
17
17
|
class GrpcChannel extends _client.GrpcCallApi {
|
|
18
18
|
closed = false;
|
|
@@ -31,9 +31,9 @@ class GrpcChannel extends _client.GrpcCallApi {
|
|
|
31
31
|
return this.channelId;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Tear down this channel. Further RPCs will fail.
|
|
36
|
-
* Does not affect the singleton `GrpcClient` default channel.
|
|
34
|
+
/**
|
|
35
|
+
* Tear down this channel. Further RPCs will fail.
|
|
36
|
+
* Does not affect the singleton `GrpcClient` default channel.
|
|
37
37
|
*/
|
|
38
38
|
close() {
|
|
39
39
|
if (this.closed) {
|
|
@@ -44,9 +44,9 @@ class GrpcChannel extends _client.GrpcCallApi {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
* Create a concurrent channel with immutable config.
|
|
49
|
-
* Prefer this over mutating `GrpcClient.setHost` when talking to multiple hosts.
|
|
47
|
+
/**
|
|
48
|
+
* Create a concurrent channel with immutable config.
|
|
49
|
+
* Prefer this over mutating `GrpcClient.setHost` when talking to multiple hosts.
|
|
50
50
|
*/
|
|
51
51
|
exports.GrpcChannel = GrpcChannel;
|
|
52
52
|
function createChannel(config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_client","require","_native","_retry","channelCtr","GrpcChannel","GrpcCallApi","closed","constructor","channelId","host","interceptors","channelDeadlineSeconds","channelRetry","channelHedging","getHost","Promise","resolve","getChannelId","close","nativeGrpc","closeChannel","exports","createChannel","config","trim","Error","assertExclusivePolicies","retry","hedging","normalizeRetryPolicy","normalizeHedgingPolicy","tls","normalizeTlsOptions","compression","keepAlive","deadline","callDeadlineSeconds","undefined","Math","max","insecure","responseSizeLimit","compressionEnable","enable","compressorName","keepAliveEnable","keepAliveTime","keepAliveTimeOut"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["_client","require","_native","_retry","channelCtr","GrpcChannel","GrpcCallApi","closed","constructor","channelId","host","interceptors","channelDeadlineSeconds","channelRetry","channelHedging","getHost","Promise","resolve","getChannelId","close","nativeGrpc","closeChannel","exports","createChannel","config","trim","Error","assertExclusivePolicies","retry","hedging","normalizeRetryPolicy","normalizeHedgingPolicy","tls","normalizeTlsOptions","compression","keepAlive","deadline","callDeadlineSeconds","undefined","Math","max","insecure","responseSizeLimit","compressionEnable","enable","compressorName","keepAliveEnable","keepAliveTime","keepAliveTimeOut"],"sourceRoot":"../../src","sources":["channel.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ServerInputStream = exports.GrpcClientStreamingCall = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Client → server request stream for client-streaming RPCs.
|
|
9
|
-
* Native call is created on the first `send`.
|
|
7
|
+
/**
|
|
8
|
+
* Client → server request stream for client-streaming RPCs.
|
|
9
|
+
* Native call is created on the first `send`.
|
|
10
10
|
*/
|
|
11
11
|
class ServerInputStream {
|
|
12
12
|
#started = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ServerInputStream","started","sendNative","finishNative","constructor","send","data","isFirst","complete","exports","GrpcClientStreamingCall","abort","method","requestHeaders","requests","headers","response","trailers","then","onfulfilled","onrejected","completedPromise","value","Promise","resolve","reason","reject","cancel","all","status"],"sourceRoot":"
|
|
1
|
+
{"version":3,"names":["ServerInputStream","started","sendNative","finishNative","constructor","send","data","isFirst","complete","exports","GrpcClientStreamingCall","abort","method","requestHeaders","requests","headers","response","trailers","then","onfulfilled","onrejected","completedPromise","value","Promise","resolve","reason","reject","cancel","all","status"],"sourceRoot":"../../src","sources":["client-streaming.ts"],"mappings":";;;;;;AAUA;AACA;AACA;AACA;AACO,MAAMA,iBAAiB,CAAkC;EAC9D,CAACC,OAAO,GAAG,KAAK;EAChB,CAACC,UAAU;EACX,CAACC,YAAY;EAEbC,WAAWA,CAACF,UAAsB,EAAEC,YAA0B,EAAE;IAC9D,IAAI,CAAC,CAACD,UAAU,GAAGA,UAAU;IAC7B,IAAI,CAAC,CAACC,YAAY,GAAGA,YAAY;EACnC;EAEAE,IAAIA,CAACC,IAAgB,EAAiB;IACpC,MAAMC,OAAO,GAAG,CAAC,IAAI,CAAC,CAACN,OAAO;IAC9B,IAAI,CAAC,CAACA,OAAO,GAAG,IAAI;IACpB,OAAO,IAAI,CAAC,CAACC,UAAU,CAACI,IAAI,EAAEC,OAAO,CAAC;EACxC;EAEAC,QAAQA,CAAA,EAAkB;IACxB,OAAO,IAAI,CAAC,CAACL,YAAY,CAAC,CAAC;EAC7B;AACF;AAACM,OAAA,CAAAT,iBAAA,GAAAA,iBAAA;AAEM,MAAMU,uBAAuB,CAEpC;EAQE,CAACC,KAAK;EAENP,WAAWA,CACTQ,MAAc,EACdC,cAA4B,EAC5BC,QAA+B,EAC/BC,OAA8B,EAC9BC,QAA6B,EAC7BC,QAA+B,EAC/BN,KAAsB,EACtB;IACA,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,cAAc,GAAGA,cAAc;IACpC,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAAC,CAACN,KAAK,GAAGA,KAAK;EACrB;EAEAO,IAAIA,CACFC,WAIQ,EACRC,UAAuE,EACrC;IAClC,OAAO,IAAI,CAACC,gBAAgB,CAAC,CAAC,CAACH,IAAI,CAChCI,KAAK,IACJH,WAAW,GACPI,OAAO,CAACC,OAAO,CAACL,WAAW,CAACG,KAAK,CAAC,CAAC,GAClCA,KAA6B,EACnCG,MAAM,IACLL,UAAU,GACNG,OAAO,CAACC,OAAO,CAACJ,UAAU,CAACK,MAAM,CAAC,CAAC,GACnCF,OAAO,CAACG,MAAM,CAACD,MAAM,CAC7B,CAAC;EACH;EAEAE,MAAMA,CAAA,EAAG;IACP,IAAI,CAAC,CAAChB,KAAK,CAACA,KAAK,CAAC,CAAC;EACrB;EAEA,MAAcU,gBAAgBA,CAAA,EAA8C;IAC1E,MAAM,CAACN,OAAO,EAAEC,QAAQ,EAAEC,QAAQ,CAAC,GAAG,MAAMM,OAAO,CAACK,GAAG,CAAC,CACtD,IAAI,CAACb,OAAO,EACZ,IAAI,CAACC,QAAQ,EACb,IAAI,CAACC,QAAQ,CACd,CAAC;IAEF,OAAO;MACLL,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBC,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCE,OAAO;MACPE,QAAQ;MACRD,QAAQ;MACRa,MAAM,EAAE;IACV,CAAC;EACH;AACF;AAACpB,OAAA,CAAAC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
package/lib/commonjs/client.js
CHANGED
|
@@ -123,9 +123,9 @@ function normalizeTlsOptions(options = {}) {
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
/**
|
|
127
|
-
* Shared RPC surface bound to a native channel id.
|
|
128
|
-
* Used by the singleton {@link GrpcClient} and by {@link GrpcChannel}.
|
|
126
|
+
/**
|
|
127
|
+
* Shared RPC surface bound to a native channel id.
|
|
128
|
+
* Used by the singleton {@link GrpcClient} and by {@link GrpcChannel}.
|
|
129
129
|
*/
|
|
130
130
|
class GrpcCallApi {
|
|
131
131
|
channelDeadlineSeconds = 120;
|
|
@@ -448,9 +448,9 @@ class GrpcCallApi {
|
|
|
448
448
|
return call;
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
-
/**
|
|
452
|
-
* Client-streaming RPC: many request messages, one response.
|
|
453
|
-
* Native call starts on the first `requests.send(...)`.
|
|
451
|
+
/**
|
|
452
|
+
* Client-streaming RPC: many request messages, one response.
|
|
453
|
+
* Native call starts on the first `requests.send(...)`.
|
|
454
454
|
*/
|
|
455
455
|
clientStreamCall(method, requestHeaders, options) {
|
|
456
456
|
const id = getId();
|
|
@@ -512,10 +512,10 @@ class GrpcCallApi {
|
|
|
512
512
|
return call;
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
/**
|
|
516
|
-
* Bidirectional streaming RPC: interleaved request and response messages.
|
|
517
|
-
* Native call starts on the first `requests.send(...)`.
|
|
518
|
-
* Registers only the `data` stream (plus headers/trailers) — no unary `response`.
|
|
515
|
+
/**
|
|
516
|
+
* Bidirectional streaming RPC: interleaved request and response messages.
|
|
517
|
+
* Native call starts on the first `requests.send(...)`.
|
|
518
|
+
* Registers only the `data` stream (plus headers/trailers) — no unary `response`.
|
|
519
519
|
*/
|
|
520
520
|
bidiStreamCall(method, requestHeaders, options) {
|
|
521
521
|
const id = getId();
|
|
@@ -586,16 +586,16 @@ class GrpcClient extends GrpcCallApi {
|
|
|
586
586
|
destroy() {
|
|
587
587
|
Emitter.removeAllListeners('grpc-call');
|
|
588
588
|
}
|
|
589
|
-
/**
|
|
590
|
-
* Replace default-channel interceptors (same replace semantics as `setTlsOptions`).
|
|
591
|
-
* Prefer `createChannel({ interceptors })` for multi-host apps.
|
|
589
|
+
/**
|
|
590
|
+
* Replace default-channel interceptors (same replace semantics as `setTlsOptions`).
|
|
591
|
+
* Prefer `createChannel({ interceptors })` for multi-host apps.
|
|
592
592
|
*/
|
|
593
593
|
setInterceptors(interceptors = []) {
|
|
594
594
|
this.channelInterceptors = [...interceptors];
|
|
595
595
|
}
|
|
596
|
-
/**
|
|
597
|
-
* Replace unary retry policy on the default channel.
|
|
598
|
-
* Clears any hedging policy (mutually exclusive). Pass `null` to disable.
|
|
596
|
+
/**
|
|
597
|
+
* Replace unary retry policy on the default channel.
|
|
598
|
+
* Clears any hedging policy (mutually exclusive). Pass `null` to disable.
|
|
599
599
|
*/
|
|
600
600
|
setRetryPolicy(policy) {
|
|
601
601
|
if (policy) {
|
|
@@ -604,9 +604,9 @@ class GrpcClient extends GrpcCallApi {
|
|
|
604
604
|
this.channelRetry = policy;
|
|
605
605
|
this.channelHedging = null;
|
|
606
606
|
}
|
|
607
|
-
/**
|
|
608
|
-
* Replace unary hedging policy on the default channel.
|
|
609
|
-
* Clears any retry policy (mutually exclusive). Pass `null` to disable.
|
|
607
|
+
/**
|
|
608
|
+
* Replace unary hedging policy on the default channel.
|
|
609
|
+
* Clears any retry policy (mutually exclusive). Pass `null` to disable.
|
|
610
610
|
*/
|
|
611
611
|
setHedgingPolicy(policy) {
|
|
612
612
|
if (policy) {
|
|
@@ -627,11 +627,11 @@ class GrpcClient extends GrpcCallApi {
|
|
|
627
627
|
setInsecure(insecure) {
|
|
628
628
|
(0, _native.nativeGrpc)().setInsecure(insecure);
|
|
629
629
|
}
|
|
630
|
-
/**
|
|
631
|
-
* Replace channel TLS options (custom CA, mTLS, hostname override).
|
|
632
|
-
* Each call replaces the previous config; omitted fields are cleared.
|
|
633
|
-
* Apply before `initGrpcChannel()`. Ignored while insecure/plaintext.
|
|
634
|
-
* For multi-host apps prefer {@link createChannel} with `tls` in config.
|
|
630
|
+
/**
|
|
631
|
+
* Replace channel TLS options (custom CA, mTLS, hostname override).
|
|
632
|
+
* Each call replaces the previous config; omitted fields are cleared.
|
|
633
|
+
* Apply before `initGrpcChannel()`. Ignored while insecure/plaintext.
|
|
634
|
+
* For multi-host apps prefer {@link createChannel} with `tls` in config.
|
|
635
635
|
*/
|
|
636
636
|
setTlsOptions(options = {}) {
|
|
637
637
|
(0, _native.nativeGrpc)().setTlsOptions(normalizeTlsOptions(options));
|