@axium/core 0.6.0 → 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 CHANGED
@@ -1,40 +1,11 @@
1
- import type { AuthenticatorTransportFuture, CredentialDeviceType, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types';
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
- export interface Session {
8
- id: string;
9
- userId: string;
10
- expires: Date;
11
- created: Date;
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
@@ -51,7 +22,7 @@ export interface $API {
51
22
  };
52
23
  };
53
24
  apps: {
54
- GET: AppMetadata[];
25
+ GET: App[];
55
26
  };
56
27
  session: {
57
28
  GET: Session & {
@@ -64,7 +35,7 @@ export interface $API {
64
35
  userId: string;
65
36
  options: PublicKeyCredentialCreationOptionsJSON;
66
37
  };
67
- POST: [z.input<typeof APIUserRegistration>, NewSessionResponse];
38
+ POST: [z.input<typeof UserRegistration>, NewSessionResponse];
68
39
  };
69
40
  'users/:id': {
70
41
  GET: UserPublic & Partial<User>;
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
@@ -0,0 +1,7 @@
1
+ import * as z from 'zod';
2
+ export const App = z.object({
3
+ id: z.string(),
4
+ name: z.string().optional(),
5
+ image: z.string().optional(),
6
+ icon: z.string().optional(),
7
+ });
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,9 @@
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';
4
7
  export * from './preferences.js';
5
8
  export * from './requests.js';
6
9
  export * from './schemas.js';
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
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';
4
7
  export * from './preferences.js';
5
8
  export * from './requests.js';
6
9
  export * from './schemas.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
+ }
@@ -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();
package/dist/schemas.d.ts CHANGED
@@ -5,82 +5,3 @@ export declare function zIs<const T extends z.core.$ZodTypeDef['type']>(schema:
5
5
  };
6
6
  export declare function zFunction<T extends z.core.$ZodFunction>(schema: T): z.ZodCustom<Parameters<T["implement"]>[0], Parameters<T["implement"]>[0]>;
7
7
  export declare function zAsyncFunction<T extends z.core.$ZodFunction>(schema: T): z.ZodCustom<Parameters<T["implementAsync"]>[0], Parameters<T["implementAsync"]>[0]>;
8
- export declare const authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
9
- export declare const PasskeyRegistration: z.ZodObject<{
10
- id: z.ZodString;
11
- rawId: z.ZodString;
12
- response: z.ZodObject<{
13
- clientDataJSON: z.ZodString;
14
- attestationObject: z.ZodString;
15
- authenticatorData: z.ZodOptional<z.ZodString>;
16
- transports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
17
- ble: "ble";
18
- hybrid: "hybrid";
19
- internal: "internal";
20
- nfc: "nfc";
21
- usb: "usb";
22
- cable: "cable";
23
- "smart-card": "smart-card";
24
- }>>>;
25
- publicKeyAlgorithm: z.ZodOptional<z.ZodNumber>;
26
- publicKey: z.ZodOptional<z.ZodString>;
27
- }, z.core.$strip>;
28
- authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
29
- clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
30
- type: z.ZodLiteral<"public-key">;
31
- }, z.core.$strip>;
32
- /**
33
- * POSTed to the `/users/:id/login` endpoint.
34
- */
35
- export declare const PasskeyAuthenticationResponse: z.ZodObject<{
36
- id: z.ZodString;
37
- rawId: z.ZodString;
38
- response: z.ZodObject<{
39
- clientDataJSON: z.ZodString;
40
- authenticatorData: z.ZodString;
41
- signature: z.ZodString;
42
- userHandle: z.ZodOptional<z.ZodString>;
43
- }, z.core.$strip>;
44
- authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
45
- clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
46
- type: z.ZodLiteral<"public-key">;
47
- }, z.core.$strip>;
48
- export declare const APIUserRegistration: z.ZodObject<{
49
- name: z.ZodString;
50
- email: z.ZodEmail;
51
- userId: z.ZodUUID;
52
- response: z.ZodObject<{
53
- id: z.ZodString;
54
- rawId: z.ZodString;
55
- response: z.ZodObject<{
56
- clientDataJSON: z.ZodString;
57
- attestationObject: z.ZodString;
58
- authenticatorData: z.ZodOptional<z.ZodString>;
59
- transports: z.ZodOptional<z.ZodArray<z.ZodEnum<{
60
- ble: "ble";
61
- hybrid: "hybrid";
62
- internal: "internal";
63
- nfc: "nfc";
64
- usb: "usb";
65
- cable: "cable";
66
- "smart-card": "smart-card";
67
- }>>>;
68
- publicKeyAlgorithm: z.ZodOptional<z.ZodNumber>;
69
- publicKey: z.ZodOptional<z.ZodString>;
70
- }, z.core.$strip>;
71
- authenticatorAttachment: z.ZodOptional<z.ZodLiteral<"cross-platform" | "platform">>;
72
- clientExtensionResults: z.ZodRecord<z.ZodAny, z.ZodAny>;
73
- type: z.ZodLiteral<"public-key">;
74
- }, z.core.$strip>;
75
- }, z.core.$strip>;
76
- export declare const PasskeyChangeable: z.ZodObject<{
77
- name: z.ZodOptional<z.ZodString>;
78
- }, z.core.$strip>;
79
- export declare const UserAuthOptions: z.ZodObject<{
80
- type: z.ZodLiteral<"login" | "action">;
81
- }, z.core.$strip>;
82
- export type UserAuthOptions = z.infer<typeof UserAuthOptions>;
83
- export declare const LogoutSessions: z.ZodObject<{
84
- id: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
85
- confirm_all: z.ZodOptional<z.ZodBoolean>;
86
- }, z.core.$strip>;
package/dist/schemas.js CHANGED
@@ -9,48 +9,3 @@ export function zFunction(schema) {
9
9
  export function zAsyncFunction(schema) {
10
10
  return z.custom((fn) => schema.implementAsync(fn));
11
11
  }
12
- const transports = ['ble', 'cable', 'hybrid', 'internal', 'nfc', 'smart-card', 'usb'];
13
- export const authenticatorAttachment = z.literal(['platform', 'cross-platform']).optional();
14
- export const PasskeyRegistration = z.object({
15
- id: z.string(),
16
- rawId: z.string(),
17
- response: z.object({
18
- clientDataJSON: z.string(),
19
- attestationObject: z.string(),
20
- authenticatorData: z.string().optional(),
21
- transports: z.array(z.enum(transports)).optional(),
22
- publicKeyAlgorithm: z.number().optional(),
23
- publicKey: z.string().optional(),
24
- }),
25
- authenticatorAttachment,
26
- clientExtensionResults: z.record(z.any(), z.any()),
27
- type: z.literal('public-key'),
28
- });
29
- /**
30
- * POSTed to the `/users/:id/login` endpoint.
31
- */
32
- export const PasskeyAuthenticationResponse = z.object({
33
- id: z.string(),
34
- rawId: z.string(),
35
- response: z.object({
36
- clientDataJSON: z.string(),
37
- authenticatorData: z.string(),
38
- signature: z.string(),
39
- userHandle: z.string().optional(),
40
- }),
41
- authenticatorAttachment,
42
- clientExtensionResults: z.record(z.any(), z.any()),
43
- type: z.literal('public-key'),
44
- });
45
- export const APIUserRegistration = z.object({
46
- name: z.string().min(1).max(100),
47
- email: z.email(),
48
- userId: z.uuid(),
49
- response: PasskeyRegistration,
50
- });
51
- export const PasskeyChangeable = z.object({ name: z.string() }).partial();
52
- export const UserAuthOptions = z.object({ type: z.literal(['login', 'action']) });
53
- export const LogoutSessions = z.object({
54
- id: z.array(z.uuid()).optional(),
55
- confirm_all: z.boolean().optional(),
56
- });
package/dist/user.d.ts CHANGED
@@ -28,4 +28,40 @@ export interface UserChangeable extends z.infer<typeof UserChangeable> {
28
28
  preferences?: Preferences;
29
29
  }
30
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>;
31
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
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axium/core",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "author": "James Prevett <axium@jamespre.dev> (https://jamespre.dev)",
5
5
  "funding": {
6
6
  "type": "individual",