@getcronit/pylon 2.10.0-canary-20250206024306.0b965bfde9f8e1db5b2728aeb8259def3c857325 → 3.0.0-canary-20250206125311.f228add1e2e04c8af5d91db6063583bd317de463
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/context.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +291 -239
- package/dist/index.js.map +4 -4
- package/dist/plugins/use-auth/auth-require.d.ts +10 -0
- package/dist/plugins/use-auth/import-private-key.d.ts +2 -0
- package/dist/plugins/use-auth/index.d.ts +3 -0
- package/dist/plugins/use-auth/types.d.ts +7 -0
- package/dist/plugins/use-auth/use-auth.d.ts +6 -0
- package/package.json +2 -2
- package/dist/auth/decorators/requireAuth.d.ts +0 -5
- package/dist/auth/index.d.ts +0 -21
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context as HonoContext } from 'hono';
|
|
2
2
|
import type { Toucan } from 'toucan-js';
|
|
3
|
-
import { AuthState } from './auth';
|
|
3
|
+
import type { AuthState } from './plugins/use-auth';
|
|
4
4
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
5
5
|
import type { GraphQLResolveInfo } from 'graphql';
|
|
6
6
|
export interface Bindings {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Env } from './context.js';
|
|
2
2
|
export { ServiceError } from './define-pylon.js';
|
|
3
|
-
export
|
|
3
|
+
export { useAuth, requireAuth, authMiddleware } from './plugins/use-auth/index.js';
|
|
4
4
|
export { Context, Env, Variables, Bindings, asyncContext, getContext, setContext } from './context.js';
|
|
5
5
|
import { app as pylonApp } from './app/index.js';
|
|
6
6
|
export { pylonApp as app };
|
package/dist/index.js
CHANGED
|
@@ -148,13 +148,13 @@ var resolversToGraphQLResolvers = (resolvers, configureContext) => {
|
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
ctx2?.set("graphqlResolveInfo", info);
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
151
|
+
const auth = ctx2?.get("auth");
|
|
152
|
+
if (auth?.user) {
|
|
153
153
|
scope.setUser({
|
|
154
|
-
id:
|
|
155
|
-
username:
|
|
156
|
-
email:
|
|
157
|
-
details:
|
|
154
|
+
id: auth.user.sub,
|
|
155
|
+
username: auth.user.preferred_username,
|
|
156
|
+
email: auth.user.email,
|
|
157
|
+
details: auth.user
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
let type = null;
|
|
@@ -273,18 +273,246 @@ var ServiceError = class extends GraphQLError {
|
|
|
273
273
|
}
|
|
274
274
|
};
|
|
275
275
|
|
|
276
|
-
// src/auth/
|
|
277
|
-
import
|
|
276
|
+
// src/plugins/use-auth/use-auth.ts
|
|
277
|
+
import { promises as fs } from "fs";
|
|
278
|
+
import { deleteCookie, getCookie, setCookie } from "hono/cookie";
|
|
279
|
+
import { HTTPException } from "hono/http-exception";
|
|
280
|
+
import * as openid from "openid-client";
|
|
278
281
|
import path from "path";
|
|
279
|
-
import { HTTPException as HTTPException2 } from "hono/http-exception";
|
|
280
|
-
import { env as env2 } from "hono/adapter";
|
|
281
|
-
import * as Sentry2 from "@sentry/bun";
|
|
282
|
-
import { existsSync, readFileSync } from "fs";
|
|
283
|
-
import { sendFunctionEvent as sendFunctionEvent4 } from "@getcronit/pylon-telemetry";
|
|
284
282
|
|
|
285
|
-
// src/auth/
|
|
286
|
-
import
|
|
287
|
-
|
|
283
|
+
// src/plugins/use-auth/import-private-key.ts
|
|
284
|
+
import * as crypto2 from "crypto";
|
|
285
|
+
function str2ab(str) {
|
|
286
|
+
const buf = new ArrayBuffer(str.length);
|
|
287
|
+
const bufView = new Uint8Array(buf);
|
|
288
|
+
for (let i = 0, strLen = str.length; i < strLen; i++) {
|
|
289
|
+
bufView[i] = str.charCodeAt(i);
|
|
290
|
+
}
|
|
291
|
+
return buf;
|
|
292
|
+
}
|
|
293
|
+
var convertPKCS1ToPKCS8 = (pkcs1) => {
|
|
294
|
+
const key = crypto2.createPrivateKey(pkcs1);
|
|
295
|
+
return key.export({
|
|
296
|
+
type: "pkcs8",
|
|
297
|
+
format: "pem"
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
function importPKCS8PrivateKey(pem) {
|
|
301
|
+
const pemHeader = "-----BEGIN PRIVATE KEY-----";
|
|
302
|
+
const pemFooter = "-----END PRIVATE KEY-----";
|
|
303
|
+
const pemContents = pem.substring(
|
|
304
|
+
pemHeader.length,
|
|
305
|
+
pem.length - pemFooter.length - 1
|
|
306
|
+
);
|
|
307
|
+
const binaryDerString = atob(pemContents);
|
|
308
|
+
const binaryDer = str2ab(binaryDerString);
|
|
309
|
+
return crypto2.subtle.importKey(
|
|
310
|
+
"pkcs8",
|
|
311
|
+
binaryDer,
|
|
312
|
+
{
|
|
313
|
+
name: "RSASSA-PKCS1-v1_5",
|
|
314
|
+
hash: "SHA-256"
|
|
315
|
+
},
|
|
316
|
+
true,
|
|
317
|
+
["sign"]
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
var importPrivateKey = async (pkcs1Pem) => {
|
|
321
|
+
const pkcs8Pem = convertPKCS1ToPKCS8(pkcs1Pem);
|
|
322
|
+
return await importPKCS8PrivateKey(pkcs8Pem);
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/plugins/use-auth/use-auth.ts
|
|
326
|
+
var loadAuthKey = async (keyPath) => {
|
|
327
|
+
const authKeyFilePath = path.join(process.cwd(), keyPath);
|
|
328
|
+
const env3 = getContext().env;
|
|
329
|
+
if (env3.AUTH_KEY) {
|
|
330
|
+
try {
|
|
331
|
+
return JSON.parse(env3.AUTH_KEY);
|
|
332
|
+
} catch (error) {
|
|
333
|
+
throw new Error(
|
|
334
|
+
"Error while reading AUTH_KEY. Make sure it is valid JSON"
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
try {
|
|
339
|
+
const ketFileContent = await fs.readFile(authKeyFilePath, "utf-8");
|
|
340
|
+
try {
|
|
341
|
+
return JSON.parse(ketFileContent);
|
|
342
|
+
} catch (error) {
|
|
343
|
+
throw new Error(
|
|
344
|
+
"Error while reading key file. Make sure it is valid JSON"
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
} catch (error) {
|
|
348
|
+
throw new Error("Error while reading key file. Make sure it exists");
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
var openidConfigCache;
|
|
352
|
+
var bootstrapAuth = async (issuer, keyPath) => {
|
|
353
|
+
if (!openidConfigCache) {
|
|
354
|
+
const authKey = await loadAuthKey(keyPath);
|
|
355
|
+
openidConfigCache = await openid.discovery(
|
|
356
|
+
new URL(issuer),
|
|
357
|
+
authKey.clientId,
|
|
358
|
+
void 0,
|
|
359
|
+
openid.PrivateKeyJwt({
|
|
360
|
+
key: await importPrivateKey(authKey.key),
|
|
361
|
+
kid: authKey.keyId
|
|
362
|
+
})
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
return openidConfigCache;
|
|
366
|
+
};
|
|
367
|
+
var PylonAuthException = class extends HTTPException {
|
|
368
|
+
// Same constructor as HTTPException
|
|
369
|
+
constructor(...args) {
|
|
370
|
+
args[1] = {
|
|
371
|
+
...args[1],
|
|
372
|
+
message: `PylonAuthException: ${args[1]?.message}`
|
|
373
|
+
};
|
|
374
|
+
super(...args);
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
function useAuth(args) {
|
|
378
|
+
const { issuer, endpoint = "/auth", keyPath = "key.json" } = args;
|
|
379
|
+
const loginPath = `${endpoint}/login`;
|
|
380
|
+
const logoutPath = `${endpoint}/logout`;
|
|
381
|
+
const callbackPath = `${endpoint}/callback`;
|
|
382
|
+
return {
|
|
383
|
+
middleware: async (ctx, next) => {
|
|
384
|
+
const openidConfig = await bootstrapAuth(issuer, keyPath);
|
|
385
|
+
ctx.set("auth", { openidConfig });
|
|
386
|
+
const authCookieToken = getCookie(ctx, "pylon-auth");
|
|
387
|
+
const authHeader = ctx.req.header("Authorization");
|
|
388
|
+
const authQueryToken = ctx.req.query("token");
|
|
389
|
+
if (authCookieToken || authHeader || authQueryToken) {
|
|
390
|
+
let token;
|
|
391
|
+
if (authHeader) {
|
|
392
|
+
const [type, value] = authHeader.split(" ");
|
|
393
|
+
if (type === "Bearer") {
|
|
394
|
+
token = value;
|
|
395
|
+
}
|
|
396
|
+
} else if (authQueryToken) {
|
|
397
|
+
token = authQueryToken;
|
|
398
|
+
} else if (authCookieToken) {
|
|
399
|
+
token = authCookieToken;
|
|
400
|
+
}
|
|
401
|
+
if (!token) {
|
|
402
|
+
throw new PylonAuthException(401, {
|
|
403
|
+
message: "Invalid token"
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
const introspection = await openid.tokenIntrospection(
|
|
407
|
+
openidConfig,
|
|
408
|
+
token,
|
|
409
|
+
{
|
|
410
|
+
scope: "openid email profile"
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
if (!introspection.active) {
|
|
414
|
+
throw new PylonAuthException(401, {
|
|
415
|
+
message: "Token is not active"
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
if (!introspection.sub) {
|
|
419
|
+
throw new PylonAuthException(401, {
|
|
420
|
+
message: "Token is missing subject"
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
const userInfo = await openid.fetchUserInfo(
|
|
424
|
+
openidConfig,
|
|
425
|
+
token,
|
|
426
|
+
introspection.sub
|
|
427
|
+
);
|
|
428
|
+
const roles = Object.keys(
|
|
429
|
+
introspection["urn:zitadel:iam:org:projects:roles"]?.valueOf() || {}
|
|
430
|
+
);
|
|
431
|
+
ctx.set("auth", {
|
|
432
|
+
user: {
|
|
433
|
+
...userInfo,
|
|
434
|
+
roles
|
|
435
|
+
},
|
|
436
|
+
openidConfig
|
|
437
|
+
});
|
|
438
|
+
return next();
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
setup(app2) {
|
|
442
|
+
app2.get(loginPath, async (ctx) => {
|
|
443
|
+
const openidConfig = ctx.get("auth").openidConfig;
|
|
444
|
+
const codeVerifier = openid.randomPKCECodeVerifier();
|
|
445
|
+
const codeChallenge = await openid.calculatePKCECodeChallenge(
|
|
446
|
+
codeVerifier
|
|
447
|
+
);
|
|
448
|
+
setCookie(ctx, "pylon_code_verifier", codeVerifier, {
|
|
449
|
+
httpOnly: true,
|
|
450
|
+
maxAge: 300
|
|
451
|
+
// 5 minutes
|
|
452
|
+
});
|
|
453
|
+
let scope = "openid profile email urn:zitadel:iam:user:resourceowner urn:zitadel:iam:org:projects:roles";
|
|
454
|
+
const parameters = {
|
|
455
|
+
scope,
|
|
456
|
+
code_challenge: codeChallenge,
|
|
457
|
+
code_challenge_method: "S256",
|
|
458
|
+
redirect_uri: new URL(ctx.req.url).origin + "/auth/callback",
|
|
459
|
+
state: openid.randomState()
|
|
460
|
+
};
|
|
461
|
+
const authorizationUrl = openid.buildAuthorizationUrl(
|
|
462
|
+
openidConfig,
|
|
463
|
+
parameters
|
|
464
|
+
);
|
|
465
|
+
return ctx.redirect(authorizationUrl);
|
|
466
|
+
});
|
|
467
|
+
app2.get(logoutPath, async (ctx) => {
|
|
468
|
+
deleteCookie(ctx, "pylon-auth");
|
|
469
|
+
return ctx.redirect("/");
|
|
470
|
+
});
|
|
471
|
+
app2.get(callbackPath, async (ctx) => {
|
|
472
|
+
const openidConfig = ctx.get("auth").openidConfig;
|
|
473
|
+
const params = ctx.req.query();
|
|
474
|
+
const code = params.code;
|
|
475
|
+
const state = params.state;
|
|
476
|
+
if (!code || !state) {
|
|
477
|
+
throw new PylonAuthException(400, {
|
|
478
|
+
message: "Missing authorization code or state"
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
const codeVerifier = getCookie(ctx, "pylon_code_verifier");
|
|
482
|
+
if (!codeVerifier) {
|
|
483
|
+
throw new PylonAuthException(400, {
|
|
484
|
+
message: "Missing code verifier"
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
try {
|
|
488
|
+
const cbUrl = new URL(ctx.req.url);
|
|
489
|
+
let tokenSet = await openid.authorizationCodeGrant(
|
|
490
|
+
openidConfig,
|
|
491
|
+
cbUrl,
|
|
492
|
+
{
|
|
493
|
+
pkceCodeVerifier: codeVerifier,
|
|
494
|
+
expectedState: state
|
|
495
|
+
},
|
|
496
|
+
cbUrl.searchParams
|
|
497
|
+
);
|
|
498
|
+
setCookie(ctx, `pylon-auth`, tokenSet.access_token, {
|
|
499
|
+
httpOnly: true,
|
|
500
|
+
maxAge: tokenSet.expires_in || 3600
|
|
501
|
+
// Default to 1 hour if not specified
|
|
502
|
+
});
|
|
503
|
+
return ctx.redirect("/");
|
|
504
|
+
} catch (error) {
|
|
505
|
+
console.error("Error during token exchange:", error);
|
|
506
|
+
return ctx.text("Authentication failed!", 500);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/plugins/use-auth/auth-require.ts
|
|
514
|
+
import { env as env2 } from "hono/adapter";
|
|
515
|
+
import { HTTPException as HTTPException2 } from "hono/http-exception";
|
|
288
516
|
|
|
289
517
|
// src/create-decorator.ts
|
|
290
518
|
import { sendFunctionEvent as sendFunctionEvent2 } from "@getcronit/pylon-telemetry";
|
|
@@ -335,20 +563,47 @@ function createDecorator(callback) {
|
|
|
335
563
|
return MyDecorator;
|
|
336
564
|
}
|
|
337
565
|
|
|
338
|
-
// src/auth/
|
|
566
|
+
// src/plugins/use-auth/auth-require.ts
|
|
567
|
+
var authMiddleware = (checks = {}) => {
|
|
568
|
+
const middleware = async (ctx, next) => {
|
|
569
|
+
const AUTH_PROJECT_ID = env2(ctx).AUTH_PROJECT_ID;
|
|
570
|
+
const auth = ctx.get("auth");
|
|
571
|
+
if (!auth) {
|
|
572
|
+
throw new HTTPException2(401, {
|
|
573
|
+
message: "Authentication required"
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
if (checks.roles && auth.user) {
|
|
577
|
+
const roles = auth.user.roles;
|
|
578
|
+
const hasRole = checks.roles.some((role) => {
|
|
579
|
+
return roles.includes(role) || roles.includes(`${AUTH_PROJECT_ID}:${role}`);
|
|
580
|
+
});
|
|
581
|
+
if (!hasRole) {
|
|
582
|
+
const resError = new Response("Forbidden", {
|
|
583
|
+
status: 403,
|
|
584
|
+
statusText: "Forbidden",
|
|
585
|
+
headers: {
|
|
586
|
+
"Missing-Roles": checks.roles.join(","),
|
|
587
|
+
"Obtained-Roles": roles.join(",")
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
throw new HTTPException2(resError.status, {
|
|
591
|
+
res: resError
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return next();
|
|
596
|
+
};
|
|
597
|
+
return middleware;
|
|
598
|
+
};
|
|
339
599
|
function requireAuth(checks) {
|
|
340
|
-
sendFunctionEvent3({
|
|
341
|
-
name: "requireAuth",
|
|
342
|
-
duration: 0
|
|
343
|
-
}).then(() => {
|
|
344
|
-
});
|
|
345
600
|
const checkAuth = async (c) => {
|
|
346
601
|
const ctx = await c;
|
|
347
602
|
try {
|
|
348
|
-
await
|
|
603
|
+
await authMiddleware(checks)(ctx, async () => {
|
|
349
604
|
});
|
|
350
605
|
} catch (e) {
|
|
351
|
-
if (e instanceof
|
|
606
|
+
if (e instanceof HTTPException2) {
|
|
352
607
|
if (e.status === 401) {
|
|
353
608
|
throw new ServiceError(e.message, {
|
|
354
609
|
statusCode: 401,
|
|
@@ -377,210 +632,6 @@ function requireAuth(checks) {
|
|
|
377
632
|
});
|
|
378
633
|
}
|
|
379
634
|
|
|
380
|
-
// src/auth/index.ts
|
|
381
|
-
var authInitialize = () => {
|
|
382
|
-
const authKeyFilePath = path.join(process.cwd(), "key.json");
|
|
383
|
-
let API_PRIVATE_KEY_FILE = void 0;
|
|
384
|
-
if (existsSync(authKeyFilePath)) {
|
|
385
|
-
try {
|
|
386
|
-
API_PRIVATE_KEY_FILE = JSON.parse(readFileSync(authKeyFilePath, "utf-8"));
|
|
387
|
-
} catch (error) {
|
|
388
|
-
throw new Error(
|
|
389
|
-
"Error while reading key file. Make sure it is valid JSON"
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
const middleware = Sentry2.startSpan(
|
|
394
|
-
{
|
|
395
|
-
name: "AuthMiddleware",
|
|
396
|
-
op: "auth"
|
|
397
|
-
},
|
|
398
|
-
() => async function(ctx, next) {
|
|
399
|
-
const AUTH_ISSUER = env2(ctx).AUTH_ISSUER;
|
|
400
|
-
if (!AUTH_ISSUER) {
|
|
401
|
-
throw new Error("AUTH_ISSUER is not set");
|
|
402
|
-
}
|
|
403
|
-
if (!API_PRIVATE_KEY_FILE) {
|
|
404
|
-
const AUTH_KEY = env2(ctx).AUTH_KEY;
|
|
405
|
-
API_PRIVATE_KEY_FILE = AUTH_KEY ? JSON.parse(AUTH_KEY) : void 0;
|
|
406
|
-
}
|
|
407
|
-
if (!API_PRIVATE_KEY_FILE) {
|
|
408
|
-
throw new Error(
|
|
409
|
-
"You have initialized the auth middleware without a private key file"
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
const AUTH_PROJECT_ID = env2(ctx).AUTH_PROJECT_ID;
|
|
413
|
-
const ZITADEL_INTROSPECTION_URL = `${AUTH_ISSUER}/oauth/v2/introspect`;
|
|
414
|
-
async function getRolesFromToken(tokenString) {
|
|
415
|
-
const response = await fetch(
|
|
416
|
-
`${AUTH_ISSUER}/auth/v1/usergrants/me/_search`,
|
|
417
|
-
{
|
|
418
|
-
method: "POST",
|
|
419
|
-
headers: {
|
|
420
|
-
"Content-Type": "application/json",
|
|
421
|
-
Authorization: `Bearer ${tokenString}`
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
);
|
|
425
|
-
const data = await response.json();
|
|
426
|
-
const userRoles = data.result?.map((grant) => {
|
|
427
|
-
return (grant.roles || []).map((role) => {
|
|
428
|
-
return `${grant.projectId}:${role}`;
|
|
429
|
-
});
|
|
430
|
-
}) || [];
|
|
431
|
-
const projectScopedRoles = userRoles.flat();
|
|
432
|
-
const rolesSet = new Set(projectScopedRoles);
|
|
433
|
-
if (AUTH_PROJECT_ID) {
|
|
434
|
-
for (const role of projectScopedRoles) {
|
|
435
|
-
const [projectId, ...roleNameParts] = role.split(":");
|
|
436
|
-
const roleName = roleNameParts.join(":");
|
|
437
|
-
if (projectId === AUTH_PROJECT_ID) {
|
|
438
|
-
rolesSet.add(roleName);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
return Array.from(rolesSet);
|
|
443
|
-
}
|
|
444
|
-
async function introspectToken(tokenString) {
|
|
445
|
-
if (!API_PRIVATE_KEY_FILE) {
|
|
446
|
-
throw new Error("Internal error: API_PRIVATE_KEY_FILE is not set");
|
|
447
|
-
}
|
|
448
|
-
const payload = {
|
|
449
|
-
iss: API_PRIVATE_KEY_FILE.clientId,
|
|
450
|
-
sub: API_PRIVATE_KEY_FILE.clientId,
|
|
451
|
-
aud: AUTH_ISSUER,
|
|
452
|
-
exp: Math.floor(Date.now() / 1e3) + 60 * 60,
|
|
453
|
-
// Expires in 1 hour
|
|
454
|
-
iat: Math.floor(Date.now() / 1e3)
|
|
455
|
-
};
|
|
456
|
-
const headers = {
|
|
457
|
-
alg: "RS256",
|
|
458
|
-
kid: API_PRIVATE_KEY_FILE.keyId
|
|
459
|
-
};
|
|
460
|
-
const jwtToken = jwt.sign(payload, API_PRIVATE_KEY_FILE.key, {
|
|
461
|
-
algorithm: "RS256",
|
|
462
|
-
header: headers
|
|
463
|
-
});
|
|
464
|
-
const scopeSet = /* @__PURE__ */ new Set();
|
|
465
|
-
scopeSet.add("openid");
|
|
466
|
-
scopeSet.add("profile");
|
|
467
|
-
scopeSet.add("email");
|
|
468
|
-
if (AUTH_PROJECT_ID) {
|
|
469
|
-
scopeSet.add(
|
|
470
|
-
`urn:zitadel:iam:org:project:id:${AUTH_PROJECT_ID}:aud`
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
const scope = Array.from(scopeSet).join(" ");
|
|
474
|
-
const body = new URLSearchParams({
|
|
475
|
-
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
476
|
-
client_assertion: jwtToken,
|
|
477
|
-
token: tokenString,
|
|
478
|
-
scope
|
|
479
|
-
}).toString();
|
|
480
|
-
try {
|
|
481
|
-
const response = await fetch(ZITADEL_INTROSPECTION_URL, {
|
|
482
|
-
method: "POST",
|
|
483
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
484
|
-
body
|
|
485
|
-
});
|
|
486
|
-
if (!response.ok) {
|
|
487
|
-
throw new Error("Network response was not ok");
|
|
488
|
-
}
|
|
489
|
-
const tokenData = await response.json();
|
|
490
|
-
const roles = await getRolesFromToken(tokenString);
|
|
491
|
-
const state = {
|
|
492
|
-
...tokenData,
|
|
493
|
-
roles
|
|
494
|
-
};
|
|
495
|
-
return state;
|
|
496
|
-
} catch (error) {
|
|
497
|
-
console.error("Error while introspecting token", error);
|
|
498
|
-
throw new Error("Token introspection failed");
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
let token = void 0;
|
|
502
|
-
if (ctx.req.header("Authorization")) {
|
|
503
|
-
const authHeader = ctx.req.header("Authorization");
|
|
504
|
-
if (authHeader) {
|
|
505
|
-
const parts = authHeader.split(" ");
|
|
506
|
-
if (parts.length === 2 && parts[0] === "Bearer") {
|
|
507
|
-
token = parts[1];
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
if (!token) {
|
|
512
|
-
const queryToken = ctx.req.query("token");
|
|
513
|
-
if (queryToken) {
|
|
514
|
-
token = queryToken;
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
if (token) {
|
|
518
|
-
const auth2 = await introspectToken(token);
|
|
519
|
-
if (auth2.active) {
|
|
520
|
-
ctx.set("auth", auth2);
|
|
521
|
-
Sentry2.setUser({
|
|
522
|
-
id: auth2.sub,
|
|
523
|
-
username: auth2.preferred_username,
|
|
524
|
-
email: auth2.email,
|
|
525
|
-
details: auth2
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return next();
|
|
530
|
-
}
|
|
531
|
-
);
|
|
532
|
-
sendFunctionEvent4({
|
|
533
|
-
name: "authInitialize",
|
|
534
|
-
duration: 0
|
|
535
|
-
}).then(() => {
|
|
536
|
-
});
|
|
537
|
-
return middleware;
|
|
538
|
-
};
|
|
539
|
-
var authRequire = (checks = {}) => {
|
|
540
|
-
sendFunctionEvent4({
|
|
541
|
-
name: "authRequire",
|
|
542
|
-
duration: 0
|
|
543
|
-
}).then(() => {
|
|
544
|
-
});
|
|
545
|
-
const middleware = async (ctx, next) => {
|
|
546
|
-
const AUTH_PROJECT_ID = env2(ctx).AUTH_PROJECT_ID;
|
|
547
|
-
const auth2 = ctx.get("auth");
|
|
548
|
-
if (!auth2) {
|
|
549
|
-
throw new HTTPException2(401, {
|
|
550
|
-
message: "Authentication required"
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
if (checks.roles) {
|
|
554
|
-
const roles = auth2.roles;
|
|
555
|
-
const hasRole = checks.roles.some((role) => {
|
|
556
|
-
return roles.includes(role) || roles.includes(`${AUTH_PROJECT_ID}:${role}`);
|
|
557
|
-
});
|
|
558
|
-
if (!hasRole) {
|
|
559
|
-
const resError = new Response("Forbidden", {
|
|
560
|
-
status: 403,
|
|
561
|
-
statusText: "Forbidden",
|
|
562
|
-
headers: {
|
|
563
|
-
"Missing-Roles": checks.roles.join(","),
|
|
564
|
-
"Obtained-Roles": roles.join(",")
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
throw new HTTPException2(resError.status, { res: resError });
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return next();
|
|
571
|
-
};
|
|
572
|
-
sendFunctionEvent4({
|
|
573
|
-
name: "authRequire",
|
|
574
|
-
duration: 0
|
|
575
|
-
}).then(() => {
|
|
576
|
-
});
|
|
577
|
-
return middleware;
|
|
578
|
-
};
|
|
579
|
-
var auth = {
|
|
580
|
-
initialize: authInitialize,
|
|
581
|
-
require: authRequire
|
|
582
|
-
};
|
|
583
|
-
|
|
584
635
|
// src/app/index.ts
|
|
585
636
|
import { Hono } from "hono";
|
|
586
637
|
import { logger } from "hono/logger";
|
|
@@ -633,7 +684,7 @@ import {
|
|
|
633
684
|
handleStreamOrSingleExecutionResult,
|
|
634
685
|
isOriginalGraphQLError
|
|
635
686
|
} from "@envelop/core";
|
|
636
|
-
import * as
|
|
687
|
+
import * as Sentry2 from "@sentry/node";
|
|
637
688
|
var defaultSkipError = isOriginalGraphQLError;
|
|
638
689
|
var useSentry = (options = {}) => {
|
|
639
690
|
function pick(key, defaultValue) {
|
|
@@ -673,7 +724,7 @@ var useSentry = (options = {}) => {
|
|
|
673
724
|
...addedTags
|
|
674
725
|
};
|
|
675
726
|
if (options.configureScope) {
|
|
676
|
-
options.configureScope(args,
|
|
727
|
+
options.configureScope(args, Sentry2.getCurrentScope());
|
|
677
728
|
}
|
|
678
729
|
return {
|
|
679
730
|
onExecuteDone(payload) {
|
|
@@ -681,7 +732,7 @@ var useSentry = (options = {}) => {
|
|
|
681
732
|
result,
|
|
682
733
|
setResult
|
|
683
734
|
}) => {
|
|
684
|
-
|
|
735
|
+
Sentry2.startSpanManual(
|
|
685
736
|
{
|
|
686
737
|
op,
|
|
687
738
|
name: opName,
|
|
@@ -696,7 +747,7 @@ var useSentry = (options = {}) => {
|
|
|
696
747
|
span.setAttribute("result", JSON.stringify(result));
|
|
697
748
|
}
|
|
698
749
|
if (result.errors && result.errors.length > 0) {
|
|
699
|
-
|
|
750
|
+
Sentry2.withScope((scope) => {
|
|
700
751
|
scope.setTransactionName(opName);
|
|
701
752
|
scope.setTag("operation", operationType);
|
|
702
753
|
scope.setTag("operationName", opName);
|
|
@@ -722,7 +773,7 @@ var useSentry = (options = {}) => {
|
|
|
722
773
|
level: "debug"
|
|
723
774
|
});
|
|
724
775
|
}
|
|
725
|
-
const eventId =
|
|
776
|
+
const eventId = Sentry2.captureException(
|
|
726
777
|
err.originalError,
|
|
727
778
|
{
|
|
728
779
|
fingerprint: [
|
|
@@ -760,7 +811,7 @@ var useSentry = (options = {}) => {
|
|
|
760
811
|
};
|
|
761
812
|
|
|
762
813
|
// src/app/pylon-handler.ts
|
|
763
|
-
import { readFileSync
|
|
814
|
+
import { readFileSync } from "fs";
|
|
764
815
|
import path2 from "path";
|
|
765
816
|
|
|
766
817
|
// src/plugins/use-viewer.ts
|
|
@@ -1055,7 +1106,7 @@ var handler = (options) => {
|
|
|
1055
1106
|
if (!typeDefs) {
|
|
1056
1107
|
const schemaPath = path2.join(process.cwd(), ".pylon", "schema.graphql");
|
|
1057
1108
|
if (schemaPath) {
|
|
1058
|
-
typeDefs =
|
|
1109
|
+
typeDefs = readFileSync(schemaPath, "utf-8");
|
|
1059
1110
|
}
|
|
1060
1111
|
}
|
|
1061
1112
|
if (!typeDefs) {
|
|
@@ -1134,7 +1185,7 @@ var handler = (options) => {
|
|
|
1134
1185
|
};
|
|
1135
1186
|
|
|
1136
1187
|
// src/get-env.ts
|
|
1137
|
-
import { sendFunctionEvent as
|
|
1188
|
+
import { sendFunctionEvent as sendFunctionEvent3 } from "@getcronit/pylon-telemetry";
|
|
1138
1189
|
function getEnv() {
|
|
1139
1190
|
const start = Date.now();
|
|
1140
1191
|
const skipTracing = arguments[0] === true;
|
|
@@ -1145,7 +1196,7 @@ function getEnv() {
|
|
|
1145
1196
|
return process.env;
|
|
1146
1197
|
} finally {
|
|
1147
1198
|
if (!skipTracing) {
|
|
1148
|
-
|
|
1199
|
+
sendFunctionEvent3({
|
|
1149
1200
|
name: "getEnv",
|
|
1150
1201
|
duration: Date.now() - start
|
|
1151
1202
|
}).then(() => {
|
|
@@ -1160,13 +1211,14 @@ export {
|
|
|
1160
1211
|
ServiceError,
|
|
1161
1212
|
app,
|
|
1162
1213
|
asyncContext,
|
|
1163
|
-
|
|
1214
|
+
authMiddleware,
|
|
1164
1215
|
createDecorator,
|
|
1165
1216
|
createPubSub as experimentalCreatePubSub,
|
|
1166
1217
|
getContext,
|
|
1167
1218
|
getEnv,
|
|
1168
1219
|
handler,
|
|
1169
1220
|
requireAuth,
|
|
1170
|
-
setContext
|
|
1221
|
+
setContext,
|
|
1222
|
+
useAuth
|
|
1171
1223
|
};
|
|
1172
1224
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/define-pylon.ts", "../src/context.ts", "../src/auth/
|
|
4
|
-
"sourcesContent": ["import * as Sentry from '@sentry/bun'\nimport consola from 'consola'\nimport {\n FragmentDefinitionNode,\n GraphQLError,\n GraphQLErrorExtensions,\n GraphQLObjectType,\n GraphQLResolveInfo,\n SelectionSetNode\n} from 'graphql'\n\nimport {Context, asyncContext} from './context'\nimport {isAsyncIterable, Maybe} from 'graphql-yoga'\n\nexport interface Resolvers {\n Query: Record<string, any>\n Mutation?: Record<string, any>\n Subscription?: Record<string, any>\n}\n\ntype FunctionWrapper = (fn: (...args: any[]) => any) => (...args: any[]) => any\n\nfunction getAllPropertyNames(instance: any): string[] {\n const allProps = new Set<string>()\n\n // Traverse the prototype chain\n let currentObj: any = instance\n\n while (currentObj && currentObj !== Object.prototype) {\n // Get all own property names of the current object\n const ownProps = Object.getOwnPropertyNames(currentObj)\n\n // Add each property to the Set\n ownProps.forEach(prop => allProps.add(prop))\n\n // Move up the prototype chain\n currentObj = Object.getPrototypeOf(currentObj)\n }\n\n // Convert Set to array and filter out the constructor if desired\n return Array.from(allProps).filter(prop => prop !== 'constructor')\n}\n\nasync function wrapFunctionsRecursively(\n obj: any,\n wrapper: FunctionWrapper,\n that: any = null,\n selectionSet: SelectionSetNode['selections'] = [],\n info: GraphQLResolveInfo\n): Promise<any> {\n // Skip if the object is a Date object or any other special object.\n // Those objects are then handled by custom resolvers.\n if (obj === null || obj instanceof Date) {\n return obj\n }\n\n if (Array.isArray(obj)) {\n return await Promise.all(\n obj.map(async item => {\n return await wrapFunctionsRecursively(\n item,\n wrapper,\n that,\n selectionSet,\n info\n )\n })\n )\n } else if (typeof obj === 'function') {\n return Sentry.startSpan(\n {\n name: obj.name,\n op: 'pylon.fn'\n },\n async () => {\n // @ts-ignore\n return await wrapper.call(that, obj, selectionSet, info)\n }\n )\n } else if (obj instanceof Promise) {\n return await wrapFunctionsRecursively(\n await obj,\n wrapper,\n that,\n selectionSet,\n info\n )\n } else if (isAsyncIterable(obj)) {\n return obj\n } else if (typeof obj === 'object') {\n that = obj\n\n const result: Record<string, any> = {}\n\n for (const key of getAllPropertyNames(obj)) {\n result[key] = await wrapFunctionsRecursively(\n obj[key],\n wrapper,\n that,\n selectionSet,\n info\n )\n }\n\n return result\n } else {\n return await obj\n }\n}\nfunction spreadFunctionArguments<T extends (...args: any[]) => any>(fn: T) {\n return (otherArgs: Record<string, any>, c: any, info: GraphQLResolveInfo) => {\n const selections = arguments[1] as SelectionSetNode['selections']\n const realInfo = arguments[2] as GraphQLResolveInfo\n\n let args: Record<string, any> = {}\n\n if (info) {\n const type = info.parentType\n\n const field = type.getFields()[info.fieldName]\n\n const fieldArguments = field?.args\n\n const preparedArguments = fieldArguments?.reduce(\n (acc: {[x: string]: undefined}, arg: {name: string | number}) => {\n if (otherArgs[arg.name] !== undefined) {\n acc[arg.name] = otherArgs[arg.name]\n } else {\n acc[arg.name] = undefined\n }\n\n return acc\n },\n {} as Record<string, any>\n )\n\n if (preparedArguments) {\n args = preparedArguments\n }\n } else {\n args = otherArgs\n }\n\n const orderedArgs = Object.keys(args).map(key => args[key])\n\n const that = this || {}\n\n const result = wrapFunctionsRecursively(\n fn.call(that, ...orderedArgs),\n spreadFunctionArguments,\n this,\n selections,\n realInfo\n )\n\n return result as ReturnType<typeof fn>\n }\n}\n\n/**\n * Converts a set of resolvers into a corresponding set of GraphQL resolvers.\n * @param resolvers The original resolvers.\n * @returns The converted GraphQL resolvers.\n */\nexport const resolversToGraphQLResolvers = (\n resolvers: Resolvers,\n configureContext?: (context: Context) => Context\n): Resolvers => {\n // Define a root resolver function that maps a given resolver function or object to a GraphQL resolver.\n const rootGraphqlResolver =\n (fn: Function | object | Promise<Function> | Promise<object>) =>\n async (\n _: object,\n args: Record<string, any>,\n ctx: Context,\n info: GraphQLResolveInfo\n ) => {\n return Sentry.withScope(async scope => {\n const ctx = asyncContext.getStore()\n\n\n if (!ctx) {\n consola.warn(\n 'Context is not defined. Make sure AsyncLocalStorage is supported in your environment.'\n )\n }\n\n ctx?.set(\"graphqlResolveInfo\", info)\n\n const auth = ctx?.get('auth')\n\n if (auth?.active) {\n scope.setUser({\n id: auth.sub,\n username: auth.preferred_username,\n email: auth.email,\n details: auth\n })\n }\n\n // get query or mutation field\n\n let type: Maybe<GraphQLObjectType> | null = null\n\n switch (info.operation.operation) {\n case 'query':\n type = info.schema.getQueryType()\n break\n case 'mutation':\n type = info.schema.getMutationType()\n break\n case 'subscription':\n type = info.schema.getSubscriptionType()\n break\n default:\n throw new Error('Unknown operation')\n }\n\n const field = type?.getFields()[info.fieldName]\n\n // Get the list of arguments expected by the current query field.\n const fieldArguments = field?.args || []\n\n // Prepare the arguments for the resolver function call by adding any missing arguments with an undefined value.\n const preparedArguments = fieldArguments.reduce(\n (acc: {[x: string]: undefined}, arg: {name: string | number}) => {\n if (args[arg.name] !== undefined) {\n acc[arg.name] = args[arg.name]\n } else {\n acc[arg.name] = undefined\n }\n\n return acc\n },\n {} as Record<string, any>\n )\n\n // Determine the resolver function to call (either the given function or the wrappedWithContext function if it exists).\n let inner = await fn\n\n let baseSelectionSet: SelectionSetNode['selections'] = []\n\n // Find the selection set for the current field.\n for (const selection of info.operation.selectionSet.selections) {\n if (\n selection.kind === 'Field' &&\n selection.name.value === info.fieldName\n ) {\n baseSelectionSet = selection.selectionSet?.selections || []\n }\n }\n\n // Wrap the resolver function with any required middleware.\n const wrappedFn = await wrapFunctionsRecursively(\n inner,\n spreadFunctionArguments,\n this,\n baseSelectionSet,\n info\n )\n\n // Call the resolver function with the prepared arguments.\n if (typeof wrappedFn !== 'function') {\n return wrappedFn\n }\n\n const res = await wrappedFn(preparedArguments)\n\n return res\n })\n }\n\n // Convert the Query and Mutation resolvers to GraphQL resolvers.\n const graphqlResolvers = {} as Resolvers\n\n // Remove empty resolvers\n for (const key of Object.keys(resolvers.Query)) {\n if (!resolvers.Query[key]) {\n delete resolvers.Query[key]\n }\n }\n\n if (resolvers.Query && Object.keys(resolvers.Query).length > 0) {\n for (const [key, value] of Object.entries(resolvers.Query)) {\n if (!graphqlResolvers.Query) {\n graphqlResolvers.Query = {}\n }\n\n graphqlResolvers.Query[key] = rootGraphqlResolver(\n value as Function | object\n )\n }\n }\n\n if (resolvers.Mutation && Object.keys(resolvers.Mutation).length > 0) {\n if (!graphqlResolvers.Mutation) {\n graphqlResolvers.Mutation = {}\n }\n\n for (const [key, value] of Object.entries(resolvers.Mutation)) {\n graphqlResolvers.Mutation[key] = rootGraphqlResolver(\n value as Function | object\n )\n }\n }\n\n if (\n resolvers.Subscription &&\n Object.keys(resolvers.Subscription).length > 0\n ) {\n if (!graphqlResolvers.Subscription) {\n graphqlResolvers.Subscription = {}\n }\n\n for (const [key, value] of Object.entries(resolvers.Subscription)) {\n graphqlResolvers.Subscription[key] = {\n subscribe: rootGraphqlResolver(value as Function | object),\n resolve: (payload: any) => payload\n }\n }\n }\n\n // Query root type must be provided.\n if (!graphqlResolvers.Query) {\n // Custom Error for Query root type must be provided.\n\n throw new Error(`At least one 'Query' resolver must be provided.\n\nExample:\n\nexport const graphql = {\n Query: {\n // Define at least one query resolver here\n hello: () => 'world'\n }\n}\n`)\n }\n\n // Add extra resolvers (e.g. custom scalars) to the GraphQL resolvers.\n for (const key of Object.keys(resolvers)) {\n if (key !== 'Query' && key !== 'Mutation' && key !== 'Subscription') {\n graphqlResolvers[key] = resolvers[key]\n }\n }\n\n return graphqlResolvers\n}\n\nexport class ServiceError extends GraphQLError {\n extensions: GraphQLErrorExtensions\n\n constructor(\n message: string,\n extensions: {\n code: string\n statusCode: number\n details?: Record<string, any>\n },\n error?: Error\n ) {\n super(message, {\n originalError: error\n })\n this.extensions = extensions\n this.cause = error\n }\n}\n", "import {Context as HonoContext} from 'hono'\nimport type {Toucan} from 'toucan-js'\nimport {AuthState} from './auth'\nimport {AsyncLocalStorage} from 'async_hooks'\nimport {sendFunctionEvent} from '@getcronit/pylon-telemetry'\nimport {env} from 'hono/adapter'\nimport type { GraphQLResolveInfo } from 'graphql'\n\nexport interface Bindings {\n NODE_ENV: string\n AUTH_PROJECT_ID?: string\n AUTH_KEY?: string\n AUTH_ISSUER?: string\n}\n\nexport interface Variables {\n auth: AuthState\n sentry: Toucan\n graphqlResolveInfo?: GraphQLResolveInfo\n}\n\nexport type Env = {\n Bindings: Bindings\n Variables: Variables\n}\n\nexport type Context = HonoContext<Env, string, {}>\n\nexport const asyncContext = new AsyncLocalStorage<Context>()\n\nexport const getContext = () => {\n const start = Date.now()\n const ctx = asyncContext.getStore()\n\n sendFunctionEvent({\n name: 'getContext',\n duration: Date.now() - start\n }).then(() => {})\n\n if (!ctx) {\n throw new Error('Context not defined')\n }\n\n ctx.env = env(ctx)\n\n return ctx\n}\n\nexport const setContext = (context: Context) => {\n return asyncContext.enterWith(context)\n}\n", "import {MiddlewareHandler} from 'hono'\nimport jwt from 'jsonwebtoken'\nimport type {IdTokenClaims, IntrospectionResponse} from 'openid-client'\nimport path from 'path'\nimport {HTTPException} from 'hono/http-exception'\nimport {ContentfulStatusCode} from 'hono/utils/http-status'\nimport {env} from 'hono/adapter'\nimport * as Sentry from '@sentry/bun'\nimport {existsSync, readFileSync} from 'fs'\nimport {sendFunctionEvent} from '@getcronit/pylon-telemetry'\n\nexport type AuthState = IntrospectionResponse &\n IdTokenClaims & {\n roles: string[]\n }\n\nconst authInitialize = () => {\n // Load private key file from cwd\n const authKeyFilePath = path.join(process.cwd(), 'key.json')\n\n // Load private key file from cwd\n let API_PRIVATE_KEY_FILE:\n | {\n type: 'application'\n keyId: string\n key: string\n appId: string\n clientId: string\n }\n | undefined = undefined\n\n if (existsSync(authKeyFilePath)) {\n try {\n API_PRIVATE_KEY_FILE = JSON.parse(readFileSync(authKeyFilePath, 'utf-8'))\n } catch (error) {\n throw new Error(\n 'Error while reading key file. Make sure it is valid JSON'\n )\n }\n }\n\n const middleware: MiddlewareHandler<{\n Variables: {\n auth: AuthState\n }\n }> = Sentry.startSpan(\n {\n name: 'AuthMiddleware',\n op: 'auth'\n },\n () =>\n async function (ctx, next) {\n const AUTH_ISSUER = env(ctx).AUTH_ISSUER\n\n if (!AUTH_ISSUER) {\n throw new Error('AUTH_ISSUER is not set')\n }\n\n if (!API_PRIVATE_KEY_FILE) {\n // If the private key file is not loaded, try to load it from the environment\n const AUTH_KEY = env(ctx).AUTH_KEY as string | undefined\n\n API_PRIVATE_KEY_FILE = AUTH_KEY ? JSON.parse(AUTH_KEY) : undefined\n }\n\n if (!API_PRIVATE_KEY_FILE) {\n throw new Error(\n 'You have initialized the auth middleware without a private key file'\n )\n }\n\n const AUTH_PROJECT_ID = env(ctx).AUTH_PROJECT_ID\n\n const ZITADEL_INTROSPECTION_URL = `${AUTH_ISSUER}/oauth/v2/introspect`\n\n async function getRolesFromToken(tokenString: string) {\n const response = await fetch(\n `${AUTH_ISSUER}/auth/v1/usergrants/me/_search`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${tokenString}`\n }\n }\n )\n\n const data = (await response.json()) as any\n\n const userRoles = (data.result?.map((grant: any) => {\n return (grant.roles || []).map((role: any) => {\n return `${grant.projectId}:${role}`\n })\n }) || []) as string[][]\n\n const projectScopedRoles = userRoles.flat()\n\n const rolesSet = new Set(projectScopedRoles)\n\n // Add unscoped roles based on project id\n // This is useful so that it is not necessary to specify the project id for every role check\n if (AUTH_PROJECT_ID) {\n for (const role of projectScopedRoles) {\n const [projectId, ...roleNameParts] = role.split(':')\n\n const roleName = roleNameParts.join(':')\n\n if (projectId === AUTH_PROJECT_ID) {\n rolesSet.add(roleName)\n }\n }\n }\n\n return Array.from(rolesSet)\n }\n\n async function introspectToken(\n tokenString: string\n ): Promise<AuthState> {\n if (!API_PRIVATE_KEY_FILE) {\n throw new Error('Internal error: API_PRIVATE_KEY_FILE is not set')\n }\n\n // Create JWT for client assertion\n const payload = {\n iss: API_PRIVATE_KEY_FILE.clientId,\n sub: API_PRIVATE_KEY_FILE.clientId,\n aud: AUTH_ISSUER,\n exp: Math.floor(Date.now() / 1000) + 60 * 60, // Expires in 1 hour\n iat: Math.floor(Date.now() / 1000)\n }\n\n const headers = {\n alg: 'RS256',\n kid: API_PRIVATE_KEY_FILE.keyId\n }\n const jwtToken = jwt.sign(payload, API_PRIVATE_KEY_FILE.key, {\n algorithm: 'RS256',\n header: headers\n })\n\n const scopeSet = new Set<string>()\n\n scopeSet.add('openid')\n scopeSet.add('profile')\n scopeSet.add('email')\n\n if (AUTH_PROJECT_ID) {\n scopeSet.add(\n `urn:zitadel:iam:org:project:id:${AUTH_PROJECT_ID}:aud`\n )\n }\n\n const scope = Array.from(scopeSet).join(' ')\n\n // Send introspection request\n const body = new URLSearchParams({\n client_assertion_type:\n 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',\n client_assertion: jwtToken,\n token: tokenString,\n scope\n }).toString()\n\n try {\n const response = await fetch(ZITADEL_INTROSPECTION_URL, {\n method: 'POST',\n headers: {'Content-Type': 'application/x-www-form-urlencoded'},\n body\n })\n\n if (!response.ok) {\n throw new Error('Network response was not ok')\n }\n\n const tokenData = (await response.json()) as IntrospectionResponse\n\n const roles = await getRolesFromToken(tokenString)\n\n const state = {\n ...tokenData,\n roles\n } as AuthState\n\n return state\n } catch (error) {\n console.error('Error while introspecting token', error)\n throw new Error('Token introspection failed')\n }\n }\n\n let token: string | undefined = undefined\n\n if (ctx.req.header('Authorization')) {\n const authHeader = ctx.req.header('Authorization')\n\n if (authHeader) {\n const parts = authHeader.split(' ')\n\n if (parts.length === 2 && parts[0] === 'Bearer') {\n token = parts[1]\n }\n }\n }\n\n if (!token) {\n const queryToken = ctx.req.query('token')\n\n if (queryToken) {\n token = queryToken\n }\n }\n\n if (token) {\n const auth = await introspectToken(token)\n\n if (auth.active) {\n ctx.set('auth', auth)\n\n Sentry.setUser({\n id: auth.sub,\n username: auth.preferred_username,\n email: auth.email,\n details: auth\n })\n }\n }\n\n return next()\n }\n )\n\n sendFunctionEvent({\n name: 'authInitialize',\n duration: 0\n }).then(() => {})\n\n return middleware\n}\n\nexport type AuthRequireChecks = {\n roles?: string[]\n}\n\nconst authRequire = (checks: AuthRequireChecks = {}) => {\n sendFunctionEvent({\n name: 'authRequire',\n duration: 0\n }).then(() => {})\n\n const middleware: MiddlewareHandler<{\n Variables: {\n auth?: AuthState\n }\n }> = async (ctx, next) => {\n const AUTH_PROJECT_ID = env(ctx).AUTH_PROJECT_ID\n\n // Check if user is authenticated\n const auth = ctx.get('auth')\n\n if (!auth) {\n throw new HTTPException(401, {\n message: 'Authentication required'\n })\n }\n\n if (checks.roles) {\n const roles = auth.roles\n\n const hasRole = checks.roles.some(role => {\n return (\n roles.includes(role) || roles.includes(`${AUTH_PROJECT_ID}:${role}`)\n )\n })\n\n if (!hasRole) {\n const resError = new Response('Forbidden', {\n status: 403,\n statusText: 'Forbidden',\n headers: {\n 'Missing-Roles': checks.roles.join(','),\n 'Obtained-Roles': roles.join(',')\n }\n })\n\n throw new HTTPException(resError.status as ContentfulStatusCode, {res: resError})\n }\n }\n\n return next()\n }\n\n sendFunctionEvent({\n name: 'authRequire',\n duration: 0\n }).then(() => {})\n\n return middleware\n}\n\nexport const auth = {\n initialize: authInitialize,\n require: authRequire\n}\n\nexport {requireAuth} from './decorators/requireAuth'\n", "import {sendFunctionEvent} from '@getcronit/pylon-telemetry'\nimport {HTTPException} from 'hono/http-exception'\n\nimport {AuthRequireChecks, auth} from '..'\nimport {getContext} from '../../context'\nimport {ServiceError} from '../../define-pylon'\nimport {createDecorator} from '../../create-decorator'\n\nexport function requireAuth(checks?: AuthRequireChecks) {\n sendFunctionEvent({\n name: 'requireAuth',\n duration: 0\n }).then(() => {})\n\n const checkAuth = async (c: any) => {\n const ctx = await c\n\n try {\n await auth.require(checks)(ctx, async () => {})\n } catch (e) {\n if (e instanceof HTTPException) {\n if (e.status === 401) {\n throw new ServiceError(e.message, {\n statusCode: 401,\n code: 'AUTH_REQUIRED'\n })\n } else if (e.status === 403) {\n const res = e.getResponse()\n\n throw new ServiceError(res.statusText, {\n statusCode: res.status,\n code: 'AUTHORIZATION_REQUIRED',\n details: {\n missingRoles: res.headers.get('Missing-Roles')?.split(','),\n obtainedRoles: res.headers.get('Obtained-Roles')?.split(',')\n }\n })\n } else {\n throw e\n }\n }\n\n throw e\n }\n }\n\n return createDecorator(async () => {\n const ctx = getContext()\n\n await checkAuth(ctx)\n })\n}\n", "import {sendFunctionEvent} from '@getcronit/pylon-telemetry'\n\nexport function createDecorator(callback: (...args: any[]) => Promise<void>) {\n sendFunctionEvent({\n name: 'createDecorator',\n duration: 0\n }).then(() => {})\n\n function MyDecorator<T extends (...args: any[]) => any>(\n target: Object,\n propertyKey: string | symbol\n ): void\n\n function MyDecorator<T>(fn: T): T\n\n function MyDecorator<T>(\n arg1: Object | T,\n propertyKey?: string | symbol,\n descriptor?: PropertyDescriptor\n ): any {\n if (descriptor) {\n const originalMethod = descriptor.value as T\n\n descriptor.value = async function (...args: any[]) {\n await callback(...args)\n return (originalMethod as any).apply(this, args)\n }\n\n return descriptor\n } else {\n if (!descriptor) {\n if (propertyKey === undefined) {\n const originalFunction = arg1 as T\n\n return async function (\n ...args: Parameters<any>\n ): Promise<ReturnType<any>> {\n await callback(...args)\n return (originalFunction as any)(...args)\n } as T\n }\n\n let value: any = arg1[propertyKey]\n Object.defineProperty(arg1, propertyKey, {\n get: function () {\n return async function (...args: Parameters<any>) {\n await callback(...args)\n if (typeof value === 'function') {\n return value(...args)\n }\n\n return value\n }\n },\n set: function (newValue) {\n value = newValue\n },\n enumerable: true,\n configurable: true\n })\n\n return\n }\n }\n }\n\n return MyDecorator\n}\n", "import {Hono, MiddlewareHandler} from 'hono'\nimport {logger} from 'hono/logger'\nimport {sentry} from '@hono/sentry'\n\nimport {asyncContext, Env} from '../context'\n\nexport const app = new Hono<Env>()\n\napp.use('*', sentry())\n\napp.use('*', async (c, next) => {\n return new Promise((resolve, reject) => {\n asyncContext.run(c, async () => {\n try {\n resolve(await next()) // You can pass the value you want to return here\n } catch (error) {\n reject(error) // If an error occurs during the execution of `next()`, reject the Promise\n }\n })\n })\n})\n\napp.use('*', logger())\n\napp.use((c, next) => {\n // @ts-ignore\n c.req.id = crypto.randomUUID()\n return next()\n})\n\nexport const pluginsMiddleware: MiddlewareHandler[] = []\n\nconst pluginsMiddlewareLoader: MiddlewareHandler = async (c, next) => {\n for (const middleware of pluginsMiddleware) {\n const response = await middleware(c, async () => {})\n\n if (response) {\n return response\n }\n }\n\n return next()\n}\n\napp.use(pluginsMiddlewareLoader)\n", "import {createSchema, createYoga} from 'graphql-yoga'\nimport {GraphQLScalarType, Kind} from 'graphql'\nimport {\n DateTimeISOResolver,\n GraphQLVoid,\n JSONObjectResolver,\n JSONResolver\n} from 'graphql-scalars'\n\nimport {useSentry} from '../plugins/use-sentry'\nimport {Context} from '../context'\nimport {resolversToGraphQLResolvers} from '../define-pylon'\nimport {Plugin, PylonConfig} from '..'\nimport {readFileSync} from 'fs'\nimport path from 'path'\nimport {app, pluginsMiddleware} from '.'\nimport {useViewer} from '../plugins/use-viewer'\nimport {useUnhandledRoute} from '../plugins/use-unhandled-route'\n\ninterface PylonHandlerOptions {\n graphql: {\n Query: Record<string, any>\n Mutation?: Record<string, any>\n Subscription?: Record<string, any>\n }\n config?: PylonConfig\n}\n\ntype MaybeLazyObject<T> = T | (() => T)\n\nconst resolveLazyObject = <T>(obj: MaybeLazyObject<T>): T => {\n return typeof obj === 'function' ? (obj as () => T)() : obj\n}\n\nexport const handler = (options: PylonHandlerOptions) => {\n let {\n typeDefs,\n resolvers,\n graphql: graphql$,\n config: config$\n } = options as PylonHandlerOptions & {\n typeDefs?: string\n resolvers?: Record<string, any>\n }\n\n const loadPluginsMiddleware = (plugins: Plugin[]) => {\n for (const plugin of plugins) {\n plugin.setup?.(app)\n\n if (plugin.middleware) {\n pluginsMiddleware.push(plugin.middleware)\n }\n }\n }\n\n const graphql = resolveLazyObject(graphql$)\n\n const config = resolveLazyObject(config$)\n\n const plugins = [useSentry(), useViewer(), ...(config?.plugins || [])]\n\n if (config?.landingPage ?? true) {\n plugins.push(\n useUnhandledRoute({\n graphqlEndpoint: '/graphql'\n })\n )\n }\n\n loadPluginsMiddleware(plugins)\n\n if (!typeDefs) {\n // Try to read the schema from the default location\n const schemaPath = path.join(process.cwd(), '.pylon', 'schema.graphql')\n\n // If `schemaPath` is provided, read the schema from the file\n if (schemaPath) {\n typeDefs = readFileSync(schemaPath, 'utf-8')\n }\n }\n\n if (!typeDefs) {\n throw new Error('No schema provided.')\n }\n\n if (!resolvers) {\n // Try to read the resolvers from the default location\n const resolversPath = path.join(process.cwd(), '.pylon', 'resolvers.js')\n\n // If `resolversPath` is provided, read the resolvers from the file\n\n if (resolversPath) {\n resolvers = require(resolversPath).resolvers\n }\n }\n\n const graphqlResolvers = resolversToGraphQLResolvers(graphql)\n\n const schema = createSchema<Context>({\n typeDefs,\n resolvers: {\n ...graphqlResolvers,\n ...resolvers,\n // Transforms a date object to a timestamp\n Date: DateTimeISOResolver,\n JSON: JSONResolver,\n Object: JSONObjectResolver,\n Void: GraphQLVoid,\n Number: new GraphQLScalarType({\n name: 'Number',\n description: 'Custom scalar that handles both integers and floats',\n\n // Parsing input from query variables\n parseValue(value) {\n if (typeof value !== 'number') {\n throw new TypeError(`Value is not a number: ${value}`)\n }\n return value // Valid number\n },\n\n // Validation when sending from client (input literals)\n parseLiteral(ast) {\n if (ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n return parseFloat(ast.value) // Convert the value to a float\n }\n throw new TypeError(\n `Value is not a valid number or float: ${\n 'value' in ast ? ast.value : ast\n }`\n )\n },\n\n // Serialize output to be sent to the client\n serialize(value) {\n if (typeof value !== 'number') {\n throw new TypeError(`Value is not a number: ${value}`)\n }\n return value\n }\n })\n }\n })\n\n const yoga = createYoga({\n landingPage: false,\n graphiql: req => {\n return {\n shouldPersistHeaders: true,\n title: 'Pylon Playground',\n defaultQuery: `# Welcome to the Pylon Playground!`\n }\n },\n graphqlEndpoint: '/graphql',\n ...config,\n plugins,\n schema\n })\n\n const handler = async (c: Context): Promise<Response> => {\n let executionContext: Context['executionCtx'] | {} = {}\n\n try {\n executionContext = c.executionCtx\n } catch (e) {}\n\n const response = await yoga.fetch(c.req.raw, c.env, executionContext)\n\n return c.newResponse(response.body, response)\n }\n\n return handler\n}\n", "import {GraphQLError, Kind, OperationDefinitionNode, print} from 'graphql'\nimport {\n getDocumentString,\n handleStreamOrSingleExecutionResult,\n isOriginalGraphQLError,\n OnExecuteDoneHookResultOnNextHook,\n TypedExecutionArgs\n} from '@envelop/core'\nimport * as Sentry from '@sentry/node'\nimport type {Span, TraceparentData} from '@sentry/types'\nimport {Plugin} from '..'\n\nexport type SentryPluginOptions<PluginContext extends Record<string, any>> = {\n /**\n * Starts a new transaction for every GraphQL Operation.\n * When disabled, an already existing Transaction will be used.\n *\n * @default true\n */\n startTransaction?: boolean\n /**\n * Renames Transaction.\n * @default false\n */\n renameTransaction?: boolean\n /**\n * Adds result of each resolver and operation to Span's data (available under \"result\")\n * @default false\n */\n includeRawResult?: boolean\n /**\n * Adds operation's variables to a Scope (only in case of errors)\n * @default false\n */\n includeExecuteVariables?: boolean\n /**\n * The key of the event id in the error's extension. `null` to disable.\n * @default sentryEventId\n */\n eventIdKey?: string | null\n /**\n * Adds custom tags to every Transaction.\n */\n appendTags?: (\n args: TypedExecutionArgs<PluginContext>\n ) => Record<string, unknown>\n /**\n * Callback to set context information onto the scope.\n */\n configureScope?: (\n args: TypedExecutionArgs<PluginContext>,\n scope: Sentry.Scope\n ) => void\n /**\n * Produces a name of Transaction (only when \"renameTransaction\" or \"startTransaction\" are enabled) and description of created Span.\n *\n * @default operation's name or \"Anonymous Operation\" when missing)\n */\n transactionName?: (args: TypedExecutionArgs<PluginContext>) => string\n /**\n * Produces tracing data for Transaction\n *\n * @default is empty\n */\n traceparentData?: (\n args: TypedExecutionArgs<PluginContext>\n ) => TraceparentData | undefined\n /**\n * Produces a \"op\" (operation) of created Span.\n *\n * @default execute\n */\n operationName?: (args: TypedExecutionArgs<PluginContext>) => string\n /**\n * Indicates whether or not to skip the entire Sentry flow for given GraphQL operation.\n * By default, no operations are skipped.\n */\n skip?: (args: TypedExecutionArgs<PluginContext>) => boolean\n /**\n * Indicates whether or not to skip Sentry exception reporting for a given error.\n * By default, this plugin skips all `GraphQLError` errors and does not report it to Sentry.\n */\n skipError?: (args: Error) => boolean\n}\n\nexport const defaultSkipError = isOriginalGraphQLError\n\nexport const useSentry = <PluginContext extends Record<string, any> = {}>(\n options: SentryPluginOptions<PluginContext> = {}\n): Plugin<PluginContext> => {\n function pick<K extends keyof SentryPluginOptions<PluginContext>>(\n key: K,\n defaultValue: NonNullable<SentryPluginOptions<PluginContext>[K]>\n ) {\n return options[key] ?? defaultValue\n }\n\n const startTransaction = pick('startTransaction', true)\n const includeRawResult = pick('includeRawResult', false)\n const includeExecuteVariables = pick('includeExecuteVariables', false)\n const renameTransaction = pick('renameTransaction', false)\n const skipOperation = pick('skip', () => false)\n const skipError = pick('skipError', defaultSkipError)\n\n const eventIdKey = options.eventIdKey === null ? null : 'sentryEventId'\n\n function addEventId(err: GraphQLError, eventId: string | null): GraphQLError {\n if (eventIdKey !== null && eventId !== null) {\n err.extensions[eventIdKey] = eventId\n }\n\n return err\n }\n\n return {\n onExecute({args}) {\n if (skipOperation(args)) {\n return\n }\n\n const rootOperation = args.document.definitions.find(\n o => o.kind === Kind.OPERATION_DEFINITION\n ) as OperationDefinitionNode\n const operationType = rootOperation.operation\n\n const document = getDocumentString(args.document, print)\n\n const opName =\n args.operationName || rootOperation.name?.value || 'Anonymous Operation'\n const addedTags: Record<string, any> =\n (options.appendTags && options.appendTags(args)) || {}\n const traceparentData =\n (options.traceparentData && options.traceparentData(args)) || {}\n\n const transactionName = options.transactionName\n ? options.transactionName(args)\n : opName\n const op = options.operationName ? options.operationName(args) : 'execute'\n const tags = {\n operationName: opName,\n operation: operationType,\n ...addedTags\n }\n\n if (options.configureScope) {\n options.configureScope(args, Sentry.getCurrentScope())\n }\n\n return {\n onExecuteDone(payload) {\n const handleResult: OnExecuteDoneHookResultOnNextHook<{}> = ({\n result,\n setResult\n }) => {\n Sentry.startSpanManual(\n {\n op,\n name: opName,\n attributes: tags\n },\n span => {\n if (renameTransaction) {\n span.updateName(transactionName)\n }\n\n span.setAttribute('document', document)\n\n if (includeRawResult) {\n span.setAttribute('result', JSON.stringify(result))\n }\n\n if (result.errors && result.errors.length > 0) {\n Sentry.withScope(scope => {\n scope.setTransactionName(opName)\n scope.setTag('operation', operationType)\n scope.setTag('operationName', opName)\n scope.setExtra('document', document)\n\n scope.setTags(addedTags || {})\n\n if (includeRawResult) {\n scope.setExtra('result', result)\n }\n\n if (includeExecuteVariables) {\n scope.setExtra('variables', args.variableValues)\n }\n\n const errors = result.errors?.map(err => {\n if (skipError(err) === true) {\n return err\n }\n\n const errorPath = (err.path ?? [])\n .map((v: string | number) =>\n typeof v === 'number' ? '$index' : v\n )\n .join(' > ')\n\n if (errorPath) {\n scope.addBreadcrumb({\n category: 'execution-path',\n message: errorPath,\n level: 'debug'\n })\n }\n\n const eventId = Sentry.captureException(\n err.originalError,\n {\n fingerprint: [\n 'graphql',\n errorPath,\n opName,\n operationType\n ],\n contexts: {\n GraphQL: {\n operationName: opName,\n operationType,\n variables: args.variableValues\n }\n }\n }\n )\n\n return addEventId(err, eventId)\n })\n\n setResult({\n ...result,\n errors\n })\n })\n }\n\n span.end()\n }\n )\n }\n return handleStreamOrSingleExecutionResult(payload, handleResult)\n }\n }\n }\n }\n}\n", "import {html} from 'hono/html'\nimport {getContext, type Plugin} from '../index'\n\nexport function useViewer(): Plugin {\n return {\n onRequest: async ({request, fetchAPI, endResponse, url}) => {\n const c = getContext()\n\n if (request.method === 'GET' && url.pathname === '/viewer') {\n endResponse(\n c.html(\n await html`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Pylon Viewer</title>\n <script src=\"https://cdn.jsdelivr.net/npm/react@16/umd/react.production.min.js\"></script>\n <script src=\"https://cdn.jsdelivr.net/npm/react-dom@16/umd/react-dom.production.min.js\"></script>\n\n <link\n rel=\"stylesheet\"\n href=\"https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.css\"\n />\n <style>\n body {\n padding: 0;\n margin: 0;\n width: 100%;\n height: 100vh;\n overflow: hidden;\n }\n\n #voyager {\n height: 100%;\n position: relative;\n }\n }\n </style>\n <script src=\"https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.min.js\"></script>\n </head>\n <body>\n <div id=\"voyager\">Loading...</div>\n <script>\n function introspectionProvider(introspectionQuery) {\n // ... do a call to server using introspectionQuery provided\n // or just return pre-fetched introspection\n\n // Endpoint is current path instead of root/graphql\n const endpoint = window.location.pathname.replace(\n '/viewer',\n '/graphql'\n )\n\n return fetch(endpoint, {\n method: 'post',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({query: introspectionQuery})\n }).then(response => response.json())\n }\n\n // Render <Voyager />\n GraphQLVoyager.init(document.getElementById('voyager'), {\n introspection: introspectionProvider\n })\n </script>\n </body>\n </html>\n `\n )\n )\n }\n }\n }\n}\n", "import {getVersions} from '@getcronit/pylon-telemetry'\nimport {html} from 'hono/html'\nimport {type Plugin} from '../index'\n\nexport function useUnhandledRoute(args: {graphqlEndpoint: string}): Plugin {\n const versions = getVersions()\n\n return {\n setup: app => {\n app.use(async (c, next) => {\n if (c.req.method === 'GET' && c.req.path !== args.graphqlEndpoint) {\n return c.html(\n await html`<!doctype html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>Welcome to Pylon</title>\n <link\n rel=\"icon\"\n href=\"https://pylon.cronit.io/favicon/favicon.ico\"\n />\n <style>\n body,\n html {\n padding: 0;\n margin: 0;\n height: 100%;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n 'Roboto',\n 'Oxygen',\n 'Ubuntu',\n 'Cantarell',\n 'Fira Sans',\n 'Droid Sans',\n 'Helvetica Neue',\n sans-serif;\n color: white;\n background-color: black;\n }\n \n main > section.hero {\n display: flex;\n height: 90vh;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n }\n \n .logo {\n display: flex;\n align-items: center;\n }\n \n .logo-svg {\n width: 100%\n }\n \n .buttons {\n margin-top: 24px;\n }\n \n h1 {\n font-size: 80px;\n }\n \n h2 {\n color: #888;\n max-width: 50%;\n margin-top: 0;\n text-align: center;\n }\n \n a {\n color: #fff;\n text-decoration: none;\n margin-left: 10px;\n margin-right: 10px;\n font-weight: bold;\n transition: color 0.3s ease;\n padding: 4px;\n overflow: visible;\n }\n \n a.graphiql:hover {\n color: rgba(255, 0, 255, 0.7);\n }\n a.docs:hover {\n color: rgba(28, 200, 238, 0.7);\n }\n a.tutorial:hover {\n color: rgba(125, 85, 245, 0.7);\n }\n svg {\n margin-right: 24px;\n }\n \n .not-what-your-looking-for {\n margin-top: 5vh;\n }\n \n .not-what-your-looking-for > * {\n margin-left: auto;\n margin-right: auto;\n }\n \n .not-what-your-looking-for > p {\n text-align: center;\n }\n \n .not-what-your-looking-for > h2 {\n color: #464646;\n }\n \n .not-what-your-looking-for > p {\n max-width: 600px;\n line-height: 1.3em;\n }\n \n .not-what-your-looking-for > pre {\n max-width: 300px;\n }\n </style>\n </head>\n <body id=\"body\">\n <main>\n <section class=\"hero\">\n <div class=\"logo\">\n <div>\n <svg class=\"logo-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" zoomAndPan=\"magnify\" viewBox=\"0 0 286.5 121.500001\" preserveAspectRatio=\"xMidYMid meet\" version=\"1.0\"><defs><g></g><clipPath id=\"38f6fcde47\"><path d=\"M 0.339844 42 L 10 42 L 10 79 L 0.339844 79 Z M 0.339844 42 \" clip-rule=\"nonzero\"></path></clipPath><clipPath id=\"af000f7256\"><path d=\"M 64 23.925781 L 72.789062 23.925781 L 72.789062 96.378906 L 64 96.378906 Z M 64 23.925781 \" clip-rule=\"nonzero\"></path></clipPath></defs><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(107.11969, 78.49768)\"><g><path d=\"M 10.078125 -25.046875 C 11.109375 -26.398438 12.507812 -27.535156 14.28125 -28.453125 C 16.0625 -29.378906 18.070312 -29.84375 20.3125 -29.84375 C 22.863281 -29.84375 25.195312 -29.210938 27.3125 -27.953125 C 29.425781 -26.691406 31.085938 -24.921875 32.296875 -22.640625 C 33.503906 -20.367188 34.109375 -17.757812 34.109375 -14.8125 C 34.109375 -11.863281 33.503906 -9.222656 32.296875 -6.890625 C 31.085938 -4.566406 29.425781 -2.753906 27.3125 -1.453125 C 25.195312 -0.160156 22.863281 0.484375 20.3125 0.484375 C 18.070312 0.484375 16.078125 0.03125 14.328125 -0.875 C 12.585938 -1.78125 11.171875 -2.910156 10.078125 -4.265625 L 10.078125 13.96875 L 4 13.96875 L 4 -29.359375 L 10.078125 -29.359375 Z M 27.921875 -14.8125 C 27.921875 -16.84375 27.503906 -18.59375 26.671875 -20.0625 C 25.835938 -21.539062 24.734375 -22.660156 23.359375 -23.421875 C 21.992188 -24.179688 20.53125 -24.5625 18.96875 -24.5625 C 17.445312 -24.5625 16 -24.171875 14.625 -23.390625 C 13.257812 -22.609375 12.160156 -21.472656 11.328125 -19.984375 C 10.492188 -18.492188 10.078125 -16.734375 10.078125 -14.703125 C 10.078125 -12.679688 10.492188 -10.914062 11.328125 -9.40625 C 12.160156 -7.894531 13.257812 -6.75 14.625 -5.96875 C 16 -5.1875 17.445312 -4.796875 18.96875 -4.796875 C 20.53125 -4.796875 21.992188 -5.191406 23.359375 -5.984375 C 24.734375 -6.785156 25.835938 -7.953125 26.671875 -9.484375 C 27.503906 -11.015625 27.921875 -12.789062 27.921875 -14.8125 Z M 27.921875 -14.8125 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(143.259256, 78.49768)\"><g><path d=\"M 30.4375 -29.359375 L 12.421875 13.796875 L 6.125 13.796875 L 12.09375 -0.484375 L 0.53125 -29.359375 L 7.296875 -29.359375 L 15.5625 -6.984375 L 24.140625 -29.359375 Z M 30.4375 -29.359375 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(174.281707, 78.49768)\"><g><path d=\"M 10.078125 -39.4375 L 10.078125 0 L 4 0 L 4 -39.4375 Z M 10.078125 -39.4375 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(188.353752, 78.49768)\"><g><path d=\"M 16.734375 0.484375 C 13.960938 0.484375 11.457031 -0.144531 9.21875 -1.40625 C 6.976562 -2.664062 5.21875 -4.441406 3.9375 -6.734375 C 2.664062 -9.035156 2.03125 -11.691406 2.03125 -14.703125 C 2.03125 -17.691406 2.6875 -20.335938 4 -22.640625 C 5.3125 -24.953125 7.101562 -26.726562 9.375 -27.96875 C 11.65625 -29.21875 14.195312 -29.84375 17 -29.84375 C 19.8125 -29.84375 22.351562 -29.21875 24.625 -27.96875 C 26.894531 -26.726562 28.6875 -24.953125 30 -22.640625 C 31.320312 -20.335938 31.984375 -17.691406 31.984375 -14.703125 C 31.984375 -11.722656 31.304688 -9.078125 29.953125 -6.765625 C 28.597656 -4.453125 26.757812 -2.664062 24.4375 -1.40625 C 22.113281 -0.144531 19.546875 0.484375 16.734375 0.484375 Z M 16.734375 -4.796875 C 18.296875 -4.796875 19.757812 -5.164062 21.125 -5.90625 C 22.5 -6.65625 23.613281 -7.773438 24.46875 -9.265625 C 25.320312 -10.765625 25.75 -12.578125 25.75 -14.703125 C 25.75 -16.835938 25.335938 -18.640625 24.515625 -20.109375 C 23.703125 -21.585938 22.617188 -22.695312 21.265625 -23.4375 C 19.910156 -24.1875 18.453125 -24.5625 16.890625 -24.5625 C 15.328125 -24.5625 13.878906 -24.1875 12.546875 -23.4375 C 11.210938 -22.695312 10.15625 -21.585938 9.375 -20.109375 C 8.59375 -18.640625 8.203125 -16.835938 8.203125 -14.703125 C 8.203125 -11.546875 9.007812 -9.101562 10.625 -7.375 C 12.25 -5.65625 14.285156 -4.796875 16.734375 -4.796875 Z M 16.734375 -4.796875 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(222.361196, 78.49768)\"><g><path d=\"M 18.8125 -29.84375 C 21.125 -29.84375 23.191406 -29.363281 25.015625 -28.40625 C 26.847656 -27.445312 28.28125 -26.023438 29.3125 -24.140625 C 30.34375 -22.253906 30.859375 -19.984375 30.859375 -17.328125 L 30.859375 0 L 24.84375 0 L 24.84375 -16.421875 C 24.84375 -19.046875 24.179688 -21.054688 22.859375 -22.453125 C 21.546875 -23.859375 19.753906 -24.5625 17.484375 -24.5625 C 15.210938 -24.5625 13.410156 -23.859375 12.078125 -22.453125 C 10.742188 -21.054688 10.078125 -19.046875 10.078125 -16.421875 L 10.078125 0 L 4 0 L 4 -29.359375 L 10.078125 -29.359375 L 10.078125 -26.015625 C 11.066406 -27.222656 12.332031 -28.160156 13.875 -28.828125 C 15.425781 -29.503906 17.070312 -29.84375 18.8125 -29.84375 Z M 18.8125 -29.84375 \"></path></g></g></g><path fill=\"currentColor\" d=\"M 53.359375 31.652344 L 53.359375 88.6875 L 62.410156 90.859375 L 62.410156 29.484375 Z M 53.359375 31.652344 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path><g clip-path=\"url(#38f6fcde47)\"><path fill=\"currentColor\" d=\"M 0.339844 47.433594 L 0.339844 72.910156 C 0.339844 73.34375 0.410156 73.769531 0.554688 74.179688 C 0.699219 74.59375 0.90625 74.96875 1.175781 75.3125 C 1.445312 75.65625 1.765625 75.945312 2.132812 76.179688 C 2.503906 76.414062 2.898438 76.582031 3.324219 76.683594 L 9.390625 78.140625 L 9.390625 42.195312 L 3.3125 43.660156 C 2.890625 43.761719 2.492188 43.929688 2.125 44.164062 C 1.761719 44.402344 1.441406 44.6875 1.171875 45.03125 C 0.902344 45.375 0.695312 45.75 0.554688 46.164062 C 0.410156 46.574219 0.339844 46.996094 0.339844 47.433594 Z M 0.339844 47.433594 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path></g><g clip-path=\"url(#af000f7256)\"><path fill=\"currentColor\" d=\"M 64.996094 95.085938 L 64.996094 25.253906 C 64.996094 25.082031 65.027344 24.917969 65.09375 24.761719 C 65.160156 24.601562 65.253906 24.460938 65.375 24.339844 C 65.496094 24.21875 65.636719 24.125 65.792969 24.0625 C 65.953125 23.996094 66.117188 23.960938 66.289062 23.960938 L 71.460938 23.960938 C 71.632812 23.960938 71.796875 23.996094 71.957031 24.0625 C 72.113281 24.125 72.253906 24.21875 72.375 24.339844 C 72.496094 24.460938 72.589844 24.601562 72.65625 24.761719 C 72.722656 24.917969 72.753906 25.082031 72.753906 25.253906 L 72.753906 95.085938 C 72.753906 95.257812 72.722656 95.421875 72.65625 95.582031 C 72.589844 95.738281 72.496094 95.878906 72.375 96 C 72.253906 96.121094 72.113281 96.214844 71.957031 96.28125 C 71.796875 96.347656 71.632812 96.378906 71.460938 96.378906 L 66.289062 96.378906 C 66.117188 96.378906 65.953125 96.347656 65.792969 96.28125 C 65.636719 96.214844 65.496094 96.121094 65.375 96 C 65.253906 95.878906 65.160156 95.738281 65.09375 95.582031 C 65.027344 95.421875 64.996094 95.257812 64.996094 95.085938 Z M 64.996094 95.085938 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path></g><path fill=\"currentColor\" d=\"M 22.320312 81.238281 L 22.320312 39.101562 L 11.976562 41.585938 L 11.976562 78.757812 Z M 22.320312 81.238281 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path><path fill=\"currentColor\" d=\"M 50.769531 88.066406 L 50.769531 32.277344 L 37.839844 35.378906 L 37.839844 84.960938 Z M 50.769531 88.066406 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path><path fill=\"currentColor\" d=\"M 24.90625 81.863281 L 35.253906 84.34375 L 35.253906 35.996094 L 24.90625 38.480469 Z M 24.90625 81.863281 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path></svg>\n </div>\n <p>Version: ${versions.pylonVersion}</p>\n </div>\n <h2>Enables TypeScript developers to easily build GraphQL APIs</h2>\n <div class=\"buttons\">\n <a href=\"https://pylon.cronit.io/docs\" class=\"docs\"\n >Read the Docs</add\n >\n <a href=\"/graphql\" class=\"graphiql\">Visit GraphiQL</a>\n <a href=\"/viewer\" class=\"graphiql\">Visit Viewer</a>\n </div>\n </section>\n <section class=\"not-what-your-looking-for\">\n <h2>Not the page you are looking for? \uD83D\uDC40</h2>\n <p>\n This page is shown be default whenever a 404 is hit.<br />You can disable this by behavior\n via the <code>landingPage</code> option in the Pylon config. Edit the <code>src/index.ts</code> file\n and add the following code:\n </p>\n <pre>\n <code>\n export const config: PylonConfig = {\n landingPage: false\n }\n </code>\n </pre>\n \n <p>\n When you define a route, this page will no longer be shown. For example, the following code\n will show a \"Hello, world!\" message at the root of your app:\n </p>\n <pre>\n <code>\n import {app} from '@getcronit/pylon'\n \n app.get(\"/\", c => {\n return c.text(\"Hello, world!\")\n })\n </code>\n </pre>\n </section>\n </main>\n </body>\n </html>`,\n 404\n )\n }\n\n return next()\n })\n }\n }\n}\n", "import {sendFunctionEvent} from '@getcronit/pylon-telemetry'\nimport {asyncContext, Context} from './context'\n\nexport function getEnv() {\n const start = Date.now()\n const skipTracing = arguments[0] === true\n\n try {\n const context = asyncContext.getStore() as Context\n\n // Fall back to process.env or an empty object if no context is available\n // This is useful for testing\n // ref: https://hono.dev/docs/guides/testing#env\n return context.env || process.env || {}\n } catch {\n return process.env\n } finally {\n if (!skipTracing) {\n sendFunctionEvent({\n name: 'getEnv',\n duration: Date.now() - start\n }).then(() => {})\n }\n }\n}\n", "import {Env} from './context.js'\n\nexport {ServiceError} from './define-pylon.js'\nexport * from './auth/index.js'\nexport {\n Context,\n Env,\n Variables,\n Bindings,\n asyncContext,\n getContext,\n setContext\n} from './context.js'\nimport {app as pylonApp} from './app/index.js'\nexport {pylonApp as app}\nexport {handler} from './app/pylon-handler.js'\nexport {getEnv} from './get-env.js'\nexport {createDecorator} from './create-decorator.js'\nexport {createPubSub as experimentalCreatePubSub} from 'graphql-yoga'\n\nimport type {Plugin as YogaPlugin} from 'graphql-yoga'\nimport {MiddlewareHandler} from 'hono'\n\nexport type Plugin<\n PluginContext extends Record<string, any> = {},\n TServerContext extends Record<string, any> = {},\n TUserContext = {}\n> = YogaPlugin<PluginContext, TServerContext, TUserContext> & {\n middleware?: MiddlewareHandler<Env>\n setup?: (app: typeof pylonApp) => void\n build?: () => Promise<void>\n}\n\nexport type PylonConfig = {\n landingPage?: boolean\n plugins?: Plugin[]\n}\n\nexport type ID = string & {readonly brand?: unique symbol}\nexport type Int = number & {readonly brand?: unique symbol}\nexport type Float = number & {readonly brand?: unique symbol}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAAA,YAAY,YAAY;AACxB,OAAO,aAAa;AACpB;AAAA,EAEE;AAAA,OAKK;;;ACNP,SAAQ,yBAAwB;AAChC,SAAQ,yBAAwB;AAChC,SAAQ,WAAU;AAuBX,IAAM,eAAe,IAAI,kBAA2B;AAEpD,IAAM,aAAa,MAAM;AAC9B,QAAM,QAAQ,KAAK,IAAI;AACvB,QAAM,MAAM,aAAa,SAAS;AAElC,oBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,UAAU,KAAK,IAAI,IAAI;AAAA,EACzB,CAAC,EAAE,KAAK,MAAM;AAAA,EAAC,CAAC;AAEhB,MAAI,CAAC,KAAK;AACR,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Q;AAAA,EAC9C;AAEA,SAAOA;AACT;;;AI3KA,SAAQ,qBAAAC,0BAAwB;AAGzB,SAAS,SAAS;AACvB,QAAM,QAAQ,KAAK,IAAI;AACvB,QAAM,cAAc,UAAU,CAAC,MAAM;AAErC,MAAI;AACF,UAAM,UAAU,aAAa,SAAS;AAKtC,WAAO,QAAQ,OAAO,QAAQ,OAAO,CAAC;AAAA,EACxC,QAAQ;AACN,WAAO,QAAQ;AAAA,EACjB,UAAE;AACA,QAAI,CAAC,aAAa;AAChB,MAAAC,mBAAkB;AAAA,QAChB,MAAM;AAAA,QACN,UAAU,KAAK,IAAI,IAAI;AAAA,MACzB,CAAC,EAAE,KAAK,MAAM;AAAA,MAAC,CAAC;AAAA,IAClB;AAAA,EACF;AACF;;;ACNA,SAAwB,oBAA+B;",
|
|
6
|
-
"names": ["ctx", "
|
|
3
|
+
"sources": ["../src/define-pylon.ts", "../src/context.ts", "../src/plugins/use-auth/use-auth.ts", "../src/plugins/use-auth/import-private-key.ts", "../src/plugins/use-auth/auth-require.ts", "../src/create-decorator.ts", "../src/app/index.ts", "../src/app/pylon-handler.ts", "../src/plugins/use-sentry.ts", "../src/plugins/use-viewer.ts", "../src/plugins/use-unhandled-route.ts", "../src/get-env.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as Sentry from '@sentry/bun'\nimport consola from 'consola'\nimport {\n FragmentDefinitionNode,\n GraphQLError,\n GraphQLErrorExtensions,\n GraphQLObjectType,\n GraphQLResolveInfo,\n SelectionSetNode\n} from 'graphql'\n\nimport {Context, asyncContext} from './context'\nimport {isAsyncIterable, Maybe} from 'graphql-yoga'\n\nexport interface Resolvers {\n Query: Record<string, any>\n Mutation?: Record<string, any>\n Subscription?: Record<string, any>\n}\n\ntype FunctionWrapper = (fn: (...args: any[]) => any) => (...args: any[]) => any\n\nfunction getAllPropertyNames(instance: any): string[] {\n const allProps = new Set<string>()\n\n // Traverse the prototype chain\n let currentObj: any = instance\n\n while (currentObj && currentObj !== Object.prototype) {\n // Get all own property names of the current object\n const ownProps = Object.getOwnPropertyNames(currentObj)\n\n // Add each property to the Set\n ownProps.forEach(prop => allProps.add(prop))\n\n // Move up the prototype chain\n currentObj = Object.getPrototypeOf(currentObj)\n }\n\n // Convert Set to array and filter out the constructor if desired\n return Array.from(allProps).filter(prop => prop !== 'constructor')\n}\n\nasync function wrapFunctionsRecursively(\n obj: any,\n wrapper: FunctionWrapper,\n that: any = null,\n selectionSet: SelectionSetNode['selections'] = [],\n info: GraphQLResolveInfo\n): Promise<any> {\n // Skip if the object is a Date object or any other special object.\n // Those objects are then handled by custom resolvers.\n if (obj === null || obj instanceof Date) {\n return obj\n }\n\n if (Array.isArray(obj)) {\n return await Promise.all(\n obj.map(async item => {\n return await wrapFunctionsRecursively(\n item,\n wrapper,\n that,\n selectionSet,\n info\n )\n })\n )\n } else if (typeof obj === 'function') {\n return Sentry.startSpan(\n {\n name: obj.name,\n op: 'pylon.fn'\n },\n async () => {\n // @ts-ignore\n return await wrapper.call(that, obj, selectionSet, info)\n }\n )\n } else if (obj instanceof Promise) {\n return await wrapFunctionsRecursively(\n await obj,\n wrapper,\n that,\n selectionSet,\n info\n )\n } else if (isAsyncIterable(obj)) {\n return obj\n } else if (typeof obj === 'object') {\n that = obj\n\n const result: Record<string, any> = {}\n\n for (const key of getAllPropertyNames(obj)) {\n result[key] = await wrapFunctionsRecursively(\n obj[key],\n wrapper,\n that,\n selectionSet,\n info\n )\n }\n\n return result\n } else {\n return await obj\n }\n}\nfunction spreadFunctionArguments<T extends (...args: any[]) => any>(fn: T) {\n return (otherArgs: Record<string, any>, c: any, info: GraphQLResolveInfo) => {\n const selections = arguments[1] as SelectionSetNode['selections']\n const realInfo = arguments[2] as GraphQLResolveInfo\n\n let args: Record<string, any> = {}\n\n if (info) {\n const type = info.parentType\n\n const field = type.getFields()[info.fieldName]\n\n const fieldArguments = field?.args\n\n const preparedArguments = fieldArguments?.reduce(\n (acc: {[x: string]: undefined}, arg: {name: string | number}) => {\n if (otherArgs[arg.name] !== undefined) {\n acc[arg.name] = otherArgs[arg.name]\n } else {\n acc[arg.name] = undefined\n }\n\n return acc\n },\n {} as Record<string, any>\n )\n\n if (preparedArguments) {\n args = preparedArguments\n }\n } else {\n args = otherArgs\n }\n\n const orderedArgs = Object.keys(args).map(key => args[key])\n\n const that = this || {}\n\n const result = wrapFunctionsRecursively(\n fn.call(that, ...orderedArgs),\n spreadFunctionArguments,\n this,\n selections,\n realInfo\n )\n\n return result as ReturnType<typeof fn>\n }\n}\n\n/**\n * Converts a set of resolvers into a corresponding set of GraphQL resolvers.\n * @param resolvers The original resolvers.\n * @returns The converted GraphQL resolvers.\n */\nexport const resolversToGraphQLResolvers = (\n resolvers: Resolvers,\n configureContext?: (context: Context) => Context\n): Resolvers => {\n // Define a root resolver function that maps a given resolver function or object to a GraphQL resolver.\n const rootGraphqlResolver =\n (fn: Function | object | Promise<Function> | Promise<object>) =>\n async (\n _: object,\n args: Record<string, any>,\n ctx: Context,\n info: GraphQLResolveInfo\n ) => {\n return Sentry.withScope(async scope => {\n const ctx = asyncContext.getStore()\n\n if (!ctx) {\n consola.warn(\n 'Context is not defined. Make sure AsyncLocalStorage is supported in your environment.'\n )\n }\n\n ctx?.set('graphqlResolveInfo', info)\n\n const auth = ctx?.get('auth')\n\n if (auth?.user) {\n scope.setUser({\n id: auth.user.sub,\n username: auth.user.preferred_username,\n email: auth.user.email,\n details: auth.user\n })\n }\n\n // get query or mutation field\n\n let type: Maybe<GraphQLObjectType> | null = null\n\n switch (info.operation.operation) {\n case 'query':\n type = info.schema.getQueryType()\n break\n case 'mutation':\n type = info.schema.getMutationType()\n break\n case 'subscription':\n type = info.schema.getSubscriptionType()\n break\n default:\n throw new Error('Unknown operation')\n }\n\n const field = type?.getFields()[info.fieldName]\n\n // Get the list of arguments expected by the current query field.\n const fieldArguments = field?.args || []\n\n // Prepare the arguments for the resolver function call by adding any missing arguments with an undefined value.\n const preparedArguments = fieldArguments.reduce(\n (acc: {[x: string]: undefined}, arg: {name: string | number}) => {\n if (args[arg.name] !== undefined) {\n acc[arg.name] = args[arg.name]\n } else {\n acc[arg.name] = undefined\n }\n\n return acc\n },\n {} as Record<string, any>\n )\n\n // Determine the resolver function to call (either the given function or the wrappedWithContext function if it exists).\n let inner = await fn\n\n let baseSelectionSet: SelectionSetNode['selections'] = []\n\n // Find the selection set for the current field.\n for (const selection of info.operation.selectionSet.selections) {\n if (\n selection.kind === 'Field' &&\n selection.name.value === info.fieldName\n ) {\n baseSelectionSet = selection.selectionSet?.selections || []\n }\n }\n\n // Wrap the resolver function with any required middleware.\n const wrappedFn = await wrapFunctionsRecursively(\n inner,\n spreadFunctionArguments,\n this,\n baseSelectionSet,\n info\n )\n\n // Call the resolver function with the prepared arguments.\n if (typeof wrappedFn !== 'function') {\n return wrappedFn\n }\n\n const res = await wrappedFn(preparedArguments)\n\n return res\n })\n }\n\n // Convert the Query and Mutation resolvers to GraphQL resolvers.\n const graphqlResolvers = {} as Resolvers\n\n // Remove empty resolvers\n for (const key of Object.keys(resolvers.Query)) {\n if (!resolvers.Query[key]) {\n delete resolvers.Query[key]\n }\n }\n\n if (resolvers.Query && Object.keys(resolvers.Query).length > 0) {\n for (const [key, value] of Object.entries(resolvers.Query)) {\n if (!graphqlResolvers.Query) {\n graphqlResolvers.Query = {}\n }\n\n graphqlResolvers.Query[key] = rootGraphqlResolver(\n value as Function | object\n )\n }\n }\n\n if (resolvers.Mutation && Object.keys(resolvers.Mutation).length > 0) {\n if (!graphqlResolvers.Mutation) {\n graphqlResolvers.Mutation = {}\n }\n\n for (const [key, value] of Object.entries(resolvers.Mutation)) {\n graphqlResolvers.Mutation[key] = rootGraphqlResolver(\n value as Function | object\n )\n }\n }\n\n if (\n resolvers.Subscription &&\n Object.keys(resolvers.Subscription).length > 0\n ) {\n if (!graphqlResolvers.Subscription) {\n graphqlResolvers.Subscription = {}\n }\n\n for (const [key, value] of Object.entries(resolvers.Subscription)) {\n graphqlResolvers.Subscription[key] = {\n subscribe: rootGraphqlResolver(value as Function | object),\n resolve: (payload: any) => payload\n }\n }\n }\n\n // Query root type must be provided.\n if (!graphqlResolvers.Query) {\n // Custom Error for Query root type must be provided.\n\n throw new Error(`At least one 'Query' resolver must be provided.\n\nExample:\n\nexport const graphql = {\n Query: {\n // Define at least one query resolver here\n hello: () => 'world'\n }\n}\n`)\n }\n\n // Add extra resolvers (e.g. custom scalars) to the GraphQL resolvers.\n for (const key of Object.keys(resolvers)) {\n if (key !== 'Query' && key !== 'Mutation' && key !== 'Subscription') {\n graphqlResolvers[key] = resolvers[key]\n }\n }\n\n return graphqlResolvers\n}\n\nexport class ServiceError extends GraphQLError {\n extensions: GraphQLErrorExtensions\n\n constructor(\n message: string,\n extensions: {\n code: string\n statusCode: number\n details?: Record<string, any>\n },\n error?: Error\n ) {\n super(message, {\n originalError: error\n })\n this.extensions = extensions\n this.cause = error\n }\n}\n", "import {Context as HonoContext} from 'hono'\nimport type {Toucan} from 'toucan-js'\nimport type {AuthState} from './plugins/use-auth'\nimport {AsyncLocalStorage} from 'async_hooks'\nimport {sendFunctionEvent} from '@getcronit/pylon-telemetry'\nimport {env} from 'hono/adapter'\nimport type {GraphQLResolveInfo} from 'graphql'\n\nexport interface Bindings {\n NODE_ENV: string\n AUTH_PROJECT_ID?: string\n AUTH_KEY?: string\n AUTH_ISSUER?: string\n}\n\nexport interface Variables {\n auth: AuthState\n sentry: Toucan\n graphqlResolveInfo?: GraphQLResolveInfo\n}\n\nexport type Env = {\n Bindings: Bindings\n Variables: Variables\n}\n\nexport type Context = HonoContext<Env, string, {}>\n\nexport const asyncContext = new AsyncLocalStorage<Context>()\n\nexport const getContext = () => {\n const start = Date.now()\n const ctx = asyncContext.getStore()\n\n sendFunctionEvent({\n name: 'getContext',\n duration: Date.now() - start\n }).then(() => {})\n\n if (!ctx) {\n throw new Error('Context not defined')\n }\n\n ctx.env = env(ctx)\n\n return ctx\n}\n\nexport const setContext = (context: Context) => {\n return asyncContext.enterWith(context)\n}\n", "import {promises as fs} from 'fs'\nimport {deleteCookie, getCookie, setCookie} from 'hono/cookie'\nimport {HTTPException} from 'hono/http-exception'\nimport * as openid from 'openid-client'\nimport path from 'path'\nimport {getContext, type Plugin} from '../../index'\nimport {importPrivateKey} from './import-private-key'\n\ntype AuthKey = {\n type: 'application'\n keyId: string\n key: string\n appId: string\n clientId: string\n}\n\nconst loadAuthKey = async (keyPath: string): Promise<AuthKey> => {\n const authKeyFilePath = path.join(process.cwd(), keyPath)\n\n const env = getContext().env\n\n if (env.AUTH_KEY) {\n try {\n return JSON.parse(env.AUTH_KEY)\n } catch (error) {\n throw new Error(\n 'Error while reading AUTH_KEY. Make sure it is valid JSON'\n )\n }\n }\n\n try {\n const ketFileContent = await fs.readFile(authKeyFilePath, 'utf-8')\n\n try {\n return JSON.parse(ketFileContent)\n } catch (error) {\n throw new Error(\n 'Error while reading key file. Make sure it is valid JSON'\n )\n }\n } catch (error) {\n throw new Error('Error while reading key file. Make sure it exists')\n }\n}\n\nlet openidConfigCache: openid.Configuration | undefined\n\nconst bootstrapAuth = async (issuer: string, keyPath: string) => {\n if (!openidConfigCache) {\n const authKey = await loadAuthKey(keyPath)\n\n openidConfigCache = await openid.discovery(\n new URL(issuer),\n authKey.clientId,\n undefined,\n openid.PrivateKeyJwt({\n key: await importPrivateKey(authKey.key),\n kid: authKey.keyId\n })\n )\n }\n\n return openidConfigCache\n}\n\nclass PylonAuthException extends HTTPException {\n // Same constructor as HTTPException\n constructor(...args: ConstructorParameters<typeof HTTPException>) {\n // Prefix the message with \"PylonAuthException: \"\n args[1] = {\n ...args[1],\n message: `PylonAuthException: ${args[1]?.message}`\n }\n\n super(...args)\n }\n}\n\nexport function useAuth(args: {\n issuer: string\n endpoint?: string\n keyPath?: string\n}): Plugin {\n const {issuer, endpoint = '/auth', keyPath = 'key.json'} = args\n\n const loginPath = `${endpoint}/login`\n const logoutPath = `${endpoint}/logout`\n const callbackPath = `${endpoint}/callback`\n\n return {\n middleware: async (ctx, next) => {\n const openidConfig = await bootstrapAuth(issuer, keyPath)\n\n ctx.set('auth', {openidConfig})\n\n // Introspect token\n const authCookieToken = getCookie(ctx, 'pylon-auth')\n const authHeader = ctx.req.header('Authorization')\n const authQueryToken = ctx.req.query('token')\n\n if (authCookieToken || authHeader || authQueryToken) {\n let token: string | undefined\n\n if (authHeader) {\n const [type, value] = authHeader.split(' ')\n if (type === 'Bearer') {\n token = value\n }\n } else if (authQueryToken) {\n token = authQueryToken\n } else if (authCookieToken) {\n token = authCookieToken\n }\n\n if (!token) {\n throw new PylonAuthException(401, {\n message: 'Invalid token'\n })\n }\n\n const introspection = await openid.tokenIntrospection(\n openidConfig,\n token,\n {\n scope: 'openid email profile'\n }\n )\n\n if (!introspection.active) {\n throw new PylonAuthException(401, {\n message: 'Token is not active'\n })\n }\n\n if (!introspection.sub) {\n throw new PylonAuthException(401, {\n message: 'Token is missing subject'\n })\n }\n\n // Fetch user info\n const userInfo = await openid.fetchUserInfo(\n openidConfig,\n token,\n introspection.sub\n )\n\n const roles = Object.keys(\n introspection['urn:zitadel:iam:org:projects:roles']?.valueOf() || {}\n )\n\n ctx.set('auth', {\n user: {\n ...userInfo,\n roles\n },\n openidConfig\n })\n\n return next()\n }\n },\n setup(app) {\n app.get(loginPath, async ctx => {\n const openidConfig = ctx.get('auth').openidConfig\n\n const codeVerifier = openid.randomPKCECodeVerifier() // PKCE code verifier\n const codeChallenge = await openid.calculatePKCECodeChallenge(\n codeVerifier\n )\n\n // Store the code verifier in a secure cookie (not accessible to JavaScript)\n setCookie(ctx, 'pylon_code_verifier', codeVerifier, {\n httpOnly: true,\n maxAge: 300 // 5 minutes\n })\n\n let scope =\n 'openid profile email urn:zitadel:iam:user:resourceowner urn:zitadel:iam:org:projects:roles'\n\n const parameters: Record<string, string> = {\n scope,\n code_challenge: codeChallenge,\n code_challenge_method: 'S256',\n redirect_uri: new URL(ctx.req.url).origin + '/auth/callback',\n state: openid.randomState()\n }\n\n const authorizationUrl = openid.buildAuthorizationUrl(\n openidConfig,\n parameters\n )\n\n return ctx.redirect(authorizationUrl)\n })\n\n app.get(logoutPath, async ctx => {\n // Remove auth cookie\n deleteCookie(ctx, 'pylon-auth')\n\n return ctx.redirect('/')\n })\n\n app.get(callbackPath, async ctx => {\n const openidConfig = ctx.get('auth').openidConfig\n\n const params = ctx.req.query()\n const code = params.code\n const state = params.state\n\n if (!code || !state) {\n throw new PylonAuthException(400, {\n message: 'Missing authorization code or state'\n })\n }\n\n const codeVerifier = getCookie(ctx, 'pylon_code_verifier')\n if (!codeVerifier) {\n throw new PylonAuthException(400, {\n message: 'Missing code verifier'\n })\n }\n\n try {\n const cbUrl = new URL(ctx.req.url)\n // Exchange the authorization code for tokens\n let tokenSet = await openid.authorizationCodeGrant(\n openidConfig,\n cbUrl,\n {\n pkceCodeVerifier: codeVerifier,\n expectedState: state\n },\n cbUrl.searchParams\n )\n\n // Store tokens in secure cookies\n setCookie(ctx, `pylon-auth`, tokenSet.access_token, {\n httpOnly: true,\n maxAge: tokenSet.expires_in || 3600 // Default to 1 hour if not specified\n })\n\n return ctx.redirect('/')\n } catch (error) {\n console.error('Error during token exchange:', error)\n\n return ctx.text('Authentication failed!', 500)\n }\n })\n }\n }\n}\n", "import * as crypto from 'crypto'\n\n/*\nConvert a string into an ArrayBuffer\nfrom https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String\n*/\nfunction str2ab(str) {\n const buf = new ArrayBuffer(str.length)\n const bufView = new Uint8Array(buf)\n for (let i = 0, strLen = str.length; i < strLen; i++) {\n bufView[i] = str.charCodeAt(i)\n }\n return buf\n}\n\nconst convertPKCS1ToPKCS8 = (pkcs1: string) => {\n // with cryto module\n\n const key = crypto.createPrivateKey(pkcs1)\n\n return key.export({\n type: 'pkcs8',\n format: 'pem'\n })\n}\n\n/*\nImport a PEM encoded RSA private key, to use for RSA-PSS signing.\nTakes a string containing the PEM encoded key, and returns a Promise\nthat will resolve to a CryptoKey representing the private key.\n*/\nfunction importPKCS8PrivateKey(pem) {\n // fetch the part of the PEM string between header and footer\n const pemHeader = '-----BEGIN PRIVATE KEY-----'\n const pemFooter = '-----END PRIVATE KEY-----'\n const pemContents = pem.substring(\n pemHeader.length,\n pem.length - pemFooter.length - 1\n )\n // base64 decode the string to get the binary data\n const binaryDerString = atob(pemContents)\n // convert from a binary string to an ArrayBuffer\n const binaryDer = str2ab(binaryDerString)\n\n return crypto.subtle.importKey(\n 'pkcs8',\n binaryDer,\n {\n name: 'RSASSA-PKCS1-v1_5',\n hash: 'SHA-256'\n },\n true,\n ['sign']\n )\n}\n\nexport const importPrivateKey = async (pkcs1Pem: string) => {\n const pkcs8Pem = convertPKCS1ToPKCS8(pkcs1Pem)\n\n return await importPKCS8PrivateKey(pkcs8Pem)\n}\n", "import {MiddlewareHandler} from 'hono'\nimport {env} from 'hono/adapter'\nimport {HTTPException} from 'hono/http-exception'\nimport {ContentfulStatusCode} from 'hono/utils/http-status'\nimport {ServiceError} from '../../define-pylon'\nimport {Env, getContext} from '../../context'\nimport {createDecorator} from '../../create-decorator'\n\nexport type AuthRequireChecks = {\n roles?: string[]\n}\n\nexport const authMiddleware = (checks: AuthRequireChecks = {}) => {\n const middleware: MiddlewareHandler<Env> = async (ctx, next) => {\n const AUTH_PROJECT_ID = env(ctx).AUTH_PROJECT_ID\n\n // Check if user is authenticated\n const auth = ctx.get('auth')\n\n if (!auth) {\n throw new HTTPException(401, {\n message: 'Authentication required'\n })\n }\n\n if (checks.roles && auth.user) {\n const roles = auth.user.roles\n\n const hasRole = checks.roles.some(role => {\n return (\n roles.includes(role) || roles.includes(`${AUTH_PROJECT_ID}:${role}`)\n )\n })\n\n if (!hasRole) {\n const resError = new Response('Forbidden', {\n status: 403,\n statusText: 'Forbidden',\n headers: {\n 'Missing-Roles': checks.roles.join(','),\n 'Obtained-Roles': roles.join(',')\n }\n })\n\n throw new HTTPException(resError.status as ContentfulStatusCode, {\n res: resError\n })\n }\n }\n\n return next()\n }\n\n return middleware\n}\n\nexport function requireAuth(checks?: AuthRequireChecks) {\n const checkAuth = async (c: any) => {\n const ctx = await c\n\n try {\n await authMiddleware(checks)(ctx, async () => {})\n } catch (e) {\n if (e instanceof HTTPException) {\n if (e.status === 401) {\n throw new ServiceError(e.message, {\n statusCode: 401,\n code: 'AUTH_REQUIRED'\n })\n } else if (e.status === 403) {\n const res = e.getResponse()\n\n throw new ServiceError(res.statusText, {\n statusCode: res.status,\n code: 'AUTHORIZATION_REQUIRED',\n details: {\n missingRoles: res.headers.get('Missing-Roles')?.split(','),\n obtainedRoles: res.headers.get('Obtained-Roles')?.split(',')\n }\n })\n } else {\n throw e\n }\n }\n\n throw e\n }\n }\n\n return createDecorator(async () => {\n const ctx = getContext()\n\n await checkAuth(ctx)\n })\n}\n", "import {sendFunctionEvent} from '@getcronit/pylon-telemetry'\n\nexport function createDecorator(callback: (...args: any[]) => Promise<void>) {\n sendFunctionEvent({\n name: 'createDecorator',\n duration: 0\n }).then(() => {})\n\n function MyDecorator<T extends (...args: any[]) => any>(\n target: Object,\n propertyKey: string | symbol\n ): void\n\n function MyDecorator<T>(fn: T): T\n\n function MyDecorator<T>(\n arg1: Object | T,\n propertyKey?: string | symbol,\n descriptor?: PropertyDescriptor\n ): any {\n if (descriptor) {\n const originalMethod = descriptor.value as T\n\n descriptor.value = async function (...args: any[]) {\n await callback(...args)\n return (originalMethod as any).apply(this, args)\n }\n\n return descriptor\n } else {\n if (!descriptor) {\n if (propertyKey === undefined) {\n const originalFunction = arg1 as T\n\n return async function (\n ...args: Parameters<any>\n ): Promise<ReturnType<any>> {\n await callback(...args)\n return (originalFunction as any)(...args)\n } as T\n }\n\n let value: any = arg1[propertyKey]\n Object.defineProperty(arg1, propertyKey, {\n get: function () {\n return async function (...args: Parameters<any>) {\n await callback(...args)\n if (typeof value === 'function') {\n return value(...args)\n }\n\n return value\n }\n },\n set: function (newValue) {\n value = newValue\n },\n enumerable: true,\n configurable: true\n })\n\n return\n }\n }\n }\n\n return MyDecorator\n}\n", "import {Hono, MiddlewareHandler} from 'hono'\nimport {logger} from 'hono/logger'\nimport {sentry} from '@hono/sentry'\n\nimport {asyncContext, Env} from '../context'\n\nexport const app = new Hono<Env>()\n\napp.use('*', sentry())\n\napp.use('*', async (c, next) => {\n return new Promise((resolve, reject) => {\n asyncContext.run(c, async () => {\n try {\n resolve(await next()) // You can pass the value you want to return here\n } catch (error) {\n reject(error) // If an error occurs during the execution of `next()`, reject the Promise\n }\n })\n })\n})\n\napp.use('*', logger())\n\napp.use((c, next) => {\n // @ts-ignore\n c.req.id = crypto.randomUUID()\n return next()\n})\n\nexport const pluginsMiddleware: MiddlewareHandler[] = []\n\nconst pluginsMiddlewareLoader: MiddlewareHandler = async (c, next) => {\n for (const middleware of pluginsMiddleware) {\n const response = await middleware(c, async () => {})\n\n if (response) {\n return response\n }\n }\n\n return next()\n}\n\napp.use(pluginsMiddlewareLoader)\n", "import {createSchema, createYoga} from 'graphql-yoga'\nimport {GraphQLScalarType, Kind} from 'graphql'\nimport {\n DateTimeISOResolver,\n GraphQLVoid,\n JSONObjectResolver,\n JSONResolver\n} from 'graphql-scalars'\n\nimport {useSentry} from '../plugins/use-sentry'\nimport {Context} from '../context'\nimport {resolversToGraphQLResolvers} from '../define-pylon'\nimport {Plugin, PylonConfig} from '..'\nimport {readFileSync} from 'fs'\nimport path from 'path'\nimport {app, pluginsMiddleware} from '.'\nimport {useViewer} from '../plugins/use-viewer'\nimport {useUnhandledRoute} from '../plugins/use-unhandled-route'\n\ninterface PylonHandlerOptions {\n graphql: {\n Query: Record<string, any>\n Mutation?: Record<string, any>\n Subscription?: Record<string, any>\n }\n config?: PylonConfig\n}\n\ntype MaybeLazyObject<T> = T | (() => T)\n\nconst resolveLazyObject = <T>(obj: MaybeLazyObject<T>): T => {\n return typeof obj === 'function' ? (obj as () => T)() : obj\n}\n\nexport const handler = (options: PylonHandlerOptions) => {\n let {\n typeDefs,\n resolvers,\n graphql: graphql$,\n config: config$\n } = options as PylonHandlerOptions & {\n typeDefs?: string\n resolvers?: Record<string, any>\n }\n\n const loadPluginsMiddleware = (plugins: Plugin[]) => {\n for (const plugin of plugins) {\n plugin.setup?.(app)\n\n if (plugin.middleware) {\n pluginsMiddleware.push(plugin.middleware)\n }\n }\n }\n\n const graphql = resolveLazyObject(graphql$)\n\n const config = resolveLazyObject(config$)\n\n const plugins = [useSentry(), useViewer(), ...(config?.plugins || [])]\n\n if (config?.landingPage ?? true) {\n plugins.push(\n useUnhandledRoute({\n graphqlEndpoint: '/graphql'\n })\n )\n }\n\n loadPluginsMiddleware(plugins)\n\n if (!typeDefs) {\n // Try to read the schema from the default location\n const schemaPath = path.join(process.cwd(), '.pylon', 'schema.graphql')\n\n // If `schemaPath` is provided, read the schema from the file\n if (schemaPath) {\n typeDefs = readFileSync(schemaPath, 'utf-8')\n }\n }\n\n if (!typeDefs) {\n throw new Error('No schema provided.')\n }\n\n if (!resolvers) {\n // Try to read the resolvers from the default location\n const resolversPath = path.join(process.cwd(), '.pylon', 'resolvers.js')\n\n // If `resolversPath` is provided, read the resolvers from the file\n\n if (resolversPath) {\n resolvers = require(resolversPath).resolvers\n }\n }\n\n const graphqlResolvers = resolversToGraphQLResolvers(graphql)\n\n const schema = createSchema<Context>({\n typeDefs,\n resolvers: {\n ...graphqlResolvers,\n ...resolvers,\n // Transforms a date object to a timestamp\n Date: DateTimeISOResolver,\n JSON: JSONResolver,\n Object: JSONObjectResolver,\n Void: GraphQLVoid,\n Number: new GraphQLScalarType({\n name: 'Number',\n description: 'Custom scalar that handles both integers and floats',\n\n // Parsing input from query variables\n parseValue(value) {\n if (typeof value !== 'number') {\n throw new TypeError(`Value is not a number: ${value}`)\n }\n return value // Valid number\n },\n\n // Validation when sending from client (input literals)\n parseLiteral(ast) {\n if (ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {\n return parseFloat(ast.value) // Convert the value to a float\n }\n throw new TypeError(\n `Value is not a valid number or float: ${\n 'value' in ast ? ast.value : ast\n }`\n )\n },\n\n // Serialize output to be sent to the client\n serialize(value) {\n if (typeof value !== 'number') {\n throw new TypeError(`Value is not a number: ${value}`)\n }\n return value\n }\n })\n }\n })\n\n const yoga = createYoga({\n landingPage: false,\n graphiql: req => {\n return {\n shouldPersistHeaders: true,\n title: 'Pylon Playground',\n defaultQuery: `# Welcome to the Pylon Playground!`\n }\n },\n graphqlEndpoint: '/graphql',\n ...config,\n plugins,\n schema\n })\n\n const handler = async (c: Context): Promise<Response> => {\n let executionContext: Context['executionCtx'] | {} = {}\n\n try {\n executionContext = c.executionCtx\n } catch (e) {}\n\n const response = await yoga.fetch(c.req.raw, c.env, executionContext)\n\n return c.newResponse(response.body, response)\n }\n\n return handler\n}\n", "import {GraphQLError, Kind, OperationDefinitionNode, print} from 'graphql'\nimport {\n getDocumentString,\n handleStreamOrSingleExecutionResult,\n isOriginalGraphQLError,\n OnExecuteDoneHookResultOnNextHook,\n TypedExecutionArgs\n} from '@envelop/core'\nimport * as Sentry from '@sentry/node'\nimport type {Span, TraceparentData} from '@sentry/types'\nimport {Plugin} from '..'\n\nexport type SentryPluginOptions<PluginContext extends Record<string, any>> = {\n /**\n * Starts a new transaction for every GraphQL Operation.\n * When disabled, an already existing Transaction will be used.\n *\n * @default true\n */\n startTransaction?: boolean\n /**\n * Renames Transaction.\n * @default false\n */\n renameTransaction?: boolean\n /**\n * Adds result of each resolver and operation to Span's data (available under \"result\")\n * @default false\n */\n includeRawResult?: boolean\n /**\n * Adds operation's variables to a Scope (only in case of errors)\n * @default false\n */\n includeExecuteVariables?: boolean\n /**\n * The key of the event id in the error's extension. `null` to disable.\n * @default sentryEventId\n */\n eventIdKey?: string | null\n /**\n * Adds custom tags to every Transaction.\n */\n appendTags?: (\n args: TypedExecutionArgs<PluginContext>\n ) => Record<string, unknown>\n /**\n * Callback to set context information onto the scope.\n */\n configureScope?: (\n args: TypedExecutionArgs<PluginContext>,\n scope: Sentry.Scope\n ) => void\n /**\n * Produces a name of Transaction (only when \"renameTransaction\" or \"startTransaction\" are enabled) and description of created Span.\n *\n * @default operation's name or \"Anonymous Operation\" when missing)\n */\n transactionName?: (args: TypedExecutionArgs<PluginContext>) => string\n /**\n * Produces tracing data for Transaction\n *\n * @default is empty\n */\n traceparentData?: (\n args: TypedExecutionArgs<PluginContext>\n ) => TraceparentData | undefined\n /**\n * Produces a \"op\" (operation) of created Span.\n *\n * @default execute\n */\n operationName?: (args: TypedExecutionArgs<PluginContext>) => string\n /**\n * Indicates whether or not to skip the entire Sentry flow for given GraphQL operation.\n * By default, no operations are skipped.\n */\n skip?: (args: TypedExecutionArgs<PluginContext>) => boolean\n /**\n * Indicates whether or not to skip Sentry exception reporting for a given error.\n * By default, this plugin skips all `GraphQLError` errors and does not report it to Sentry.\n */\n skipError?: (args: Error) => boolean\n}\n\nexport const defaultSkipError = isOriginalGraphQLError\n\nexport const useSentry = <PluginContext extends Record<string, any> = {}>(\n options: SentryPluginOptions<PluginContext> = {}\n): Plugin<PluginContext> => {\n function pick<K extends keyof SentryPluginOptions<PluginContext>>(\n key: K,\n defaultValue: NonNullable<SentryPluginOptions<PluginContext>[K]>\n ) {\n return options[key] ?? defaultValue\n }\n\n const startTransaction = pick('startTransaction', true)\n const includeRawResult = pick('includeRawResult', false)\n const includeExecuteVariables = pick('includeExecuteVariables', false)\n const renameTransaction = pick('renameTransaction', false)\n const skipOperation = pick('skip', () => false)\n const skipError = pick('skipError', defaultSkipError)\n\n const eventIdKey = options.eventIdKey === null ? null : 'sentryEventId'\n\n function addEventId(err: GraphQLError, eventId: string | null): GraphQLError {\n if (eventIdKey !== null && eventId !== null) {\n err.extensions[eventIdKey] = eventId\n }\n\n return err\n }\n\n return {\n onExecute({args}) {\n if (skipOperation(args)) {\n return\n }\n\n const rootOperation = args.document.definitions.find(\n o => o.kind === Kind.OPERATION_DEFINITION\n ) as OperationDefinitionNode\n const operationType = rootOperation.operation\n\n const document = getDocumentString(args.document, print)\n\n const opName =\n args.operationName || rootOperation.name?.value || 'Anonymous Operation'\n const addedTags: Record<string, any> =\n (options.appendTags && options.appendTags(args)) || {}\n const traceparentData =\n (options.traceparentData && options.traceparentData(args)) || {}\n\n const transactionName = options.transactionName\n ? options.transactionName(args)\n : opName\n const op = options.operationName ? options.operationName(args) : 'execute'\n const tags = {\n operationName: opName,\n operation: operationType,\n ...addedTags\n }\n\n if (options.configureScope) {\n options.configureScope(args, Sentry.getCurrentScope())\n }\n\n return {\n onExecuteDone(payload) {\n const handleResult: OnExecuteDoneHookResultOnNextHook<{}> = ({\n result,\n setResult\n }) => {\n Sentry.startSpanManual(\n {\n op,\n name: opName,\n attributes: tags\n },\n span => {\n if (renameTransaction) {\n span.updateName(transactionName)\n }\n\n span.setAttribute('document', document)\n\n if (includeRawResult) {\n span.setAttribute('result', JSON.stringify(result))\n }\n\n if (result.errors && result.errors.length > 0) {\n Sentry.withScope(scope => {\n scope.setTransactionName(opName)\n scope.setTag('operation', operationType)\n scope.setTag('operationName', opName)\n scope.setExtra('document', document)\n\n scope.setTags(addedTags || {})\n\n if (includeRawResult) {\n scope.setExtra('result', result)\n }\n\n if (includeExecuteVariables) {\n scope.setExtra('variables', args.variableValues)\n }\n\n const errors = result.errors?.map(err => {\n if (skipError(err) === true) {\n return err\n }\n\n const errorPath = (err.path ?? [])\n .map((v: string | number) =>\n typeof v === 'number' ? '$index' : v\n )\n .join(' > ')\n\n if (errorPath) {\n scope.addBreadcrumb({\n category: 'execution-path',\n message: errorPath,\n level: 'debug'\n })\n }\n\n const eventId = Sentry.captureException(\n err.originalError,\n {\n fingerprint: [\n 'graphql',\n errorPath,\n opName,\n operationType\n ],\n contexts: {\n GraphQL: {\n operationName: opName,\n operationType,\n variables: args.variableValues\n }\n }\n }\n )\n\n return addEventId(err, eventId)\n })\n\n setResult({\n ...result,\n errors\n })\n })\n }\n\n span.end()\n }\n )\n }\n return handleStreamOrSingleExecutionResult(payload, handleResult)\n }\n }\n }\n }\n}\n", "import {html} from 'hono/html'\nimport {getContext, type Plugin} from '../index'\n\nexport function useViewer(): Plugin {\n return {\n onRequest: async ({request, fetchAPI, endResponse, url}) => {\n const c = getContext()\n\n if (request.method === 'GET' && url.pathname === '/viewer') {\n endResponse(\n c.html(\n await html`\n <!DOCTYPE html>\n <html>\n <head>\n <title>Pylon Viewer</title>\n <script src=\"https://cdn.jsdelivr.net/npm/react@16/umd/react.production.min.js\"></script>\n <script src=\"https://cdn.jsdelivr.net/npm/react-dom@16/umd/react-dom.production.min.js\"></script>\n\n <link\n rel=\"stylesheet\"\n href=\"https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.css\"\n />\n <style>\n body {\n padding: 0;\n margin: 0;\n width: 100%;\n height: 100vh;\n overflow: hidden;\n }\n\n #voyager {\n height: 100%;\n position: relative;\n }\n }\n </style>\n <script src=\"https://cdn.jsdelivr.net/npm/graphql-voyager/dist/voyager.min.js\"></script>\n </head>\n <body>\n <div id=\"voyager\">Loading...</div>\n <script>\n function introspectionProvider(introspectionQuery) {\n // ... do a call to server using introspectionQuery provided\n // or just return pre-fetched introspection\n\n // Endpoint is current path instead of root/graphql\n const endpoint = window.location.pathname.replace(\n '/viewer',\n '/graphql'\n )\n\n return fetch(endpoint, {\n method: 'post',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({query: introspectionQuery})\n }).then(response => response.json())\n }\n\n // Render <Voyager />\n GraphQLVoyager.init(document.getElementById('voyager'), {\n introspection: introspectionProvider\n })\n </script>\n </body>\n </html>\n `\n )\n )\n }\n }\n }\n}\n", "import {getVersions} from '@getcronit/pylon-telemetry'\nimport {html} from 'hono/html'\nimport {type Plugin} from '../index'\n\nexport function useUnhandledRoute(args: {graphqlEndpoint: string}): Plugin {\n const versions = getVersions()\n\n return {\n setup: app => {\n app.use(async (c, next) => {\n if (c.req.method === 'GET' && c.req.path !== args.graphqlEndpoint) {\n return c.html(\n await html`<!doctype html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>Welcome to Pylon</title>\n <link\n rel=\"icon\"\n href=\"https://pylon.cronit.io/favicon/favicon.ico\"\n />\n <style>\n body,\n html {\n padding: 0;\n margin: 0;\n height: 100%;\n font-family:\n 'Inter',\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n 'Roboto',\n 'Oxygen',\n 'Ubuntu',\n 'Cantarell',\n 'Fira Sans',\n 'Droid Sans',\n 'Helvetica Neue',\n sans-serif;\n color: white;\n background-color: black;\n }\n \n main > section.hero {\n display: flex;\n height: 90vh;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n }\n \n .logo {\n display: flex;\n align-items: center;\n }\n \n .logo-svg {\n width: 100%\n }\n \n .buttons {\n margin-top: 24px;\n }\n \n h1 {\n font-size: 80px;\n }\n \n h2 {\n color: #888;\n max-width: 50%;\n margin-top: 0;\n text-align: center;\n }\n \n a {\n color: #fff;\n text-decoration: none;\n margin-left: 10px;\n margin-right: 10px;\n font-weight: bold;\n transition: color 0.3s ease;\n padding: 4px;\n overflow: visible;\n }\n \n a.graphiql:hover {\n color: rgba(255, 0, 255, 0.7);\n }\n a.docs:hover {\n color: rgba(28, 200, 238, 0.7);\n }\n a.tutorial:hover {\n color: rgba(125, 85, 245, 0.7);\n }\n svg {\n margin-right: 24px;\n }\n \n .not-what-your-looking-for {\n margin-top: 5vh;\n }\n \n .not-what-your-looking-for > * {\n margin-left: auto;\n margin-right: auto;\n }\n \n .not-what-your-looking-for > p {\n text-align: center;\n }\n \n .not-what-your-looking-for > h2 {\n color: #464646;\n }\n \n .not-what-your-looking-for > p {\n max-width: 600px;\n line-height: 1.3em;\n }\n \n .not-what-your-looking-for > pre {\n max-width: 300px;\n }\n </style>\n </head>\n <body id=\"body\">\n <main>\n <section class=\"hero\">\n <div class=\"logo\">\n <div>\n <svg class=\"logo-svg\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" zoomAndPan=\"magnify\" viewBox=\"0 0 286.5 121.500001\" preserveAspectRatio=\"xMidYMid meet\" version=\"1.0\"><defs><g></g><clipPath id=\"38f6fcde47\"><path d=\"M 0.339844 42 L 10 42 L 10 79 L 0.339844 79 Z M 0.339844 42 \" clip-rule=\"nonzero\"></path></clipPath><clipPath id=\"af000f7256\"><path d=\"M 64 23.925781 L 72.789062 23.925781 L 72.789062 96.378906 L 64 96.378906 Z M 64 23.925781 \" clip-rule=\"nonzero\"></path></clipPath></defs><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(107.11969, 78.49768)\"><g><path d=\"M 10.078125 -25.046875 C 11.109375 -26.398438 12.507812 -27.535156 14.28125 -28.453125 C 16.0625 -29.378906 18.070312 -29.84375 20.3125 -29.84375 C 22.863281 -29.84375 25.195312 -29.210938 27.3125 -27.953125 C 29.425781 -26.691406 31.085938 -24.921875 32.296875 -22.640625 C 33.503906 -20.367188 34.109375 -17.757812 34.109375 -14.8125 C 34.109375 -11.863281 33.503906 -9.222656 32.296875 -6.890625 C 31.085938 -4.566406 29.425781 -2.753906 27.3125 -1.453125 C 25.195312 -0.160156 22.863281 0.484375 20.3125 0.484375 C 18.070312 0.484375 16.078125 0.03125 14.328125 -0.875 C 12.585938 -1.78125 11.171875 -2.910156 10.078125 -4.265625 L 10.078125 13.96875 L 4 13.96875 L 4 -29.359375 L 10.078125 -29.359375 Z M 27.921875 -14.8125 C 27.921875 -16.84375 27.503906 -18.59375 26.671875 -20.0625 C 25.835938 -21.539062 24.734375 -22.660156 23.359375 -23.421875 C 21.992188 -24.179688 20.53125 -24.5625 18.96875 -24.5625 C 17.445312 -24.5625 16 -24.171875 14.625 -23.390625 C 13.257812 -22.609375 12.160156 -21.472656 11.328125 -19.984375 C 10.492188 -18.492188 10.078125 -16.734375 10.078125 -14.703125 C 10.078125 -12.679688 10.492188 -10.914062 11.328125 -9.40625 C 12.160156 -7.894531 13.257812 -6.75 14.625 -5.96875 C 16 -5.1875 17.445312 -4.796875 18.96875 -4.796875 C 20.53125 -4.796875 21.992188 -5.191406 23.359375 -5.984375 C 24.734375 -6.785156 25.835938 -7.953125 26.671875 -9.484375 C 27.503906 -11.015625 27.921875 -12.789062 27.921875 -14.8125 Z M 27.921875 -14.8125 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(143.259256, 78.49768)\"><g><path d=\"M 30.4375 -29.359375 L 12.421875 13.796875 L 6.125 13.796875 L 12.09375 -0.484375 L 0.53125 -29.359375 L 7.296875 -29.359375 L 15.5625 -6.984375 L 24.140625 -29.359375 Z M 30.4375 -29.359375 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(174.281707, 78.49768)\"><g><path d=\"M 10.078125 -39.4375 L 10.078125 0 L 4 0 L 4 -39.4375 Z M 10.078125 -39.4375 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(188.353752, 78.49768)\"><g><path d=\"M 16.734375 0.484375 C 13.960938 0.484375 11.457031 -0.144531 9.21875 -1.40625 C 6.976562 -2.664062 5.21875 -4.441406 3.9375 -6.734375 C 2.664062 -9.035156 2.03125 -11.691406 2.03125 -14.703125 C 2.03125 -17.691406 2.6875 -20.335938 4 -22.640625 C 5.3125 -24.953125 7.101562 -26.726562 9.375 -27.96875 C 11.65625 -29.21875 14.195312 -29.84375 17 -29.84375 C 19.8125 -29.84375 22.351562 -29.21875 24.625 -27.96875 C 26.894531 -26.726562 28.6875 -24.953125 30 -22.640625 C 31.320312 -20.335938 31.984375 -17.691406 31.984375 -14.703125 C 31.984375 -11.722656 31.304688 -9.078125 29.953125 -6.765625 C 28.597656 -4.453125 26.757812 -2.664062 24.4375 -1.40625 C 22.113281 -0.144531 19.546875 0.484375 16.734375 0.484375 Z M 16.734375 -4.796875 C 18.296875 -4.796875 19.757812 -5.164062 21.125 -5.90625 C 22.5 -6.65625 23.613281 -7.773438 24.46875 -9.265625 C 25.320312 -10.765625 25.75 -12.578125 25.75 -14.703125 C 25.75 -16.835938 25.335938 -18.640625 24.515625 -20.109375 C 23.703125 -21.585938 22.617188 -22.695312 21.265625 -23.4375 C 19.910156 -24.1875 18.453125 -24.5625 16.890625 -24.5625 C 15.328125 -24.5625 13.878906 -24.1875 12.546875 -23.4375 C 11.210938 -22.695312 10.15625 -21.585938 9.375 -20.109375 C 8.59375 -18.640625 8.203125 -16.835938 8.203125 -14.703125 C 8.203125 -11.546875 9.007812 -9.101562 10.625 -7.375 C 12.25 -5.65625 14.285156 -4.796875 16.734375 -4.796875 Z M 16.734375 -4.796875 \"></path></g></g></g><g fill=\"currentColor\" fill-opacity=\"1\"><g transform=\"translate(222.361196, 78.49768)\"><g><path d=\"M 18.8125 -29.84375 C 21.125 -29.84375 23.191406 -29.363281 25.015625 -28.40625 C 26.847656 -27.445312 28.28125 -26.023438 29.3125 -24.140625 C 30.34375 -22.253906 30.859375 -19.984375 30.859375 -17.328125 L 30.859375 0 L 24.84375 0 L 24.84375 -16.421875 C 24.84375 -19.046875 24.179688 -21.054688 22.859375 -22.453125 C 21.546875 -23.859375 19.753906 -24.5625 17.484375 -24.5625 C 15.210938 -24.5625 13.410156 -23.859375 12.078125 -22.453125 C 10.742188 -21.054688 10.078125 -19.046875 10.078125 -16.421875 L 10.078125 0 L 4 0 L 4 -29.359375 L 10.078125 -29.359375 L 10.078125 -26.015625 C 11.066406 -27.222656 12.332031 -28.160156 13.875 -28.828125 C 15.425781 -29.503906 17.070312 -29.84375 18.8125 -29.84375 Z M 18.8125 -29.84375 \"></path></g></g></g><path fill=\"currentColor\" d=\"M 53.359375 31.652344 L 53.359375 88.6875 L 62.410156 90.859375 L 62.410156 29.484375 Z M 53.359375 31.652344 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path><g clip-path=\"url(#38f6fcde47)\"><path fill=\"currentColor\" d=\"M 0.339844 47.433594 L 0.339844 72.910156 C 0.339844 73.34375 0.410156 73.769531 0.554688 74.179688 C 0.699219 74.59375 0.90625 74.96875 1.175781 75.3125 C 1.445312 75.65625 1.765625 75.945312 2.132812 76.179688 C 2.503906 76.414062 2.898438 76.582031 3.324219 76.683594 L 9.390625 78.140625 L 9.390625 42.195312 L 3.3125 43.660156 C 2.890625 43.761719 2.492188 43.929688 2.125 44.164062 C 1.761719 44.402344 1.441406 44.6875 1.171875 45.03125 C 0.902344 45.375 0.695312 45.75 0.554688 46.164062 C 0.410156 46.574219 0.339844 46.996094 0.339844 47.433594 Z M 0.339844 47.433594 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path></g><g clip-path=\"url(#af000f7256)\"><path fill=\"currentColor\" d=\"M 64.996094 95.085938 L 64.996094 25.253906 C 64.996094 25.082031 65.027344 24.917969 65.09375 24.761719 C 65.160156 24.601562 65.253906 24.460938 65.375 24.339844 C 65.496094 24.21875 65.636719 24.125 65.792969 24.0625 C 65.953125 23.996094 66.117188 23.960938 66.289062 23.960938 L 71.460938 23.960938 C 71.632812 23.960938 71.796875 23.996094 71.957031 24.0625 C 72.113281 24.125 72.253906 24.21875 72.375 24.339844 C 72.496094 24.460938 72.589844 24.601562 72.65625 24.761719 C 72.722656 24.917969 72.753906 25.082031 72.753906 25.253906 L 72.753906 95.085938 C 72.753906 95.257812 72.722656 95.421875 72.65625 95.582031 C 72.589844 95.738281 72.496094 95.878906 72.375 96 C 72.253906 96.121094 72.113281 96.214844 71.957031 96.28125 C 71.796875 96.347656 71.632812 96.378906 71.460938 96.378906 L 66.289062 96.378906 C 66.117188 96.378906 65.953125 96.347656 65.792969 96.28125 C 65.636719 96.214844 65.496094 96.121094 65.375 96 C 65.253906 95.878906 65.160156 95.738281 65.09375 95.582031 C 65.027344 95.421875 64.996094 95.257812 64.996094 95.085938 Z M 64.996094 95.085938 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path></g><path fill=\"currentColor\" d=\"M 22.320312 81.238281 L 22.320312 39.101562 L 11.976562 41.585938 L 11.976562 78.757812 Z M 22.320312 81.238281 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path><path fill=\"currentColor\" d=\"M 50.769531 88.066406 L 50.769531 32.277344 L 37.839844 35.378906 L 37.839844 84.960938 Z M 50.769531 88.066406 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path><path fill=\"currentColor\" d=\"M 24.90625 81.863281 L 35.253906 84.34375 L 35.253906 35.996094 L 24.90625 38.480469 Z M 24.90625 81.863281 \" fill-opacity=\"1\" fill-rule=\"nonzero\"></path></svg>\n </div>\n <p>Version: ${versions.pylonVersion}</p>\n </div>\n <h2>Enables TypeScript developers to easily build GraphQL APIs</h2>\n <div class=\"buttons\">\n <a href=\"https://pylon.cronit.io/docs\" class=\"docs\"\n >Read the Docs</add\n >\n <a href=\"/graphql\" class=\"graphiql\">Visit GraphiQL</a>\n <a href=\"/viewer\" class=\"graphiql\">Visit Viewer</a>\n </div>\n </section>\n <section class=\"not-what-your-looking-for\">\n <h2>Not the page you are looking for? \uD83D\uDC40</h2>\n <p>\n This page is shown be default whenever a 404 is hit.<br />You can disable this by behavior\n via the <code>landingPage</code> option in the Pylon config. Edit the <code>src/index.ts</code> file\n and add the following code:\n </p>\n <pre>\n <code>\n export const config: PylonConfig = {\n landingPage: false\n }\n </code>\n </pre>\n \n <p>\n When you define a route, this page will no longer be shown. For example, the following code\n will show a \"Hello, world!\" message at the root of your app:\n </p>\n <pre>\n <code>\n import {app} from '@getcronit/pylon'\n \n app.get(\"/\", c => {\n return c.text(\"Hello, world!\")\n })\n </code>\n </pre>\n </section>\n </main>\n </body>\n </html>`,\n 404\n )\n }\n\n return next()\n })\n }\n }\n}\n", "import {sendFunctionEvent} from '@getcronit/pylon-telemetry'\nimport {asyncContext, Context} from './context'\n\nexport function getEnv() {\n const start = Date.now()\n const skipTracing = arguments[0] === true\n\n try {\n const context = asyncContext.getStore() as Context\n\n // Fall back to process.env or an empty object if no context is available\n // This is useful for testing\n // ref: https://hono.dev/docs/guides/testing#env\n return context.env || process.env || {}\n } catch {\n return process.env\n } finally {\n if (!skipTracing) {\n sendFunctionEvent({\n name: 'getEnv',\n duration: Date.now() - start\n }).then(() => {})\n }\n }\n}\n", "import {Env} from './context.js'\n\nexport {ServiceError} from './define-pylon.js'\nexport {useAuth, requireAuth, authMiddleware} from './plugins/use-auth/index.js'\nexport {\n Context,\n Env,\n Variables,\n Bindings,\n asyncContext,\n getContext,\n setContext\n} from './context.js'\nimport {app as pylonApp} from './app/index.js'\nexport {pylonApp as app}\nexport {handler} from './app/pylon-handler.js'\nexport {getEnv} from './get-env.js'\nexport {createDecorator} from './create-decorator.js'\nexport {createPubSub as experimentalCreatePubSub} from 'graphql-yoga'\n\nimport type {Plugin as YogaPlugin} from 'graphql-yoga'\nimport {MiddlewareHandler} from 'hono'\n\nexport type Plugin<\n PluginContext extends Record<string, any> = {},\n TServerContext extends Record<string, any> = {},\n TUserContext = {}\n> = YogaPlugin<PluginContext, TServerContext, TUserContext> & {\n middleware?: MiddlewareHandler<Env>\n setup?: (app: typeof pylonApp) => void\n build?: () => Promise<void>\n}\n\nexport type PylonConfig = {\n landingPage?: boolean\n plugins?: Plugin[]\n}\n\nexport type ID = string & {readonly brand?: unique symbol}\nexport type Int = number & {readonly brand?: unique symbol}\nexport type Float = number & {readonly brand?: unique symbol}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA,YAAY,YAAY;AACxB,OAAO,aAAa;AACpB;AAAA,EAEE;AAAA,OAKK;;;ACNP,SAAQ,yBAAwB;AAChC,SAAQ,yBAAwB;AAChC,SAAQ,WAAU;AAuBX,IAAM,eAAe,IAAI,kBAA2B;AAEpD,IAAM,aAAa,MAAM;AAC9B,QAAM,QAAQ,KAAK,IAAI;AACvB,QAAM,MAAM,aAAa,SAAS;AAElC,oBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,UAAU,KAAK,IAAI,IAAI;AAAA,EACzB,CAAC,EAAE,KAAK,MAAM;AAAA,EAAC,CAAC;AAEhB,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAEA,MAAI,MAAM,IAAI,GAAG;AAEjB,SAAO;AACT;AAEO,IAAM,aAA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,SAAwB,oBAA+B;",
|
|
6
|
+
"names": ["ctx", "crypto", "env", "app", "env", "HTTPException", "sendFunctionEvent", "env", "HTTPException", "Kind", "Sentry", "path", "html", "app", "plugins", "path", "Kind", "handler", "sendFunctionEvent", "sendFunctionEvent"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MiddlewareHandler } from 'hono';
|
|
2
|
+
import { Env } from '../../context';
|
|
3
|
+
export type AuthRequireChecks = {
|
|
4
|
+
roles?: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare const authMiddleware: (checks?: AuthRequireChecks) => MiddlewareHandler<Env>;
|
|
7
|
+
export declare function requireAuth(checks?: AuthRequireChecks): {
|
|
8
|
+
<T extends (...args: any[]) => any>(target: Object, propertyKey: string | symbol): void;
|
|
9
|
+
<T>(fn: T): T;
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getcronit/pylon",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-canary-20250206125311.f228add1e2e04c8af5d91db6063583bd317de463",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"graphql-yoga": "^5.6.2",
|
|
28
28
|
"hono": "^4.0.8",
|
|
29
29
|
"jsonwebtoken": "^9.0.2",
|
|
30
|
-
"openid-client": "^
|
|
30
|
+
"openid-client": "^6.1.7",
|
|
31
31
|
"toucan-js": "^4.1.0",
|
|
32
32
|
"winston": "^3.8.2",
|
|
33
33
|
"@getcronit/pylon-telemetry": "^1.0.2"
|
package/dist/auth/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { MiddlewareHandler } from 'hono';
|
|
2
|
-
import type { IdTokenClaims, IntrospectionResponse } from 'openid-client';
|
|
3
|
-
export type AuthState = IntrospectionResponse & IdTokenClaims & {
|
|
4
|
-
roles: string[];
|
|
5
|
-
};
|
|
6
|
-
export type AuthRequireChecks = {
|
|
7
|
-
roles?: string[];
|
|
8
|
-
};
|
|
9
|
-
export declare const auth: {
|
|
10
|
-
initialize: () => MiddlewareHandler<{
|
|
11
|
-
Variables: {
|
|
12
|
-
auth: AuthState;
|
|
13
|
-
};
|
|
14
|
-
}>;
|
|
15
|
-
require: (checks?: AuthRequireChecks) => MiddlewareHandler<{
|
|
16
|
-
Variables: {
|
|
17
|
-
auth?: AuthState;
|
|
18
|
-
};
|
|
19
|
-
}>;
|
|
20
|
-
};
|
|
21
|
-
export { requireAuth } from './decorators/requireAuth';
|