@attlaz/client 1.102.1 → 1.104.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/dist/Http/Transport/DirectTransport.d.ts +6 -20
- package/dist/Http/Transport/DirectTransport.js +6 -22
- package/dist/Service/AdapterConnectionEndpoint.d.ts +8 -0
- package/dist/Service/AdapterConnectionEndpoint.js +9 -1
- package/dist/index.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -4,24 +4,18 @@ export interface DirectTransportRoute {
|
|
|
4
4
|
prefix: string;
|
|
5
5
|
baseUrl: string;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* The actor an internal call runs as. Backends resolve access against this, so a caller that reaches
|
|
9
|
-
* user-owned resources must name one — an anonymous session can only reach unguarded routes.
|
|
10
|
-
*/
|
|
11
|
-
export interface DirectTransportPrincipal {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
}
|
|
15
7
|
/**
|
|
16
8
|
* Transport for internal service-to-service calls that bypasses Gateway OAuth.
|
|
17
9
|
* Authenticates via HMAC-signed session headers instead of an OAuth token.
|
|
18
10
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
11
|
+
* It carries the session payload and its signature without interpreting either: the payload's shape
|
|
12
|
+
* is a contract between Attlaz services, and building it needs `node:crypto` and platform models
|
|
13
|
+
* this package deliberately does not depend on. **Attlaz services should not construct this
|
|
14
|
+
* directly** — use `InternalTransportFactory.asSystem()` from `@attlaz/attlaz-core`, which owns that
|
|
15
|
+
* shape and does the signing.
|
|
21
16
|
*
|
|
22
|
-
* Usage:
|
|
17
|
+
* Usage (non-Attlaz callers, or anything supplying its own session):
|
|
23
18
|
* import {createHmac} from 'node:crypto';
|
|
24
|
-
* const sessionPayload = DirectTransport.createSessionPayload();
|
|
25
19
|
* const sessionSignature = createHmac('sha256', apiSecret).update(sessionPayload).digest('hex');
|
|
26
20
|
* const transport = new DirectTransport('http://core-api:5728', sessionPayload, sessionSignature);
|
|
27
21
|
* const client = Client.withTransport(transport);
|
|
@@ -36,14 +30,6 @@ export declare class DirectTransport implements ITransport {
|
|
|
36
30
|
private readonly clients;
|
|
37
31
|
private readonly sortedRoutes;
|
|
38
32
|
private parseErrorHandler;
|
|
39
|
-
/**
|
|
40
|
-
* Creates the session payload for internal service-to-service calls.
|
|
41
|
-
*
|
|
42
|
-
* Pass `user` when the call reaches resources an access policy guards (typically the platform
|
|
43
|
-
* SYSTEM user); omit it only for routes that need no actor. The payload is what the receiving
|
|
44
|
-
* backend authenticates as, so it must be re-signed whenever it changes.
|
|
45
|
-
*/
|
|
46
|
-
static createSessionPayload(user?: DirectTransportPrincipal | null): string;
|
|
47
33
|
constructor(defaultBaseUrl: string, sessionPayload: string, sessionSignature: string, routes?: DirectTransportRoute[]);
|
|
48
34
|
request<T>(action: string, parameters?: Parameters, method?: string, _signWithOauthToken?: boolean): Promise<T>;
|
|
49
35
|
private resolveClient;
|
|
@@ -4,12 +4,14 @@ import { OAuthClient } from './OAuthClient.js';
|
|
|
4
4
|
* Transport for internal service-to-service calls that bypasses Gateway OAuth.
|
|
5
5
|
* Authenticates via HMAC-signed session headers instead of an OAuth token.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* It carries the session payload and its signature without interpreting either: the payload's shape
|
|
8
|
+
* is a contract between Attlaz services, and building it needs `node:crypto` and platform models
|
|
9
|
+
* this package deliberately does not depend on. **Attlaz services should not construct this
|
|
10
|
+
* directly** — use `InternalTransportFactory.asSystem()` from `@attlaz/attlaz-core`, which owns that
|
|
11
|
+
* shape and does the signing.
|
|
9
12
|
*
|
|
10
|
-
* Usage:
|
|
13
|
+
* Usage (non-Attlaz callers, or anything supplying its own session):
|
|
11
14
|
* import {createHmac} from 'node:crypto';
|
|
12
|
-
* const sessionPayload = DirectTransport.createSessionPayload();
|
|
13
15
|
* const sessionSignature = createHmac('sha256', apiSecret).update(sessionPayload).digest('hex');
|
|
14
16
|
* const transport = new DirectTransport('http://core-api:5728', sessionPayload, sessionSignature);
|
|
15
17
|
* const client = Client.withTransport(transport);
|
|
@@ -24,24 +26,6 @@ export class DirectTransport {
|
|
|
24
26
|
clients = new Map();
|
|
25
27
|
sortedRoutes;
|
|
26
28
|
parseErrorHandler = null;
|
|
27
|
-
/**
|
|
28
|
-
* Creates the session payload for internal service-to-service calls.
|
|
29
|
-
*
|
|
30
|
-
* Pass `user` when the call reaches resources an access policy guards (typically the platform
|
|
31
|
-
* SYSTEM user); omit it only for routes that need no actor. The payload is what the receiving
|
|
32
|
-
* backend authenticates as, so it must be re-signed whenever it changes.
|
|
33
|
-
*/
|
|
34
|
-
static createSessionPayload(user = null) {
|
|
35
|
-
return JSON.stringify({
|
|
36
|
-
api_version: 'latest',
|
|
37
|
-
user: user,
|
|
38
|
-
client: null,
|
|
39
|
-
ip: 'internal',
|
|
40
|
-
roles: [],
|
|
41
|
-
scopes: [],
|
|
42
|
-
access_token: null,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
29
|
constructor(defaultBaseUrl, sessionPayload, sessionSignature, routes = []) {
|
|
46
30
|
// All routes plus the catch-all default, sorted by prefix length descending (most specific first)
|
|
47
31
|
this.sortedRoutes = [...routes, { prefix: '', baseUrl: defaultBaseUrl }]
|
|
@@ -11,6 +11,14 @@ export declare class AdapterConnectionEndpoint extends Endpoint {
|
|
|
11
11
|
getConnectionByKey(projectId: string, connectionKey: string): Promise<AdapterConnection | null>;
|
|
12
12
|
getConnectionConfiguration(connectionId: string): Promise<CollectionResult<AdapterConnectionConfigurationValue>>;
|
|
13
13
|
saveConnection(projectId: string, connection: AdapterConnection): Promise<AdapterConnection>;
|
|
14
|
+
/**
|
|
15
|
+
* Writes the supplied configurations and leaves the rest of the connection alone — PATCH, since
|
|
16
|
+
* it is a partial update. A configuration the API does not let a client set (a provider token)
|
|
17
|
+
* is untouched rather than cleared.
|
|
18
|
+
*
|
|
19
|
+
* Needs an API that serves the PATCH route; it is also still registered as POST for clients
|
|
20
|
+
* released before the verb changed.
|
|
21
|
+
*/
|
|
14
22
|
saveConnectionConfiguration(connectionId: string, configuration: AdapterConnectionConfigurationValue[]): Promise<boolean>;
|
|
15
23
|
getConnectionEvents(connectionId: string, pagination: CursorPagination): Promise<CollectionResult<AdapterConnectionEvent>>;
|
|
16
24
|
/**
|
|
@@ -79,11 +79,19 @@ export class AdapterConnectionEndpoint extends Endpoint {
|
|
|
79
79
|
throw error;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Writes the supplied configurations and leaves the rest of the connection alone — PATCH, since
|
|
84
|
+
* it is a partial update. A configuration the API does not let a client set (a provider token)
|
|
85
|
+
* is untouched rather than cleared.
|
|
86
|
+
*
|
|
87
|
+
* Needs an API that serves the PATCH route; it is also still registered as POST for clients
|
|
88
|
+
* released before the verb changed.
|
|
89
|
+
*/
|
|
82
90
|
async saveConnectionConfiguration(connectionId, configuration) {
|
|
83
91
|
try {
|
|
84
92
|
const url = path('/connections/:connectionId/configuration', { connectionId });
|
|
85
93
|
const parser = (raw) => ({ saved: raw.saved });
|
|
86
|
-
const result = await this.requestObject(url, { configuration: configuration }, parser, '
|
|
94
|
+
const result = await this.requestObject(url, { configuration: configuration }, parser, 'PATCH');
|
|
87
95
|
const res = result.getData();
|
|
88
96
|
if (res === null) {
|
|
89
97
|
throw new Error('Unable to save connection configuration: wrong response from API');
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { HttpClientRequest } from './Http/HttpClientRequest.js';
|
|
|
9
9
|
export { HttpClientResponse } from './Http/HttpClientResponse.js';
|
|
10
10
|
export { ITransport } from './Http/Transport/ITransport.js';
|
|
11
11
|
export { DirectTransport } from './Http/Transport/DirectTransport.js';
|
|
12
|
-
export type { DirectTransportRoute
|
|
12
|
+
export type { DirectTransportRoute } from './Http/Transport/DirectTransport.js';
|
|
13
13
|
export { OAuthClient } from './Http/Transport/OAuthClient.js';
|
|
14
14
|
export { OAuthClientOptions } from './Http/OAuthClientOptions.js';
|
|
15
15
|
export { OAuthClientToken } from './Http/OAuthClientToken.js';
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.103.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.103.0";
|