about summary refs log tree commit diff
path: root/src/api/auth.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-06-15 17:40:18 -0500
committerPaul Frazee <pfrazee@gmail.com>2022-06-15 17:40:18 -0500
commit77b938845aa909a70f896b759b04ba7c1b1d9aa6 (patch)
tree0d5f65c3efa2c7702f4c5eee024248b73ec36f07 /src/api/auth.ts
parentb2dd8d4f440243ac2eb12e7013d5a024b4e95f07 (diff)
downloadvoidsky-77b938845aa909a70f896b759b04ba7c1b1d9aa6.tar.zst
Polyfills for native crypto
Diffstat (limited to 'src/api/auth.ts')
-rw-r--r--src/api/auth.ts68
1 files changed, 0 insertions, 68 deletions
diff --git a/src/api/auth.ts b/src/api/auth.ts
deleted file mode 100644
index 60ff1a3f2..000000000
--- a/src/api/auth.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import {Linking} from 'react-native'
-import * as auth from '@adxp/auth'
-import {InAppBrowser} from 'react-native-inappbrowser-reborn'
-import {isWeb} from '../platform/detection'
-import {makeAppUrl} from '../platform/urls'
-import * as env from '../env'
-
-const SCOPE = auth.writeCap(
-  'did:key:z6MkfRiFMLzCxxnw6VMrHK8pPFt4QAHS3jX3XM87y9rta6kP',
-  'did:example:microblog',
-)
-
-export async function isAuthed(authStore: auth.BrowserStore) {
-  return await authStore.hasUcan(SCOPE)
-}
-
-export async function logout(authStore: auth.BrowserStore) {
-  await authStore.reset()
-}
-
-export async function parseUrlForUcan() {
-  // @ts-ignore window is defined -prf
-  const fragment = window.location.hash
-  if (fragment.length < 1) {
-    return undefined
-  }
-  try {
-    const ucan = await auth.parseLobbyResponseHashFragment(fragment)
-    // @ts-ignore window is defined -prf
-    window.location.hash = ''
-    return ucan
-  } catch (err) {
-    return undefined
-  }
-}
-
-export async function requestAppUcan(authStore: auth.BrowserStore) {
-  const did = await authStore.getDid()
-  const returnUrl = makeAppUrl()
-  const fragment = auth.requestAppUcanHashFragment(did, SCOPE, returnUrl)
-  const url = `${env.AUTH_LOBBY}#${fragment}`
-
-  if (isWeb) {
-    // @ts-ignore window is defined -prf
-    window.location.href = url
-    return false
-  }
-
-  if (await InAppBrowser.isAvailable()) {
-    const res = await InAppBrowser.openAuth(url, returnUrl, {
-      // iOS Properties
-      ephemeralWebSession: false,
-      // Android Properties
-      showTitle: false,
-      enableUrlBarHiding: true,
-      enableDefaultShare: false,
-    })
-    if (res.type === 'success' && res.url) {
-      Linking.openURL(res.url)
-    } else {
-      console.error('Bad response', res)
-      return false
-    }
-  } else {
-    Linking.openURL(url)
-  }
-  return true
-}