@hello-bill/node 2.1.3-beta.0 → 2.1.3

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.
@@ -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();
@@ -930,27 +928,6 @@ function createHellobillHandler(opts) {
930
928
  if (!result2) return;
931
929
  passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
932
930
  };
933
- const loaDocument = async (req, res) => {
934
- const rawLoa = req.query.loa_id ?? req.params?.id;
935
- const loaId = Array.isArray(rawLoa) ? rawLoa[0] : rawLoa;
936
- if (!loaId) {
937
- sendError(res, 400, "validation.missing_required_field", "loa_id query parameter required");
938
- return;
939
- }
940
- const sessionBearer = extractBearer(req);
941
- if (!sessionBearer) {
942
- sendError(res, 401, "auth.token_malformed", "Missing Authorization bearer token");
943
- return;
944
- }
945
- const result2 = await safeCallUpstream(res, {
946
- method: "GET",
947
- path: `/partner/loa/${encodeURIComponent(loaId)}/document`,
948
- sessionBearer,
949
- logger
950
- });
951
- if (!result2) return;
952
- passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
953
- };
954
931
  const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
955
932
  const result = {
956
933
  session,
@@ -962,8 +939,7 @@ function createHellobillHandler(opts) {
962
939
  property,
963
940
  sessions: { list: sessionsList, get: sessionsGet },
964
941
  savingsSummary,
965
- serviceSlots,
966
- loaDocument
942
+ serviceSlots
967
943
  };
968
944
  if (webhookHandler !== void 0) {
969
945
  result.webhook = webhookHandler;
@@ -1092,12 +1068,6 @@ function createHellobillHandler2(opts) {
1092
1068
  await handlers.sessions.list(hbReq, res);
1093
1069
  } else if (segment === "sessions" && slug[1] && method === "GET") {
1094
1070
  await handlers.sessions.get(hbReq, res);
1095
- } else if (segment === "service-slots" && method === "GET") {
1096
- await handlers.serviceSlots(hbReq, res);
1097
- } else if (segment === "savings-summary" && method === "GET") {
1098
- await handlers.savingsSummary(hbReq, res);
1099
- } else if (segment === "loa-document" && method === "GET") {
1100
- await handlers.loaDocument(hbReq, res);
1101
1071
  } else if (segment === "webhooks" && method === "POST" && handlers.webhook) {
1102
1072
  await handlers.webhook(hbReq, res);
1103
1073
  } else if (segment === "webhooks" && method === "POST" && !handlers.webhook) {