inovabiz-opencode-companion 0.1.0 → 0.1.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/dist/api-key.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type IPersistence } from "@azure/msal-node-extensions";
1
+ import { type DpapiPersistence } from "./msal-persistence.js";
2
2
  export interface LiteLLMApiKeyProvider {
3
3
  getApiKey(options?: LiteLLMApiKeyLookupOptions): Promise<string>;
4
4
  }
@@ -11,4 +11,4 @@ export declare class SecureLiteLLMApiKeyStore implements LiteLLMApiKeyProvider {
11
11
  getApiKey(options?: LiteLLMApiKeyLookupOptions): Promise<string>;
12
12
  private getPersistence;
13
13
  }
14
- export declare function createLiteLLMKeyPersistence(options?: Required<LiteLLMApiKeyLookupOptions>): Promise<IPersistence>;
14
+ export declare function createLiteLLMKeyPersistence(options?: Required<LiteLLMApiKeyLookupOptions>): Promise<DpapiPersistence>;
package/dist/api-key.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { mkdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { DataProtectionScope, PersistenceCreator, } from "@azure/msal-node-extensions";
4
3
  import { LITELLM_KEY_ACCOUNT_NAME, LITELLM_KEY_FILE_NAME, LITELLM_KEY_SERVICE_NAME, } from "./config.js";
4
+ import { createDpapiPersistence } from "./msal-persistence.js";
5
5
  export class SecureLiteLLMApiKeyStore {
6
6
  persistenceByKey = new Map();
7
7
  async getApiKey(options = {}) {
@@ -36,11 +36,7 @@ export async function createLiteLLMKeyPersistence(options = {
36
36
  }
37
37
  const directory = join(localAppData, "Inovabiz", "OpenCodeEntraSso");
38
38
  await mkdir(directory, { recursive: true });
39
- return PersistenceCreator.createPersistence({
40
- cachePath: join(directory, options.fileName),
41
- dataProtectionScope: DataProtectionScope.CurrentUser,
42
- serviceName: LITELLM_KEY_SERVICE_NAME,
43
- accountName: options.accountName,
44
- usePlaintextFileOnLinux: false,
45
- });
39
+ void LITELLM_KEY_SERVICE_NAME;
40
+ void options.accountName;
41
+ return createDpapiPersistence(join(directory, options.fileName));
46
42
  }
package/dist/auth.js CHANGED
@@ -2,9 +2,9 @@ import { mkdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { spawn } from "node:child_process";
4
4
  import { InteractionRequiredAuthError, PublicClientApplication, } from "@azure/msal-node";
5
- import { DataProtectionScope, PersistenceCachePlugin, PersistenceCreator, } from "@azure/msal-node-extensions";
6
- import { CACHE_ACCOUNT_NAME, CACHE_DIRECTORY_NAME, CACHE_FILE_NAME, CACHE_SERVICE_NAME, INTERACTIVE_LOGIN_TIMEOUT_MS, LOGIN_SCOPES, TOKEN_EXPIRY_MARGIN_MS, getConfiguration, } from "./config.js";
5
+ import { CACHE_DIRECTORY_NAME, CACHE_FILE_NAME, INTERACTIVE_LOGIN_TIMEOUT_MS, LOGIN_SCOPES, TOKEN_EXPIRY_MARGIN_MS, getConfiguration, } from "./config.js";
7
6
  import { TimedLoopbackClient } from "./loopback.js";
7
+ import { createDpapiPersistence, createPersistenceCachePlugin, } from "./msal-persistence.js";
8
8
  export class EntraTokenService {
9
9
  initialized;
10
10
  tokenRequest;
@@ -27,13 +27,7 @@ export class EntraTokenService {
27
27
  }
28
28
  const cacheDirectory = join(localAppData, CACHE_DIRECTORY_NAME);
29
29
  await mkdir(cacheDirectory, { recursive: true });
30
- const persistence = await PersistenceCreator.createPersistence({
31
- cachePath: join(cacheDirectory, CACHE_FILE_NAME),
32
- dataProtectionScope: DataProtectionScope.CurrentUser,
33
- serviceName: CACHE_SERVICE_NAME,
34
- accountName: CACHE_ACCOUNT_NAME,
35
- usePlaintextFileOnLinux: false,
36
- });
30
+ const persistence = await createDpapiPersistence(join(cacheDirectory, CACHE_FILE_NAME));
37
31
  if (!(await persistence.verifyPersistence())) {
38
32
  throw new Error("Windows DPAPI persistence validation failed.");
39
33
  }
@@ -42,7 +36,7 @@ export class EntraTokenService {
42
36
  clientId: configuration.clientId,
43
37
  authority: `https://login.microsoftonline.com/${configuration.tenantId}`,
44
38
  },
45
- cache: { cachePlugin: new PersistenceCachePlugin(persistence) },
39
+ cache: { cachePlugin: await createPersistenceCachePlugin(persistence) },
46
40
  system: {
47
41
  loggerOptions: {
48
42
  piiLoggingEnabled: false,
@@ -0,0 +1,12 @@
1
+ import type { ICachePlugin } from "@azure/msal-common/node";
2
+ export interface DpapiPersistence {
3
+ save(contents: string): Promise<void>;
4
+ load(): Promise<string | null>;
5
+ delete(): Promise<boolean>;
6
+ reloadNecessary(lastSync: number): Promise<boolean>;
7
+ getFilePath(): string;
8
+ verifyPersistence(): Promise<boolean>;
9
+ createForPersistenceValidation(): Promise<DpapiPersistence>;
10
+ }
11
+ export declare function createDpapiPersistence(cachePath: string): Promise<DpapiPersistence>;
12
+ export declare function createPersistenceCachePlugin(persistence: DpapiPersistence): Promise<ICachePlugin>;
@@ -0,0 +1,11 @@
1
+ export async function createDpapiPersistence(cachePath) {
2
+ const { FilePersistenceWithDataProtection } = await importMsalNodeExtensionModule("persistence/FilePersistenceWithDataProtection.mjs");
3
+ return FilePersistenceWithDataProtection.create(cachePath, "CurrentUser");
4
+ }
5
+ export async function createPersistenceCachePlugin(persistence) {
6
+ const { PersistenceCachePlugin } = await importMsalNodeExtensionModule("persistence/PersistenceCachePlugin.mjs");
7
+ return new PersistenceCachePlugin(persistence);
8
+ }
9
+ function importMsalNodeExtensionModule(modulePath) {
10
+ return import(new URL(`../node_modules/@azure/msal-node-extensions/dist/${modulePath}`, import.meta.url).href);
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inovabiz-opencode-companion",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "OpenCode companion plugin for corporate provider authentication and gateway integration.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",