@hello-bill/node 2.1.3 → 2.1.4-beta.0
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/express/index.d.cts +1 -1
- package/dist/express/index.d.ts +1 -1
- package/dist/express/index.js +35 -8
- package/dist/express/index.js.map +1 -1
- package/dist/express/index.mjs +35 -8
- package/dist/express/index.mjs.map +1 -1
- package/dist/hono/index.d.cts +1 -1
- package/dist/hono/index.d.ts +1 -1
- package/dist/hono/index.js +35 -8
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/index.mjs +35 -8
- package/dist/hono/index.mjs.map +1 -1
- package/dist/{index-D5WlUYVZ.d.cts → index-C_gIXrzG.d.cts} +7 -0
- package/dist/{index-jK9cEnEY.d.ts → index-DnEk4Y5R.d.ts} +7 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -8
- package/dist/index.mjs.map +1 -1
- package/dist/koa/index.d.cts +1 -1
- package/dist/koa/index.d.ts +1 -1
- package/dist/koa/index.js +35 -8
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/index.mjs +35 -8
- package/dist/koa/index.mjs.map +1 -1
- package/dist/next/index.d.cts +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/next/index.js +38 -8
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +38 -8
- package/dist/next/index.mjs.map +1 -1
- package/dist/webhook/index.d.cts +1 -1
- package/dist/webhook/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/next/index.mjs
CHANGED
|
@@ -131,9 +131,10 @@ 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
|
|
134
|
+
const m2mToken = await tokenManager.getAccessToken();
|
|
135
|
+
const bearerToken = opts.sessionBearer ?? m2mToken;
|
|
135
136
|
const headers = {
|
|
136
|
-
Authorization: `Bearer ${
|
|
137
|
+
Authorization: `Bearer ${bearerToken}`,
|
|
137
138
|
Accept: "application/json"
|
|
138
139
|
};
|
|
139
140
|
if (opts.body !== void 0) headers["Content-Type"] = "application/json";
|
|
@@ -143,14 +144,15 @@ async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
|
|
|
143
144
|
headers
|
|
144
145
|
};
|
|
145
146
|
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
|
+
};
|
|
146
152
|
const res = await retryFetch(url, init, {
|
|
147
153
|
fetch: fetchImpl,
|
|
148
154
|
timeoutMs: opts.timeoutMs,
|
|
149
|
-
onTokenExpired
|
|
150
|
-
await tokenManager.invalidate();
|
|
151
|
-
const fresh = await tokenManager.getAccessToken();
|
|
152
|
-
headers.Authorization = `Bearer ${fresh}`;
|
|
153
|
-
}
|
|
155
|
+
onTokenExpired
|
|
154
156
|
});
|
|
155
157
|
let body = null;
|
|
156
158
|
const text = await res.text();
|
|
@@ -928,6 +930,27 @@ function createHellobillHandler(opts) {
|
|
|
928
930
|
if (!result2) return;
|
|
929
931
|
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
930
932
|
};
|
|
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
|
+
};
|
|
931
954
|
const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
|
|
932
955
|
const result = {
|
|
933
956
|
session,
|
|
@@ -939,7 +962,8 @@ function createHellobillHandler(opts) {
|
|
|
939
962
|
property,
|
|
940
963
|
sessions: { list: sessionsList, get: sessionsGet },
|
|
941
964
|
savingsSummary,
|
|
942
|
-
serviceSlots
|
|
965
|
+
serviceSlots,
|
|
966
|
+
loaDocument
|
|
943
967
|
};
|
|
944
968
|
if (webhookHandler !== void 0) {
|
|
945
969
|
result.webhook = webhookHandler;
|
|
@@ -1068,6 +1092,12 @@ function createHellobillHandler2(opts) {
|
|
|
1068
1092
|
await handlers.sessions.list(hbReq, res);
|
|
1069
1093
|
} else if (segment === "sessions" && slug[1] && method === "GET") {
|
|
1070
1094
|
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);
|
|
1071
1101
|
} else if (segment === "webhooks" && method === "POST" && handlers.webhook) {
|
|
1072
1102
|
await handlers.webhook(hbReq, res);
|
|
1073
1103
|
} else if (segment === "webhooks" && method === "POST" && !handlers.webhook) {
|