aiox-core 5.0.0 → 5.0.2
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/.aiox-core/data/entity-registry.yaml +5297 -1814
- package/.aiox-core/data/registry-update-log.jsonl +2 -0
- package/.aiox-core/development/templates/service-template/README.md.hbs +158 -158
- package/.aiox-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
- package/.aiox-core/development/templates/service-template/client.ts.hbs +403 -403
- package/.aiox-core/development/templates/service-template/errors.ts.hbs +182 -182
- package/.aiox-core/development/templates/service-template/index.ts.hbs +120 -120
- package/.aiox-core/development/templates/service-template/package.json.hbs +87 -87
- package/.aiox-core/development/templates/service-template/types.ts.hbs +145 -145
- package/.aiox-core/development/templates/squad-template/LICENSE +21 -21
- package/.aiox-core/infrastructure/scripts/tool-resolver.js +4 -4
- package/.aiox-core/infrastructure/templates/aiox-sync.yaml.template +182 -182
- package/.aiox-core/infrastructure/templates/coderabbit.yaml.template +279 -279
- package/.aiox-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
- package/.aiox-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
- package/.aiox-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-aiox-base.tmpl +63 -63
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
- package/.aiox-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
- package/.aiox-core/install-manifest.yaml +58 -58
- package/.aiox-core/local-config.yaml.template +71 -71
- package/.aiox-core/monitor/hooks/lib/__init__.py +1 -1
- package/.aiox-core/monitor/hooks/lib/enrich.py +58 -58
- package/.aiox-core/monitor/hooks/lib/send_event.py +47 -47
- package/.aiox-core/monitor/hooks/notification.py +29 -29
- package/.aiox-core/monitor/hooks/post_tool_use.py +45 -45
- package/.aiox-core/monitor/hooks/pre_compact.py +29 -29
- package/.aiox-core/monitor/hooks/pre_tool_use.py +40 -40
- package/.aiox-core/monitor/hooks/stop.py +29 -29
- package/.aiox-core/monitor/hooks/subagent_stop.py +29 -29
- package/.aiox-core/monitor/hooks/user_prompt_submit.py +38 -38
- package/.aiox-core/product/templates/adr.hbs +125 -125
- package/.aiox-core/product/templates/dbdr.hbs +241 -241
- package/.aiox-core/product/templates/engine/elicitation.js +2 -3
- package/.aiox-core/product/templates/epic.hbs +212 -212
- package/.aiox-core/product/templates/pmdr.hbs +186 -186
- package/.aiox-core/product/templates/prd-v2.0.hbs +216 -216
- package/.aiox-core/product/templates/prd.hbs +201 -201
- package/.aiox-core/product/templates/story.hbs +263 -263
- package/.aiox-core/product/templates/task.hbs +170 -170
- package/.aiox-core/product/templates/tmpl-comment-on-examples.sql +158 -158
- package/.aiox-core/product/templates/tmpl-migration-script.sql +91 -91
- package/.aiox-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
- package/.aiox-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
- package/.aiox-core/product/templates/tmpl-rls-roles.sql +135 -135
- package/.aiox-core/product/templates/tmpl-rls-simple.sql +77 -77
- package/.aiox-core/product/templates/tmpl-rls-tenant.sql +152 -152
- package/.aiox-core/product/templates/tmpl-rollback-script.sql +77 -77
- package/.aiox-core/product/templates/tmpl-seed-data.sql +140 -140
- package/.aiox-core/product/templates/tmpl-smoke-test.sql +16 -16
- package/.aiox-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
- package/.aiox-core/product/templates/tmpl-stored-proc.sql +140 -140
- package/.aiox-core/product/templates/tmpl-trigger.sql +152 -152
- package/.aiox-core/product/templates/tmpl-view-materialized.sql +133 -133
- package/.aiox-core/product/templates/tmpl-view.sql +177 -177
- package/.aiox-core/scripts/pm.sh +0 -0
- package/.claude/hooks/code-intel-pretool.cjs +107 -0
- package/.claude/hooks/enforce-architecture-first.py +196 -196
- package/.claude/hooks/mind-clone-governance.py +192 -192
- package/.claude/hooks/read-protection.py +151 -151
- package/.claude/hooks/slug-validation.py +176 -176
- package/.claude/hooks/sql-governance.py +182 -182
- package/.claude/hooks/write-path-validation.py +194 -194
- package/LICENSE +33 -33
- package/bin/aiox-graph.js +0 -0
- package/bin/aiox-minimal.js +0 -0
- package/bin/aiox.js +0 -0
- package/docs/guides/aios-workflows/README.md +247 -0
- package/docs/guides/aios-workflows/bob-orchestrator-workflow.md +1536 -0
- package/package.json +1 -1
- package/packages/aiox-install/bin/aiox-install.js +0 -0
- package/packages/aiox-install/bin/edmcp.js +0 -0
- package/packages/aiox-pro-cli/bin/aiox-pro.js +0 -0
- package/packages/installer/src/wizard/pro-setup.js +210 -123
- package/pro/README.md +66 -0
- package/pro/license/degradation.js +220 -0
- package/pro/license/errors.js +450 -0
- package/pro/license/feature-gate.js +354 -0
- package/pro/license/index.js +181 -0
- package/pro/license/license-api.js +679 -0
- package/pro/license/license-cache.js +523 -0
- package/pro/license/license-crypto.js +303 -0
- package/scripts/check-markdown-links.py +352 -352
- package/scripts/dashboard-parallel-dev.sh +0 -0
- package/scripts/dashboard-parallel-phase3.sh +0 -0
- package/scripts/dashboard-parallel-phase4.sh +0 -0
- package/scripts/glue/README.md +355 -0
- package/scripts/glue/compose-agent-prompt.cjs +362 -0
- package/scripts/install-monitor-hooks.sh +0 -0
- package/.aiox-core/lib/build.json +0 -1
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* License Errors Module
|
|
3
|
+
*
|
|
4
|
+
* Custom error classes for license and feature gating.
|
|
5
|
+
*
|
|
6
|
+
* @module pro/license/errors
|
|
7
|
+
* @see ADR-PRO-003 - Feature Gating & Licensing
|
|
8
|
+
* @see Story PRO-6 - License Key & Feature Gating System
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when a pro feature is accessed without a valid license.
|
|
15
|
+
*
|
|
16
|
+
* Provides a user-friendly message with activation instructions.
|
|
17
|
+
* Never exposes sensitive information (license keys, internal state).
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* throw new ProFeatureError('pro.squads.premium', 'Premium Squads');
|
|
21
|
+
*
|
|
22
|
+
* Message format (per ADR-PRO-003):
|
|
23
|
+
* {Feature Name} requires an active AIOS Pro license.
|
|
24
|
+
* Your data and configurations are preserved.
|
|
25
|
+
* Activate: aios pro activate --key <KEY>
|
|
26
|
+
* Purchase: https://synkra.ai/pro
|
|
27
|
+
*/
|
|
28
|
+
class ProFeatureError extends Error {
|
|
29
|
+
/**
|
|
30
|
+
* Create a ProFeatureError.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} featureId - The feature ID that was requested (e.g., "pro.squads.premium")
|
|
33
|
+
* @param {string} [friendlyName] - Human-friendly name for the feature
|
|
34
|
+
* @param {object} [options] - Additional options
|
|
35
|
+
* @param {string} [options.purchaseUrl] - Custom purchase URL
|
|
36
|
+
* @param {string} [options.activateCommand] - Custom activation command
|
|
37
|
+
*/
|
|
38
|
+
constructor(featureId, friendlyName, options = {}) {
|
|
39
|
+
const name = friendlyName || featureId;
|
|
40
|
+
const purchaseUrl = options.purchaseUrl || 'https://synkra.ai/pro';
|
|
41
|
+
const activateCommand = options.activateCommand || 'aios pro activate --key <KEY>';
|
|
42
|
+
|
|
43
|
+
const message = [
|
|
44
|
+
`${name} requires an active AIOS Pro license.`,
|
|
45
|
+
'Your data and configurations are preserved.',
|
|
46
|
+
`Activate: ${activateCommand}`,
|
|
47
|
+
`Purchase: ${purchaseUrl}`,
|
|
48
|
+
].join('\n');
|
|
49
|
+
|
|
50
|
+
super(message);
|
|
51
|
+
|
|
52
|
+
this.name = 'ProFeatureError';
|
|
53
|
+
this.featureId = featureId;
|
|
54
|
+
this.friendlyName = name;
|
|
55
|
+
this.purchaseUrl = purchaseUrl;
|
|
56
|
+
this.activateCommand = activateCommand;
|
|
57
|
+
|
|
58
|
+
// Capture stack trace (V8 engines)
|
|
59
|
+
if (Error.captureStackTrace) {
|
|
60
|
+
Error.captureStackTrace(this, ProFeatureError);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get formatted message for CLI display.
|
|
66
|
+
*
|
|
67
|
+
* @returns {string} Formatted error message
|
|
68
|
+
*/
|
|
69
|
+
toCliMessage() {
|
|
70
|
+
return [
|
|
71
|
+
'',
|
|
72
|
+
` ${this.friendlyName} requires an active AIOS Pro license.`,
|
|
73
|
+
'',
|
|
74
|
+
' Your data and configurations are preserved.',
|
|
75
|
+
'',
|
|
76
|
+
` Activate: ${this.activateCommand}`,
|
|
77
|
+
` Purchase: ${this.purchaseUrl}`,
|
|
78
|
+
'',
|
|
79
|
+
].join('\n');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get JSON representation for API responses.
|
|
84
|
+
*
|
|
85
|
+
* @returns {object} JSON-serializable error object
|
|
86
|
+
*/
|
|
87
|
+
toJSON() {
|
|
88
|
+
return {
|
|
89
|
+
error: 'ProFeatureError',
|
|
90
|
+
featureId: this.featureId,
|
|
91
|
+
friendlyName: this.friendlyName,
|
|
92
|
+
message: `${this.friendlyName} requires an active AIOS Pro license.`,
|
|
93
|
+
activateCommand: this.activateCommand,
|
|
94
|
+
purchaseUrl: this.purchaseUrl,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Error thrown when license activation fails.
|
|
101
|
+
*/
|
|
102
|
+
class LicenseActivationError extends Error {
|
|
103
|
+
/**
|
|
104
|
+
* Create a LicenseActivationError.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} message - Error message
|
|
107
|
+
* @param {string} [code] - Error code (e.g., 'INVALID_KEY', 'NETWORK_ERROR')
|
|
108
|
+
* @param {object} [details] - Additional error details
|
|
109
|
+
*/
|
|
110
|
+
constructor(message, code, details = {}) {
|
|
111
|
+
super(message);
|
|
112
|
+
|
|
113
|
+
this.name = 'LicenseActivationError';
|
|
114
|
+
this.code = code || 'ACTIVATION_FAILED';
|
|
115
|
+
this.details = details;
|
|
116
|
+
|
|
117
|
+
if (Error.captureStackTrace) {
|
|
118
|
+
Error.captureStackTrace(this, LicenseActivationError);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Create error for invalid key format.
|
|
124
|
+
*
|
|
125
|
+
* @returns {LicenseActivationError}
|
|
126
|
+
*/
|
|
127
|
+
static invalidKeyFormat() {
|
|
128
|
+
return new LicenseActivationError(
|
|
129
|
+
'Invalid license key format. Expected: PRO-XXXX-XXXX-XXXX-XXXX',
|
|
130
|
+
'INVALID_KEY_FORMAT',
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Create error for network failure.
|
|
136
|
+
*
|
|
137
|
+
* @param {Error} [cause] - Original error
|
|
138
|
+
* @returns {LicenseActivationError}
|
|
139
|
+
*/
|
|
140
|
+
static networkError(cause) {
|
|
141
|
+
return new LicenseActivationError(
|
|
142
|
+
'Unable to reach license server. Please check your internet connection.',
|
|
143
|
+
'NETWORK_ERROR',
|
|
144
|
+
{ cause: cause ? cause.message : undefined },
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Create error for invalid key (server rejected).
|
|
150
|
+
*
|
|
151
|
+
* @returns {LicenseActivationError}
|
|
152
|
+
*/
|
|
153
|
+
static invalidKey() {
|
|
154
|
+
return new LicenseActivationError(
|
|
155
|
+
'The license key is invalid or has been revoked.',
|
|
156
|
+
'INVALID_KEY',
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Create error for expired key.
|
|
162
|
+
*
|
|
163
|
+
* @returns {LicenseActivationError}
|
|
164
|
+
*/
|
|
165
|
+
static expiredKey() {
|
|
166
|
+
return new LicenseActivationError(
|
|
167
|
+
'The license key has expired. Please renew at https://synkra.ai/pro',
|
|
168
|
+
'EXPIRED_KEY',
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Create error for seat limit exceeded.
|
|
174
|
+
*
|
|
175
|
+
* @param {number} used - Seats currently used
|
|
176
|
+
* @param {number} max - Maximum seats allowed
|
|
177
|
+
* @returns {LicenseActivationError}
|
|
178
|
+
*/
|
|
179
|
+
static seatLimitExceeded(used, max) {
|
|
180
|
+
return new LicenseActivationError(
|
|
181
|
+
`Seat limit exceeded. ${used}/${max} seats in use. Deactivate another device or upgrade your license.`,
|
|
182
|
+
'SEAT_LIMIT_EXCEEDED',
|
|
183
|
+
{ used, max },
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Create error for rate limiting.
|
|
189
|
+
*
|
|
190
|
+
* @param {number} [retryAfter] - Seconds until retry is allowed
|
|
191
|
+
* @returns {LicenseActivationError}
|
|
192
|
+
*/
|
|
193
|
+
static rateLimited(retryAfter) {
|
|
194
|
+
const message = retryAfter
|
|
195
|
+
? `Too many requests. Please try again in ${retryAfter} seconds.`
|
|
196
|
+
: 'Too many requests. Please try again later.';
|
|
197
|
+
|
|
198
|
+
return new LicenseActivationError(message, 'RATE_LIMITED', { retryAfter });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Create error for server error.
|
|
203
|
+
*
|
|
204
|
+
* @returns {LicenseActivationError}
|
|
205
|
+
*/
|
|
206
|
+
static serverError() {
|
|
207
|
+
return new LicenseActivationError(
|
|
208
|
+
'License server error. Please try again later.',
|
|
209
|
+
'SERVER_ERROR',
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get JSON representation for API responses.
|
|
215
|
+
*
|
|
216
|
+
* @returns {object} JSON-serializable error object
|
|
217
|
+
*/
|
|
218
|
+
toJSON() {
|
|
219
|
+
return {
|
|
220
|
+
error: 'LicenseActivationError',
|
|
221
|
+
code: this.code,
|
|
222
|
+
message: this.message,
|
|
223
|
+
details: this.details,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Error thrown when license validation fails.
|
|
230
|
+
*/
|
|
231
|
+
class LicenseValidationError extends Error {
|
|
232
|
+
/**
|
|
233
|
+
* Create a LicenseValidationError.
|
|
234
|
+
*
|
|
235
|
+
* @param {string} message - Error message
|
|
236
|
+
* @param {string} [code] - Error code
|
|
237
|
+
*/
|
|
238
|
+
constructor(message, code) {
|
|
239
|
+
super(message);
|
|
240
|
+
|
|
241
|
+
this.name = 'LicenseValidationError';
|
|
242
|
+
this.code = code || 'VALIDATION_FAILED';
|
|
243
|
+
|
|
244
|
+
if (Error.captureStackTrace) {
|
|
245
|
+
Error.captureStackTrace(this, LicenseValidationError);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Create error for corrupted cache.
|
|
251
|
+
*
|
|
252
|
+
* @returns {LicenseValidationError}
|
|
253
|
+
*/
|
|
254
|
+
static corruptedCache() {
|
|
255
|
+
return new LicenseValidationError(
|
|
256
|
+
'License cache is corrupted. Please reactivate with: aios pro activate --key <KEY>',
|
|
257
|
+
'CORRUPTED_CACHE',
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Create error for machine mismatch.
|
|
263
|
+
*
|
|
264
|
+
* @returns {LicenseValidationError}
|
|
265
|
+
*/
|
|
266
|
+
static machineMismatch() {
|
|
267
|
+
return new LicenseValidationError(
|
|
268
|
+
'License was activated on a different machine. Please reactivate.',
|
|
269
|
+
'MACHINE_MISMATCH',
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Error thrown when authentication fails.
|
|
276
|
+
*
|
|
277
|
+
* Covers signup, login, email verification, and session errors.
|
|
278
|
+
*
|
|
279
|
+
* @see Story PRO-11 - Email Authentication & Buyer-Based Pro Activation
|
|
280
|
+
*/
|
|
281
|
+
class AuthError extends Error {
|
|
282
|
+
/**
|
|
283
|
+
* Create an AuthError.
|
|
284
|
+
*
|
|
285
|
+
* @param {string} message - Error message
|
|
286
|
+
* @param {string} [code] - Error code (e.g., 'EMAIL_NOT_VERIFIED', 'INVALID_CREDENTIALS')
|
|
287
|
+
* @param {object} [details] - Additional error details
|
|
288
|
+
*/
|
|
289
|
+
constructor(message, code, details = {}) {
|
|
290
|
+
super(message);
|
|
291
|
+
|
|
292
|
+
this.name = 'AuthError';
|
|
293
|
+
this.code = code || 'AUTH_FAILED';
|
|
294
|
+
this.details = details;
|
|
295
|
+
|
|
296
|
+
if (Error.captureStackTrace) {
|
|
297
|
+
Error.captureStackTrace(this, AuthError);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Create error for invalid credentials (wrong email/password).
|
|
303
|
+
*
|
|
304
|
+
* @returns {AuthError}
|
|
305
|
+
*/
|
|
306
|
+
static invalidCredentials() {
|
|
307
|
+
return new AuthError(
|
|
308
|
+
'Invalid email or password.',
|
|
309
|
+
'INVALID_CREDENTIALS',
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Create error for email not verified.
|
|
315
|
+
*
|
|
316
|
+
* @returns {AuthError}
|
|
317
|
+
*/
|
|
318
|
+
static emailNotVerified() {
|
|
319
|
+
return new AuthError(
|
|
320
|
+
'Please verify your email first. Check your inbox.',
|
|
321
|
+
'EMAIL_NOT_VERIFIED',
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Create error for email already registered.
|
|
327
|
+
*
|
|
328
|
+
* @returns {AuthError}
|
|
329
|
+
*/
|
|
330
|
+
static emailAlreadyRegistered() {
|
|
331
|
+
return new AuthError(
|
|
332
|
+
'An account with this email already exists. Try logging in instead.',
|
|
333
|
+
'EMAIL_ALREADY_REGISTERED',
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Create error for rate limiting on auth endpoints.
|
|
339
|
+
*
|
|
340
|
+
* @param {number} [retryAfter] - Seconds until retry is allowed
|
|
341
|
+
* @returns {AuthError}
|
|
342
|
+
*/
|
|
343
|
+
static rateLimited(retryAfter) {
|
|
344
|
+
const message = retryAfter
|
|
345
|
+
? `Too many attempts. Try again in ${Math.ceil(retryAfter / 60)} minutes.`
|
|
346
|
+
: 'Too many attempts. Please try again later.';
|
|
347
|
+
|
|
348
|
+
return new AuthError(message, 'AUTH_RATE_LIMITED', { retryAfter });
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Create error for verification timeout.
|
|
353
|
+
*
|
|
354
|
+
* @returns {AuthError}
|
|
355
|
+
*/
|
|
356
|
+
static verificationTimeout() {
|
|
357
|
+
return new AuthError(
|
|
358
|
+
'Email verification timed out. Please try again.',
|
|
359
|
+
'VERIFICATION_TIMEOUT',
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Get JSON representation for API responses.
|
|
365
|
+
*
|
|
366
|
+
* @returns {object} JSON-serializable error object
|
|
367
|
+
*/
|
|
368
|
+
toJSON() {
|
|
369
|
+
return {
|
|
370
|
+
error: 'AuthError',
|
|
371
|
+
code: this.code,
|
|
372
|
+
message: this.message,
|
|
373
|
+
details: this.details,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Error thrown when buyer validation fails.
|
|
380
|
+
*
|
|
381
|
+
* Used when validate_buyer API indicates the user is not a paying customer.
|
|
382
|
+
*
|
|
383
|
+
* @see Story PRO-11 - Email Authentication & Buyer-Based Pro Activation
|
|
384
|
+
*/
|
|
385
|
+
class BuyerValidationError extends Error {
|
|
386
|
+
/**
|
|
387
|
+
* Create a BuyerValidationError.
|
|
388
|
+
*
|
|
389
|
+
* @param {string} message - Error message
|
|
390
|
+
* @param {string} [code] - Error code
|
|
391
|
+
* @param {object} [details] - Additional error details
|
|
392
|
+
*/
|
|
393
|
+
constructor(message, code, details = {}) {
|
|
394
|
+
super(message);
|
|
395
|
+
|
|
396
|
+
this.name = 'BuyerValidationError';
|
|
397
|
+
this.code = code || 'BUYER_VALIDATION_FAILED';
|
|
398
|
+
this.details = details;
|
|
399
|
+
|
|
400
|
+
if (Error.captureStackTrace) {
|
|
401
|
+
Error.captureStackTrace(this, BuyerValidationError);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Create error for non-buyer (validate_buyer returned false).
|
|
407
|
+
*
|
|
408
|
+
* @returns {BuyerValidationError}
|
|
409
|
+
*/
|
|
410
|
+
static notABuyer() {
|
|
411
|
+
return new BuyerValidationError(
|
|
412
|
+
'No active Pro subscription found for this email.',
|
|
413
|
+
'NOT_A_BUYER',
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Create error for buyer validation service failure.
|
|
419
|
+
*
|
|
420
|
+
* @returns {BuyerValidationError}
|
|
421
|
+
*/
|
|
422
|
+
static serviceUnavailable() {
|
|
423
|
+
return new BuyerValidationError(
|
|
424
|
+
'Subscription verification service is temporarily unavailable. Please try again later.',
|
|
425
|
+
'BUYER_SERVICE_UNAVAILABLE',
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Get JSON representation for API responses.
|
|
431
|
+
*
|
|
432
|
+
* @returns {object} JSON-serializable error object
|
|
433
|
+
*/
|
|
434
|
+
toJSON() {
|
|
435
|
+
return {
|
|
436
|
+
error: 'BuyerValidationError',
|
|
437
|
+
code: this.code,
|
|
438
|
+
message: this.message,
|
|
439
|
+
details: this.details,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
module.exports = {
|
|
445
|
+
ProFeatureError,
|
|
446
|
+
LicenseActivationError,
|
|
447
|
+
LicenseValidationError,
|
|
448
|
+
AuthError,
|
|
449
|
+
BuyerValidationError,
|
|
450
|
+
};
|