private async _awsRealTimeHeaderBasedAuth()

in packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts [410:454]


  private async _awsRealTimeHeaderBasedAuth({
    authenticationType,
    payload,
    canonicalUri,
    appSyncGraphqlEndpoint,
    apiKey,
    region,
    credentials,
    token,
    graphql_headers
  }) {
    const headerHandler: Record<
      string,
      (info: any) => Promise<Record<string, string>>
    > = {
      API_KEY: this._awsRealTimeApiKeyHeader.bind(this),
      AWS_IAM: this._awsRealTimeIAMHeader.bind(this),
      OPENID_CONNECT: this._awsRealTimeAuthorizationHeader.bind(this),
      AMAZON_COGNITO_USER_POOLS: this._awsRealTimeAuthorizationHeader.bind(this),
      AWS_LAMBDA: this._awsRealTimeAuthorizationHeader.bind(this)
    };

    const handler = headerHandler[authenticationType];

    if (typeof handler !== "function") {
      logger(`Authentication type ${authenticationType} not supported`);
      return {};
    }

    const { host } = url.parse(appSyncGraphqlEndpoint);

    const result = await handler({
      payload,
      canonicalUri,
      appSyncGraphqlEndpoint,
      apiKey,
      region,
      host,
      credentials,
      token,
      graphql_headers
    });

    return result;
  }