Skip to content

Commit 8902415

Browse files
MOB-862 #comment updated webAuthn method signature. Added getDeviceInfo and isWebAuthnSupported functions
1 parent 04b8174 commit 8902415

File tree

5 files changed

+56
-28
lines changed

5 files changed

+56
-28
lines changed

example/ios/Podfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ PODS:
375375
- React-jsinspector (0.72.7)
376376
- React-logger (0.72.7):
377377
- glog
378-
- react-native-ts-authentication (0.1.0):
378+
- react-native-ts-authentication (0.1.2):
379379
- RCT-Folly (= 2021.07.22.00)
380380
- React-Core
381-
- TSAuthentication (~> 1.0.2)
381+
- TSAuthentication (~> 1.0.5)
382382
- React-NativeModulesApple (0.72.7):
383383
- hermes-engine
384384
- React-callinvoker
@@ -492,9 +492,9 @@ PODS:
492492
- RNCAsyncStorage (1.21.0):
493493
- React-Core
494494
- SocketRocket (0.6.1)
495-
- TSAuthentication (1.0.2):
496-
- TSCoreSDK (~> 1.0.17)
497-
- TSCoreSDK (1.0.17)
495+
- TSAuthentication (1.0.5):
496+
- TSCoreSDK (~> 1.0.20)
497+
- TSCoreSDK (1.0.21)
498498
- Yoga (1.14.0)
499499
- YogaKit (1.18.1):
500500
- Yoga (~> 1.14)
@@ -704,7 +704,7 @@ SPEC CHECKSUMS:
704704
React-jsiexecutor: c49502e5d02112247ee4526bc3ccfc891ae3eb9b
705705
React-jsinspector: 8baadae51f01d867c3921213a25ab78ab4fbcd91
706706
React-logger: 8edc785c47c8686c7962199a307015e2ce9a0e4f
707-
react-native-ts-authentication: fa1fdbf7f401515476cce2fe7aeb2d49e6affbe5
707+
react-native-ts-authentication: 27e08992c0ef968c01c2655b43984bcdc5c1daf7
708708
React-NativeModulesApple: b6868ee904013a7923128892ee4a032498a1024a
709709
React-perflogger: 31ea61077185eb1428baf60c0db6e2886f141a5a
710710
React-RCTActionSheet: 392090a3abc8992eb269ef0eaa561750588fc39d
@@ -724,8 +724,8 @@ SPEC CHECKSUMS:
724724
ReactCommon: 5f704096ccf7733b390f59043b6fa9cc180ee4f6
725725
RNCAsyncStorage: 618d03a5f52fbccb3d7010076bc54712844c18ef
726726
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
727-
TSAuthentication: a94a6f2bacf0bc518bf8974e9795b1bd28647d59
728-
TSCoreSDK: c602d0392aef99325911a9c1431903976d64e23a
727+
TSAuthentication: 401287772614dd4fc2d9e7120d6857fee0faa344
728+
TSCoreSDK: e30a537480334e5b9971f955ec3d3cdaa334f0a4
729729
Yoga: 4c3aa327e4a6a23eeacd71f61c81df1bcdf677d5
730730
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
731731

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
89
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
910
</dependencies>
1011
<scenes>
@@ -16,32 +17,29 @@
1617
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1718
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1819
<subviews>
19-
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TsAuthenticationExample" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
20-
<rect key="frame" x="0.0" y="202" width="375" height="43"/>
20+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Authentication SDK" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
21+
<rect key="frame" x="12" y="202" width="351" height="43"/>
2122
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
2223
<nil key="highlightedColor"/>
2324
</label>
24-
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="MN2-I3-ftu">
25-
<rect key="frame" x="0.0" y="626" width="375" height="21"/>
26-
<fontDescription key="fontDescription" type="system" pointSize="17"/>
27-
<nil key="highlightedColor"/>
28-
</label>
2925
</subviews>
30-
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
26+
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
27+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
3128
<constraints>
32-
<constraint firstItem="Bcu-3y-fUS" firstAttribute="bottom" secondItem="MN2-I3-ftu" secondAttribute="bottom" constant="20" id="OZV-Vh-mqD"/>
33-
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
34-
<constraint firstItem="MN2-I3-ftu" firstAttribute="centerX" secondItem="Bcu-3y-fUS" secondAttribute="centerX" id="akx-eg-2ui"/>
35-
<constraint firstItem="MN2-I3-ftu" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" id="i1E-0Y-4RG"/>
29+
<constraint firstItem="Bcu-3y-fUS" firstAttribute="trailing" secondItem="GJd-Yh-RWb" secondAttribute="trailing" constant="12" id="hDo-kl-d9Y"/>
3630
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
37-
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="x7j-FC-K8j"/>
31+
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="12" id="x7j-FC-K8j"/>
3832
</constraints>
39-
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
4033
</view>
4134
</viewController>
4235
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
4336
</objects>
4437
<point key="canvasLocation" x="52.173913043478265" y="375"/>
4538
</scene>
4639
</scenes>
40+
<resources>
41+
<systemColor name="systemBackgroundColor">
42+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
43+
</systemColor>
44+
</resources>
4745
</document>

ios/TsAuthentication.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ @interface RCT_EXTERN_MODULE(TsAuthentication, NSObject)
1111
withRejecter:(RCTPromiseRejectBlock)reject)
1212
RCT_EXTERN_METHOD(signTransaction:(NSString *)username withResolver:(RCTPromiseResolveBlock)resolve
1313
withRejecter:(RCTPromiseRejectBlock)reject)
14+
RCT_EXTERN_METHOD(getDeviceInfo:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
15+
RCT_EXTERN_METHOD(isWebAuthnSupported:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
1416

1517
+ (BOOL)requiresMainQueueSetup
1618
{

ios/TsAuthentication.swift

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TsAuthentication: NSObject {
3434
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
3535

3636
runBlockOnMain { [weak self] in
37-
TSAuthentication.shared.register(
37+
TSAuthentication.shared.registerWebAuthn(
3838
username: username,
3939
displayName: displayName) { [weak self] results in
4040
guard let self = self else { return }
@@ -56,7 +56,7 @@ class TsAuthentication: NSObject {
5656
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
5757

5858
runBlockOnMain {
59-
TSAuthentication.shared.authenticate(username: username) { [weak self] results in
59+
TSAuthentication.shared.authenticateWebAuthn(username: username) { [weak self] results in
6060
guard let self = self else { return }
6161

6262
switch results {
@@ -75,7 +75,7 @@ class TsAuthentication: NSObject {
7575
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
7676

7777
runBlockOnMain {
78-
TSAuthentication.shared.signTransaction(username: username) { [weak self] results in
78+
TSAuthentication.shared.signWebauthnTransaction(username: username) { [weak self] results in
7979
guard let self = self else { return }
8080

8181
switch results {
@@ -87,7 +87,35 @@ class TsAuthentication: NSObject {
8787
}
8888
}
8989
}
90+
91+
@objc(getDeviceInfo:withRejecter:)
92+
func getDeviceInfo(
93+
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
94+
95+
runBlockOnMain {
96+
TSAuthentication.shared.getDeviceInfo() { [weak self] deviceInfo in
97+
guard let self = self else { return }
98+
99+
switch deviceInfo {
100+
case .success(let response):
101+
resolve(["result": response])
102+
case .failure(let error):
103+
reject(self.kTag, error.localizedDescription, error)
104+
}
105+
}
106+
}
107+
}
108+
109+
@objc(isWebAuthnSupported:withRejecter:)
110+
func isWebAuthnSupported(
111+
resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
90112

113+
runBlockOnMain {
114+
let isSupported = TSAuthentication.isWebAuthnSupported()
115+
resolve(isSupported)
116+
}
117+
}
118+
91119
// MARK: - Threading
92120

93121
private func runBlockOnMain(_ block: @escaping () -> Void) {

react-native-ts-authentication.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414
s.platforms = { :ios => "15.0" }
1515
s.source = { :git => "https://github.com/TransmitSecurity/react-native-ts-authentication.git", :tag => "#{s.version}" }
1616

17-
s.dependency 'TSAuthentication', '~> 1.0.2'
17+
s.dependency 'TSAuthentication', '~> 1.0.5'
1818
s.source_files = "ios/**/*.{h,m,mm,swift}"
1919

2020
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.

0 commit comments

Comments
 (0)