@softistx/janus-graphql 0.0.0-stage → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +716 -2
- package/dist/api-keys/index.d.ts +11 -0
- package/dist/api-keys/index.d.ts.map +1 -0
- package/dist/api-keys/resolvers/deps.d.ts +39 -0
- package/dist/api-keys/resolvers/deps.d.ts.map +1 -0
- package/dist/api-keys/resolvers/index.d.ts +39 -0
- package/dist/api-keys/resolvers/index.d.ts.map +1 -0
- package/dist/api-keys/resolvers/list.d.ts +16 -0
- package/dist/api-keys/resolvers/list.d.ts.map +1 -0
- package/dist/api-keys/resolvers/manage.d.ts +17 -0
- package/dist/api-keys/resolvers/manage.d.ts.map +1 -0
- package/dist/api-keys/sdl.d.ts +14 -0
- package/dist/api-keys/sdl.d.ts.map +1 -0
- package/dist/api-keys/shape.d.ts +38 -0
- package/dist/api-keys/shape.d.ts.map +1 -0
- package/dist/api-keys/types.d.ts +149 -0
- package/dist/api-keys/types.d.ts.map +1 -0
- package/dist/avatar/index.d.ts +32 -0
- package/dist/avatar/index.d.ts.map +1 -0
- package/dist/avatar/resolvers.d.ts +41 -0
- package/dist/avatar/resolvers.d.ts.map +1 -0
- package/dist/avatar/sdl.d.ts +16 -0
- package/dist/avatar/sdl.d.ts.map +1 -0
- package/dist/bad-input.d.ts +17 -0
- package/dist/bad-input.d.ts.map +1 -0
- package/dist/connection/connection.d.ts +36 -0
- package/dist/connection/connection.d.ts.map +1 -0
- package/dist/connection/credential.d.ts +34 -0
- package/dist/connection/credential.d.ts.map +1 -0
- package/dist/connection/types.d.ts +61 -0
- package/dist/connection/types.d.ts.map +1 -0
- package/dist/context/create.d.ts +32 -0
- package/dist/context/create.d.ts.map +1 -0
- package/dist/context/index.d.ts +9 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/registry.d.ts +72 -0
- package/dist/context/registry.d.ts.map +1 -0
- package/dist/context/resolve.d.ts +20 -0
- package/dist/context/resolve.d.ts.map +1 -0
- package/dist/device.d.ts +28 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/directives/apply.d.ts +51 -0
- package/dist/directives/apply.d.ts.map +1 -0
- package/dist/directives/guard.d.ts +22 -0
- package/dist/directives/guard.d.ts.map +1 -0
- package/dist/directives/permission/enforce.d.ts +24 -0
- package/dist/directives/permission/enforce.d.ts.map +1 -0
- package/dist/directives/permission/model.d.ts +35 -0
- package/dist/directives/permission/model.d.ts.map +1 -0
- package/dist/directives/permission/path.d.ts +31 -0
- package/dist/directives/permission/path.d.ts.map +1 -0
- package/dist/directives/permission/validate.d.ts +42 -0
- package/dist/directives/permission/validate.d.ts.map +1 -0
- package/dist/directives/read.d.ts +43 -0
- package/dist/directives/read.d.ts.map +1 -0
- package/dist/directives/validate.d.ts +39 -0
- package/dist/directives/validate.d.ts.map +1 -0
- package/dist/directives/words.d.ts +7 -0
- package/dist/directives/words.d.ts.map +1 -0
- package/dist/errors/denial.d.ts +6 -0
- package/dist/errors/denial.d.ts.map +1 -0
- package/dist/errors/index.d.ts +12 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/janus-error.d.ts +20 -0
- package/dist/errors/janus-error.d.ts.map +1 -0
- package/dist/errors/mask.d.ts +69 -0
- package/dist/errors/mask.d.ts.map +1 -0
- package/dist/fresh.d.ts +44 -0
- package/dist/fresh.d.ts.map +1 -0
- package/dist/helpers.d.ts +56 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3393 -0
- package/dist/index.js.map +75 -0
- package/dist/invitations/index.d.ts +12 -0
- package/dist/invitations/index.d.ts.map +1 -0
- package/dist/invitations/resolvers/anonymous.d.ts +11 -0
- package/dist/invitations/resolvers/anonymous.d.ts.map +1 -0
- package/dist/invitations/resolvers/deps.d.ts +38 -0
- package/dist/invitations/resolvers/deps.d.ts.map +1 -0
- package/dist/invitations/resolvers/index.d.ts +37 -0
- package/dist/invitations/resolvers/index.d.ts.map +1 -0
- package/dist/invitations/resolvers/owner.d.ts +17 -0
- package/dist/invitations/resolvers/owner.d.ts.map +1 -0
- package/dist/invitations/sdl/accept.d.ts +7 -0
- package/dist/invitations/sdl/accept.d.ts.map +1 -0
- package/dist/invitations/sdl/index.d.ts +14 -0
- package/dist/invitations/sdl/index.d.ts.map +1 -0
- package/dist/invitations/sdl/owner.d.ts +8 -0
- package/dist/invitations/sdl/owner.d.ts.map +1 -0
- package/dist/invitations/shape.d.ts +63 -0
- package/dist/invitations/shape.d.ts.map +1 -0
- package/dist/invitations/types/index.d.ts +5 -0
- package/dist/invitations/types/index.d.ts.map +1 -0
- package/dist/invitations/types/options.d.ts +104 -0
- package/dist/invitations/types/options.d.ts.map +1 -0
- package/dist/invitations/types/out.d.ts +136 -0
- package/dist/invitations/types/out.d.ts.map +1 -0
- package/dist/invitations/types/surface.d.ts +18 -0
- package/dist/invitations/types/surface.d.ts.map +1 -0
- package/dist/map-code.d.ts +10 -0
- package/dist/map-code.d.ts.map +1 -0
- package/dist/mask-error.d.ts +18 -0
- package/dist/mask-error.d.ts.map +1 -0
- package/dist/memo.d.ts +16 -0
- package/dist/memo.d.ts.map +1 -0
- package/dist/options.d.ts +17 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/passkeys/deps.d.ts +23 -0
- package/dist/passkeys/deps.d.ts.map +1 -0
- package/dist/passkeys/first-factor.types.d.ts +38 -0
- package/dist/passkeys/first-factor.types.d.ts.map +1 -0
- package/dist/passkeys/index.d.ts +14 -0
- package/dist/passkeys/index.d.ts.map +1 -0
- package/dist/passkeys/resolvers.d.ts +23 -0
- package/dist/passkeys/resolvers.d.ts.map +1 -0
- package/dist/passkeys/sdl.d.ts +14 -0
- package/dist/passkeys/sdl.d.ts.map +1 -0
- package/dist/passkeys/shape.d.ts +14 -0
- package/dist/passkeys/shape.d.ts.map +1 -0
- package/dist/passkeys/sign-in.resolvers.d.ts +19 -0
- package/dist/passkeys/sign-in.resolvers.d.ts.map +1 -0
- package/dist/passkeys/sign-in.sdl.d.ts +16 -0
- package/dist/passkeys/sign-in.sdl.d.ts.map +1 -0
- package/dist/passkeys/types.d.ts +193 -0
- package/dist/passkeys/types.d.ts.map +1 -0
- package/dist/plugin.d.ts +59 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/renewal.d.ts +51 -0
- package/dist/renewal.d.ts.map +1 -0
- package/dist/report.d.ts +29 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/sdl.d.ts +12 -0
- package/dist/sdl.d.ts.map +1 -0
- package/dist/second-factor/index.d.ts +12 -0
- package/dist/second-factor/index.d.ts.map +1 -0
- package/dist/second-factor/resolvers/deps.d.ts +39 -0
- package/dist/second-factor/resolvers/deps.d.ts.map +1 -0
- package/dist/second-factor/resolvers/index.d.ts +39 -0
- package/dist/second-factor/resolvers/index.d.ts.map +1 -0
- package/dist/second-factor/resolvers/sign-in.d.ts +10 -0
- package/dist/second-factor/resolvers/sign-in.d.ts.map +1 -0
- package/dist/second-factor/resolvers/status.d.ts +10 -0
- package/dist/second-factor/resolvers/status.d.ts.map +1 -0
- package/dist/second-factor/resolvers/step-up.d.ts +16 -0
- package/dist/second-factor/resolvers/step-up.d.ts.map +1 -0
- package/dist/second-factor/resolvers/writes.d.ts +19 -0
- package/dist/second-factor/resolvers/writes.d.ts.map +1 -0
- package/dist/second-factor/sdl.d.ts +14 -0
- package/dist/second-factor/sdl.d.ts.map +1 -0
- package/dist/second-factor/shape.d.ts +18 -0
- package/dist/second-factor/shape.d.ts.map +1 -0
- package/dist/second-factor/types/index.d.ts +5 -0
- package/dist/second-factor/types/index.d.ts.map +1 -0
- package/dist/second-factor/types/options.d.ts +61 -0
- package/dist/second-factor/types/options.d.ts.map +1 -0
- package/dist/second-factor/types/out.d.ts +84 -0
- package/dist/second-factor/types/out.d.ts.map +1 -0
- package/dist/second-factor/types/surface.d.ts +89 -0
- package/dist/second-factor/types/surface.d.ts.map +1 -0
- package/dist/social/index.d.ts +10 -0
- package/dist/social/index.d.ts.map +1 -0
- package/dist/social/resolvers.d.ts +25 -0
- package/dist/social/resolvers.d.ts.map +1 -0
- package/dist/social/sdl.d.ts +13 -0
- package/dist/social/sdl.d.ts.map +1 -0
- package/dist/social/shape.d.ts +11 -0
- package/dist/social/shape.d.ts.map +1 -0
- package/dist/social/types.d.ts +160 -0
- package/dist/social/types.d.ts.map +1 -0
- package/dist/surface/api.d.ts +16 -0
- package/dist/surface/api.d.ts.map +1 -0
- package/dist/surface/request.d.ts +10 -0
- package/dist/surface/request.d.ts.map +1 -0
- package/dist/surface/signed-in.d.ts +30 -0
- package/dist/surface/signed-in.d.ts.map +1 -0
- package/dist/types.d.ts +117 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/wiring.d.ts +56 -0
- package/dist/wiring.d.ts.map +1 -0
- package/docs/README.md +26 -0
- package/docs/guide/api-keys.md +365 -0
- package/docs/guide/avatars.md +129 -0
- package/docs/guide/context.md +371 -0
- package/docs/guide/directives.md +371 -0
- package/docs/guide/errors.md +318 -0
- package/docs/guide/federation.md +71 -0
- package/docs/guide/invitations.md +269 -0
- package/docs/guide/passkeys.md +207 -0
- package/docs/guide/second-factor.md +238 -0
- package/docs/guide/social.md +190 -0
- package/docs/guide/step-up.md +208 -0
- package/docs/guide/subscriptions.md +255 -0
- package/docs/guide/telemetry.md +45 -0
- package/docs/roadmap.md +124 -0
- package/docs/troubleshooting.md +1265 -0
- package/graphql/janus-api-keys.graphqls +237 -0
- package/graphql/janus-avatar.graphqls +19 -0
- package/graphql/janus-invitations.graphqls +280 -0
- package/graphql/janus-passkey-sign-in.graphqls +40 -0
- package/graphql/janus-passkeys.graphqls +134 -0
- package/graphql/janus-second-factor.graphqls +199 -0
- package/graphql/janus-social.graphqls +155 -0
- package/graphql/janus.graphqls +44 -0
- package/package.json +80 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/connection/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAC1E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB;AAED,sCAAsC;AACtC,MAAM,WAAW,sBAAsB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM;IAC7D;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,kEAAkE;IAClE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,iBAAiB,GAAG,WAAW,GAAG,SAAS,CAAC;CAC1D;AAED,kFAAkF;AAClF,MAAM,WAAW,eAAe,CAC/B,CAAC,EACD,CAAC,GAAG,SAAS,EACb,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAEvD;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CACpE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Clock, RequestLike } from '@softistx/janus';
|
|
2
|
+
import { type Built } from './registry';
|
|
3
|
+
import { type AuthOrResolver } from './resolve';
|
|
4
|
+
/** What `createJanusContext` reads from `useJanus()`'s options. */
|
|
5
|
+
export interface ContextOptions {
|
|
6
|
+
readonly auth: AuthOrResolver;
|
|
7
|
+
/** What an `auth` function is called with: the context the request's `ctx` is built from. */
|
|
8
|
+
readonly context?: unknown;
|
|
9
|
+
/** What the resolver's error names: a `request` (HTTP) or a `connection` (graphql-ws). */
|
|
10
|
+
readonly what?: 'request' | 'connection';
|
|
11
|
+
readonly access?: {
|
|
12
|
+
readonly can: unknown;
|
|
13
|
+
} | undefined;
|
|
14
|
+
readonly type?: string | undefined;
|
|
15
|
+
readonly clock?: Clock | undefined;
|
|
16
|
+
/** Accept an API key beside a session: `authenticate(request, { apiKey: true })`. */
|
|
17
|
+
readonly apiKey?: boolean | undefined;
|
|
18
|
+
/** The call the consumer wrote, named by the no-request `TypeError`. */
|
|
19
|
+
readonly caller?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `ctx.janus` for one request. `authenticate` runs the first time `user()`
|
|
23
|
+
* or `session()` is asked, once, and its answer — or its failure — is the
|
|
24
|
+
* answer of both from then on.
|
|
25
|
+
*
|
|
26
|
+
* A context with no request — a transport that is not HTTP, or a graphql-ws
|
|
27
|
+
* connection no `janusConnection().onConnect` accepted — answers a
|
|
28
|
+
* `TypeError` from `user()`, not `null`: anonymous is an answer, and nothing
|
|
29
|
+
* here asked.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createJanusContext(request: RequestLike | undefined, options: ContextOptions): Built;
|
|
32
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/context/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAa,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAGN,KAAK,KAAK,EAIV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,WAAW,CAAC;AAE5D,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;IACxD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IACnC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,OAAO,EAAE,cAAc,GACrB,KAAK,CA0DP"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ctx.janus`, built once per request by `useJanus()`: a lazy
|
|
3
|
+
* authentication, and the per-request check `can()` and the directives ask
|
|
4
|
+
* through.
|
|
5
|
+
*/
|
|
6
|
+
export { type ContextOptions, createJanusContext } from './create';
|
|
7
|
+
export { answerOf, type Check, checkOf, clockOf, cookieOfContext, janusOf, } from './registry';
|
|
8
|
+
export { resolveAuth } from './resolve';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EACN,QAAQ,EACR,KAAK,KAAK,EACV,OAAO,EACP,OAAO,EACP,eAAe,EACf,OAAO,GACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type Clock, type Principal } from '@softistx/janus';
|
|
2
|
+
import type { SessionCookie } from '../renewal';
|
|
3
|
+
import type { JanusOnContext } from '../types';
|
|
4
|
+
/** One check, as `access.can` answers it — loose: the typing is the caller's. */
|
|
5
|
+
export type Check = (subject: {
|
|
6
|
+
readonly type: string;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
} | null, permission: string, object: {
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
}, options?: {
|
|
12
|
+
readonly ctx?: unknown;
|
|
13
|
+
}) => Promise<boolean>;
|
|
14
|
+
/** A user as this module reads one: the part every user type has. */
|
|
15
|
+
export type AnyUser = {
|
|
16
|
+
readonly type: string;
|
|
17
|
+
readonly id: string;
|
|
18
|
+
};
|
|
19
|
+
export type Built = JanusOnContext<AnyUser, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* The check of each context this module built. A `WeakMap` rather than a
|
|
22
|
+
* property, so the context's own surface stays `user`, `session` and
|
|
23
|
+
* `access`; it is the one place a request's checks pass through, and so the
|
|
24
|
+
* one place a per-request memo of their answers goes.
|
|
25
|
+
*/
|
|
26
|
+
export declare const checks: WeakMap<object, {
|
|
27
|
+
memo: Check;
|
|
28
|
+
fresh: Check;
|
|
29
|
+
}>;
|
|
30
|
+
/** The clock of each context this module built with one: what `@fresh` reads. */
|
|
31
|
+
export declare const clocks: WeakMap<object, Clock>;
|
|
32
|
+
/**
|
|
33
|
+
* The answer of `authenticate` for each context this module built — or
|
|
34
|
+
* `undefined` while neither `user()` nor `session()` has been asked, so that
|
|
35
|
+
* reading it never authenticates.
|
|
36
|
+
*/
|
|
37
|
+
export declare const answers: WeakMap<object, () => Promise<Principal<AnyUser> | null> | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* The session cookie of the instance each context authenticated with — set
|
|
40
|
+
* once a resolver has answered, so a renewed session is sent again with the
|
|
41
|
+
* cookie of the instance that renewed it.
|
|
42
|
+
*/
|
|
43
|
+
export declare const cookies: WeakMap<object, SessionCookie | undefined>;
|
|
44
|
+
/** The session cookie of the instance `janus` authenticated with, once it did. */
|
|
45
|
+
export declare function cookieOfContext(janus: object): SessionCookie | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* What `authenticate` answered for `janus`'s request, or `undefined` when it
|
|
48
|
+
* never ran — nothing asked `user()` or `session()`, or the context was not
|
|
49
|
+
* built here. Never runs it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function answerOf(janus: object): Promise<Principal<AnyUser> | null> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* The clock `@fresh` and `requireFresh()` read the time from: the one given
|
|
54
|
+
* to `useJanus({ clock })`, or the system's.
|
|
55
|
+
*/
|
|
56
|
+
export declare function clockOf(janus: object): Clock;
|
|
57
|
+
/**
|
|
58
|
+
* The check `ctx.janus` answers through: the one its context was built
|
|
59
|
+
* with — `access.can`, memoized for the request (`memo.ts`) — or
|
|
60
|
+
* `access.can` itself for a context built by hand. `null` when it has no
|
|
61
|
+
* `access` at all.
|
|
62
|
+
*
|
|
63
|
+
* `fresh` skips the memo: a subscription is one request whose checks run
|
|
64
|
+
* again on every event, and must see a `revoke()` made since it started.
|
|
65
|
+
*/
|
|
66
|
+
export declare function checkOf(janus: object, fresh?: boolean): Check | null;
|
|
67
|
+
/**
|
|
68
|
+
* `ctx.janus`, or a wiring `TypeError` naming `caller` when nothing put it
|
|
69
|
+
* there: `useJanus()` is missing from the plugins.
|
|
70
|
+
*/
|
|
71
|
+
export declare function janusOf(ctx: unknown, caller: string): Built;
|
|
72
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/context/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAe,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,iFAAiF;AACjF,MAAM,MAAM,KAAK,GAAG,CACnB,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EAC9D,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EACtD,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,KAChC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtB,qEAAqE;AACrE,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,MAAM;UAA+B,KAAK;WAAS,KAAK;EAAK,CAAC;AAE3E,iFAAiF;AACjF,eAAO,MAAM,MAAM,wBAA+B,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,OAAO,wBAEb,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAClD,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,OAAO,4CAAmD,CAAC;AAExE,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAExE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACvB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAEhD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAE5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,KAAK,GAAG,IAAI,CAMlE;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAQ3D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Principal, RequestLike } from '@softistx/janus';
|
|
2
|
+
import { type AnyUser } from './registry';
|
|
3
|
+
type LooseAuth = {
|
|
4
|
+
authenticate(request: RequestLike, options?: {
|
|
5
|
+
readonly type?: string;
|
|
6
|
+
readonly apiKey?: boolean;
|
|
7
|
+
}): Promise<Principal<AnyUser> | null>;
|
|
8
|
+
};
|
|
9
|
+
/** `auth` as the options give it: an instance, or a function answering one. */
|
|
10
|
+
export type AuthOrResolver = LooseAuth | ((ctx: never) => LooseAuth | null | undefined | Promise<LooseAuth | null | undefined>);
|
|
11
|
+
/**
|
|
12
|
+
* The instance that serves a request: `auth` itself, or what the function
|
|
13
|
+
* given as `auth` answers for `context`. A function that answers none, or
|
|
14
|
+
* something that is not what `janus()` answered, is a `TypeError`; one that
|
|
15
|
+
* throws or rejects is its own error, unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveAuth(auth: AuthOrResolver, context: unknown, caller: string, what?: 'request' | 'connection'): Promise<LooseAuth>;
|
|
18
|
+
export declare function instanceOf(auth: AuthOrResolver, context: unknown, caller: string, janus: object, what: 'request' | 'connection'): Promise<LooseAuth>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/context/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,YAAY,CAAC;AAEnD,KAAK,SAAS,GAAG;IAChB,YAAY,CACX,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAC7D,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;CACtC,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GACvB,SAAS,GACT,CAAC,CACD,GAAG,EAAE,KAAK,KACL,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,SAAS,GAAG,YAAwB,GACxC,OAAO,CAAC,SAAS,CAAC,CAqBpB;AAED,wBAAsB,UAAU,CAC/B,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS,GAAG,YAAY,GAC5B,OAAO,CAAC,SAAS,CAAC,CAIpB"}
|
package/dist/device.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The device cookie: the long-lived cookie that holds the device token
|
|
3
|
+
* `@softistx/janus` answers as `deviceToken`, read from the request a
|
|
4
|
+
* sign-in mutation received and set back on the response it will send.
|
|
5
|
+
* The same names, defaults and option shape as `@softistx/janus-hono`.
|
|
6
|
+
*/
|
|
7
|
+
import { DEVICE_COOKIE, type DeviceCookieOptions } from '@softistx/janus';
|
|
8
|
+
export { DEVICE_COOKIE, type DeviceCookieOptions };
|
|
9
|
+
/**
|
|
10
|
+
* The device token the request's cookie holds, or `null` when it holds none:
|
|
11
|
+
* what a sign-in takes as `device`.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const signedIn = await auth.signIn(args, { device: deviceOf(ctx.request) });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function deviceOf(request: Request, options?: DeviceCookieOptions): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the device cookie, or sets it again so it lasts another `maxAge`:
|
|
20
|
+
* queues its `Set-Cookie` for `useJanus()` to append to Yoga's response,
|
|
21
|
+
* beside any other cookie the response sets.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* if (result.deviceToken !== null) sendDevice(ctx.request, result.deviceToken);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function sendDevice(request: Request, deviceToken: string, options?: DeviceCookieOptions): void;
|
|
28
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,aAAa,EACb,KAAK,mBAAmB,EAGxB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,CAAC;AAYnD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACvB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,mBAAwB,GAC/B,MAAM,GAAG,IAAI,CAKf;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACzB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,mBAAwB,GAC/B,IAAI,CAKN"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema transform: every object field a directive guards gets its
|
|
3
|
+
* resolver wrapped, once, when the schema is built.
|
|
4
|
+
*/
|
|
5
|
+
import { type GraphQLSchema } from 'graphql';
|
|
6
|
+
type Entries = {
|
|
7
|
+
readonly [type: string]: ((...args: never[]) => unknown) | undefined;
|
|
8
|
+
};
|
|
9
|
+
/** What `applyJanusDirectives()` takes. */
|
|
10
|
+
export interface JanusDirectivesOptions<T extends string = string> {
|
|
11
|
+
/**
|
|
12
|
+
* What `janus()` answered: its `types` are the names `type:` may take.
|
|
13
|
+
* `types: null` (a server whose instance is chosen per request) checks
|
|
14
|
+
* none.
|
|
15
|
+
*/
|
|
16
|
+
readonly auth: {
|
|
17
|
+
readonly types: readonly T[] | null;
|
|
18
|
+
};
|
|
19
|
+
/** `useJanus({ type })`'s: the one user type the schema's users can have. */
|
|
20
|
+
readonly type?: NoInfer<T>;
|
|
21
|
+
/** What `permissions()` answered: its model is what `@permission` may name. Required once a schema uses it. */
|
|
22
|
+
readonly access?: {
|
|
23
|
+
readonly model: unknown;
|
|
24
|
+
} | undefined;
|
|
25
|
+
/** `useJanus({ loaders })`'s. */
|
|
26
|
+
readonly loaders?: Entries | undefined;
|
|
27
|
+
/** `useJanus({ conditions })`'s. */
|
|
28
|
+
readonly conditions?: Entries | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The schema with every field guarded by `@authenticated`, `@fresh` or
|
|
32
|
+
* `@permission` — on the field, on its type, or on an interface the type
|
|
33
|
+
* implements — wrapped so its resolver runs only for a signed-in user, of
|
|
34
|
+
* one of the types `type:` names when it names some, on a session that
|
|
35
|
+
* proved who it is less than `maxAge` seconds ago, holding every permission
|
|
36
|
+
* asked. Every directive that applies must hold.
|
|
37
|
+
*
|
|
38
|
+
* `useJanus()` calls it on every schema it is given. Call it yourself to
|
|
39
|
+
* check a schema without a server: the guards it installs read `ctx.janus`,
|
|
40
|
+
* which only `useJanus()` builds.
|
|
41
|
+
*
|
|
42
|
+
* **Refuses when the schema is built**, with a `TypeError` naming the
|
|
43
|
+
* field: a user type `auth` does not know, a `type: []`, restrictions no
|
|
44
|
+
* user type meets together, a `@fresh` whose `maxAge` is not above zero;
|
|
45
|
+
* for `@permission`, an object type or a permission the model does not
|
|
46
|
+
* declare, a malformed `id:`, an argument the field does not take, and a
|
|
47
|
+
* loader or a condition's `ctx` it needs and was not given.
|
|
48
|
+
*/
|
|
49
|
+
export declare function applyJanusDirectives<const T extends string>(schema: GraphQLSchema, options: JanusDirectivesOptions<T>): GraphQLSchema;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/directives/apply.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAMnE,KAAK,OAAO,GAAG;IACd,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;CACrE,CAAC;AAEF,2CAA2C;AAC3C,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAChE;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAA;KAAE,CAAC;IACvD,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,+GAA+G;IAC/G,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;IAC1D,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,oCAAoC;IACpC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAC1D,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAChC,aAAa,CA4Bf"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What runs before a guarded field's resolver, at request time: the user,
|
|
3
|
+
* then the requirement — its user types, the session's freshness, then each
|
|
4
|
+
* `@permission` in order. A
|
|
5
|
+
* denial is a `GraphQLError`; a failure to answer is `SERVICE_UNAVAILABLE`,
|
|
6
|
+
* never a denial.
|
|
7
|
+
*/
|
|
8
|
+
import type { GraphQLFieldResolver } from 'graphql';
|
|
9
|
+
import type { Requirement } from './validate';
|
|
10
|
+
/** What the field was asked with. */
|
|
11
|
+
export interface Resolving {
|
|
12
|
+
readonly parent: unknown;
|
|
13
|
+
readonly args: unknown;
|
|
14
|
+
readonly ctx: unknown;
|
|
15
|
+
/** A subscription's: its checks skip the request's memo, and see a revoke. */
|
|
16
|
+
readonly fresh: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Refuses the request unless it meets `requirement`. */
|
|
19
|
+
export declare function enforce(requirement: Requirement, { parent, args, ctx, fresh }: Resolving): Promise<void>;
|
|
20
|
+
/** `resolve`, run only once `requirement` is met. */
|
|
21
|
+
export declare function guarded<S, C, A>(resolve: GraphQLFieldResolver<S, C, A>, requirement: Requirement): GraphQLFieldResolver<S, C, A>;
|
|
22
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/directives/guard.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAKpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,qCAAqC;AACrC,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACxB;AAED,yDAAyD;AACzD,wBAAsB,OAAO,CAC5B,WAAW,EAAE,WAAW,EACxB,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,SAAS,GACrC,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED,qDAAqD;AACrD,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC9B,OAAO,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACtC,WAAW,EAAE,WAAW,GACtB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAU/B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One `@permission`, asked at request time: the objects its `id:` names, each
|
|
3
|
+
* checked with the request's check — memoized per request — and a denial
|
|
4
|
+
* unless every one holds. A failure to answer is never a denial.
|
|
5
|
+
*/
|
|
6
|
+
import type { Check } from '../../context';
|
|
7
|
+
import type { PermissionCheck } from './validate';
|
|
8
|
+
type Subject = {
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
};
|
|
12
|
+
/** What the guard has in hand when it asks. */
|
|
13
|
+
export interface Asking {
|
|
14
|
+
readonly check: Check;
|
|
15
|
+
readonly user: Subject;
|
|
16
|
+
readonly parent: unknown;
|
|
17
|
+
readonly args: unknown;
|
|
18
|
+
/** The GraphQL context, which `loaders` and `conditions` receive. */
|
|
19
|
+
readonly ctx: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** Refuses the request unless `user` holds `permission` on every object its `id:` names. */
|
|
22
|
+
export declare function enforcePermission(permission: PermissionCheck, asking: Asking): Promise<void>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=enforce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enforce.d.ts","sourceRoot":"","sources":["../../../src/directives/permission/enforce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,KAAK,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,+CAA+C;AAC/C,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;CACtB;AAED,4FAA4F;AAC5F,wBAAsB,iBAAiB,CACtC,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `@permission` reads of the permission model when the schema is built:
|
|
3
|
+
* the object types, the names each declares, whether one reads a field of
|
|
4
|
+
* its object (`fromField`), and whether a permission reaches a condition
|
|
5
|
+
* (`when`). Read from `access.model`, as `defineModel()` answered it.
|
|
6
|
+
*/
|
|
7
|
+
/** `access.model`, as this module reads it. */
|
|
8
|
+
export interface ModelLike {
|
|
9
|
+
readonly types: readonly string[];
|
|
10
|
+
readonly definition: {
|
|
11
|
+
readonly types: {
|
|
12
|
+
readonly [type: string]: {
|
|
13
|
+
readonly related?: {
|
|
14
|
+
readonly [name: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
readonly permits?: {
|
|
17
|
+
readonly [name: string]: readonly unknown[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** `access.model`, or `null` when `access` is not what `permissions()` answered. */
|
|
24
|
+
export declare function modelOf(access: unknown): ModelLike | null;
|
|
25
|
+
/** The relations and permissions `type` declares: what `can()` may be asked. */
|
|
26
|
+
export declare function namesOf(model: ModelLike, type: string): readonly string[];
|
|
27
|
+
/** The fields `type`'s `fromField`s read; empty when it has none. */
|
|
28
|
+
export declare function fieldsOf(model: ModelLike, type: string): readonly string[];
|
|
29
|
+
/**
|
|
30
|
+
* Whether `can(…, name, { type })` reaches a `when` — through the
|
|
31
|
+
* permission's rules, the permissions they name, and arrows into other types
|
|
32
|
+
* — and so needs a `ctx`. What `CtxOf` computes in the compiler.
|
|
33
|
+
*/
|
|
34
|
+
export declare function reachesCondition(model: ModelLike, type: string, name: string, seen?: Set<string>): boolean;
|
|
35
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/directives/permission/model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+CAA+C;AAC/C,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE;QACpB,QAAQ,CAAC,KAAK,EAAE;YACf,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG;gBACxB,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;iBAAE,CAAC;gBACxD,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAAA;iBAAE,CAAC;aACnE,CAAC;SACF,CAAC;KACF,CAAC;CACF;AAED,oFAAoF;AACpF,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAOzD;AAED,gFAAgF;AAChF,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAMzE;AAYD,qEAAqE;AACrE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAK1E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,GAAG,CAAC,MAAM,CAAa,GAC3B,OAAO,CAiBT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@permission`'s `id:` — `args.<path>` or `parent.<path>` — parsed when the
|
|
3
|
+
* schema is built, and read from a request's arguments or parent value when a
|
|
4
|
+
* field is resolved.
|
|
5
|
+
*/
|
|
6
|
+
/** A parsed `id:`. */
|
|
7
|
+
export interface IdPath {
|
|
8
|
+
/** As written: `args.id`, `parent.wardId`, `args.input.ids`. */
|
|
9
|
+
readonly text: string;
|
|
10
|
+
readonly root: 'args' | 'parent';
|
|
11
|
+
/** The names after the root, at least one. */
|
|
12
|
+
readonly segments: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
/** `text` parsed, or `null` when it is not `args.<name>…` or `parent.<name>…`. */
|
|
15
|
+
export declare function parsePath(text: string): IdPath | null;
|
|
16
|
+
/** One object a check is about: its id, and the value that holds it when that value is the object. */
|
|
17
|
+
export interface Target {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
/** The value the id was read from, when `id` is its `id` field under `parent`. */
|
|
20
|
+
readonly holder: object | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The objects `path` names in this request: one, or one per element where a
|
|
24
|
+
* step reads a list. `null` when a step reads nothing, or an id is not a
|
|
25
|
+
* string or an integer: the request resolved no object id. An empty list
|
|
26
|
+
* under `parent` is `null` too — the object's data names nothing to check,
|
|
27
|
+
* and its fields are not open to everyone for it; under `args` it is the
|
|
28
|
+
* client asking for nothing, and there is nothing to refuse.
|
|
29
|
+
*/
|
|
30
|
+
export declare function targetsOf(path: IdPath, parent: unknown, args: unknown): readonly Target[] | null;
|
|
31
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/directives/permission/path.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sBAAsB;AACtB,MAAM,WAAW,MAAM;IACtB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAID,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOrD;AAED,sGAAsG;AACtG,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,OAAO,GACX,SAAS,MAAM,EAAE,GAAG,IAAI,CAiB1B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One `@permission`, checked against the model and the field when the schema
|
|
3
|
+
* is built, and turned into what the guard asks at request time. Everything
|
|
4
|
+
* no request could pass is a `TypeError` naming the field.
|
|
5
|
+
*/
|
|
6
|
+
import type { PermissionUse } from '../read';
|
|
7
|
+
import { type IdPath } from './path';
|
|
8
|
+
/** `useJanus({ loaders })`'s entry: the object of a type, by id, or `null`. */
|
|
9
|
+
export type Loader = (id: string, ctx: unknown) => unknown;
|
|
10
|
+
/** `useJanus({ conditions })`'s entry: the `ctx` a type's conditions test. */
|
|
11
|
+
export type Condition = (object: unknown, ctx: unknown) => unknown;
|
|
12
|
+
/** What `@permission` reads from `useJanus()`'s options. */
|
|
13
|
+
export interface PermissionWiring {
|
|
14
|
+
readonly access?: unknown;
|
|
15
|
+
readonly loaders?: {
|
|
16
|
+
readonly [type: string]: unknown;
|
|
17
|
+
} | undefined;
|
|
18
|
+
readonly conditions?: {
|
|
19
|
+
readonly [type: string]: unknown;
|
|
20
|
+
} | undefined;
|
|
21
|
+
}
|
|
22
|
+
/** One `@permission`, as the guard asks it. */
|
|
23
|
+
export interface PermissionCheck {
|
|
24
|
+
/** `@permission on Record (read by Record.title)`, for the messages. */
|
|
25
|
+
readonly label: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly type: string;
|
|
28
|
+
readonly onDeny: 'NOT_FOUND' | 'FORBIDDEN';
|
|
29
|
+
readonly path: IdPath;
|
|
30
|
+
/** Loads an object named by id alone; `null` passes `{ type, id }`. */
|
|
31
|
+
readonly load: Loader | null;
|
|
32
|
+
/** Answers the check's `ctx`; `null` when no condition is reachable. */
|
|
33
|
+
readonly condition: Condition | null;
|
|
34
|
+
}
|
|
35
|
+
/** The field a directive is read for: `Type.field`, and the arguments it takes. */
|
|
36
|
+
export interface FieldShape {
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly args: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/** `use`, checked, or a `TypeError` naming the field. */
|
|
41
|
+
export declare function permissionCheckOf(use: PermissionUse, field: FieldShape, wiring: PermissionWiring): PermissionCheck;
|
|
42
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/directives/permission/validate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAS7C,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,QAAQ,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,MAAM,MAAM,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;AAC3D,8EAA8E;AAC9E,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;AAEnE,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;IACpE,QAAQ,CAAC,UAAU,CAAC,EAAE;QAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,SAAS,CAAC;CACvE;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;CACrC;AAED,mFAAmF;AACnF,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,gBAAgB,GACtB,eAAe,CAoCjB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the directives that apply to one object field: its own, its object
|
|
3
|
+
* type's, and those of every interface the type implements — on the
|
|
4
|
+
* interface itself and on the interface's field of the same name. Reads, and
|
|
5
|
+
* decides nothing: `validate.ts` decides what they add up to.
|
|
6
|
+
*/
|
|
7
|
+
import type { GraphQLFieldConfig, GraphQLSchema } from 'graphql';
|
|
8
|
+
/** One `@authenticated`, and where it was written. */
|
|
9
|
+
export interface AuthenticatedUse {
|
|
10
|
+
/** `Type.field`, `Type`, `Interface.field` or `Interface`. */
|
|
11
|
+
readonly where: string;
|
|
12
|
+
/** Its `type:` argument, or `null` when it names none: any signed-in user. */
|
|
13
|
+
readonly types: readonly string[] | null;
|
|
14
|
+
}
|
|
15
|
+
/** One `@fresh`, and where it was written. */
|
|
16
|
+
export interface FreshUse {
|
|
17
|
+
/** `Type.field`, `Type`, `Interface.field` or `Interface`. */
|
|
18
|
+
readonly where: string;
|
|
19
|
+
/** Its `maxAge:` argument, in seconds, as written: checked by `validate.ts`. */
|
|
20
|
+
readonly maxAge: number;
|
|
21
|
+
}
|
|
22
|
+
/** One `@permission`, as written, and where. */
|
|
23
|
+
export interface PermissionUse {
|
|
24
|
+
/** `Type.field`, `Type`, `Interface.field` or `Interface`. */
|
|
25
|
+
readonly where: string;
|
|
26
|
+
/** Written on a type or an interface, rather than on a field. */
|
|
27
|
+
readonly onType: boolean;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly type: string;
|
|
30
|
+
/** Its `id:` argument, or `null` when absent. */
|
|
31
|
+
readonly id: string | null;
|
|
32
|
+
readonly onDeny: 'NOT_FOUND' | 'FORBIDDEN';
|
|
33
|
+
}
|
|
34
|
+
/** Everything written on one field's locations. */
|
|
35
|
+
export interface FieldDirectives {
|
|
36
|
+
readonly authenticated: readonly AuthenticatedUse[];
|
|
37
|
+
readonly fresh: readonly FreshUse[];
|
|
38
|
+
/** In the order they are checked: the type's and interfaces' first, then the field's. */
|
|
39
|
+
readonly permission: readonly PermissionUse[];
|
|
40
|
+
}
|
|
41
|
+
/** Every `@authenticated`, `@fresh` and `@permission` that applies to one object field. */
|
|
42
|
+
export declare function readField(schema: GraphQLSchema, field: GraphQLFieldConfig<unknown, unknown>, fieldName: string, typeName: string): FieldDirectives;
|
|
43
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/directives/read.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAGlB,aAAa,EACb,MAAM,SAAS,CAAC;AAEjB,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CACzC;AAED,8CAA8C;AAC9C,MAAM,WAAW,QAAQ;IACxB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAAC;CAC3C;AAED,mDAAmD;AACnD,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,aAAa,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IACpC,yFAAyF;IACzF,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC9C;AA0CD,2FAA2F;AAC3F,wBAAgB,SAAS,CACxB,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,EAC3C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACd,eAAe,CA6BjB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides, when the schema is built, what the directives on one field add up
|
|
3
|
+
* to — and refuses with a `TypeError` what no request could ever pass: a user
|
|
4
|
+
* type `auth` does not know, a `type: []`, restrictions that exclude each
|
|
5
|
+
* other, a `@fresh` whose `maxAge` is not above zero, or a `@permission` the
|
|
6
|
+
* model, the field or the wiring cannot answer (`permission/validate.ts`).
|
|
7
|
+
*/
|
|
8
|
+
import { type FieldShape, type PermissionCheck, type PermissionWiring } from './permission/validate';
|
|
9
|
+
import type { FieldDirectives } from './read';
|
|
10
|
+
/** What a field requires before its resolver runs. */
|
|
11
|
+
export interface Requirement {
|
|
12
|
+
/** `Type.field`, for the messages. */
|
|
13
|
+
readonly where: string;
|
|
14
|
+
/** The directive a missing `ctx.janus` is reported against. */
|
|
15
|
+
readonly label: string;
|
|
16
|
+
/**
|
|
17
|
+
* The user types allowed, every `type:` intersected; `null` when none
|
|
18
|
+
* narrows it: any signed-in user.
|
|
19
|
+
*/
|
|
20
|
+
readonly types: ReadonlySet<string> | null;
|
|
21
|
+
/**
|
|
22
|
+
* How long ago, in milliseconds, the session may have proved who it is at
|
|
23
|
+
* most — the smallest `@fresh` that applies; `null` when none does.
|
|
24
|
+
*/
|
|
25
|
+
readonly maxAgeMs: number | null;
|
|
26
|
+
/** The permissions asked after that, in order: every one must hold. */
|
|
27
|
+
readonly permissions: readonly PermissionCheck[];
|
|
28
|
+
}
|
|
29
|
+
/** The user types a schema may name: `auth.types`, or the one `useJanus({ type })` keeps. */
|
|
30
|
+
export interface Known {
|
|
31
|
+
/** `null`: none is known, and no `type:` is checked. */
|
|
32
|
+
readonly types: readonly string[] | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The requirement of one field, or `null` when nothing guards it. Throws a
|
|
36
|
+
* `TypeError` naming the field for a directive no request could pass.
|
|
37
|
+
*/
|
|
38
|
+
export declare function requirementOf(field: FieldShape, directives: FieldDirectives, known: Known, wiring: PermissionWiring): Requirement | null;
|
|
39
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/directives/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAoB,eAAe,EAAY,MAAM,QAAQ,CAAC;AAG1E,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC3B,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,CAAC;CACjD;AAED,6FAA6F;AAC7F,MAAM,WAAW,KAAK;IACrB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,gBAAgB,GACtB,WAAW,GAAG,IAAI,CAWpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The phrases the schema-time refusals share. */
|
|
2
|
+
export declare const PREFIX = "applyJanusDirectives()";
|
|
3
|
+
/** `Query.me`, or `Record (read by Record.title)` for a type's directive. */
|
|
4
|
+
export declare function on(where: string, field: string): string;
|
|
5
|
+
/** `'a', 'b'`. */
|
|
6
|
+
export declare function list(names: readonly string[]): string;
|
|
7
|
+
//# sourceMappingURL=words.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words.d.ts","sourceRoot":"","sources":["../../src/directives/words.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAElD,eAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,6EAA6E;AAC7E,wBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,kBAAkB;AAClB,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAErD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
/** What a guard answers without asking `@softistx/janus`: no user, or not this one. */
|
|
3
|
+
export type DenialCode = 'UNAUTHENTICATED' | 'FORBIDDEN' | 'NOT_FOUND';
|
|
4
|
+
/** A denial: `UNAUTHENTICATED` 401, `FORBIDDEN` 403 or `NOT_FOUND` 404. */
|
|
5
|
+
export declare function denial(code: DenialCode, message?: string): GraphQLError;
|
|
6
|
+
//# sourceMappingURL=denial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"denial.d.ts","sourceRoot":"","sources":["../../src/errors/denial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,uFAAuF;AACvF,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,WAAW,GAAG,WAAW,CAAC;AAEvE,2EAA2E;AAC3E,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CAKvE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every refusal as a `GraphQLError` whose `extensions` carry a `code` and the
|
|
3
|
+
* HTTP status Yoga answers with: `{ code, http: { status } }`. This package
|
|
4
|
+
* defines no error class of its own — every denial goes through `denial()`
|
|
5
|
+
* and is a `GraphQLError`, and what `@softistx/janus` throws stays its own until
|
|
6
|
+
* `janusMaskError()` reads it. The one other error built here is
|
|
7
|
+
* `avatarResolvers`' refusal of a bad `size` (`BAD_USER_INPUT`, in `avatar.ts`).
|
|
8
|
+
*/
|
|
9
|
+
export { type DenialCode, denial } from './denial';
|
|
10
|
+
export { janusGraphQLError, rethrown } from './janus-error';
|
|
11
|
+
export { type JanusMaskError, type JanusMaskErrorOptions, janusMaskError, type MaskError, } from './mask';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,cAAc,EACd,KAAK,SAAS,GACd,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JanusError } from '@softistx/janus';
|
|
2
|
+
import { GraphQLError } from 'graphql';
|
|
3
|
+
/**
|
|
4
|
+
* A `JanusError` as the client may read it: its code and status, and only
|
|
5
|
+
* what the client can act on — `issues`, `minLength`, `attemptsLeft`,
|
|
6
|
+
* `retryAfter`, `maxActive`, `field`, an invitation code's refusal `reason` (`unknown`, `expired`, `accepted`, `revoked`), and a social flow's `returnTo` and `flowSpent`. Never any other `reason`, `login`, `slot` or a cause: those are for
|
|
7
|
+
* your logs. A throttled sign-in, and a request past its e-mails
|
|
8
|
+
* (`MAIL_THROTTLED`, 429), also carry their `Retry-After` header in
|
|
9
|
+
* `http.headers`, which Yoga answers with.
|
|
10
|
+
*
|
|
11
|
+
* `STORE_FAILED` is `SERVICE_UNAVAILABLE` 503 — **an outage is never a
|
|
12
|
+
* denial** — and no message of the core's reaches the client.
|
|
13
|
+
*/
|
|
14
|
+
export declare function janusGraphQLError(error: JanusError): GraphQLError;
|
|
15
|
+
/**
|
|
16
|
+
* A rejection handler: a `JanusError` becomes its `GraphQLError`, anything
|
|
17
|
+
* else goes on as it is. `.then(undefined, rethrown)`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function rethrown(error: unknown): never;
|
|
20
|
+
//# sourceMappingURL=janus-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"janus-error.d.ts","sourceRoot":"","sources":["../../src/errors/janus-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmC,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,CAYjE;AA4HD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAE9C"}
|