UNPKG

@unito/integration-cli

Version:

Integration CLI

44 lines (41 loc) 1.57 kB
import { Credentials, Secrets } from '@unito/integration-sdk'; /** * Use this helper function to centralize the logic for getting the credentials from the context object. * For example, you might want to enrich the original object with some additional properties, or ensure * that some critical properties are present before proceeding. * * This function also ensures that your credentials are consistenly typed across your integration. * * As an example, to ensure access token is always set; * * ``` * if (!context.credentials.accessToken) { * throw new HttpErrors.UnauthorizedError('Missing access token'); * } * * return { accessToken: context.credentials.accessToken }; * ``` * * @param context The object containing the raw credentials * @returns The enriched credentials object */ export const getCredentials = (context: { credentials: Credentials }) => { return { // Tweak these properties to suit your needs }; }; /** * Use this helper function to centralize the logic for getting the secrets from the context object. * For example, you might want to enrich the original object with some additional properties, or ensure * that some critical properties are present before proceeding. * * This function also ensures that your secrets are consistenly typed across your integration. * * @param context The object containing the raw secrets * @returns The enriched secrets object */ export const getSecrets = (context: { secrets: Secrets }) => { return { // Tweak these properties to suit your needs }; };