Options
All
  • Public
  • Public/Protected
  • All
Menu
description

This class contains methods for connecting, linking accounts to the providers usage example can be found in OAuthController

since

v0.2.0

Hierarchy

  • OAuthService

Index

Constructors

Methods

  • This method executes a basic HTTP handler that uses axios under the hood, to execute a HTTP request to a remote data provider API. This method can be used to request specific endpoints from the providers API, e.g. /activities/:id from Strava.

    Note that the access token attached to the request as an Authorization header (Bearer), is the one from the integration parameter. This permits to execute requests using the account's valid OAuth authorization.

    Note that you do not need to add an access token header in the options parameters, it will be added automatically whenever you use this method.

    access

    public

    async
    throws

    {HttpException} HTTP 403 - Forbidden: Given missing oauth authorization from getIntegration.

    Parameters

    • endpointUri: string

      The endpoint URI that must be requested from the remote data provider API.

    • integration: AccountIntegrationDocument

      The accountintegrations entity that will be updated.

    • httpOptions: { body?: any; headers?: any; method: HttpMethod; options?: any } = ...
      • Optional body?: any
      • Optional headers?: any
      • method: HttpMethod
      • Optional options?: any

    Returns Promise<ResponseStatusDTO>

    A response object that contains a status, code and response as defined in ResponseStatusDTO.

  • This method determines and creates an OAuth driver from the inputs' provider name and config and returns a OAuthDriver object.

    access

    private

    Parameters

    • providerName: string

      Contains the identifier of the OAuth Provider, e.g. "strava".

    • providerConfig: OAuthProviderParameters

      The OAuth provider parameters, i.e. URLs and configuration.

    Returns OAuthDriver

    The created driver instance.

  • Method to extract and transform an entity as described by the data provider API. Typically, this method is used to handle transformations of remote objects (from data provider API) to internal objects in the backend runtime's database.

    e.g. This method is used to transform activity data as defined by the Strava API, into ActivityData as defined internally.

    access

    public

    Parameters

    • providerName: string

      Contains the identifier of the OAuth Provider, e.g. "strava".

    • data: any

      The API Response object that will be transformed.

    • Optional type: OAuthEntityType

      (Optional) The type of entity as described in OAuthEntityType.

    Returns OAuthEntity

    A parsed entity object.

  • getAuthorizeURL(providerName: string, dhealthAddress: string, referralCode?: string): string
  • Method to returns the remote authorization URL to link accounts e.g. "Strava OAuth URL".

    access

    public

    Parameters

    • providerName: string

      Contains the identifier of the OAuth Provider, e.g. "strava".

    • dhealthAddress: string

      The Address of the user account on dHealth Network.

    • Optional referralCode: string

      The provided referral code.

    Returns string

    The remote authorization URL to link accounts.

  • Generate an encryption password (seed) to protect the access token using a combination of the authentication secret, the user address and Strava-owned authentication details.

    access

    private

    Parameters

    • integration: AccountIntegrationDocument

      The document of OAuth integration.

    • remoteIdentifier: string

      The remote identifier of the end-user (remote as in "from Strava").

    Returns string

    The generated encryption seed.

  • This method sends an OAuth callback request to the provider and stores the integration result's details in database.

    Note that this process includes requesting an access/refresh token from the provider and creating an encryption password that will be used to sign the access/refresh tokens pair.

    access

    public

    async
    throws

    {HttpException} HTTP 403 - Forbidden: Given missing oauth authorization from getIntegration.

    Parameters

    • providerName: string

      Contains the identifier of the OAuth Provider, e.g. "strava".

    • account: AccountDocument

      The account document to be integrated with access/refresh tokens.

    • request: OAuthCallbackRequest

      The OAuth callback request.

    Returns Promise<AccountIntegrationDocument>

    The result account integration document that has been saved.

  • This method sends an OAuth access token refresh request to the provider and stores the integration result's details in database.

    Note that this process includes requesting an access/refresh token from the provider and creating an encryption password that will be used to sign the access/refresh tokens pair.

    access

    public

    async
    throws

    {HttpException} HTTP 403 - Forbidden: Given missing oauth authorization from integration parameter.

    Parameters

    • providerName: string

      Contains the identifier of the OAuth Provider, e.g. "strava".

    • integration: AccountIntegrationDocument

      The accountintegrations entity that will be updated.

    Returns Promise<AccountIntegrationDocument>

    The resulting account integration document that has been saved.

Generated using TypeDoc