@seamless-auth/types 0.1.1 → 0.1.3
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/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -0
- package/dist/schemas/auth/auth.schema.d.ts +1 -0
- package/dist/schemas/auth/auth.schema.d.ts.map +1 -0
- package/dist/schemas/auth/auth.schema.js +1 -0
- package/dist/schemas/auth/auth.schema.js.map +1 -0
- package/dist/schemas/authEvent/schema.d.ts +1 -0
- package/dist/schemas/authEvent/schema.d.ts.map +1 -0
- package/dist/schemas/authEvent/schema.js +2 -1
- package/dist/schemas/authEvent/schema.js.map +1 -0
- package/dist/schemas/credential/schema.d.ts +1 -0
- package/dist/schemas/credential/schema.d.ts.map +1 -0
- package/dist/schemas/credential/schema.js +2 -1
- package/dist/schemas/credential/schema.js.map +1 -0
- package/dist/schemas/session/schema.d.ts +1 -0
- package/dist/schemas/session/schema.d.ts.map +1 -0
- package/dist/schemas/session/schema.js +1 -0
- package/dist/schemas/session/schema.js.map +1 -0
- package/dist/schemas/user/schema.d.ts +1 -0
- package/dist/schemas/user/schema.d.ts.map +1 -0
- package/dist/schemas/user/schema.js +2 -1
- package/dist/schemas/user/schema.js.map +1 -0
- package/dist/shared.d.ts +1 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +1 -0
- package/dist/shared.js.map +1 -0
- package/package.json +4 -2
- package/dist/schemas/authEvent/schema.test.d.ts +0 -1
- package/dist/schemas/authEvent/schema.test.js +0 -71
- package/dist/schemas/credential/schema.test.d.ts +0 -1
- package/dist/schemas/credential/schema.test.js +0 -74
- package/dist/schemas/session/schema.test.d.ts +0 -1
- package/dist/schemas/session/schema.test.js +0 -61
- package/dist/schemas/user/schema.test.d.ts +0 -1
- package/dist/schemas/user/schema.test.js +0 -115
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './schemas/user/schema';
|
|
2
|
-
export * from './schemas/credential/schema';
|
|
3
|
-
export * from './schemas/auth/auth.schema';
|
|
4
|
-
export * from './schemas/authEvent/schema';
|
|
5
|
-
export * from './schemas/session/schema';
|
|
1
|
+
export * from './schemas/user/schema.js';
|
|
2
|
+
export * from './schemas/credential/schema.js';
|
|
3
|
+
export * from './schemas/auth/auth.schema.js';
|
|
4
|
+
export * from './schemas/authEvent/schema.js';
|
|
5
|
+
export * from './schemas/session/schema.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './schemas/user/schema';
|
|
2
|
-
export * from './schemas/credential/schema';
|
|
3
|
-
export * from './schemas/auth/auth.schema';
|
|
4
|
-
export * from './schemas/authEvent/schema';
|
|
5
|
-
export * from './schemas/session/schema';
|
|
1
|
+
export * from './schemas/user/schema.js';
|
|
2
|
+
export * from './schemas/credential/schema.js';
|
|
3
|
+
export * from './schemas/auth/auth.schema.js';
|
|
4
|
+
export * from './schemas/authEvent/schema.js';
|
|
5
|
+
export * from './schemas/session/schema.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/auth/auth.schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,kBAAkB;;iBAE7B,CAAC;AAEH,eAAO,MAAM,yBAAyB,gCAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.schema.js","sourceRoot":"","sources":["../../../src/schemas/auth/auth.schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/authEvent/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,eAAO,MAAM,eAAe;;;;;;;;;iBAS1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
import { IsoDate } from '../../shared';
|
|
2
|
+
import { IsoDate } from '../../shared.js';
|
|
3
3
|
export const AuthEventSchema = z.object({
|
|
4
4
|
id: z.string(),
|
|
5
5
|
user_id: z.string().nullable().optional(),
|
|
@@ -10,3 +10,4 @@ export const AuthEventSchema = z.object({
|
|
|
10
10
|
created_at: IsoDate,
|
|
11
11
|
updated_at: IsoDate,
|
|
12
12
|
});
|
|
13
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/authEvent/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC5C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACtD,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,OAAO;CACpB,CAAC,CAAC"}
|
|
@@ -55,3 +55,4 @@ export declare const CredentialApiSchema: z.ZodObject<{
|
|
|
55
55
|
lastUsedAt: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodCoercedDate<unknown>, z.ZodTransform<string, Date>>>>;
|
|
56
56
|
deviceInfo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
57
|
}, z.core.$strip>;
|
|
58
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/credential/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAOpB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;iBAsB3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,6BAA6B;;;;iBAIxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,6BAA6B;;iBAExC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;iBAY9B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
|
-
import { IsoDate } from '../../shared';
|
|
2
|
+
import { IsoDate } from '../../shared.js';
|
|
3
3
|
const TransportSchema = z.enum(['usb', 'ble', 'nfc', 'internal']);
|
|
4
4
|
const DeviceTypeSchema = z.enum(['singleDevice', 'multiDevice']);
|
|
5
5
|
export const CredentialSchema = z.object({
|
|
@@ -39,3 +39,4 @@ export const CredentialApiSchema = CredentialSchema.pick({
|
|
|
39
39
|
deviceInfo: true,
|
|
40
40
|
createdAt: true,
|
|
41
41
|
});
|
|
42
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/credential/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;AAElE,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,gBAAg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AM,CAAC;IACpD,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;CACf,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,IAAI,CAAC;IACvD,EAAE,EAAE,IAAI;IACR,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/session/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;;;;;;;;iBAQxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/session/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC5C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC3C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAC3C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/user/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,UAAU,aAAyD,CAAC;AAEjF,eAAO,MAAM,UAAU;;;;;;;;;;;;iBAYrB,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;kBAQlB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { IsoDate } from '../../shared';
|
|
2
|
+
import { IsoDate } from '../../shared.js';
|
|
3
3
|
export const RoleSchema = z.string().regex(/^(?!.*[_/\\\s])[A-Za-z0-9-]{1,31}$/);
|
|
4
4
|
export const UserSchema = z.object({
|
|
5
5
|
id: z.uuid(),
|
|
@@ -28,3 +28,4 @@ export const UpdateUserSchema = z
|
|
|
28
28
|
roles: z.array(RoleSchema).min(1).optional(),
|
|
29
29
|
})
|
|
30
30
|
.strict();
|
|
31
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/schemas/user/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;AAEjF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,C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AAE;IACrC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAAC;KACD,MAAM,EAAE,CAAC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,OAAO,oEAAoD,CAAC"}
|
package/dist/shared.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamless-auth/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Shared TypeScript types and Zod schemas for SeamlessAuth.",
|
|
5
5
|
"author": "Fells Code, LLC",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
".": "./dist/index.js"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
15
17
|
],
|
|
16
18
|
"repository": {
|
|
17
19
|
"type": "git",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { AuthEventSchema } from './schema';
|
|
3
|
-
const now = new Date().toISOString();
|
|
4
|
-
describe('AuthEventSchema', () => {
|
|
5
|
-
const baseEvent = {
|
|
6
|
-
id: 'event_123',
|
|
7
|
-
user_id: 'user_123',
|
|
8
|
-
type: 'login',
|
|
9
|
-
ip_address: '127.0.0.1',
|
|
10
|
-
user_agent: 'Mozilla/5.0',
|
|
11
|
-
metadata: {
|
|
12
|
-
device: 'desktop',
|
|
13
|
-
success: true,
|
|
14
|
-
},
|
|
15
|
-
created_at: now,
|
|
16
|
-
updated_at: now,
|
|
17
|
-
};
|
|
18
|
-
it('parses a valid auth event', () => {
|
|
19
|
-
expect(() => AuthEventSchema.parse(baseEvent)).not.toThrow();
|
|
20
|
-
});
|
|
21
|
-
it('allows nullable optional fields', () => {
|
|
22
|
-
const minimal = {
|
|
23
|
-
id: 'event_123',
|
|
24
|
-
type: 'login',
|
|
25
|
-
metadata: null,
|
|
26
|
-
created_at: now,
|
|
27
|
-
updated_at: now,
|
|
28
|
-
};
|
|
29
|
-
expect(() => AuthEventSchema.parse(minimal)).not.toThrow();
|
|
30
|
-
});
|
|
31
|
-
it('allows missing optional fields', () => {
|
|
32
|
-
const { ...rest } = baseEvent;
|
|
33
|
-
expect(() => AuthEventSchema.parse(rest)).not.toThrow();
|
|
34
|
-
});
|
|
35
|
-
it('fails if required fields are missing', () => {
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
const { id, ...rest } = baseEvent;
|
|
38
|
-
expect(() => AuthEventSchema.parse(rest)).toThrow();
|
|
39
|
-
});
|
|
40
|
-
it('fails if metadata is not an object or null', () => {
|
|
41
|
-
expect(() => AuthEventSchema.parse({
|
|
42
|
-
...baseEvent,
|
|
43
|
-
metadata: 'invalid',
|
|
44
|
-
})).toThrow();
|
|
45
|
-
});
|
|
46
|
-
it('allows metadata with arbitrary values', () => {
|
|
47
|
-
expect(() => AuthEventSchema.parse({
|
|
48
|
-
...baseEvent,
|
|
49
|
-
metadata: {
|
|
50
|
-
string: 'value',
|
|
51
|
-
number: 123,
|
|
52
|
-
boolean: true,
|
|
53
|
-
nested: { key: 'value' },
|
|
54
|
-
array: [1, 2, 3],
|
|
55
|
-
},
|
|
56
|
-
})).not.toThrow();
|
|
57
|
-
});
|
|
58
|
-
it('fails on invalid ISO date', () => {
|
|
59
|
-
expect(() => AuthEventSchema.parse({
|
|
60
|
-
...baseEvent,
|
|
61
|
-
created_at: 'not-a-date',
|
|
62
|
-
})).toThrow();
|
|
63
|
-
});
|
|
64
|
-
it('fails when metadata is undefined (not nullable)', () => {
|
|
65
|
-
const { ...rest } = baseEvent;
|
|
66
|
-
expect(() => AuthEventSchema.parse({
|
|
67
|
-
...rest,
|
|
68
|
-
metadata: undefined,
|
|
69
|
-
})).toThrow();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { CredentialSchema } from './schema';
|
|
3
|
-
const now = new Date().toISOString();
|
|
4
|
-
describe('CredentialSchema', () => {
|
|
5
|
-
const baseCredential = {
|
|
6
|
-
id: 'credential_id_base64url',
|
|
7
|
-
userId: crypto.randomUUID(),
|
|
8
|
-
publicKey: 'public_key_base64url',
|
|
9
|
-
counter: 0,
|
|
10
|
-
transports: ['internal'],
|
|
11
|
-
deviceType: 'singleDevice',
|
|
12
|
-
backedUp: false,
|
|
13
|
-
friendlyName: 'My Device',
|
|
14
|
-
lastUsedAt: now,
|
|
15
|
-
platform: 'ios',
|
|
16
|
-
browser: 'safari',
|
|
17
|
-
deviceInfo: 'iPhone',
|
|
18
|
-
createdAt: now,
|
|
19
|
-
updatedAt: now,
|
|
20
|
-
};
|
|
21
|
-
it('parses a valid credential', () => {
|
|
22
|
-
expect(() => CredentialSchema.parse(baseCredential)).not.toThrow();
|
|
23
|
-
});
|
|
24
|
-
it('fails when required fields are missing', () => {
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
-
const { id, ...rest } = baseCredential;
|
|
27
|
-
expect(() => CredentialSchema.parse(rest)).toThrow();
|
|
28
|
-
});
|
|
29
|
-
it('fails when publicKey is not a string', () => {
|
|
30
|
-
expect(() => CredentialSchema.parse({
|
|
31
|
-
...baseCredential,
|
|
32
|
-
publicKey: 123,
|
|
33
|
-
})).toThrow();
|
|
34
|
-
});
|
|
35
|
-
it('allows optional metadata fields to be omitted', () => {
|
|
36
|
-
const { ...minimal } = baseCredential;
|
|
37
|
-
expect(() => CredentialSchema.parse(minimal)).not.toThrow();
|
|
38
|
-
});
|
|
39
|
-
it('allows nullable optional fields', () => {
|
|
40
|
-
expect(() => CredentialSchema.parse({
|
|
41
|
-
...baseCredential,
|
|
42
|
-
friendlyName: null,
|
|
43
|
-
platform: null,
|
|
44
|
-
browser: null,
|
|
45
|
-
deviceInfo: null,
|
|
46
|
-
})).not.toThrow();
|
|
47
|
-
});
|
|
48
|
-
it('allows missing transports', () => {
|
|
49
|
-
const { ...rest } = baseCredential;
|
|
50
|
-
expect(() => CredentialSchema.parse(rest)).not.toThrow();
|
|
51
|
-
});
|
|
52
|
-
it('fails on invalid transport value', () => {
|
|
53
|
-
expect(() => CredentialSchema.parse({
|
|
54
|
-
...baseCredential,
|
|
55
|
-
transports: ['invalid'],
|
|
56
|
-
})).toThrow();
|
|
57
|
-
});
|
|
58
|
-
it('fails on invalid deviceType', () => {
|
|
59
|
-
expect(() => CredentialSchema.parse({
|
|
60
|
-
...baseCredential,
|
|
61
|
-
deviceType: 'invalidType',
|
|
62
|
-
})).toThrow();
|
|
63
|
-
});
|
|
64
|
-
it('fails on invalid ISO date', () => {
|
|
65
|
-
expect(() => CredentialSchema.parse({
|
|
66
|
-
...baseCredential,
|
|
67
|
-
createdAt: 'not-a-date',
|
|
68
|
-
})).toThrow();
|
|
69
|
-
});
|
|
70
|
-
it('allows lastUsedAt to be omitted', () => {
|
|
71
|
-
const { ...rest } = baseCredential;
|
|
72
|
-
expect(() => CredentialSchema.parse(rest)).not.toThrow();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { SessionSchema } from './schema';
|
|
3
|
-
const now = new Date().toISOString();
|
|
4
|
-
const later = new Date(Date.now() + 1000 * 60 * 60).toISOString();
|
|
5
|
-
describe('SessionSchema', () => {
|
|
6
|
-
const baseSession = {
|
|
7
|
-
id: 'session_123',
|
|
8
|
-
deviceName: 'MacBook Pro',
|
|
9
|
-
ipAddress: '127.0.0.1',
|
|
10
|
-
userAgent: 'Mozilla/5.0',
|
|
11
|
-
lastUsedAt: now,
|
|
12
|
-
expiresAt: later,
|
|
13
|
-
current: true,
|
|
14
|
-
};
|
|
15
|
-
it('parses a valid session', () => {
|
|
16
|
-
expect(() => SessionSchema.parse(baseSession)).not.toThrow();
|
|
17
|
-
});
|
|
18
|
-
it('allows optional nullable fields to be omitted', () => {
|
|
19
|
-
const { ...minimal } = baseSession;
|
|
20
|
-
expect(() => SessionSchema.parse(minimal)).not.toThrow();
|
|
21
|
-
});
|
|
22
|
-
it('allows optional nullable fields to be null', () => {
|
|
23
|
-
expect(() => SessionSchema.parse({
|
|
24
|
-
...baseSession,
|
|
25
|
-
deviceName: null,
|
|
26
|
-
ipAddress: null,
|
|
27
|
-
userAgent: null,
|
|
28
|
-
})).not.toThrow();
|
|
29
|
-
});
|
|
30
|
-
it('fails when required fields are missing', () => {
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
-
const { id, ...rest } = baseSession;
|
|
33
|
-
expect(() => SessionSchema.parse(rest)).toThrow();
|
|
34
|
-
});
|
|
35
|
-
it('fails when current is not a boolean', () => {
|
|
36
|
-
expect(() => SessionSchema.parse({
|
|
37
|
-
...baseSession,
|
|
38
|
-
current: 'true',
|
|
39
|
-
})).toThrow();
|
|
40
|
-
});
|
|
41
|
-
it('fails when lastUsedAt is not a string', () => {
|
|
42
|
-
expect(() => SessionSchema.parse({
|
|
43
|
-
...baseSession,
|
|
44
|
-
lastUsedAt: 123,
|
|
45
|
-
})).toThrow();
|
|
46
|
-
});
|
|
47
|
-
it('fails when expiresAt is not a string', () => {
|
|
48
|
-
expect(() => SessionSchema.parse({
|
|
49
|
-
...baseSession,
|
|
50
|
-
expiresAt: 123,
|
|
51
|
-
})).toThrow();
|
|
52
|
-
});
|
|
53
|
-
it('allows different valid session shapes', () => {
|
|
54
|
-
expect(() => SessionSchema.parse({
|
|
55
|
-
id: 'session_456',
|
|
56
|
-
lastUsedAt: now,
|
|
57
|
-
expiresAt: later,
|
|
58
|
-
current: false,
|
|
59
|
-
})).not.toThrow();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { UserSchema, CreateUserSchema, UpdateUserSchema } from './schema';
|
|
3
|
-
const now = new Date().toISOString();
|
|
4
|
-
describe('UserSchema', () => {
|
|
5
|
-
const baseUser = {
|
|
6
|
-
id: crypto.randomUUID(),
|
|
7
|
-
email: 'test@example.com',
|
|
8
|
-
phone: '1234567890',
|
|
9
|
-
roles: ['user'],
|
|
10
|
-
revoked: false,
|
|
11
|
-
emailVerified: true,
|
|
12
|
-
phoneVerified: false,
|
|
13
|
-
verified: true,
|
|
14
|
-
lastLogin: now,
|
|
15
|
-
createdAt: now,
|
|
16
|
-
updatedAt: now,
|
|
17
|
-
};
|
|
18
|
-
it('parses a valid user', () => {
|
|
19
|
-
expect(() => UserSchema.parse(baseUser)).not.toThrow();
|
|
20
|
-
});
|
|
21
|
-
it('applies defaults when optional fields are missing', () => {
|
|
22
|
-
const minimal = {
|
|
23
|
-
id: crypto.randomUUID(),
|
|
24
|
-
email: 'test@example.com',
|
|
25
|
-
phone: '1234567890',
|
|
26
|
-
createdAt: now,
|
|
27
|
-
};
|
|
28
|
-
const parsed = UserSchema.parse(minimal);
|
|
29
|
-
expect(parsed.roles).toEqual([]);
|
|
30
|
-
expect(parsed.revoked).toBe(false);
|
|
31
|
-
expect(parsed.emailVerified).toBe(false);
|
|
32
|
-
expect(parsed.phoneVerified).toBe(false);
|
|
33
|
-
expect(parsed.verified).toBe(false);
|
|
34
|
-
});
|
|
35
|
-
it('fails on invalid email', () => {
|
|
36
|
-
expect(() => UserSchema.parse({
|
|
37
|
-
...baseUser,
|
|
38
|
-
email: 'invalid-email',
|
|
39
|
-
})).toThrow();
|
|
40
|
-
});
|
|
41
|
-
it('fails on invalid role format', () => {
|
|
42
|
-
expect(() => UserSchema.parse({
|
|
43
|
-
...baseUser,
|
|
44
|
-
roles: ['bad role'], // contains space
|
|
45
|
-
})).toThrow();
|
|
46
|
-
});
|
|
47
|
-
it('allows nullable lastLogin', () => {
|
|
48
|
-
expect(() => UserSchema.parse({
|
|
49
|
-
...baseUser,
|
|
50
|
-
lastLogin: null,
|
|
51
|
-
})).not.toThrow();
|
|
52
|
-
});
|
|
53
|
-
it('allows missing optional fields', () => {
|
|
54
|
-
const { ...rest } = baseUser;
|
|
55
|
-
expect(() => UserSchema.parse(rest)).not.toThrow();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
describe('CreateUserSchema', () => {
|
|
59
|
-
it('parses valid input', () => {
|
|
60
|
-
expect(() => CreateUserSchema.parse({
|
|
61
|
-
email: 'test@example.com',
|
|
62
|
-
phone: '1234567890',
|
|
63
|
-
roles: ['admin'],
|
|
64
|
-
})).not.toThrow();
|
|
65
|
-
});
|
|
66
|
-
it('fails if roles are empty', () => {
|
|
67
|
-
expect(() => CreateUserSchema.parse({
|
|
68
|
-
email: 'test@example.com',
|
|
69
|
-
phone: '1234567890',
|
|
70
|
-
roles: [],
|
|
71
|
-
})).toThrow();
|
|
72
|
-
});
|
|
73
|
-
it('fails on invalid email', () => {
|
|
74
|
-
expect(() => CreateUserSchema.parse({
|
|
75
|
-
email: 'bad-email',
|
|
76
|
-
phone: '1234567890',
|
|
77
|
-
roles: ['user'],
|
|
78
|
-
})).toThrow();
|
|
79
|
-
});
|
|
80
|
-
it('fails on invalid role format', () => {
|
|
81
|
-
expect(() => CreateUserSchema.parse({
|
|
82
|
-
email: 'test@example.com',
|
|
83
|
-
phone: '1234567890',
|
|
84
|
-
roles: ['bad role'],
|
|
85
|
-
})).toThrow();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe('UpdateUserSchema', () => {
|
|
89
|
-
it('parses valid partial update', () => {
|
|
90
|
-
expect(() => UpdateUserSchema.parse({
|
|
91
|
-
email: 'new@example.com',
|
|
92
|
-
})).not.toThrow();
|
|
93
|
-
});
|
|
94
|
-
it('requires roles if provided and must be non-empty', () => {
|
|
95
|
-
expect(() => UpdateUserSchema.parse({
|
|
96
|
-
roles: [],
|
|
97
|
-
})).toThrow();
|
|
98
|
-
});
|
|
99
|
-
it('fails on short phone number', () => {
|
|
100
|
-
expect(() => UpdateUserSchema.parse({
|
|
101
|
-
phone: '123',
|
|
102
|
-
})).toThrow();
|
|
103
|
-
});
|
|
104
|
-
it('fails on invalid role format', () => {
|
|
105
|
-
expect(() => UpdateUserSchema.parse({
|
|
106
|
-
roles: ['invalid role'],
|
|
107
|
-
})).toThrow();
|
|
108
|
-
});
|
|
109
|
-
it('fails on unknown fields due to strict()', () => {
|
|
110
|
-
expect(() => UpdateUserSchema.parse({
|
|
111
|
-
email: 'test@example.com',
|
|
112
|
-
unknownField: true,
|
|
113
|
-
})).toThrow();
|
|
114
|
-
});
|
|
115
|
-
});
|