@axium/core 0.5.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +13 -42
- package/dist/apps.d.ts +9 -0
- package/dist/apps.js +7 -0
- package/dist/auth.d.ts +15 -0
- package/dist/auth.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/passkeys.d.ts +55 -0
- package/dist/passkeys.js +35 -0
- package/dist/preferences.d.ts +39 -0
- package/dist/preferences.js +27 -0
- package/dist/schemas.d.ts +4 -79
- package/dist/schemas.js +4 -45
- package/dist/user.d.ts +40 -7
- package/dist/user.js +12 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,45 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
|
|
2
2
|
import type z from 'zod';
|
|
3
|
-
import type { RequestMethod } from './requests.js';
|
|
4
|
-
import type { APIUserRegistration, LogoutSessions, PasskeyAuthenticationResponse, PasskeyChangeable, PasskeyRegistration, UserAuthOptions } from './schemas.js';
|
|
5
|
-
import type { User, UserChangeable, UserPublic } from './user.js';
|
|
6
3
|
import type { AccessControl } from './access.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
elevated: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface Verification {
|
|
15
|
-
userId: string;
|
|
16
|
-
expires: Date;
|
|
17
|
-
}
|
|
18
|
-
export interface Passkey {
|
|
19
|
-
id: string;
|
|
20
|
-
name?: string | null;
|
|
21
|
-
createdAt: Date;
|
|
22
|
-
userId: string;
|
|
23
|
-
deviceType: CredentialDeviceType;
|
|
24
|
-
backedUp: boolean;
|
|
25
|
-
transports: AuthenticatorTransportFuture[];
|
|
26
|
-
}
|
|
27
|
-
export interface NewSessionResponse {
|
|
28
|
-
userId: string;
|
|
29
|
-
token: string;
|
|
30
|
-
}
|
|
31
|
-
export interface AppMetadata {
|
|
32
|
-
readonly id: string;
|
|
33
|
-
readonly name?: string;
|
|
34
|
-
readonly version?: string;
|
|
35
|
-
readonly image?: string;
|
|
36
|
-
readonly icon?: string;
|
|
37
|
-
}
|
|
4
|
+
import type { App } from './apps.js';
|
|
5
|
+
import type { NewSessionResponse, Session, Verification } from './auth.js';
|
|
6
|
+
import type { Passkey, PasskeyAuthenticationResponse, PasskeyChangeable, PasskeyRegistration } from './passkeys.js';
|
|
7
|
+
import type { RequestMethod } from './requests.js';
|
|
8
|
+
import type { LogoutSessions, User, UserAuthOptions, UserChangeable, UserPublic, UserRegistration } from './user.js';
|
|
38
9
|
/**
|
|
39
10
|
* Types for all API endpoints
|
|
40
11
|
* @internal
|
|
41
12
|
*/
|
|
42
|
-
export interface
|
|
13
|
+
export interface $API {
|
|
43
14
|
metadata: {
|
|
44
15
|
GET: {
|
|
45
16
|
version: string;
|
|
@@ -51,7 +22,7 @@ export interface _apiTypes {
|
|
|
51
22
|
};
|
|
52
23
|
};
|
|
53
24
|
apps: {
|
|
54
|
-
GET:
|
|
25
|
+
GET: App[];
|
|
55
26
|
};
|
|
56
27
|
session: {
|
|
57
28
|
GET: Session & {
|
|
@@ -64,7 +35,7 @@ export interface _apiTypes {
|
|
|
64
35
|
userId: string;
|
|
65
36
|
options: PublicKeyCredentialCreationOptionsJSON;
|
|
66
37
|
};
|
|
67
|
-
POST: [z.input<typeof
|
|
38
|
+
POST: [z.input<typeof UserRegistration>, NewSessionResponse];
|
|
68
39
|
};
|
|
69
40
|
'users/:id': {
|
|
70
41
|
GET: UserPublic & Partial<User>;
|
|
@@ -118,8 +89,8 @@ export interface _apiTypes {
|
|
|
118
89
|
}, AccessControl];
|
|
119
90
|
};
|
|
120
91
|
}
|
|
121
|
-
export type Endpoint = keyof
|
|
122
|
-
export type APIFunction<Method extends RequestMethod, E extends Endpoint> = Method extends keyof
|
|
123
|
-
export type RequestBody<Method extends RequestMethod, E extends Endpoint> = Method extends keyof
|
|
124
|
-
export type Result<Method extends RequestMethod, E extends Endpoint> = Promise<Method extends keyof
|
|
92
|
+
export type Endpoint = keyof $API;
|
|
93
|
+
export type APIFunction<Method extends RequestMethod, E extends Endpoint> = Method extends keyof $API[E] ? $API[E][Method] extends [infer Body, infer Result] ? (body: Body) => Promise<Result> : () => $API[E][Method] : unknown;
|
|
94
|
+
export type RequestBody<Method extends RequestMethod, E extends Endpoint> = Method extends keyof $API[E] ? $API[E][Method] extends [infer Body, unknown] ? Body : any : unknown;
|
|
95
|
+
export type Result<Method extends RequestMethod, E extends Endpoint> = Promise<Method extends keyof $API[E] ? ($API[E][Method] extends [unknown, infer R] ? R : $API[E][Method]) : unknown>;
|
|
125
96
|
export type APIParameters<S extends string> = S extends `${string}/:${infer Right}` ? [string, ...APIParameters<Right>] : [];
|
package/dist/apps.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const App: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
image: z.ZodOptional<z.ZodString>;
|
|
6
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export interface App extends z.infer<typeof App> {
|
|
9
|
+
}
|
package/dist/apps.js
ADDED
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Session {
|
|
2
|
+
id: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
expires: Date;
|
|
5
|
+
created: Date;
|
|
6
|
+
elevated: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface Verification {
|
|
9
|
+
userId: string;
|
|
10
|
+
expires: Date;
|
|
11
|
+
}
|
|
12
|
+
export interface NewSessionResponse {
|
|
13
|
+
userId: string;
|
|
14
|
+
token: string;
|
|
15
|
+
}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from './access.js';
|
|
2
2
|
export * from './api.js';
|
|
3
|
+
export * from './apps.js';
|
|
4
|
+
export * from './auth.js';
|
|
3
5
|
export * as icons from './icons.js';
|
|
6
|
+
export * from './passkeys.js';
|
|
7
|
+
export * from './preferences.js';
|
|
4
8
|
export * from './requests.js';
|
|
5
9
|
export * from './schemas.js';
|
|
6
10
|
export * from './user.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from './access.js';
|
|
2
2
|
export * from './api.js';
|
|
3
|
+
export * from './apps.js';
|
|
4
|
+
export * from './auth.js';
|
|
3
5
|
export * as icons from './icons.js';
|
|
6
|
+
export * from './passkeys.js';
|
|
7
|
+
export * from './preferences.js';
|
|
4
8
|
export * from './requests.js';
|
|
5
9
|
export * from './schemas.js';
|
|
6
10
|
export * from './user.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AuthenticatorTransportFuture } from '@simplewebauthn/server';
|
|
2
|
+
import type { CredentialDeviceType } from '@simplewebauthn/types';
|
|
3
|
+
import * as z from 'zod';
|
|
4
|
+
export declare const authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
5
|
+
export declare const PasskeyRegistration: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
rawId: z.ZodString;
|
|
8
|
+
response: z.ZodObject<{
|
|
9
|
+
clientDataJSON: z.ZodString;
|
|
10
|
+
attestationObject: z.ZodString;
|
|
11
|
+
authenticatorData: z.ZodOptional<z.ZodString>;
|
|
12
|
+
transports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
13
|
+
ble: "ble";
|
|
14
|
+
hybrid: "hybrid";
|
|
15
|
+
internal: "internal";
|
|
16
|
+
nfc: "nfc";
|
|
17
|
+
usb: "usb";
|
|
18
|
+
cable: "cable";
|
|
19
|
+
"smart-card": "smart-card";
|
|
20
|
+
}>>>;
|
|
21
|
+
publicKeyAlgorithm: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
publicKey: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
25
|
+
clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
26
|
+
type: z.ZodLiteral<"public-key">;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
/**
|
|
29
|
+
* POSTed to the `/users/:id/login` endpoint.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PasskeyAuthenticationResponse: z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
rawId: z.ZodString;
|
|
34
|
+
response: z.ZodObject<{
|
|
35
|
+
clientDataJSON: z.ZodString;
|
|
36
|
+
authenticatorData: z.ZodString;
|
|
37
|
+
signature: z.ZodString;
|
|
38
|
+
userHandle: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
41
|
+
clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
42
|
+
type: z.ZodLiteral<"public-key">;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export declare const PasskeyChangeable: z.ZodObject<{
|
|
45
|
+
name: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export interface Passkey {
|
|
48
|
+
id: string;
|
|
49
|
+
name?: string | null;
|
|
50
|
+
createdAt: Date;
|
|
51
|
+
userId: string;
|
|
52
|
+
deviceType: CredentialDeviceType;
|
|
53
|
+
backedUp: boolean;
|
|
54
|
+
transports: AuthenticatorTransportFuture[];
|
|
55
|
+
}
|
package/dist/passkeys.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
const transports = ['ble', 'cable', 'hybrid', 'internal', 'nfc', 'smart-card', 'usb'];
|
|
3
|
+
export const authenticatorAttachment = z.literal(['platform', 'cross-platform']).optional();
|
|
4
|
+
export const PasskeyRegistration = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
rawId: z.string(),
|
|
7
|
+
response: z.object({
|
|
8
|
+
clientDataJSON: z.string(),
|
|
9
|
+
attestationObject: z.string(),
|
|
10
|
+
authenticatorData: z.string().optional(),
|
|
11
|
+
transports: z.array(z.enum(transports)).optional(),
|
|
12
|
+
publicKeyAlgorithm: z.number().optional(),
|
|
13
|
+
publicKey: z.string().optional(),
|
|
14
|
+
}),
|
|
15
|
+
authenticatorAttachment,
|
|
16
|
+
clientExtensionResults: z.record(z.any(), z.any()),
|
|
17
|
+
type: z.literal('public-key'),
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* POSTed to the `/users/:id/login` endpoint.
|
|
21
|
+
*/
|
|
22
|
+
export const PasskeyAuthenticationResponse = z.object({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
rawId: z.string(),
|
|
25
|
+
response: z.object({
|
|
26
|
+
clientDataJSON: z.string(),
|
|
27
|
+
authenticatorData: z.string(),
|
|
28
|
+
signature: z.string(),
|
|
29
|
+
userHandle: z.string().optional(),
|
|
30
|
+
}),
|
|
31
|
+
authenticatorAttachment,
|
|
32
|
+
clientExtensionResults: z.record(z.any(), z.any()),
|
|
33
|
+
type: z.literal('public-key'),
|
|
34
|
+
});
|
|
35
|
+
export const PasskeyChangeable = z.object({ name: z.string() }).partial();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/** @internal Used so we can narrow using `type` and get access to type-specific properties (e.g. `ZodNumber.minValue`) */
|
|
3
|
+
type StringFormatTypes = z.ZodGUID | z.ZodUUID | z.ZodEmail | z.ZodURL | z.ZodEmoji | z.ZodNanoID | z.ZodCUID | z.ZodCUID2 | z.ZodULID | z.ZodXID | z.ZodKSUID | z.ZodISODateTime | z.ZodISODate | z.ZodISOTime | z.ZodISODuration | z.ZodIPv4 | z.ZodIPv6 | z.ZodCIDRv4 | z.ZodCIDRv6 | z.ZodBase64 | z.ZodBase64URL | z.ZodE164 | z.ZodJWT;
|
|
4
|
+
type ZodPrefPrimitive = z.ZodString | z.ZodNumber | z.ZodBigInt | z.ZodBoolean | z.ZodDate | z.ZodLiteral | z.ZodTemplateLiteral | z.ZodFile | z.ZodEnum | StringFormatTypes;
|
|
5
|
+
type ZodPrefComposite = ZodPrefPrimitive | z.ZodNullable<ZodPrefPrimitive> | z.ZodOptional<ZodPrefPrimitive> | z.ZodArray<ZodPrefPrimitive> | z.ZodTuple<ZodPrefPrimitive[]> | z.ZodRecord<z.ZodString, ZodPrefPrimitive> | z.ZodObject<Readonly<Record<string, ZodPrefPrimitive>>>;
|
|
6
|
+
/** @internal Used so we can narrow using `type` and get access to type-specific properties (e.g. `ZodNumber.minValue`) */
|
|
7
|
+
export type ZodPref = ZodPrefComposite | z.ZodObject<Readonly<Record<string, ZodPrefComposite>>>;
|
|
8
|
+
/**
|
|
9
|
+
* Interface for the user preferences schema shape.
|
|
10
|
+
* Modify with `declare module ...`.
|
|
11
|
+
*/
|
|
12
|
+
export interface PreferenceSchemas {
|
|
13
|
+
debug: z.ZodBoolean;
|
|
14
|
+
}
|
|
15
|
+
export type PreferenceName = keyof PreferenceSchemas & string;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare const preferenceSchemas: PreferenceSchemas;
|
|
20
|
+
export type Preferences = z.infer<z.ZodObject<Readonly<PreferenceSchemas>>>;
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare const preferenceDefaults: Preferences;
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
* @todo Implement proper localization
|
|
28
|
+
*/
|
|
29
|
+
export declare const preferenceLabels: Record<PreferenceName, string>;
|
|
30
|
+
export declare const preferenceDescriptions: Partial<Record<PreferenceName, string>>;
|
|
31
|
+
export interface PreferenceInit<T extends PreferenceName = PreferenceName> {
|
|
32
|
+
name: T;
|
|
33
|
+
schema: PreferenceSchemas[T] & ZodPref;
|
|
34
|
+
initial: z.infer<PreferenceSchemas[T] & ZodPref>;
|
|
35
|
+
label: string;
|
|
36
|
+
descriptions?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function addPreference<T extends PreferenceName = PreferenceName>(init: PreferenceInit<T>): void;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export const preferenceSchemas = {
|
|
6
|
+
debug: z.boolean(),
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export const preferenceDefaults = {
|
|
12
|
+
debug: false,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
* @todo Implement proper localization
|
|
17
|
+
*/
|
|
18
|
+
export const preferenceLabels = {
|
|
19
|
+
debug: 'Debug mode',
|
|
20
|
+
};
|
|
21
|
+
export const preferenceDescriptions = {};
|
|
22
|
+
export function addPreference(init) {
|
|
23
|
+
preferenceSchemas[init.name] = init.schema;
|
|
24
|
+
preferenceDefaults[init.name] = init.initial;
|
|
25
|
+
preferenceLabels[init.name] = init.label;
|
|
26
|
+
preferenceDescriptions[init.name] = init.descriptions;
|
|
27
|
+
}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,82 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
/** Needed for discriminated union type narrowing */
|
|
3
|
+
export declare function zIs<const T extends z.core.$ZodTypeDef['type']>(schema: z.ZodType, type: T): schema is z.ZodType & {
|
|
4
|
+
type: T;
|
|
5
|
+
};
|
|
2
6
|
export declare function zFunction<T extends z.core.$ZodFunction>(schema: T): z.ZodCustom<Parameters<T["implement"]>[0], Parameters<T["implement"]>[0]>;
|
|
3
7
|
export declare function zAsyncFunction<T extends z.core.$ZodFunction>(schema: T): z.ZodCustom<Parameters<T["implementAsync"]>[0], Parameters<T["implementAsync"]>[0]>;
|
|
4
|
-
export declare const authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
5
|
-
export declare const PasskeyRegistration: z.ZodObject<{
|
|
6
|
-
id: z.ZodString;
|
|
7
|
-
rawId: z.ZodString;
|
|
8
|
-
response: z.ZodObject<{
|
|
9
|
-
clientDataJSON: z.ZodString;
|
|
10
|
-
attestationObject: z.ZodString;
|
|
11
|
-
authenticatorData: z.ZodOptional<z.ZodString>;
|
|
12
|
-
transports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
13
|
-
ble: "ble";
|
|
14
|
-
hybrid: "hybrid";
|
|
15
|
-
internal: "internal";
|
|
16
|
-
nfc: "nfc";
|
|
17
|
-
usb: "usb";
|
|
18
|
-
cable: "cable";
|
|
19
|
-
"smart-card": "smart-card";
|
|
20
|
-
}>>>;
|
|
21
|
-
publicKeyAlgorithm: z.ZodOptional<z.ZodNumber>;
|
|
22
|
-
publicKey: z.ZodOptional<z.ZodString>;
|
|
23
|
-
}, z.core.$strip>;
|
|
24
|
-
authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
25
|
-
clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
26
|
-
type: z.ZodLiteral<"public-key">;
|
|
27
|
-
}, z.core.$strip>;
|
|
28
|
-
/**
|
|
29
|
-
* POSTed to the `/users/:id/login` endpoint.
|
|
30
|
-
*/
|
|
31
|
-
export declare const PasskeyAuthenticationResponse: z.ZodObject<{
|
|
32
|
-
id: z.ZodString;
|
|
33
|
-
rawId: z.ZodString;
|
|
34
|
-
response: z.ZodObject<{
|
|
35
|
-
clientDataJSON: z.ZodString;
|
|
36
|
-
authenticatorData: z.ZodString;
|
|
37
|
-
signature: z.ZodString;
|
|
38
|
-
userHandle: z.ZodOptional<z.ZodString>;
|
|
39
|
-
}, z.core.$strip>;
|
|
40
|
-
authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
41
|
-
clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
42
|
-
type: z.ZodLiteral<"public-key">;
|
|
43
|
-
}, z.core.$strip>;
|
|
44
|
-
export declare const APIUserRegistration: z.ZodObject<{
|
|
45
|
-
name: z.ZodString;
|
|
46
|
-
email: z.ZodEmail;
|
|
47
|
-
userId: z.ZodUUID;
|
|
48
|
-
response: z.ZodObject<{
|
|
49
|
-
id: z.ZodString;
|
|
50
|
-
rawId: z.ZodString;
|
|
51
|
-
response: z.ZodObject<{
|
|
52
|
-
clientDataJSON: z.ZodString;
|
|
53
|
-
attestationObject: z.ZodString;
|
|
54
|
-
authenticatorData: z.ZodOptional<z.ZodString>;
|
|
55
|
-
transports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
56
|
-
ble: "ble";
|
|
57
|
-
hybrid: "hybrid";
|
|
58
|
-
internal: "internal";
|
|
59
|
-
nfc: "nfc";
|
|
60
|
-
usb: "usb";
|
|
61
|
-
cable: "cable";
|
|
62
|
-
"smart-card": "smart-card";
|
|
63
|
-
}>>>;
|
|
64
|
-
publicKeyAlgorithm: z.ZodOptional<z.ZodNumber>;
|
|
65
|
-
publicKey: z.ZodOptional<z.ZodString>;
|
|
66
|
-
}, z.core.$strip>;
|
|
67
|
-
authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
68
|
-
clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
69
|
-
type: z.ZodLiteral<"public-key">;
|
|
70
|
-
}, z.core.$strip>;
|
|
71
|
-
}, z.core.$strip>;
|
|
72
|
-
export declare const PasskeyChangeable: z.ZodObject<{
|
|
73
|
-
name: z.ZodOptional<z.ZodString>;
|
|
74
|
-
}, z.core.$strip>;
|
|
75
|
-
export declare const UserAuthOptions: z.ZodObject<{
|
|
76
|
-
type: z.ZodLiteral<"login" | "action">;
|
|
77
|
-
}, z.core.$strip>;
|
|
78
|
-
export type UserAuthOptions = z.infer<typeof UserAuthOptions>;
|
|
79
|
-
export declare const LogoutSessions: z.ZodObject<{
|
|
80
|
-
id: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
81
|
-
confirm_all: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
-
}, z.core.$strip>;
|
package/dist/schemas.js
CHANGED
|
@@ -1,52 +1,11 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
/** Needed for discriminated union type narrowing */
|
|
3
|
+
export function zIs(schema, type) {
|
|
4
|
+
return schema.def.type == type;
|
|
5
|
+
}
|
|
2
6
|
export function zFunction(schema) {
|
|
3
7
|
return z.custom((fn) => schema.implement(fn));
|
|
4
8
|
}
|
|
5
9
|
export function zAsyncFunction(schema) {
|
|
6
10
|
return z.custom((fn) => schema.implementAsync(fn));
|
|
7
11
|
}
|
|
8
|
-
const transports = ['ble', 'cable', 'hybrid', 'internal', 'nfc', 'smart-card', 'usb'];
|
|
9
|
-
export const authenticatorAttachment = z.literal(['platform', 'cross-platform']).optional();
|
|
10
|
-
export const PasskeyRegistration = z.object({
|
|
11
|
-
id: z.string(),
|
|
12
|
-
rawId: z.string(),
|
|
13
|
-
response: z.object({
|
|
14
|
-
clientDataJSON: z.string(),
|
|
15
|
-
attestationObject: z.string(),
|
|
16
|
-
authenticatorData: z.string().optional(),
|
|
17
|
-
transports: z.array(z.enum(transports)).optional(),
|
|
18
|
-
publicKeyAlgorithm: z.number().optional(),
|
|
19
|
-
publicKey: z.string().optional(),
|
|
20
|
-
}),
|
|
21
|
-
authenticatorAttachment,
|
|
22
|
-
clientExtensionResults: z.record(z.any(), z.any()),
|
|
23
|
-
type: z.literal('public-key'),
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* POSTed to the `/users/:id/login` endpoint.
|
|
27
|
-
*/
|
|
28
|
-
export const PasskeyAuthenticationResponse = z.object({
|
|
29
|
-
id: z.string(),
|
|
30
|
-
rawId: z.string(),
|
|
31
|
-
response: z.object({
|
|
32
|
-
clientDataJSON: z.string(),
|
|
33
|
-
authenticatorData: z.string(),
|
|
34
|
-
signature: z.string(),
|
|
35
|
-
userHandle: z.string().optional(),
|
|
36
|
-
}),
|
|
37
|
-
authenticatorAttachment,
|
|
38
|
-
clientExtensionResults: z.record(z.any(), z.any()),
|
|
39
|
-
type: z.literal('public-key'),
|
|
40
|
-
});
|
|
41
|
-
export const APIUserRegistration = z.object({
|
|
42
|
-
name: z.string().min(1).max(100),
|
|
43
|
-
email: z.email(),
|
|
44
|
-
userId: z.uuid(),
|
|
45
|
-
response: PasskeyRegistration,
|
|
46
|
-
});
|
|
47
|
-
export const PasskeyChangeable = z.object({ name: z.string() }).partial();
|
|
48
|
-
export const UserAuthOptions = z.object({ type: z.literal(['login', 'action']) });
|
|
49
|
-
export const LogoutSessions = z.object({
|
|
50
|
-
id: z.array(z.uuid()).optional(),
|
|
51
|
-
confirm_all: z.boolean().optional(),
|
|
52
|
-
});
|
package/dist/user.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
-
|
|
3
|
-
* User preferences.
|
|
4
|
-
* Modify with `declare module ...`
|
|
5
|
-
*/
|
|
6
|
-
export interface Preferences {
|
|
7
|
-
}
|
|
2
|
+
import type { Preferences } from './preferences.js';
|
|
8
3
|
export declare const User: z.ZodObject<{
|
|
9
4
|
id: z.ZodUUID;
|
|
10
5
|
name: z.ZodString;
|
|
@@ -29,6 +24,44 @@ export declare const UserChangeable: z.ZodObject<{
|
|
|
29
24
|
image: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodURL>>>;
|
|
30
25
|
preferences: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
31
26
|
}, z.core.$strip>;
|
|
32
|
-
export
|
|
27
|
+
export interface UserChangeable extends z.infer<typeof UserChangeable> {
|
|
28
|
+
preferences?: Preferences;
|
|
29
|
+
}
|
|
33
30
|
export declare function getUserImage(user: Partial<User>): string;
|
|
31
|
+
export declare const UserRegistration: z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
email: z.ZodEmail;
|
|
34
|
+
userId: z.ZodUUID;
|
|
35
|
+
response: z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
rawId: z.ZodString;
|
|
38
|
+
response: z.ZodObject<{
|
|
39
|
+
clientDataJSON: z.ZodString;
|
|
40
|
+
attestationObject: z.ZodString;
|
|
41
|
+
authenticatorData: z.ZodOptional<z.ZodString>;
|
|
42
|
+
transports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
43
|
+
ble: "ble";
|
|
44
|
+
hybrid: "hybrid";
|
|
45
|
+
internal: "internal";
|
|
46
|
+
nfc: "nfc";
|
|
47
|
+
usb: "usb";
|
|
48
|
+
cable: "cable";
|
|
49
|
+
"smart-card": "smart-card";
|
|
50
|
+
}>>>;
|
|
51
|
+
publicKeyAlgorithm: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
publicKey: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
|
|
55
|
+
clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
56
|
+
type: z.ZodLiteral<"public-key">;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export declare const UserAuthOptions: z.ZodObject<{
|
|
60
|
+
type: z.ZodLiteral<"login" | "action">;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type UserAuthOptions = z.infer<typeof UserAuthOptions>;
|
|
63
|
+
export declare const LogoutSessions: z.ZodObject<{
|
|
64
|
+
id: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
65
|
+
confirm_all: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
}, z.core.$strip>;
|
|
34
67
|
export {};
|
package/dist/user.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
import { PasskeyRegistration } from './passkeys.js';
|
|
2
3
|
export const User = z.object({
|
|
3
4
|
id: z.uuid(),
|
|
4
5
|
name: z.string().min(1, 'Name is required').max(255, 'Name is too long'),
|
|
@@ -33,3 +34,14 @@ export function getUserImage(user) {
|
|
|
33
34
|
<text x="23" y="28" style="font-family:sans-serif;font-weight:bold;" fill="white">${user.name.replaceAll(/\W/g, '')[0]}</text>
|
|
34
35
|
</svg>`.replaceAll(/[\t\n]/g, '');
|
|
35
36
|
}
|
|
37
|
+
export const UserRegistration = z.object({
|
|
38
|
+
name: z.string().min(1).max(100),
|
|
39
|
+
email: z.email(),
|
|
40
|
+
userId: z.uuid(),
|
|
41
|
+
response: PasskeyRegistration,
|
|
42
|
+
});
|
|
43
|
+
export const UserAuthOptions = z.object({ type: z.literal(['login', 'action']) });
|
|
44
|
+
export const LogoutSessions = z.object({
|
|
45
|
+
id: z.array(z.uuid()).optional(),
|
|
46
|
+
confirm_all: z.boolean().optional(),
|
|
47
|
+
});
|