@veltdev/react 4.5.0-beta.12 → 4.5.0-beta.13

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.
@@ -5,6 +5,7 @@ export interface IVeltProps extends React.DetailedHTMLProps<React.HTMLAttributes
5
5
  config?: Config & {
6
6
  proxyDomain?: string;
7
7
  version?: string;
8
+ integrity?: boolean;
8
9
  };
9
10
  user?: any;
10
11
  documentId?: string;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
- export declare const VELT_SDK_VERSION = "4.5.0-beta.12";
2
+ export declare const VELT_SDK_VERSION = "4.5.0-beta.13";
3
3
  export declare const VELT_SDK_INIT_EVENT = "onVeltInit";
4
4
  export declare const VELT_TAB_ID = "veltTabId";
5
+ export declare const INTEGRITY_MAP: Record<string, string>;
5
6
  export interface IVeltWireframeCommonProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
6
7
  veltIf?: string;
7
8
  veltClass?: string;
@@ -1,4 +1,7 @@
1
1
  import { GetPresenceDataResponse, PresenceElement, PresenceRequestQuery, PresenceUser } from "@veltdev/types";
2
2
  export declare function usePresenceUtils(): PresenceElement | undefined;
3
+ /**
4
+ * @deprecated Use `usePresenceData` hook instead.
5
+ */
3
6
  export declare function usePresenceUsers(): PresenceUser[] | null;
4
7
  export declare function usePresenceData(query?: PresenceRequestQuery): GetPresenceDataResponse;
@@ -1,2 +1,2 @@
1
- declare const loadVelt: (callback: Function, version?: string, staging?: boolean, develop?: boolean, proxyDomain?: string) => void;
1
+ declare const loadVelt: (callback: Function, version?: string, staging?: boolean, develop?: boolean, proxyDomain?: string, integrity?: boolean, integrityValue?: string) => void;
2
2
  export default loadVelt;
package/esm/index.js CHANGED
@@ -91,7 +91,7 @@ function useVeltClient() {
91
91
  return useContext(VeltContext);
92
92
  }
93
93
 
94
- var loadVelt = function (callback, version, staging, develop, proxyDomain) {
94
+ var loadVelt = function (callback, version, staging, develop, proxyDomain, integrity, integrityValue) {
95
95
  if (version === void 0) { version = 'latest'; }
96
96
  if (staging === void 0) { staging = false; }
97
97
  if (develop === void 0) { develop = false; }
@@ -118,6 +118,10 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
118
118
  }
119
119
  script.id = 'veltScript';
120
120
  script.type = 'module';
121
+ if (integrity && integrityValue) {
122
+ script.integrity = integrityValue;
123
+ script.crossOrigin = 'anonymous';
124
+ }
121
125
  document.body.appendChild(script);
122
126
  script.onload = function () {
123
127
  if (callback) {
@@ -132,18 +136,40 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
132
136
  }
133
137
  };
134
138
 
135
- var VELT_SDK_VERSION = '4.5.0-beta.12';
139
+ var VELT_SDK_VERSION = '4.5.0-beta.13';
136
140
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
137
141
  var VELT_TAB_ID = 'veltTabId';
142
+ // integrity map for the Velt SDK
143
+ // Note: generate integrity hashes with: https://www.srihash.org/
144
+ var INTEGRITY_MAP = {
145
+ '4.5.0-beta.13': 'sha384-Mu1jdD223jLItSpbJev0mw5PyMUf+5UlS+qPrM/1P2JMejbTZvnwa8roDWwhP/In',
146
+ };
138
147
 
139
148
  var SnippylyProvider = function (props) {
140
149
  var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, language = props.language, translations = props.translations, autoTranslation = props.autoTranslation, userDataProvider = props.userDataProvider, dataProviders = props.dataProviders, onClientLoad = props.onClientLoad, children = props.children;
141
150
  var _a = useState(null), client = _a[0], setClient = _a[1];
142
151
  useEffect(function () {
143
152
  if (apiKey) {
153
+ var staging = config === null || config === void 0 ? void 0 : config.staging;
154
+ var develop = config === null || config === void 0 ? void 0 : config.develop;
155
+ var version = (config === null || config === void 0 ? void 0 : config.version) || VELT_SDK_VERSION;
156
+ var integrity = !!(config === null || config === void 0 ? void 0 : config.integrity);
157
+ var integrityValue = '';
158
+ if (integrity) {
159
+ if (develop || staging) {
160
+ if (config === null || config === void 0 ? void 0 : config.sriv) {
161
+ integrityValue = config === null || config === void 0 ? void 0 : config.sriv;
162
+ }
163
+ }
164
+ else {
165
+ if (INTEGRITY_MAP[version]) {
166
+ integrityValue = INTEGRITY_MAP[version];
167
+ }
168
+ }
169
+ }
144
170
  loadVelt(function () {
145
171
  initVelt();
146
- }, (config === null || config === void 0 ? void 0 : config.version) || VELT_SDK_VERSION, config === null || config === void 0 ? void 0 : config.staging, config === null || config === void 0 ? void 0 : config.develop, config === null || config === void 0 ? void 0 : config.proxyDomain);
172
+ }, version, staging, develop, config === null || config === void 0 ? void 0 : config.proxyDomain, integrity, integrityValue);
147
173
  }
148
174
  }, []);
149
175
  useEffect(function () {
@@ -6537,6 +6563,9 @@ function usePresenceUtils() {
6537
6563
  }, [client, setPresenceElement, presenceElement]);
6538
6564
  return presenceElement;
6539
6565
  }
6566
+ /**
6567
+ * @deprecated Use `usePresenceData` hook instead.
6568
+ */
6540
6569
  function usePresenceUsers() {
6541
6570
  var presenceElement = usePresenceUtils();
6542
6571
  var _a = React.useState(null), data = _a[0], setData = _a[1];