@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/index.mjs
CHANGED
|
@@ -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
|
|
135
|
-
const bearerToken = opts.sessionBearer ?? m2mToken;
|
|
134
|
+
const token = await tokenManager.getAccessToken();
|
|
136
135
|
const headers = {
|
|
137
|
-
Authorization: `Bearer ${
|
|
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();
|
|
@@ -972,27 +970,6 @@ function createHellobillHandler(opts) {
|
|
|
972
970
|
if (!result2) return;
|
|
973
971
|
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
974
972
|
};
|
|
975
|
-
const loaDocument = async (req, res) => {
|
|
976
|
-
const rawLoa = req.query.loa_id ?? req.params?.id;
|
|
977
|
-
const loaId = Array.isArray(rawLoa) ? rawLoa[0] : rawLoa;
|
|
978
|
-
if (!loaId) {
|
|
979
|
-
sendError(res, 400, "validation.missing_required_field", "loa_id query parameter required");
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
const sessionBearer = extractBearer(req);
|
|
983
|
-
if (!sessionBearer) {
|
|
984
|
-
sendError(res, 401, "auth.token_malformed", "Missing Authorization bearer token");
|
|
985
|
-
return;
|
|
986
|
-
}
|
|
987
|
-
const result2 = await safeCallUpstream(res, {
|
|
988
|
-
method: "GET",
|
|
989
|
-
path: `/partner/loa/${encodeURIComponent(loaId)}/document`,
|
|
990
|
-
sessionBearer,
|
|
991
|
-
logger
|
|
992
|
-
});
|
|
993
|
-
if (!result2) return;
|
|
994
|
-
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
995
|
-
};
|
|
996
973
|
const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
|
|
997
974
|
const result = {
|
|
998
975
|
session,
|
|
@@ -1004,8 +981,7 @@ function createHellobillHandler(opts) {
|
|
|
1004
981
|
property,
|
|
1005
982
|
sessions: { list: sessionsList, get: sessionsGet },
|
|
1006
983
|
savingsSummary,
|
|
1007
|
-
serviceSlots
|
|
1008
|
-
loaDocument
|
|
984
|
+
serviceSlots
|
|
1009
985
|
};
|
|
1010
986
|
if (webhookHandler !== void 0) {
|
|
1011
987
|
result.webhook = webhookHandler;
|