@fy-/fws-vue 2.3.58 → 2.3.59

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.
@@ -39,6 +39,8 @@ const inFlightRequests = new Map<number, Promise<any>>()
39
39
  // Detect if we're in SSR mode once and cache the result
40
40
  let isSSRMode: boolean | null = null
41
41
 
42
+ const secret = import.meta.env.VITE_API_SECRET
43
+
42
44
  // Memoized function to extract URL pathname and search for hashing
43
45
  function getUrlForHash(url: string): string {
44
46
  const cached = urlParseCache.get(url)
@@ -134,6 +136,16 @@ params?: RestParams,
134
136
 
135
137
  // Create the actual request function
136
138
  const performRequest = async (): Promise<ResultType> => {
139
+ const headers: { [key: string]: string } = {}
140
+ const timestamp = Date.now()
141
+
142
+ if (secret && secret !== '') {
143
+ const signature = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(`${method}${url}${timestamp}${secret}`),
144
+ )
145
+ headers['X-Timestamp'] = timestamp.toString()
146
+ headers['X-Signature'] = btoa(String.fromCharCode(...new Uint8Array(signature)))
147
+ }
148
+
137
149
  try {
138
150
  const restResult: ResultType = await rest(url, method, params)
139
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "2.3.58",
3
+ "version": "2.3.59",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/fy-to/FWJS#readme",