apiblaze 0.17.23 → 0.18.1
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/index.js +1 -1
- package/dist/server/index.js +2 -1
- package/dist/server/index.mjs +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -54,7 +54,6 @@ function createPlaneCore(cfg) {
|
|
|
54
54
|
function planeFetch(base, method, path, user, opts = {}) {
|
|
55
55
|
const params = new URLSearchParams({ product: "apiblaze", ...opts.query ?? {} });
|
|
56
56
|
const headers = { "X-API-Key": cfg.cpKey, "X-End-User-Id": user.userId };
|
|
57
|
-
if (user.email) headers["X-End-User-Email"] = String(user.email);
|
|
58
57
|
let body;
|
|
59
58
|
if (opts.body !== void 0) {
|
|
60
59
|
headers["Content-Type"] = "application/json";
|
|
@@ -206,6 +205,7 @@ function createApiblazeKeys(cfg) {
|
|
|
206
205
|
const expiresIn = cfg.keyExpiresInSeconds;
|
|
207
206
|
const planeFetch = (method, path, user, opts = {}) => core.planeFetch(base, method, path, user, opts);
|
|
208
207
|
const resolveTenant = (user) => core.resolveTenant(user);
|
|
208
|
+
const ensureEndUser = (user, tenant) => core.ensureEndUser(user, tenant);
|
|
209
209
|
async function allowedTypesFor(user) {
|
|
210
210
|
const raw = cfg.resolveKeyTypes ? await cfg.resolveKeyTypes(user) : user.keyTypes;
|
|
211
211
|
if (raw === false) return false;
|
|
@@ -242,6 +242,7 @@ function createApiblazeKeys(cfg) {
|
|
|
242
242
|
return { status: 403, data: { error: "You are not allowed to create that key type." } };
|
|
243
243
|
}
|
|
244
244
|
const chosen = op.keyType ?? (eligible.includes("call-only") ? "call-only" : eligible[0]);
|
|
245
|
+
await ensureEndUser(user, tenant2);
|
|
245
246
|
const body = { tenant: tenant2, key_type_ids: [chosen], environment: "prod" };
|
|
246
247
|
if (typeof expiresIn === "number" && expiresIn > 0) body.expires_in_seconds = expiresIn;
|
|
247
248
|
const r = await planeFetch("POST", "/apikeys", user, { body });
|
package/dist/server/index.mjs
CHANGED
|
@@ -26,7 +26,6 @@ function createPlaneCore(cfg) {
|
|
|
26
26
|
function planeFetch(base, method, path, user, opts = {}) {
|
|
27
27
|
const params = new URLSearchParams({ product: "apiblaze", ...opts.query ?? {} });
|
|
28
28
|
const headers = { "X-API-Key": cfg.cpKey, "X-End-User-Id": user.userId };
|
|
29
|
-
if (user.email) headers["X-End-User-Email"] = String(user.email);
|
|
30
29
|
let body;
|
|
31
30
|
if (opts.body !== void 0) {
|
|
32
31
|
headers["Content-Type"] = "application/json";
|
|
@@ -178,6 +177,7 @@ function createApiblazeKeys(cfg) {
|
|
|
178
177
|
const expiresIn = cfg.keyExpiresInSeconds;
|
|
179
178
|
const planeFetch = (method, path, user, opts = {}) => core.planeFetch(base, method, path, user, opts);
|
|
180
179
|
const resolveTenant = (user) => core.resolveTenant(user);
|
|
180
|
+
const ensureEndUser = (user, tenant) => core.ensureEndUser(user, tenant);
|
|
181
181
|
async function allowedTypesFor(user) {
|
|
182
182
|
const raw = cfg.resolveKeyTypes ? await cfg.resolveKeyTypes(user) : user.keyTypes;
|
|
183
183
|
if (raw === false) return false;
|
|
@@ -214,6 +214,7 @@ function createApiblazeKeys(cfg) {
|
|
|
214
214
|
return { status: 403, data: { error: "You are not allowed to create that key type." } };
|
|
215
215
|
}
|
|
216
216
|
const chosen = op.keyType ?? (eligible.includes("call-only") ? "call-only" : eligible[0]);
|
|
217
|
+
await ensureEndUser(user, tenant2);
|
|
217
218
|
const body = { tenant: tenant2, key_type_ids: [chosen], environment: "prod" };
|
|
218
219
|
if (typeof expiresIn === "number" && expiresIn > 0) body.expires_in_seconds = expiresIn;
|
|
219
220
|
const r = await planeFetch("POST", "/apikeys", user, { body });
|