@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.
- package/.turbo/turbo-build.log +52 -0
- package/dist/auth.cjs +4 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.mts +215 -0
- package/dist/auth.d.ts +215 -0
- package/dist/auth.mjs +3 -0
- package/dist/auth.mjs.map +1 -0
- package/dist/flags.cjs +4 -0
- package/dist/flags.cjs.map +1 -0
- package/dist/flags.d.mts +235 -0
- package/dist/flags.d.ts +235 -0
- package/dist/flags.mjs +3 -0
- package/dist/flags.mjs.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/rfc7807.cjs +8 -0
- package/dist/rfc7807.cjs.map +1 -0
- package/dist/rfc7807.d.mts +76 -0
- package/dist/rfc7807.d.ts +76 -0
- package/dist/rfc7807.mjs +6 -0
- package/dist/rfc7807.mjs.map +1 -0
- package/dist/tracker.cjs +4 -0
- package/dist/tracker.cjs.map +1 -0
- package/dist/tracker.d.mts +197 -0
- package/dist/tracker.d.ts +197 -0
- package/dist/tracker.mjs +3 -0
- package/dist/tracker.mjs.map +1 -0
- package/package.json +50 -0
- package/src/auth.ts +224 -0
- package/src/flags.ts +255 -0
- package/src/index.ts +12 -0
- package/src/rfc7807.ts +76 -0
- package/src/tracker.ts +205 -0
- package/tsconfig.json +8 -0
- package/tsup.config.ts +17 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
> @nexussdk/contracts@0.0.1 build /home/runner/work/NexusSDK/NexusSDK/packages/contracts
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
[34mCLI[39m Building entry: src/auth.ts, src/flags.ts, src/index.ts, src/rfc7807.ts, src/tracker.ts
|
|
6
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
+
[34mCLI[39m tsup v8.5.1
|
|
8
|
+
[34mCLI[39m Using tsup config: /home/runner/work/NexusSDK/NexusSDK/packages/contracts/tsup.config.ts
|
|
9
|
+
[34mCLI[39m Target: es2022
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[34mCJS[39m 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
|
+
[32mCJS[39m [1mdist/auth.cjs [22m[32m82.00 B[39m
|
|
20
|
+
[32mCJS[39m [1mdist/flags.cjs [22m[32m84.00 B[39m
|
|
21
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m199.00 B[39m
|
|
22
|
+
[32mCJS[39m [1mdist/rfc7807.cjs [22m[32m203.00 B[39m
|
|
23
|
+
[32mCJS[39m [1mdist/tracker.cjs [22m[32m88.00 B[39m
|
|
24
|
+
[32mCJS[39m [1mdist/auth.cjs.map [22m[32m69.00 B[39m
|
|
25
|
+
[32mCJS[39m [1mdist/flags.cjs.map [22m[32m70.00 B[39m
|
|
26
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m2.58 KB[39m
|
|
27
|
+
[32mCJS[39m [1mdist/rfc7807.cjs.map [22m[32m2.58 KB[39m
|
|
28
|
+
[32mCJS[39m [1mdist/tracker.cjs.map [22m[32m72.00 B[39m
|
|
29
|
+
[32mCJS[39m ⚡️ Build success in 111ms
|
|
30
|
+
[32mESM[39m [1mdist/auth.mjs [22m[32m68.00 B[39m
|
|
31
|
+
[32mESM[39m [1mdist/flags.mjs [22m[32m70.00 B[39m
|
|
32
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m168.00 B[39m
|
|
33
|
+
[32mESM[39m [1mdist/rfc7807.mjs [22m[32m172.00 B[39m
|
|
34
|
+
[32mESM[39m [1mdist/tracker.mjs [22m[32m74.00 B[39m
|
|
35
|
+
[32mESM[39m [1mdist/auth.mjs.map [22m[32m69.00 B[39m
|
|
36
|
+
[32mESM[39m [1mdist/flags.mjs.map [22m[32m70.00 B[39m
|
|
37
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m2.57 KB[39m
|
|
38
|
+
[32mESM[39m [1mdist/rfc7807.mjs.map [22m[32m2.58 KB[39m
|
|
39
|
+
[32mESM[39m [1mdist/tracker.mjs.map [22m[32m72.00 B[39m
|
|
40
|
+
[32mESM[39m ⚡️ Build success in 113ms
|
|
41
|
+
[34mDTS[39m Build start
|
|
42
|
+
[32mDTS[39m ⚡️ Build success in 1002ms
|
|
43
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m607.00 B[39m
|
|
44
|
+
[32mDTS[39m [1mdist/rfc7807.d.mts [22m[32m2.49 KB[39m
|
|
45
|
+
[32mDTS[39m [1mdist/tracker.d.mts [22m[32m6.48 KB[39m
|
|
46
|
+
[32mDTS[39m [1mdist/flags.d.mts [22m[32m7.17 KB[39m
|
|
47
|
+
[32mDTS[39m [1mdist/auth.d.mts [22m[32m6.21 KB[39m
|
|
48
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m603.00 B[39m
|
|
49
|
+
[32mDTS[39m [1mdist/rfc7807.d.ts [22m[32m2.49 KB[39m
|
|
50
|
+
[32mDTS[39m [1mdist/tracker.d.ts [22m[32m6.48 KB[39m
|
|
51
|
+
[32mDTS[39m [1mdist/flags.d.ts [22m[32m7.17 KB[39m
|
|
52
|
+
[32mDTS[39m [1mdist/auth.d.ts [22m[32m6.21 KB[39m
|
package/dist/auth.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"auth.cjs"}
|
package/dist/auth.d.mts
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.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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"auth.mjs"}
|
package/dist/flags.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"flags.cjs"}
|