@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/express/index.d.cts +1 -1
- package/dist/express/index.d.ts +1 -1
- package/dist/express/index.js +8 -35
- package/dist/express/index.js.map +1 -1
- package/dist/express/index.mjs +8 -35
- 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 +8 -35
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/index.mjs +8 -35
- package/dist/hono/index.mjs.map +1 -1
- package/dist/{index-C_gIXrzG.d.cts → index-D5WlUYVZ.d.cts} +0 -7
- package/dist/{index-DnEk4Y5R.d.ts → index-jK9cEnEY.d.ts} +0 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -32
- 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 +8 -35
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/index.mjs +8 -35
- 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 +8 -38
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +8 -38
- 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/hono/index.mjs
CHANGED
|
@@ -132,10 +132,9 @@ function buildQueryString(query) {
|
|
|
132
132
|
async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
|
|
133
133
|
const base = apiBaseUrl.replace(/\/$/, "");
|
|
134
134
|
const url = `${base}${opts.path}${buildQueryString(opts.query)}`;
|
|
135
|
-
const
|
|
136
|
-
const bearerToken = opts.sessionBearer ?? m2mToken;
|
|
135
|
+
const token = await tokenManager.getAccessToken();
|
|
137
136
|
const headers = {
|
|
138
|
-
Authorization: `Bearer ${
|
|
137
|
+
Authorization: `Bearer ${token}`,
|
|
139
138
|
Accept: "application/json"
|
|
140
139
|
};
|
|
141
140
|
if (opts.body !== void 0) headers["Content-Type"] = "application/json";
|
|
@@ -145,15 +144,14 @@ async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
|
|
|
145
144
|
headers
|
|
146
145
|
};
|
|
147
146
|
if (opts.body !== void 0) init.body = JSON.stringify(opts.body);
|
|
148
|
-
const onTokenExpired = opts.sessionBearer ? void 0 : async () => {
|
|
149
|
-
await tokenManager.invalidate();
|
|
150
|
-
const fresh = await tokenManager.getAccessToken();
|
|
151
|
-
headers.Authorization = `Bearer ${fresh}`;
|
|
152
|
-
};
|
|
153
147
|
const res = await retryFetch(url, init, {
|
|
154
148
|
fetch: fetchImpl,
|
|
155
149
|
timeoutMs: opts.timeoutMs,
|
|
156
|
-
onTokenExpired
|
|
150
|
+
onTokenExpired: async () => {
|
|
151
|
+
await tokenManager.invalidate();
|
|
152
|
+
const fresh = await tokenManager.getAccessToken();
|
|
153
|
+
headers.Authorization = `Bearer ${fresh}`;
|
|
154
|
+
}
|
|
157
155
|
});
|
|
158
156
|
let body = null;
|
|
159
157
|
const text = await res.text();
|
|
@@ -931,27 +929,6 @@ function createHellobillHandler(opts) {
|
|
|
931
929
|
if (!result2) return;
|
|
932
930
|
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
933
931
|
};
|
|
934
|
-
const loaDocument = async (req, res) => {
|
|
935
|
-
const rawLoa = req.query.loa_id ?? req.params?.id;
|
|
936
|
-
const loaId = Array.isArray(rawLoa) ? rawLoa[0] : rawLoa;
|
|
937
|
-
if (!loaId) {
|
|
938
|
-
sendError(res, 400, "validation.missing_required_field", "loa_id query parameter required");
|
|
939
|
-
return;
|
|
940
|
-
}
|
|
941
|
-
const sessionBearer = extractBearer(req);
|
|
942
|
-
if (!sessionBearer) {
|
|
943
|
-
sendError(res, 401, "auth.token_malformed", "Missing Authorization bearer token");
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
const result2 = await safeCallUpstream(res, {
|
|
947
|
-
method: "GET",
|
|
948
|
-
path: `/partner/loa/${encodeURIComponent(loaId)}/document`,
|
|
949
|
-
sessionBearer,
|
|
950
|
-
logger
|
|
951
|
-
});
|
|
952
|
-
if (!result2) return;
|
|
953
|
-
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
954
|
-
};
|
|
955
932
|
const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
|
|
956
933
|
const result = {
|
|
957
934
|
session,
|
|
@@ -963,8 +940,7 @@ function createHellobillHandler(opts) {
|
|
|
963
940
|
property,
|
|
964
941
|
sessions: { list: sessionsList, get: sessionsGet },
|
|
965
942
|
savingsSummary,
|
|
966
|
-
serviceSlots
|
|
967
|
-
loaDocument
|
|
943
|
+
serviceSlots
|
|
968
944
|
};
|
|
969
945
|
if (webhookHandler !== void 0) {
|
|
970
946
|
result.webhook = webhookHandler;
|
|
@@ -1074,9 +1050,6 @@ function createHellobillRouter(opts) {
|
|
|
1074
1050
|
router.get("/property", bridge(handlers.property));
|
|
1075
1051
|
router.get("/sessions", bridge(handlers.sessions.list));
|
|
1076
1052
|
router.get("/sessions/:id", bridge(handlers.sessions.get));
|
|
1077
|
-
router.get("/service-slots", bridge(handlers.serviceSlots));
|
|
1078
|
-
router.get("/savings-summary", bridge(handlers.savingsSummary));
|
|
1079
|
-
router.get("/loa-document", bridge(handlers.loaDocument));
|
|
1080
1053
|
return router;
|
|
1081
1054
|
}
|
|
1082
1055
|
|