import { AccessToken2, ServiceFpa } from './AccessToken2';

export class FpaTokenBuilder {
  /**
   * Build the FPA token.
   * @param appId - The App ID issued to you by Agora.
   * @param appCertificate - Certificate of the application that you registered in the Agora Dashboard.
   * @returns The FPA token.
   */
  public static buildToken(appId: string, appCertificate: string): string {
    const token = new AccessToken2(appId, appCertificate, 0, 24 * 3600);

    const serviceFpa = new ServiceFpa();
    serviceFpa.add_privilege(ServiceFpa.kPrivilegeLogin, 0);
    token.add_service(serviceFpa);

    return token.build();
  }
}
