@wix/sdk 1.18.0 → 1.20.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/build/flat-utils.d.ts +1 -5
- package/build/flat-utils.js +15 -6
- package/build/object-utils.d.ts +4 -0
- package/build/object-utils.js +38 -0
- package/build/wixClient.js +6 -4
- package/cjs/build/flat-utils.d.ts +1 -5
- package/cjs/build/flat-utils.js +15 -6
- package/cjs/build/object-utils.d.ts +4 -0
- package/cjs/build/object-utils.js +42 -0
- package/cjs/build/wixClient.js +6 -4
- package/package.json +4 -4
package/build/flat-utils.d.ts
CHANGED
package/build/flat-utils.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { set, toPathObject } from './object-utils.js';
|
|
2
|
+
export function unflatten(flatObject) {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const [flatKey, value] of Object.entries(flatObject)) {
|
|
5
|
+
// Skip prototype pollution keys
|
|
6
|
+
if (isPrototypePollutionKey(flatKey)) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
const path = toPathObject(flatKey);
|
|
10
|
+
set(result, path, value);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
function isPrototypePollutionKey(key) {
|
|
15
|
+
return key === '__proto__' || key === 'constructor' || key === 'prototype';
|
|
7
16
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const DELIMITER = '.';
|
|
2
|
+
export function set(obj, path, value) {
|
|
3
|
+
if (obj == null) {
|
|
4
|
+
throw new Error('Cannot set value on null or undefined');
|
|
5
|
+
}
|
|
6
|
+
const keys = toPathObject(path);
|
|
7
|
+
let current = obj;
|
|
8
|
+
for (let i = 0; i < keys.length; i++) {
|
|
9
|
+
const key = keys[i];
|
|
10
|
+
// Last key → assign value
|
|
11
|
+
if (i === keys.length - 1) {
|
|
12
|
+
current[key] = value;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
// Create object or array if missing
|
|
16
|
+
const nextKey = keys[i + 1];
|
|
17
|
+
if (!(key in current) || current[key] == null) {
|
|
18
|
+
current[key] = typeof nextKey === 'number' ? [] : {};
|
|
19
|
+
}
|
|
20
|
+
else if (typeof current[key] !== 'object' || current[key] === null) {
|
|
21
|
+
// Overwrite non-object values
|
|
22
|
+
current[key] = typeof nextKey === 'number' ? [] : {};
|
|
23
|
+
}
|
|
24
|
+
current = current[key];
|
|
25
|
+
}
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
export function toPathObject(path) {
|
|
29
|
+
if (Array.isArray(path)) {
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
return path
|
|
33
|
+
.split(DELIMITER)
|
|
34
|
+
.map((segment) => (isNumericSegment(segment) ? Number(segment) : segment));
|
|
35
|
+
}
|
|
36
|
+
function isNumericSegment(segment) {
|
|
37
|
+
return /^\d+$/.test(segment);
|
|
38
|
+
}
|
package/build/wixClient.js
CHANGED
|
@@ -156,12 +156,14 @@ export function createClient(config) {
|
|
|
156
156
|
const wrappedModules = config.modules
|
|
157
157
|
? use(config.modules)
|
|
158
158
|
: {};
|
|
159
|
-
const authStrategy = getAuthStrategy();
|
|
160
|
-
const originalGetAuthHeaders = authStrategy.getAuthHeaders;
|
|
161
|
-
authStrategy.getAuthHeaders = originalGetAuthHeaders.bind(undefined, config.host);
|
|
162
159
|
return {
|
|
163
160
|
...wrappedModules,
|
|
164
|
-
auth
|
|
161
|
+
get auth() {
|
|
162
|
+
const authStrategy = getAuthStrategy();
|
|
163
|
+
const originalGetAuthHeaders = authStrategy.getAuthHeaders;
|
|
164
|
+
authStrategy.getAuthHeaders = originalGetAuthHeaders.bind(undefined, config.host);
|
|
165
|
+
return authStrategy;
|
|
166
|
+
},
|
|
165
167
|
setHeaders,
|
|
166
168
|
use,
|
|
167
169
|
enableContext(contextType, opts = { elevated: false }) {
|
package/cjs/build/flat-utils.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* TODO - implement this function
|
|
5
|
-
*/
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
exports.unflatten = unflatten;
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const object_utils_js_1 = require("./object-utils.js");
|
|
5
|
+
function unflatten(flatObject) {
|
|
6
|
+
const result = {};
|
|
7
|
+
for (const [flatKey, value] of Object.entries(flatObject)) {
|
|
8
|
+
// Skip prototype pollution keys
|
|
9
|
+
if (isPrototypePollutionKey(flatKey)) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const path = (0, object_utils_js_1.toPathObject)(flatKey);
|
|
13
|
+
(0, object_utils_js_1.set)(result, path, value);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function isPrototypePollutionKey(key) {
|
|
18
|
+
return key === '__proto__' || key === 'constructor' || key === 'prototype';
|
|
10
19
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.set = set;
|
|
4
|
+
exports.toPathObject = toPathObject;
|
|
5
|
+
const DELIMITER = '.';
|
|
6
|
+
function set(obj, path, value) {
|
|
7
|
+
if (obj == null) {
|
|
8
|
+
throw new Error('Cannot set value on null or undefined');
|
|
9
|
+
}
|
|
10
|
+
const keys = toPathObject(path);
|
|
11
|
+
let current = obj;
|
|
12
|
+
for (let i = 0; i < keys.length; i++) {
|
|
13
|
+
const key = keys[i];
|
|
14
|
+
// Last key → assign value
|
|
15
|
+
if (i === keys.length - 1) {
|
|
16
|
+
current[key] = value;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
// Create object or array if missing
|
|
20
|
+
const nextKey = keys[i + 1];
|
|
21
|
+
if (!(key in current) || current[key] == null) {
|
|
22
|
+
current[key] = typeof nextKey === 'number' ? [] : {};
|
|
23
|
+
}
|
|
24
|
+
else if (typeof current[key] !== 'object' || current[key] === null) {
|
|
25
|
+
// Overwrite non-object values
|
|
26
|
+
current[key] = typeof nextKey === 'number' ? [] : {};
|
|
27
|
+
}
|
|
28
|
+
current = current[key];
|
|
29
|
+
}
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
function toPathObject(path) {
|
|
33
|
+
if (Array.isArray(path)) {
|
|
34
|
+
return path;
|
|
35
|
+
}
|
|
36
|
+
return path
|
|
37
|
+
.split(DELIMITER)
|
|
38
|
+
.map((segment) => (isNumericSegment(segment) ? Number(segment) : segment));
|
|
39
|
+
}
|
|
40
|
+
function isNumericSegment(segment) {
|
|
41
|
+
return /^\d+$/.test(segment);
|
|
42
|
+
}
|
package/cjs/build/wixClient.js
CHANGED
|
@@ -160,12 +160,14 @@ function createClient(config) {
|
|
|
160
160
|
const wrappedModules = config.modules
|
|
161
161
|
? use(config.modules)
|
|
162
162
|
: {};
|
|
163
|
-
const authStrategy = getAuthStrategy();
|
|
164
|
-
const originalGetAuthHeaders = authStrategy.getAuthHeaders;
|
|
165
|
-
authStrategy.getAuthHeaders = originalGetAuthHeaders.bind(undefined, config.host);
|
|
166
163
|
return {
|
|
167
164
|
...wrappedModules,
|
|
168
|
-
auth
|
|
165
|
+
get auth() {
|
|
166
|
+
const authStrategy = getAuthStrategy();
|
|
167
|
+
const originalGetAuthHeaders = authStrategy.getAuthHeaders;
|
|
168
|
+
authStrategy.getAuthHeaders = originalGetAuthHeaders.bind(undefined, config.host);
|
|
169
|
+
return authStrategy;
|
|
170
|
+
},
|
|
169
171
|
setHeaders,
|
|
170
172
|
use,
|
|
171
173
|
enableContext(contextType, opts = { elevated: false }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@wix/image-kit": "^1.114.0",
|
|
77
77
|
"@wix/redirects": "^1.0.70",
|
|
78
78
|
"@wix/sdk-context": "0.0.1",
|
|
79
|
-
"@wix/sdk-runtime": "1.0.
|
|
79
|
+
"@wix/sdk-runtime": "1.0.2",
|
|
80
80
|
"@wix/sdk-types": "1.16.0",
|
|
81
81
|
"jose": "^5.10.0",
|
|
82
82
|
"type-fest": "^4.41.0"
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@wix/events": "^1.0.382",
|
|
93
93
|
"@wix/metro": "^1.0.93",
|
|
94
94
|
"@wix/metro-runtime": "^1.1891.0",
|
|
95
|
-
"@wix/sdk-runtime": "1.0.
|
|
95
|
+
"@wix/sdk-runtime": "1.0.2",
|
|
96
96
|
"eslint": "^8.57.1",
|
|
97
97
|
"eslint-config-sdk": "1.0.0",
|
|
98
98
|
"graphql": "^16.8.0",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"wallaby": {
|
|
127
127
|
"autoDetect": true
|
|
128
128
|
},
|
|
129
|
-
"falconPackageHash": "
|
|
129
|
+
"falconPackageHash": "4073f5e283bbe708a3e8e45d798f3998874111ad3aab43d426686c29"
|
|
130
130
|
}
|