@nxgt/janus-graphql 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -12
- package/dist/context.d.ts +6 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/errors.d.ts +30 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +97 -15
- package/dist/index.js.map +8 -6
- package/dist/plugin.d.ts +13 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/renewal.d.ts +30 -0
- package/dist/renewal.d.ts.map +1 -0
- package/dist/report.d.ts +22 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +3 -3
- package/docs/guide/context.md +30 -2
- package/docs/guide/errors.md +85 -5
- package/docs/guide/subscriptions.md +5 -1
- package/docs/roadmap.md +16 -4
- package/docs/troubleshooting.md +55 -2
- package/package.json +3 -3
package/dist/index.js.map
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/context.ts", "../src/memo.ts", "../src/options.ts", "../src/connection/credential.ts", "../src/connection/connection.ts", "../src/directives/apply.ts", "../src/errors.ts", "../src/fresh.ts", "../src/directives/permission/path.ts", "../src/directives/permission/enforce.ts", "../src/directives/guard.ts", "../src/directives/read.ts", "../src/directives/words.ts", "../src/directives/permission/model.ts", "../src/directives/permission/validate.ts", "../src/directives/validate.ts", "../src/helpers.ts", "../src/plugin.ts", "../src/sdl.ts"],
|
|
3
|
+
"sources": ["../src/context.ts", "../src/memo.ts", "../src/options.ts", "../src/connection/credential.ts", "../src/connection/connection.ts", "../src/directives/apply.ts", "../src/errors.ts", "../src/report.ts", "../src/fresh.ts", "../src/directives/permission/path.ts", "../src/directives/permission/enforce.ts", "../src/directives/guard.ts", "../src/directives/read.ts", "../src/directives/words.ts", "../src/directives/permission/model.ts", "../src/directives/permission/validate.ts", "../src/directives/validate.ts", "../src/helpers.ts", "../src/renewal.ts", "../src/plugin.ts", "../src/sdl.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * `ctx.janus`, built once per request by `useJanus()`: a lazy\n * authentication, and the per-request check `can()` and the directives ask\n * through.\n */\n\nimport {\n\ttype Authenticated,\n\ttype Clock,\n\ttype RequestLike,\n\tsystemClock,\n} from '@nxgt/janus';\nimport { memoized } from './memo';\nimport type { JanusOnContext } from './types';\n\n/** One check, as `access.can` answers it — loose: the typing is the caller's. */\nexport type Check = (\n\tsubject: { readonly type: string; readonly id: string } | null,\n\tpermission: string,\n\tobject: { readonly type: string; readonly id: string },\n\toptions?: { readonly ctx?: unknown },\n) => Promise<boolean>;\n\n/** A user as this module reads one: the part every user type has. */\ntype AnyUser = { readonly type: string; readonly id: string };\n\ntype LooseAuth = {\n\tauthenticate(\n\t\trequest: RequestLike,\n\t\toptions?: { readonly type?: string },\n\t): Promise<Authenticated<AnyUser> | null>;\n};\n\ntype Built = JanusOnContext<AnyUser, unknown>;\n\n/**\n * The check of each context this module built. A `WeakMap` rather than a\n * property, so the context's own surface stays `user`, `session` and\n * `access`; it is the one place a request's checks pass through, and so the\n * one place a per-request memo of their answers goes.\n */\nconst checks = new WeakMap<object, { memo: Check; fresh: Check }>();\n\n/** The clock of each context this module built with one: what `@fresh` reads. */\nconst clocks = new WeakMap<object, Clock>();\n\n/** What `createJanusContext` reads from `useJanus()`'s options. */\nexport interface ContextOptions {\n\treadonly auth: LooseAuth;\n\treadonly access?: { readonly can: unknown } | undefined;\n\treadonly type?: string | undefined;\n\treadonly clock?: Clock | undefined;\n\t/** The call the consumer wrote, named by the no-request `TypeError`. */\n\treadonly caller?: string;\n}\n\n/**\n * `ctx.janus` for one request. `authenticate` runs the first time `user()`\n * or `session()` is asked, once, and its answer — or its failure — is the\n * answer of both from then on.\n *\n * A context with no request — a transport that is not HTTP, or a graphql-ws\n * connection no `janusConnection().onConnect` accepted — answers a\n * `TypeError` from `user()`, not `null`: anonymous is an answer, and nothing\n * here asked.\n */\nexport function createJanusContext(\n\trequest: RequestLike | undefined,\n\toptions: ContextOptions,\n): Built {\n\tconst { auth, access, type, clock, caller = 'useJanus()' } = options;\n\tlet answer: Promise<Authenticated<AnyUser> | null>;\n\tlet asked = false;\n\tconst authenticated = () => {\n\t\tif (!asked) {\n\t\t\tasked = true;\n\t\t\tanswer =\n\t\t\t\trequest === undefined\n\t\t\t\t\t? Promise.reject(\n\t\t\t\t\t\t\tnew TypeError(\n\t\t\t\t\t\t\t\t`${caller}: the GraphQL context has no request to authenticate — build the context from an HTTP request, or accept a graphql-ws connection with janusConnection().onConnect`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t: auth.authenticate(\n\t\t\t\t\t\t\trequest,\n\t\t\t\t\t\t\ttype === undefined ? undefined : { type },\n\t\t\t\t\t\t);\n\t\t}\n\t\treturn answer;\n\t};\n\n\tconst janus = Object.freeze({\n\t\tuser: () => authenticated().then((current) => current?.user ?? null),\n\t\tsession: () => authenticated().then((current) => current?.session ?? null),\n\t\t...(access === undefined ? {} : { access }),\n\t});\n\tif (access !== undefined) {\n\t\tconst can = access.can as Check;\n\t\tchecks.set(janus, {\n\t\t\tmemo: memoized(access),\n\t\t\tfresh: (...args) => can.apply(access, args),\n\t\t});\n\t}\n\tif (clock !== undefined) clocks.set(janus, clock);\n\treturn janus as Built;\n}\n\n/**\n * The clock `@fresh` and `requireFresh()` read the time from: the one given\n * to `useJanus({ clock })`, or the system's.\n */\nexport function clockOf(janus: object): Clock {\n\treturn clocks.get(janus) ?? systemClock;\n}\n\n/**\n * The check `ctx.janus` answers through: the one its context was built\n * with — `access.can`, memoized for the request (`memo.ts`) — or\n * `access.can` itself for a context built by hand. `null` when it has no\n * `access` at all.\n *\n * `fresh` skips the memo: a subscription is one request whose checks run\n * again on every event, and must see a `revoke()` made since it started.\n */\nexport function checkOf(janus: object, fresh = false): Check | null {\n\tconst built = checks.get(janus);\n\tif (built !== undefined) return fresh ? built.fresh : built.memo;\n\tconst access = (janus as { readonly access?: { readonly can?: unknown } })\n\t\t.access;\n\treturn typeof access?.can === 'function' ? (access.can as Check) : null;\n}\n\n/**\n * `ctx.janus`, or a wiring `TypeError` naming `caller` when nothing put it\n * there: `useJanus()` is missing from the plugins.\n */\nexport function janusOf(ctx: unknown, caller: string): Built {\n\tconst janus = (ctx as { readonly janus?: Built } | null)?.janus;\n\tif (janus === undefined || typeof janus.user !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`${caller}: ctx.janus is not set — add useJanus({ auth }) to the plugins`,\n\t\t);\n\t}\n\treturn janus;\n}\n",
|
|
5
|
+
"/**\n * `ctx.janus`, built once per request by `useJanus()`: a lazy\n * authentication, and the per-request check `can()` and the directives ask\n * through.\n */\n\nimport {\n\ttype Authenticated,\n\ttype Clock,\n\ttype RequestLike,\n\tsystemClock,\n} from '@nxgt/janus';\nimport { memoized } from './memo';\nimport type { JanusOnContext } from './types';\n\n/** One check, as `access.can` answers it — loose: the typing is the caller's. */\nexport type Check = (\n\tsubject: { readonly type: string; readonly id: string } | null,\n\tpermission: string,\n\tobject: { readonly type: string; readonly id: string },\n\toptions?: { readonly ctx?: unknown },\n) => Promise<boolean>;\n\n/** A user as this module reads one: the part every user type has. */\ntype AnyUser = { readonly type: string; readonly id: string };\n\ntype LooseAuth = {\n\tauthenticate(\n\t\trequest: RequestLike,\n\t\toptions?: { readonly type?: string },\n\t): Promise<Authenticated<AnyUser> | null>;\n};\n\ntype Built = JanusOnContext<AnyUser, unknown>;\n\n/**\n * The check of each context this module built. A `WeakMap` rather than a\n * property, so the context's own surface stays `user`, `session` and\n * `access`; it is the one place a request's checks pass through, and so the\n * one place a per-request memo of their answers goes.\n */\nconst checks = new WeakMap<object, { memo: Check; fresh: Check }>();\n\n/** The clock of each context this module built with one: what `@fresh` reads. */\nconst clocks = new WeakMap<object, Clock>();\n\n/**\n * The answer of `authenticate` for each context this module built — or\n * `undefined` while neither `user()` nor `session()` has been asked, so that\n * reading it never authenticates.\n */\nconst answers = new WeakMap<\n\tobject,\n\t() => Promise<Authenticated<AnyUser> | null> | undefined\n>();\n\n/** What `createJanusContext` reads from `useJanus()`'s options. */\nexport interface ContextOptions {\n\treadonly auth: LooseAuth;\n\treadonly access?: { readonly can: unknown } | undefined;\n\treadonly type?: string | undefined;\n\treadonly clock?: Clock | undefined;\n\t/** The call the consumer wrote, named by the no-request `TypeError`. */\n\treadonly caller?: string;\n}\n\n/**\n * `ctx.janus` for one request. `authenticate` runs the first time `user()`\n * or `session()` is asked, once, and its answer — or its failure — is the\n * answer of both from then on.\n *\n * A context with no request — a transport that is not HTTP, or a graphql-ws\n * connection no `janusConnection().onConnect` accepted — answers a\n * `TypeError` from `user()`, not `null`: anonymous is an answer, and nothing\n * here asked.\n */\nexport function createJanusContext(\n\trequest: RequestLike | undefined,\n\toptions: ContextOptions,\n): Built {\n\tconst { auth, access, type, clock, caller = 'useJanus()' } = options;\n\tlet answer: Promise<Authenticated<AnyUser> | null>;\n\tlet asked = false;\n\tconst authenticated = () => {\n\t\tif (!asked) {\n\t\t\tasked = true;\n\t\t\tanswer =\n\t\t\t\trequest === undefined\n\t\t\t\t\t? Promise.reject(\n\t\t\t\t\t\t\tnew TypeError(\n\t\t\t\t\t\t\t\t`${caller}: the GraphQL context has no request to authenticate — build the context from an HTTP request, or accept a graphql-ws connection with janusConnection().onConnect`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t: auth.authenticate(\n\t\t\t\t\t\t\trequest,\n\t\t\t\t\t\t\ttype === undefined ? undefined : { type },\n\t\t\t\t\t\t);\n\t\t}\n\t\treturn answer;\n\t};\n\n\tconst janus = Object.freeze({\n\t\tuser: () => authenticated().then((current) => current?.user ?? null),\n\t\tsession: () => authenticated().then((current) => current?.session ?? null),\n\t\t...(access === undefined ? {} : { access }),\n\t});\n\tif (access !== undefined) {\n\t\tconst can = access.can as Check;\n\t\tchecks.set(janus, {\n\t\t\tmemo: memoized(access),\n\t\t\tfresh: (...args) => can.apply(access, args),\n\t\t});\n\t}\n\tif (clock !== undefined) clocks.set(janus, clock);\n\tanswers.set(janus, () => (asked ? answer : undefined));\n\treturn janus as Built;\n}\n\n/**\n * What `authenticate` answered for `janus`'s request, or `undefined` when it\n * never ran — nothing asked `user()` or `session()`, or the context was not\n * built here. Never runs it.\n */\nexport function answerOf(\n\tjanus: object,\n): Promise<Authenticated<AnyUser> | null> | undefined {\n\treturn answers.get(janus)?.();\n}\n\n/**\n * The clock `@fresh` and `requireFresh()` read the time from: the one given\n * to `useJanus({ clock })`, or the system's.\n */\nexport function clockOf(janus: object): Clock {\n\treturn clocks.get(janus) ?? systemClock;\n}\n\n/**\n * The check `ctx.janus` answers through: the one its context was built\n * with — `access.can`, memoized for the request (`memo.ts`) — or\n * `access.can` itself for a context built by hand. `null` when it has no\n * `access` at all.\n *\n * `fresh` skips the memo: a subscription is one request whose checks run\n * again on every event, and must see a `revoke()` made since it started.\n */\nexport function checkOf(janus: object, fresh = false): Check | null {\n\tconst built = checks.get(janus);\n\tif (built !== undefined) return fresh ? built.fresh : built.memo;\n\tconst access = (janus as { readonly access?: { readonly can?: unknown } })\n\t\t.access;\n\treturn typeof access?.can === 'function' ? (access.can as Check) : null;\n}\n\n/**\n * `ctx.janus`, or a wiring `TypeError` naming `caller` when nothing put it\n * there: `useJanus()` is missing from the plugins.\n */\nexport function janusOf(ctx: unknown, caller: string): Built {\n\tconst janus = (ctx as { readonly janus?: Built } | null)?.janus;\n\tif (janus === undefined || typeof janus.user !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t`${caller}: ctx.janus is not set — add useJanus({ auth }) to the plugins`,\n\t\t);\n\t}\n\treturn janus;\n}\n",
|
|
6
6
|
"/**\n * The per-request memo of permission checks: the same question asked twice\n * in one request — by two fields, by a directive and a resolver's `can()`,\n * or by two fields at once — is one call to `access.can`.\n */\n\nimport type { Check } from './context';\n\ntype Ref = {\n\treadonly type: string;\n\treadonly id: string;\n\treadonly relation?: unknown;\n};\n\n/**\n * What no id in a key may hold: the notation reads `@` and `#` as its own,\n * so a key built from such an id could be another question's. `can()`\n * refuses or denies such an id anyway; it is asked, not remembered.\n */\nconst NOTATION = /[@#]/;\n\n/**\n * The key of one question, in the notation — `record:r1#view@staff:u1` —\n * or `null` when it is not remembered: an anonymous subject, which `can()`\n * answers `false` with no store call; a condition's `ctx`, which the key\n * does not hold; an id the notation could read two ways.\n */\nfunction keyOf(\n\tsubject: Ref | null,\n\tpermission: string,\n\tobject: Ref,\n\toptions: { readonly ctx?: unknown } | undefined,\n): string | null {\n\tif (subject === null || options?.ctx !== undefined) return null;\n\tif (NOTATION.test(object.id) || NOTATION.test(subject.id)) return null;\n\tconst set =\n\t\ttypeof subject.relation === 'string' ? `#${subject.relation}` : '';\n\treturn `${object.type}:${object.id}#${permission}@${subject.type}:${subject.id}${set}`;\n}\n\n/**\n * `access.can` for one request, remembered: a question asked again answers\n * the first answer's promise, so two asked at once share one call. A\n * failure is not remembered — an outage is no answer, and the next question\n * asks again.\n */\nexport function memoized(access: { readonly can: unknown }): Check {\n\tconst can = access.can as Check;\n\tconst answers = new Map<string, Promise<boolean>>();\n\tconst ask: Check = async (subject, permission, object, options) =>\n\t\tcan.call(access, subject, permission, object, options);\n\treturn (subject, permission, object, options) => {\n\t\tconst key = keyOf(subject, permission, object, options);\n\t\tif (key === null) return ask(subject, permission, object, options);\n\t\tconst known = answers.get(key);\n\t\tif (known !== undefined) return known;\n\t\tconst answer = ask(subject, permission, object, options);\n\t\tanswers.set(key, answer);\n\t\tanswer.then(undefined, () => answers.delete(key));\n\t\treturn answer;\n\t};\n}\n",
|
|
7
7
|
"/**\n * The wiring checks `useJanus()` and `janusConnection()` share: what each\n * refuses at start-up, with a `TypeError` naming the call that was written.\n */\n\n/** What both calls take and check before anything runs. */\nexport interface Wiring {\n\treadonly auth: unknown;\n\treadonly access?: unknown;\n\treadonly clock?: unknown;\n}\n\n/**\n * Refuses an `auth` that is not what `janus()` answered, an `access` that\n * is not what `permissions()` answered, and a `clock` that is not a\n * `Clock` — each a `TypeError` naming `caller`.\n */\nexport function checkWiring(caller: string, { auth, access, clock }: Wiring) {\n\tif (\n\t\ttypeof (auth as { readonly authenticate?: unknown } | null)\n\t\t\t?.authenticate !== 'function'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${caller}: auth is not what janus() answered — pass { auth }`,\n\t\t);\n\t}\n\tif (\n\t\taccess !== undefined &&\n\t\ttypeof (access as { readonly can?: unknown } | null)?.can !== 'function'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${caller}: access is not what permissions() answered — pass { auth, access }`,\n\t\t);\n\t}\n\tif (\n\t\tclock !== undefined &&\n\t\ttypeof (clock as { readonly now?: unknown } | null)?.now !== 'function'\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`${caller}: clock is not a Clock — pass the clock given to janus(), or leave it out for the system clock`,\n\t\t);\n\t}\n}\n",
|
|
8
8
|
"/**\n * The credential a graphql-ws connection presents, and the connections\n * `janusConnection().onConnect` accepted: what each operation on one is\n * authenticated from.\n */\n\nimport type { RequestLike } from '@nxgt/janus';\nimport type { ConnectionContext } from './types';\n\n/** Where the upgrade request is, when the transport does not say `extra.request`. */\nexport type Upgrade = (ctx: ConnectionContext) => RequestLike | undefined;\n\n/** The scheme `@nxgt/janus` reads a session token from — any case, as it does. */\nconst BEARER = /^\\s*bearer(?:\\s|$)/i;\n\n/**\n * The connection's credential, as `auth.authenticate` reads one:\n *\n * 1. `connectionParams.authorization`, when it is a `Bearer` token — a\n * non-browser client's `'Bearer <token>'`;\n * 2. otherwise the upgrade request itself, read as any request is —\n * `Authorization`, then `X-Session-Token`, then the session cookie a\n * browser sends with it.\n *\n * **The first present wins, not the first valid one**, as in `@nxgt/janus`:\n * a lapsed token in `connectionParams` beside a live cookie is refused. An\n * `authorization` of another scheme (`Basic`) is not a session credential,\n * as in `@nxgt/janus`, and does not count. `null` when there is nothing to\n * read, or an `authorization` that is not a string — refused, as a\n * client's mistake.\n */\nexport function credentialOf(\n\tctx: ConnectionContext,\n\tupgrade: Upgrade | undefined,\n): RequestLike | null {\n\tconst params = ctx.connectionParams;\n\tif (params !== undefined && Object.hasOwn(params, 'authorization')) {\n\t\tconst { authorization } = params;\n\t\tif (typeof authorization !== 'string') return null;\n\t\t// A record, not `Headers`, which would throw on a value no header may\n\t\t// hold: a client's mistake is a refusal, never a 4500.\n\t\tif (BEARER.test(authorization)) return { authorization };\n\t}\n\tconst request =\n\t\tupgrade === undefined\n\t\t\t? (ctx.extra as { readonly request?: RequestLike } | null)?.request\n\t\t\t: upgrade(ctx);\n\treturn request ?? null;\n}\n\n/**\n * The credential of each connection `onConnect` accepted, by its `extra`:\n * the one object graphql-ws hands every callback of a connection, and that\n * Yoga's recipe spreads into the context it builds. A `WeakMap`, so a\n * closed connection takes its entry with it, and nothing a request carries\n * can name one.\n */\nconst accepted = new WeakMap<object, RequestLike>();\n\n/** Remembers `credential` as the one `ctx`'s connection presented. */\nexport function accept(ctx: ConnectionContext, credential: RequestLike) {\n\tconst { extra } = ctx;\n\tif (typeof extra !== 'object' || extra === null) {\n\t\tthrow new TypeError(\n\t\t\t\"janusConnection(): the connection's extra is not an object — pass the context graphql-ws gave onConnect\",\n\t\t);\n\t}\n\taccepted.set(extra, credential);\n}\n\n/**\n * The credential of the connection a context was built for, or `undefined`\n * for one no `onConnect` accepted — and for every HTTP request.\n */\nexport function acceptedOf(context: unknown): RequestLike | undefined {\n\tconst extra = (context as { readonly extra?: unknown } | null)?.extra;\n\tif (typeof extra !== 'object' || extra === null) return undefined;\n\treturn accepted.get(extra);\n}\n",
|
|
9
9
|
"/**\n * `janusConnection()`: authenticated subscriptions over graphql-ws.\n */\n\nimport { createJanusContext } from '../context';\nimport { checkWiring } from '../options';\nimport type { Auth, JanusContext, UserOfAuth } from '../types';\nimport { accept, acceptedOf, credentialOf } from './credential';\nimport type { JanusConnection, JanusConnectionOptions } from './types';\n\n/**\n * The pieces of graphql-ws's `useServer()` that authenticate a WebSocket\n * connection, for Yoga's recommended setup:\n *\n * ```ts\n * const connection = janusConnection({ auth });\n * useServer({\n * onConnect: connection.onConnect,\n * execute: (args) => args.rootValue.execute(args),\n * subscribe: (args) => args.rootValue.subscribe(args),\n * onSubscribe: async (ctx, _id, params) => { … yoga.getEnveloped({ ...ctx, … }) … },\n * }, wsServer);\n * ```\n *\n * `onConnect` reads the connection's credential — `connectionParams`'\n * `authorization`, else the upgrade request's headers and cookie — and\n * refuses it unless it authenticates, as a user of `type` when it is given.\n * Each operation on the connection then gets a `ctx.janus` of its own from\n * `useJanus()`, authenticated again from that credential when a field asks:\n * `@authenticated`, `@fresh` and `@permission` hold as over HTTP, and a\n * session revoked since the connection opened is refused at the next\n * subscribe.\n *\n * A server without Yoga passes `context` too, and applies the directives\n * with `applyJanusDirectives()`.\n */\nexport function janusConnection<\n\tA extends Auth<{ readonly type: string; readonly id: string }>,\n\tP extends object | undefined = undefined,\n\tconst T extends UserOfAuth<A>['type'] = UserOfAuth<A>['type'],\n>(options: JanusConnectionOptions<A, P, T>): JanusConnection<A, P, T> {\n\tconst { auth, access, type, clock } = options;\n\tcheckWiring('janusConnection()', { auth, access, clock });\n\tif (options.upgrade !== undefined && typeof options.upgrade !== 'function') {\n\t\tthrow new TypeError(\n\t\t\t'janusConnection(): upgrade is not a function — pass (ctx) => the upgrade request, or leave it out to read ctx.extra.request',\n\t\t);\n\t}\n\tconst upgrade = options.upgrade?.bind(options);\n\tconst wiring = {\n\t\tauth,\n\t\taccess: access as { readonly can: unknown } | undefined,\n\t\ttype,\n\t\tclock,\n\t\tcaller: 'janusConnection().context',\n\t};\n\n\treturn {\n\t\tonConnect: async (ctx) => {\n\t\t\tconst credential = credentialOf(ctx, upgrade);\n\t\t\tif (credential === null) return false;\n\t\t\t// An outage rejects here, and graphql-ws closes the socket 4500:\n\t\t\t// never `false`, which a client reads as a refusal.\n\t\t\tconst current = await auth.authenticate(\n\t\t\t\tcredential,\n\t\t\t\ttype === undefined ? undefined : { type },\n\t\t\t);\n\t\t\tif (current === null) return false;\n\t\t\taccept(ctx, credential);\n\t\t\treturn true;\n\t\t},\n\t\t// The one cast at the boundary: the context is built loose, typed here.\n\t\tcontext: (ctx) =>\n\t\t\t({\n\t\t\t\tjanus: createJanusContext(acceptedOf(ctx), wiring),\n\t\t\t}) as unknown as JanusContext<A, P, T>,\n\t};\n}\n",
|
|
10
10
|
"/**\n * The schema transform: every object field a directive guards gets its\n * resolver wrapped, once, when the schema is built.\n */\n\nimport { MapperKind, mapSchema } from '@graphql-tools/utils';\nimport { defaultFieldResolver, type GraphQLSchema } from 'graphql';\nimport { guarded } from './guard';\nimport { readField } from './read';\nimport { type Known, requirementOf } from './validate';\nimport { list, PREFIX } from './words';\n\ntype Entries = {\n\treadonly [type: string]: ((...args: never[]) => unknown) | undefined;\n};\n\n/** What `applyJanusDirectives()` takes. */\nexport interface JanusDirectivesOptions<T extends string = string> {\n\t/** What `janus()` answered: its `types` are the names `type:` may take. */\n\treadonly auth: { readonly types: readonly T[] };\n\t/** `useJanus({ type })`'s: the one user type the schema's users can have. */\n\treadonly type?: NoInfer<T>;\n\t/** What `permissions()` answered: its model is what `@permission` may name. Required once a schema uses it. */\n\treadonly access?: { readonly model: unknown } | undefined;\n\t/** `useJanus({ loaders })`'s. */\n\treadonly loaders?: Entries | undefined;\n\t/** `useJanus({ conditions })`'s. */\n\treadonly conditions?: Entries | undefined;\n}\n\n/**\n * The schema with every field guarded by `@authenticated`, `@fresh` or\n * `@permission` — on the field, on its type, or on an interface the type\n * implements — wrapped so its resolver runs only for a signed-in user, of\n * one of the types `type:` names when it names some, on a session that\n * proved who it is less than `maxAge` seconds ago, holding every permission\n * asked. Every directive that applies must hold.\n *\n * `useJanus()` calls it on every schema it is given. Call it yourself to\n * check a schema without a server: the guards it installs read `ctx.janus`,\n * which only `useJanus()` builds.\n *\n * **Refuses when the schema is built**, with a `TypeError` naming the\n * field: a user type `auth` does not know, a `type: []`, restrictions no\n * user type meets together, a `@fresh` whose `maxAge` is not above zero;\n * for `@permission`, an object type or a permission the model does not\n * declare, a malformed `id:`, an argument the field does not take, and a\n * loader or a condition's `ctx` it needs and was not given.\n */\nexport function applyJanusDirectives<const T extends string>(\n\tschema: GraphQLSchema,\n\toptions: JanusDirectivesOptions<T>,\n): GraphQLSchema {\n\tconst known = knownOf(options);\n\treturn mapSchema(schema, {\n\t\t[MapperKind.OBJECT_FIELD]: (field, fieldName, typeName) => {\n\t\t\tconst requirement = requirementOf(\n\t\t\t\t{\n\t\t\t\t\tname: `${typeName}.${fieldName}`,\n\t\t\t\t\targs: Object.keys(field.args ?? {}),\n\t\t\t\t},\n\t\t\t\treadField(schema, field, fieldName, typeName),\n\t\t\t\tknown,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\tif (requirement === null) return field;\n\t\t\tconst resolve = field.resolve ?? defaultFieldResolver;\n\t\t\tif (field.subscribe === undefined) {\n\t\t\t\treturn { ...field, resolve: guarded(resolve, requirement) };\n\t\t\t}\n\t\t\t// A subscription's freshness is checked when it subscribes: its\n\t\t\t// events keep coming past maxAge, as its session keeps standing.\n\t\t\tconst onEvent = { ...requirement, maxAgeMs: null };\n\t\t\treturn {\n\t\t\t\t...field,\n\t\t\t\tsubscribe: guarded(field.subscribe, requirement),\n\t\t\t\tresolve: guarded(resolve, onEvent),\n\t\t\t};\n\t\t},\n\t});\n}\n\n/** The user types a directive may name — `type` alone when it is given, and one of `auth.types`. */\nfunction knownOf({ auth, type }: JanusDirectivesOptions): Known {\n\tif (type === undefined) return { types: auth.types };\n\tif (!auth.types.includes(type)) {\n\t\tthrow new TypeError(\n\t\t\t`${PREFIX}: type '${type}' is not a user type of auth — it knows ${list(auth.types)}`,\n\t\t);\n\t}\n\treturn { types: [type] };\n}\n",
|
|
11
|
-
"/**\n * Every refusal as a `GraphQLError` whose `extensions` carry a `code` and the\n * HTTP status Yoga answers with: `{ code, http: { status } }`. This package\n * defines no error class of its own — a denial is a `GraphQLError`, and what\n * `@nxgt/janus` throws stays its own until `janusMaskError()` reads it.\n */\n\nimport { JanusError, type JanusErrorStatus, statusOf } from '@nxgt/janus';\nimport { GraphQLError } from 'graphql';\n\n/** What a guard answers without asking `@nxgt/janus`: no user, or not this one. */\nexport type DenialCode = 'UNAUTHENTICATED' | 'FORBIDDEN' | 'NOT_FOUND';\n\n/** A denial: `UNAUTHENTICATED` 401, `FORBIDDEN` 403 or `NOT_FOUND` 404. */\nexport function denial(code: DenialCode, message?: string): GraphQLError {\n\tconst [status, fallback] = denialOf(code);\n\treturn new GraphQLError(message ?? fallback, {\n\t\textensions: { code, http: { status } },\n\t});\n}\n\nfunction denialOf(code: DenialCode): readonly [number, string] {\n\tswitch (code) {\n\t\tcase 'UNAUTHENTICATED':\n\t\t\treturn [401, 'Not signed in'];\n\t\tcase 'FORBIDDEN':\n\t\t\treturn [403, 'Forbidden'];\n\t\tcase 'NOT_FOUND':\n\t\t\treturn [404, 'Not found'];\n\t}\n}\n\n/**\n * A `JanusError` as the client may read it: its code and status, and only\n * what the client can act on — `issues`, `minLength`, `attemptsLeft
|
|
11
|
+
"/**\n * Every refusal as a `GraphQLError` whose `extensions` carry a `code` and the\n * HTTP status Yoga answers with: `{ code, http: { status } }`. This package\n * defines no error class of its own — a denial is a `GraphQLError`, and what\n * `@nxgt/janus` throws stays its own until `janusMaskError()` reads it.\n */\n\nimport { JanusError, type JanusErrorStatus, statusOf } from '@nxgt/janus';\nimport { GraphQLError } from 'graphql';\nimport { reporting } from './report';\n\n/** What a guard answers without asking `@nxgt/janus`: no user, or not this one. */\nexport type DenialCode = 'UNAUTHENTICATED' | 'FORBIDDEN' | 'NOT_FOUND';\n\n/** A denial: `UNAUTHENTICATED` 401, `FORBIDDEN` 403 or `NOT_FOUND` 404. */\nexport function denial(code: DenialCode, message?: string): GraphQLError {\n\tconst [status, fallback] = denialOf(code);\n\treturn new GraphQLError(message ?? fallback, {\n\t\textensions: { code, http: { status } },\n\t});\n}\n\nfunction denialOf(code: DenialCode): readonly [number, string] {\n\tswitch (code) {\n\t\tcase 'UNAUTHENTICATED':\n\t\t\treturn [401, 'Not signed in'];\n\t\tcase 'FORBIDDEN':\n\t\t\treturn [403, 'Forbidden'];\n\t\tcase 'NOT_FOUND':\n\t\t\treturn [404, 'Not found'];\n\t}\n}\n\n/**\n * A `JanusError` as the client may read it: its code and status, and only\n * what the client can act on — `issues`, `minLength`, `attemptsLeft`,\n * `retryAfter`. Never `reason`, `login`, `slot` or a cause: those are for\n * your logs. A throttled sign-in also carries its `Retry-After` header in\n * `http.headers`, which Yoga answers with.\n *\n * `STORE_FAILED` is `SERVICE_UNAVAILABLE` 503 — **an outage is never a\n * denial** — and no message of the core's reaches the client.\n */\nexport function janusGraphQLError(error: JanusError): GraphQLError {\n\tconst status = statusOf(error.code);\n\tconst code =\n\t\terror.code === 'STORE_FAILED' ? 'SERVICE_UNAVAILABLE' : error.code;\n\treturn new GraphQLError(messageOf(status), {\n\t\toriginalError: error,\n\t\textensions: { code, http: httpOf(error, status), ...actionable(error) },\n\t});\n}\n\n/**\n * A fixed message per status: the core's own message names a hash prefix or\n * a version, which are for your logs. The client reads `extensions.code`.\n */\nfunction messageOf(status: JanusErrorStatus): string {\n\tswitch (status) {\n\t\tcase 400:\n\t\t\treturn 'Invalid request';\n\t\tcase 401:\n\t\t\treturn 'Invalid credentials';\n\t\tcase 403:\n\t\t\treturn 'Forbidden';\n\t\tcase 404:\n\t\t\treturn 'Not found';\n\t\tcase 409:\n\t\t\treturn 'Conflict';\n\t\tcase 503:\n\t\t\treturn 'The service is unavailable, retry later';\n\t\tcase 500:\n\t\tcase 501:\n\t\t\treturn 'Internal server error';\n\t}\n}\n\n/** The status, and the `Retry-After` of a throttled sign-in. */\nfunction httpOf(\n\terror: JanusError,\n\tstatus: JanusErrorStatus,\n): Record<string, unknown> {\n\treturn error.retryAfter === undefined\n\t\t? { status }\n\t\t: { status, headers: { 'Retry-After': String(error.retryAfter) } };\n}\n\n/** The fields of a refusal a client can act on, as `@nxgt/janus-hono`'s `bodyOf`. */\nfunction actionable(error: JanusError): Record<string, unknown> {\n\tswitch (error.code) {\n\t\tcase 'USER_INVALID':\n\t\t\treturn { issues: error.issues ?? [] };\n\t\tcase 'PASSWORD_TOO_SHORT':\n\t\t\treturn error.minLength === undefined\n\t\t\t\t? {}\n\t\t\t\t: { minLength: error.minLength };\n\t\tcase 'CODE_INVALID':\n\t\t\treturn error.attemptsLeft === undefined\n\t\t\t\t? {}\n\t\t\t\t: { attemptsLeft: error.attemptsLeft };\n\t\tcase 'CREDENTIALS_INVALID':\n\t\t\treturn error.retryAfter === undefined\n\t\t\t\t? {}\n\t\t\t\t: { retryAfter: error.retryAfter };\n\t\tdefault:\n\t\t\treturn {};\n\t}\n}\n\n/**\n * A rejection handler: a `JanusError` becomes its `GraphQLError`, anything\n * else goes on as it is. `.then(undefined, rethrown)`.\n */\nexport function rethrown(error: unknown): never {\n\tthrow error instanceof JanusError ? janusGraphQLError(error) : error;\n}\n\n/** Yoga's and envelop's `maskError` signature. */\nexport type MaskError = (\n\terror: unknown,\n\tmessage: string,\n\tisDev?: boolean,\n) => Error;\n\n/** What `janusMaskError()` takes. */\nexport interface JanusMaskErrorOptions {\n\t/**\n\t * Called once with every `JanusError` answered 5xx — `STORE_FAILED`,\n\t * `UNSUPPORTED`, `PERMISSION_DEPTH` — whichever path it took: a\n\t * directive, `requireUser()`, `can()`, or a resolver that let it through.\n\t * Its `slot`, `operation`, `reason` and cause are for your logs; the\n\t * response never carries them.\n\t *\n\t * **It cannot change the answer**: one that throws, or rejects, is a\n\t * `process.emitWarning`, and the 503 is sent all the same.\n\t */\n\treadonly report?: (error: JanusError) => unknown;\n\t/** Every error that is not a `JanusError`; see `janusMaskError()`. */\n\treadonly fallback?: MaskError;\n}\n\n/**\n * Yoga's `maskedErrors.maskError`: a `JanusError` a resolver let through is\n * answered with its code and status — `STORE_FAILED` as 503, never masked\n * into a 500 and never a denial — and every other error goes to `fallback`.\n *\n * Without a `fallback`, a `GraphQLError` is kept and anything else becomes\n * `message`, with no detail. Pass Yoga's own `maskError` to keep its\n * development-mode details — as the options' `fallback`, or alone, as\n * before `report` existed:\n *\n * ```ts\n * import { createYoga, maskError } from 'graphql-yoga';\n * createYoga({\n * schema,\n * plugins,\n * maskedErrors: {\n * maskError: janusMaskError({ report: (error) => logger.error(error), fallback: maskError }),\n * },\n * });\n * ```\n */\nexport function janusMaskError(\n\toptions: JanusMaskErrorOptions | MaskError = {},\n): MaskError {\n\tconst { report, fallback = masked } =\n\t\ttypeof options === 'function' ? { fallback: options } : options;\n\tconst reported = report === undefined ? undefined : reporting(report);\n\treturn (error, message, isDev) => {\n\t\treported?.(error);\n\t\tconst original =\n\t\t\terror instanceof GraphQLError ? error.originalError : error;\n\t\tif (original instanceof JanusError) {\n\t\t\tconst answer = janusGraphQLError(original);\n\t\t\treturn error instanceof GraphQLError\n\t\t\t\t? new GraphQLError(answer.message, {\n\t\t\t\t\t\tnodes: error.nodes ?? null,\n\t\t\t\t\t\tpath: error.path ?? null,\n\t\t\t\t\t\toriginalError: original,\n\t\t\t\t\t\textensions: answer.extensions,\n\t\t\t\t\t})\n\t\t\t\t: answer;\n\t\t}\n\t\treturn fallback(error, message, isDev);\n\t};\n}\n\n/** The default `fallback`: a `GraphQLError` of our own kept, anything else `message`. */\nfunction masked(error: unknown, message: string): Error {\n\tif (error instanceof GraphQLError) {\n\t\tconst original = error.originalError;\n\t\tif (original === undefined || original instanceof GraphQLError) {\n\t\t\treturn error;\n\t\t}\n\t\treturn new GraphQLError(message, {\n\t\t\tnodes: error.nodes ?? null,\n\t\t\tpath: error.path ?? null,\n\t\t\textensions: { code: 'INTERNAL_SERVER_ERROR' },\n\t\t});\n\t}\n\treturn new GraphQLError(message, {\n\t\textensions: { code: 'INTERNAL_SERVER_ERROR' },\n\t});\n}\n",
|
|
12
|
+
"/**\n * `janusMaskError({ report })`: every `JanusError` answered 5xx, handed to\n * the application's logger before the response goes — the directives' and\n * the helpers' included, which reach the mask already a `GraphQLError`.\n */\n\nimport { JanusError, statusOf } from '@nxgt/janus';\nimport { GraphQLError } from 'graphql';\n\n/**\n * The `JanusError` behind `error`: itself, or the one a chain of\n * `GraphQLError`s carries as `originalError` — a directive's refusal,\n * located again by graphql-js. `null` when there is none.\n */\nexport function janusErrorIn(error: unknown): JanusError | null {\n\tlet current = error;\n\twhile (current instanceof GraphQLError) current = current.originalError;\n\treturn current instanceof JanusError ? current : null;\n}\n\n/**\n * A `report` that sees each failure once — a lazy `authenticate` shared by\n * two guarded fields fails both with one error — and only a 5xx: an outage,\n * `UNSUPPORTED`, `PERMISSION_DEPTH`, the ones the server must fix.\n *\n * **It cannot change the answer**: one that throws, or rejects, is a\n * `process.emitWarning`, and the response is sent all the same.\n */\nexport function reporting(\n\treport: (error: JanusError) => unknown,\n): (error: unknown) => void {\n\tconst seen = new WeakSet<JanusError>();\n\treturn (error) => {\n\t\tconst janusError = janusErrorIn(error);\n\t\tif (janusError === null || seen.has(janusError)) return;\n\t\tif (statusOf(janusError.code) < 500) return;\n\t\tseen.add(janusError);\n\t\tconst warn = (failure: unknown) =>\n\t\t\tprocess.emitWarning(\n\t\t\t\t`janusMaskError: report failed on ${janusError.code}: ${failure instanceof Error ? failure.name : typeof failure}`,\n\t\t\t);\n\t\ttry {\n\t\t\t// A thenable of any make, as a native promise: its rejection warns too.\n\t\t\tPromise.resolve(report(janusError)).then(undefined, warn);\n\t\t} catch (failure) {\n\t\t\twarn(failure);\n\t\t}\n\t};\n}\n",
|
|
12
13
|
"/**\n * Freshness: whether the request's session proved who it is recently enough\n * — the check `@fresh` runs before a field, and `requireFresh()` in a\n * resolver. Both are `@nxgt/janus`'s `assertFresh`, on the clock given to\n * `useJanus({ clock })`.\n */\n\nimport {\n\tassertFresh,\n\ttype Duration,\n\tparseDuration,\n\ttype Session,\n} from '@nxgt/janus';\nimport { clockOf, janusOf } from './context';\nimport { denial, rethrown } from './errors';\n\n/**\n * The request's session, once it proved who it is less than `maxAgeMs` ago\n * — or a denial: `UNAUTHENTICATED` 401 for an anonymous request,\n * `STEP_UP_REQUIRED` 403 for an older session. A store that cannot answer is\n * `SERVICE_UNAVAILABLE` 503, never either of them.\n */\nexport async function freshSession(\n\tjanus: { session(): Promise<Session | null> },\n\tmaxAgeMs: number,\n): Promise<Session> {\n\tconst session = await janus.session().then(undefined, rethrown);\n\tif (session === null) throw denial('UNAUTHENTICATED');\n\ttry {\n\t\tassertFresh(session, maxAgeMs, clockOf(janus));\n\t} catch (error) {\n\t\trethrown(error);\n\t}\n\treturn session;\n}\n\n/**\n * The request's session, once it proved who it is less than `maxAge` ago —\n * signed in, or confirmed since by `auth.stepUp.confirm` — or a denial:\n * `UNAUTHENTICATED` 401 for an anonymous request, `STEP_UP_REQUIRED` 403 for\n * an older session, which tells the client to ask for a step-up.\n *\n * ```ts\n * await requireFresh(ctx, '10m'); // before changing the e-mail\n * ```\n *\n * `maxAge` is a duration with its unit — `'10m'`, `'600s'` — never a bare\n * number, which `@nxgt/janus` reads as milliseconds where `@fresh` reads\n * seconds: a `TypeError`, as any other malformed duration.\n */\nexport async function requireFresh(\n\tctx: {\n\t\treadonly janus: {\n\t\t\tuser(): Promise<unknown>;\n\t\t\tsession(): Promise<Session | null>;\n\t\t};\n\t},\n\tmaxAge: Exclude<Duration, number>,\n): Promise<Session> {\n\tif (typeof maxAge !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t\"requireFresh(): maxAge is a duration with its unit, such as '10m' — a bare number would be milliseconds, where @fresh reads seconds\",\n\t\t);\n\t}\n\tconst maxAgeMs = parseDuration(maxAge, 'requireFresh(): maxAge');\n\treturn freshSession(janusOf(ctx, 'requireFresh()'), maxAgeMs);\n}\n",
|
|
13
14
|
"/**\n * `@permission`'s `id:` — `args.<path>` or `parent.<path>` — parsed when the\n * schema is built, and read from a request's arguments or parent value when a\n * field is resolved.\n */\n\n/** A parsed `id:`. */\nexport interface IdPath {\n\t/** As written: `args.id`, `parent.wardId`, `args.input.ids`. */\n\treadonly text: string;\n\treadonly root: 'args' | 'parent';\n\t/** The names after the root, at least one. */\n\treadonly segments: readonly string[];\n}\n\nconst NAME = /^[_A-Za-z][_0-9A-Za-z]*$/;\n\n/** `text` parsed, or `null` when it is not `args.<name>…` or `parent.<name>…`. */\nexport function parsePath(text: string): IdPath | null {\n\tconst [root, ...segments] = text.split('.');\n\tif (root !== 'args' && root !== 'parent') return null;\n\tif (segments.length === 0 || !segments.every((name) => NAME.test(name))) {\n\t\treturn null;\n\t}\n\treturn { text, root, segments };\n}\n\n/** One object a check is about: its id, and the value that holds it when that value is the object. */\nexport interface Target {\n\treadonly id: string;\n\t/** The value the id was read from, when `id` is its `id` field under `parent`. */\n\treadonly holder: object | null;\n}\n\n/**\n * The objects `path` names in this request: one, or one per element where a\n * step reads a list. `null` when a step reads nothing, or an id is not a\n * string or an integer: the request resolved no object id. An empty list\n * under `parent` is `null` too — the object's data names nothing to check,\n * and its fields are not open to everyone for it; under `args` it is the\n * client asking for nothing, and there is nothing to refuse.\n */\nexport function targetsOf(\n\tpath: IdPath,\n\tparent: unknown,\n\targs: unknown,\n): readonly Target[] | null {\n\tconst containers = walk(\n\t\t[path.root === 'args' ? args : parent],\n\t\tpath.segments.slice(0, -1),\n\t);\n\tif (containers === null) return null;\n\tconst last = path.segments[path.segments.length - 1] as string;\n\tconst held = path.root === 'parent' && last === 'id';\n\tconst targets: Target[] = [];\n\tfor (const container of containers) {\n\t\tfor (const value of spread((container as Record<string, unknown>)[last])) {\n\t\t\tconst id = idOf(value);\n\t\t\tif (id === null) return null;\n\t\t\ttargets.push({ id, holder: held ? (container as object) : null });\n\t\t}\n\t}\n\treturn path.root === 'parent' && targets.length === 0 ? null : targets;\n}\n\n/** The values `segments` reach from `values`, a list read as its elements. */\nfunction walk(\n\tvalues: readonly unknown[],\n\tsegments: readonly string[],\n): readonly unknown[] | null {\n\tlet current = values;\n\tfor (const segment of segments) {\n\t\tconst next: unknown[] = [];\n\t\tfor (const value of current) {\n\t\t\tif (typeof value !== 'object' || value === null) return null;\n\t\t\tnext.push(...spread((value as Record<string, unknown>)[segment]));\n\t\t}\n\t\tcurrent = next;\n\t}\n\treturn current.every((value) => typeof value === 'object' && value !== null)\n\t\t? current\n\t\t: null;\n}\n\nfunction spread(value: unknown): readonly unknown[] {\n\treturn Array.isArray(value) ? value.flat(Number.POSITIVE_INFINITY) : [value];\n}\n\n/** An `ID` as graphql-js coerces one: a string, or an integer serialised. */\nfunction idOf(value: unknown): string | null {\n\tif (typeof value === 'string') return value;\n\tif (typeof value === 'number' && Number.isSafeInteger(value)) {\n\t\treturn String(value);\n\t}\n\treturn null;\n}\n",
|
|
14
15
|
"/**\n * One `@permission`, asked at request time: the objects its `id:` names, each\n * checked with the request's check — memoized per request — and a denial\n * unless every one holds. A failure to answer is never a denial.\n */\n\nimport type { Check } from '../../context';\nimport { denial, rethrown } from '../../errors';\nimport { type Target, targetsOf } from './path';\nimport type { PermissionCheck } from './validate';\n\ntype ObjectLike = { readonly type: string; readonly id: string };\ntype Subject = { readonly type: string; readonly id: string };\n\n/** What the guard has in hand when it asks. */\nexport interface Asking {\n\treadonly check: Check;\n\treadonly user: Subject;\n\treadonly parent: unknown;\n\treadonly args: unknown;\n\t/** The GraphQL context, which `loaders` and `conditions` receive. */\n\treadonly ctx: unknown;\n}\n\n/** Refuses the request unless `user` holds `permission` on every object its `id:` names. */\nexport async function enforcePermission(\n\tpermission: PermissionCheck,\n\tasking: Asking,\n): Promise<void> {\n\tconst targets = targetsOf(permission.path, asking.parent, asking.args);\n\tif (targets === null) {\n\t\twarnNoId(permission);\n\t\tthrow denial('NOT_FOUND');\n\t}\n\tconst objects = await Promise.all(\n\t\ttargets.map((target) => objectOf(permission, target, asking.ctx)),\n\t).then(undefined, rethrown);\n\tconst found = objects.filter(\n\t\t(object): object is ObjectLike => object !== null,\n\t);\n\tif (found.length < objects.length) throw denial('NOT_FOUND');\n\tconst answers = await Promise.all(\n\t\tfound.map((object) => ask(permission, object, asking)),\n\t).then(undefined, rethrown);\n\tif (answers.includes(false)) throw denial(permission.onDeny);\n}\n\nasync function ask(\n\tpermission: PermissionCheck,\n\tobject: ObjectLike,\n\t{ check, user, ctx }: Asking,\n): Promise<boolean> {\n\tconst options =\n\t\tpermission.condition === null\n\t\t\t? undefined\n\t\t\t: { ctx: await permission.condition(object, ctx) };\n\treturn check(user, permission.name, object, options);\n}\n\n/**\n * What no object id can hold, as `@nxgt/janus` reads the notation: `can()`\n * refuses such an id with a `TypeError`, and one sent by a client is no\n * object's. A copy of the core's `RESERVED`, recorded in AGENTS.md's\n * *Deliberate duplications*.\n */\nconst UNNAMEABLE = /^$|[@#()]/;\n\n/**\n * Whether an id sent by a client can name an object: none of the characters\n * above, no NUL and no lone surrogate — which no store keeps, so `can()`\n * holds them for nobody, and the application's loader must never see them.\n * A copy of the core's `isStorable`, recorded beside `UNNAMEABLE`.\n */\nconst isNameable = (id: string): boolean =>\n\t!UNNAMEABLE.test(id) && !id.includes('\\u0000') && id.isWellFormed();\n\n/**\n * The object `can()` is given for one target: the value that holds the id,\n * the loader's answer, or `{ type, id }`. `null` when there is none: the\n * loader found none, or the id could name no object.\n */\nasync function objectOf(\n\tpermission: PermissionCheck,\n\t{ id, holder }: Target,\n\tctx: unknown,\n): Promise<ObjectLike | null> {\n\tconst { type, load } = permission;\n\tif (!isNameable(id)) return null;\n\tif (holder !== null) return view(holder, type, id);\n\tif (load === null) return { type, id };\n\tconst loaded = await load(id, ctx);\n\tif (loaded === null) return null;\n\tif (typeof loaded !== 'object') {\n\t\tthrow new TypeError(\n\t\t\t`${permission.label}: loaders.${type} answered ${typeof loaded} — answer the object, or null when there is none`,\n\t\t);\n\t}\n\treturn view(loaded, type, id);\n}\n\n/**\n * The object as `can()` reads it: `type` added — and `id`, the string read\n * from the path, so an integer id reads as graphql-js serialises it — every\n * other field read from the object itself, so a getter, a\n * class's `#private` state or an ORM document's accessors answer as they do\n * in the resolver. A spread would copy own enumerable fields only. The\n * proxy's target is an empty object rather than `object`, so a frozen\n * object whose own `type` means something else is read without breaking a\n * proxy invariant.\n */\nfunction view(object: object, type: string, id: string): ObjectLike {\n\treturn new Proxy(Object.create(null) as object, {\n\t\tget: (_, key) =>\n\t\t\tkey === 'type' ? type : key === 'id' ? id : Reflect.get(object, key),\n\t\thas: (_, key) => key === 'type' || Reflect.has(object, key),\n\t}) as ObjectLike;\n}\n\nconst warned = new WeakSet<PermissionCheck>();\n\n/** Says once per directive, on the only channel a library has, why a field answers `NOT_FOUND`. */\nfunction warnNoId(permission: PermissionCheck): void {\n\tif (warned.has(permission)) return;\n\twarned.add(permission);\n\tprocess.emitWarning(\n\t\t`${permission.label} resolved no object id from ${permission.path.text} — answered NOT_FOUND`,\n\t\t{ code: 'JANUS_GRAPHQL_NO_OBJECT_ID' },\n\t);\n}\n",
|
|
@@ -19,10 +20,11 @@
|
|
|
19
20
|
"/**\n * One `@permission`, checked against the model and the field when the schema\n * is built, and turned into what the guard asks at request time. Everything\n * no request could pass is a `TypeError` naming the field.\n */\n\nimport type { PermissionUse } from '../read';\nimport { list, on, PREFIX } from '../words';\nimport {\n\tfieldsOf,\n\ttype ModelLike,\n\tmodelOf,\n\tnamesOf,\n\treachesCondition,\n} from './model';\nimport { type IdPath, parsePath } from './path';\n\n/** `useJanus({ loaders })`'s entry: the object of a type, by id, or `null`. */\nexport type Loader = (id: string, ctx: unknown) => unknown;\n/** `useJanus({ conditions })`'s entry: the `ctx` a type's conditions test. */\nexport type Condition = (object: unknown, ctx: unknown) => unknown;\n\n/** What `@permission` reads from `useJanus()`'s options. */\nexport interface PermissionWiring {\n\treadonly access?: unknown;\n\treadonly loaders?: { readonly [type: string]: unknown } | undefined;\n\treadonly conditions?: { readonly [type: string]: unknown } | undefined;\n}\n\n/** One `@permission`, as the guard asks it. */\nexport interface PermissionCheck {\n\t/** `@permission on Record (read by Record.title)`, for the messages. */\n\treadonly label: string;\n\treadonly name: string;\n\treadonly type: string;\n\treadonly onDeny: 'NOT_FOUND' | 'FORBIDDEN';\n\treadonly path: IdPath;\n\t/** Loads an object named by id alone; `null` passes `{ type, id }`. */\n\treadonly load: Loader | null;\n\t/** Answers the check's `ctx`; `null` when no condition is reachable. */\n\treadonly condition: Condition | null;\n}\n\n/** The field a directive is read for: `Type.field`, and the arguments it takes. */\nexport interface FieldShape {\n\treadonly name: string;\n\treadonly args: readonly string[];\n}\n\n/** `use`, checked, or a `TypeError` naming the field. */\nexport function permissionCheckOf(\n\tuse: PermissionUse,\n\tfield: FieldShape,\n\twiring: PermissionWiring,\n): PermissionCheck {\n\tconst label = `@permission on ${on(use.where, field.name)}`;\n\tconst refuse = (why: string) => new TypeError(`${PREFIX}: ${label} ${why}`);\n\tconst model = modelOf(wiring.access);\n\tif (model === null) {\n\t\tthrow refuse(\n\t\t\t'needs the permissions() instance — pass useJanus({ auth, access }), with access what permissions() answered',\n\t\t);\n\t}\n\tcheckNames(model, use, refuse);\n\tconst text = use.id ?? (use.onType ? 'parent.id' : 'args.id');\n\tconst path = parsePath(text);\n\tif (path === null) {\n\t\tthrow refuse(\n\t\t\t`reads its id from '${text}', which is not args.<name> or parent.<name>`,\n\t\t);\n\t}\n\tconst [first] = path.segments;\n\tif (path.root === 'args' && !field.args.includes(first as string)) {\n\t\tthrow refuse(\n\t\t\t`reads ${path.root}.${first}, and ${field.name} takes no argument ${first}${\n\t\t\t\tuse.id === null && use.onType === false\n\t\t\t\t\t? ' — name the id with id: \"parent.<field>\" or id: \"args.<name>\"'\n\t\t\t\t\t: ''\n\t\t\t}`,\n\t\t);\n\t}\n\treturn {\n\t\tlabel,\n\t\tname: use.name,\n\t\ttype: use.type,\n\t\tonDeny: use.onDeny,\n\t\tpath,\n\t\tload: loaderOf(model, use.type, path, wiring, refuse),\n\t\tcondition: conditionOf(model, use, wiring, refuse),\n\t};\n}\n\ntype Refuse = (why: string) => TypeError;\n\nfunction checkNames(model: ModelLike, use: PermissionUse, refuse: Refuse) {\n\tif (!model.types.includes(use.type)) {\n\t\tthrow refuse(\n\t\t\t`names the object type '${use.type}', which is not one of ${list(model.types)}`,\n\t\t);\n\t}\n\tconst names = namesOf(model, use.type);\n\tif (!names.includes(use.name)) {\n\t\tthrow refuse(\n\t\t\t`asks '${use.name}', which ${use.type} does not declare — it declares ${list(names)}`,\n\t\t);\n\t}\n}\n\n/** The loader a check needs: its type's, required when the object is named by id alone and reads its own fields. */\nfunction loaderOf(\n\tmodel: ModelLike,\n\ttype: string,\n\tpath: IdPath,\n\twiring: PermissionWiring,\n\trefuse: Refuse,\n): Loader | null {\n\tconst load = wiring.loaders?.[type];\n\tif (load !== undefined && typeof load !== 'function') {\n\t\tthrow refuse(`finds loaders.${type}, which is not a function`);\n\t}\n\tconst held = path.root === 'parent' && path.segments.at(-1) === 'id';\n\tif (held) return null;\n\tif (load !== undefined) return load as Loader;\n\tconst fields = fieldsOf(model, type);\n\tif (fields.length > 0) {\n\t\tthrow refuse(\n\t\t\t`reads the ${type}'s id from ${path.text}, and ${type} reads ${list(fields)} of the object itself (fromField) — pass useJanus({ loaders: { ${type}: (id, ctx) => … } })`,\n\t\t);\n\t}\n\treturn null;\n}\n\n/** The type's `conditions` entry, required when the permission reaches a `when`. */\nfunction conditionOf(\n\tmodel: ModelLike,\n\tuse: PermissionUse,\n\twiring: PermissionWiring,\n\trefuse: Refuse,\n): Condition | null {\n\tif (!reachesCondition(model, use.type, use.name)) return null;\n\tconst condition = wiring.conditions?.[use.type];\n\tif (typeof condition !== 'function') {\n\t\tthrow refuse(\n\t\t\t`asks '${use.name}' of ${use.type}, which reaches a when() — pass useJanus({ conditions: { ${use.type}: (object, ctx) => … } })`,\n\t\t);\n\t}\n\treturn condition as Condition;\n}\n",
|
|
20
21
|
"/**\n * Decides, when the schema is built, what the directives on one field add up\n * to — and refuses with a `TypeError` what no request could ever pass: a user\n * type `auth` does not know, a `type: []`, restrictions that exclude each\n * other, a `@fresh` whose `maxAge` is not above zero, or a `@permission` the\n * model, the field or the wiring cannot answer (`permission/validate.ts`).\n */\n\nimport {\n\ttype FieldShape,\n\ttype PermissionCheck,\n\ttype PermissionWiring,\n\tpermissionCheckOf,\n} from './permission/validate';\nimport type { AuthenticatedUse, FieldDirectives, FreshUse } from './read';\nimport { list, on, PREFIX } from './words';\n\n/** What a field requires before its resolver runs. */\nexport interface Requirement {\n\t/** `Type.field`, for the messages. */\n\treadonly where: string;\n\t/** The directive a missing `ctx.janus` is reported against. */\n\treadonly label: string;\n\t/**\n\t * The user types allowed, every `type:` intersected; `null` when none\n\t * narrows it: any signed-in user.\n\t */\n\treadonly types: ReadonlySet<string> | null;\n\t/**\n\t * How long ago, in milliseconds, the session may have proved who it is at\n\t * most — the smallest `@fresh` that applies; `null` when none does.\n\t */\n\treadonly maxAgeMs: number | null;\n\t/** The permissions asked after that, in order: every one must hold. */\n\treadonly permissions: readonly PermissionCheck[];\n}\n\n/** The user types a schema may name: `auth.types`, or the one `useJanus({ type })` keeps. */\nexport interface Known {\n\treadonly types: readonly string[];\n}\n\n/**\n * The requirement of one field, or `null` when nothing guards it. Throws a\n * `TypeError` naming the field for a directive no request could pass.\n */\nexport function requirementOf(\n\tfield: FieldShape,\n\tdirectives: FieldDirectives,\n\tknown: Known,\n\twiring: PermissionWiring,\n): Requirement | null {\n\tconst { authenticated, fresh, permission } = directives;\n\tconst [name, first] = firstOf(directives);\n\tif (first === undefined) return null;\n\treturn {\n\t\twhere: field.name,\n\t\tlabel: `${name} on ${on(first.where, field.name)}`,\n\t\ttypes: typesOf(field.name, authenticated, known),\n\t\tmaxAgeMs: maxAgeOf(field.name, fresh),\n\t\tpermissions: permission.map((use) => permissionCheckOf(use, field, wiring)),\n\t};\n}\n\n/** Every `type:` intersected, or `null` when none names any. */\nfunction typesOf(\n\tfield: string,\n\tuses: readonly AuthenticatedUse[],\n\tknown: Known,\n): ReadonlySet<string> | null {\n\tlet types: Set<string> | null = null;\n\tfor (const { where, types: named } of uses) {\n\t\tif (named === null) continue;\n\t\tif (named.length === 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${PREFIX}: @authenticated on ${on(where, field)} names no user type — leave type: out to admit any signed-in user`,\n\t\t\t);\n\t\t}\n\t\tfor (const name of named) {\n\t\t\tif (!known.types.includes(name)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`${PREFIX}: @authenticated on ${on(where, field)} names the user type '${name}', which is not one of ${list(known.types)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\ttypes =\n\t\t\ttypes === null\n\t\t\t\t? new Set(named)\n\t\t\t\t: new Set(named.filter((name) => types?.has(name)));\n\t}\n\tif (types !== null && types.size === 0) {\n\t\tthrow new TypeError(\n\t\t\t`${PREFIX}: the @authenticated on ${field} and on its type or interfaces admit no user type in common`,\n\t\t);\n\t}\n\treturn types;\n}\n\n/** The directive a missing `ctx.janus` is reported against: the first checked. */\nfunction firstOf({\n\tauthenticated,\n\tfresh,\n\tpermission,\n}: FieldDirectives): readonly [string, { readonly where: string } | undefined] {\n\tif (authenticated.length > 0) return ['@authenticated', authenticated[0]];\n\tif (fresh.length > 0) return ['@fresh', fresh[0]];\n\treturn ['@permission', permission[0]];\n}\n\n/** The smallest `maxAge`, in milliseconds, or `null` when no `@fresh` applies. */\nfunction maxAgeOf(field: string, uses: readonly FreshUse[]): number | null {\n\tlet seconds: number | null = null;\n\tfor (const { where, maxAge } of uses) {\n\t\tif (!Number.isSafeInteger(maxAge) || maxAge <= 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`${PREFIX}: @fresh on ${on(where, field)} asks maxAge: ${maxAge} — write a number of seconds above zero, such as maxAge: 600 for ten minutes`,\n\t\t\t);\n\t\t}\n\t\tseconds = seconds === null ? maxAge : Math.min(seconds, maxAge);\n\t}\n\treturn seconds === null ? null : seconds * 1000;\n}\n",
|
|
21
22
|
"/**\n * The two calls a resolver makes itself: `requireUser` where a directive\n * would not do, and `can` for a check the schema cannot express.\n */\n\nimport type {\n\tCheckArgs,\n\tCheckableOf,\n\tModelConfig,\n\tObjectRef,\n\tObjectTypeOf,\n\tPermissions,\n} from '@nxgt/janus/permissions';\nimport { checkOf, janusOf } from './context';\nimport { denial, rethrown } from './errors';\n\n/** What `requireUser()` takes. */\nexport interface RequireUserOptions<T extends string> {\n\t/**\n\t * Only a user of this type, or of one of these — never an empty list,\n\t * which no user could pass: any other is `FORBIDDEN`.\n\t */\n\treadonly type?: T | readonly [T, ...T[]];\n}\n\n/**\n * The signed-in user, narrowed to `type` when it is given — or a denial:\n * `UNAUTHENTICATED` 401 for an anonymous request, `FORBIDDEN` 403 for a user\n * of another type. A store that cannot answer is `SERVICE_UNAVAILABLE` 503,\n * never either of them.\n *\n * ```ts\n * const staff = await requireUser(ctx, { type: 'staff' });\n * staff.username; // typed: a staff member\n * ```\n */\nexport async function requireUser<\n\tU extends { readonly type: string },\n\tconst T extends U['type'] = U['type'],\n>(\n\tctx: { readonly janus: { user(): Promise<U | null> } },\n\toptions: RequireUserOptions<T> = {},\n): Promise<Extract<U, { readonly type: T }>> {\n\tconst { type } = options;\n\tconst allowed: readonly string[] | undefined =\n\t\ttypeof type === 'string' ? [type] : type;\n\tif (allowed?.length === 0) {\n\t\tthrow new TypeError(\n\t\t\t'requireUser(): type is an empty list, which no user could pass — name at least one user type, or leave type out',\n\t\t);\n\t}\n\tconst user = await janusOf(ctx, 'requireUser()')\n\t\t.user()\n\t\t.then(undefined, rethrown);\n\tif (user === null) throw denial('UNAUTHENTICATED');\n\tif (allowed !== undefined && !allowed.includes(user.type)) {\n\t\tthrow denial('FORBIDDEN');\n\t}\n\treturn user as unknown as Extract<U, { readonly type: T }>;\n}\n\n/**\n * Whether the request's user holds `permission` on `object`, typed as\n * `access.can` is: the permission must be one the object's type declares,\n * the object must carry every field its `fromField`s read, and `{ ctx }` is\n * required exactly when a condition is reachable. Anonymous answers `false`.\n *\n * **A failure throws**: a store that cannot answer is `SERVICE_UNAVAILABLE`\n * 503, never `false`.\n *\n * ```ts\n * if (!(await can(ctx, 'edit', { type: 'record', ...record }))) return null;\n * ```\n */\nexport async function can<\n\tC extends ModelConfig,\n\tconst T extends ObjectTypeOf<C>,\n\tconst P extends CheckableOf<C, T>,\n>(\n\tctx: {\n\t\treadonly janus: {\n\t\t\tuser(): Promise<{ readonly type: string; readonly id: string } | null>;\n\t\t\treadonly access: Pick<Permissions<C>, 'can'>;\n\t\t};\n\t},\n\tpermission: P,\n\tobject: ObjectRef<C, T>,\n\t...options: CheckArgs<C, T, P>\n): Promise<boolean> {\n\tconst janus = janusOf(ctx, 'can()');\n\tconst check = checkOf(janus);\n\tif (check === null) {\n\t\tthrow new TypeError(\n\t\t\t'can(): ctx.janus.access is not set — pass { access } to useJanus()',\n\t\t);\n\t}\n\tconst subject = await janus.user().then(undefined, rethrown);\n\treturn check(subject, permission, object, options[0]).then(\n\t\tundefined,\n\t\trethrown,\n\t);\n}\n",
|
|
22
|
-
"/**\n *
|
|
23
|
+
"/**\n * The renewed session cookie: `authenticate` renews a sliding session in\n * passing, and `useJanus()` sends it again on the HTTP response — as\n * `@nxgt/janus-hono`'s `session()` does — through Yoga's `onResponse`.\n */\n\nimport type { Session } from '@nxgt/janus';\nimport { answerOf } from './context';\n\n/** The part of `auth.cookie` a renewal needs. */\nexport interface SessionCookie {\n\treadonly name: string;\n\tserialize(token: string, session: Session): string;\n}\n\n/** What Yoga hands `onResponse`: the part of it read here. */\nexport interface ResponsePayload {\n\treadonly request: Request;\n\treadonly response: Response;\n}\n\n/**\n * The contexts built for each HTTP request: one, or one per operation of a\n * batched request. A `WeakMap`, so an answered request takes its entry with\n * it.\n */\nconst contexts = new WeakMap<object, object[]>();\n\n/** Remembers `janus` as a context built for `request`. */\nexport function track(request: object, janus: object): void {\n\tconst known = contexts.get(request);\n\tif (known === undefined) contexts.set(request, [janus]);\n\telse known.push(janus);\n}\n\n/**\n * Sends the session cookie again when a context of `request` renewed it —\n * only when `authenticate` ran for it, so an operation that asked nothing\n * costs nothing here. As `session()` in `@nxgt/janus-hono`, only to a\n * request that presented the token as the session cookie — a client that sent\n * `Authorization: Bearer` or `X-Session-Token` is not handed a cookie it never\n * asked for — and never over a session cookie the response already sets.\n *\n * A failed `authenticate` sends nothing: its error is the response's.\n */\nexport async function resendRenewed(\n\t{ request, response }: ResponsePayload,\n\tcookie: SessionCookie | undefined,\n): Promise<void> {\n\tconst known = contexts.get(request);\n\tif (cookie === undefined || known === undefined) return;\n\tfor (const janus of known) {\n\t\tconst current = await answerOf(janus)?.then(\n\t\t\t(answer) => answer,\n\t\t\t() => null,\n\t\t);\n\t\tif (\n\t\t\tcurrent?.renewed === true &&\n\t\t\tcookieOf(request, cookie.name) === current.token &&\n\t\t\t!sets(response, cookie.name)\n\t\t) {\n\t\t\tresponse.headers.append(\n\t\t\t\t'Set-Cookie',\n\t\t\t\tcookie.serialize(current.token, current.session),\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** The value of the cookie `name` the request sent, or `null`. */\nfunction cookieOf(request: Request, name: string): string | null {\n\tconst header = request.headers.get('cookie');\n\tif (header === null) return null;\n\tfor (const pair of header.split(';')) {\n\t\tconst at = pair.indexOf('=');\n\t\tif (at !== -1 && pair.slice(0, at).trim() === name) {\n\t\t\treturn pair.slice(at + 1).trim();\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Whether the response already sets the cookie `name`. */\nfunction sets(response: Response, name: string): boolean {\n\treturn response.headers\n\t\t.getSetCookie()\n\t\t.some((value) => value.startsWith(`${name}=`));\n}\n",
|
|
24
|
+
"/**\n * `useJanus()`, the envelop plugin — for Yoga, or any server built on\n * envelop.\n */\n\nimport type { Plugin } from '@envelop/core';\nimport type { RequestLike } from '@nxgt/janus';\nimport type { GraphQLSchema } from 'graphql';\nimport { acceptedOf } from './connection/credential';\nimport { createJanusContext } from './context';\nimport { applyJanusDirectives } from './directives/apply';\nimport { checkWiring } from './options';\nimport { resendRenewed, track } from './renewal';\nimport type { Auth, JanusContext, JanusOptions, UserOfAuth } from './types';\n\n/**\n * The plugin that wires `@nxgt/janus` into a GraphQL server:\n *\n * - every request's context gets `ctx.janus` — `user()` and `session()`,\n * authenticated lazily and once, and `access` when it is given;\n * - every schema the server is given has its directives applied, once, by\n * `applyJanusDirectives()`.\n *\n * ```ts\n * createYoga({\n * schema: createSchema({ typeDefs: [janusTypeDefs, typeDefs], resolvers }),\n * plugins: [useJanus({ auth, access })],\n * maskedErrors: { maskError: janusMaskError() },\n * });\n * ```\n *\n * `type` treats a user of any other type as anonymous, as\n * `auth.authenticate(request, { type })` does. `clock` is what `@fresh` and\n * `requireFresh()` read the time from — the one given to `janus()`.\n * `loaders` and `conditions` are what `@permission` needs beside `access`:\n * the objects it checks by id, and the `ctx` of the conditions it reaches.\n *\n * A session `authenticate` renewed for a request that presented it as the\n * session cookie is sent again, `Set-Cookie` on Yoga's response\n * (`onResponse`), so a browser keeps the new expiry. Not to a bearer token or\n * `X-Session-Token`, and never when nothing authenticated.\n *\n * An operation over graphql-ws has no request: its `ctx.janus`\n * authenticates the credential its connection presented, once\n * `janusConnection().onConnect` accepted it — and has no response to carry a\n * renewed cookie.\n */\nexport function useJanus<\n\tA extends Auth<{ readonly type: string; readonly id: string }>,\n\tP extends object | undefined = undefined,\n\tconst T extends UserOfAuth<A>['type'] = UserOfAuth<A>['type'],\n>(\n\toptions: JanusOptions<A, P, T>,\n): Plugin<JanusContext<A, P, T>> & {\n\treadonly onResponse: (payload: {\n\t\treadonly request: Request;\n\t\treadonly response: Response;\n\t}) => Promise<void>;\n} {\n\tconst { auth, access, type, clock, loaders, conditions } = options;\n\tcheckWiring('useJanus()', { auth, access, clock });\n\tconst applied = new WeakSet<GraphQLSchema>();\n\n\treturn {\n\t\tonContextBuilding: ({ context, extendContext }) => {\n\t\t\tconst { request } = context as { readonly request?: RequestLike };\n\t\t\tconst janus = createJanusContext(request ?? acceptedOf(context), {\n\t\t\t\tauth,\n\t\t\t\taccess: access as { readonly can: unknown } | undefined,\n\t\t\t\ttype,\n\t\t\t\tclock,\n\t\t\t});\n\t\t\tif (typeof request === 'object' && request !== null) {\n\t\t\t\ttrack(request, janus);\n\t\t\t}\n\t\t\textendContext({ janus } as unknown as Partial<JanusContext<A, P, T>>);\n\t\t},\n\t\t// `replaceSchema` calls this hook again with the schema it was given:\n\t\t// the one it made is remembered, or it would transform it for ever.\n\t\tonSchemaChange: ({ schema, replaceSchema }) => {\n\t\t\tif (applied.has(schema)) return;\n\t\t\tconst next = applyJanusDirectives(schema, {\n\t\t\t\tauth,\n\t\t\t\t...(type === undefined ? {} : { type }),\n\t\t\t\taccess: access as { readonly model: unknown } | undefined,\n\t\t\t\tloaders,\n\t\t\t\tconditions,\n\t\t\t});\n\t\t\tapplied.add(next);\n\t\t\treplaceSchema(next);\n\t\t},\n\t\t// Yoga's own hook, which envelop ignores: the HTTP response, once made.\n\t\tonResponse: (payload) => resendRenewed(payload, auth.cookie),\n\t};\n}\n",
|
|
23
25
|
"/**\n * The directives and the enum this package reads, as SDL: put it beside your\n * own type definitions. The same text ships as `graphql/janus.graphqls`, for\n * a code generator or an editor that reads files — `sdl.spec.ts` holds that\n * the two are identical.\n *\n * ```ts\n * createSchema({ typeDefs: [janusTypeDefs, typeDefs], resolvers });\n * ```\n */\nexport const janusTypeDefs: string = `\"\"\"\nOnly a signed-in user reaches this field, or every field of this type or\ninterface. With \\`type\\`, only a user of one of these user types: any other is\nanswered FORBIDDEN.\n\"\"\"\ndirective @authenticated(\n\ttype: [String!]\n) on OBJECT | INTERFACE | FIELD_DEFINITION\n\n\"\"\"\nOnly a session that proved who it is less than \\`maxAge\\` seconds ago reaches\nthis field, or every field of this type or interface: signed in, or confirmed\nsince by a step-up. Anonymous is answered UNAUTHENTICATED, an older session\nSTEP_UP_REQUIRED. Where several apply, the smallest \\`maxAge\\` holds.\n\"\"\"\ndirective @fresh(maxAge: Int!) on OBJECT | INTERFACE | FIELD_DEFINITION\n\n\"\"\"\nWhat a denied \\`@permission\\` answers.\n\"\"\"\nenum JanusPermissionDenial {\n\t\"\"\"\n\t404: the object is not told to exist. The default.\n\t\"\"\"\n\tNOT_FOUND\n\t\"\"\"\n\t403: the object exists, and this user may not do this to it.\n\t\"\"\"\n\tFORBIDDEN\n}\n\n\"\"\"\nOnly a user holding permission \\`name\\` on the object of \\`type\\` whose id \\`id\\`\nreads reaches this field, or every field of this type or interface. \\`id\\` is\n\\`args.<path>\\` or \\`parent.<path>\\`: \\`args.id\\` on a field and \\`parent.id\\` on a\ntype or an interface when absent. A list of ids requires the permission on\nevery one. Repeated, every one must hold, in the order written.\n\"\"\"\ndirective @permission(\n\tname: String!\n\ttype: String!\n\tid: String\n\tonDeny: JanusPermissionDenial! = NOT_FOUND\n) repeatable on OBJECT | INTERFACE | FIELD_DEFINITION\n`;\n"
|
|
24
26
|
],
|
|
25
|
-
"mappings": ";AAMA;AAAA;AAAA;;;ACaA,IAAM,WAAW;AAQjB,SAAS,KAAK,CACb,SACA,YACA,QACA,SACgB;AAAA,EAChB,IAAI,YAAY,QAAQ,SAAS,QAAQ;AAAA,IAAW,OAAO;AAAA,EAC3D,IAAI,SAAS,KAAK,OAAO,EAAE,KAAK,SAAS,KAAK,QAAQ,EAAE;AAAA,IAAG,OAAO;AAAA,EAClE,MAAM,MACL,OAAO,QAAQ,aAAa,WAAW,IAAI,QAAQ,aAAa;AAAA,EACjE,OAAO,GAAG,OAAO,QAAQ,OAAO,MAAM,cAAc,QAAQ,QAAQ,QAAQ,KAAK;AAAA;AAS3E,SAAS,QAAQ,CAAC,QAA0C;AAAA,EAClE,MAAM,MAAM,OAAO;AAAA,EACnB,MAAM,UAAU,IAAI;AAAA,EACpB,MAAM,MAAa,OAAO,SAAS,YAAY,QAAQ,YACtD,IAAI,KAAK,QAAQ,SAAS,YAAY,QAAQ,OAAO;AAAA,EACtD,OAAO,CAAC,SAAS,YAAY,QAAQ,YAAY;AAAA,IAChD,MAAM,MAAM,MAAM,SAAS,YAAY,QAAQ,OAAO;AAAA,IACtD,IAAI,QAAQ;AAAA,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AAK;AAAA,QACrC;AAAA,QACA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,MACD,QAAQ,IAAI,IAAI;AAAA,MAChB,cAAc,IAAI;AAAA;AAAA,IAGnB,YAAY,CAAC,YAAY,cAAc,SAAS,KAAK,MAAM;AAAA,EAC5D;AAAA;;ACnFM,IAAM,gBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
28
|
+
"debugId": "7B97AB6C768D830E64756E2164756E21",
|
|
27
29
|
"names": []
|
|
28
30
|
}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -26,12 +26,23 @@ import type { Auth, JanusContext, JanusOptions, UserOfAuth } from './types';
|
|
|
26
26
|
* `loaders` and `conditions` are what `@permission` needs beside `access`:
|
|
27
27
|
* the objects it checks by id, and the `ctx` of the conditions it reaches.
|
|
28
28
|
*
|
|
29
|
+
* A session `authenticate` renewed for a request that presented it as the
|
|
30
|
+
* session cookie is sent again, `Set-Cookie` on Yoga's response
|
|
31
|
+
* (`onResponse`), so a browser keeps the new expiry. Not to a bearer token or
|
|
32
|
+
* `X-Session-Token`, and never when nothing authenticated.
|
|
33
|
+
*
|
|
29
34
|
* An operation over graphql-ws has no request: its `ctx.janus`
|
|
30
35
|
* authenticates the credential its connection presented, once
|
|
31
|
-
* `janusConnection().onConnect` accepted it
|
|
36
|
+
* `janusConnection().onConnect` accepted it — and has no response to carry a
|
|
37
|
+
* renewed cookie.
|
|
32
38
|
*/
|
|
33
39
|
export declare function useJanus<A extends Auth<{
|
|
34
40
|
readonly type: string;
|
|
35
41
|
readonly id: string;
|
|
36
|
-
}>, P extends object | undefined = undefined, const T extends UserOfAuth<A>['type'] = UserOfAuth<A>['type']>(options: JanusOptions<A, P, T>): Plugin<JanusContext<A, P, T
|
|
42
|
+
}>, P extends object | undefined = undefined, const T extends UserOfAuth<A>['type'] = UserOfAuth<A>['type']>(options: JanusOptions<A, P, T>): Plugin<JanusContext<A, P, T>> & {
|
|
43
|
+
readonly onResponse: (payload: {
|
|
44
|
+
readonly request: Request;
|
|
45
|
+
readonly response: Response;
|
|
46
|
+
}) => Promise<void>;
|
|
47
|
+
};
|
|
37
48
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAQ5C,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CACvB,CAAC,SAAS,IAAI,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAC9D,CAAC,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EACxC,KAAK,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAE7D,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC5B,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG;IAClC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE;QAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;KAC5B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,CAoCA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The renewed session cookie: `authenticate` renews a sliding session in
|
|
3
|
+
* passing, and `useJanus()` sends it again on the HTTP response — as
|
|
4
|
+
* `@nxgt/janus-hono`'s `session()` does — through Yoga's `onResponse`.
|
|
5
|
+
*/
|
|
6
|
+
import type { Session } from '@nxgt/janus';
|
|
7
|
+
/** The part of `auth.cookie` a renewal needs. */
|
|
8
|
+
export interface SessionCookie {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
serialize(token: string, session: Session): string;
|
|
11
|
+
}
|
|
12
|
+
/** What Yoga hands `onResponse`: the part of it read here. */
|
|
13
|
+
export interface ResponsePayload {
|
|
14
|
+
readonly request: Request;
|
|
15
|
+
readonly response: Response;
|
|
16
|
+
}
|
|
17
|
+
/** Remembers `janus` as a context built for `request`. */
|
|
18
|
+
export declare function track(request: object, janus: object): void;
|
|
19
|
+
/**
|
|
20
|
+
* Sends the session cookie again when a context of `request` renewed it —
|
|
21
|
+
* only when `authenticate` ran for it, so an operation that asked nothing
|
|
22
|
+
* costs nothing here. As `session()` in `@nxgt/janus-hono`, only to a
|
|
23
|
+
* request that presented the token as the session cookie — a client that sent
|
|
24
|
+
* `Authorization: Bearer` or `X-Session-Token` is not handed a cookie it never
|
|
25
|
+
* asked for — and never over a session cookie the response already sets.
|
|
26
|
+
*
|
|
27
|
+
* A failed `authenticate` sends nothing: its error is the response's.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resendRenewed({ request, response }: ResponsePayload, cookie: SessionCookie | undefined): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=renewal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renewal.d.ts","sourceRoot":"","sources":["../src/renewal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC;CACnD;AAED,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC5B;AASD,0DAA0D;AAC1D,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAI1D;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAClC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,eAAe,EACtC,MAAM,EAAE,aAAa,GAAG,SAAS,GAC/B,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `janusMaskError({ report })`: every `JanusError` answered 5xx, handed to
|
|
3
|
+
* the application's logger before the response goes — the directives' and
|
|
4
|
+
* the helpers' included, which reach the mask already a `GraphQLError`.
|
|
5
|
+
*/
|
|
6
|
+
import { JanusError } from '@nxgt/janus';
|
|
7
|
+
/**
|
|
8
|
+
* The `JanusError` behind `error`: itself, or the one a chain of
|
|
9
|
+
* `GraphQLError`s carries as `originalError` — a directive's refusal,
|
|
10
|
+
* located again by graphql-js. `null` when there is none.
|
|
11
|
+
*/
|
|
12
|
+
export declare function janusErrorIn(error: unknown): JanusError | null;
|
|
13
|
+
/**
|
|
14
|
+
* A `report` that sees each failure once — a lazy `authenticate` shared by
|
|
15
|
+
* two guarded fields fails both with one error — and only a 5xx: an outage,
|
|
16
|
+
* `UNSUPPORTED`, `PERMISSION_DEPTH`, the ones the server must fix.
|
|
17
|
+
*
|
|
18
|
+
* **It cannot change the answer**: one that throws, or rejects, is a
|
|
19
|
+
* `process.emitWarning`, and the response is sent all the same.
|
|
20
|
+
*/
|
|
21
|
+
export declare function reporting(report: (error: JanusError) => unknown): (error: unknown) => void;
|
|
22
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAY,MAAM,aAAa,CAAC;AAGnD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAI9D;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,GACpC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAkB1B"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Clock, Session, SharedApi } from '@nxgt/janus';
|
|
6
6
|
import type { PermissionWiringOf } from './wiring';
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Anything `janus()` answered: the part of it this package calls. `cookie`
|
|
9
|
+
* is what `useJanus()` sends a renewed session again with; an `auth` without
|
|
10
|
+
* one — a wrapper of your own — sends none.
|
|
11
|
+
*/
|
|
8
12
|
export type Auth<U extends {
|
|
9
13
|
readonly type: string;
|
|
10
|
-
}> = Pick<SharedApi<U>, 'authenticate' | 'types'
|
|
14
|
+
}> = Pick<SharedApi<U>, 'authenticate' | 'types'> & Partial<Pick<SharedApi<U>, 'cookie'>>;
|
|
11
15
|
/** The users an `auth` instance knows, as a union narrowed by `user.type`. */
|
|
12
16
|
export type UserOfAuth<A> = A extends Auth<infer U> ? U : never;
|
|
13
17
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,IAAI,IAAI,CAC3D,SAAS,CAAC,CAAC,CAAC,EACZ,cAAc,GAAG,OAAO,CACxB,GACA,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEvC,8EAA8E;AAC9E,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI;IAClD,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;CACvB,GAAG,kBAAkB,CACrB,CAAC,EACD;IACC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAC7B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,EAC5C,CAAC,CACD,CAAC;CACF,CACD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI;IAClC;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAC1B,yEAAyE;IACzE,OAAO,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CACnC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CACvB,CAAC,EACD,CAAC,GAAG,SAAS,EACb,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IACpD;IACH,QAAQ,CAAC,KAAK,EAAE,cAAc,CAC7B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,EAC5C,CAAC,CACD,CAAC;CACF,CAAC"}
|
package/docs/README.md
CHANGED
|
@@ -8,12 +8,12 @@ give the detail.
|
|
|
8
8
|
| [Directives](guide/directives.md) | You are guarding fields, types or interfaces with `@authenticated`, `@fresh` or `@permission`: where the id is read, loaders and conditions, lists, the order, the denials, one check per question, and what is refused at start-up |
|
|
9
9
|
| [The step-up over GraphQL](guide/step-up.md) | A mutation must run only on a session that proved who it is recently: `@fresh`, `STEP_UP_REQUIRED`, `stepUp.request` and `confirm` as mutations, `requireFresh()`, subscriptions, and testing with a clock |
|
|
10
10
|
| [Subscriptions over graphql-ws](guide/subscriptions.md) | You serve subscriptions over a WebSocket: `janusConnection()`, the cookie or `connectionParams`, the close codes, a session revoked mid-stream, Bun, and a server without Yoga |
|
|
11
|
-
| [The context](guide/context.md) | You are reading the user in a resolver, narrowing it to a user type,
|
|
12
|
-
| [Errors](guide/errors.md) | You want to know what a client receives for a denial or an outage, what the status of the response is,
|
|
11
|
+
| [The context](guide/context.md) | You are reading the user in a resolver, narrowing it to a user type, checking a permission or freshness yourself with `requireUser()`, `requireFresh()` and `can()`, or wondering when the renewed session cookie is sent |
|
|
12
|
+
| [Errors](guide/errors.md) | You want to know what a client receives for a denial or an outage, what the status of the response is, how `janusMaskError()` fits Yoga's masking, and how `report` logs every outage |
|
|
13
13
|
| [Telemetry](guide/telemetry.md) | You want a span per authentication and per permission check, with `@nxgt/janus-telemetry` |
|
|
14
14
|
| [Federation](guide/federation.md) | The server is a subgraph: where the directives are checked, what the router must forward, and `@composeDirective` |
|
|
15
15
|
| [Troubleshooting](troubleshooting.md) | A query answers something you did not expect, the server refuses to start, or the compiler refuses a resolver |
|
|
16
|
-
| [Roadmap](roadmap.md) | You want to know what is coming —
|
|
16
|
+
| [Roadmap](roadmap.md) | You want to know what is coming — anonymous graphql-ws connections — and what is deliberately not planned |
|
|
17
17
|
|
|
18
18
|
The words — user, user type, session, subject, permission, failure, denial —
|
|
19
19
|
are [`@nxgt/janus`'s vocabulary](https://github.com/softistx/nxgt-janus/blob/develop/packages/janus/docs/guide/vocabulary.md),
|
package/docs/guide/context.md
CHANGED
|
@@ -81,8 +81,36 @@ with `STORE_FAILED` rather than answering `null`, and the client receives
|
|
|
81
81
|
|
|
82
82
|
`authenticate` reads the request as it does anywhere: `Authorization:
|
|
83
83
|
Bearer`, then `X-Session-Token`, then the cookie. It renews a sliding session
|
|
84
|
-
in passing, and
|
|
85
|
-
|
|
84
|
+
in passing, and **`useJanus()` sends the renewed cookie back**, as
|
|
85
|
+
`@nxgt/janus-hono`'s `session()` does:
|
|
86
|
+
|
|
87
|
+
| The request | The response |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| Presented the session cookie, and `authenticate` renewed it | `Set-Cookie` with the session's new `Expires` — once, for a batch of operations too |
|
|
90
|
+
| Presented the cookie, not yet due for renewal | No `Set-Cookie` |
|
|
91
|
+
| `Authorization: Bearer` or `X-Session-Token` | No `Set-Cookie`, renewed or not: the client never asked for a cookie, and reads the new expiry from `session().expiresAt` |
|
|
92
|
+
| Anonymous, or no field asked `user()` or `session()` | No `Set-Cookie`, and no store call |
|
|
93
|
+
| The store failed | No `Set-Cookie`: the response is the 503 |
|
|
94
|
+
| A mutation of yours already set the session cookie — a sign-in, a sign-out | Yours: the renewal never overwrites it |
|
|
95
|
+
|
|
96
|
+
The cookie is `auth.cookie.serialize(token, session)`, under the attributes
|
|
97
|
+
`janus({ cookie })` resolved. It is set in Yoga's `onResponse` hook:
|
|
98
|
+
|
|
99
|
+
- **A server on envelop alone** never calls it, and sends no renewed cookie.
|
|
100
|
+
- **An operation over graphql-ws** has no response per operation, so none is
|
|
101
|
+
sent: the store holds the renewed session, but the browser keeps its
|
|
102
|
+
cookie's old expiry. That renewal is spent — an HTTP query right after
|
|
103
|
+
finds the session not yet due, and sends nothing — so the cookie is sent
|
|
104
|
+
again by the next renewal over HTTP, a `renewAfter` later. A client whose
|
|
105
|
+
only traffic is the WebSocket for longer than the lifespan minus
|
|
106
|
+
`renewAfter` should renew through an HTTP route of yours. See
|
|
107
|
+
[subscriptions](subscriptions.md).
|
|
108
|
+
- **A session first read after the response started** — by a field under
|
|
109
|
+
`@defer`, when no field of the initial payload read it — is not sent: the
|
|
110
|
+
headers had already gone.
|
|
111
|
+
- **An `auth` of your own** — a wrapper that counts or caches — must pass on
|
|
112
|
+
`cookie: auth.cookie` beside `authenticate` and `types`; without it, no
|
|
113
|
+
renewed cookie is sent.
|
|
86
114
|
|
|
87
115
|
`JanusContext<typeof auth, typeof access, Type>` takes the third argument
|
|
88
116
|
when `useJanus({ type })` narrows the server:
|