@devorash/core 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/LICENSE +21 -0
- package/README.md +187 -0
- package/dist/constants/api-url.gen.d.ts +4 -0
- package/dist/constants/api-url.gen.d.ts.map +1 -0
- package/dist/constants/api-url.gen.example.d.ts +7 -0
- package/dist/constants/api-url.gen.example.d.ts.map +1 -0
- package/dist/constants/api-url.gen.example.js +7 -0
- package/dist/constants/api-url.gen.example.js.map +1 -0
- package/dist/constants/api-url.gen.js +4 -0
- package/dist/constants/api-url.gen.js.map +1 -0
- package/dist/constants/index.d.ts +203 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +236 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants/sessionLifecycle.d.ts +22 -0
- package/dist/constants/sessionLifecycle.d.ts.map +1 -0
- package/dist/constants/sessionLifecycle.js +21 -0
- package/dist/constants/sessionLifecycle.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/security/index.d.ts +118 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +345 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/request-body.d.ts +16 -0
- package/dist/security/request-body.d.ts.map +1 -0
- package/dist/security/request-body.js +84 -0
- package/dist/security/request-body.js.map +1 -0
- package/dist/security/signing.d.ts +127 -0
- package/dist/security/signing.d.ts.map +1 -0
- package/dist/security/signing.js +297 -0
- package/dist/security/signing.js.map +1 -0
- package/dist/types/index.d.ts +487 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +211 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +600 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Devora
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# @devorash/core
|
|
2
|
+
|
|
3
|
+
Core utilities, types, and constants shared across all Devora SDKs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @devorash/core
|
|
9
|
+
# or
|
|
10
|
+
bun add @devorash/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
This package is primarily used as a dependency by other Devora SDK packages. You typically won't need to install it directly unless you're building custom integrations.
|
|
16
|
+
|
|
17
|
+
### Types
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import type {
|
|
21
|
+
DevoraRequest,
|
|
22
|
+
DevoraResponse,
|
|
23
|
+
ImpersonationScope,
|
|
24
|
+
BackendSDKConfig,
|
|
25
|
+
FrontendSDKConfig,
|
|
26
|
+
} from "@devorash/core"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Constants
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { DEVORA_ENDPOINTS, SECURITY_HEADERS, SDK_DEFAULTS, SDK_VERSION } from "@devorash/core"
|
|
33
|
+
|
|
34
|
+
// Use predefined endpoints for type safety
|
|
35
|
+
console.log(DEVORA_ENDPOINTS.USER_SEARCH) // "/user/search"
|
|
36
|
+
console.log(DEVORA_ENDPOINTS.USER_BY_ID) // "/user/:id"
|
|
37
|
+
console.log(DEVORA_ENDPOINTS.IMPERSONATE) // "/impersonate/:id"
|
|
38
|
+
console.log(DEVORA_ENDPOINTS.TERMINATE) // "/impersonate/:id/terminate"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Security Utilities
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import {
|
|
45
|
+
validateTimestamp,
|
|
46
|
+
extractSecurityHeaders,
|
|
47
|
+
timingSafeEqual,
|
|
48
|
+
isWriteMethod,
|
|
49
|
+
} from "@devorash/core"
|
|
50
|
+
|
|
51
|
+
// Validate request timestamp
|
|
52
|
+
const { valid, error } = validateTimestamp(requestTimestamp)
|
|
53
|
+
|
|
54
|
+
// Check if HTTP method is a write operation (blocked in read-only mode)
|
|
55
|
+
if (isWriteMethod("POST")) {
|
|
56
|
+
console.log("This is a write operation")
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Utility Functions
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import {
|
|
64
|
+
matchPath,
|
|
65
|
+
createSuccessResponse,
|
|
66
|
+
createErrorResponse,
|
|
67
|
+
validateApiKeyFormat,
|
|
68
|
+
} from "@devorash/core"
|
|
69
|
+
|
|
70
|
+
// Match path patterns
|
|
71
|
+
const { match, params } = matchPath("/impersonate/:id", "/impersonate/user123")
|
|
72
|
+
console.log(match) // true
|
|
73
|
+
console.log(params) // { id: "user123" }
|
|
74
|
+
|
|
75
|
+
// Create SDK responses
|
|
76
|
+
const success = createSuccessResponse({ users: [] })
|
|
77
|
+
const error = createErrorResponse("Not found", "NOT_FOUND")
|
|
78
|
+
|
|
79
|
+
// Validate API key format
|
|
80
|
+
const validation = validateApiKeyFormat("pk_server_live_abc123")
|
|
81
|
+
console.log(validation) // { valid: true, type: "server", environment: "live" }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Exports
|
|
85
|
+
|
|
86
|
+
### Subpath Exports
|
|
87
|
+
|
|
88
|
+
This package supports subpath exports for tree-shaking:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// Import only types
|
|
92
|
+
import type { DevoraRequest } from "@devorash/core/types"
|
|
93
|
+
|
|
94
|
+
// Import only constants
|
|
95
|
+
import { DEVORA_ENDPOINTS } from "@devorash/core/constants"
|
|
96
|
+
|
|
97
|
+
// Import only security utilities
|
|
98
|
+
import { validateTimestamp } from "@devorash/core/security"
|
|
99
|
+
|
|
100
|
+
// Import only utility functions
|
|
101
|
+
import { matchPath } from "@devorash/core/utils"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## API Reference
|
|
105
|
+
|
|
106
|
+
### Types
|
|
107
|
+
|
|
108
|
+
| Type | Description |
|
|
109
|
+
| -------------------- | -------------------------------------------- |
|
|
110
|
+
| `DevoraRequest` | Normalized request object passed to handlers |
|
|
111
|
+
| `DevoraResponse` | Standard response format |
|
|
112
|
+
| `DevoraUser` | User object for search results |
|
|
113
|
+
| `ImpersonationScope` | "read" or "write" scope |
|
|
114
|
+
| `BackendSDKConfig` | Backend SDK configuration |
|
|
115
|
+
| `FrontendSDKConfig` | Frontend SDK configuration |
|
|
116
|
+
| `RouteDefinition` | Route handler definition |
|
|
117
|
+
| `LogEvent` | Activity log event |
|
|
118
|
+
|
|
119
|
+
### Constants
|
|
120
|
+
|
|
121
|
+
| Constant | Description |
|
|
122
|
+
| ------------------ | ------------------------------- |
|
|
123
|
+
| `DEVORA_ENDPOINTS` | Predefined endpoint paths |
|
|
124
|
+
| `SECURITY_HEADERS` | HTTP header names for HMAC auth |
|
|
125
|
+
| `SDK_DEFAULTS` | Default configuration values |
|
|
126
|
+
| `ERROR_CODES` | SDK error codes |
|
|
127
|
+
| `WRITE_METHODS` | HTTP methods considered writes |
|
|
128
|
+
|
|
129
|
+
### Security Functions
|
|
130
|
+
|
|
131
|
+
| Function | Description |
|
|
132
|
+
| --------------------------- | ------------------------------------- |
|
|
133
|
+
| `validateTimestamp()` | Validate request timestamp |
|
|
134
|
+
| `extractSecurityHeaders()` | Extract security headers from request |
|
|
135
|
+
| `validateSecurityHeaders()` | Full security validation |
|
|
136
|
+
| `timingSafeEqual()` | Timing-safe string comparison |
|
|
137
|
+
| `isWriteMethod()` | Check if method is a write operation |
|
|
138
|
+
|
|
139
|
+
### Utility Functions
|
|
140
|
+
|
|
141
|
+
| Function | Description |
|
|
142
|
+
| ------------------------- | ---------------------------------- |
|
|
143
|
+
| `matchPath()` | Match path pattern with parameters |
|
|
144
|
+
| `createSuccessResponse()` | Create success response |
|
|
145
|
+
| `createErrorResponse()` | Create error response |
|
|
146
|
+
| `validateApiKeyFormat()` | Validate API key format |
|
|
147
|
+
|
|
148
|
+
### Logger Service
|
|
149
|
+
|
|
150
|
+
The SDK includes a configurable logger service that automatically adjusts based on environment.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { configureLogger, LogLevel, createLogger } from "@devorash/core"
|
|
154
|
+
|
|
155
|
+
// Configure globally at app initialization (optional)
|
|
156
|
+
configureLogger({
|
|
157
|
+
level: LogLevel.DEBUG, // DEBUG, INFO, WARN, ERROR, SILENT
|
|
158
|
+
enabled: true, // Override auto-detection
|
|
159
|
+
includeTimestamp: true, // Add timestamps to log messages
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
// Create a logger instance
|
|
163
|
+
const logger = createLogger("MyComponent")
|
|
164
|
+
|
|
165
|
+
logger.debug("Verbose debugging info") // Only in development
|
|
166
|
+
logger.info("General information") // Only if level <= INFO
|
|
167
|
+
logger.warn("Warning message") // Only if level <= WARN
|
|
168
|
+
logger.error("Error message") // Always logged (unless disabled)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Environment Auto-Detection:**
|
|
172
|
+
|
|
173
|
+
- Development: `NODE_ENV=development` or running on `localhost`
|
|
174
|
+
- Production: All other cases (logging disabled by default)
|
|
175
|
+
|
|
176
|
+
**Log Levels:**
|
|
177
|
+
| Level | Value | Description |
|
|
178
|
+
|-------|-------|-------------|
|
|
179
|
+
| `DEBUG` | 0 | Verbose debugging (dev only) |
|
|
180
|
+
| `INFO` | 1 | General information |
|
|
181
|
+
| `WARN` | 2 | Warnings (default in dev) |
|
|
182
|
+
| `ERROR` | 3 | Errors only (default in prod) |
|
|
183
|
+
| `SILENT` | 4 | No logging |
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-url.gen.d.ts","sourceRoot":"","sources":["../../src/constants/api-url.gen.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,eAAO,MAAM,iBAAiB,EAAG,qCAA8C,CAAA;AAC/E,eAAO,MAAM,uBAAuB,EAAG,uBAAgC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example of the generated api-url.gen.ts file.
|
|
3
|
+
* Run: node packages/sdks/scripts/generate-api-url.mjs (with DEVORA_SDK_API_ORIGIN set)
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEVORA_API_ORIGIN: "https://YOUR_DEPLOYMENT.convex.site";
|
|
6
|
+
export declare const DEVORA_DASHBOARD_ORIGIN: "https://app.devora.sh";
|
|
7
|
+
//# sourceMappingURL=api-url.gen.example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-url.gen.example.d.ts","sourceRoot":"","sources":["../../src/constants/api-url.gen.example.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAG,qCAA8C,CAAA;AAC/E,eAAO,MAAM,uBAAuB,EAAG,uBAAgC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example of the generated api-url.gen.ts file.
|
|
3
|
+
* Run: node packages/sdks/scripts/generate-api-url.mjs (with DEVORA_SDK_API_ORIGIN set)
|
|
4
|
+
*/
|
|
5
|
+
export const DEVORA_API_ORIGIN = "https://YOUR_DEPLOYMENT.convex.site";
|
|
6
|
+
export const DEVORA_DASHBOARD_ORIGIN = "https://app.devora.sh";
|
|
7
|
+
//# sourceMappingURL=api-url.gen.example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-url.gen.example.js","sourceRoot":"","sources":["../../src/constants/api-url.gen.example.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,qCAA8C,CAAA;AAC/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAgC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-url.gen.js","sourceRoot":"","sources":["../../src/constants/api-url.gen.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,qCAA8C,CAAA;AAC/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAgC,CAAA"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for Devora SDKs
|
|
3
|
+
* @module @devorash/core/constants
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Predefined endpoint constants for Devora SDK integration.
|
|
7
|
+
* Using these constants ensures:
|
|
8
|
+
* - Typo prevention (/impersonation vs /impersonate)
|
|
9
|
+
* - Automatic HTTP method detection
|
|
10
|
+
* - IDE autocomplete and documentation
|
|
11
|
+
* - Consistency across all customer integrations
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEVORA_ENDPOINTS: {
|
|
14
|
+
/**
|
|
15
|
+
* User search endpoint - allows Devora to search customer's users
|
|
16
|
+
* @method GET
|
|
17
|
+
* @path /user/search
|
|
18
|
+
* @query term - Search term (name, email, or user ID)
|
|
19
|
+
*/
|
|
20
|
+
readonly USER_SEARCH: "/user/search";
|
|
21
|
+
/**
|
|
22
|
+
* Get user by ID endpoint - retrieves a specific user's details
|
|
23
|
+
* @method GET
|
|
24
|
+
* @path /user/:id
|
|
25
|
+
* @params id - User ID to look up
|
|
26
|
+
*/
|
|
27
|
+
readonly USER_BY_ID: "/user/:id";
|
|
28
|
+
/**
|
|
29
|
+
* Impersonation start endpoint - generates auth token for session
|
|
30
|
+
* @method POST
|
|
31
|
+
* @path /impersonate/:id
|
|
32
|
+
* @params id - Target user ID to impersonate
|
|
33
|
+
*/
|
|
34
|
+
readonly IMPERSONATE: "/impersonate/:id";
|
|
35
|
+
/**
|
|
36
|
+
* Session termination endpoint - revokes impersonation session
|
|
37
|
+
* @method DELETE
|
|
38
|
+
* @path /impersonate/:id/terminate
|
|
39
|
+
* @params id - Session ID to terminate
|
|
40
|
+
*/
|
|
41
|
+
readonly TERMINATE: "/impersonate/:id/terminate";
|
|
42
|
+
/**
|
|
43
|
+
* Connection test endpoint - validates SDK setup (built-in)
|
|
44
|
+
* @method GET
|
|
45
|
+
* @path /test
|
|
46
|
+
* @internal This endpoint is automatically provided by the SDK
|
|
47
|
+
*/
|
|
48
|
+
readonly TEST: "/test";
|
|
49
|
+
/**
|
|
50
|
+
* Health check endpoint - SDK health and metrics (built-in)
|
|
51
|
+
* @method GET
|
|
52
|
+
* @path /health
|
|
53
|
+
* @internal This endpoint is automatically provided by the SDK
|
|
54
|
+
*/
|
|
55
|
+
readonly HEALTH: "/health";
|
|
56
|
+
};
|
|
57
|
+
/** Type for endpoint keys */
|
|
58
|
+
export type DevoraEndpointKey = keyof typeof DEVORA_ENDPOINTS;
|
|
59
|
+
/** Type for endpoint values */
|
|
60
|
+
export type DevoraEndpointPath = (typeof DEVORA_ENDPOINTS)[keyof typeof DEVORA_ENDPOINTS];
|
|
61
|
+
/**
|
|
62
|
+
* HTTP methods for each endpoint (auto-detected when using constants)
|
|
63
|
+
*/
|
|
64
|
+
export declare const ENDPOINT_METHODS: Record<DevoraEndpointPath, "GET" | "POST" | "DELETE">;
|
|
65
|
+
/**
|
|
66
|
+
* Built-in endpoints that cannot be overridden
|
|
67
|
+
*/
|
|
68
|
+
export declare const PROTECTED_ENDPOINTS: readonly DevoraEndpointPath[];
|
|
69
|
+
/**
|
|
70
|
+
* HTTP headers used for HMAC authentication
|
|
71
|
+
*/
|
|
72
|
+
export declare const SECURITY_HEADERS: {
|
|
73
|
+
/** HMAC-SHA256 signature (hex encoded) */
|
|
74
|
+
readonly SIGNATURE: "x-devora-signature";
|
|
75
|
+
/** Unix timestamp in seconds when request was sent */
|
|
76
|
+
readonly SENT_AT: "x-devora-sent-at";
|
|
77
|
+
/** API Key ID (public identifier) */
|
|
78
|
+
readonly KEY_ID: "x-devora-key-id";
|
|
79
|
+
/** Organization ID */
|
|
80
|
+
readonly ORG_ID: "x-devora-org-id";
|
|
81
|
+
/** Unique request identifier used for replay prevention */
|
|
82
|
+
readonly REQUEST_ID: "x-devora-request-id";
|
|
83
|
+
/** Signature payload version */
|
|
84
|
+
readonly SIGNATURE_VERSION: "x-devora-signature-version";
|
|
85
|
+
/** Session ID (for impersonation requests) */
|
|
86
|
+
readonly SESSION_ID: "x-devora-session-id";
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Frontend SDK headers
|
|
90
|
+
*/
|
|
91
|
+
export declare const FRONTEND_HEADERS: {
|
|
92
|
+
/** Client API Key */
|
|
93
|
+
readonly API_KEY: "x-devora-key";
|
|
94
|
+
/** Session ID */
|
|
95
|
+
readonly SESSION: "x-devora-session";
|
|
96
|
+
/** Short-lived impersonation-session bearer token (never the customer auth token). */
|
|
97
|
+
readonly SESSION_TOKEN: "x-devora-session-token";
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* URL parameters used for impersonation payload passing
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* Browser-session bridge: the customer route the browser SDK calls to restore
|
|
104
|
+
* an impersonation session in a new tab. Always allowed by the scope guards
|
|
105
|
+
* because it only mints a Devora resume code for an already-authenticated
|
|
106
|
+
* customer session.
|
|
107
|
+
*/
|
|
108
|
+
export declare const BROWSER_SESSION_BRIDGE: {
|
|
109
|
+
/** Default customer route path. */
|
|
110
|
+
readonly PATH: "/api/devora/browser-session";
|
|
111
|
+
/** Devora endpoint the customer backend calls with a signed server request. */
|
|
112
|
+
readonly RESUME_CODE_ENDPOINT: "/api/sdk/browser-resume-code";
|
|
113
|
+
/** Devora endpoint the browser calls to redeem the code for its own capability. */
|
|
114
|
+
readonly RESUME_ENDPOINT: "/api/sdk/browser-resume";
|
|
115
|
+
/** Non-secret per-tab identifier shape (also stored in sessionStorage). */
|
|
116
|
+
readonly TAB_REF_PATTERN: RegExp;
|
|
117
|
+
};
|
|
118
|
+
export declare const URL_PARAMS: {
|
|
119
|
+
/** One-time code exchanged for the encrypted impersonation payload */
|
|
120
|
+
readonly EXCHANGE_CODE: "devora_exchange";
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Default SDK configuration values
|
|
124
|
+
*/
|
|
125
|
+
export declare const SDK_DEFAULTS: {
|
|
126
|
+
/** Devora API origin baked into the SDK package at build time. */
|
|
127
|
+
readonly API_URL: "https://beloved-bee-737.convex.site";
|
|
128
|
+
/**
|
|
129
|
+
* The Devora dashboard origin, baked in at build time. Only a tab at this
|
|
130
|
+
* origin (or, for a customer app on loopback, a loopback dashboard) may hand
|
|
131
|
+
* an exchange verifier to the browser SDK.
|
|
132
|
+
*/
|
|
133
|
+
readonly DASHBOARD_ORIGIN: "https://app.devora.sh";
|
|
134
|
+
/** Timestamp tolerance in seconds (5 minutes) */
|
|
135
|
+
readonly TIMESTAMP_TOLERANCE: 300;
|
|
136
|
+
/** Log batch size before flush */
|
|
137
|
+
readonly LOG_BATCH_SIZE: 10;
|
|
138
|
+
/** Log flush interval in milliseconds (5 seconds) */
|
|
139
|
+
readonly LOG_FLUSH_INTERVAL: 5000;
|
|
140
|
+
/** Maximum log queue size */
|
|
141
|
+
readonly MAX_LOG_QUEUE_SIZE: 100;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* SDK package names
|
|
145
|
+
*/
|
|
146
|
+
export declare const SDK_PACKAGES: {
|
|
147
|
+
readonly CORE: "@devorash/core";
|
|
148
|
+
readonly NODE: "@devorash/node";
|
|
149
|
+
readonly BROWSER: "@devorash/browser";
|
|
150
|
+
readonly EXPRESS: "@devorash/express";
|
|
151
|
+
readonly HONO: "@devorash/hono";
|
|
152
|
+
readonly FASTIFY: "@devorash/fastify";
|
|
153
|
+
readonly REACT: "@devorash/react";
|
|
154
|
+
readonly VUE: "@devorash/vue";
|
|
155
|
+
readonly SVELTE: "@devorash/svelte";
|
|
156
|
+
readonly SOLID: "@devorash/solid";
|
|
157
|
+
readonly NEXT: "@devorash/nextjs";
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Current SDK version (synced across all packages)
|
|
161
|
+
*/
|
|
162
|
+
export declare const SDK_VERSION = "0.1.0";
|
|
163
|
+
/**
|
|
164
|
+
* SDK error codes
|
|
165
|
+
*/
|
|
166
|
+
export declare const ERROR_CODES: {
|
|
167
|
+
readonly MISSING_HEADERS: "DEVORA_101";
|
|
168
|
+
readonly INVALID_TIMESTAMP: "DEVORA_102";
|
|
169
|
+
readonly TIMESTAMP_EXPIRED: "DEVORA_103";
|
|
170
|
+
readonly INVALID_SIGNATURE: "DEVORA_104";
|
|
171
|
+
readonly ORG_MISMATCH: "DEVORA_105";
|
|
172
|
+
readonly KEY_NOT_FOUND: "DEVORA_106";
|
|
173
|
+
readonly KEY_REVOKED: "DEVORA_107";
|
|
174
|
+
readonly MISSING_SIGNATURE: "DEVORA_108";
|
|
175
|
+
readonly INVALID_CONFIG: "DEVORA_201";
|
|
176
|
+
readonly MISSING_ENDPOINT: "DEVORA_202";
|
|
177
|
+
readonly INVALID_HANDLER: "DEVORA_203";
|
|
178
|
+
readonly DUPLICATE_ENDPOINT: "DEVORA_204";
|
|
179
|
+
readonly BODY_TOO_LARGE: "DEVORA_205";
|
|
180
|
+
readonly INVALID_API_KEY: "DEVORA_206";
|
|
181
|
+
readonly INVALID_ORG_ID: "DEVORA_207";
|
|
182
|
+
readonly HANDLER_ERROR: "DEVORA_301";
|
|
183
|
+
readonly NETWORK_ERROR: "DEVORA_302";
|
|
184
|
+
readonly SESSION_EXPIRED: "DEVORA_303";
|
|
185
|
+
readonly TOKEN_CONSUMED: "DEVORA_304";
|
|
186
|
+
readonly SCOPE_VIOLATION: "DEVORA_401";
|
|
187
|
+
readonly WRITE_BLOCKED: "DEVORA_402";
|
|
188
|
+
readonly RATE_LIMITED: "DEVORA_501";
|
|
189
|
+
readonly TOO_MANY_REQUESTS: "DEVORA_502";
|
|
190
|
+
};
|
|
191
|
+
export type DevoraErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
192
|
+
/**
|
|
193
|
+
* HTTP methods considered as write operations (blocked in read-only mode)
|
|
194
|
+
*/
|
|
195
|
+
export declare const WRITE_METHODS: readonly ["POST", "PUT", "DELETE", "PATCH"];
|
|
196
|
+
/**
|
|
197
|
+
* HTTP methods considered as read operations (allowed in read-only mode)
|
|
198
|
+
*/
|
|
199
|
+
export declare const READ_METHODS: readonly ["GET", "HEAD", "OPTIONS"];
|
|
200
|
+
export type WriteMethod = (typeof WRITE_METHODS)[number];
|
|
201
|
+
export type ReadMethod = (typeof READ_METHODS)[number];
|
|
202
|
+
export * from "./sessionLifecycle.js";
|
|
203
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;IAC5B;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;;CAEM,CAAA;AAEV,6BAA6B;AAC7B,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,gBAAgB,CAAA;AAE7D,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAA;AAEzF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,kBAAkB,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAOlF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,kBAAkB,EAG5D,CAAA;AAMD;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC5B,0CAA0C;;IAE1C,sDAAsD;;IAEtD,qCAAqC;;IAErC,sBAAsB;;IAEtB,2DAA2D;;IAE3D,gCAAgC;;IAEhC,8CAA8C;;CAErC,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC5B,qBAAqB;;IAErB,iBAAiB;;IAEjB,sFAAsF;;CAE7E,CAAA;AAMV;;GAEG;AACH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;IAClC,mCAAmC;;IAEnC,+EAA+E;;IAE/E,mFAAmF;;IAEnF,2EAA2E;;CAElE,CAAA;AAEV,eAAO,MAAM,UAAU;IACtB,sEAAsE;;CAE7D,CAAA;AAQV;;GAEG;AACH,eAAO,MAAM,YAAY;IACxB,kEAAkE;;IAElE;;;;OAIG;;IAEH,iDAAiD;;IAEjD,kCAAkC;;IAElC,qDAAqD;;IAErD,6BAA6B;;CAEpB,CAAA;AAMV;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;CAYf,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,WAAW,UAAU,CAAA;AAMlC;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;CAiCd,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAA;AAM5E;;GAEG;AACH,eAAO,MAAM,aAAa,6CAA8C,CAAA;AAExE;;GAEG;AACH,eAAO,MAAM,YAAY,qCAAsC,CAAA;AAE/D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAMtD,cAAc,uBAAuB,CAAA"}
|