@go-mondo/identity-sdk 0.0.2-beta.68 → 0.0.2-beta.71

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 (66) 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 +21 -0
  5. package/README.md +2 -0
  6. package/dist/cjs/action/schema/base.d.ts +0 -2
  7. package/dist/cjs/action/schema/base.d.ts.map +1 -1
  8. package/dist/cjs/action/schema/base.js +0 -2
  9. package/dist/cjs/action/schema/base.test.js +0 -1
  10. package/dist/cjs/action/schema/schema.d.ts +5 -28
  11. package/dist/cjs/action/schema/schema.d.ts.map +1 -1
  12. package/dist/cjs/action/schema/schema.js +6 -5
  13. package/dist/cjs/action/schema/schema.test.js +20 -46
  14. package/dist/cjs/association/schema.d.ts +8 -8
  15. package/dist/cjs/authentication/sessions/schema.d.ts +2 -5
  16. package/dist/cjs/authentication/sessions/schema.d.ts.map +1 -1
  17. package/dist/cjs/authentication/strategies/schema/base.d.ts +0 -2
  18. package/dist/cjs/authentication/strategies/schema/base.d.ts.map +1 -1
  19. package/dist/cjs/authentication/strategies/schema/base.js +0 -2
  20. package/dist/cjs/authentication/strategies/schema/schema.d.ts +0 -84
  21. package/dist/cjs/authentication/strategies/schema/schema.d.ts.map +1 -1
  22. package/dist/cjs/authentication/strategies/schema/schema.js +0 -6
  23. package/dist/cjs/oauth/authorize/schema/grants/implicit.d.ts +1 -1
  24. package/dist/cjs/oauth/authorize/schema/schema.d.ts +1 -1
  25. package/dist/esm/action/schema/base.d.ts +0 -2
  26. package/dist/esm/action/schema/base.d.ts.map +1 -1
  27. package/dist/esm/action/schema/base.js +0 -2
  28. package/dist/esm/action/schema/base.test.js +1 -2
  29. package/dist/esm/action/schema/schema.d.ts +5 -28
  30. package/dist/esm/action/schema/schema.d.ts.map +1 -1
  31. package/dist/esm/action/schema/schema.js +6 -5
  32. package/dist/esm/action/schema/schema.test.js +2 -28
  33. package/dist/esm/association/schema.d.ts +8 -8
  34. package/dist/esm/authentication/sessions/schema.d.ts +2 -5
  35. package/dist/esm/authentication/sessions/schema.d.ts.map +1 -1
  36. package/dist/esm/authentication/strategies/schema/base.d.ts +0 -2
  37. package/dist/esm/authentication/strategies/schema/base.d.ts.map +1 -1
  38. package/dist/esm/authentication/strategies/schema/base.js +0 -2
  39. package/dist/esm/authentication/strategies/schema/schema.d.ts +0 -84
  40. package/dist/esm/authentication/strategies/schema/schema.d.ts.map +1 -1
  41. package/dist/esm/authentication/strategies/schema/schema.js +0 -6
  42. package/dist/esm/oauth/authorize/schema/grants/implicit.d.ts +1 -1
  43. package/dist/esm/oauth/authorize/schema/schema.d.ts +1 -1
  44. package/package.json +1 -1
  45. package/dist/cjs/action/schema/operations/set-password.d.ts +0 -31
  46. package/dist/cjs/action/schema/operations/set-password.d.ts.map +0 -1
  47. package/dist/cjs/action/schema/operations/set-password.js +0 -52
  48. package/dist/cjs/action/schema/operations/set-password.test.d.ts +0 -2
  49. package/dist/cjs/action/schema/operations/set-password.test.d.ts.map +0 -1
  50. package/dist/cjs/action/schema/operations/set-password.test.js +0 -168
  51. package/dist/cjs/authentication/strategies/schema/types/password.d.ts +0 -139
  52. package/dist/cjs/authentication/strategies/schema/types/password.d.ts.map +0 -1
  53. package/dist/cjs/authentication/strategies/schema/types/password.js +0 -93
  54. package/dist/esm/action/schema/operations/set-password.d.ts +0 -31
  55. package/dist/esm/action/schema/operations/set-password.d.ts.map +0 -1
  56. package/dist/esm/action/schema/operations/set-password.js +0 -16
  57. package/dist/esm/action/schema/operations/set-password.test.d.ts +0 -2
  58. package/dist/esm/action/schema/operations/set-password.test.d.ts.map +0 -1
  59. package/dist/esm/action/schema/operations/set-password.test.js +0 -166
  60. package/dist/esm/authentication/strategies/schema/types/password.d.ts +0 -139
  61. package/dist/esm/authentication/strategies/schema/types/password.d.ts.map +0 -1
  62. package/dist/esm/authentication/strategies/schema/types/password.js +0 -57
  63. package/src/action/schema/base.test.ts.bak +0 -152
  64. package/src/action/schema/operations/set-password.test.ts.bak +0 -197
  65. package/src/action/schema/schema.test.ts.bak +0 -218
  66. package/src/authentication/strategies/schema/types/email.test.ts.bak +0 -252
@@ -1,152 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import {
4
- ActionOperation,
5
- ActionIdSchema,
6
- ActionIdPropertySchema,
7
- OperationSchema,
8
- BasePayloadSchema,
9
- } from './base.js';
10
- import { generateActionId } from './utils.js';
11
-
12
- describe('Action Schema - Base', () => {
13
- describe('ActionOperation constants', () => {
14
- test('should have correct operation values', () => {
15
- expect(ActionOperation.SET_PASSWORD).toBe('set-password');
16
- expect(ActionOperation.USER_ATTRIBUTE_VERIFICATION).toBe(
17
- 'user-attribute-verification'
18
- );
19
- expect(ActionOperation.SIGN_UP).toBe('sign-up');
20
- expect(ActionOperation.SIGN_UP_VERIFICATION).toBe('sign-up-verification');
21
- });
22
- });
23
-
24
- describe('ActionIdSchema', () => {
25
- test('should accept valid action ID', () => {
26
- const id = generateActionId();
27
- const result = ActionIdSchema(id);
28
- expect(result).not.toBeInstanceOf(type.errors);
29
- expect(result).toBe(id);
30
- });
31
-
32
- test('should reject invalid action ID format', () => {
33
- expect(ActionIdSchema('invalid_id')).toBeInstanceOf(type.errors);
34
- expect(ActionIdSchema('wrong_prefix_123')).toBeInstanceOf(type.errors);
35
- });
36
-
37
- test('should reject non-string values', () => {
38
- expect(ActionIdSchema(123)).toBeInstanceOf(type.errors);
39
- expect(ActionIdSchema(null)).toBeInstanceOf(type.errors);
40
- });
41
- });
42
-
43
- describe('ActionIdPropertySchema', () => {
44
- test('should accept valid id property', () => {
45
- const payload = { id: generateActionId() };
46
- const result = ActionIdPropertySchema(payload);
47
- expect(result).not.toBeInstanceOf(type.errors);
48
- expect(result).toEqual(payload);
49
- });
50
-
51
- test('should reject missing id', () => {
52
- const result = ActionIdPropertySchema({});
53
- expect(result).toBeInstanceOf(type.errors);
54
- });
55
-
56
- test('should reject invalid id format', () => {
57
- const result = ActionIdPropertySchema({ id: 'invalid_id' });
58
- expect(result).toBeInstanceOf(type.errors);
59
- });
60
- });
61
-
62
- describe('OperationSchema', () => {
63
- test('should accept valid operations', () => {
64
- expect(OperationSchema('sign-up')).not.toBeInstanceOf(type.errors);
65
- expect(OperationSchema('sign-up-verification')).not.toBeInstanceOf(
66
- type.errors
67
- );
68
- expect(OperationSchema('set-password')).not.toBeInstanceOf(type.errors);
69
- expect(OperationSchema('user-attribute-verification')).not.toBeInstanceOf(
70
- type.errors
71
- );
72
- });
73
-
74
- test('should reject invalid operations', () => {
75
- expect(OperationSchema('invalid-operation')).toBeInstanceOf(type.errors);
76
- expect(OperationSchema('signup')).toBeInstanceOf(type.errors);
77
- expect(OperationSchema('')).toBeInstanceOf(type.errors);
78
- });
79
-
80
- test('should reject non-string values', () => {
81
- expect(OperationSchema(123)).toBeInstanceOf(type.errors);
82
- expect(OperationSchema(null)).toBeInstanceOf(type.errors);
83
- });
84
- });
85
-
86
- describe('BasePayloadSchema', () => {
87
- test('should accept complete base payload', () => {
88
- const payload = {
89
- id: generateActionId(),
90
- attempt: 1,
91
- expiresAt: new Date().toISOString(),
92
- updatedAt: new Date().toISOString(),
93
- metadata: { key: 'value' },
94
- };
95
-
96
- const result = BasePayloadSchema(payload);
97
- expect(result).not.toBeInstanceOf(type.errors);
98
- });
99
-
100
- test('should accept base payload with optional dates', () => {
101
- const payload = {
102
- id: generateActionId(),
103
- attempt: 2,
104
- expiresAt: new Date().toISOString(),
105
- updatedAt: new Date().toISOString(),
106
- deletedAt: new Date().toISOString(),
107
- deactivatedAt: new Date().toISOString(),
108
- metadata: {},
109
- };
110
-
111
- const result = BasePayloadSchema(payload);
112
- expect(result).not.toBeInstanceOf(type.errors);
113
- });
114
-
115
- test('should reject missing required fields', () => {
116
- const payload = {
117
- id: generateActionId(),
118
- attempt: 1,
119
- // missing expiresAt, updatedAt, metadata
120
- };
121
-
122
- const result = BasePayloadSchema(payload);
123
- expect(result).toBeInstanceOf(type.errors);
124
- });
125
-
126
- test('should reject invalid attempt type', () => {
127
- const payload = {
128
- id: generateActionId(),
129
- attempt: 'not-a-number',
130
- expiresAt: new Date().toISOString(),
131
- updatedAt: new Date().toISOString(),
132
- metadata: {},
133
- };
134
-
135
- const result = BasePayloadSchema(payload);
136
- expect(result).toBeInstanceOf(type.errors);
137
- });
138
-
139
- test('should reject invalid date formats', () => {
140
- const payload = {
141
- id: generateActionId(),
142
- attempt: 1,
143
- expiresAt: 'invalid-date',
144
- updatedAt: new Date().toISOString(),
145
- metadata: {},
146
- };
147
-
148
- const result = BasePayloadSchema(payload);
149
- expect(result).toBeInstanceOf(type.errors);
150
- });
151
- });
152
- });
@@ -1,197 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { generateUserId } from '../../../customer/schema.js';
4
- import { generateActionId } from '../utils.js';
5
- import {
6
- SetPasswordActionPayloadSchema,
7
- SetPasswordActionRequestSchema,
8
- } from './set-password.js';
9
-
10
- describe('Action Schema Operations - Set Password', () => {
11
- describe('SetPasswordActionPayloadSchema', () => {
12
- test('should accept complete payload with email identifier', () => {
13
- const payload = {
14
- id: generateActionId(),
15
- operation: 'set-password' as const,
16
- user: generateUserId(),
17
- identifier: 'email' as const,
18
- policy: {},
19
- attempt: 1,
20
- expiresAt: new Date().toISOString(),
21
- updatedAt: new Date().toISOString(),
22
- metadata: { key: 'value' },
23
- };
24
-
25
- const result = SetPasswordActionPayloadSchema(payload);
26
- expect(result).not.toBeInstanceOf(type.errors);
27
- // Policy defaults are applied, so we don't compare exact equality
28
- });
29
-
30
- test('should accept payload with phoneNumber identifier', () => {
31
- const payload = {
32
- id: generateActionId(),
33
- operation: 'set-password' as const,
34
- user: generateUserId(),
35
- identifier: 'phoneNumber' as const,
36
- policy: {},
37
- attempt: 1,
38
- expiresAt: new Date().toISOString(),
39
- updatedAt: new Date().toISOString(),
40
- metadata: {},
41
- };
42
-
43
- const result = SetPasswordActionPayloadSchema(payload);
44
- expect(result).not.toBeInstanceOf(type.errors);
45
- // Policy defaults are applied, so we don't compare exact equality
46
- });
47
-
48
- test('should accept payload with optional dates', () => {
49
- const payload = {
50
- id: generateActionId(),
51
- operation: 'set-password' as const,
52
- user: generateUserId(),
53
- identifier: 'email' as const,
54
- policy: {},
55
- attempt: 2,
56
- expiresAt: new Date().toISOString(),
57
- updatedAt: new Date().toISOString(),
58
- deletedAt: new Date().toISOString(),
59
- deactivatedAt: new Date().toISOString(),
60
- metadata: {},
61
- };
62
-
63
- const result = SetPasswordActionPayloadSchema(payload);
64
- expect(result).not.toBeInstanceOf(type.errors);
65
- });
66
-
67
- test('should reject invalid operation', () => {
68
- const payload = {
69
- id: generateActionId(),
70
- operation: 'invalid-operation',
71
- user: generateUserId(),
72
- identifier: 'email' as const,
73
- policy: {},
74
- attempt: 1,
75
- expiresAt: new Date().toISOString(),
76
- updatedAt: new Date().toISOString(),
77
- metadata: {},
78
- };
79
-
80
- const result = SetPasswordActionPayloadSchema(payload);
81
- expect(result).toBeInstanceOf(type.errors);
82
- });
83
-
84
- test('should reject invalid identifier', () => {
85
- const payload = {
86
- id: generateActionId(),
87
- operation: 'set-password' as const,
88
- user: generateUserId(),
89
- identifier: 'username',
90
- policy: {},
91
- attempt: 1,
92
- expiresAt: new Date().toISOString(),
93
- updatedAt: new Date().toISOString(),
94
- metadata: {},
95
- };
96
-
97
- const result = SetPasswordActionPayloadSchema(payload);
98
- expect(result).toBeInstanceOf(type.errors);
99
- });
100
-
101
- test('should reject missing required fields', () => {
102
- const payload = {
103
- id: generateActionId(),
104
- operation: 'set-password' as const,
105
- // missing user, identifier, policy, etc.
106
- };
107
-
108
- const result = SetPasswordActionPayloadSchema(payload);
109
- expect(result).toBeInstanceOf(type.errors);
110
- });
111
-
112
- test('should delete undeclared keys', () => {
113
- const payload = {
114
- id: generateActionId(),
115
- operation: 'set-password' as const,
116
- user: generateUserId(),
117
- identifier: 'email' as const,
118
- policy: {},
119
- attempt: 1,
120
- expiresAt: new Date().toISOString(),
121
- updatedAt: new Date().toISOString(),
122
- metadata: {},
123
- extraField: 'should be removed',
124
- };
125
-
126
- const result = SetPasswordActionPayloadSchema(payload);
127
- expect(result).not.toBeInstanceOf(type.errors);
128
- expect(result).not.toHaveProperty('extraField');
129
- });
130
- });
131
-
132
- describe('SetPasswordActionRequestSchema', () => {
133
- test('should accept valid request', () => {
134
- const request = {
135
- code: 'reset_code_123',
136
- password: 'NewPassword123!',
137
- };
138
-
139
- const result = SetPasswordActionRequestSchema(request);
140
- expect(result).not.toBeInstanceOf(type.errors);
141
- expect(result).toEqual(request);
142
- });
143
-
144
- test('should reject missing code', () => {
145
- const request = {
146
- password: 'NewPassword123!',
147
- };
148
-
149
- const result = SetPasswordActionRequestSchema(request);
150
- expect(result).toBeInstanceOf(type.errors);
151
- });
152
-
153
- test('should reject missing password', () => {
154
- const request = {
155
- code: 'reset_code_123',
156
- };
157
-
158
- const result = SetPasswordActionRequestSchema(request);
159
- expect(result).toBeInstanceOf(type.errors);
160
- });
161
-
162
- test('should reject non-string values', () => {
163
- const request1 = {
164
- code: 123456,
165
- password: 'NewPassword123!',
166
- };
167
-
168
- const request2 = {
169
- code: 'reset_code_123',
170
- password: 123456,
171
- };
172
-
173
- expect(SetPasswordActionRequestSchema(request1)).toBeInstanceOf(
174
- type.errors
175
- );
176
- expect(SetPasswordActionRequestSchema(request2)).toBeInstanceOf(
177
- type.errors
178
- );
179
- });
180
-
181
- test('should delete undeclared keys', () => {
182
- const request = {
183
- code: 'reset_code_123',
184
- password: 'NewPassword123!',
185
- extraField: 'should be removed',
186
- };
187
-
188
- const result = SetPasswordActionRequestSchema(request);
189
- expect(result).not.toBeInstanceOf(type.errors);
190
- expect(result).not.toHaveProperty('extraField');
191
- expect(result).toEqual({
192
- code: 'reset_code_123',
193
- password: 'NewPassword123!',
194
- });
195
- });
196
- });
197
- });
@@ -1,218 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { ActionPayloadSchema, ActionOperation } from './schema.js';
4
- import { generateActionId } from './utils.js';
5
- import { generateUserId } from '../../customer/schema.js';
6
-
7
- describe('Action Schema - Main', () => {
8
- describe('ActionPayloadSchema', () => {
9
- test('should accept set-password action payload', () => {
10
- const payload = {
11
- id: generateActionId(),
12
- operation: 'set-password' as const,
13
- user: generateUserId(),
14
- identifier: 'email' as const,
15
- policy: {},
16
- attempt: 1,
17
- expiresAt: new Date().toISOString(),
18
- updatedAt: new Date().toISOString(),
19
- metadata: { source: 'user-initiated' },
20
- };
21
-
22
- const result = ActionPayloadSchema(payload);
23
- expect(result).not.toBeInstanceOf(type.errors);
24
- });
25
-
26
- test('should accept sign-up-verification action payload', () => {
27
- const payload = {
28
- id: generateActionId(),
29
- operation: 'sign-up-verification' as const,
30
- user: generateUserId(),
31
- identifier: 'email' as const,
32
- attempt: 1,
33
- expiresAt: new Date().toISOString(),
34
- updatedAt: new Date().toISOString(),
35
- metadata: { method: 'email' },
36
- };
37
-
38
- const result = ActionPayloadSchema(payload);
39
- expect(result).not.toBeInstanceOf(type.errors);
40
- });
41
-
42
- test('should accept sign-up action payload', () => {
43
- const payload = {
44
- id: generateActionId(),
45
- operation: 'sign-up' as const,
46
- user: {
47
- firstName: 'John',
48
- lastName: 'Doe',
49
- },
50
- attempt: 1,
51
- expiresAt: new Date().toISOString(),
52
- updatedAt: new Date().toISOString(),
53
- metadata: { registration_source: 'web' },
54
- };
55
-
56
- const result = ActionPayloadSchema(payload);
57
- expect(result).not.toBeInstanceOf(type.errors);
58
- });
59
-
60
- test('should accept user-attribute-verification action payload', () => {
61
- const payload = {
62
- id: generateActionId(),
63
- operation: 'user-attribute-verification' as const,
64
- user: generateUserId(),
65
- attribute: 'email' as const,
66
- attempt: 1,
67
- expiresAt: new Date().toISOString(),
68
- updatedAt: new Date().toISOString(),
69
- metadata: { verification_type: 'change_email' },
70
- };
71
-
72
- const result = ActionPayloadSchema(payload);
73
- expect(result).not.toBeInstanceOf(type.errors);
74
- });
75
-
76
- test('should reject invalid action operation', () => {
77
- const payload = {
78
- id: generateActionId(),
79
- operation: 'invalid-operation',
80
- metadata: {},
81
- };
82
-
83
- const result = ActionPayloadSchema(payload);
84
- expect(result).toBeInstanceOf(type.errors);
85
- });
86
-
87
- test('should reject payload missing required fields for set-password', () => {
88
- const payload = {
89
- id: generateActionId(),
90
- operation: 'set-password' as const,
91
- // missing password
92
- metadata: {},
93
- };
94
-
95
- const result = ActionPayloadSchema(payload);
96
- expect(result).toBeInstanceOf(type.errors);
97
- });
98
-
99
- test('should reject payload missing required fields for sign-up-verification', () => {
100
- const payload = {
101
- id: generateActionId(),
102
- operation: 'sign-up-verification' as const,
103
- // missing code
104
- metadata: {},
105
- };
106
-
107
- const result = ActionPayloadSchema(payload);
108
- expect(result).toBeInstanceOf(type.errors);
109
- });
110
-
111
- test('should reject payload missing required fields for sign-up', () => {
112
- const payload = {
113
- id: generateActionId(),
114
- operation: 'sign-up' as const,
115
- // missing email
116
- metadata: {},
117
- };
118
-
119
- const result = ActionPayloadSchema(payload);
120
- expect(result).toBeInstanceOf(type.errors);
121
- });
122
-
123
- test('should reject payload missing required fields for user-attribute-verification', () => {
124
- const payload = {
125
- id: generateActionId(),
126
- operation: 'user-attribute-verification' as const,
127
- attribute: 'email' as const,
128
- // missing value and code
129
- metadata: {},
130
- };
131
-
132
- const result = ActionPayloadSchema(payload);
133
- expect(result).toBeInstanceOf(type.errors);
134
- });
135
-
136
- test('should accept complex payloads with all optional fields', () => {
137
- const payload = {
138
- id: generateActionId(),
139
- operation: 'sign-up' as const,
140
- user: {
141
- firstName: 'John',
142
- lastName: 'Doe',
143
- },
144
- attempt: 1,
145
- expiresAt: new Date().toISOString(),
146
- updatedAt: new Date().toISOString(),
147
- metadata: {
148
- source: 'mobile-app',
149
- campaign: 'summer-2024',
150
- referrer: 'friend-invitation',
151
- terms_accepted: true,
152
- marketing_consent: false,
153
- },
154
- };
155
-
156
- const result = ActionPayloadSchema(payload);
157
- expect(result).not.toBeInstanceOf(type.errors);
158
- });
159
-
160
- test('should accept user-attribute-verification with phone attribute', () => {
161
- const payload = {
162
- id: generateActionId(),
163
- operation: 'user-attribute-verification' as const,
164
- user: generateUserId(),
165
- attribute: 'phoneNumber' as const,
166
- attempt: 1,
167
- expiresAt: new Date().toISOString(),
168
- updatedAt: new Date().toISOString(),
169
- metadata: { verification_method: 'sms' },
170
- };
171
-
172
- const result = ActionPayloadSchema(payload);
173
- expect(result).not.toBeInstanceOf(type.errors);
174
- });
175
-
176
- test('should reject malformed user data in sign-up action', () => {
177
- const payload = {
178
- id: generateActionId(),
179
- operation: 'sign-up' as const,
180
- user: 'invalid-user-data', // should be object
181
- attempt: 1,
182
- expiresAt: new Date().toISOString(),
183
- updatedAt: new Date().toISOString(),
184
- metadata: {},
185
- };
186
-
187
- const result = ActionPayloadSchema(payload);
188
- expect(result).toBeInstanceOf(type.errors);
189
- });
190
-
191
- test('should reject invalid attribute type in user-attribute-verification', () => {
192
- const payload = {
193
- id: generateActionId(),
194
- operation: 'user-attribute-verification' as const,
195
- user: generateUserId(),
196
- attribute: 'invalid_attribute',
197
- attempt: 1,
198
- expiresAt: new Date().toISOString(),
199
- updatedAt: new Date().toISOString(),
200
- metadata: {},
201
- };
202
-
203
- const result = ActionPayloadSchema(payload);
204
- expect(result).toBeInstanceOf(type.errors);
205
- });
206
- });
207
-
208
- describe('ActionOperation constants', () => {
209
- test('should contain expected operation values', () => {
210
- expect(ActionOperation.SET_PASSWORD).toBe('set-password');
211
- expect(ActionOperation.SIGN_UP_VERIFICATION).toBe('sign-up-verification');
212
- expect(ActionOperation.SIGN_UP).toBe('sign-up');
213
- expect(ActionOperation.USER_ATTRIBUTE_VERIFICATION).toBe(
214
- 'user-attribute-verification'
215
- );
216
- });
217
- });
218
- });