about summary refs log tree commit diff
path: root/src/platform/auth-flow.ts
blob: fbc85a3733da71dcbb7ca22d4acfa6d5697f4dc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import * as auth from '@adxp/auth'
import * as ucan from 'ucans'
import {makeAppUrl} from '../platform/urls'
import {ReactNativeStore} from '../state/lib/auth'
import * as env from '../env'

export async function requestAppUcan(
  authStore: ReactNativeStore,
  scope: ucan.Capability,
) {
  const did = await authStore.getDid()
  const returnUrl = makeAppUrl()
  const fragment = auth.requestAppUcanHashFragment(did, scope, returnUrl)
  const url = `${env.AUTH_LOBBY}#${fragment}`

  // @ts-ignore window is defined -prf
  window.location.href = url
  return false
}