@hello-bill/node 2.1.2 → 2.1.3-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.js
CHANGED
|
@@ -133,9 +133,10 @@ 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
|
|
136
|
+
const m2mToken = await tokenManager.getAccessToken();
|
|
137
|
+
const bearerToken = opts.sessionBearer ?? m2mToken;
|
|
137
138
|
const headers = {
|
|
138
|
-
Authorization: `Bearer ${
|
|
139
|
+
Authorization: `Bearer ${bearerToken}`,
|
|
139
140
|
Accept: "application/json"
|
|
140
141
|
};
|
|
141
142
|
if (opts.body !== void 0) headers["Content-Type"] = "application/json";
|
|
@@ -145,14 +146,15 @@ async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
|
|
|
145
146
|
headers
|
|
146
147
|
};
|
|
147
148
|
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
|
+
};
|
|
148
154
|
const res = await retryFetch(url, init, {
|
|
149
155
|
fetch: fetchImpl,
|
|
150
156
|
timeoutMs: opts.timeoutMs,
|
|
151
|
-
onTokenExpired
|
|
152
|
-
await tokenManager.invalidate();
|
|
153
|
-
const fresh = await tokenManager.getAccessToken();
|
|
154
|
-
headers.Authorization = `Bearer ${fresh}`;
|
|
155
|
-
}
|
|
157
|
+
onTokenExpired
|
|
156
158
|
});
|
|
157
159
|
let body = null;
|
|
158
160
|
const text = await res.text();
|
|
@@ -930,6 +932,27 @@ function createHellobillHandler(opts) {
|
|
|
930
932
|
if (!result2) return;
|
|
931
933
|
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
932
934
|
};
|
|
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
|
+
};
|
|
933
956
|
const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
|
|
934
957
|
const result = {
|
|
935
958
|
session,
|
|
@@ -941,7 +964,8 @@ function createHellobillHandler(opts) {
|
|
|
941
964
|
property,
|
|
942
965
|
sessions: { list: sessionsList, get: sessionsGet },
|
|
943
966
|
savingsSummary,
|
|
944
|
-
serviceSlots
|
|
967
|
+
serviceSlots,
|
|
968
|
+
loaDocument
|
|
945
969
|
};
|
|
946
970
|
if (webhookHandler !== void 0) {
|
|
947
971
|
result.webhook = webhookHandler;
|
|
@@ -1070,6 +1094,12 @@ function createHellobillHandler2(opts) {
|
|
|
1070
1094
|
await handlers.sessions.list(hbReq, res);
|
|
1071
1095
|
} else if (segment === "sessions" && slug[1] && method === "GET") {
|
|
1072
1096
|
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);
|
|
1073
1103
|
} else if (segment === "webhooks" && method === "POST" && handlers.webhook) {
|
|
1074
1104
|
await handlers.webhook(hbReq, res);
|
|
1075
1105
|
} else if (segment === "webhooks" && method === "POST" && !handlers.webhook) {
|