From 00702941d7ee69d8b2469689e9c7c39a8b3b6097 Mon Sep 17 00:00:00 2001 From: julien mounier Date: Tue, 26 Apr 2022 11:15:01 +0200 Subject: [PATCH] feat(psc): expose setOidcTestNonce --- .../ClientReactNativeModule.kt | 5 +++++ ios/ClientReactNative.m | 13 +++++++++++++ src/native.ts | 1 + src/nativeWrapper.ts | 6 ++++++ 4 files changed, 25 insertions(+) diff --git a/android/src/main/java/com/tankerclientreactnative/ClientReactNativeModule.kt b/android/src/main/java/com/tankerclientreactnative/ClientReactNativeModule.kt index 92c37b5..41c83b1 100644 --- a/android/src/main/java/com/tankerclientreactnative/ClientReactNativeModule.kt +++ b/android/src/main/java/com/tankerclientreactnative/ClientReactNativeModule.kt @@ -130,6 +130,11 @@ class ClientReactNativeModule(reactContext: ReactApplicationContext) : return getTanker(handle).createOidcNonce().bridge(promise) } + @ReactMethod() + fun setOidcTestNonce(handle: TankerHandle, nonce: String, promise: Promise) { + return getTanker(handle).setOidcTestNonce(nonce).bridge(promise) + } + @ReactMethod() fun registerIdentity( handle: TankerHandle, diff --git a/ios/ClientReactNative.m b/ios/ClientReactNative.m index c205ccd..d3ad9ab 100644 --- a/ios/ClientReactNative.m +++ b/ios/ClientReactNative.m @@ -136,6 +136,19 @@ -(void) stopObserving { }]; } +RCT_REMAP_METHOD(setOidcTestNonce, setOidcTestNonceWithTankerHandle:(nonnull NSNumber*)handle nonce:(nonnull NSString*)nonce resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) +{ + TKRTanker* tanker = [self.tankerInstanceMap objectForKey:handle]; + if (!tanker) + return rejectInvalidHandle(reject, handle); + + [tanker setOidcTestNonce:nonce completionHandler:^(NSError * _Nullable err) { + if (err != nil) + return rejectWithError(reject, err); + resolve(nil); + }]; +} + RCT_REMAP_METHOD(registerIdentity, registerIdentityWithTankerHandle:(nonnull NSNumber*)handle verification:(nonnull NSDictionary*)verificationDict diff --git a/src/native.ts b/src/native.ts index a11993e..d0bf327 100644 --- a/src/native.ts +++ b/src/native.ts @@ -26,6 +26,7 @@ type ClientReactNativeType = { start(instance: NativeTanker, identity: String): Promise; stop(instance: NativeTanker): Promise; createOidcNonce(instance: NativeTanker): Promise; + setOidcTestNonce(instance: NativeTanker, nonce: string): Promise; registerIdentity( instance: NativeTanker, verification: Verification, diff --git a/src/nativeWrapper.ts b/src/nativeWrapper.ts index 3970ee6..91b825b 100644 --- a/src/nativeWrapper.ts +++ b/src/nativeWrapper.ts @@ -67,6 +67,12 @@ export class Tanker { return bridgeAsyncExceptions(Native.createOidcNonce(this.getInstance())); } + async setOidcTestNonce(nonce: string): Promise { + return bridgeAsyncExceptions( + Native.setOidcTestNonce(this.getInstance(), nonce) + ); + } + async registerIdentity( verification: Verification, options?: VerificationOptions