mftsccs-node 0.0.80-dev → 0.0.82-dev
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/bundle.js +2 -1
- package/dist/bundle.js.LICENSE.txt +1 -0
- package/dist/bundle.mjs +2 -1
- package/dist/bundle.mjs.LICENSE.txt +1 -0
- package/dist/types/DataStructures/Security/TokenStorage.d.ts +18 -0
- package/dist/types/Services/Http/HttpClient.service.d.ts +1 -45
- package/dist/types/Services/Security/ResolveUserId.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
@@ -83,6 +83,16 @@ export declare class TokenStorage {
|
|
|
83
83
|
* @type {number}
|
|
84
84
|
*/
|
|
85
85
|
static EXPIRY_BUFFER_MS: number;
|
|
86
|
+
/**
|
|
87
|
+
* Fallback owning-user identity, populated from the claims of the
|
|
88
|
+
* client-credentials access token obtained via CLIENT_ID/CLIENT_SECRET.
|
|
89
|
+
* Used only when a caller does not pass an explicit userId.
|
|
90
|
+
* @static
|
|
91
|
+
*/
|
|
92
|
+
static DEFAULT_USER_ID: number;
|
|
93
|
+
static DEFAULT_USER_CONCEPT_ID: number;
|
|
94
|
+
static DEFAULT_ENTITY_ID: number;
|
|
95
|
+
static DEFAULT_SESSION_ID: number;
|
|
86
96
|
/**
|
|
87
97
|
* Gets authorization header object for HTTP requests.
|
|
88
98
|
* @returns {Record<string, string>} Headers object with Authorization header if token exists
|
|
@@ -122,4 +132,12 @@ export declare class TokenStorage {
|
|
|
122
132
|
* @param applicationName - Application name
|
|
123
133
|
*/
|
|
124
134
|
static setOAuthCredentials(clientId: string, clientSecret: string, applicationName: string): void;
|
|
135
|
+
/**
|
|
136
|
+
* Sets the fallback owning-user identity decoded from an access token's claims.
|
|
137
|
+
* @param userId - unique_name claim: the owning application's own user id
|
|
138
|
+
* @param userConceptId - upn claim: the owning user's concept id in the CCS graph
|
|
139
|
+
* @param entityId - EntityId claim
|
|
140
|
+
* @param sessionId - primarysid claim
|
|
141
|
+
*/
|
|
142
|
+
static setDefaultIdentity(userId: number, userConceptId: number, entityId: number, sessionId: number): void;
|
|
125
143
|
}
|
|
@@ -55,51 +55,7 @@ export declare class HttpResponse {
|
|
|
55
55
|
*/
|
|
56
56
|
get ok(): boolean;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
* Make an HTTP request with automatic retry on 401 Unauthorized.
|
|
60
|
-
*
|
|
61
|
-
* If a 401 error occurs and OAuth credentials are available, this function
|
|
62
|
-
* will automatically refresh the token and retry the request once.
|
|
63
|
-
*
|
|
64
|
-
* @async
|
|
65
|
-
* @param {string} method - HTTP method (GET, POST, PUT, DELETE, etc.)
|
|
66
|
-
* @param {string} url - The URL to request
|
|
67
|
-
* @param {Record<string, string>} [headers] - Optional headers dict
|
|
68
|
-
* @param {any} [body] - Optional request body (JSON will be stringified)
|
|
69
|
-
* @param {number} [maxRetries=1] - Maximum number of retries on 401
|
|
70
|
-
* @returns {Promise<HttpResponse>} HttpResponse object with status, body, and headers
|
|
71
|
-
* @throws {TokenRefreshError} If token refresh fails
|
|
72
|
-
* @throws {Error} For other network errors
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const headers = { "Content-Type": "application/json" };
|
|
77
|
-
* const response = await requestWithRetry(
|
|
78
|
-
* "POST",
|
|
79
|
-
* url,
|
|
80
|
-
* headers,
|
|
81
|
-
* { id: 123 }
|
|
82
|
-
* );
|
|
83
|
-
* if (response.ok) {
|
|
84
|
-
* const data = await response.json();
|
|
85
|
-
* console.log(data);
|
|
86
|
-
* }
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* // Automatic token refresh on 401
|
|
92
|
-
* try {
|
|
93
|
-
* const response = await requestWithRetry("GET", url);
|
|
94
|
-
* // If receives 401, will automatically refresh token and retry
|
|
95
|
-
* } catch (error) {
|
|
96
|
-
* if (error instanceof TokenRefreshError) {
|
|
97
|
-
* console.error('Authentication failed:', error.message);
|
|
98
|
-
* }
|
|
99
|
-
* }
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
export declare function requestWithRetry(method: string, url: string, headers?: Record<string, string>, body?: any, maxRetries?: number): Promise<HttpResponse>;
|
|
58
|
+
export declare function requestWithRetry(method: string, url: string, headers?: Record<string, string>, body?: any, maxRetries?: number, timeoutMs?: number): Promise<HttpResponse>;
|
|
103
59
|
/**
|
|
104
60
|
* Fetch-compatible wrapper backed by requestWithRetry.
|
|
105
61
|
*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ResolveUserId
|
|
3
|
+
* @description Resolves the owning-user concept id for a concept/connection creation call.
|
|
4
|
+
* Priority: explicitly passed userId > the default identity decoded from the
|
|
5
|
+
* client-credentials access token (TokenStorage.DEFAULT_USER_CONCEPT_ID) > the
|
|
6
|
+
* legacy system placeholder id (999).
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveUserId(passedUserId?: number): number;
|