react-native-authsignal 0.1.0 → 0.2.1

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.
Files changed (56) hide show
  1. package/.github/workflows/release-package.yml +0 -14
  2. package/{LICENSE → LICENSE.md} +3 -2
  3. package/README.md +1 -1
  4. package/android/build.gradle +6 -11
  5. package/android/gradle.properties +1 -2
  6. package/android/src/main/java/com/authsignal/react/AuthsignalModule.java +2 -2
  7. package/android/src/main/java/com/authsignal/react/AuthsignalPackage.java +5 -1
  8. package/android/src/main/java/com/authsignal/react/AuthsignalPasskeyModule.java +96 -0
  9. package/android/src/main/java/com/authsignal/react/AuthsignalPushModule.java +156 -0
  10. package/ios/Authsignal-Bridging-Header.h +1 -0
  11. package/ios/Authsignal.xcodeproj/project.pbxproj +16 -6
  12. package/ios/AuthsignalModule.h +11 -0
  13. package/ios/{Authsignal.m → AuthsignalModule.m} +3 -3
  14. package/ios/AuthsignalPasskeyModule.m +23 -0
  15. package/ios/AuthsignalPasskeyModule.swift +77 -0
  16. package/ios/AuthsignalPushModule.m +30 -0
  17. package/ios/AuthsignalPushModule.swift +145 -0
  18. package/lib/commonjs/error.js +13 -0
  19. package/lib/commonjs/error.js.map +1 -0
  20. package/lib/commonjs/index.js +37 -8
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/passkey.js +99 -0
  23. package/lib/commonjs/passkey.js.map +1 -0
  24. package/lib/commonjs/push.js +134 -0
  25. package/lib/commonjs/push.js.map +1 -0
  26. package/lib/commonjs/types.js +2 -0
  27. package/lib/commonjs/types.js.map +1 -0
  28. package/lib/module/error.js +6 -0
  29. package/lib/module/error.js.map +1 -0
  30. package/lib/module/index.js +34 -7
  31. package/lib/module/index.js.map +1 -1
  32. package/lib/module/passkey.js +92 -0
  33. package/lib/module/passkey.js.map +1 -0
  34. package/lib/module/push.js +127 -0
  35. package/lib/module/push.js.map +1 -0
  36. package/lib/module/types.js +2 -0
  37. package/lib/module/types.js.map +1 -0
  38. package/lib/typescript/error.d.ts +2 -0
  39. package/lib/typescript/error.d.ts.map +1 -0
  40. package/lib/typescript/index.d.ts +16 -0
  41. package/lib/typescript/index.d.ts.map +1 -1
  42. package/lib/typescript/passkey.d.ts +26 -0
  43. package/lib/typescript/passkey.d.ts.map +1 -0
  44. package/lib/typescript/push.d.ts +25 -0
  45. package/lib/typescript/push.d.ts.map +1 -0
  46. package/lib/typescript/types.d.ts +5 -0
  47. package/lib/typescript/types.d.ts.map +1 -0
  48. package/package.json +3 -3
  49. package/react-native-authsignal.podspec +2 -1
  50. package/src/error.ts +7 -0
  51. package/src/index.tsx +35 -10
  52. package/src/passkey.ts +114 -0
  53. package/src/push.ts +157 -0
  54. package/src/types.ts +4 -0
  55. package/yarn.lock +405 -126
  56. package/ios/Authsignal.h +0 -12
@@ -3,23 +3,9 @@ name: Release the Authsignal React Native package
3
3
  on:
4
4
  release:
5
5
  types: [created]
6
- push:
7
- branches:
8
- - publish
9
6
 
10
7
  jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: yarn
19
- - run: yarn prepare
20
-
21
8
  publish:
22
- needs: build
23
9
  runs-on: ubuntu-latest
24
10
  permissions:
25
11
  packages: write
@@ -1,6 +1,7 @@
1
- MIT License
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Authsignal
2
4
 
3
- Copyright (c) 2022 Authsignal
4
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
6
  of this software and associated documentation files (the "Software"), to deal
6
7
  in the Software without restriction, including without limitation the rights
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # react-native-authsignal
2
2
 
3
- React Native library for the Authsignal API
3
+ The official Authsignal library for React Native.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,7 +1,4 @@
1
1
  buildscript {
2
- // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
- def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Authsignal_kotlinVersion']
4
-
5
2
  repositories {
6
3
  google()
7
4
  mavenCentral()
@@ -9,8 +6,6 @@ buildscript {
9
6
 
10
7
  dependencies {
11
8
  classpath 'com.android.tools.build:gradle:4.2.0'
12
- // noinspection DifferentKotlinGradleVersion
13
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
9
  }
15
10
  }
16
11
 
@@ -19,7 +14,7 @@ def isNewArchitectureEnabled() {
19
14
  }
20
15
 
21
16
  apply plugin: 'com.android.library'
22
- apply plugin: 'kotlin-android'
17
+
23
18
 
24
19
  if (isNewArchitectureEnabled()) {
25
20
  apply plugin: 'com.facebook.react'
@@ -128,14 +123,14 @@ repositories {
128
123
  }
129
124
  }
130
125
 
131
- def kotlin_version = getExtOrDefault('kotlinVersion')
132
-
133
126
  dependencies {
134
- //noinspection GradleDynamicVersion
127
+ //noinspection GradleDynamicVersion
135
128
  implementation "com.facebook.react:react-native:+"
129
+
136
130
  implementation "androidx.browser:browser:1.2.0"
137
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
138
- // From node_modules
131
+
132
+ implementation("com.authsignal:authsignal-push-android:0.1.12")
133
+ implementation("com.authsignal:authsignal-passkey-android:0.0.5")
139
134
  }
140
135
 
141
136
  if (isNewArchitectureEnabled()) {
@@ -1,5 +1,4 @@
1
- Authsignal_kotlinVersion=1.7.0
2
- Authsignal_minSdkVersion=21
1
+ Authsignal_minSdkVersion=24
3
2
  Authsignal_targetSdkVersion=31
4
3
  Authsignal_compileSdkVersion=31
5
4
  Authsignal_ndkversion=21.4.7075529
@@ -42,7 +42,7 @@ public class AuthsignalModule extends ReactContextBaseJavaModule implements Acti
42
42
  @NonNull
43
43
  @Override
44
44
  public String getName() {
45
- return "Authsignal";
45
+ return "AuthsignalModule";
46
46
  }
47
47
 
48
48
  @ReactMethod
@@ -115,4 +115,4 @@ public class AuthsignalModule extends ReactContextBaseJavaModule implements Acti
115
115
  @Override
116
116
  public void onNewIntent(Intent intent) {
117
117
  }
118
- }
118
+ }
@@ -12,7 +12,11 @@ import com.facebook.react.uimanager.ViewManager;
12
12
  public class AuthsignalPackage implements ReactPackage {
13
13
  @Override
14
14
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
15
- return Arrays.<NativeModule>asList(new AuthsignalModule(reactContext));
15
+ return Arrays.asList(
16
+ new AuthsignalModule(reactContext),
17
+ new AuthsignalPasskeyModule(reactContext),
18
+ new AuthsignalPushModule(reactContext)
19
+ );
16
20
  }
17
21
 
18
22
  @Override
@@ -0,0 +1,96 @@
1
+ package com.authsignal.react;
2
+
3
+ import android.app.Activity;
4
+ import android.util.Log;
5
+
6
+ import androidx.annotation.NonNull;
7
+
8
+ import com.authsignal.passkey.AuthsignalPasskey;
9
+ import com.facebook.react.bridge.Promise;
10
+ import com.facebook.react.bridge.ReactApplicationContext;
11
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
+ import com.facebook.react.bridge.ReactMethod;
13
+
14
+ import java.util.HashMap;
15
+ import java.util.Map;
16
+
17
+ public class AuthsignalPasskeyModule extends ReactContextBaseJavaModule {
18
+ private final ReactApplicationContext reactContext;
19
+
20
+ private AuthsignalPasskey authsignalPasskey;
21
+
22
+ private final String TAG = "AuthsignalPasskeyModule";
23
+ private final String INIT_WARNING = "AuthsignalPasskeyModule is not initialized.";
24
+
25
+ public AuthsignalPasskeyModule(ReactApplicationContext reactContext) {
26
+ super(reactContext);
27
+ this.reactContext = reactContext;
28
+ }
29
+
30
+ @Override
31
+ public Map<String, Object> getConstants() {
32
+ final Map<String, Object> constants = new HashMap<>();
33
+ constants.put("bundleIdentifier", reactContext.getApplicationInfo().packageName);
34
+ return constants;
35
+ }
36
+
37
+ @NonNull
38
+ @Override
39
+ public String getName() {
40
+ return "AuthsignalPasskeyModule";
41
+ }
42
+
43
+ @ReactMethod
44
+ public void initialize(String tenantID, String baseURL, Promise promise) {
45
+ Activity currentActivity = reactContext.getCurrentActivity();
46
+
47
+ if (currentActivity != null) {
48
+ authsignalPasskey = new AuthsignalPasskey(
49
+ tenantID,
50
+ baseURL,
51
+ reactContext,
52
+ reactContext.getCurrentActivity()
53
+ );
54
+ }
55
+
56
+ promise.resolve(null);
57
+ }
58
+
59
+ @ReactMethod
60
+ public void signUp(String token, String userName, Promise promise) {
61
+ if (authsignalPasskey != null) {
62
+ authsignalPasskey
63
+ .signUpAsync(token, userName)
64
+ .thenAcceptAsync(response -> {
65
+ if (response.getError() != null) {
66
+ promise.reject("signUp error", response.getError());
67
+ } else {
68
+ promise.resolve(response.getData());
69
+ }
70
+ });
71
+ } else {
72
+ Log.w(TAG, INIT_WARNING);
73
+
74
+ promise.resolve(null);
75
+ }
76
+ }
77
+
78
+ @ReactMethod
79
+ public void signIn(String token, Promise promise) {
80
+ if (authsignalPasskey != null) {
81
+ authsignalPasskey
82
+ .signInAsync(token)
83
+ .thenAcceptAsync(response -> {
84
+ if (response.getError() != null) {
85
+ promise.reject("signIn error", response.getError());
86
+ } else {
87
+ promise.resolve(response.getData());
88
+ }
89
+ });
90
+ } else {
91
+ Log.w(TAG, INIT_WARNING);
92
+
93
+ promise.resolve(null);
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,156 @@
1
+ package com.authsignal.react;
2
+
3
+ import android.util.Log;
4
+
5
+ import androidx.annotation.NonNull;
6
+
7
+ import com.authsignal.push.AuthsignalPush;
8
+ import com.authsignal.push.models.PushCredential;
9
+ import com.facebook.react.bridge.Arguments;
10
+ import com.facebook.react.bridge.Promise;
11
+ import com.facebook.react.bridge.ReactApplicationContext;
12
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
13
+ import com.facebook.react.bridge.ReactMethod;
14
+ import com.facebook.react.bridge.WritableMap;
15
+
16
+ import java.util.HashMap;
17
+ import java.util.Map;
18
+
19
+ public class AuthsignalPushModule extends ReactContextBaseJavaModule {
20
+ private final ReactApplicationContext reactContext;
21
+
22
+ private AuthsignalPush authsignalPush;
23
+
24
+ private final String TAG = "AuthsignalPasskeyModule";
25
+ private final String INIT_WARNING = "AuthsignalPasskeyModule is not initialized.";
26
+
27
+ public AuthsignalPushModule(ReactApplicationContext reactContext) {
28
+ super(reactContext);
29
+ this.reactContext = reactContext;
30
+ }
31
+
32
+ @Override
33
+ public Map<String, Object> getConstants() {
34
+ final Map<String, Object> constants = new HashMap<>();
35
+ constants.put("bundleIdentifier", reactContext.getApplicationInfo().packageName);
36
+ return constants;
37
+ }
38
+
39
+ @NonNull
40
+ @Override
41
+ public String getName() {
42
+ return "AuthsignalPushModule";
43
+ }
44
+
45
+ @ReactMethod
46
+ public void initialize(String tenantID, String baseURL, Promise promise) {
47
+ authsignalPush = new AuthsignalPush(tenantID, baseURL);
48
+
49
+ promise.resolve(null);
50
+ }
51
+
52
+ @ReactMethod
53
+ public void getCredential(Promise promise) {
54
+ if (authsignalPush != null) {
55
+ authsignalPush
56
+ .getCredentialAsync()
57
+ .thenAcceptAsync((response) -> {
58
+ if (response.getError() != null) {
59
+ promise.reject("getCredential error", response.getError());
60
+ } else {
61
+ PushCredential credential = response.getData();
62
+ WritableMap map = Arguments.createMap();
63
+ map.putString("credentialID", credential.getCredentialID());
64
+ map.putString("createdAt", credential.getCreatedAt());
65
+ map.putString("lastAuthenticatedAt", credential.getLastAuthenticatedAt());
66
+ promise.resolve(map);
67
+ }
68
+ });
69
+ } else {
70
+ Log.w(TAG, INIT_WARNING);
71
+
72
+ promise.resolve(null);
73
+ }
74
+ }
75
+
76
+ @ReactMethod
77
+ public void addCredential(String token, Promise promise) {
78
+ if (authsignalPush != null) {
79
+ authsignalPush
80
+ .addCredentialAsync(token, null)
81
+ .thenAcceptAsync(response -> {
82
+ if (response.getError() != null) {
83
+ promise.reject("addCredential error", response.getError());
84
+ } else {
85
+ promise.resolve(response.getData());
86
+ }
87
+ });
88
+ } else {
89
+ Log.w(TAG, INIT_WARNING);
90
+
91
+ promise.resolve(false);
92
+ }
93
+ }
94
+
95
+ @ReactMethod
96
+ public void removeCredential(Promise promise) {
97
+ if (authsignalPush != null) {
98
+ authsignalPush
99
+ .removeCredentialAsync()
100
+ .thenAcceptAsync(response -> {
101
+ if (response.getError() != null) {
102
+ promise.reject("removeCredential error", response.getError());
103
+ } else {
104
+ promise.resolve(response.getData());
105
+ }
106
+ });
107
+ } else {
108
+ Log.w(TAG, INIT_WARNING);
109
+
110
+ promise.resolve(false);
111
+ }
112
+ }
113
+
114
+ @ReactMethod
115
+ public void getChallenge(Promise promise) {
116
+ if (authsignalPush != null) {
117
+ authsignalPush
118
+ .getChallengeAsync()
119
+ .thenAcceptAsync(response -> {
120
+ if (response.getError() != null) {
121
+ promise.reject("getChallenge error", response.getError());
122
+ } else {
123
+ promise.resolve(response.getData());
124
+ }
125
+ });
126
+ } else {
127
+ Log.w(TAG, INIT_WARNING);
128
+
129
+ promise.resolve(null);
130
+ }
131
+ }
132
+
133
+ @ReactMethod
134
+ public void updateChallenge(
135
+ String challengeId,
136
+ Boolean approved,
137
+ String verificationCode,
138
+ Promise promise
139
+ ) {
140
+ if (authsignalPush != null) {
141
+ authsignalPush
142
+ .updateChallengeAsync(challengeId, approved, verificationCode)
143
+ .thenAcceptAsync(response -> {
144
+ if (response.getError() != null) {
145
+ promise.reject("updateChallenge error", response.getError());
146
+ } else {
147
+ promise.resolve(response.getData());
148
+ }
149
+ });
150
+ } else {
151
+ Log.w(TAG, INIT_WARNING);
152
+
153
+ promise.resolve(false);
154
+ }
155
+ }
156
+ }
@@ -0,0 +1 @@
1
+ #import <React/RCTBridgeModule.h>
@@ -20,8 +20,13 @@
20
20
 
21
21
  /* Begin PBXFileReference section */
22
22
  134814201AA4EA6300B7C361 /* libAuthsignal.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAuthsignal.a; sourceTree = BUILT_PRODUCTS_DIR; };
23
- B3E7B5891CC2AC0600A0062D /* Authsignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Authsignal.m; sourceTree = "<group>"; };
24
- D8CCAF332908C7A30040E0F0 /* Authsignal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Authsignal.h; sourceTree = "<group>"; };
23
+ B3E7B5891CC2AC0600A0062D /* AuthsignalModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthsignalModule.m; sourceTree = "<group>"; };
24
+ D8CCAF332908C7A30040E0F0 /* AuthsignalModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthsignalModule.h; sourceTree = "<group>"; };
25
+ D8EC5CD32A4D1EE00085B442 /* AuthsignalPasskeyModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthsignalPasskeyModule.swift; sourceTree = "<group>"; };
26
+ D8EC5CD42A4D1EE00085B442 /* AuthsignalPushModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthsignalPushModule.swift; sourceTree = "<group>"; };
27
+ D8EC5CD52A4D1EE00085B442 /* AuthsignalPushModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AuthsignalPushModule.m; sourceTree = "<group>"; };
28
+ D8EC5CD62A4D1EE00085B442 /* AuthsignalPasskeyModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AuthsignalPasskeyModule.m; sourceTree = "<group>"; };
29
+ D8EC5CD72A4D1EE90085B442 /* Authsignal-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Authsignal-Bridging-Header.h"; sourceTree = "<group>"; };
25
30
  /* End PBXFileReference section */
26
31
 
27
32
  /* Begin PBXFrameworksBuildPhase section */
@@ -46,8 +51,13 @@
46
51
  58B511D21A9E6C8500147676 = {
47
52
  isa = PBXGroup;
48
53
  children = (
49
- D8CCAF332908C7A30040E0F0 /* Authsignal.h */,
50
- B3E7B5891CC2AC0600A0062D /* Authsignal.m */,
54
+ D8EC5CD72A4D1EE90085B442 /* Authsignal-Bridging-Header.h */,
55
+ D8EC5CD62A4D1EE00085B442 /* AuthsignalPasskeyModule.m */,
56
+ D8EC5CD32A4D1EE00085B442 /* AuthsignalPasskeyModule.swift */,
57
+ D8EC5CD52A4D1EE00085B442 /* AuthsignalPushModule.m */,
58
+ D8EC5CD42A4D1EE00085B442 /* AuthsignalPushModule.swift */,
59
+ D8CCAF332908C7A30040E0F0 /* AuthsignalModule.h */,
60
+ B3E7B5891CC2AC0600A0062D /* AuthsignalModule.m */,
51
61
  134814211AA4EA7D00B7C361 /* Products */,
52
62
  );
53
63
  sourceTree = "<group>";
@@ -159,7 +169,7 @@
159
169
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
160
170
  GCC_WARN_UNUSED_FUNCTION = YES;
161
171
  GCC_WARN_UNUSED_VARIABLE = YES;
162
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
172
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
163
173
  MTL_ENABLE_DEBUG_INFO = YES;
164
174
  ONLY_ACTIVE_ARCH = YES;
165
175
  SDKROOT = iphoneos;
@@ -203,7 +213,7 @@
203
213
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
204
214
  GCC_WARN_UNUSED_FUNCTION = YES;
205
215
  GCC_WARN_UNUSED_VARIABLE = YES;
206
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
216
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
207
217
  MTL_ENABLE_DEBUG_INFO = NO;
208
218
  SDKROOT = iphoneos;
209
219
  VALIDATE_PRODUCT = YES;
@@ -0,0 +1,11 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ @import AuthenticationServices;
4
+
5
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
6
+ @interface AuthsignalModule : NSObject <RCTBridgeModule, ASWebAuthenticationPresentationContextProviding>
7
+ @end
8
+ #else
9
+ @interface AuthsignalModule : NSObject <RCTBridgeModule>
10
+ @end
11
+ #endif
@@ -1,11 +1,11 @@
1
- #import "Authsignal.h"
1
+ #import "AuthsignalModule.h"
2
2
  #import <React/RCTConvert.h>
3
3
 
4
- @interface Authsignal ()
4
+ @interface AuthsignalModule ()
5
5
  @property (strong, nonatomic) NSObject *session;
6
6
  @end
7
7
 
8
- @implementation Authsignal
8
+ @implementation AuthsignalModule
9
9
 
10
10
  RCT_EXPORT_MODULE();
11
11
 
@@ -0,0 +1,23 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <Foundation/Foundation.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(AuthsignalPasskeyModule, NSObject)
5
+
6
+ RCT_EXTERN_METHOD(initialize:(NSString)tenantID
7
+ withBaseURL:(NSString)baseURL
8
+ resolver:(RCTPromiseResolveBlock)resolve
9
+ rejecter:(RCTPromiseRejectBlock)reject)
10
+
11
+ RCT_EXTERN_METHOD(signUp:(NSString)token
12
+ withUserName:(NSString)userName
13
+ resolver:(RCTPromiseResolveBlock)resolve
14
+ rejecter:(RCTPromiseRejectBlock)reject)
15
+
16
+ RCT_EXTERN_METHOD(signIn:(NSString*)token
17
+ withAutofill:(BOOL)autofill
18
+ resolver:(RCTPromiseResolveBlock)resolve
19
+ rejecter:(RCTPromiseRejectBlock)reject)
20
+
21
+ RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(cancel)
22
+
23
+ @end
@@ -0,0 +1,77 @@
1
+ import Security
2
+ import Foundation
3
+ import Authsignal
4
+
5
+ @objc(AuthsignalPasskeyModule)
6
+ class AuthsignalPasskeyModule: NSObject {
7
+ var authsignal: AuthsignalPasskey?
8
+
9
+ @objc static func requiresMainQueueSetup() -> Bool {
10
+ return true
11
+ }
12
+
13
+ @objc func initialize(
14
+ _ tenantID: NSString,
15
+ withBaseURL baseURL: NSString,
16
+ resolver resolve: @escaping RCTPromiseResolveBlock,
17
+ rejecter reject: @escaping RCTPromiseRejectBlock
18
+ ) -> Void {
19
+ self.authsignal = AuthsignalPasskey(tenantID: tenantID as String, baseURL: baseURL as String)
20
+
21
+ resolve(nil)
22
+ }
23
+
24
+ @objc func signUp(
25
+ _ token: NSString,
26
+ withUserName userName: NSString,
27
+ resolver resolve: @escaping RCTPromiseResolveBlock,
28
+ rejecter reject: @escaping RCTPromiseRejectBlock
29
+ ) -> Void {
30
+ if (authsignal == nil) {
31
+ resolve(nil)
32
+ return
33
+ }
34
+
35
+ let tokenStr = token as String
36
+ let userNameStr = userName as String?
37
+
38
+ Task.init {
39
+ let response = await authsignal!.signUp(token: tokenStr, userName: userNameStr)
40
+
41
+ if (response.error != nil) {
42
+ reject("signUp error", response.error, nil)
43
+ } else {
44
+ resolve(response.data)
45
+ }
46
+ }
47
+ }
48
+
49
+ @objc func signIn(_ token: NSString?, withAutofill autofill: Bool, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
50
+ if (authsignal == nil) {
51
+ resolve(nil)
52
+ return
53
+ }
54
+
55
+ let tokenStr = token as String?
56
+
57
+ Task.init {
58
+ let response = await authsignal!.signIn(token: tokenStr, autofill: autofill)
59
+
60
+ if (response.error != nil) {
61
+ reject("signIn error", response.error, nil)
62
+ } else {
63
+ resolve(response.data)
64
+ }
65
+ }
66
+ }
67
+
68
+ @objc func cancel() -> NSString? {
69
+ authsignal?.cancel()
70
+
71
+ return nil
72
+ }
73
+
74
+ @objc func invalidate() -> Void {
75
+ authsignal?.cancel()
76
+ }
77
+ }
@@ -0,0 +1,30 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <Foundation/Foundation.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(AuthsignalPushModule, NSObject)
5
+
6
+ RCT_EXTERN_METHOD(initialize:(NSString)tenantID
7
+ withBaseURL:(NSString)baseURL
8
+ resolver:(RCTPromiseResolveBlock)resolve
9
+ rejecter:(RCTPromiseRejectBlock)reject)
10
+
11
+ RCT_EXTERN_METHOD(getCredential:(RCTPromiseResolveBlock)resolve
12
+ rejecter:(RCTPromiseRejectBlock)reject)
13
+
14
+ RCT_EXTERN_METHOD(addCredential:(NSString)token
15
+ resolver:(RCTPromiseResolveBlock)resolve
16
+ rejecter:(RCTPromiseRejectBlock)reject)
17
+
18
+ RCT_EXTERN_METHOD(removeCredential:(RCTPromiseResolveBlock)resolve
19
+ rejecter:(RCTPromiseRejectBlock)reject)
20
+
21
+ RCT_EXTERN_METHOD(getChallenge:(RCTPromiseResolveBlock)resolve
22
+ rejecter:(RCTPromiseRejectBlock)reject)
23
+
24
+ RCT_EXTERN_METHOD(updateChallenge:(NSString)challengeID
25
+ withApproval:(BOOL)approved
26
+ withVerificationCode:(NSString)verificationCode
27
+ resolver:(RCTPromiseResolveBlock)resolve
28
+ rejecter:(RCTPromiseRejectBlock)reject)
29
+
30
+ @end