Project

General

Profile

Actions

Task #12075

closed

Earn Alliance Register kampan

Added by Michal Hornak almost 2 years ago. Updated over 1 year ago.

Status:
Done
Priority:
Normal
Assignee:
Category:
Backend
Target version:
WWW - V3 - integrated custody L10
Start date:
07/10/2023
Due date:
% Done:

100%

Estimated time:
custom category:
Backend
Co-assignee:
Sprint:
#5 summer is here (Jul 03 - Jul 17)

Description

Documentation

https://docs.google.com/document/d/1DRugdiiHMwcQSt4Z9AvDXZ1nep9rjWY3_2dP1Cn2SAA/edit

Credentials

export const EARN_ALLIANCE_SETTINGS = {
  clientId: '46a72344-dc3d-42b9-8372-498666caadb9',
  clientSecret: 'e9hnAaN520e2VbHCN9gUvckXZJntNvq6',
  gameId: 'b2a0d439-414a-4f2d-aa2d-c2eb8fac56ea',
};

JS Example

private callCustomEvent(event: string) {
    const requestBody: EACustomEventRequestBody = {
      gameId: EARN_ALLIANCE_SETTINGS.gameId,
      event: event,
      address: this.walletAddres.value(),
      time: new Date().toISOString(),
    };

    const headers = new HttpHeaders({
      'x-client-id': EARN_ALLIANCE_SETTINGS.clientId,
      'x-timestapm': String(new Date().getMilliseconds()),
      'x-signature': this.generateSignature(requestBody),
    });

    return this.request.post(
      `${this.endpoint}${CUSTOM_EVENT_API}`,
      requestBody,
      { headers }
    );
  }

  private generateSignature(body) {
    const ts = Date.now();
    const message = `${EARN_ALLIANCE_SETTINGS.clientId}${ts}${JSON.stringify(
      body
    )}`;
    return HmacSHA256(message, EARN_ALLIANCE_SETTINGS.clientSecret).toString();
  }
Actions

Also available in: Atom PDF