@openmdm/core 0.2.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/dist/index.d.ts +90 -0
- package/dist/index.js +1368 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +78 -0
- package/dist/schema.js +415 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +899 -0
- package/dist/types.js +49 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
- package/src/index.ts +1145 -0
- package/src/schema.ts +533 -0
- package/src/types.ts +1161 -0
- package/src/webhooks.ts +314 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present OpenMDM Contributors
|
|
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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { WebhookConfig, MDMEvent, WebhookEndpoint, EventType, MDMConfig, MDMInstance } from './types.js';
|
|
2
|
+
export { AppRollback, AppVersion, Application, ApplicationManager, ApplicationNotFoundError, AuthConfig, AuthenticationError, AuthorizationError, Command, CommandFilter, CommandManager, CommandResult, CommandStatus, CommandType, CreateAppRollbackInput, CreateApplicationInput, CreateDeviceInput, CreateGroupInput, CreatePolicyInput, DatabaseAdapter, DeployTarget, Device, DeviceFilter, DeviceListResult, DeviceLocation, DeviceManager, DeviceNotFoundError, DeviceStatus, EnrollmentConfig, EnrollmentError, EnrollmentMethod, EnrollmentRequest, EnrollmentResponse, EventFilter, EventHandler, EventPayloadMap, Group, GroupManager, HardwareControl, Heartbeat, InstalledApp, MDMError, MDMPlugin, PasswordPolicy, PluginMiddleware, PluginRoute, Policy, PolicyApplication, PolicyManager, PolicyNotFoundError, PolicySettings, PushAdapter, PushBatchResult, PushConfig, PushMessage, PushProviderConfig, PushResult, PushToken, RegisterPushTokenInput, SendCommandInput, StorageConfig, SystemUpdatePolicy, TimeWindow, UpdateApplicationInput, UpdateDeviceInput, UpdateGroupInput, UpdatePolicyInput, ValidationError, VpnConfig, WebhookDeliveryResult, WebhookManager, WifiConfig } from './types.js';
|
|
3
|
+
export { ColumnDefinition, ColumnType, IndexDefinition, SchemaDefinition, TableDefinition, camelToSnake, getColumnNames, getPrimaryKey, getTableNames, mdmSchema, snakeToCamel, transformToCamelCase, transformToSnakeCase } from './schema.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* OpenMDM Webhook Delivery System
|
|
7
|
+
*
|
|
8
|
+
* Handles outbound webhook delivery with HMAC signing and retry logic.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface WebhookDeliveryResult {
|
|
12
|
+
endpointId: string;
|
|
13
|
+
success: boolean;
|
|
14
|
+
statusCode?: number;
|
|
15
|
+
error?: string;
|
|
16
|
+
retryCount: number;
|
|
17
|
+
deliveredAt?: Date;
|
|
18
|
+
}
|
|
19
|
+
interface WebhookPayload<T = unknown> {
|
|
20
|
+
id: string;
|
|
21
|
+
event: EventType;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
data: T;
|
|
24
|
+
}
|
|
25
|
+
interface WebhookManager {
|
|
26
|
+
/**
|
|
27
|
+
* Deliver an event to all matching webhook endpoints
|
|
28
|
+
*/
|
|
29
|
+
deliver<T>(event: MDMEvent<T>): Promise<WebhookDeliveryResult[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Add a webhook endpoint at runtime
|
|
32
|
+
*/
|
|
33
|
+
addEndpoint(endpoint: WebhookEndpoint): void;
|
|
34
|
+
/**
|
|
35
|
+
* Remove a webhook endpoint
|
|
36
|
+
*/
|
|
37
|
+
removeEndpoint(endpointId: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Update a webhook endpoint
|
|
40
|
+
*/
|
|
41
|
+
updateEndpoint(endpointId: string, updates: Partial<WebhookEndpoint>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Get all configured endpoints
|
|
44
|
+
*/
|
|
45
|
+
getEndpoints(): WebhookEndpoint[];
|
|
46
|
+
/**
|
|
47
|
+
* Test a webhook endpoint with a test payload
|
|
48
|
+
*/
|
|
49
|
+
testEndpoint(endpointId: string): Promise<WebhookDeliveryResult>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a webhook manager instance
|
|
53
|
+
*/
|
|
54
|
+
declare function createWebhookManager(config: WebhookConfig): WebhookManager;
|
|
55
|
+
/**
|
|
56
|
+
* Verify a webhook signature from incoming requests
|
|
57
|
+
* (Utility for consumers to verify our webhooks)
|
|
58
|
+
*/
|
|
59
|
+
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* OpenMDM Core
|
|
63
|
+
*
|
|
64
|
+
* A flexible, embeddable MDM (Mobile Device Management) SDK.
|
|
65
|
+
* Inspired by better-auth's design philosophy.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { createMDM } from '@openmdm/core';
|
|
70
|
+
* import { drizzleAdapter } from '@openmdm/drizzle-adapter';
|
|
71
|
+
*
|
|
72
|
+
* const mdm = createMDM({
|
|
73
|
+
* database: drizzleAdapter(db),
|
|
74
|
+
* enrollment: {
|
|
75
|
+
* deviceSecret: process.env.DEVICE_HMAC_SECRET!,
|
|
76
|
+
* autoEnroll: true,
|
|
77
|
+
* },
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Use in your routes
|
|
81
|
+
* const devices = await mdm.devices.list();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create an MDM instance with the given configuration.
|
|
87
|
+
*/
|
|
88
|
+
declare function createMDM(config: MDMConfig): MDMInstance;
|
|
89
|
+
|
|
90
|
+
export { EventType, MDMConfig, MDMEvent, MDMInstance, WebhookConfig, WebhookEndpoint, type WebhookPayload, createMDM, createWebhookManager, verifyWebhookSignature };
|