@nexussdk/contracts 0.0.1

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.
@@ -0,0 +1,52 @@
1
+
2
+ > @nexussdk/contracts@0.0.1 build /home/runner/work/NexusSDK/NexusSDK/packages/contracts
3
+ > tsup
4
+
5
+ CLI Building entry: src/auth.ts, src/flags.ts, src/index.ts, src/rfc7807.ts, src/tracker.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.1
8
+ CLI Using tsup config: /home/runner/work/NexusSDK/NexusSDK/packages/contracts/tsup.config.ts
9
+ CLI Target: es2022
10
+ CLI Cleaning output folder
11
+ ESM Build start
12
+ CJS Build start
13
+ Generated an empty chunk: "auth".
14
+ Generated an empty chunk: "flags".
15
+ Generated an empty chunk: "tracker".
16
+ Generated an empty chunk: "auth".
17
+ Generated an empty chunk: "flags".
18
+ Generated an empty chunk: "tracker".
19
+ CJS dist/auth.cjs 82.00 B
20
+ CJS dist/flags.cjs 84.00 B
21
+ CJS dist/index.cjs 199.00 B
22
+ CJS dist/rfc7807.cjs 203.00 B
23
+ CJS dist/tracker.cjs 88.00 B
24
+ CJS dist/auth.cjs.map 69.00 B
25
+ CJS dist/flags.cjs.map 70.00 B
26
+ CJS dist/index.cjs.map 2.58 KB
27
+ CJS dist/rfc7807.cjs.map 2.58 KB
28
+ CJS dist/tracker.cjs.map 72.00 B
29
+ CJS ⚡️ Build success in 111ms
30
+ ESM dist/auth.mjs 68.00 B
31
+ ESM dist/flags.mjs 70.00 B
32
+ ESM dist/index.mjs 168.00 B
33
+ ESM dist/rfc7807.mjs 172.00 B
34
+ ESM dist/tracker.mjs 74.00 B
35
+ ESM dist/auth.mjs.map 69.00 B
36
+ ESM dist/flags.mjs.map 70.00 B
37
+ ESM dist/index.mjs.map 2.57 KB
38
+ ESM dist/rfc7807.mjs.map 2.58 KB
39
+ ESM dist/tracker.mjs.map 72.00 B
40
+ ESM ⚡️ Build success in 113ms
41
+ DTS Build start
42
+ DTS ⚡️ Build success in 1002ms
43
+ DTS dist/index.d.mts 607.00 B
44
+ DTS dist/rfc7807.d.mts 2.49 KB
45
+ DTS dist/tracker.d.mts 6.48 KB
46
+ DTS dist/flags.d.mts 7.17 KB
47
+ DTS dist/auth.d.mts 6.21 KB
48
+ DTS dist/index.d.ts 603.00 B
49
+ DTS dist/rfc7807.d.ts 2.49 KB
50
+ DTS dist/tracker.d.ts 6.48 KB
51
+ DTS dist/flags.d.ts 7.17 KB
52
+ DTS dist/auth.d.ts 6.21 KB
package/dist/auth.cjs ADDED
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=auth.cjs.map
4
+ //# sourceMappingURL=auth.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"auth.cjs"}
@@ -0,0 +1,215 @@
1
+ /**
2
+ * @fileoverview Authentication, Organization, Project, and API Key contracts.
3
+ * Governs multi-tenant B2B2C security and quota boundaries.
4
+ * @module @nexus/contracts/auth
5
+ */
6
+ /**
7
+ * Subscription plan tiers determining rate limits and feature entitlements.
8
+ * @example
9
+ * const tier: PlanTier = 'PRO';
10
+ */
11
+ type PlanTier = 'FREE' | 'PRO' | 'ENTERPRISE';
12
+ /**
13
+ * Operational status of a tenant account.
14
+ * @example
15
+ * const status: AccountStatus = 'ACTIVE';
16
+ */
17
+ type AccountStatus = 'ACTIVE' | 'SUSPENDED' | 'CANCELLED';
18
+ /**
19
+ * Deployment environments for project isolation.
20
+ * @example
21
+ * const env: Environment = 'production';
22
+ */
23
+ type Environment = 'development' | 'staging' | 'production';
24
+ /**
25
+ * Cryptographic API Key permission scope.
26
+ * - `PUBLIC`: Embedded in client browsers. Permitted only for flag evaluation,
27
+ * SSE subscriptions, and error ingestion.
28
+ * - `SECRET`: Secure server-side only. Full administrative CRUD operations.
29
+ * @example
30
+ * const keyType: ApiKeyType = 'PUBLIC';
31
+ */
32
+ type ApiKeyType = 'PUBLIC' | 'SECRET';
33
+ /**
34
+ * Represents a developer or organization account (Tenant).
35
+ *
36
+ * @example
37
+ * const account: Account = {
38
+ * id: 'uuid-v4',
39
+ * name: 'Acme Corp',
40
+ * email: 'admin@acme.com',
41
+ * planTier: 'PRO',
42
+ * status: 'ACTIVE',
43
+ * createdAt: '2024-01-01T00:00:00Z',
44
+ * updatedAt: '2024-06-01T00:00:00Z',
45
+ * };
46
+ */
47
+ interface Account {
48
+ /** Unique UUID v4 identifier. */
49
+ id: string;
50
+ /** Organization or developer display name. */
51
+ name: string;
52
+ /** Primary contact and authentication email. */
53
+ email: string;
54
+ /** Current billing entitlement tier. */
55
+ planTier: PlanTier;
56
+ /** Current operational state. */
57
+ status: AccountStatus;
58
+ /** Arbitrary organizational metadata. */
59
+ metadata?: Record<string, unknown>;
60
+ /** Timestamp when account was created. */
61
+ createdAt: string;
62
+ /** Timestamp when account was last modified. */
63
+ updatedAt: string;
64
+ }
65
+ /**
66
+ * Represents an isolated application owned by an Account.
67
+ *
68
+ * @example
69
+ * const project: Project = {
70
+ * id: 'uuid-v4',
71
+ * accountId: 'account-uuid-v4',
72
+ * name: 'My App',
73
+ * slug: 'my-app',
74
+ * createdAt: '2024-01-01T00:00:00Z',
75
+ * updatedAt: '2024-06-01T00:00:00Z',
76
+ * };
77
+ */
78
+ interface Project {
79
+ /** Unique UUID v4 identifier. */
80
+ id: string;
81
+ /** Owning Account UUID v4 identifier. */
82
+ accountId: string;
83
+ /** Human-readable project name. */
84
+ name: string;
85
+ /** URL-friendly unique slug under the parent account. */
86
+ slug: string;
87
+ /** Project description. */
88
+ description?: string;
89
+ /** Timestamp of project creation. */
90
+ createdAt: string;
91
+ /** Timestamp of last modification. */
92
+ updatedAt: string;
93
+ }
94
+ /**
95
+ * Public or Secret API Key metadata used by Go-Gin and NestJS guards.
96
+ *
97
+ * @example
98
+ * const apiKey: ApiKey = {
99
+ * id: 'uuid-v4',
100
+ * projectId: 'project-uuid-v4',
101
+ * environment: 'production',
102
+ * keyType: 'PUBLIC',
103
+ * keyPrefix: 'pk_live_a1b2',
104
+ * keyHash: 'sha256hexstring...',
105
+ * allowedDomains: ['https://mybrand.com'],
106
+ * rateLimitPerMin: 1000,
107
+ * monthlyEventsLimit: 100000,
108
+ * currentMonthUsage: 4250,
109
+ * usageResetAt: '2024-07-01T00:00:00Z',
110
+ * isActive: true,
111
+ * createdAt: '2024-01-01T00:00:00Z',
112
+ * };
113
+ */
114
+ interface ApiKey {
115
+ /** Unique UUID v4 identifier. */
116
+ id: string;
117
+ /** Parent Project identifier. */
118
+ projectId: string;
119
+ /** Target deployment environment. */
120
+ environment: Environment;
121
+ /** Key capability level. */
122
+ keyType: ApiKeyType;
123
+ /** Public preview prefix (e.g. "pk_live_abcd1234"). Raw secret is never persisted. */
124
+ keyPrefix: string;
125
+ /** SHA-256 hash string (64 chars) matching stored database records. */
126
+ keyHash: string;
127
+ /** Whitelisted Origin domains for browser CORS security (e.g. ["https://mybrand.com"]). */
128
+ allowedDomains: string[];
129
+ /** Maximum allowed HTTP requests per minute. */
130
+ rateLimitPerMin: number;
131
+ /** Hard cap for error and event ingestion per calendar month. */
132
+ monthlyEventsLimit: number;
133
+ /** Current count of events processed in the active billing window. */
134
+ currentMonthUsage: number;
135
+ /** Timestamp when the current billing usage cycle resets. */
136
+ usageResetAt: string;
137
+ /** Flag toggle allowing immediate key revocation. */
138
+ isActive: boolean;
139
+ /** Timestamp when the key was last used in any API request. */
140
+ lastUsedAt?: string;
141
+ /** Creation timestamp. */
142
+ createdAt: string;
143
+ }
144
+ /**
145
+ * Payload returned to the developer upon key generation.
146
+ * This is the ONLY time the raw token is made visible.
147
+ *
148
+ * @example
149
+ * const response: GeneratedApiKeyResponse = {
150
+ * apiKey: { ... },
151
+ * rawKey: 'pk_live_a1b2c3d4e5f6...',
152
+ * };
153
+ */
154
+ interface GeneratedApiKeyResponse {
155
+ /** Public or Secret key metadata entity. */
156
+ apiKey: ApiKey;
157
+ /**
158
+ * Plaintext unhashed API key string (e.g., 'pk_live_a1b2c3...').
159
+ * Must be securely copied by developer; cannot be recovered after this response.
160
+ */
161
+ rawKey: string;
162
+ }
163
+ /**
164
+ * DTO for account registration requests.
165
+ *
166
+ * @example
167
+ * const dto: RegisterAccountDto = {
168
+ * name: 'Acme Corp',
169
+ * email: 'admin@acme.com',
170
+ * password: 'S3cur3P@ssw0rd!',
171
+ * };
172
+ */
173
+ interface RegisterAccountDto {
174
+ /** Organization display name. */
175
+ name: string;
176
+ /** Primary contact email. */
177
+ email: string;
178
+ /** Plaintext password (hashed server-side with bcrypt). */
179
+ password: string;
180
+ }
181
+ /**
182
+ * DTO for login requests.
183
+ *
184
+ * @example
185
+ * const dto: LoginDto = {
186
+ * email: 'admin@acme.com',
187
+ * password: 'S3cur3P@ssw0rd!',
188
+ * };
189
+ */
190
+ interface LoginDto {
191
+ /** Registered email address. */
192
+ email: string;
193
+ /** Plaintext password to verify against stored bcrypt hash. */
194
+ password: string;
195
+ }
196
+ /**
197
+ * Session payload embedded in JWT and HttpOnly cookies.
198
+ *
199
+ * @example
200
+ * const session: SessionPayload = {
201
+ * accountId: 'uuid-v4',
202
+ * email: 'admin@acme.com',
203
+ * planTier: 'PRO',
204
+ * };
205
+ */
206
+ interface SessionPayload {
207
+ /** Authenticated account's UUID. */
208
+ accountId: string;
209
+ /** Authenticated account's email. */
210
+ email: string;
211
+ /** Plan tier for feature entitlement checks. */
212
+ planTier: PlanTier;
213
+ }
214
+
215
+ export type { Account, AccountStatus, ApiKey, ApiKeyType, Environment, GeneratedApiKeyResponse, LoginDto, PlanTier, Project, RegisterAccountDto, SessionPayload };
package/dist/auth.d.ts ADDED
@@ -0,0 +1,215 @@
1
+ /**
2
+ * @fileoverview Authentication, Organization, Project, and API Key contracts.
3
+ * Governs multi-tenant B2B2C security and quota boundaries.
4
+ * @module @nexus/contracts/auth
5
+ */
6
+ /**
7
+ * Subscription plan tiers determining rate limits and feature entitlements.
8
+ * @example
9
+ * const tier: PlanTier = 'PRO';
10
+ */
11
+ type PlanTier = 'FREE' | 'PRO' | 'ENTERPRISE';
12
+ /**
13
+ * Operational status of a tenant account.
14
+ * @example
15
+ * const status: AccountStatus = 'ACTIVE';
16
+ */
17
+ type AccountStatus = 'ACTIVE' | 'SUSPENDED' | 'CANCELLED';
18
+ /**
19
+ * Deployment environments for project isolation.
20
+ * @example
21
+ * const env: Environment = 'production';
22
+ */
23
+ type Environment = 'development' | 'staging' | 'production';
24
+ /**
25
+ * Cryptographic API Key permission scope.
26
+ * - `PUBLIC`: Embedded in client browsers. Permitted only for flag evaluation,
27
+ * SSE subscriptions, and error ingestion.
28
+ * - `SECRET`: Secure server-side only. Full administrative CRUD operations.
29
+ * @example
30
+ * const keyType: ApiKeyType = 'PUBLIC';
31
+ */
32
+ type ApiKeyType = 'PUBLIC' | 'SECRET';
33
+ /**
34
+ * Represents a developer or organization account (Tenant).
35
+ *
36
+ * @example
37
+ * const account: Account = {
38
+ * id: 'uuid-v4',
39
+ * name: 'Acme Corp',
40
+ * email: 'admin@acme.com',
41
+ * planTier: 'PRO',
42
+ * status: 'ACTIVE',
43
+ * createdAt: '2024-01-01T00:00:00Z',
44
+ * updatedAt: '2024-06-01T00:00:00Z',
45
+ * };
46
+ */
47
+ interface Account {
48
+ /** Unique UUID v4 identifier. */
49
+ id: string;
50
+ /** Organization or developer display name. */
51
+ name: string;
52
+ /** Primary contact and authentication email. */
53
+ email: string;
54
+ /** Current billing entitlement tier. */
55
+ planTier: PlanTier;
56
+ /** Current operational state. */
57
+ status: AccountStatus;
58
+ /** Arbitrary organizational metadata. */
59
+ metadata?: Record<string, unknown>;
60
+ /** Timestamp when account was created. */
61
+ createdAt: string;
62
+ /** Timestamp when account was last modified. */
63
+ updatedAt: string;
64
+ }
65
+ /**
66
+ * Represents an isolated application owned by an Account.
67
+ *
68
+ * @example
69
+ * const project: Project = {
70
+ * id: 'uuid-v4',
71
+ * accountId: 'account-uuid-v4',
72
+ * name: 'My App',
73
+ * slug: 'my-app',
74
+ * createdAt: '2024-01-01T00:00:00Z',
75
+ * updatedAt: '2024-06-01T00:00:00Z',
76
+ * };
77
+ */
78
+ interface Project {
79
+ /** Unique UUID v4 identifier. */
80
+ id: string;
81
+ /** Owning Account UUID v4 identifier. */
82
+ accountId: string;
83
+ /** Human-readable project name. */
84
+ name: string;
85
+ /** URL-friendly unique slug under the parent account. */
86
+ slug: string;
87
+ /** Project description. */
88
+ description?: string;
89
+ /** Timestamp of project creation. */
90
+ createdAt: string;
91
+ /** Timestamp of last modification. */
92
+ updatedAt: string;
93
+ }
94
+ /**
95
+ * Public or Secret API Key metadata used by Go-Gin and NestJS guards.
96
+ *
97
+ * @example
98
+ * const apiKey: ApiKey = {
99
+ * id: 'uuid-v4',
100
+ * projectId: 'project-uuid-v4',
101
+ * environment: 'production',
102
+ * keyType: 'PUBLIC',
103
+ * keyPrefix: 'pk_live_a1b2',
104
+ * keyHash: 'sha256hexstring...',
105
+ * allowedDomains: ['https://mybrand.com'],
106
+ * rateLimitPerMin: 1000,
107
+ * monthlyEventsLimit: 100000,
108
+ * currentMonthUsage: 4250,
109
+ * usageResetAt: '2024-07-01T00:00:00Z',
110
+ * isActive: true,
111
+ * createdAt: '2024-01-01T00:00:00Z',
112
+ * };
113
+ */
114
+ interface ApiKey {
115
+ /** Unique UUID v4 identifier. */
116
+ id: string;
117
+ /** Parent Project identifier. */
118
+ projectId: string;
119
+ /** Target deployment environment. */
120
+ environment: Environment;
121
+ /** Key capability level. */
122
+ keyType: ApiKeyType;
123
+ /** Public preview prefix (e.g. "pk_live_abcd1234"). Raw secret is never persisted. */
124
+ keyPrefix: string;
125
+ /** SHA-256 hash string (64 chars) matching stored database records. */
126
+ keyHash: string;
127
+ /** Whitelisted Origin domains for browser CORS security (e.g. ["https://mybrand.com"]). */
128
+ allowedDomains: string[];
129
+ /** Maximum allowed HTTP requests per minute. */
130
+ rateLimitPerMin: number;
131
+ /** Hard cap for error and event ingestion per calendar month. */
132
+ monthlyEventsLimit: number;
133
+ /** Current count of events processed in the active billing window. */
134
+ currentMonthUsage: number;
135
+ /** Timestamp when the current billing usage cycle resets. */
136
+ usageResetAt: string;
137
+ /** Flag toggle allowing immediate key revocation. */
138
+ isActive: boolean;
139
+ /** Timestamp when the key was last used in any API request. */
140
+ lastUsedAt?: string;
141
+ /** Creation timestamp. */
142
+ createdAt: string;
143
+ }
144
+ /**
145
+ * Payload returned to the developer upon key generation.
146
+ * This is the ONLY time the raw token is made visible.
147
+ *
148
+ * @example
149
+ * const response: GeneratedApiKeyResponse = {
150
+ * apiKey: { ... },
151
+ * rawKey: 'pk_live_a1b2c3d4e5f6...',
152
+ * };
153
+ */
154
+ interface GeneratedApiKeyResponse {
155
+ /** Public or Secret key metadata entity. */
156
+ apiKey: ApiKey;
157
+ /**
158
+ * Plaintext unhashed API key string (e.g., 'pk_live_a1b2c3...').
159
+ * Must be securely copied by developer; cannot be recovered after this response.
160
+ */
161
+ rawKey: string;
162
+ }
163
+ /**
164
+ * DTO for account registration requests.
165
+ *
166
+ * @example
167
+ * const dto: RegisterAccountDto = {
168
+ * name: 'Acme Corp',
169
+ * email: 'admin@acme.com',
170
+ * password: 'S3cur3P@ssw0rd!',
171
+ * };
172
+ */
173
+ interface RegisterAccountDto {
174
+ /** Organization display name. */
175
+ name: string;
176
+ /** Primary contact email. */
177
+ email: string;
178
+ /** Plaintext password (hashed server-side with bcrypt). */
179
+ password: string;
180
+ }
181
+ /**
182
+ * DTO for login requests.
183
+ *
184
+ * @example
185
+ * const dto: LoginDto = {
186
+ * email: 'admin@acme.com',
187
+ * password: 'S3cur3P@ssw0rd!',
188
+ * };
189
+ */
190
+ interface LoginDto {
191
+ /** Registered email address. */
192
+ email: string;
193
+ /** Plaintext password to verify against stored bcrypt hash. */
194
+ password: string;
195
+ }
196
+ /**
197
+ * Session payload embedded in JWT and HttpOnly cookies.
198
+ *
199
+ * @example
200
+ * const session: SessionPayload = {
201
+ * accountId: 'uuid-v4',
202
+ * email: 'admin@acme.com',
203
+ * planTier: 'PRO',
204
+ * };
205
+ */
206
+ interface SessionPayload {
207
+ /** Authenticated account's UUID. */
208
+ accountId: string;
209
+ /** Authenticated account's email. */
210
+ email: string;
211
+ /** Plan tier for feature entitlement checks. */
212
+ planTier: PlanTier;
213
+ }
214
+
215
+ export type { Account, AccountStatus, ApiKey, ApiKeyType, Environment, GeneratedApiKeyResponse, LoginDto, PlanTier, Project, RegisterAccountDto, SessionPayload };
package/dist/auth.mjs ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=auth.mjs.map
3
+ //# sourceMappingURL=auth.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"auth.mjs"}
package/dist/flags.cjs ADDED
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=flags.cjs.map
4
+ //# sourceMappingURL=flags.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"flags.cjs"}