@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.
@@ -133,10 +133,9 @@ function buildQueryString(query) {
133
133
  async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
134
134
  const base = apiBaseUrl.replace(/\/$/, "");
135
135
  const url = `${base}${opts.path}${buildQueryString(opts.query)}`;
136
- const m2mToken = await tokenManager.getAccessToken();
137
- const bearerToken = opts.sessionBearer ?? m2mToken;
136
+ const token = await tokenManager.getAccessToken();
138
137
  const headers = {
139
- Authorization: `Bearer ${bearerToken}`,
138
+ Authorization: `Bearer ${token}`,
140
139
  Accept: "application/json"
141
140
  };
142
141
  if (opts.body !== void 0) headers["Content-Type"] = "application/json";
@@ -146,15 +145,14 @@ async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
146
145
  headers
147
146
  };
148
147
  if (opts.body !== void 0) init.body = JSON.stringify(opts.body);
149
- const onTokenExpired = opts.sessionBearer ? void 0 : async () => {
150
- await tokenManager.invalidate();
151
- const fresh = await tokenManager.getAccessToken();
152
- headers.Authorization = `Bearer ${fresh}`;
153
- };
154
148
  const res = await retryFetch(url, init, {
155
149
  fetch: fetchImpl,
156
150
  timeoutMs: opts.timeoutMs,
157
- onTokenExpired
151
+ onTokenExpired: async () => {
152
+ await tokenManager.invalidate();
153
+ const fresh = await tokenManager.getAccessToken();
154
+ headers.Authorization = `Bearer ${fresh}`;
155
+ }
158
156
  });
159
157
  let body = null;
160
158
  const text = await res.text();
@@ -932,27 +930,6 @@ function createHellobillHandler(opts) {
932
930
  if (!result2) return;
933
931
  passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
934
932
  };
935
- const loaDocument = async (req, res) => {
936
- const rawLoa = req.query.loa_id ?? req.params?.id;
937
- const loaId = Array.isArray(rawLoa) ? rawLoa[0] : rawLoa;
938
- if (!loaId) {
939
- sendError(res, 400, "validation.missing_required_field", "loa_id query parameter required");
940
- return;
941
- }
942
- const sessionBearer = extractBearer(req);
943
- if (!sessionBearer) {
944
- sendError(res, 401, "auth.token_malformed", "Missing Authorization bearer token");
945
- return;
946
- }
947
- const result2 = await safeCallUpstream(res, {
948
- method: "GET",
949
- path: `/partner/loa/${encodeURIComponent(loaId)}/document`,
950
- sessionBearer,
951
- logger
952
- });
953
- if (!result2) return;
954
- passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
955
- };
956
933
  const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
957
934
  const result = {
958
935
  session,
@@ -964,8 +941,7 @@ function createHellobillHandler(opts) {
964
941
  property,
965
942
  sessions: { list: sessionsList, get: sessionsGet },
966
943
  savingsSummary,
967
- serviceSlots,
968
- loaDocument
944
+ serviceSlots
969
945
  };
970
946
  if (webhookHandler !== void 0) {
971
947
  result.webhook = webhookHandler;
@@ -1094,12 +1070,6 @@ function createHellobillHandler2(opts) {
1094
1070
  await handlers.sessions.list(hbReq, res);
1095
1071
  } else if (segment === "sessions" && slug[1] && method === "GET") {
1096
1072
  await handlers.sessions.get(hbReq, res);
1097
- } else if (segment === "service-slots" && method === "GET") {
1098
- await handlers.serviceSlots(hbReq, res);
1099
- } else if (segment === "savings-summary" && method === "GET") {
1100
- await handlers.savingsSummary(hbReq, res);
1101
- } else if (segment === "loa-document" && method === "GET") {
1102
- await handlers.loaDocument(hbReq, res);
1103
1073
  } else if (segment === "webhooks" && method === "POST" && handlers.webhook) {
1104
1074
  await handlers.webhook(hbReq, res);
1105
1075
  } else if (segment === "webhooks" && method === "POST" && !handlers.webhook) {