@hello-bill/node 2.1.2-beta.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -131,10 +131,9 @@ function buildQueryString(query) {
131
131
  async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
132
132
  const base = apiBaseUrl.replace(/\/$/, "");
133
133
  const url = `${base}${opts.path}${buildQueryString(opts.query)}`;
134
- const m2mToken = await tokenManager.getAccessToken();
135
- const bearerToken = opts.sessionBearer ?? m2mToken;
134
+ const token = await tokenManager.getAccessToken();
136
135
  const headers = {
137
- Authorization: `Bearer ${bearerToken}`,
136
+ Authorization: `Bearer ${token}`,
138
137
  Accept: "application/json"
139
138
  };
140
139
  if (opts.body !== void 0) headers["Content-Type"] = "application/json";
@@ -144,15 +143,14 @@ async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
144
143
  headers
145
144
  };
146
145
  if (opts.body !== void 0) init.body = JSON.stringify(opts.body);
147
- const onTokenExpired = opts.sessionBearer ? void 0 : async () => {
148
- await tokenManager.invalidate();
149
- const fresh = await tokenManager.getAccessToken();
150
- headers.Authorization = `Bearer ${fresh}`;
151
- };
152
146
  const res = await retryFetch(url, init, {
153
147
  fetch: fetchImpl,
154
148
  timeoutMs: opts.timeoutMs,
155
- onTokenExpired
149
+ onTokenExpired: async () => {
150
+ await tokenManager.invalidate();
151
+ const fresh = await tokenManager.getAccessToken();
152
+ headers.Authorization = `Bearer ${fresh}`;
153
+ }
156
154
  });
157
155
  let body = null;
158
156
  const text = await res.text();
@@ -972,27 +970,6 @@ function createHellobillHandler(opts) {
972
970
  if (!result2) return;
973
971
  passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
974
972
  };
975
- const loaDocument = async (req, res) => {
976
- const rawLoa = req.query.loa_id ?? req.params?.id;
977
- const loaId = Array.isArray(rawLoa) ? rawLoa[0] : rawLoa;
978
- if (!loaId) {
979
- sendError(res, 400, "validation.missing_required_field", "loa_id query parameter required");
980
- return;
981
- }
982
- const sessionBearer = extractBearer(req);
983
- if (!sessionBearer) {
984
- sendError(res, 401, "auth.token_malformed", "Missing Authorization bearer token");
985
- return;
986
- }
987
- const result2 = await safeCallUpstream(res, {
988
- method: "GET",
989
- path: `/partner/loa/${encodeURIComponent(loaId)}/document`,
990
- sessionBearer,
991
- logger
992
- });
993
- if (!result2) return;
994
- passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
995
- };
996
973
  const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
997
974
  const result = {
998
975
  session,
@@ -1004,8 +981,7 @@ function createHellobillHandler(opts) {
1004
981
  property,
1005
982
  sessions: { list: sessionsList, get: sessionsGet },
1006
983
  savingsSummary,
1007
- serviceSlots,
1008
- loaDocument
984
+ serviceSlots
1009
985
  };
1010
986
  if (webhookHandler !== void 0) {
1011
987
  result.webhook = webhookHandler;