@uniformdev/mesh-sdk 20.50.2-alpha.9 → 20.50.2-alpha.96

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.esm.js CHANGED
@@ -4,10 +4,112 @@ var __typeError = (msg) => {
4
4
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
5
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+
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
+ }
53
+ var _options, _DelegationTokenClient_instances, post_fn;
54
+ var DelegationTokenClient = class {
55
+ constructor(options) {
56
+ __privateAdd(this, _DelegationTokenClient_instances);
57
+ __privateAdd(this, _options);
58
+ __privateSet(this, _options, options);
59
+ }
60
+ /**
61
+ * Exchanges a short-lived session token for a delegation token and refresh token.
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.
65
+ */
66
+ async exchangeSessionToken(sessionToken) {
67
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
68
+ grant_type: "delegation_token",
69
+ sessionToken,
70
+ integrationId: __privateGet(this, _options).integrationId,
71
+ integrationSecret: __privateGet(this, _options).integrationSecret
72
+ });
73
+ }
74
+ /**
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.
84
+ */
85
+ async refreshDelegationToken(refreshToken) {
86
+ return __privateMethod(this, _DelegationTokenClient_instances, post_fn).call(this, {
87
+ grant_type: "refresh_token",
88
+ refreshToken,
89
+ integrationId: __privateGet(this, _options).integrationId,
90
+ integrationSecret: __privateGet(this, _options).integrationSecret
91
+ });
92
+ }
93
+ };
94
+ _options = new WeakMap();
95
+ _DelegationTokenClient_instances = new WeakSet();
96
+ post_fn = async function(body) {
97
+ const url = `${__privateGet(this, _options).apiHost}/api/v1/token`;
98
+ const response = await fetch(url, {
99
+ method: "POST",
100
+ headers: { "Content-Type": "application/json" },
101
+ body: JSON.stringify(body)
102
+ });
103
+ if (!response.ok) {
104
+ await response.text().catch(() => "");
105
+ throw buildDelegationTokenError(response.status);
106
+ }
107
+ return await response.json();
108
+ };
7
109
 
8
110
  // src/clients/IntegrationDefinitionClient.ts
9
111
  import { ApiClient } from "@uniformdev/context/api";
10
- var _url;
112
+ var _url, _credentialsUrl;
11
113
  var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends ApiClient {
12
114
  constructor(options) {
13
115
  super(options);
@@ -18,7 +120,7 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
18
120
  const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url), { ...options, teamId });
19
121
  return await this.apiClient(fetchUri);
20
122
  }
21
- /** 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}. */
22
124
  async upsert(body) {
23
125
  const fetchUri = this.createUrl(__privateGet(_IntegrationDefinitionClient, _url));
24
126
  return await this.apiClient(fetchUri, {
@@ -35,9 +137,37 @@ var _IntegrationDefinitionClient = class _IntegrationDefinitionClient extends Ap
35
137
  expectNoContent: true
36
138
  });
37
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
+ }
38
166
  };
39
167
  _url = new WeakMap();
168
+ _credentialsUrl = new WeakMap();
40
169
  __privateAdd(_IntegrationDefinitionClient, _url, "/api/v1/integration-definitions");
170
+ __privateAdd(_IntegrationDefinitionClient, _credentialsUrl, "/api/v1/integration-credentials");
41
171
  var IntegrationDefinitionClient = _IntegrationDefinitionClient;
42
172
 
43
173
  // src/clients/IntegrationInstallationClient.ts
@@ -131,7 +261,7 @@ var getLogger = (prefix, debug) => {
131
261
  };
132
262
 
133
263
  // src/temp/version.ts
134
- var UNIFORM_MESH_SDK_VERSION = "20.50.1";
264
+ var UNIFORM_MESH_SDK_VERSION = "20.63.0";
135
265
 
136
266
  // src/framepost/constants.ts
137
267
  var DEFAULT_REQUEST_TIMEOUT = 5e3;
@@ -488,159 +618,63 @@ async function connectToParent({
488
618
  });
489
619
  client.onRequest("metadata-value", onMetadataUpdated);
490
620
  client.onRequest("external-value-update", onValueExternallyUpdated);
491
- return {
492
- initData,
493
- parent: {
494
- resize: async ({ height }) => {
495
- await client.request("resize", { height });
496
- },
497
- setValue: async (value) => {
498
- await client.request("setValue", value);
499
- },
500
- openDialog: async (message) => {
501
- const res = await client.request(
502
- "openDialog",
503
- message
504
- );
505
- const dialogId = res == null ? void 0 : res.dialogId;
506
- if (!dialogId) {
507
- return;
508
- }
509
- return new Promise((resolve, reject) => {
510
- dialogResponseHandlers[dialogId] = { resolve, reject };
511
- });
512
- },
513
- closeDialog: async (message) => {
514
- await client.request("closeDialog", message);
515
- },
516
- getDataResource: async (message) => {
517
- return await client.request("getDataResource", message, {
518
- timeout: 3e4
519
- });
520
- },
521
- navigate: async (message) => {
522
- await client.request("navigate", message);
523
- },
524
- reloadLocation: async () => {
525
- await client.request("reload");
526
- },
527
- editConnectedData: async (message) => {
528
- return await client.request(
529
- "editConnectedData",
530
- message,
531
- {
532
- timeout: (
533
- // 24 hours in ms
534
- 864e5
535
- )
536
- }
537
- );
538
- },
539
- editorState: createEditorStateApi(client)
540
- }
541
- };
542
- }
543
- function createEditorStateApi(client) {
544
- let cachedRootNodeId;
545
- return {
546
- async getRootNodeId() {
547
- if (cachedRootNodeId) {
548
- return cachedRootNodeId;
549
- }
550
- const result = await client.request("editorState.getRootNodeId");
551
- cachedRootNodeId = result;
552
- return result;
553
- },
554
- // Read operations
555
- async exportTree(params) {
556
- const result = await client.request("editorState.exportTree", params);
557
- cachedRootNodeId != null ? cachedRootNodeId : cachedRootNodeId = result == null ? void 0 : result._id;
558
- return result;
559
- },
560
- async exportSubtree(params) {
561
- return await client.request("editorState.exportSubtree", params);
562
- },
563
- async exportMetadata() {
564
- return await client.request("editorState.exportMetadata");
565
- },
566
- async exportRootNodeMetadata() {
567
- return await client.request("editorState.exportRootNodeMetadata");
568
- },
569
- async getNodeById(params) {
570
- return await client.request("editorState.getNodeById", params);
571
- },
572
- async getNodeChildren(params) {
573
- return await client.request("editorState.getNodeChildren", params);
574
- },
575
- async getNodeProperty(params) {
576
- return await client.request("editorState.getNodeProperty", params);
577
- },
578
- async getNodeProperties(params) {
579
- return await client.request("editorState.getNodeProperties", params);
580
- },
581
- async getParentInfo(params) {
582
- return await client.request("editorState.getParentInfo", params);
621
+ const parent = {
622
+ resize: async ({ height }) => {
623
+ await client.request("resize", { height });
583
624
  },
584
- // Selection
585
- async getSelectedNodeId() {
586
- return await client.request("editorState.getSelectedNodeId");
625
+ setValue: async (value) => {
626
+ await client.request("setValue", value);
587
627
  },
588
- async setSelectedNodeId(params) {
589
- await client.request("editorState.setSelectedNodeId", params);
590
- },
591
- async getSelectedParameterId() {
592
- return await client.request("editorState.getSelectedParameterId");
593
- },
594
- async setSelectedParameterId(params) {
595
- await client.request("editorState.setSelectedParameterId", params);
596
- },
597
- async getPristine() {
598
- return await client.request("editorState.getPristine");
599
- },
600
- // Write operations
601
- async insertNode(params) {
602
- return await client.request("editorState.insertNode", params);
603
- },
604
- async deleteNode(params) {
605
- await client.request("editorState.deleteNode", params);
606
- },
607
- async moveNode(params) {
608
- await client.request("editorState.moveNode", params);
609
- },
610
- async updateNodeProperty(params) {
611
- await client.request("editorState.updateNodeProperty", params);
612
- },
613
- async updateRootMetadata(params) {
614
- await client.request("editorState.updateRootMetadata", params);
615
- },
616
- async updateRootNode(params) {
617
- await client.request("editorState.updateRootNode", params);
618
- },
619
- // Pattern operations
620
- async insertPattern(params) {
621
- return await client.request("editorState.insertPattern", params);
628
+ openDialog: async (message) => {
629
+ const res = await client.request(
630
+ "openDialog",
631
+ message
632
+ );
633
+ const dialogId = res == null ? void 0 : res.dialogId;
634
+ if (!dialogId) {
635
+ return;
636
+ }
637
+ return new Promise((resolve, reject) => {
638
+ dialogResponseHandlers[dialogId] = { resolve, reject };
639
+ });
622
640
  },
623
- async isPatternPropertyOverridden(params) {
624
- return await client.request("editorState.isPatternPropertyOverridden", params);
641
+ closeDialog: async (message) => {
642
+ await client.request("closeDialog", message);
625
643
  },
626
- async resetPatternPropertyOverride(params) {
627
- await client.request("editorState.resetPatternPropertyOverride", params);
644
+ getDataResource: async (message) => {
645
+ return await client.request("getDataResource", message, {
646
+ timeout: 3e4
647
+ });
628
648
  },
629
- // Locale operations
630
- async enableLocale(params) {
631
- await client.request("editorState.enableLocale", params);
649
+ navigate: async (message) => {
650
+ await client.request("navigate", message);
632
651
  },
633
- async disableLocale(params) {
634
- await client.request("editorState.disableLocale", params);
652
+ reloadLocation: async () => {
653
+ await client.request("reload");
635
654
  },
636
- async setCurrentLocale(params) {
637
- await client.request("editorState.setCurrentLocale", params);
655
+ editConnectedData: async (message) => {
656
+ return await client.request(
657
+ "editConnectedData",
658
+ message,
659
+ {
660
+ timeout: (
661
+ // 24 hours in ms
662
+ 864e5
663
+ )
664
+ }
665
+ );
638
666
  },
639
- // Dynamic input operations
640
- async setDynamicInputPreviewValue(params) {
641
- await client.request("editorState.setDynamicInputPreviewValue", params);
667
+ getSessionToken: async () => {
668
+ return await client.request("getSessionToken", void 0, {
669
+ // Delegation may wait on consent UI + token API; default framepost timeout (5s) is too short.
670
+ timeout: 12e4
671
+ });
642
672
  }
643
673
  };
674
+ return {
675
+ initData,
676
+ parent
677
+ };
644
678
  }
645
679
 
646
680
  // src/sdkWindow.ts
@@ -836,8 +870,7 @@ async function initializeUniformMeshSDK({
836
870
  sdk.events.emit("onValueChanged", { newValue: value });
837
871
  await parent.setValue({ uniformMeshLocationValue: value, closeDialog: true });
838
872
  }
839
- } : void 0,
840
- editorState: parent.editorState
873
+ } : void 0
841
874
  };
842
875
  return location;
843
876
  },
@@ -920,7 +953,8 @@ async function initializeUniformMeshSDK({
920
953
  },
921
954
  closeCurrentLocationDialog: async () => {
922
955
  await parent.closeDialog({ dialogId: void 0, dialogType: "currentLocation" });
923
- }
956
+ },
957
+ getSessionToken: () => parent.getSessionToken()
924
958
  };
925
959
  window.UniformMeshSDK = sdk;
926
960
  initializing = false;
@@ -942,6 +976,8 @@ var hasRole = (role, user) => {
942
976
  return user.roles.some((userRole) => userRole.name === role || userRole.id === role);
943
977
  };
944
978
  export {
979
+ DelegationTokenClient,
980
+ DelegationTokenError,
945
981
  IntegrationDefinitionClient,
946
982
  IntegrationInstallationClient,
947
983
  functionCallSystemParameters,