@sentriflow/core 0.1.2 → 0.1.4

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.
Files changed (74) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/package.json +60 -60
  4. package/src/constants.ts +0 -0
  5. package/src/engine/RuleExecutor.ts +0 -0
  6. package/src/engine/Runner.ts +0 -0
  7. package/src/engine/SandboxedExecutor.ts +0 -0
  8. package/src/errors.ts +0 -0
  9. package/src/helpers/arista/helpers.ts +0 -0
  10. package/src/helpers/arista/index.ts +0 -0
  11. package/src/helpers/aruba/helpers.ts +0 -0
  12. package/src/helpers/aruba/index.ts +0 -0
  13. package/src/helpers/cisco/helpers.ts +0 -0
  14. package/src/helpers/cisco/index.ts +0 -0
  15. package/src/helpers/common/helpers.ts +0 -0
  16. package/src/helpers/common/index.ts +0 -0
  17. package/src/helpers/common/validation.ts +0 -0
  18. package/src/helpers/cumulus/helpers.ts +0 -0
  19. package/src/helpers/cumulus/index.ts +0 -0
  20. package/src/helpers/extreme/helpers.ts +0 -0
  21. package/src/helpers/extreme/index.ts +0 -0
  22. package/src/helpers/fortinet/helpers.ts +0 -0
  23. package/src/helpers/fortinet/index.ts +0 -0
  24. package/src/helpers/huawei/helpers.ts +0 -0
  25. package/src/helpers/huawei/index.ts +0 -0
  26. package/src/helpers/index.ts +0 -0
  27. package/src/helpers/juniper/helpers.ts +0 -0
  28. package/src/helpers/juniper/index.ts +0 -0
  29. package/src/helpers/mikrotik/helpers.ts +0 -0
  30. package/src/helpers/mikrotik/index.ts +0 -0
  31. package/src/helpers/nokia/helpers.ts +0 -0
  32. package/src/helpers/nokia/index.ts +0 -0
  33. package/src/helpers/paloalto/helpers.ts +0 -0
  34. package/src/helpers/paloalto/index.ts +0 -0
  35. package/src/helpers/vyos/helpers.ts +0 -0
  36. package/src/helpers/vyos/index.ts +0 -0
  37. package/src/index.ts +3 -0
  38. package/src/json-rules/ExpressionEvaluator.ts +0 -0
  39. package/src/json-rules/HelperRegistry.ts +0 -0
  40. package/src/json-rules/JsonRuleCompiler.ts +0 -0
  41. package/src/json-rules/JsonRuleValidator.ts +0 -0
  42. package/src/json-rules/index.ts +0 -0
  43. package/src/json-rules/schema.json +0 -0
  44. package/src/json-rules/types.ts +0 -0
  45. package/src/pack-loader/PackLoader.ts +0 -0
  46. package/src/pack-loader/index.ts +0 -0
  47. package/src/pack-loader/types.ts +0 -0
  48. package/src/pack-provider/LocalPackProvider.ts +194 -0
  49. package/src/pack-provider/PackProvider.ts +160 -0
  50. package/src/pack-provider/index.ts +116 -0
  51. package/src/parser/IncrementalParser.ts +0 -0
  52. package/src/parser/Sanitizer.ts +0 -0
  53. package/src/parser/SchemaAwareParser.ts +0 -0
  54. package/src/parser/VendorSchema.ts +0 -0
  55. package/src/parser/vendors/arista-eos.ts +0 -0
  56. package/src/parser/vendors/aruba-aoscx.ts +0 -0
  57. package/src/parser/vendors/aruba-aosswitch.ts +0 -0
  58. package/src/parser/vendors/aruba-wlc.ts +0 -0
  59. package/src/parser/vendors/cisco-ios.ts +0 -0
  60. package/src/parser/vendors/cisco-nxos.ts +0 -0
  61. package/src/parser/vendors/cumulus-linux.ts +0 -0
  62. package/src/parser/vendors/extreme-exos.ts +0 -0
  63. package/src/parser/vendors/extreme-voss.ts +0 -0
  64. package/src/parser/vendors/fortinet-fortigate.ts +0 -0
  65. package/src/parser/vendors/huawei-vrp.ts +0 -0
  66. package/src/parser/vendors/index.ts +0 -0
  67. package/src/parser/vendors/juniper-junos.ts +0 -0
  68. package/src/parser/vendors/mikrotik-routeros.ts +0 -0
  69. package/src/parser/vendors/nokia-sros.ts +0 -0
  70. package/src/parser/vendors/paloalto-panos.ts +0 -0
  71. package/src/parser/vendors/vyos-vyos.ts +0 -0
  72. package/src/types/ConfigNode.ts +0 -0
  73. package/src/types/DeclarativeRule.ts +0 -0
  74. package/src/types/IRule.ts +0 -0
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
package/package.json CHANGED
@@ -1,60 +1,60 @@
1
- {
2
- "name": "@sentriflow/core",
3
- "version": "0.1.2",
4
- "description": "SentriFlow core engine for network configuration validation",
5
- "license": "Apache-2.0",
6
- "module": "src/index.ts",
7
- "type": "module",
8
- "exports": {
9
- ".": "./src/index.ts",
10
- "./helpers": "./src/helpers/index.ts",
11
- "./helpers/common": "./src/helpers/common/index.ts",
12
- "./helpers/arista": "./src/helpers/arista/index.ts",
13
- "./helpers/aruba": "./src/helpers/aruba/index.ts",
14
- "./helpers/cisco": "./src/helpers/cisco/index.ts",
15
- "./helpers/cumulus": "./src/helpers/cumulus/index.ts",
16
- "./helpers/extreme": "./src/helpers/extreme/index.ts",
17
- "./helpers/fortinet": "./src/helpers/fortinet/index.ts",
18
- "./helpers/huawei": "./src/helpers/huawei/index.ts",
19
- "./helpers/juniper": "./src/helpers/juniper/index.ts",
20
- "./helpers/mikrotik": "./src/helpers/mikrotik/index.ts",
21
- "./helpers/nokia": "./src/helpers/nokia/index.ts",
22
- "./helpers/paloalto": "./src/helpers/paloalto/index.ts",
23
- "./helpers/vyos": "./src/helpers/vyos/index.ts"
24
- },
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/sentriflow/sentriflow.git",
28
- "directory": "packages/core"
29
- },
30
- "homepage": "https://github.com/sentriflow/sentriflow#readme",
31
- "bugs": {
32
- "url": "https://github.com/sentriflow/sentriflow/issues"
33
- },
34
- "keywords": [
35
- "network",
36
- "configuration",
37
- "validation",
38
- "security",
39
- "cisco",
40
- "juniper",
41
- "arista",
42
- "firewall",
43
- "linter",
44
- "helpers"
45
- ],
46
- "files": [
47
- "src",
48
- "LICENSE",
49
- "README.md"
50
- ],
51
- "publishConfig": {
52
- "access": "public"
53
- },
54
- "devDependencies": {
55
- "bun-types": "latest"
56
- },
57
- "peerDependencies": {
58
- "typescript": "^5.0.0"
59
- }
60
- }
1
+ {
2
+ "name": "@sentriflow/core",
3
+ "version": "0.1.4",
4
+ "description": "SentriFlow core engine for network configuration validation",
5
+ "license": "Apache-2.0",
6
+ "module": "src/index.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": "./src/index.ts",
10
+ "./helpers": "./src/helpers/index.ts",
11
+ "./helpers/common": "./src/helpers/common/index.ts",
12
+ "./helpers/arista": "./src/helpers/arista/index.ts",
13
+ "./helpers/aruba": "./src/helpers/aruba/index.ts",
14
+ "./helpers/cisco": "./src/helpers/cisco/index.ts",
15
+ "./helpers/cumulus": "./src/helpers/cumulus/index.ts",
16
+ "./helpers/extreme": "./src/helpers/extreme/index.ts",
17
+ "./helpers/fortinet": "./src/helpers/fortinet/index.ts",
18
+ "./helpers/huawei": "./src/helpers/huawei/index.ts",
19
+ "./helpers/juniper": "./src/helpers/juniper/index.ts",
20
+ "./helpers/mikrotik": "./src/helpers/mikrotik/index.ts",
21
+ "./helpers/nokia": "./src/helpers/nokia/index.ts",
22
+ "./helpers/paloalto": "./src/helpers/paloalto/index.ts",
23
+ "./helpers/vyos": "./src/helpers/vyos/index.ts"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/sentriflow/sentriflow.git",
28
+ "directory": "packages/core"
29
+ },
30
+ "homepage": "https://github.com/sentriflow/sentriflow#readme",
31
+ "bugs": {
32
+ "url": "https://github.com/sentriflow/sentriflow/issues"
33
+ },
34
+ "keywords": [
35
+ "network",
36
+ "configuration",
37
+ "validation",
38
+ "security",
39
+ "cisco",
40
+ "juniper",
41
+ "arista",
42
+ "firewall",
43
+ "linter",
44
+ "helpers"
45
+ ],
46
+ "files": [
47
+ "src",
48
+ "LICENSE",
49
+ "README.md"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "devDependencies": {
55
+ "bun-types": "latest"
56
+ },
57
+ "peerDependencies": {
58
+ "typescript": "^5.0.0"
59
+ }
60
+ }
package/src/constants.ts CHANGED
File without changes
File without changes
File without changes
File without changes
package/src/errors.ts CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/src/index.ts CHANGED
@@ -15,6 +15,9 @@ export * from './errors';
15
15
  // SEC-012: Encrypted rule pack loader
16
16
  export * from './pack-loader';
17
17
 
18
+ // Pack Provider abstraction for cloud licensing extension
19
+ export * from './pack-provider';
20
+
18
21
  // SEC-001: Declarative rules and sandboxed execution
19
22
  export * from './types/DeclarativeRule';
20
23
  export * from './engine/SandboxedExecutor';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Local Pack Provider
3
+ *
4
+ * Default IPackProvider implementation for local file-based pack loading.
5
+ * Uses the existing loadEncryptedPack function for .grpx files.
6
+ *
7
+ * @module pack-provider/LocalPackProvider
8
+ */
9
+
10
+ import { readFile } from 'fs/promises';
11
+ import { existsSync } from 'fs';
12
+ import { resolve, basename } from 'path';
13
+ import type {
14
+ IPackProvider,
15
+ PackUpdateInfo,
16
+ PackProviderLicenseStatus,
17
+ LocalPackProviderOptions,
18
+ } from './PackProvider';
19
+ import type { RulePack } from '../types/IRule';
20
+ import { loadEncryptedPack, validatePackFormat, PackLoadError } from '../pack-loader';
21
+
22
+ /**
23
+ * Local file-based pack provider
24
+ *
25
+ * Loads encrypted rule packs (.grpx) from the local filesystem
26
+ * using a license key for decryption.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const provider = new LocalPackProvider({
31
+ * licenseKey: 'XXXX-XXXX-XXXX-XXXX',
32
+ * packPaths: ['./rules/security.grpx', './rules/compliance.grpx'],
33
+ * });
34
+ *
35
+ * const packs = await provider.loadPacks();
36
+ * ```
37
+ */
38
+ export class LocalPackProvider implements IPackProvider {
39
+ private readonly licenseKey: string;
40
+ private readonly packPaths: string[];
41
+ private readonly machineId?: string;
42
+ private readonly strict: boolean;
43
+
44
+ private loadedPacks: RulePack[] = [];
45
+ private lastLoadError: string | null = null;
46
+
47
+ constructor(options: LocalPackProviderOptions) {
48
+ this.licenseKey = options.licenseKey;
49
+ this.packPaths = options.packPaths.map((p) => resolve(p));
50
+ this.machineId = options.machineId;
51
+ this.strict = options.strict ?? false;
52
+ }
53
+
54
+ /**
55
+ * Load all configured pack files
56
+ *
57
+ * @returns Promise resolving to array of loaded RulePacks
58
+ * @throws Error if strict mode and any pack fails to load
59
+ */
60
+ async loadPacks(): Promise<RulePack[]> {
61
+ const packs: RulePack[] = [];
62
+ const errors: string[] = [];
63
+
64
+ for (const packPath of this.packPaths) {
65
+ try {
66
+ const pack = await this.loadSinglePack(packPath);
67
+ packs.push(pack);
68
+ } catch (error) {
69
+ const message = error instanceof Error ? error.message : String(error);
70
+ const fileName = basename(packPath);
71
+
72
+ if (this.strict) {
73
+ throw new Error(`Failed to load pack ${fileName}: ${message}`);
74
+ }
75
+
76
+ errors.push(`${fileName}: ${message}`);
77
+ console.warn(`Warning: Failed to load pack ${fileName}: ${message}`);
78
+ }
79
+ }
80
+
81
+ this.loadedPacks = packs;
82
+ this.lastLoadError = errors.length > 0 ? errors.join('; ') : null;
83
+
84
+ return packs;
85
+ }
86
+
87
+ /**
88
+ * Check for updates (not supported for local files)
89
+ *
90
+ * @returns Empty array - local files don't support updates
91
+ */
92
+ async checkForUpdates(): Promise<PackUpdateInfo[]> {
93
+ // Local file provider doesn't support update checking
94
+ return [];
95
+ }
96
+
97
+ /**
98
+ * Apply updates (not supported for local files)
99
+ *
100
+ * @returns 0 - local files don't support updates
101
+ */
102
+ async applyUpdates(_feedIds?: string[]): Promise<number> {
103
+ // Local file provider doesn't support updates
104
+ return 0;
105
+ }
106
+
107
+ /**
108
+ * Get license status
109
+ *
110
+ * Returns basic status based on loaded packs.
111
+ */
112
+ async getLicenseStatus(): Promise<PackProviderLicenseStatus> {
113
+ return {
114
+ isValid: this.loadedPacks.length > 0,
115
+ tier: 'community', // Local packs don't have tier info
116
+ entitledFeeds: this.loadedPacks.map((p) => p.name),
117
+ isOffline: true, // Local is always "offline"
118
+ cachedPackCount: this.loadedPacks.length,
119
+ totalRuleCount: this.loadedPacks.reduce((sum, p) => sum + p.rules.length, 0),
120
+ hasUpdates: false,
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Clean up resources
126
+ */
127
+ destroy(): void {
128
+ // Clear loaded packs
129
+ this.loadedPacks = [];
130
+ }
131
+
132
+ /**
133
+ * Load a single pack file
134
+ *
135
+ * @param packPath - Path to the .grpx file
136
+ * @returns Loaded RulePack
137
+ */
138
+ private async loadSinglePack(packPath: string): Promise<RulePack> {
139
+ // Check file exists
140
+ if (!existsSync(packPath)) {
141
+ throw new Error(`Pack file not found: ${packPath}`);
142
+ }
143
+
144
+ // Read binary data
145
+ const packData = await readFile(packPath);
146
+
147
+ // Validate format
148
+ if (!validatePackFormat(packData)) {
149
+ throw new Error('Invalid pack format');
150
+ }
151
+
152
+ // Load and decrypt
153
+ const loadedPack = await loadEncryptedPack(packData, {
154
+ licenseKey: this.licenseKey,
155
+ machineId: this.machineId,
156
+ timeout: 10000,
157
+ });
158
+
159
+ // Convert LoadedPack to RulePack
160
+ return {
161
+ ...loadedPack.metadata,
162
+ priority: 200, // High priority for licensed packs
163
+ rules: loadedPack.rules,
164
+ };
165
+ }
166
+
167
+ /**
168
+ * Get the last load error message (if any)
169
+ */
170
+ getLastError(): string | null {
171
+ return this.lastLoadError;
172
+ }
173
+
174
+ /**
175
+ * Get list of configured pack paths
176
+ */
177
+ getPackPaths(): readonly string[] {
178
+ return this.packPaths;
179
+ }
180
+ }
181
+
182
+ /**
183
+ * Create a local pack provider
184
+ *
185
+ * Factory function for creating LocalPackProvider instances.
186
+ *
187
+ * @param options - Provider configuration
188
+ * @returns Configured LocalPackProvider
189
+ */
190
+ export function createLocalPackProvider(
191
+ options: LocalPackProviderOptions
192
+ ): LocalPackProvider {
193
+ return new LocalPackProvider(options);
194
+ }
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Pack Provider Interface
3
+ *
4
+ * Provides an abstraction layer for loading rule packs from different sources:
5
+ * - Local file-based packs (OSS default)
6
+ * - Cloud licensing (via @sentriflow/licensing)
7
+ * - Offline bundles
8
+ *
9
+ * This enables the commercial licensing package to provide cloud-based
10
+ * pack loading without modifying the core engine.
11
+ *
12
+ * @module pack-provider
13
+ */
14
+
15
+ import type { IRule, RulePack, RulePackMetadata } from '../types/IRule';
16
+
17
+ /**
18
+ * Information about available pack updates
19
+ */
20
+ export interface PackUpdateInfo {
21
+ /** Feed/pack identifier */
22
+ feedId: string;
23
+
24
+ /** Currently cached version */
25
+ currentVersion: string;
26
+
27
+ /** Available version on server */
28
+ availableVersion: string;
29
+
30
+ /** Download size in bytes (if known) */
31
+ downloadSize?: number;
32
+ }
33
+
34
+ /**
35
+ * License status information
36
+ */
37
+ export interface PackProviderLicenseStatus {
38
+ /** Whether the license is currently valid */
39
+ isValid: boolean;
40
+
41
+ /** License tier */
42
+ tier: 'community' | 'professional' | 'enterprise' | string;
43
+
44
+ /** List of entitled feed/pack IDs */
45
+ entitledFeeds: string[];
46
+
47
+ /** Whether currently operating in offline mode */
48
+ isOffline?: boolean;
49
+
50
+ /** ISO timestamp when cached license expires */
51
+ cacheExpiresAt?: string;
52
+
53
+ /** Number of packs available in cache */
54
+ cachedPackCount?: number;
55
+
56
+ /** Total number of rules available */
57
+ totalRuleCount?: number;
58
+
59
+ /** Whether updates are available */
60
+ hasUpdates?: boolean;
61
+ }
62
+
63
+ /**
64
+ * Pack Provider Interface
65
+ *
66
+ * Abstracts rule pack loading to support different sources:
67
+ * - Default: Local file loading with license key
68
+ * - Cloud: Network-based activation and downloads
69
+ * - Offline: Air-gapped bundle loading
70
+ *
71
+ * Usage:
72
+ * ```typescript
73
+ * import { setPackProvider, getPackProvider } from '@sentriflow/core';
74
+ *
75
+ * // Use cloud provider (requires @sentriflow/licensing)
76
+ * const cloudProvider = new CloudPackProvider({ apiUrl, licenseKey });
77
+ * setPackProvider(cloudProvider);
78
+ *
79
+ * // Load packs using the registered provider
80
+ * const packs = await getPackProvider().loadPacks();
81
+ * ```
82
+ */
83
+ export interface IPackProvider {
84
+ /**
85
+ * Load all available rule packs
86
+ *
87
+ * @returns Promise resolving to array of rule packs
88
+ * @throws Error if loading fails
89
+ */
90
+ loadPacks(): Promise<RulePack[]>;
91
+
92
+ /**
93
+ * Check for available updates
94
+ *
95
+ * Optional - only implemented by cloud/network providers.
96
+ * Local providers can return empty array.
97
+ *
98
+ * @returns Promise resolving to array of update info
99
+ */
100
+ checkForUpdates?(): Promise<PackUpdateInfo[]>;
101
+
102
+ /**
103
+ * Download and apply available updates
104
+ *
105
+ * Optional - only implemented by cloud/network providers.
106
+ *
107
+ * @param feedIds - Specific feeds to update (all if undefined)
108
+ * @returns Promise resolving to number of packs updated
109
+ */
110
+ applyUpdates?(feedIds?: string[]): Promise<number>;
111
+
112
+ /**
113
+ * Get current license status
114
+ *
115
+ * Optional - only implemented by licensed providers.
116
+ * OSS providers can return a default community status.
117
+ *
118
+ * @returns Promise resolving to license status
119
+ */
120
+ getLicenseStatus?(): Promise<PackProviderLicenseStatus>;
121
+
122
+ /**
123
+ * Clean up resources
124
+ *
125
+ * Optional - called when provider is being replaced or application exits.
126
+ * Should clear sensitive data from memory.
127
+ */
128
+ destroy?(): void;
129
+ }
130
+
131
+ /**
132
+ * Result of loading a single pack
133
+ */
134
+ export interface PackLoadResult {
135
+ /** The loaded rule pack */
136
+ pack: RulePack;
137
+
138
+ /** Source of the pack (file path, feed ID, etc.) */
139
+ source: string;
140
+
141
+ /** ISO timestamp when the pack expires (if applicable) */
142
+ validUntil?: string;
143
+ }
144
+
145
+ /**
146
+ * Options for the default local pack provider
147
+ */
148
+ export interface LocalPackProviderOptions {
149
+ /** License key for decryption */
150
+ licenseKey: string;
151
+
152
+ /** Paths to .grpx pack files */
153
+ packPaths: string[];
154
+
155
+ /** Optional machine ID for node-locked licenses */
156
+ machineId?: string;
157
+
158
+ /** Fail on first error (default: false, continue loading other packs) */
159
+ strict?: boolean;
160
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Pack Provider System
3
+ *
4
+ * Provides registration and access to pack providers:
5
+ * - Default: Local file-based pack loading
6
+ * - Custom: Cloud licensing via @sentriflow/licensing
7
+ *
8
+ * @module pack-provider
9
+ */
10
+
11
+ export * from './PackProvider';
12
+ export { LocalPackProvider, createLocalPackProvider } from './LocalPackProvider';
13
+
14
+ import type { IPackProvider } from './PackProvider';
15
+ import { LocalPackProvider } from './LocalPackProvider';
16
+
17
+ /**
18
+ * Currently registered pack provider
19
+ * Default: null (uses legacy local loading)
20
+ */
21
+ let currentProvider: IPackProvider | null = null;
22
+
23
+ /**
24
+ * Set the global pack provider
25
+ *
26
+ * This allows replacing the default local pack loading with
27
+ * cloud-based providers from @sentriflow/licensing.
28
+ *
29
+ * @param provider - The pack provider to use
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * import { setPackProvider } from '@sentriflow/core';
34
+ * import { CloudPackProvider } from '@sentriflow/licensing';
35
+ *
36
+ * // Enable cloud licensing
37
+ * const cloudProvider = new CloudPackProvider({
38
+ * licenseKey: 'XXXX-XXXX-XXXX-XXXX',
39
+ * apiUrl: 'https://api.sentriflow.dev',
40
+ * });
41
+ * setPackProvider(cloudProvider);
42
+ * ```
43
+ */
44
+ export function setPackProvider(provider: IPackProvider): void {
45
+ // Clean up previous provider if it has a destroy method
46
+ if (currentProvider?.destroy) {
47
+ currentProvider.destroy();
48
+ }
49
+
50
+ currentProvider = provider;
51
+ }
52
+
53
+ /**
54
+ * Get the current pack provider
55
+ *
56
+ * Returns the registered provider, or null if using legacy loading.
57
+ *
58
+ * @returns The current pack provider or null
59
+ */
60
+ export function getPackProvider(): IPackProvider | null {
61
+ return currentProvider;
62
+ }
63
+
64
+ /**
65
+ * Check if a custom pack provider is registered
66
+ *
67
+ * @returns true if a custom provider is set
68
+ */
69
+ export function hasPackProvider(): boolean {
70
+ return currentProvider !== null;
71
+ }
72
+
73
+ /**
74
+ * Clear the current pack provider
75
+ *
76
+ * Resets to using legacy local pack loading.
77
+ * Calls destroy() on the current provider if available.
78
+ */
79
+ export function clearPackProvider(): void {
80
+ if (currentProvider?.destroy) {
81
+ currentProvider.destroy();
82
+ }
83
+ currentProvider = null;
84
+ }
85
+
86
+ /**
87
+ * Create and set a local pack provider
88
+ *
89
+ * Convenience function to create a LocalPackProvider and set it
90
+ * as the current provider.
91
+ *
92
+ * @param options - Provider options
93
+ * @returns The created LocalPackProvider
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * import { createAndSetLocalProvider } from '@sentriflow/core';
98
+ *
99
+ * const provider = createAndSetLocalProvider({
100
+ * licenseKey: 'XXXX-XXXX-XXXX-XXXX',
101
+ * packPaths: ['./rules/custom.grpx'],
102
+ * });
103
+ *
104
+ * const packs = await provider.loadPacks();
105
+ * ```
106
+ */
107
+ export function createAndSetLocalProvider(options: {
108
+ licenseKey: string;
109
+ packPaths: string[];
110
+ machineId?: string;
111
+ strict?: boolean;
112
+ }): LocalPackProvider {
113
+ const provider = new LocalPackProvider(options);
114
+ setPackProvider(provider);
115
+ return provider;
116
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes