1import * as Linking from 'expo-linking'; 2import * as WebBrowser from 'expo-web-browser'; 3import React from 'react'; 4 5import FunctionDemo, { FunctionDescription } from '../../components/FunctionDemo'; 6 7const FUNCTION_DESCRIPTION: FunctionDescription = { 8 name: 'openAuthSessionAsync', 9 parameters: [ 10 { 11 name: 'url', 12 type: 'constant', 13 value: 'url', 14 }, 15 { name: 'redirectUrl', type: 'constant', value: Linking.createURL('redirect') }, 16 { 17 name: 'options', 18 type: 'object', 19 properties: [ 20 { name: 'createTask', type: 'boolean', initial: true }, 21 { name: 'preferEphemeralSession', type: 'boolean', platforms: ['ios'], initial: false }, 22 ], 23 }, 24 ], 25 additionalParameters: [{ name: 'shouldPrompt', type: 'boolean', initial: false }], 26 actions: ( 27 _: string, 28 redirectUrl: string, 29 options: WebBrowser.WebBrowserOpenOptions, 30 shouldPrompt: boolean 31 ) => { 32 const url = `https://fake-auth.netlify.com?state=faker&redirect_uri=${encodeURIComponent( 33 redirectUrl 34 )}&prompt=${shouldPrompt ? 'consent' : 'none'}`; 35 return WebBrowser.openAuthSessionAsync(url, redirectUrl, options); 36 }, 37}; 38 39export default function OpenAuthSessionAsyncDemo() { 40 return <FunctionDemo namespace="WebBrowser" {...FUNCTION_DESCRIPTION} />; 41} 42