import { NativeModules , NativeEventEmitter } from "react-native" ; import { CANCEL } from "@skygear/core" ; const { SGSkygearReactNative } = NativeModules ; const SGSkygearReactNativeEmitter = new NativeEventEmitter ( SGSkygearReactNative ) ; export function randomBytes ( length ) { return SGSkygearReactNative . randomBytes ( length ) ; } export function sha256String ( input ) { return SGSkygearReactNative . sha256String ( input ) ; } export function openURL ( url ) { return SGSkygearReactNative . openURL ( url ) ; } export async function openAuthorizeURL ( url , callbackURLScheme ) { try { const redirectURI = await SGSkygearReactNative . openAuthorizeURL ( url , callbackURLScheme ) ; await dismiss ( ) ; return redirectURI ; } catch ( e ) { if ( e . message === "CANCEL" ) { throw CANCEL ; } throw e ; } } export function dismiss ( ) { return SGSkygearReactNative . dismiss ( ) ; } export function signInWithApple ( url ) { return SGSkygearReactNative . signInWithApple ( url ) ; } export function getAnonymousKey ( kid ) { return SGSkygearReactNative . getAnonymousKey ( kid ) ; } export function signAnonymousToken ( kid , tokenData ) { return SGSkygearReactNative . signAnonymousToken ( kid , tokenData ) ; } public export function getCredentialStateForUserID ( userID ) { return SGSkygearReactNative . getCredentialStateForUserID ( userID ) ; } public export function addAppleIDCredentialRevokedListener ( listener ) { return SGSkygearReactNativeEmitter . addListener ( "SGSkygearReactNativeAppleIDCredentialRevokedNotification" , listener ) ; }