@mcp-abap-adt/auth-stores 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.
Files changed (50) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE +22 -0
  3. package/README.md +209 -0
  4. package/dist/index.d.ts +22 -0
  5. package/dist/index.js +53 -0
  6. package/dist/loaders/abap/serviceKeyLoader.d.ts +15 -0
  7. package/dist/loaders/abap/serviceKeyLoader.js +84 -0
  8. package/dist/loaders/xsuaa/xsuaaServiceKeyLoader.d.ts +19 -0
  9. package/dist/loaders/xsuaa/xsuaaServiceKeyLoader.js +80 -0
  10. package/dist/parsers/abap/AbapServiceKeyParser.d.ts +35 -0
  11. package/dist/parsers/abap/AbapServiceKeyParser.js +50 -0
  12. package/dist/parsers/xsuaa/XsuaaServiceKeyParser.d.ts +30 -0
  13. package/dist/parsers/xsuaa/XsuaaServiceKeyParser.js +72 -0
  14. package/dist/storage/abap/envLoader.d.ts +21 -0
  15. package/dist/storage/abap/envLoader.js +94 -0
  16. package/dist/storage/abap/tokenStorage.d.ts +24 -0
  17. package/dist/storage/abap/tokenStorage.js +113 -0
  18. package/dist/storage/xsuaa/xsuaaEnvLoader.d.ts +20 -0
  19. package/dist/storage/xsuaa/xsuaaEnvLoader.js +91 -0
  20. package/dist/storage/xsuaa/xsuaaTokenStorage.d.ts +19 -0
  21. package/dist/storage/xsuaa/xsuaaTokenStorage.js +115 -0
  22. package/dist/stores/abap/AbapServiceKeyStore.d.ts +34 -0
  23. package/dist/stores/abap/AbapServiceKeyStore.js +43 -0
  24. package/dist/stores/abap/AbapSessionStore.d.ts +80 -0
  25. package/dist/stores/abap/AbapSessionStore.js +239 -0
  26. package/dist/stores/abap/SafeAbapSessionStore.d.ts +35 -0
  27. package/dist/stores/abap/SafeAbapSessionStore.js +117 -0
  28. package/dist/stores/abstract/AbstractJsonSessionStore.d.ts +67 -0
  29. package/dist/stores/abstract/AbstractJsonSessionStore.js +99 -0
  30. package/dist/stores/abstract/AbstractSafeSessionStore.d.ts +89 -0
  31. package/dist/stores/abstract/AbstractSafeSessionStore.js +76 -0
  32. package/dist/stores/abstract/AbstractServiceKeyStore.d.ts +66 -0
  33. package/dist/stores/abstract/AbstractServiceKeyStore.js +165 -0
  34. package/dist/stores/btp/BtpServiceKeyStore.d.ts +34 -0
  35. package/dist/stores/btp/BtpServiceKeyStore.js +43 -0
  36. package/dist/stores/btp/BtpSessionStore.d.ts +79 -0
  37. package/dist/stores/btp/BtpSessionStore.js +247 -0
  38. package/dist/stores/btp/SafeBtpSessionStore.d.ts +32 -0
  39. package/dist/stores/btp/SafeBtpSessionStore.js +115 -0
  40. package/dist/stores/xsuaa/SafeXsuaaSessionStore.d.ts +34 -0
  41. package/dist/stores/xsuaa/SafeXsuaaSessionStore.js +117 -0
  42. package/dist/stores/xsuaa/XsuaaServiceKeyStore.d.ts +36 -0
  43. package/dist/stores/xsuaa/XsuaaServiceKeyStore.js +49 -0
  44. package/dist/stores/xsuaa/XsuaaSessionStore.d.ts +54 -0
  45. package/dist/stores/xsuaa/XsuaaSessionStore.js +223 -0
  46. package/dist/utils/constants.d.ts +83 -0
  47. package/dist/utils/constants.js +86 -0
  48. package/dist/utils/pathResolver.d.ts +20 -0
  49. package/dist/utils/pathResolver.js +105 -0
  50. package/package.json +63 -0
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Abstract Safe Session Store - base class for in-memory session stores
3
+ *
4
+ * Provides common functionality for in-memory session storage.
5
+ * Subclasses implement type-specific validation and conversion logic.
6
+ */
7
+ import type { IAuthorizationConfig, IConnectionConfig } from '@mcp-abap-adt/auth-broker';
8
+ import type { IConfig } from '@mcp-abap-adt/auth-broker';
9
+ /**
10
+ * Abstract base class for safe (in-memory) session stores
11
+ *
12
+ * Handles common in-memory operations. Subclasses provide type-specific logic.
13
+ */
14
+ export declare abstract class AbstractSafeSessionStore {
15
+ protected sessions: Map<string, unknown>;
16
+ /**
17
+ * Load raw session data (internal representation)
18
+ * Used internally by getAuthorizationConfig, getConnectionConfig, setAuthorizationConfig, setConnectionConfig
19
+ */
20
+ protected loadRawSession(destination: string): unknown | null;
21
+ /**
22
+ * Load session configuration for destination
23
+ * Returns optional composition of IAuthorizationConfig and IConnectionConfig
24
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
25
+ * @returns IConfig with actual values or null if not found
26
+ */
27
+ loadSession(destination: string): Promise<IConfig | null>;
28
+ /**
29
+ * Save session configuration for destination
30
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
31
+ * @param config Session configuration to save (IConfig or internal format)
32
+ */
33
+ saveSession(destination: string, config: unknown): Promise<void>;
34
+ /**
35
+ * Convert IConfig to internal format (override in subclasses if needed)
36
+ * @param config IConfig or internal format
37
+ * @returns Internal format
38
+ */
39
+ protected convertToInternalFormat(config: unknown): unknown;
40
+ /**
41
+ * Delete session for destination
42
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
43
+ */
44
+ deleteSession(destination: string): Promise<void>;
45
+ /**
46
+ * Clear all sessions
47
+ */
48
+ clearAll(): void;
49
+ /**
50
+ * Get authorization configuration with actual values (not file paths)
51
+ * Returns values needed for obtaining and refreshing tokens
52
+ * Must be implemented by subclasses
53
+ * @param destination Destination name
54
+ * @returns IAuthorizationConfig with actual values or null if not found
55
+ */
56
+ abstract getAuthorizationConfig(destination: string): Promise<IAuthorizationConfig | null>;
57
+ /**
58
+ * Set authorization configuration
59
+ * Updates values needed for obtaining and refreshing tokens
60
+ * Must be implemented by subclasses
61
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
62
+ * @param config IAuthorizationConfig with values to set
63
+ */
64
+ abstract setAuthorizationConfig(destination: string, config: IAuthorizationConfig): Promise<void>;
65
+ /**
66
+ * Validate session configuration (must be implemented by subclasses)
67
+ * @param config Session configuration to validate
68
+ * @throws Error if config is invalid for this store type
69
+ */
70
+ protected abstract validateSessionConfig(config: unknown): void;
71
+ /**
72
+ * Check if session config is valid for this store type (must be implemented by subclasses)
73
+ * @param config Session configuration to check
74
+ * @returns true if config is valid for this store type
75
+ */
76
+ protected abstract isValidSessionConfig(config: unknown): boolean;
77
+ /**
78
+ * Get connection configuration with actual values (must be implemented by subclasses)
79
+ * @param destination Destination name
80
+ * @returns IConnectionConfig with actual values or null if not found
81
+ */
82
+ abstract getConnectionConfig(destination: string): Promise<IConnectionConfig | null>;
83
+ /**
84
+ * Set connection configuration (must be implemented by subclasses)
85
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
86
+ * @param config IConnectionConfig with values to set
87
+ */
88
+ abstract setConnectionConfig(destination: string, config: IConnectionConfig): Promise<void>;
89
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /**
3
+ * Abstract Safe Session Store - base class for in-memory session stores
4
+ *
5
+ * Provides common functionality for in-memory session storage.
6
+ * Subclasses implement type-specific validation and conversion logic.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AbstractSafeSessionStore = void 0;
10
+ /**
11
+ * Abstract base class for safe (in-memory) session stores
12
+ *
13
+ * Handles common in-memory operations. Subclasses provide type-specific logic.
14
+ */
15
+ class AbstractSafeSessionStore {
16
+ sessions = new Map();
17
+ /**
18
+ * Load raw session data (internal representation)
19
+ * Used internally by getAuthorizationConfig, getConnectionConfig, setAuthorizationConfig, setConnectionConfig
20
+ */
21
+ loadRawSession(destination) {
22
+ return this.sessions.get(destination) || null;
23
+ }
24
+ /**
25
+ * Load session configuration for destination
26
+ * Returns optional composition of IAuthorizationConfig and IConnectionConfig
27
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
28
+ * @returns IConfig with actual values or null if not found
29
+ */
30
+ async loadSession(destination) {
31
+ const authConfig = await this.getAuthorizationConfig(destination);
32
+ const connConfig = await this.getConnectionConfig(destination);
33
+ // Return null if both are null, otherwise return composition (even if one is null)
34
+ if (!authConfig && !connConfig) {
35
+ return null;
36
+ }
37
+ return {
38
+ ...(authConfig || {}),
39
+ ...(connConfig || {}),
40
+ };
41
+ }
42
+ /**
43
+ * Save session configuration for destination
44
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
45
+ * @param config Session configuration to save (IConfig or internal format)
46
+ */
47
+ async saveSession(destination, config) {
48
+ this.validateSessionConfig(config);
49
+ // Convert IConfig to internal format if needed
50
+ const internalConfig = this.convertToInternalFormat(config);
51
+ this.sessions.set(destination, internalConfig);
52
+ }
53
+ /**
54
+ * Convert IConfig to internal format (override in subclasses if needed)
55
+ * @param config IConfig or internal format
56
+ * @returns Internal format
57
+ */
58
+ convertToInternalFormat(config) {
59
+ // Default: return as-is (subclasses can override)
60
+ return config;
61
+ }
62
+ /**
63
+ * Delete session for destination
64
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
65
+ */
66
+ async deleteSession(destination) {
67
+ this.sessions.delete(destination);
68
+ }
69
+ /**
70
+ * Clear all sessions
71
+ */
72
+ clearAll() {
73
+ this.sessions.clear();
74
+ }
75
+ }
76
+ exports.AbstractSafeSessionStore = AbstractSafeSessionStore;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Abstract Service Key Store - base class for service key stores
3
+ *
4
+ * Provides common functionality for file-based service key stores.
5
+ * Subclasses implement format-specific parsing logic.
6
+ */
7
+ import type { IServiceKeyStore, IAuthorizationConfig, IConnectionConfig } from '@mcp-abap-adt/auth-broker';
8
+ import type { IConfig } from '@mcp-abap-adt/auth-broker';
9
+ /**
10
+ * Abstract base class for service key stores
11
+ *
12
+ * Handles file I/O operations. Subclasses provide parsing logic.
13
+ */
14
+ export declare abstract class AbstractServiceKeyStore implements IServiceKeyStore {
15
+ protected searchPaths: string[];
16
+ /**
17
+ * Create a new AbstractServiceKeyStore instance
18
+ * @param searchPaths Optional search paths for .json files.
19
+ * Can be a single path (string) or array of paths.
20
+ * If not provided, uses AUTH_BROKER_PATH env var or current working directory.
21
+ */
22
+ constructor(searchPaths?: string | string[]);
23
+ /**
24
+ * Load raw JSON data from file
25
+ * @param destination Destination name
26
+ * @returns Raw JSON data or null if file not found
27
+ */
28
+ protected loadRawData(destination: string): Promise<any | null>;
29
+ /**
30
+ * Parse raw JSON data into service key format
31
+ * Must be implemented by subclasses
32
+ * @param rawData Raw JSON data from service key file
33
+ * @returns Parsed service key object (implementation-specific)
34
+ * @throws Error if data cannot be parsed or is invalid
35
+ */
36
+ protected abstract parse(rawData: unknown): unknown;
37
+ /**
38
+ * Get raw parsed service key (internal representation)
39
+ * Used internally by getAuthorizationConfig and getConnectionConfig
40
+ */
41
+ private getRawServiceKey;
42
+ /**
43
+ * Get service key for destination
44
+ * Returns optional composition of IAuthorizationConfig and IConnectionConfig
45
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
46
+ * @returns IConfig with actual values or null if not found
47
+ */
48
+ getServiceKey(destination: string): Promise<IConfig | null>;
49
+ /**
50
+ * Get authorization configuration from service key
51
+ * @param destination Destination name (e.g., "TRIAL")
52
+ * @returns IAuthorizationConfig with actual values or null if not found
53
+ */
54
+ getAuthorizationConfig(destination: string): Promise<IAuthorizationConfig | null>;
55
+ /**
56
+ * Get connection configuration from service key
57
+ * @param destination Destination name (e.g., "TRIAL")
58
+ * @returns IConnectionConfig with actual values or null if not found
59
+ */
60
+ getConnectionConfig(destination: string): Promise<IConnectionConfig | null>;
61
+ /**
62
+ * Get search paths (for error messages)
63
+ * @returns Array of search paths
64
+ */
65
+ getSearchPaths(): string[];
66
+ }
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ /**
3
+ * Abstract Service Key Store - base class for service key stores
4
+ *
5
+ * Provides common functionality for file-based service key stores.
6
+ * Subclasses implement format-specific parsing logic.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.AbstractServiceKeyStore = void 0;
43
+ const pathResolver_1 = require("../../utils/pathResolver");
44
+ const fs = __importStar(require("fs"));
45
+ /**
46
+ * Abstract base class for service key stores
47
+ *
48
+ * Handles file I/O operations. Subclasses provide parsing logic.
49
+ */
50
+ class AbstractServiceKeyStore {
51
+ searchPaths;
52
+ /**
53
+ * Create a new AbstractServiceKeyStore instance
54
+ * @param searchPaths Optional search paths for .json files.
55
+ * Can be a single path (string) or array of paths.
56
+ * If not provided, uses AUTH_BROKER_PATH env var or current working directory.
57
+ */
58
+ constructor(searchPaths) {
59
+ this.searchPaths = (0, pathResolver_1.resolveSearchPaths)(searchPaths);
60
+ }
61
+ /**
62
+ * Load raw JSON data from file
63
+ * @param destination Destination name
64
+ * @returns Raw JSON data or null if file not found
65
+ */
66
+ async loadRawData(destination) {
67
+ const fileName = `${destination}.json`;
68
+ const serviceKeyPath = (0, pathResolver_1.findFileInPaths)(fileName, this.searchPaths);
69
+ if (!serviceKeyPath) {
70
+ return null;
71
+ }
72
+ try {
73
+ const fileContent = fs.readFileSync(serviceKeyPath, 'utf8');
74
+ return JSON.parse(fileContent);
75
+ }
76
+ catch (error) {
77
+ if (error instanceof SyntaxError) {
78
+ throw new Error(`Invalid JSON in service key file for destination "${destination}": ${error.message}`);
79
+ }
80
+ throw new Error(`Failed to load service key file for destination "${destination}": ${error instanceof Error ? error.message : String(error)}`);
81
+ }
82
+ }
83
+ /**
84
+ * Get raw parsed service key (internal representation)
85
+ * Used internally by getAuthorizationConfig and getConnectionConfig
86
+ */
87
+ async getRawServiceKey(destination) {
88
+ const rawData = await this.loadRawData(destination);
89
+ if (!rawData) {
90
+ return null;
91
+ }
92
+ try {
93
+ return this.parse(rawData);
94
+ }
95
+ catch (error) {
96
+ throw new Error(`Failed to parse service key for destination "${destination}": ${error instanceof Error ? error.message : String(error)}`);
97
+ }
98
+ }
99
+ /**
100
+ * Get service key for destination
101
+ * Returns optional composition of IAuthorizationConfig and IConnectionConfig
102
+ * @param destination Destination name (e.g., "TRIAL" or "mcp")
103
+ * @returns IConfig with actual values or null if not found
104
+ */
105
+ async getServiceKey(destination) {
106
+ const authConfig = await this.getAuthorizationConfig(destination);
107
+ const connConfig = await this.getConnectionConfig(destination);
108
+ // Return null if both are null, otherwise return composition (even if one is null)
109
+ if (!authConfig && !connConfig) {
110
+ return null;
111
+ }
112
+ return {
113
+ ...(authConfig || {}),
114
+ ...(connConfig || {}),
115
+ };
116
+ }
117
+ /**
118
+ * Get authorization configuration from service key
119
+ * @param destination Destination name (e.g., "TRIAL")
120
+ * @returns IAuthorizationConfig with actual values or null if not found
121
+ */
122
+ async getAuthorizationConfig(destination) {
123
+ const serviceKey = await this.getRawServiceKey(destination);
124
+ if (!serviceKey || typeof serviceKey !== 'object') {
125
+ return null;
126
+ }
127
+ const key = serviceKey;
128
+ if (!key.uaa || !key.uaa.url || !key.uaa.clientid || !key.uaa.clientsecret) {
129
+ return null;
130
+ }
131
+ return {
132
+ uaaUrl: key.uaa.url,
133
+ uaaClientId: key.uaa.clientid,
134
+ uaaClientSecret: key.uaa.clientsecret,
135
+ };
136
+ }
137
+ /**
138
+ * Get connection configuration from service key
139
+ * @param destination Destination name (e.g., "TRIAL")
140
+ * @returns IConnectionConfig with actual values or null if not found
141
+ */
142
+ async getConnectionConfig(destination) {
143
+ const serviceKey = await this.getRawServiceKey(destination);
144
+ if (!serviceKey || typeof serviceKey !== 'object') {
145
+ return null;
146
+ }
147
+ const key = serviceKey;
148
+ // Service key doesn't have tokens - only URLs and client info
149
+ const serviceUrl = key.abap?.url || key.sap_url || (key.url && !key.url.includes('authentication') ? key.url : undefined);
150
+ return {
151
+ serviceUrl,
152
+ authorizationToken: '', // Service key doesn't contain tokens
153
+ sapClient: key.abap?.client || key.sap_client || key.client,
154
+ language: key.abap?.language || key.language,
155
+ };
156
+ }
157
+ /**
158
+ * Get search paths (for error messages)
159
+ * @returns Array of search paths
160
+ */
161
+ getSearchPaths() {
162
+ return [...this.searchPaths];
163
+ }
164
+ }
165
+ exports.AbstractServiceKeyStore = AbstractServiceKeyStore;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Base BTP Service key store - reads XSUAA service keys from {destination}.json files
3
+ *
4
+ * Uses AbstractServiceKeyStore for file I/O and XsuaaServiceKeyParser for parsing.
5
+ * Supports direct XSUAA service key format from BTP (without nested uaa object).
6
+ */
7
+ import type { IServiceKeyStore } from '@mcp-abap-adt/auth-broker';
8
+ import { AbstractServiceKeyStore } from '../abstract/AbstractServiceKeyStore';
9
+ /**
10
+ * Base BTP Service key store implementation
11
+ *
12
+ * Uses AbstractServiceKeyStore for file operations and XsuaaServiceKeyParser for parsing.
13
+ * Search paths priority:
14
+ * 1. Constructor parameter (highest)
15
+ * 2. AUTH_BROKER_PATH environment variable
16
+ * 3. Current working directory (lowest)
17
+ */
18
+ export declare class BtpServiceKeyStore extends AbstractServiceKeyStore implements IServiceKeyStore {
19
+ private parser;
20
+ /**
21
+ * Create a new BtpServiceKeyStore instance
22
+ * @param searchPaths Optional search paths for .json files.
23
+ * Can be a single path (string) or array of paths.
24
+ * If not provided, uses AUTH_BROKER_PATH env var or current working directory.
25
+ */
26
+ constructor(searchPaths?: string | string[]);
27
+ /**
28
+ * Parse raw JSON data using XsuaaServiceKeyParser
29
+ * @param rawData Raw JSON data from service key file
30
+ * @returns Parsed service key object
31
+ * @throws Error if data cannot be parsed or is invalid
32
+ */
33
+ protected parse(rawData: any): unknown;
34
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Base BTP Service key store - reads XSUAA service keys from {destination}.json files
4
+ *
5
+ * Uses AbstractServiceKeyStore for file I/O and XsuaaServiceKeyParser for parsing.
6
+ * Supports direct XSUAA service key format from BTP (without nested uaa object).
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BtpServiceKeyStore = void 0;
10
+ const AbstractServiceKeyStore_1 = require("../abstract/AbstractServiceKeyStore");
11
+ const XsuaaServiceKeyParser_1 = require("../../parsers/xsuaa/XsuaaServiceKeyParser");
12
+ /**
13
+ * Base BTP Service key store implementation
14
+ *
15
+ * Uses AbstractServiceKeyStore for file operations and XsuaaServiceKeyParser for parsing.
16
+ * Search paths priority:
17
+ * 1. Constructor parameter (highest)
18
+ * 2. AUTH_BROKER_PATH environment variable
19
+ * 3. Current working directory (lowest)
20
+ */
21
+ class BtpServiceKeyStore extends AbstractServiceKeyStore_1.AbstractServiceKeyStore {
22
+ parser;
23
+ /**
24
+ * Create a new BtpServiceKeyStore instance
25
+ * @param searchPaths Optional search paths for .json files.
26
+ * Can be a single path (string) or array of paths.
27
+ * If not provided, uses AUTH_BROKER_PATH env var or current working directory.
28
+ */
29
+ constructor(searchPaths) {
30
+ super(searchPaths);
31
+ this.parser = new XsuaaServiceKeyParser_1.XsuaaServiceKeyParser();
32
+ }
33
+ /**
34
+ * Parse raw JSON data using XsuaaServiceKeyParser
35
+ * @param rawData Raw JSON data from service key file
36
+ * @returns Parsed service key object
37
+ * @throws Error if data cannot be parsed or is invalid
38
+ */
39
+ parse(rawData) {
40
+ return this.parser.parse(rawData);
41
+ }
42
+ }
43
+ exports.BtpServiceKeyStore = BtpServiceKeyStore;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Base BTP Session Store - stores BTP session data without sapUrl (XSUAA-like)
3
+ *
4
+ * This is the base implementation for BTP stores without sapUrl requirement.
5
+ * Stores to {destination}.env files with XSUAA_* variables.
6
+ */
7
+ import type { IAuthorizationConfig, IConnectionConfig, ISessionStore } from '@mcp-abap-adt/auth-broker';
8
+ import type { IConfig } from '@mcp-abap-adt/auth-broker';
9
+ import { AbstractJsonSessionStore } from '../abstract/AbstractJsonSessionStore';
10
+ /**
11
+ * Base BTP Session Store implementation (without sapUrl)
12
+ *
13
+ * Stores session data in {destination}.env files using XSUAA_* variables.
14
+ * Search paths priority:
15
+ * 1. Constructor parameter (highest)
16
+ * 2. AUTH_BROKER_PATH environment variable
17
+ * 3. Current working directory (lowest)
18
+ */
19
+ export declare class BtpSessionStore extends AbstractJsonSessionStore implements ISessionStore {
20
+ /**
21
+ * Get file name for destination
22
+ * @param destination Destination name
23
+ * @returns File name (e.g., "mcp.env")
24
+ */
25
+ protected getFileName(destination: string): string;
26
+ /**
27
+ * Load session from file
28
+ * @param filePath Path to session file
29
+ * @returns Parsed BtpBaseSessionData or null if invalid
30
+ */
31
+ protected loadFromFile(filePath: string): Promise<unknown | null>;
32
+ /**
33
+ * Save session to file
34
+ * @param filePath Path to session file
35
+ * @param config Session configuration to save
36
+ */
37
+ protected saveToFile(filePath: string, config: unknown): Promise<void>;
38
+ /**
39
+ * Load session configuration for destination
40
+ * Returns optional composition of IAuthorizationConfig and IConnectionConfig
41
+ * @param destination Destination name
42
+ * @returns IConfig with actual values or null if not found
43
+ */
44
+ loadSession(destination: string): Promise<IConfig | null>;
45
+ /**
46
+ * Load raw session data (internal representation)
47
+ * Used internally for getAuthorizationConfig, getConnectionConfig, setAuthorizationConfig and setConnectionConfig
48
+ */
49
+ private loadRawSession;
50
+ /**
51
+ * Get authorization configuration with actual values (not file paths)
52
+ * Returns values needed for obtaining and refreshing tokens
53
+ * @param destination Destination name
54
+ * @returns AuthorizationConfig with actual values or null if not found
55
+ */
56
+ getAuthorizationConfig(destination: string): Promise<IAuthorizationConfig | null>;
57
+ /**
58
+ * Get connection configuration with actual values (not file paths)
59
+ * Returns values needed for connecting to services
60
+ * @param destination Destination name
61
+ * @returns ConnectionConfig with actual values or null if not found
62
+ * Note: For base BTP, serviceUrl may be undefined (not part of authentication)
63
+ */
64
+ getConnectionConfig(destination: string): Promise<IConnectionConfig | null>;
65
+ /**
66
+ * Set authorization configuration
67
+ * Updates values needed for obtaining and refreshing tokens
68
+ * @param destination Destination name
69
+ * @param config IAuthorizationConfig with values to set
70
+ */
71
+ setAuthorizationConfig(destination: string, config: IAuthorizationConfig): Promise<void>;
72
+ /**
73
+ * Set connection configuration
74
+ * Updates values needed for connecting to services
75
+ * @param destination Destination name
76
+ * @param config IConnectionConfig with values to set
77
+ */
78
+ setConnectionConfig(destination: string, config: IConnectionConfig): Promise<void>;
79
+ }