@inai-dev/types 0.1.0

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/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @inai-dev/types
2
+
3
+ TypeScript type definitions for the InAI Auth SDK. This package contains all shared interfaces and types used across the SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @inai-dev/types
9
+ ```
10
+
11
+ > **Note:** You typically don't need to install this directly. It's included as a dependency of all other `@inai-dev/*` packages.
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import type {
17
+ AuthObject,
18
+ UserResource,
19
+ SessionResource,
20
+ ApplicationResource,
21
+ EnvironmentResource,
22
+ OrganizationResource,
23
+ } from "@inai-dev/types";
24
+ ```
25
+
26
+ ## Exported Types
27
+
28
+ - **Auth**: `AuthObject`, `AuthConfig`, `SignInResult`, `SignUpResult`
29
+ - **Resources**: `UserResource`, `SessionResource`, `ApplicationResource`, `EnvironmentResource`, `OrganizationResource`, `RoleResource`, `PermissionResource`
30
+ - **Config**: `InAIConfig`, `CookieConfig`
31
+
32
+ ## Documentation
33
+
34
+ See the full [API Reference](https://github.com/inai-dev/sdk/blob/main/docs/api-reference.md).
35
+
36
+ ## License
37
+
38
+ [MIT](../../LICENSE)
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var index_exports = {};
18
+ module.exports = __toCommonJS(index_exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type {\n AuthObject,\n ServerAuthObject,\n ProtectedAuthObject,\n JWTClaims,\n} from \"./auth\";\n\nexport type {\n UserResource,\n PlatformUserResource,\n SessionResource,\n OrganizationResource,\n ApplicationResource,\n EnvironmentResource,\n ApplicationStats,\n ApiKeyResource,\n PaginatedResult,\n} from \"./resources\";\n\nexport type {\n InAIAuthConfig,\n InAIMiddlewareConfig,\n InAIAuthSDKConfig,\n} from \"./config\";\n\nexport type {\n LoginParams,\n LoginResult,\n MFAChallengeParams,\n TokenPair,\n SignInResult,\n SignUpResult,\n InAIAuthErrorBody,\n} from \"./results\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,211 @@
1
+ interface AuthObject {
2
+ userId: string | null;
3
+ tenantId: string | null;
4
+ appId: string | null;
5
+ envId: string | null;
6
+ orgId: string | null;
7
+ orgRole: string | null;
8
+ sessionId: string | null;
9
+ getToken: () => Promise<string | null>;
10
+ has: (params: {
11
+ role?: string;
12
+ permission?: string;
13
+ }) => boolean;
14
+ }
15
+ interface ServerAuthObject extends AuthObject {
16
+ protect: (params?: {
17
+ role?: string;
18
+ permission?: string;
19
+ redirectTo?: string;
20
+ }) => ProtectedAuthObject;
21
+ redirectToSignIn: (opts?: {
22
+ returnTo?: string;
23
+ }) => never;
24
+ }
25
+ interface ProtectedAuthObject {
26
+ userId: string;
27
+ tenantId: string;
28
+ appId: string | null;
29
+ envId: string | null;
30
+ orgId: string | null;
31
+ orgRole: string | null;
32
+ sessionId: string | null;
33
+ isSignedIn: true;
34
+ getToken: () => Promise<string>;
35
+ has: (params: {
36
+ role?: string;
37
+ permission?: string;
38
+ }) => boolean;
39
+ }
40
+ interface JWTClaims {
41
+ sub: string;
42
+ type: "app_user" | "platform";
43
+ tenant_id: string;
44
+ env_id?: string;
45
+ app_id?: string;
46
+ email: string;
47
+ roles: string[];
48
+ permissions: string[];
49
+ org_id?: string;
50
+ org_slug?: string;
51
+ org_role?: string;
52
+ org_permissions?: string[];
53
+ external_id?: string;
54
+ iat: number;
55
+ exp: number;
56
+ }
57
+
58
+ interface UserResource {
59
+ id: string;
60
+ tenantId: string;
61
+ email: string;
62
+ firstName: string | null;
63
+ lastName: string | null;
64
+ avatarUrl: string | null;
65
+ isActive: boolean;
66
+ emailVerified: boolean;
67
+ mfaEnabled: boolean;
68
+ externalId: string | null;
69
+ roles: string[];
70
+ createdAt: string;
71
+ updatedAt: string;
72
+ }
73
+ interface PlatformUserResource {
74
+ id: string;
75
+ tenantId: string | null;
76
+ email: string;
77
+ firstName: string | null;
78
+ lastName: string | null;
79
+ avatarUrl: string | null;
80
+ roles: string[];
81
+ createdAt: string;
82
+ updatedAt: string;
83
+ }
84
+ interface SessionResource {
85
+ id: string;
86
+ userId: string;
87
+ tenantId: string;
88
+ environmentId: string | null;
89
+ activeOrgId: string | null;
90
+ expiresAt: string;
91
+ }
92
+ interface OrganizationResource {
93
+ id: string;
94
+ tenantId: string;
95
+ name: string;
96
+ slug: string;
97
+ imageUrl: string | null;
98
+ metadata: Record<string, unknown> | null;
99
+ createdAt: string;
100
+ updatedAt: string;
101
+ }
102
+ interface ApplicationResource {
103
+ id: string;
104
+ tenantId: string;
105
+ name: string;
106
+ slug: string;
107
+ domain: string | null;
108
+ logoUrl: string | null;
109
+ homeUrl: string | null;
110
+ isActive: boolean;
111
+ settings: Record<string, unknown> | null;
112
+ authConfig: Record<string, unknown> | null;
113
+ environments: EnvironmentResource[];
114
+ createdAt: string;
115
+ updatedAt: string;
116
+ }
117
+ interface EnvironmentResource {
118
+ id: string;
119
+ name: string;
120
+ publishableKey: string;
121
+ isActive: boolean;
122
+ }
123
+ interface ApplicationStats {
124
+ totalUsers: number;
125
+ activeSessions: number;
126
+ totalRoles: number;
127
+ totalApiKeys: number;
128
+ environments: Array<{
129
+ id: string;
130
+ name: string;
131
+ userCount: number;
132
+ sessionCount: number;
133
+ }>;
134
+ }
135
+ interface ApiKeyResource {
136
+ id: string;
137
+ name: string;
138
+ keyPrefix: string;
139
+ keyType: string;
140
+ environmentId: string;
141
+ lastUsedAt: string | null;
142
+ expiresAt: string | null;
143
+ createdAt: string;
144
+ }
145
+ interface PaginatedResult<T> {
146
+ data: T[];
147
+ total: number;
148
+ page: number;
149
+ limit: number;
150
+ }
151
+
152
+ interface InAIAuthConfig {
153
+ apiUrl: string;
154
+ publishableKey?: string;
155
+ tenantId?: string;
156
+ }
157
+ interface InAIMiddlewareConfig {
158
+ publicRoutes?: string[] | ((req: unknown) => boolean);
159
+ signInUrl?: string;
160
+ beforeAuth?: (req: unknown) => unknown | void;
161
+ afterAuth?: (auth: unknown, req: unknown) => unknown | void;
162
+ }
163
+ interface InAIAuthSDKConfig {
164
+ signInUrl?: string;
165
+ signUpUrl?: string;
166
+ afterSignInUrl?: string;
167
+ afterSignOutUrl?: string;
168
+ apiUrl?: string;
169
+ publishableKey?: string;
170
+ }
171
+
172
+ interface LoginParams {
173
+ email: string;
174
+ password: string;
175
+ }
176
+ interface LoginResult {
177
+ mfa_required?: boolean;
178
+ mfa_token?: string;
179
+ access_token?: string;
180
+ refresh_token?: string;
181
+ token_type?: string;
182
+ expires_in?: number;
183
+ }
184
+ interface MFAChallengeParams {
185
+ mfa_token: string;
186
+ code: string;
187
+ }
188
+ interface TokenPair {
189
+ access_token: string;
190
+ refresh_token: string;
191
+ token_type: string;
192
+ expires_in: number;
193
+ }
194
+ interface SignInResult {
195
+ status: "complete" | "needs_mfa" | "error";
196
+ mfa_token?: string;
197
+ user?: UserResource;
198
+ error?: string;
199
+ }
200
+ interface SignUpResult {
201
+ status: "complete" | "needs_email_verification" | "error";
202
+ user?: UserResource;
203
+ error?: string;
204
+ }
205
+ interface InAIAuthErrorBody {
206
+ code: string;
207
+ detail: string;
208
+ field?: string;
209
+ }
210
+
211
+ export type { ApiKeyResource, ApplicationResource, ApplicationStats, AuthObject, EnvironmentResource, InAIAuthConfig, InAIAuthErrorBody, InAIAuthSDKConfig, InAIMiddlewareConfig, JWTClaims, LoginParams, LoginResult, MFAChallengeParams, OrganizationResource, PaginatedResult, PlatformUserResource, ProtectedAuthObject, ServerAuthObject, SessionResource, SignInResult, SignUpResult, TokenPair, UserResource };
@@ -0,0 +1,211 @@
1
+ interface AuthObject {
2
+ userId: string | null;
3
+ tenantId: string | null;
4
+ appId: string | null;
5
+ envId: string | null;
6
+ orgId: string | null;
7
+ orgRole: string | null;
8
+ sessionId: string | null;
9
+ getToken: () => Promise<string | null>;
10
+ has: (params: {
11
+ role?: string;
12
+ permission?: string;
13
+ }) => boolean;
14
+ }
15
+ interface ServerAuthObject extends AuthObject {
16
+ protect: (params?: {
17
+ role?: string;
18
+ permission?: string;
19
+ redirectTo?: string;
20
+ }) => ProtectedAuthObject;
21
+ redirectToSignIn: (opts?: {
22
+ returnTo?: string;
23
+ }) => never;
24
+ }
25
+ interface ProtectedAuthObject {
26
+ userId: string;
27
+ tenantId: string;
28
+ appId: string | null;
29
+ envId: string | null;
30
+ orgId: string | null;
31
+ orgRole: string | null;
32
+ sessionId: string | null;
33
+ isSignedIn: true;
34
+ getToken: () => Promise<string>;
35
+ has: (params: {
36
+ role?: string;
37
+ permission?: string;
38
+ }) => boolean;
39
+ }
40
+ interface JWTClaims {
41
+ sub: string;
42
+ type: "app_user" | "platform";
43
+ tenant_id: string;
44
+ env_id?: string;
45
+ app_id?: string;
46
+ email: string;
47
+ roles: string[];
48
+ permissions: string[];
49
+ org_id?: string;
50
+ org_slug?: string;
51
+ org_role?: string;
52
+ org_permissions?: string[];
53
+ external_id?: string;
54
+ iat: number;
55
+ exp: number;
56
+ }
57
+
58
+ interface UserResource {
59
+ id: string;
60
+ tenantId: string;
61
+ email: string;
62
+ firstName: string | null;
63
+ lastName: string | null;
64
+ avatarUrl: string | null;
65
+ isActive: boolean;
66
+ emailVerified: boolean;
67
+ mfaEnabled: boolean;
68
+ externalId: string | null;
69
+ roles: string[];
70
+ createdAt: string;
71
+ updatedAt: string;
72
+ }
73
+ interface PlatformUserResource {
74
+ id: string;
75
+ tenantId: string | null;
76
+ email: string;
77
+ firstName: string | null;
78
+ lastName: string | null;
79
+ avatarUrl: string | null;
80
+ roles: string[];
81
+ createdAt: string;
82
+ updatedAt: string;
83
+ }
84
+ interface SessionResource {
85
+ id: string;
86
+ userId: string;
87
+ tenantId: string;
88
+ environmentId: string | null;
89
+ activeOrgId: string | null;
90
+ expiresAt: string;
91
+ }
92
+ interface OrganizationResource {
93
+ id: string;
94
+ tenantId: string;
95
+ name: string;
96
+ slug: string;
97
+ imageUrl: string | null;
98
+ metadata: Record<string, unknown> | null;
99
+ createdAt: string;
100
+ updatedAt: string;
101
+ }
102
+ interface ApplicationResource {
103
+ id: string;
104
+ tenantId: string;
105
+ name: string;
106
+ slug: string;
107
+ domain: string | null;
108
+ logoUrl: string | null;
109
+ homeUrl: string | null;
110
+ isActive: boolean;
111
+ settings: Record<string, unknown> | null;
112
+ authConfig: Record<string, unknown> | null;
113
+ environments: EnvironmentResource[];
114
+ createdAt: string;
115
+ updatedAt: string;
116
+ }
117
+ interface EnvironmentResource {
118
+ id: string;
119
+ name: string;
120
+ publishableKey: string;
121
+ isActive: boolean;
122
+ }
123
+ interface ApplicationStats {
124
+ totalUsers: number;
125
+ activeSessions: number;
126
+ totalRoles: number;
127
+ totalApiKeys: number;
128
+ environments: Array<{
129
+ id: string;
130
+ name: string;
131
+ userCount: number;
132
+ sessionCount: number;
133
+ }>;
134
+ }
135
+ interface ApiKeyResource {
136
+ id: string;
137
+ name: string;
138
+ keyPrefix: string;
139
+ keyType: string;
140
+ environmentId: string;
141
+ lastUsedAt: string | null;
142
+ expiresAt: string | null;
143
+ createdAt: string;
144
+ }
145
+ interface PaginatedResult<T> {
146
+ data: T[];
147
+ total: number;
148
+ page: number;
149
+ limit: number;
150
+ }
151
+
152
+ interface InAIAuthConfig {
153
+ apiUrl: string;
154
+ publishableKey?: string;
155
+ tenantId?: string;
156
+ }
157
+ interface InAIMiddlewareConfig {
158
+ publicRoutes?: string[] | ((req: unknown) => boolean);
159
+ signInUrl?: string;
160
+ beforeAuth?: (req: unknown) => unknown | void;
161
+ afterAuth?: (auth: unknown, req: unknown) => unknown | void;
162
+ }
163
+ interface InAIAuthSDKConfig {
164
+ signInUrl?: string;
165
+ signUpUrl?: string;
166
+ afterSignInUrl?: string;
167
+ afterSignOutUrl?: string;
168
+ apiUrl?: string;
169
+ publishableKey?: string;
170
+ }
171
+
172
+ interface LoginParams {
173
+ email: string;
174
+ password: string;
175
+ }
176
+ interface LoginResult {
177
+ mfa_required?: boolean;
178
+ mfa_token?: string;
179
+ access_token?: string;
180
+ refresh_token?: string;
181
+ token_type?: string;
182
+ expires_in?: number;
183
+ }
184
+ interface MFAChallengeParams {
185
+ mfa_token: string;
186
+ code: string;
187
+ }
188
+ interface TokenPair {
189
+ access_token: string;
190
+ refresh_token: string;
191
+ token_type: string;
192
+ expires_in: number;
193
+ }
194
+ interface SignInResult {
195
+ status: "complete" | "needs_mfa" | "error";
196
+ mfa_token?: string;
197
+ user?: UserResource;
198
+ error?: string;
199
+ }
200
+ interface SignUpResult {
201
+ status: "complete" | "needs_email_verification" | "error";
202
+ user?: UserResource;
203
+ error?: string;
204
+ }
205
+ interface InAIAuthErrorBody {
206
+ code: string;
207
+ detail: string;
208
+ field?: string;
209
+ }
210
+
211
+ export type { ApiKeyResource, ApplicationResource, ApplicationStats, AuthObject, EnvironmentResource, InAIAuthConfig, InAIAuthErrorBody, InAIAuthSDKConfig, InAIMiddlewareConfig, JWTClaims, LoginParams, LoginResult, MFAChallengeParams, OrganizationResource, PaginatedResult, PlatformUserResource, ProtectedAuthObject, ServerAuthObject, SessionResource, SignInResult, SignUpResult, TokenPair, UserResource };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@inai-dev/types",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript types for the InAI Auth SDK",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": ["dist"],
16
+ "scripts": {
17
+ "build": "tsup",
18
+ "dev": "tsup --watch",
19
+ "clean": "rm -rf dist",
20
+ "typecheck": "tsc --noEmit",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "sideEffects": false,
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "author": "InAI <contact@inai.dev>",
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/inai-dev/sdk.git",
32
+ "directory": "packages/types"
33
+ },
34
+ "homepage": "https://github.com/inai-dev/sdk/tree/main/packages/types",
35
+ "bugs": "https://github.com/inai-dev/sdk/issues",
36
+ "keywords": ["inai", "auth", "types", "typescript", "multi-tenant"]
37
+ }