@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,23 @@
|
|
|
1
|
+
/** What every passkey field reads: the instance serving the request, bound to the user type and the surfaces it must carry. */
|
|
2
|
+
import type { DeviceCookieOptions } from '../device';
|
|
3
|
+
import type { PasskeyFirstFactorTypeApi } from './first-factor.types';
|
|
4
|
+
import type { AnyUser, Context, Current, PasskeyAuth, PasskeyTypeApi } from './types';
|
|
5
|
+
/** What `passkeyResolvers()` resolves from one instance: the calls every field makes. */
|
|
6
|
+
export interface Bound {
|
|
7
|
+
readonly auth: PasskeyAuth;
|
|
8
|
+
readonly api: PasskeyTypeApi;
|
|
9
|
+
readonly first: PasskeyFirstFactorTypeApi | undefined;
|
|
10
|
+
session(ctx: Context): Promise<Current | null>;
|
|
11
|
+
userOf(ctx: Context): Promise<AnyUser>;
|
|
12
|
+
}
|
|
13
|
+
/** Binds an instance to the user type and the surfaces it must carry; throws a `TypeError` when one is missing. */
|
|
14
|
+
export declare function binder(type: string | undefined, firstFactor: boolean): (auth: PasskeyAuth) => Bound;
|
|
15
|
+
/** What every field's resolver reads. */
|
|
16
|
+
export interface Deps {
|
|
17
|
+
readonly answerToken: boolean;
|
|
18
|
+
/** The device cookie's attributes, or `undefined` when devices are not tracked. */
|
|
19
|
+
readonly device: DeviceCookieOptions | undefined;
|
|
20
|
+
/** The instance serving this request, bound. */
|
|
21
|
+
bound(ctx: Context): Promise<Bound>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=deps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../../src/passkeys/deps.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAE/H,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAKrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EACX,OAAO,EACP,OAAO,EACP,OAAO,EACP,WAAW,EACX,cAAc,EACd,MAAM,SAAS,CAAC;AAqCjB,yFAAyF;AACzF,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,yBAAyB,GAAG,SAAS,CAAC;IACtD,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC/C,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC;AAED,mHAAmH;AACnH,wBAAgB,MAAM,CACrB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,WAAW,EAAE,OAAO,GAClB,CAAC,IAAI,EAAE,WAAW,KAAK,KAAK,CAmB9B;AAED,yCAAyC;AACzC,MAAM,WAAW,IAAI;IACpB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACjD,gDAAgD;IAChD,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** The types of the first-factor passkey sign-in and of `auth` chosen per request. */
|
|
2
|
+
import type { SignedIn } from '@softistx/janus';
|
|
3
|
+
import type { AnyUser, Context, PasskeyTypeApi } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* What a user type answers once `janus()` is given `passkeys` with
|
|
6
|
+
* `firstFactor: true`: the passwordless sign-in.
|
|
7
|
+
*/
|
|
8
|
+
export interface PasskeyFirstFactorTypeApi {
|
|
9
|
+
readonly passkeys: {
|
|
10
|
+
signInOptions(): Promise<{
|
|
11
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
12
|
+
readonly challenge: string;
|
|
13
|
+
readonly expiresAt: Date;
|
|
14
|
+
}>;
|
|
15
|
+
signIn(challenge: string, response: unknown, options?: {
|
|
16
|
+
readonly device?: string | null;
|
|
17
|
+
}): Promise<SignedIn<AnyUser>>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** What `firstFactor: true` also requires of `auth`, as {@link PasskeySurface} does. */
|
|
21
|
+
export type PasskeyFirstFactorSurface<T extends string> = [T] extends [never] ? PasskeyFirstFactorTypeApi : PasskeyFirstFactorTypeApi | {
|
|
22
|
+
readonly [K in T]: PasskeyFirstFactorTypeApi;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `auth` as `passkeyResolvers()` takes it: the instance, or a function of the
|
|
26
|
+
* GraphQL context answering the instance that serves the request (`null` for
|
|
27
|
+
* none), as `useJanus()` takes it.
|
|
28
|
+
*/
|
|
29
|
+
export type PasskeyAuthSource<A, Ctx = Context> = A | ((ctx: Ctx) => A | null | undefined | Promise<A | null | undefined>);
|
|
30
|
+
/** What the management fields need when `firstFactor` is on: `passkeys` alone, a `secondFactor` being optional then. */
|
|
31
|
+
export interface PasskeyManageTypeApi {
|
|
32
|
+
readonly passkeys: PasskeyTypeApi['passkeys'];
|
|
33
|
+
}
|
|
34
|
+
/** {@link PasskeyManageTypeApi} as {@link PasskeySurface} places it. */
|
|
35
|
+
export type PasskeyManageSurface<T extends string> = [T] extends [never] ? PasskeyManageTypeApi : PasskeyManageTypeApi | {
|
|
36
|
+
readonly [K in T]: PasskeyManageTypeApi;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=first-factor.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-factor.types.d.ts","sourceRoot":"","sources":["../../src/passkeys/first-factor.types.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,QAAQ,EAAE;QAClB,aAAa,IAAI,OAAO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+
/**
|
|
2
|
+
* The passkey surface, opt-in: `janusPasskeyTypeDefs` beside your own type
|
|
3
|
+
* definitions and `passkeyResolvers({ auth, type? })` for its fields. The
|
|
4
|
+
* WebAuthn options, responses and assertions travel as JSON strings; a
|
|
5
|
+
* passkey sign-in sets the session cookie. With `passkeys: { firstFactor: true }`,
|
|
6
|
+
* `janusPasskeySignInTypeDefs` and `passkeyResolvers({ auth, firstFactor: true })`
|
|
7
|
+
* add the passwordless sign-in; `auth` may be a function of the context.
|
|
8
|
+
*/
|
|
9
|
+
export type { PasskeyAuthSource, PasskeyFirstFactorSurface, PasskeyFirstFactorTypeApi, PasskeyManageSurface, PasskeyManageTypeApi, } from './first-factor.types';
|
|
10
|
+
export { passkeyResolvers } from './resolvers';
|
|
11
|
+
export { janusPasskeyTypeDefs } from './sdl';
|
|
12
|
+
export { janusPasskeySignInTypeDefs } from './sign-in.sdl';
|
|
13
|
+
export type { PasskeyAuth, PasskeyResolvers, PasskeyResolversOptions, PasskeySurface, PasskeyTypeApi, } from './types';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/passkeys/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACX,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EACX,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,cAAc,GACd,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The resolvers of the passkey SDL: two `Query` fields and four `Mutation`
|
|
3
|
+
* fields. A completed passkey sign-in sets the session cookie and the device
|
|
4
|
+
* cookie through `useJanus()`'s `onResponse`, as a renewed session is.
|
|
5
|
+
*/
|
|
6
|
+
import type { Context, PasskeyAuth, PasskeyResolvers, PasskeyResolversOptions } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* The resolvers of the passkey SDL. A refusal of the core —
|
|
9
|
+
* `PASSKEY_INVALID`, `PASSKEY_TAKEN`, `PASSKEY_LIMIT`, `STEP_UP_REQUIRED`,
|
|
10
|
+
* `CODE_INVALID`, `TOKEN_UNKNOWN`… — is rethrown as its `GraphQLError`, so
|
|
11
|
+
* `janusMaskError()` answers its code and status. Needs `useJanus()` for the
|
|
12
|
+
* directives and to set the cookies of a completed sign-in. Throws a
|
|
13
|
+
* `TypeError` at wiring when `janus()` was given no `passkeys`.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const resolvers = mergeResolvers([passkeyResolvers({ auth }), mine]);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* `Query` and `Mutation` are keys of the map: merge it with yours rather than
|
|
20
|
+
* spreading over them.
|
|
21
|
+
*/
|
|
22
|
+
export declare function passkeyResolvers<A extends PasskeyAuth, const T extends string = never, const F extends boolean = false, Ctx = Context>(options: PasskeyResolversOptions<A, T, F, Ctx>): PasskeyResolvers<F>;
|
|
23
|
+
//# sourceMappingURL=resolvers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../src/passkeys/resolvers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,KAAK,EACX,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC/B,CAAC,SAAS,WAAW,EACrB,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,KAAK,EAC9B,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EAC/B,GAAG,GAAG,OAAO,EACZ,OAAO,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CA+CrE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The opt-in passkey SDL: put it beside your own type definitions when users
|
|
3
|
+
* hold passkeys as a second factor. It `extend`s your `Query` and `Mutation`,
|
|
4
|
+
* and needs `janusTypeDefs` for `@authenticated`. The same text ships as
|
|
5
|
+
* `graphql/janus-passkeys.graphqls` — `sdl.spec.ts` holds that the two are
|
|
6
|
+
* identical. Timestamps are ISO-8601 `String`s and WebAuthn JSON travels as
|
|
7
|
+
* `String`s too: no scalar to collide with.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* createSchema({ typeDefs: [janusTypeDefs, janusPasskeyTypeDefs, typeDefs], resolvers });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const janusPasskeyTypeDefs: string;
|
|
14
|
+
//# sourceMappingURL=sdl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdl.d.ts","sourceRoot":"","sources":["../../src/passkeys/sdl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAsIlC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The answers of the passkey resolvers: a core result as the plain object the
|
|
3
|
+
* schema's fields read, timestamps as ISO-8601 strings, WebAuthn JSON as text.
|
|
4
|
+
*/
|
|
5
|
+
import type { Passkey } from '@softistx/janus';
|
|
6
|
+
import type { PasskeyOut } from './types';
|
|
7
|
+
export declare const passkeyOut: (passkey: Passkey) => PasskeyOut;
|
|
8
|
+
/**
|
|
9
|
+
* What the browser answered, parsed from the string the client sent. A text
|
|
10
|
+
* that is not JSON is `BAD_USER_INPUT`, 400, before anything is spent; none
|
|
11
|
+
* of it is echoed back.
|
|
12
|
+
*/
|
|
13
|
+
export declare function jsonOf(text: string, argument: string): unknown;
|
|
14
|
+
//# sourceMappingURL=shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/passkeys/shape.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,UAAU,YAAa,OAAO,KAAG,UAS5C,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQ9D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The resolvers of the first-factor sign-in SDL, added by `passkeyResolvers({ firstFactor: true })`. */
|
|
2
|
+
import type { Deps } from './deps';
|
|
3
|
+
import type { PasskeyResolvers } from './types';
|
|
4
|
+
type Queries = PasskeyResolvers['Query'];
|
|
5
|
+
type Mutations = PasskeyResolvers['Mutation'];
|
|
6
|
+
/**
|
|
7
|
+
* `Query.passkeySignInOptions` (with `firstFactor`): the options for
|
|
8
|
+
* `navigator.credentials.get`, with no credential named, and a challenge.
|
|
9
|
+
*/
|
|
10
|
+
export declare function passkeySignInOptions({ bound, }: Deps): NonNullable<Queries['passkeySignInOptions']>;
|
|
11
|
+
/**
|
|
12
|
+
* `Mutation.passkeySignIn` (with `firstFactor`): redeems the challenge with
|
|
13
|
+
* the browser's assertion and opens a session with the passkey alone; sets
|
|
14
|
+
* the session cookie, or answers its token with `answerToken`; with `device`,
|
|
15
|
+
* tracks the device and sets its cookie.
|
|
16
|
+
*/
|
|
17
|
+
export declare function passkeySignIn({ bound, answerToken, device, }: Deps): NonNullable<Mutations['passkeySignIn']>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=sign-in.resolvers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.resolvers.d.ts","sourceRoot":"","sources":["../../src/passkeys/sign-in.resolvers.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAOzG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGnC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,KAAK,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACzC,KAAK,SAAS,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EACpC,KAAK,GACL,EAAE,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAarD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,MAAM,GACN,EAAE,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAiBhD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The opt-in first-factor passkey SDL: put it beside `janusPasskeyTypeDefs`
|
|
3
|
+
* (it uses that SDL's `PasskeySignedIn`) when `janus()` has
|
|
4
|
+
* `passkeys: { firstFactor: true }`. It `extend`s your `Query` and `Mutation`.
|
|
5
|
+
* The same text ships as `graphql/janus-passkey-sign-in.graphqls` —
|
|
6
|
+
* `sign-in.sdl.spec.ts` holds that the two are identical.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* createSchema({
|
|
10
|
+
* typeDefs: [janusTypeDefs, janusPasskeyTypeDefs, janusPasskeySignInTypeDefs, typeDefs],
|
|
11
|
+
* resolvers: passkeyResolvers({ auth, firstFactor: true }),
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const janusPasskeySignInTypeDefs: string;
|
|
16
|
+
//# sourceMappingURL=sign-in.sdl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in.sdl.d.ts","sourceRoot":"","sources":["../../src/passkeys/sign-in.sdl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAwCxC,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types of the passkey resolvers: the part of `janus()`'s answer they
|
|
3
|
+
* call, their options, and the resolver map they return.
|
|
4
|
+
*/
|
|
5
|
+
import type { Passkey, Session, SignedIn } from '@softistx/janus';
|
|
6
|
+
import type { DeviceCookieOptions } from '../device';
|
|
7
|
+
import type { PasskeyAuthSource, PasskeyFirstFactorSurface, PasskeyManageSurface } from './first-factor.types';
|
|
8
|
+
/** The user as these resolvers read one. */
|
|
9
|
+
export type AnyUser = {
|
|
10
|
+
readonly type: string;
|
|
11
|
+
readonly id: string;
|
|
12
|
+
};
|
|
13
|
+
/** A session as `authenticate` answers it for a request that presented one. */
|
|
14
|
+
export interface Current {
|
|
15
|
+
readonly via: 'session';
|
|
16
|
+
readonly user: AnyUser;
|
|
17
|
+
readonly session: Session;
|
|
18
|
+
readonly token: string;
|
|
19
|
+
readonly renewed: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** What a user type answers once `janus()` is given `passkeys` and a `secondFactor`. */
|
|
22
|
+
export interface PasskeyTypeApi {
|
|
23
|
+
readonly passkeys: {
|
|
24
|
+
registrationOptions(user: {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
readonly options: Readonly<Record<string, unknown>>;
|
|
28
|
+
readonly challenge: string;
|
|
29
|
+
readonly expiresAt: Date;
|
|
30
|
+
}>;
|
|
31
|
+
register(current: Current, input: {
|
|
32
|
+
readonly challenge: string;
|
|
33
|
+
readonly response: unknown;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
}): Promise<Passkey>;
|
|
36
|
+
list(user: {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
}): Promise<readonly Passkey[]>;
|
|
39
|
+
rename(user: {
|
|
40
|
+
readonly id: string;
|
|
41
|
+
}, credentialId: string, name: string): Promise<boolean>;
|
|
42
|
+
remove(current: Current, credentialId: string): Promise<boolean>;
|
|
43
|
+
};
|
|
44
|
+
readonly secondFactor: {
|
|
45
|
+
confirmPasskey(challenge: string, assertion: unknown, options?: {
|
|
46
|
+
readonly device?: string | null;
|
|
47
|
+
}): Promise<SignedIn<AnyUser>>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What these resolvers call of every `janus()` answer: `authenticate` and the
|
|
52
|
+
* session `cookie`. The passkey surface is required beside it by
|
|
53
|
+
* {@link PasskeySurface}: loosely typed on purpose, the types of your
|
|
54
|
+
* instance narrow its own calls.
|
|
55
|
+
*/
|
|
56
|
+
export interface PasskeyAuth {
|
|
57
|
+
authenticate(request: Request, options?: {
|
|
58
|
+
readonly type?: string;
|
|
59
|
+
}): Promise<Current | null>;
|
|
60
|
+
readonly cookie: {
|
|
61
|
+
serialize(token: string, session: Session): string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* What `auth` must carry besides {@link PasskeyAuth}: `passkeys` and
|
|
66
|
+
* `secondFactor.confirmPasskey` at its top (one user type; `type` then only
|
|
67
|
+
* limits the fields), or under the named `type` with several. An instance whose `janus()` was given
|
|
68
|
+
* no `passkeys` carries neither, and is refused on `auth`.
|
|
69
|
+
*/
|
|
70
|
+
export type PasskeySurface<T extends string> = [T] extends [never] ? PasskeyTypeApi : PasskeyTypeApi | {
|
|
71
|
+
readonly [K in T]: PasskeyTypeApi;
|
|
72
|
+
};
|
|
73
|
+
/** What `passkeyResolvers()` takes. */
|
|
74
|
+
export interface PasskeyResolversOptions<A extends PasskeyAuth = PasskeyAuth, T extends string = string, F extends boolean = false, Ctx = Context> {
|
|
75
|
+
/**
|
|
76
|
+
* What `janus()` answered; its instance needs `passkeys` (and a
|
|
77
|
+
* `secondFactor` for `confirmSecondFactorPasskey`; with `firstFactor: true`
|
|
78
|
+
* it is optional, and `passkeys.firstFactor: true` is required). Or
|
|
79
|
+
* a function of the GraphQL context answering the instance that serves the
|
|
80
|
+
* request — `(ctx) => instances.get(ctx.host)` — to serve several tenants
|
|
81
|
+
* from one schema. It runs on every field, awaited when it returns a
|
|
82
|
+
* promise; `null` for none is `UNAUTHENTICATED`, 401. An instance that
|
|
83
|
+
* lacks the surface is then a `TypeError` on that request, not at wiring.
|
|
84
|
+
* Give `useJanus()` the same function.
|
|
85
|
+
*/
|
|
86
|
+
readonly auth: PasskeyAuthSource<A & (F extends true ? PasskeyManageSurface<T> & PasskeyFirstFactorSurface<T> : PasskeySurface<T>), Ctx>;
|
|
87
|
+
/**
|
|
88
|
+
* Add the passwordless sign-in fields, `passkeySignInOptions` and
|
|
89
|
+
* `passkeySignIn` (SDL: `janusPasskeySignInTypeDefs`). Needs
|
|
90
|
+
* `janus({ passkeys: { firstFactor: true } })`. Off by default: the
|
|
91
|
+
* resolver map holds the six fields of `janusPasskeyTypeDefs` only.
|
|
92
|
+
*/
|
|
93
|
+
readonly firstFactor?: F;
|
|
94
|
+
/**
|
|
95
|
+
* The user type that registers, lists and signs in with passkeys. Needed
|
|
96
|
+
* when several user types are configured (`auth.<type>.passkeys` is then
|
|
97
|
+
* the surface); it also limits the fields to that type's users.
|
|
98
|
+
*/
|
|
99
|
+
readonly type?: T;
|
|
100
|
+
/**
|
|
101
|
+
* Answer the session token in `PasskeySignedIn.token` instead of setting
|
|
102
|
+
* the session cookie, for a backend-for-frontend that keeps the token in
|
|
103
|
+
* its own cookie and forwards it as `Authorization: Bearer`. Off by
|
|
104
|
+
* default: the cookie is set and `token` is null.
|
|
105
|
+
*/
|
|
106
|
+
readonly answerToken?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Track the device of the passkey sign-in, as a sign-in mutation does:
|
|
109
|
+
* `true`, or the device cookie's attributes as `deviceOf` and
|
|
110
|
+
* `sendDevice` take them. Needs `janus({ devices })`: a visitor without
|
|
111
|
+
* the cookie is then a new device (`newDevice`, `user.newDeviceSignedIn`)
|
|
112
|
+
* and gets the cookie. Off by default, and `janus()` without `devices`
|
|
113
|
+
* refuses a device.
|
|
114
|
+
*/
|
|
115
|
+
readonly device?: DeviceCookieOptions | true;
|
|
116
|
+
}
|
|
117
|
+
/** A GraphQL context as these resolvers read it. */
|
|
118
|
+
export interface Context {
|
|
119
|
+
readonly request?: Request;
|
|
120
|
+
}
|
|
121
|
+
/** `Query.passkeySignInOptions`, present with `firstFactor: true`. */
|
|
122
|
+
export type PasskeySignInOptionsResolver = (parent: unknown, args: unknown, ctx: Context) => Promise<SignInChallengeOut>;
|
|
123
|
+
/** `Mutation.passkeySignIn`, present with `firstFactor: true`. */
|
|
124
|
+
export type PasskeySignInResolver = (parent: unknown, args: {
|
|
125
|
+
readonly challenge: string;
|
|
126
|
+
readonly assertion: string;
|
|
127
|
+
}, ctx: Context) => Promise<SignedInOut>;
|
|
128
|
+
/**
|
|
129
|
+
* The resolver map, keyed as `createSchema` expects. `F` is the `firstFactor`
|
|
130
|
+
* option `passkeyResolvers()` was given: with `true`, `passkeySignInOptions`
|
|
131
|
+
* and `passkeySignIn` are defined; with the default (`boolean`) they may be
|
|
132
|
+
* absent.
|
|
133
|
+
*/
|
|
134
|
+
export interface PasskeyResolvers<F extends boolean = boolean> {
|
|
135
|
+
readonly Query: {
|
|
136
|
+
readonly passkeys: (parent: unknown, args: unknown, ctx: Context) => Promise<readonly PasskeyOut[]>;
|
|
137
|
+
readonly passkeyRegistrationOptions: (parent: unknown, args: unknown, ctx: Context) => Promise<RegistrationOut>;
|
|
138
|
+
} & ([F] extends [true] ? {
|
|
139
|
+
readonly passkeySignInOptions: PasskeySignInOptionsResolver;
|
|
140
|
+
} : {
|
|
141
|
+
readonly passkeySignInOptions?: PasskeySignInOptionsResolver;
|
|
142
|
+
});
|
|
143
|
+
readonly Mutation: {
|
|
144
|
+
readonly registerPasskey: (parent: unknown, args: {
|
|
145
|
+
readonly challenge: string;
|
|
146
|
+
readonly response: string;
|
|
147
|
+
readonly name: string;
|
|
148
|
+
}, ctx: Context) => Promise<PasskeyOut>;
|
|
149
|
+
readonly renamePasskey: (parent: unknown, args: {
|
|
150
|
+
readonly credentialId: string;
|
|
151
|
+
readonly name: string;
|
|
152
|
+
}, ctx: Context) => Promise<boolean>;
|
|
153
|
+
readonly removePasskey: (parent: unknown, args: {
|
|
154
|
+
readonly credentialId: string;
|
|
155
|
+
}, ctx: Context) => Promise<boolean>;
|
|
156
|
+
readonly confirmSecondFactorPasskey: (parent: unknown, args: {
|
|
157
|
+
readonly challenge: string;
|
|
158
|
+
readonly assertion: string;
|
|
159
|
+
}, ctx: Context) => Promise<SignedInOut>;
|
|
160
|
+
} & ([F] extends [true] ? {
|
|
161
|
+
readonly passkeySignIn: PasskeySignInResolver;
|
|
162
|
+
} : {
|
|
163
|
+
readonly passkeySignIn?: PasskeySignInResolver;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
export interface PasskeyOut {
|
|
167
|
+
readonly credentialId: string;
|
|
168
|
+
readonly name: string;
|
|
169
|
+
readonly transports: readonly string[];
|
|
170
|
+
readonly aaguid: string;
|
|
171
|
+
readonly backupEligible: boolean;
|
|
172
|
+
readonly backedUp: boolean;
|
|
173
|
+
readonly createdAt: string;
|
|
174
|
+
readonly lastUsedAt: string | null;
|
|
175
|
+
}
|
|
176
|
+
export interface RegistrationOut {
|
|
177
|
+
/** The options as JSON text, for `navigator.credentials.create`. */
|
|
178
|
+
readonly options: string;
|
|
179
|
+
readonly challenge: string;
|
|
180
|
+
readonly expiresAt: string;
|
|
181
|
+
}
|
|
182
|
+
/** `JanusPasskeySignInChallenge`: the options for `navigator.credentials.get`. */
|
|
183
|
+
export type SignInChallengeOut = RegistrationOut;
|
|
184
|
+
export interface SignedInOut {
|
|
185
|
+
/** For a `user` field of your own on `PasskeySignedIn`. */
|
|
186
|
+
readonly user: AnyUser;
|
|
187
|
+
/** The session token with `answerToken`, else null. */
|
|
188
|
+
readonly token: string | null;
|
|
189
|
+
readonly userId: string;
|
|
190
|
+
readonly expiresAt: string;
|
|
191
|
+
readonly newDevice: boolean;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/passkeys/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EACX,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,EACpB,MAAM,sBAAsB,CAAC;AAE9B,4CAA4C;AAC5C,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,+EAA+E;AAC/E,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC1B;AAED,wFAAwF;AACxF,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,QAAQ,EAAE;QAClB,mBAAmB,CAAC,IAAI,EAAE;YAAE,QAAQ,CAAC,EAAE,EAAE,MAA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M,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,kFAAkF;AAClF,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `useJanus()`, the envelop plugin — for Yoga, or any server built on
|
|
3
|
+
* envelop.
|
|
4
|
+
*/
|
|
5
|
+
import type { Plugin } from '@envelop/core';
|
|
6
|
+
import type { Auth, JanusContext, JanusOptions, UserOfAuth } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* The plugin that wires `@softistx/janus` into a GraphQL server:
|
|
9
|
+
*
|
|
10
|
+
* - every request's context gets `ctx.janus` — `user()` and `session()`,
|
|
11
|
+
* authenticated lazily and once, and `access` when it is given;
|
|
12
|
+
* - every schema the server is given has its directives applied, once, by
|
|
13
|
+
* `applyJanusDirectives()`.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* createYoga({
|
|
17
|
+
* schema: createSchema({ typeDefs: [janusTypeDefs, typeDefs], resolvers }),
|
|
18
|
+
* plugins: [useJanus({ auth, access })],
|
|
19
|
+
* maskedErrors: { maskError: janusMaskError() },
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* `type` treats a user of any other type as anonymous, as
|
|
24
|
+
* `auth.authenticate(request, { type })` does. `clock` is what `@fresh` and
|
|
25
|
+
* `requireFresh()` read the time from — the one given to `janus()`.
|
|
26
|
+
* `loaders` and `conditions` are what `@permission` needs beside `access`:
|
|
27
|
+
* the objects it checks by id, and the `ctx` of the conditions it reaches.
|
|
28
|
+
*
|
|
29
|
+
* `apiKey: true` also accepts an API key (`Authorization: Bearer sl_…`):
|
|
30
|
+
* `ctx.janus` gains `principal()` and `apiKey()`, `user()` is the key's user,
|
|
31
|
+
* `session()` is `null` for a key, and `@fresh` refuses one with
|
|
32
|
+
* `STEP_UP_REQUIRED`. Off, a key is anonymous and nothing else changes.
|
|
33
|
+
*
|
|
34
|
+
* A session `authenticate` renewed for a request that presented it as the
|
|
35
|
+
* session cookie is sent again, `Set-Cookie` on Yoga's response
|
|
36
|
+
* (`onResponse`), so a browser keeps the new expiry. Not to a bearer token or
|
|
37
|
+
* `X-Session-Token`, and never when nothing authenticated.
|
|
38
|
+
*
|
|
39
|
+
* `auth` may also be a function of the request's context — `(ctx) =>
|
|
40
|
+
* instance`, `ctx.request` over HTTP — answering the `janus()` instance that
|
|
41
|
+
* serves it, so one server serves several issuers. It runs once per context,
|
|
42
|
+
* the first time `user()` or `session()` asks; `types` then names the user
|
|
43
|
+
* types the directives may use, which no instance can tell at start-up.
|
|
44
|
+
*
|
|
45
|
+
* An operation over graphql-ws has no request: its `ctx.janus`
|
|
46
|
+
* authenticates the credential its connection presented, once
|
|
47
|
+
* `janusConnection().onConnect` accepted it — and has no response to carry a
|
|
48
|
+
* renewed cookie.
|
|
49
|
+
*/
|
|
50
|
+
export declare function useJanus<A extends Auth<{
|
|
51
|
+
readonly type: string;
|
|
52
|
+
readonly id: string;
|
|
53
|
+
}>, P extends object | undefined = undefined, const T extends UserOfAuth<A>['type'] = UserOfAuth<A>['type'], const K extends boolean = false>(options: JanusOptions<A, P, T, K>): Plugin<JanusContext<A, P, T, K>> & {
|
|
54
|
+
readonly onResponse: (payload: {
|
|
55
|
+
readonly request: Request;
|
|
56
|
+
readonly response: Response;
|
|
57
|
+
}) => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +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;AAQ5C,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;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,EAC7D,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,KAAK,EAE/B,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC/B,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG;IACrC,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,CA4CA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
* `@softistx/janus-hono`'s `session()` does — through Yoga's `onResponse`.
|
|
5
|
+
*/
|
|
6
|
+
import type { Session } from '@softistx/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
|
+
/**
|
|
18
|
+
* Asks `resendRenewed` to send `setCookie` on the response of `request`: the
|
|
19
|
+
* session cookie of a sign-in a resolver made. Needs `useJanus()`'s
|
|
20
|
+
* `onResponse` to run, so it is sent over HTTP through Yoga only.
|
|
21
|
+
*/
|
|
22
|
+
export declare function sendCookie(request: object, setCookie: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Asks `resendRenewed` to answer `Cache-Control: no-store` for `request`: a
|
|
25
|
+
* response that carries a secret (a TOTP secret, recovery codes). Needs
|
|
26
|
+
* `useJanus()`'s `onResponse`, so it holds over HTTP through Yoga only.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sendNoStore(request: object): void;
|
|
29
|
+
/**
|
|
30
|
+
* `sendNoStore` for a resolver that also runs without a request (graphql-ws,
|
|
31
|
+
* a context built by hand): nothing is sent when `ctx` carries none.
|
|
32
|
+
*/
|
|
33
|
+
export declare function noStoreOf(ctx: {
|
|
34
|
+
readonly request?: Request;
|
|
35
|
+
} | undefined): void;
|
|
36
|
+
/** Remembers `janus` as a context built for `request`. */
|
|
37
|
+
export declare function track(request: object, janus: object): void;
|
|
38
|
+
/**
|
|
39
|
+
* Sends the session cookie again when a context of `request` renewed it —
|
|
40
|
+
* only when `authenticate` ran for it, so an operation that asked nothing
|
|
41
|
+
* costs nothing here. As `session()` in `@softistx/janus-hono`, only to a
|
|
42
|
+
* request that presented the token as the session cookie — a client that sent
|
|
43
|
+
* `Authorization: Bearer` or `X-Session-Token` is not handed a cookie it never
|
|
44
|
+
* asked for — and never over a session cookie the response already sets.
|
|
45
|
+
*
|
|
46
|
+
* A failed `authenticate` sends nothing: its error is the response's.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resendRenewed({ request, response }: ResponsePayload, fixed: SessionCookie | undefined): Promise<void>;
|
|
49
|
+
/** The value of the cookie `name` the request sent, or `null`. */
|
|
50
|
+
export declare function cookieOf(request: Request, name: string): string | null;
|
|
51
|
+
//# 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,iBAAiB,CAAC;AAG/C,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;AAYD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAInE;AAID;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACxB,GAAG,EAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAC7C,IAAI,CAEN;AAED,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,KAAK,EAAE,aAAa,GAAG,SAAS,GAC9B,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,kEAAkE;AAClE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUtE"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 '@softistx/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
|
+
/**
|
|
23
|
+
* The `JanusError` behind any error: itself, or the one a chain of
|
|
24
|
+
* `GraphQLError`s carries as `originalError` — what the package's resolvers
|
|
25
|
+
* and directives throw. `undefined` when there is none; use it to map a
|
|
26
|
+
* resolver's refusal (`INVITATION_NOT_PENDING`, `NOT_FOUND`…) per operation.
|
|
27
|
+
*/
|
|
28
|
+
export declare function janusErrorOf(error: unknown): JanusError | undefined;
|
|
29
|
+
//# 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,iBAAiB,CAAC;AAGvD;;;;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;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAEnE"}
|
package/dist/sdl.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directives and the enum this package reads, as SDL: put it beside your
|
|
3
|
+
* own type definitions. The same text ships as `graphql/janus.graphqls`, for
|
|
4
|
+
* a code generator or an editor that reads files — `sdl.spec.ts` holds that
|
|
5
|
+
* the two are identical.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* createSchema({ typeDefs: [janusTypeDefs, typeDefs], resolvers });
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const janusTypeDefs: string;
|
|
12
|
+
//# sourceMappingURL=sdl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdl.d.ts","sourceRoot":"","sources":["../src/sdl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,MA4C3B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The TOTP second-factor surface, opt-in: `janusSecondFactorTypeDefs` beside
|
|
3
|
+
* your own type definitions and `secondFactorResolvers({ auth, type? })` for
|
|
4
|
+
* its fields. A completed second-factor sign-in sets the session cookie;
|
|
5
|
+
* your policy (who must hold a factor, the freshness window) is an option or
|
|
6
|
+
* a hook.
|
|
7
|
+
*/
|
|
8
|
+
export { secondFactorResolvers, secondFactorViewerFields } from './resolvers';
|
|
9
|
+
export { janusSecondFactorTypeDefs } from './sdl';
|
|
10
|
+
export { secondFactorChallengeOut } from './shape';
|
|
11
|
+
export type { ChallengeIn, ChallengeOut, SecondFactorAction, SecondFactorAuth, SecondFactorAuthSource, SecondFactorResolvers, SecondFactorResolversOptions, SecondFactorSurface, SecondFactorTypeApi, SecondFactorViewerFields, } from './types';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/second-factor/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,YAAY,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,GACxB,MAAM,SAAS,CAAC"}
|