@uniformdev/mesh-sdk 20.50.2-alpha.39 → 20.50.2-alpha.77
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/index.d.mts +321 -11
- package/dist/index.d.ts +321 -11
- package/dist/index.esm.js +87 -25
- package/dist/index.js +88 -25
- package/dist/index.mjs +87 -25
- package/package.json +8 -8
package/dist/index.esm.js
CHANGED
|
@@ -8,6 +8,48 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
8
8
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
9
|
|
|
10
10
|
// src/clients/DelegationTokenClient.ts
|
|
11
|
+
var DelegationTokenError = class extends Error {
|
|
12
|
+
constructor(status, kind, publicMessage) {
|
|
13
|
+
super(publicMessage);
|
|
14
|
+
this.name = "DelegationTokenError";
|
|
15
|
+
this.status = status;
|
|
16
|
+
this.kind = kind;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var PUBLIC_MESSAGES = {
|
|
20
|
+
bad_request: "Token exchange request was rejected as invalid",
|
|
21
|
+
unauthenticated: "Token exchange authentication failed",
|
|
22
|
+
forbidden: "Token exchange forbidden by server",
|
|
23
|
+
not_found: "Token exchange target was not found",
|
|
24
|
+
rate_limited: "Token exchange rate limit exceeded",
|
|
25
|
+
server_error: "Token exchange server error",
|
|
26
|
+
unknown: "Token exchange failed"
|
|
27
|
+
};
|
|
28
|
+
function classifyDelegationTokenStatus(status) {
|
|
29
|
+
if (status === 400) {
|
|
30
|
+
return "bad_request";
|
|
31
|
+
}
|
|
32
|
+
if (status === 401) {
|
|
33
|
+
return "unauthenticated";
|
|
34
|
+
}
|
|
35
|
+
if (status === 403) {
|
|
36
|
+
return "forbidden";
|
|
37
|
+
}
|
|
38
|
+
if (status === 404) {
|
|
39
|
+
return "not_found";
|
|
40
|
+
}
|
|
41
|
+
if (status === 429) {
|
|
42
|
+
return "rate_limited";
|
|
43
|
+
}
|
|
44
|
+
if (status >= 500) {
|
|
45
|
+
return "server_error";
|
|
46
|
+
}
|
|
47
|
+
return "unknown";
|
|
48
|
+
}
|
|
49
|
+
function buildDelegationTokenError(status) {
|
|
50
|
+
const kind = classifyDelegationTokenStatus(status);
|
|
51
|
+
return new DelegationTokenError(status, kind, PUBLIC_MESSAGES[kind]);
|
|
52
|
+
}
|
|
11
53
|
var _options, _DelegationTokenClient_instances, post_fn;
|
|
12
54
|
var DelegationTokenClient = class {
|
|
13
55
|
constructor(options) {
|
|
@@ -18,6 +60,8 @@ var DelegationTokenClient = class {
|
|
|
18
60
|
/**
|
|
19
61
|
* Exchanges a short-lived session token for a delegation token and refresh token.
|
|
20
62
|
* The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
|
|
63
|
+
*
|
|
64
|
+
* @deprecated This beta identity delegation API may change with breaking changes.
|
|
21
65
|
*/
|
|
22
66
|
async exchangeSessionToken(sessionToken) {
|
|
23
67
|
return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
|
|
@@ -28,8 +72,15 @@ var DelegationTokenClient = class {
|
|
|
28
72
|
});
|
|
29
73
|
}
|
|
30
74
|
/**
|
|
31
|
-
* Exchanges a refresh token for a new delegation token and refresh token.
|
|
32
|
-
*
|
|
75
|
+
* Exchanges a refresh token for a new delegation token and a new refresh token.
|
|
76
|
+
*
|
|
77
|
+
* Replay posture: refresh tokens are bearer credentials that are valid until
|
|
78
|
+
* their server-side expiry. They are NOT single-use — a captured refresh token can be
|
|
79
|
+
* replayed by an attacker that also has the integration secret until it expires.
|
|
80
|
+
* Single-use enforcement (refresh-token storage, family/jti tracking, replay revocation)
|
|
81
|
+
* is tracked in `UNI-9279`.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated This beta identity delegation API may change with breaking changes.
|
|
33
84
|
*/
|
|
34
85
|
async refreshDelegationToken(refreshToken) {
|
|
35
86
|
return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
|
|
@@ -43,7 +94,6 @@ var DelegationTokenClient = class {
|
|
|
43
94
|
_options = new WeakMap();
|
|
44
95
|
_DelegationTokenClient_instances = new WeakSet();
|
|
45
96
|
post_fn = async function(body) {
|
|
46
|
-
var _a;
|
|
47
97
|
const url = `${__privateGet(this, _options).apiHost}/api/v1/token`;
|
|
48
98
|
const response = await fetch(url, {
|
|
49
99
|
method: "POST",
|
|
@@ -51,32 +101,15 @@ post_fn = async function(body) {
|
|
|
51
101
|
body: JSON.stringify(body)
|
|
52
102
|
});
|
|
53
103
|
if (!response.ok) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw new Error(`Token exchange failed (${response.status}): ${detail}`);
|
|
104
|
+
await response.text().catch(() => "");
|
|
105
|
+
throw buildDelegationTokenError(response.status);
|
|
57
106
|
}
|
|
58
107
|
return await response.json();
|
|
59
108
|
};
|
|
60
|
-
function extractErrorMessage(text) {
|
|
61
|
-
try {
|
|
62
|
-
const parsed = JSON.parse(text);
|
|
63
|
-
if (typeof parsed.errorMessage === "string") {
|
|
64
|
-
return parsed.errorMessage;
|
|
65
|
-
}
|
|
66
|
-
if (typeof parsed.error === "string") {
|
|
67
|
-
return parsed.error;
|
|
68
|
-
}
|
|
69
|
-
if (typeof parsed.message === "string") {
|
|
70
|
-
return parsed.message;
|
|
71
|
-
}
|
|
72
|
-
} catch (e) {
|
|
73
|
-
}
|
|
74
|
-
return void 0;
|
|
75
|
-
}
|
|
76
109
|
|
|
77
110
|
// src/clients/IntegrationDefinitionClient.ts
|
|
78
111
|
import { ApiClient } from "@uniformdev/context/api";
|
|
79
|
-
var _url;
|
|
112
|
+
var _url, _credentialsUrl;
|
|
80
113
|
var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends ApiClient {
|
|
81
114
|
constructor(options) {
|
|
82
115
|
super(options);
|
|
@@ -87,7 +120,7 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
|
|
|
87
120
|
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url), { ...options, teamId });
|
|
88
121
|
return await this.apiClient(fetchUri);
|
|
89
122
|
}
|
|
90
|
-
/** Creates or updates a mesh app definition on a team */
|
|
123
|
+
/** Creates or updates a mesh app definition on a team. Identity-delegation credentials must be minted separately via {@link rotateCredential}. */
|
|
91
124
|
async upsert(body) {
|
|
92
125
|
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url));
|
|
93
126
|
return await this.apiClient(fetchUri, {
|
|
@@ -104,9 +137,37 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
|
|
|
104
137
|
expectNoContent: true
|
|
105
138
|
});
|
|
106
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Mints or rotates an identity-delegation credential for an integration definition. The plaintext
|
|
142
|
+
* `appSecret` is returned exactly once and is not retrievable afterwards — Uniform stores only
|
|
143
|
+
* the hash. A successful response invalidates any previously-issued secret of the same kind.
|
|
144
|
+
* Caller must be a team admin.
|
|
145
|
+
*/
|
|
146
|
+
async rotateCredential(body) {
|
|
147
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
|
|
148
|
+
return await this.apiClient(fetchUri, {
|
|
149
|
+
method: "POST",
|
|
150
|
+
body: JSON.stringify({ ...body, teamId: this.options.teamId })
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Revokes an identity-delegation credential. Future delegation grants and refreshes will fail
|
|
155
|
+
* until a new credential is minted; in-flight delegation tokens remain valid until natural
|
|
156
|
+
* expiry (up to ~15 minutes). Caller must be a team admin.
|
|
157
|
+
*/
|
|
158
|
+
async revokeCredential(body) {
|
|
159
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
|
|
160
|
+
await this.apiClient(fetchUri, {
|
|
161
|
+
method: "DELETE",
|
|
162
|
+
body: JSON.stringify({ ...body, teamId: this.options.teamId }),
|
|
163
|
+
expectNoContent: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
107
166
|
};
|
|
108
167
|
_url = new WeakMap();
|
|
168
|
+
_credentialsUrl = new WeakMap();
|
|
109
169
|
__privateAdd(_IntegrationDefinitionClient, _url, "/api/v1/integration-definitions");
|
|
170
|
+
__privateAdd(_IntegrationDefinitionClient, _credentialsUrl, "/api/v1/integration-credentials");
|
|
110
171
|
var IntegrationDefinitionClient = _IntegrationDefinitionClient;
|
|
111
172
|
|
|
112
173
|
// src/clients/IntegrationInstallationClient.ts
|
|
@@ -200,7 +261,7 @@ var getLogger = (prefix, debug) => {
|
|
|
200
261
|
};
|
|
201
262
|
|
|
202
263
|
// src/temp/version.ts
|
|
203
|
-
var UNIFORM_MESH_SDK_VERSION = "20.
|
|
264
|
+
var UNIFORM_MESH_SDK_VERSION = "20.61.1";
|
|
204
265
|
|
|
205
266
|
// src/framepost/constants.ts
|
|
206
267
|
var DEFAULT_REQUEST_TIMEOUT = 5e3;
|
|
@@ -916,6 +977,7 @@ var hasRole = (role, user) => {
|
|
|
916
977
|
};
|
|
917
978
|
export {
|
|
918
979
|
DelegationTokenClient,
|
|
980
|
+
DelegationTokenError,
|
|
919
981
|
IntegrationDefinitionClient,
|
|
920
982
|
IntegrationInstallationClient,
|
|
921
983
|
functionCallSystemParameters,
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
39
39
|
var src_exports = {};
|
|
40
40
|
__export(src_exports, {
|
|
41
41
|
DelegationTokenClient: () => DelegationTokenClient,
|
|
42
|
+
DelegationTokenError: () => DelegationTokenError,
|
|
42
43
|
IntegrationDefinitionClient: () => IntegrationDefinitionClient,
|
|
43
44
|
IntegrationInstallationClient: () => IntegrationInstallationClient,
|
|
44
45
|
functionCallSystemParameters: () => functionCallSystemParameters,
|
|
@@ -50,6 +51,48 @@ __export(src_exports, {
|
|
|
50
51
|
module.exports = __toCommonJS(src_exports);
|
|
51
52
|
|
|
52
53
|
// src/clients/DelegationTokenClient.ts
|
|
54
|
+
var DelegationTokenError = class extends Error {
|
|
55
|
+
constructor(status, kind, publicMessage) {
|
|
56
|
+
super(publicMessage);
|
|
57
|
+
this.name = "DelegationTokenError";
|
|
58
|
+
this.status = status;
|
|
59
|
+
this.kind = kind;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var PUBLIC_MESSAGES = {
|
|
63
|
+
bad_request: "Token exchange request was rejected as invalid",
|
|
64
|
+
unauthenticated: "Token exchange authentication failed",
|
|
65
|
+
forbidden: "Token exchange forbidden by server",
|
|
66
|
+
not_found: "Token exchange target was not found",
|
|
67
|
+
rate_limited: "Token exchange rate limit exceeded",
|
|
68
|
+
server_error: "Token exchange server error",
|
|
69
|
+
unknown: "Token exchange failed"
|
|
70
|
+
};
|
|
71
|
+
function classifyDelegationTokenStatus(status) {
|
|
72
|
+
if (status === 400) {
|
|
73
|
+
return "bad_request";
|
|
74
|
+
}
|
|
75
|
+
if (status === 401) {
|
|
76
|
+
return "unauthenticated";
|
|
77
|
+
}
|
|
78
|
+
if (status === 403) {
|
|
79
|
+
return "forbidden";
|
|
80
|
+
}
|
|
81
|
+
if (status === 404) {
|
|
82
|
+
return "not_found";
|
|
83
|
+
}
|
|
84
|
+
if (status === 429) {
|
|
85
|
+
return "rate_limited";
|
|
86
|
+
}
|
|
87
|
+
if (status >= 500) {
|
|
88
|
+
return "server_error";
|
|
89
|
+
}
|
|
90
|
+
return "unknown";
|
|
91
|
+
}
|
|
92
|
+
function buildDelegationTokenError(status) {
|
|
93
|
+
const kind = classifyDelegationTokenStatus(status);
|
|
94
|
+
return new DelegationTokenError(status, kind, PUBLIC_MESSAGES[kind]);
|
|
95
|
+
}
|
|
53
96
|
var _options, _DelegationTokenClient_instances, post_fn;
|
|
54
97
|
var DelegationTokenClient = class {
|
|
55
98
|
constructor(options) {
|
|
@@ -60,6 +103,8 @@ var DelegationTokenClient = class {
|
|
|
60
103
|
/**
|
|
61
104
|
* Exchanges a short-lived session token for a delegation token and refresh token.
|
|
62
105
|
* The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
|
|
106
|
+
*
|
|
107
|
+
* @deprecated This beta identity delegation API may change with breaking changes.
|
|
63
108
|
*/
|
|
64
109
|
async exchangeSessionToken(sessionToken) {
|
|
65
110
|
return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
|
|
@@ -70,8 +115,15 @@ var DelegationTokenClient = class {
|
|
|
70
115
|
});
|
|
71
116
|
}
|
|
72
117
|
/**
|
|
73
|
-
* Exchanges a refresh token for a new delegation token and refresh token.
|
|
74
|
-
*
|
|
118
|
+
* Exchanges a refresh token for a new delegation token and a new refresh token.
|
|
119
|
+
*
|
|
120
|
+
* Replay posture: refresh tokens are bearer credentials that are valid until
|
|
121
|
+
* their server-side expiry. They are NOT single-use — a captured refresh token can be
|
|
122
|
+
* replayed by an attacker that also has the integration secret until it expires.
|
|
123
|
+
* Single-use enforcement (refresh-token storage, family/jti tracking, replay revocation)
|
|
124
|
+
* is tracked in `UNI-9279`.
|
|
125
|
+
*
|
|
126
|
+
* @deprecated This beta identity delegation API may change with breaking changes.
|
|
75
127
|
*/
|
|
76
128
|
async refreshDelegationToken(refreshToken) {
|
|
77
129
|
return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
|
|
@@ -85,7 +137,6 @@ var DelegationTokenClient = class {
|
|
|
85
137
|
_options = new WeakMap();
|
|
86
138
|
_DelegationTokenClient_instances = new WeakSet();
|
|
87
139
|
post_fn = async function(body) {
|
|
88
|
-
var _a;
|
|
89
140
|
const url = `${__privateGet(this, _options).apiHost}/api/v1/token`;
|
|
90
141
|
const response = await fetch(url, {
|
|
91
142
|
method: "POST",
|
|
@@ -93,32 +144,15 @@ post_fn = async function(body) {
|
|
|
93
144
|
body: JSON.stringify(body)
|
|
94
145
|
});
|
|
95
146
|
if (!response.ok) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
throw new Error(`Token exchange failed (${response.status}): ${detail}`);
|
|
147
|
+
await response.text().catch(() => "");
|
|
148
|
+
throw buildDelegationTokenError(response.status);
|
|
99
149
|
}
|
|
100
150
|
return await response.json();
|
|
101
151
|
};
|
|
102
|
-
function extractErrorMessage(text) {
|
|
103
|
-
try {
|
|
104
|
-
const parsed = JSON.parse(text);
|
|
105
|
-
if (typeof parsed.errorMessage === "string") {
|
|
106
|
-
return parsed.errorMessage;
|
|
107
|
-
}
|
|
108
|
-
if (typeof parsed.error === "string") {
|
|
109
|
-
return parsed.error;
|
|
110
|
-
}
|
|
111
|
-
if (typeof parsed.message === "string") {
|
|
112
|
-
return parsed.message;
|
|
113
|
-
}
|
|
114
|
-
} catch (e) {
|
|
115
|
-
}
|
|
116
|
-
return void 0;
|
|
117
|
-
}
|
|
118
152
|
|
|
119
153
|
// src/clients/IntegrationDefinitionClient.ts
|
|
120
154
|
var import_api = require("@uniformdev/context/api");
|
|
121
|
-
var _url;
|
|
155
|
+
var _url, _credentialsUrl;
|
|
122
156
|
var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends import_api.ApiClient {
|
|
123
157
|
constructor(options) {
|
|
124
158
|
super(options);
|
|
@@ -129,7 +163,7 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends im
|
|
|
129
163
|
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url), { ...options, teamId });
|
|
130
164
|
return await this.apiClient(fetchUri);
|
|
131
165
|
}
|
|
132
|
-
/** Creates or updates a mesh app definition on a team */
|
|
166
|
+
/** Creates or updates a mesh app definition on a team. Identity-delegation credentials must be minted separately via {@link rotateCredential}. */
|
|
133
167
|
async upsert(body) {
|
|
134
168
|
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url));
|
|
135
169
|
return await this.apiClient(fetchUri, {
|
|
@@ -146,9 +180,37 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends im
|
|
|
146
180
|
expectNoContent: true
|
|
147
181
|
});
|
|
148
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Mints or rotates an identity-delegation credential for an integration definition. The plaintext
|
|
185
|
+
* `appSecret` is returned exactly once and is not retrievable afterwards — Uniform stores only
|
|
186
|
+
* the hash. A successful response invalidates any previously-issued secret of the same kind.
|
|
187
|
+
* Caller must be a team admin.
|
|
188
|
+
*/
|
|
189
|
+
async rotateCredential(body) {
|
|
190
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
|
|
191
|
+
return await this.apiClient(fetchUri, {
|
|
192
|
+
method: "POST",
|
|
193
|
+
body: JSON.stringify({ ...body, teamId: this.options.teamId })
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Revokes an identity-delegation credential. Future delegation grants and refreshes will fail
|
|
198
|
+
* until a new credential is minted; in-flight delegation tokens remain valid until natural
|
|
199
|
+
* expiry (up to ~15 minutes). Caller must be a team admin.
|
|
200
|
+
*/
|
|
201
|
+
async revokeCredential(body) {
|
|
202
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
|
|
203
|
+
await this.apiClient(fetchUri, {
|
|
204
|
+
method: "DELETE",
|
|
205
|
+
body: JSON.stringify({ ...body, teamId: this.options.teamId }),
|
|
206
|
+
expectNoContent: true
|
|
207
|
+
});
|
|
208
|
+
}
|
|
149
209
|
};
|
|
150
210
|
_url = new WeakMap();
|
|
211
|
+
_credentialsUrl = new WeakMap();
|
|
151
212
|
__privateAdd(_IntegrationDefinitionClient, _url, "/api/v1/integration-definitions");
|
|
213
|
+
__privateAdd(_IntegrationDefinitionClient, _credentialsUrl, "/api/v1/integration-credentials");
|
|
152
214
|
var IntegrationDefinitionClient = _IntegrationDefinitionClient;
|
|
153
215
|
|
|
154
216
|
// src/clients/IntegrationInstallationClient.ts
|
|
@@ -242,7 +304,7 @@ var getLogger = (prefix, debug) => {
|
|
|
242
304
|
};
|
|
243
305
|
|
|
244
306
|
// src/temp/version.ts
|
|
245
|
-
var UNIFORM_MESH_SDK_VERSION = "20.
|
|
307
|
+
var UNIFORM_MESH_SDK_VERSION = "20.61.1";
|
|
246
308
|
|
|
247
309
|
// src/framepost/constants.ts
|
|
248
310
|
var DEFAULT_REQUEST_TIMEOUT = 5e3;
|
|
@@ -959,6 +1021,7 @@ var hasRole = (role, user) => {
|
|
|
959
1021
|
// Annotate the CommonJS export names for ESM import in node:
|
|
960
1022
|
0 && (module.exports = {
|
|
961
1023
|
DelegationTokenClient,
|
|
1024
|
+
DelegationTokenError,
|
|
962
1025
|
IntegrationDefinitionClient,
|
|
963
1026
|
IntegrationInstallationClient,
|
|
964
1027
|
functionCallSystemParameters,
|
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,48 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
8
8
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
9
|
|
|
10
10
|
// src/clients/DelegationTokenClient.ts
|
|
11
|
+
var DelegationTokenError = class extends Error {
|
|
12
|
+
constructor(status, kind, publicMessage) {
|
|
13
|
+
super(publicMessage);
|
|
14
|
+
this.name = "DelegationTokenError";
|
|
15
|
+
this.status = status;
|
|
16
|
+
this.kind = kind;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var PUBLIC_MESSAGES = {
|
|
20
|
+
bad_request: "Token exchange request was rejected as invalid",
|
|
21
|
+
unauthenticated: "Token exchange authentication failed",
|
|
22
|
+
forbidden: "Token exchange forbidden by server",
|
|
23
|
+
not_found: "Token exchange target was not found",
|
|
24
|
+
rate_limited: "Token exchange rate limit exceeded",
|
|
25
|
+
server_error: "Token exchange server error",
|
|
26
|
+
unknown: "Token exchange failed"
|
|
27
|
+
};
|
|
28
|
+
function classifyDelegationTokenStatus(status) {
|
|
29
|
+
if (status === 400) {
|
|
30
|
+
return "bad_request";
|
|
31
|
+
}
|
|
32
|
+
if (status === 401) {
|
|
33
|
+
return "unauthenticated";
|
|
34
|
+
}
|
|
35
|
+
if (status === 403) {
|
|
36
|
+
return "forbidden";
|
|
37
|
+
}
|
|
38
|
+
if (status === 404) {
|
|
39
|
+
return "not_found";
|
|
40
|
+
}
|
|
41
|
+
if (status === 429) {
|
|
42
|
+
return "rate_limited";
|
|
43
|
+
}
|
|
44
|
+
if (status >= 500) {
|
|
45
|
+
return "server_error";
|
|
46
|
+
}
|
|
47
|
+
return "unknown";
|
|
48
|
+
}
|
|
49
|
+
function buildDelegationTokenError(status) {
|
|
50
|
+
const kind = classifyDelegationTokenStatus(status);
|
|
51
|
+
return new DelegationTokenError(status, kind, PUBLIC_MESSAGES[kind]);
|
|
52
|
+
}
|
|
11
53
|
var _options, _DelegationTokenClient_instances, post_fn;
|
|
12
54
|
var DelegationTokenClient = class {
|
|
13
55
|
constructor(options) {
|
|
@@ -18,6 +60,8 @@ var DelegationTokenClient = class {
|
|
|
18
60
|
/**
|
|
19
61
|
* Exchanges a short-lived session token for a delegation token and refresh token.
|
|
20
62
|
* The session token is obtained by the integration's frontend via `sdk.getSessionToken()`.
|
|
63
|
+
*
|
|
64
|
+
* @deprecated This beta identity delegation API may change with breaking changes.
|
|
21
65
|
*/
|
|
22
66
|
async exchangeSessionToken(sessionToken) {
|
|
23
67
|
return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
|
|
@@ -28,8 +72,15 @@ var DelegationTokenClient = class {
|
|
|
28
72
|
});
|
|
29
73
|
}
|
|
30
74
|
/**
|
|
31
|
-
* Exchanges a refresh token for a new delegation token and refresh token.
|
|
32
|
-
*
|
|
75
|
+
* Exchanges a refresh token for a new delegation token and a new refresh token.
|
|
76
|
+
*
|
|
77
|
+
* Replay posture: refresh tokens are bearer credentials that are valid until
|
|
78
|
+
* their server-side expiry. They are NOT single-use — a captured refresh token can be
|
|
79
|
+
* replayed by an attacker that also has the integration secret until it expires.
|
|
80
|
+
* Single-use enforcement (refresh-token storage, family/jti tracking, replay revocation)
|
|
81
|
+
* is tracked in `UNI-9279`.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated This beta identity delegation API may change with breaking changes.
|
|
33
84
|
*/
|
|
34
85
|
async refreshDelegationToken(refreshToken) {
|
|
35
86
|
return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
|
|
@@ -43,7 +94,6 @@ var DelegationTokenClient = class {
|
|
|
43
94
|
_options = new WeakMap();
|
|
44
95
|
_DelegationTokenClient_instances = new WeakSet();
|
|
45
96
|
post_fn = async function(body) {
|
|
46
|
-
var _a;
|
|
47
97
|
const url = `${__privateGet(this, _options).apiHost}/api/v1/token`;
|
|
48
98
|
const response = await fetch(url, {
|
|
49
99
|
method: "POST",
|
|
@@ -51,32 +101,15 @@ post_fn = async function(body) {
|
|
|
51
101
|
body: JSON.stringify(body)
|
|
52
102
|
});
|
|
53
103
|
if (!response.ok) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw new Error(`Token exchange failed (${response.status}): ${detail}`);
|
|
104
|
+
await response.text().catch(() => "");
|
|
105
|
+
throw buildDelegationTokenError(response.status);
|
|
57
106
|
}
|
|
58
107
|
return await response.json();
|
|
59
108
|
};
|
|
60
|
-
function extractErrorMessage(text) {
|
|
61
|
-
try {
|
|
62
|
-
const parsed = JSON.parse(text);
|
|
63
|
-
if (typeof parsed.errorMessage === "string") {
|
|
64
|
-
return parsed.errorMessage;
|
|
65
|
-
}
|
|
66
|
-
if (typeof parsed.error === "string") {
|
|
67
|
-
return parsed.error;
|
|
68
|
-
}
|
|
69
|
-
if (typeof parsed.message === "string") {
|
|
70
|
-
return parsed.message;
|
|
71
|
-
}
|
|
72
|
-
} catch (e) {
|
|
73
|
-
}
|
|
74
|
-
return void 0;
|
|
75
|
-
}
|
|
76
109
|
|
|
77
110
|
// src/clients/IntegrationDefinitionClient.ts
|
|
78
111
|
import { ApiClient } from "@uniformdev/context/api";
|
|
79
|
-
var _url;
|
|
112
|
+
var _url, _credentialsUrl;
|
|
80
113
|
var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends ApiClient {
|
|
81
114
|
constructor(options) {
|
|
82
115
|
super(options);
|
|
@@ -87,7 +120,7 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
|
|
|
87
120
|
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url), { ...options, teamId });
|
|
88
121
|
return await this.apiClient(fetchUri);
|
|
89
122
|
}
|
|
90
|
-
/** Creates or updates a mesh app definition on a team */
|
|
123
|
+
/** Creates or updates a mesh app definition on a team. Identity-delegation credentials must be minted separately via {@link rotateCredential}. */
|
|
91
124
|
async upsert(body) {
|
|
92
125
|
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url));
|
|
93
126
|
return await this.apiClient(fetchUri, {
|
|
@@ -104,9 +137,37 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
|
|
|
104
137
|
expectNoContent: true
|
|
105
138
|
});
|
|
106
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Mints or rotates an identity-delegation credential for an integration definition. The plaintext
|
|
142
|
+
* `appSecret` is returned exactly once and is not retrievable afterwards — Uniform stores only
|
|
143
|
+
* the hash. A successful response invalidates any previously-issued secret of the same kind.
|
|
144
|
+
* Caller must be a team admin.
|
|
145
|
+
*/
|
|
146
|
+
async rotateCredential(body) {
|
|
147
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
|
|
148
|
+
return await this.apiClient(fetchUri, {
|
|
149
|
+
method: "POST",
|
|
150
|
+
body: JSON.stringify({ ...body, teamId: this.options.teamId })
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Revokes an identity-delegation credential. Future delegation grants and refreshes will fail
|
|
155
|
+
* until a new credential is minted; in-flight delegation tokens remain valid until natural
|
|
156
|
+
* expiry (up to ~15 minutes). Caller must be a team admin.
|
|
157
|
+
*/
|
|
158
|
+
async revokeCredential(body) {
|
|
159
|
+
const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _credentialsUrl));
|
|
160
|
+
await this.apiClient(fetchUri, {
|
|
161
|
+
method: "DELETE",
|
|
162
|
+
body: JSON.stringify({ ...body, teamId: this.options.teamId }),
|
|
163
|
+
expectNoContent: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
107
166
|
};
|
|
108
167
|
_url = new WeakMap();
|
|
168
|
+
_credentialsUrl = new WeakMap();
|
|
109
169
|
__privateAdd(_IntegrationDefinitionClient, _url, "/api/v1/integration-definitions");
|
|
170
|
+
__privateAdd(_IntegrationDefinitionClient, _credentialsUrl, "/api/v1/integration-credentials");
|
|
110
171
|
var IntegrationDefinitionClient = _IntegrationDefinitionClient;
|
|
111
172
|
|
|
112
173
|
// src/clients/IntegrationInstallationClient.ts
|
|
@@ -200,7 +261,7 @@ var getLogger = (prefix, debug) => {
|
|
|
200
261
|
};
|
|
201
262
|
|
|
202
263
|
// src/temp/version.ts
|
|
203
|
-
var UNIFORM_MESH_SDK_VERSION = "20.
|
|
264
|
+
var UNIFORM_MESH_SDK_VERSION = "20.61.1";
|
|
204
265
|
|
|
205
266
|
// src/framepost/constants.ts
|
|
206
267
|
var DEFAULT_REQUEST_TIMEOUT = 5e3;
|
|
@@ -916,6 +977,7 @@ var hasRole = (role, user) => {
|
|
|
916
977
|
};
|
|
917
978
|
export {
|
|
918
979
|
DelegationTokenClient,
|
|
980
|
+
DelegationTokenError,
|
|
919
981
|
IntegrationDefinitionClient,
|
|
920
982
|
IntegrationInstallationClient,
|
|
921
983
|
functionCallSystemParameters,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/mesh-sdk",
|
|
3
|
-
"version": "20.50.2-alpha.
|
|
3
|
+
"version": "20.50.2-alpha.77+51415ad3dd",
|
|
4
4
|
"description": "Uniform Mesh Framework SDK",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"build:setversion": "tsx ./scripts/set-version.ts",
|
|
22
22
|
"dev": "pnpm update-openapi && pnpm build:setversion && tsup --watch",
|
|
23
23
|
"clean": "rimraf dist",
|
|
24
|
-
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
25
24
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
25
|
+
"test": "vitest run",
|
|
26
26
|
"update-openapi": "tsx ./scripts/update-openapi.cts",
|
|
27
|
-
"
|
|
27
|
+
"apidocs-extract": "api-extractor run --local"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"/dist"
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@uniformdev/assets": "20.50.2-alpha.
|
|
37
|
-
"@uniformdev/canvas": "20.50.2-alpha.
|
|
38
|
-
"@uniformdev/context": "20.50.2-alpha.
|
|
39
|
-
"@uniformdev/project-map": "20.50.2-alpha.
|
|
36
|
+
"@uniformdev/assets": "20.50.2-alpha.77+51415ad3dd",
|
|
37
|
+
"@uniformdev/canvas": "20.50.2-alpha.77+51415ad3dd",
|
|
38
|
+
"@uniformdev/context": "20.50.2-alpha.77+51415ad3dd",
|
|
39
|
+
"@uniformdev/project-map": "20.50.2-alpha.77+51415ad3dd",
|
|
40
40
|
"imagesloaded": "^5.0.0",
|
|
41
41
|
"mitt": "^3.0.1"
|
|
42
42
|
},
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/imagesloaded": "^4.1.2",
|
|
45
45
|
"openai": "4.94.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "51415ad3ddc2e973a8c52fc4116df82182f9c44b"
|
|
48
48
|
}
|