Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import type {IChatAccountMap} from '@feasibleone/blong/types';
import {library} from '@feasibleone/blong/types';
import {chatAccountBase, chatAccountName} from '../../../chatAccounts.ts';
/**
* Which auth token a call is made with.
*
* Viber's token authenticates both directions, so the same lookup serves the API call and the reply's
* signature key. An alias nothing matches answers `undefined`, and the caller reports it with its own
* typed error.
*/
export const viberTokenGet = (
accounts: IChatAccountMap | undefined,
account?: string,
): string | undefined => {
const name = chatAccountName(accounts, account);
return name ? accounts?.[name]?.authToken : undefined;
};
/** The API base this account posts to — its own, or the port's (`@@D-687`). */
export const viberBaseGet = (
accounts: IChatAccountMap | undefined,
account: string | undefined,
fallback?: string,
): string => chatAccountBase(accounts, account, fallback) ?? 'https://chatapi.viber.com/pa/';
export default library(() => ({viberTokenGet, viberBaseGet}));
|