@stackable-labs/sdk-extension-react 1.29.0 → 1.30.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ApiRequest, FetchRequestInit, FetchResponse, ToastPayload, ContextData, AllowedIconName } from '@stackable-labs/sdk-extension-contracts';
2
+ import { ApiRequest, FetchRequestInit, FetchResponse, ToastPayload, InvokeAction, ContextData, AllowedIconName } from '@stackable-labs/sdk-extension-contracts';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
 
5
5
  /**
@@ -62,7 +62,7 @@ declare const useCapabilities: () => {
62
62
  };
63
63
  actions: {
64
64
  toast: (payload: ToastPayload) => Promise<void>;
65
- invoke: <T = unknown>(action: string, payload?: Record<string, unknown>) => Promise<T>;
65
+ invoke: <T = unknown>(action: InvokeAction, payload?: Record<string, unknown>) => Promise<T>;
66
66
  };
67
67
  context: {
68
68
  read: () => Promise<ContextData>;
package/dist/index.js CHANGED
@@ -52,23 +52,6 @@ var initRpcListener = (extensionId) => {
52
52
  });
53
53
  };
54
54
  var isEncryptedPayload = (value) => typeof value === "object" && value !== null && value.encrypted === true && Array.isArray(value.data);
55
- var callCapability = async (capability, payload) => {
56
- let actualPayload = payload;
57
- if (capability === "data.fetch" && encryptionKey) {
58
- const encrypted = await getWebCrypto().encryptMessage(JSON.stringify(payload), encryptionKey);
59
- if (!encrypted) throw new Error("Failed to encrypt data.fetch payload");
60
- actualPayload = { encrypted: true, data: encrypted };
61
- }
62
- const result = await sendCapabilityRequest(capability, actualPayload);
63
- if (capability === "data.fetch" && encryptionKey) {
64
- const fetchResult = result;
65
- if (isEncryptedPayload(fetchResult.data)) {
66
- const decrypted = await getWebCrypto().decryptMessage(fetchResult.data.data, encryptionKey);
67
- fetchResult.data = JSON.parse(decrypted);
68
- }
69
- }
70
- return result;
71
- };
72
55
  var sendCapabilityRequest = (capability, payload) => new Promise((resolve, reject) => {
73
56
  const id = generateRequestId();
74
57
  pendingRequests.set(id, {
@@ -90,6 +73,23 @@ var sendCapabilityRequest = (capability, payload) => new Promise((resolve, rejec
90
73
  }
91
74
  }, 3e4);
92
75
  });
76
+ var callCapability = async (capability, payload) => {
77
+ let actualPayload = payload;
78
+ if (capability === "data.fetch" && encryptionKey) {
79
+ const encrypted = await getWebCrypto().encryptMessage(JSON.stringify(payload), encryptionKey);
80
+ if (!encrypted) throw new Error("Failed to encrypt data.fetch payload");
81
+ actualPayload = { encrypted: true, data: encrypted };
82
+ }
83
+ const result = await sendCapabilityRequest(capability, actualPayload);
84
+ if (capability === "data.fetch" && encryptionKey) {
85
+ const fetchResult = result;
86
+ if (isEncryptedPayload(fetchResult.data)) {
87
+ const decrypted = await getWebCrypto().decryptMessage(fetchResult.data.data, encryptionKey);
88
+ fetchResult.data = JSON.parse(decrypted);
89
+ }
90
+ }
91
+ return result;
92
+ };
93
93
 
94
94
  // src/createExtension.tsx
95
95
  import { jsx } from "react/jsx-runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackable-labs/sdk-extension-react",
3
- "version": "1.29.0",
3
+ "version": "1.30.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "@agnostack/verifyd": "alpha",
16
16
  "@remote-dom/core": "1.x",
17
17
  "@remote-dom/react": "1.x",
18
- "@stackable-labs/sdk-extension-contracts": "1.29.0"
18
+ "@stackable-labs/sdk-extension-contracts": "1.30.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=18.0.0 <19.0.0",