UNPKG

@samepage/backend

Version:

Backend utilities for the apis of SamePage integrations

22 lines 836 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const client_lambda_1 = require("@aws-sdk/client-lambda"); const types_1 = require("./types"); const lambda = new client_lambda_1.Lambda({ endpoint: process.env.AWS_ENDPOINT }); const getAccessToken = (payload) => { return lambda .invoke({ FunctionName: "samepage-network_access", Payload: Buffer.from(JSON.stringify(payload)), }) .then((res) => { var _a; const payload = Buffer.from((_a = res.Payload) !== null && _a !== void 0 ? _a : []).toString() || "{}"; if (res.FunctionError) { throw new Error(payload); } return types_1.zGetAccessTokenResponse.parse(JSON.parse(payload)); }); }; exports.default = getAccessToken; //# sourceMappingURL=getAccessToken.js.map