Options
All
  • Public
  • Public/Protected
  • All
Menu

External module scripts/permissions

Manage optional permissions

Index

Variables

Const GOOGLE_SOURCE_ORIGIN

GOOGLE_SOURCE_ORIGIN: "https://*.googleusercontent.com/" = "https://*.googleusercontent.com/"

Origin for the actual url's we retrieve for google photos

Const UNSPLASH_SOURCE_ORIGIN

UNSPLASH_SOURCE_ORIGIN: "https://images.unsplash.com/" = "https://images.unsplash.com/"

Origin for the actual url's we retrieve for Unsplash

Const chromep

chromep: ChromePromise = new ChromePromise()

Functions

contains

  • contains(type: IType): Promise<boolean>
  • Determine if we have an optional permission

    throws

    An error if failed to get status

    Parameters

    • type: IType

      permission type

    Returns Promise<boolean>

    true if we have the permission

deny

  • deny(type: IType): Promise<boolean>
  • Remove and deny an optional permission

    throws

    An error if failed to deny

    Parameters

    • type: IType

      permission type

    Returns Promise<boolean>

    true if removed

hasGoogleSourceOrigin

  • hasGoogleSourceOrigin(): Promise<boolean>
  • Determine if we have permissions for Google photos baseUrl's origin

    Returns Promise<boolean>

    true if we have the permission

hasUnsplashSourceOrigin

  • hasUnsplashSourceOrigin(): Promise<boolean>
  • Determine if we have permissions for unsplash origin

    Returns Promise<boolean>

    true if we have the permission

isAllowed

  • isAllowed(type: IType): boolean
  • Has the user allowed the optional permissions

    Parameters

    • type: IType

      permission type

    Returns boolean

    true if allowed

isGoogleSourceOrigin

  • isGoogleSourceOrigin(url: string): Promise<boolean>
  • Determine if we have permissions for Google photos baseUrl's origin and the url matches

    Parameters

    • url: string

    Returns Promise<boolean>

    true if we we have permission and valid url

isInOrigins

  • isInOrigins(url: string, type: IType): boolean
  • Determine if a url is contained in the permission's origins

    Parameters

    • url: string

      url to check

    • type: IType

      Permission type

    Returns boolean

notSet

  • notSet(type: IType): boolean
  • Has user not made a choice on a permission yet

    Parameters

    • type: IType

      permission type

    Returns boolean

    true if notSet

remove

  • remove(type: IType): Promise<boolean>
  • Remove an optional permission

    remarks

    Chrome doesn't actually remove an optional permission once it has been granted

    throws

    An error if failed to remove

    Parameters

    • type: IType

      permission type

    Returns Promise<boolean>

    true if removed

removeGooglePhotos

  • removeGooglePhotos(): Promise<void>
  • Remove, deny, and clear photo selections for Google Photos

    throws

    An error on failure

    Returns Promise<void>

request

  • request(type: IType): Promise<boolean>
  • Request optional permission

    throws

    An error if request failed

    Parameters

    • type: IType

      permission type

    Returns Promise<boolean>

    true if permission granted

setState

  • setState(type: IType, value: STATE): Promise<void>

Object literals

Const BACKGROUND

BACKGROUND: object

Permission for Chrome running in background

name

name: string = "permBackground"

origins

origins: never[] = []

permissions

permissions: string[] = ['background']

Const DETECT_FACES

DETECT_FACES: object

Permission for detecting faces in photos

name

name: string = "permDetectFaces"

origins

origins: string[] = [GOOGLE_SOURCE_ORIGIN,UNSPLASH_SOURCE_ORIGIN,'https://*.redd.it/','https://live.staticflickr.com/',]

permissions

permissions: never[] = []

Const GOOGLE_PHOTOS

GOOGLE_PHOTOS: object

Permission for access to the user's Google Photos

remarks

Once upon a time, Picasa was the API for access to Google Photos, hence the name. Included 'https://*.googleusercontent.com/' so we can get error status when photos fail to load (cors thing). User's who authorized before this was added will not be required to allow it. They could be, but it might be confusing for the user.

name

name: string = "permPicasa"

origins

origins: string[] = ['https://photoslibrary.googleapis.com/',GOOGLE_SOURCE_ORIGIN,]

permissions

permissions: never[] = []

Const WEATHER

WEATHER: object

Permission for weather

remarks

geolocation can't be optional permission in chrome, so we need to use the permissions API

name

name: string = "permWeather"

origins

origins: string[] = ['https://api.openweathermap.org/']

permissions

permissions: never[] = []

Generated using TypeDoc