@go-mondo/identity-sdk 0.0.2-beta.74 → 0.0.2-beta.76

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.
Files changed (56) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/.tsbuildinfo/cjs.json +1 -1
  3. package/.tsbuildinfo/esm.json +1 -1
  4. package/CHANGELOG.md +14 -0
  5. package/dist/cjs/app/authorization/schema.d.ts +14 -23
  6. package/dist/cjs/app/authorization/schema.d.ts.map +1 -1
  7. package/dist/cjs/app/authorization/schema.js +5 -3
  8. package/dist/cjs/app/authorization/schema.test.js +26 -0
  9. package/dist/cjs/common/schema/jwt.d.ts +0 -6
  10. package/dist/cjs/common/schema/jwt.d.ts.map +1 -1
  11. package/dist/cjs/common/schema/jwt.js +0 -3
  12. package/dist/cjs/common/schema/jwt.test.js +0 -8
  13. package/dist/cjs/workspace/authorization/schema.d.ts +0 -9
  14. package/dist/cjs/workspace/authorization/schema.d.ts.map +1 -1
  15. package/dist/esm/app/authorization/schema.d.ts +14 -23
  16. package/dist/esm/app/authorization/schema.d.ts.map +1 -1
  17. package/dist/esm/app/authorization/schema.js +5 -3
  18. package/dist/esm/app/authorization/schema.test.js +26 -0
  19. package/dist/esm/common/schema/jwt.d.ts +0 -6
  20. package/dist/esm/common/schema/jwt.d.ts.map +1 -1
  21. package/dist/esm/common/schema/jwt.js +0 -3
  22. package/dist/esm/common/schema/jwt.test.js +0 -8
  23. package/dist/esm/workspace/authorization/schema.d.ts +0 -9
  24. package/dist/esm/workspace/authorization/schema.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/action/schema/operations/sign-up-verification.test.ts.bak +0 -163
  27. package/src/action/schema/operations/sign-up.test.ts.bak +0 -203
  28. package/src/action/schema/operations/user-attribute-verification.test.ts.bak +0 -148
  29. package/src/activity/schema/base.test.ts.bak +0 -291
  30. package/src/activity/schema/schema.test.ts.bak +0 -392
  31. package/src/activity/schema/types/authentication.test.ts.bak +0 -337
  32. package/src/activity/schema/types/authorization.test.ts.bak +0 -379
  33. package/src/activity/schema/types/note.test.ts.bak +0 -367
  34. package/src/activity/schema/types/operation.test.ts.bak +0 -379
  35. package/src/activity/schema/types/unknown.test.ts.bak +0 -304
  36. package/src/app/authorization/schema.test.ts.bak +0 -412
  37. package/src/app/oidc/schema.test.ts.bak +0 -117
  38. package/src/app/registration/schema.test.ts.bak +0 -308
  39. package/src/app/schema.test.ts.bak +0 -221
  40. package/src/association/schema.test.ts.bak +0 -148
  41. package/src/authentication/factors/schema.test.ts.bak +0 -174
  42. package/src/authentication/settings/schema.test.ts.bak +0 -91
  43. package/src/authorization/permissions/schema.test.ts.bak +0 -267
  44. package/src/authorization/roles/schema.test.ts.bak +0 -283
  45. package/src/common/schema/aggregate.test.ts.bak +0 -89
  46. package/src/common/schema/collection.test.ts.bak +0 -116
  47. package/src/common/schema/dates.test.ts.bak +0 -49
  48. package/src/common/schema/id.test.ts.bak +0 -149
  49. package/src/common/schema/jwt.test.ts.bak +0 -61
  50. package/src/common/schema/metadata.test.ts.bak +0 -141
  51. package/src/common/schema/pagination.test.ts.bak +0 -80
  52. package/src/common/schema/schema.test.ts.bak +0 -41
  53. package/src/customer/users/schema.test.ts.bak +0 -138
  54. package/src/identity/schema.test.ts.bak +0 -48
  55. package/src/oauth/token/schema/schema.test.ts.bak +0 -142
  56. package/src/workspace/settings/schema.test.ts.bak +0 -88
@@ -1,337 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { generateUserId } from '../../../customer/schema.js';
4
- import { generateActivityId } from '../utils.js';
5
- import {
6
- AuthenticationActivityPayloadSchema,
7
- AuthenticationActivitySchema,
8
- AuthenticationStatus,
9
- AuthenticationStatusSchema,
10
- } from './authentication.js';
11
-
12
- describe('Activity Schema - Authentication', () => {
13
- describe('AuthenticationStatus', () => {
14
- test('should contain expected status values', () => {
15
- expect(AuthenticationStatus.SUCESS).toBe('success');
16
- expect(AuthenticationStatus.FAIL).toBe('fail');
17
- });
18
- });
19
-
20
- describe('AuthenticationStatusSchema', () => {
21
- test('should accept success status', () => {
22
- const result = AuthenticationStatusSchema('success');
23
- expect(result).not.toBeInstanceOf(type.errors);
24
- expect(result).toBe('success');
25
- });
26
-
27
- test('should accept fail status', () => {
28
- const result = AuthenticationStatusSchema('fail');
29
- expect(result).not.toBeInstanceOf(type.errors);
30
- expect(result).toBe('fail');
31
- });
32
-
33
- test('should reject invalid status', () => {
34
- const result = AuthenticationStatusSchema('invalid_status');
35
- expect(result).toBeInstanceOf(type.errors);
36
- });
37
-
38
- test('should reject non-string status', () => {
39
- const result = AuthenticationStatusSchema(123);
40
- expect(result).toBeInstanceOf(type.errors);
41
- });
42
- });
43
-
44
- describe('AuthenticationActivitySchema', () => {
45
- test('should accept complete authentication activity with success', () => {
46
- const activity = {
47
- id: generateActivityId(),
48
- type: 'authentication' as const,
49
- status: 'success' as const,
50
- identity: generateUserId(),
51
- message: 'User successfully authenticated',
52
- performedBy: {
53
- type: 'identity' as const,
54
- identifier: 'user@example.com',
55
- },
56
- source: 'login-form',
57
- isMutateable: false,
58
- createdAt: new Date(),
59
- updatedAt: new Date(),
60
- metadata: { method: 'email', ip: '192.168.1.1' },
61
- };
62
-
63
- const result = AuthenticationActivitySchema(activity);
64
- expect(result).not.toBeInstanceOf(type.errors);
65
- });
66
-
67
- test('should accept authentication activity with fail status', () => {
68
- const activity = {
69
- id: generateActivityId(),
70
- type: 'authentication' as const,
71
- status: 'fail' as const,
72
- identity: generateUserId(),
73
- message: 'Authentication failed - invalid credentials',
74
- performedBy: {
75
- type: 'system' as const,
76
- identifier: 'auth-service',
77
- },
78
- source: 'api-endpoint',
79
- isMutateable: false,
80
- createdAt: new Date(),
81
- updatedAt: new Date(),
82
- metadata: { reason: 'invalid_password', attempts: 3 },
83
- };
84
-
85
- const result = AuthenticationActivitySchema(activity);
86
- expect(result).not.toBeInstanceOf(type.errors);
87
- });
88
-
89
- test('should accept authentication activity with optional fields', () => {
90
- const activity = {
91
- id: generateActivityId(),
92
- type: 'authentication' as const,
93
- status: 'success' as const,
94
- identity: generateUserId(),
95
- message: 'SSO authentication successful',
96
- performedBy: {
97
- type: 'integration' as const,
98
- identifier: 'oauth-provider',
99
- },
100
- source: 'sso-redirect',
101
- isMutateable: false,
102
- createdAt: new Date(),
103
- updatedAt: new Date(),
104
- deletedAt: new Date(),
105
- deactivatedAt: new Date(),
106
- metadata: { provider: 'google', token_type: 'bearer' },
107
- };
108
-
109
- const result = AuthenticationActivitySchema(activity);
110
- expect(result).not.toBeInstanceOf(type.errors);
111
- });
112
-
113
- test('should reject authentication activity with wrong type', () => {
114
- const activity = {
115
- id: generateActivityId(),
116
- type: 'authorization',
117
- status: 'success' as const,
118
- identity: generateUserId(),
119
- message: 'Wrong type',
120
- performedBy: {
121
- type: 'identity' as const,
122
- identifier: 'user@example.com',
123
- },
124
- source: 'login-form',
125
- isMutateable: false,
126
- createdAt: new Date(),
127
- updatedAt: new Date(),
128
- metadata: {},
129
- };
130
-
131
- const result = AuthenticationActivitySchema(activity);
132
- expect(result).toBeInstanceOf(type.errors);
133
- });
134
-
135
- test('should reject authentication activity with invalid status', () => {
136
- const activity = {
137
- id: generateActivityId(),
138
- type: 'authentication' as const,
139
- status: 'invalid_status',
140
- identity: generateUserId(),
141
- message: 'Test message',
142
- performedBy: {
143
- type: 'identity' as const,
144
- identifier: 'user@example.com',
145
- },
146
- source: 'login-form',
147
- isMutateable: false,
148
- createdAt: new Date(),
149
- updatedAt: new Date(),
150
- metadata: {},
151
- };
152
-
153
- const result = AuthenticationActivitySchema(activity);
154
- expect(result).toBeInstanceOf(type.errors);
155
- });
156
-
157
- test('should reject authentication activity missing required fields', () => {
158
- const activity = {
159
- id: generateActivityId(),
160
- type: 'authentication' as const,
161
- status: 'success' as const,
162
- // missing identity, message
163
- performedBy: {
164
- type: 'identity' as const,
165
- identifier: 'user@example.com',
166
- },
167
- source: 'login-form',
168
- isMutateable: false,
169
- createdAt: new Date(),
170
- updatedAt: new Date(),
171
- metadata: {},
172
- };
173
-
174
- const result = AuthenticationActivitySchema(activity);
175
- expect(result).toBeInstanceOf(type.errors);
176
- });
177
-
178
- test('should reject authentication activity with invalid identity ID', () => {
179
- const activity = {
180
- id: generateActivityId(),
181
- type: 'authentication' as const,
182
- status: 'success' as const,
183
- identity: 'invalid_user_id',
184
- message: 'Test message',
185
- performedBy: {
186
- type: 'identity' as const,
187
- identifier: 'user@example.com',
188
- },
189
- source: 'login-form',
190
- isMutateable: false,
191
- createdAt: new Date(),
192
- updatedAt: new Date(),
193
- metadata: {},
194
- };
195
-
196
- const result = AuthenticationActivitySchema(activity);
197
- expect(result).toBeInstanceOf(type.errors);
198
- });
199
- });
200
-
201
- describe('AuthenticationActivityPayloadSchema', () => {
202
- test('should accept complete authentication payload with success', () => {
203
- const payload = {
204
- id: generateActivityId(),
205
- type: 'authentication' as const,
206
- status: 'success' as const,
207
- identity: generateUserId(),
208
- message: 'Authentication successful',
209
- performedBy: {
210
- type: 'identity' as const,
211
- identifier: 'user@example.com',
212
- },
213
- source: 'mobile-app',
214
- isMutateable: false,
215
- createdAt: new Date().toISOString(),
216
- updatedAt: new Date().toISOString(),
217
- metadata: { device: 'iPhone', os: 'iOS 17' },
218
- };
219
-
220
- const result = AuthenticationActivityPayloadSchema(payload);
221
- expect(result).not.toBeInstanceOf(type.errors);
222
- expect(result).toEqual(payload);
223
- });
224
-
225
- test('should accept authentication payload with fail status', () => {
226
- const payload = {
227
- id: generateActivityId(),
228
- type: 'authentication' as const,
229
- status: 'fail' as const,
230
- identity: generateUserId(),
231
- message: 'Failed login attempt',
232
- performedBy: {
233
- type: 'guest' as const,
234
- identifier: 'anonymous-session',
235
- },
236
- source: 'web-form',
237
- isMutateable: false,
238
- createdAt: new Date().toISOString(),
239
- updatedAt: new Date().toISOString(),
240
- metadata: { error_code: 'INVALID_CREDENTIALS' },
241
- };
242
-
243
- const result = AuthenticationActivityPayloadSchema(payload);
244
- expect(result).not.toBeInstanceOf(type.errors);
245
- });
246
-
247
- test('should accept payload with optional date fields', () => {
248
- const payload = {
249
- id: generateActivityId(),
250
- type: 'authentication' as const,
251
- status: 'success' as const,
252
- identity: generateUserId(),
253
- message: 'Scheduled authentication',
254
- performedBy: {
255
- type: 'automation' as const,
256
- identifier: 'token-refresh',
257
- },
258
- source: 'background-service',
259
- isMutateable: false,
260
- createdAt: new Date().toISOString(),
261
- updatedAt: new Date().toISOString(),
262
- deletedAt: new Date().toISOString(),
263
- deactivatedAt: new Date().toISOString(),
264
- metadata: { automated: true },
265
- };
266
-
267
- const result = AuthenticationActivityPayloadSchema(payload);
268
- expect(result).not.toBeInstanceOf(type.errors);
269
- });
270
-
271
- test('should reject payload with invalid date format', () => {
272
- const payload = {
273
- id: generateActivityId(),
274
- type: 'authentication' as const,
275
- status: 'success' as const,
276
- identity: generateUserId(),
277
- message: 'Test authentication',
278
- performedBy: {
279
- type: 'identity' as const,
280
- identifier: 'user@example.com',
281
- },
282
- source: 'web-app',
283
- isMutateable: false,
284
- createdAt: 'invalid-date-format',
285
- updatedAt: new Date().toISOString(),
286
- metadata: {},
287
- };
288
-
289
- const result = AuthenticationActivityPayloadSchema(payload);
290
- expect(result).toBeInstanceOf(type.errors);
291
- });
292
-
293
- test('should reject payload with wrong type', () => {
294
- const payload = {
295
- id: generateActivityId(),
296
- type: 'note',
297
- status: 'success' as const,
298
- identity: generateUserId(),
299
- message: 'Wrong type',
300
- performedBy: {
301
- type: 'identity' as const,
302
- identifier: 'user@example.com',
303
- },
304
- source: 'web-app',
305
- isMutateable: false,
306
- createdAt: new Date().toISOString(),
307
- updatedAt: new Date().toISOString(),
308
- metadata: {},
309
- };
310
-
311
- const result = AuthenticationActivityPayloadSchema(payload);
312
- expect(result).toBeInstanceOf(type.errors);
313
- });
314
-
315
- test('should reject payload with invalid status', () => {
316
- const payload = {
317
- id: generateActivityId(),
318
- type: 'authentication' as const,
319
- status: 'pending',
320
- identity: generateUserId(),
321
- message: 'Invalid status',
322
- performedBy: {
323
- type: 'identity' as const,
324
- identifier: 'user@example.com',
325
- },
326
- source: 'web-app',
327
- isMutateable: false,
328
- createdAt: new Date().toISOString(),
329
- updatedAt: new Date().toISOString(),
330
- metadata: {},
331
- };
332
-
333
- const result = AuthenticationActivityPayloadSchema(payload);
334
- expect(result).toBeInstanceOf(type.errors);
335
- });
336
- });
337
- });