@wix/sdk 1.5.9 → 1.6.1
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/auth/api-key/package.json +3 -0
- package/auth/oauth2/package.json +3 -0
- package/auth/wix-app-oauth/package.json +3 -0
- package/build/ambassador-modules.d.ts +31 -0
- package/build/ambassador-modules.js +89 -0
- package/build/auth/ApiKeyAuthStrategy.d.ts +16 -0
- package/build/auth/ApiKeyAuthStrategy.js +22 -0
- package/build/auth/WixAppOAuthStrategy.d.ts +54 -0
- package/build/auth/WixAppOAuthStrategy.js +106 -0
- package/build/auth/oauth2/OAuthStrategy.d.ts +12 -0
- package/build/auth/oauth2/OAuthStrategy.js +357 -0
- package/build/auth/oauth2/constants.d.ts +5 -0
- package/build/auth/oauth2/constants.js +5 -0
- package/build/auth/oauth2/pkce-challenge.d.ts +5 -0
- package/build/auth/oauth2/pkce-challenge.js +33 -0
- package/build/auth/oauth2/types.d.ts +121 -0
- package/build/auth/oauth2/types.js +16 -0
- package/build/bi/biHeaderGenerator.d.ts +12 -0
- package/build/bi/biHeaderGenerator.js +17 -0
- package/build/common.d.ts +7 -0
- package/build/common.js +4 -0
- package/build/fetch-error.d.ts +9 -0
- package/build/fetch-error.js +31 -0
- package/build/helpers.d.ts +4 -0
- package/build/helpers.js +11 -0
- package/build/host-modules.d.ts +3 -0
- package/build/host-modules.js +5 -0
- package/build/iframeUtils.d.ts +4 -0
- package/build/iframeUtils.js +43 -0
- package/build/index.d.ts +8 -388
- package/build/index.js +9 -1115
- package/build/rest-modules.d.ts +7 -0
- package/build/rest-modules.js +82 -0
- package/build/tokenHelpers.d.ts +4 -0
- package/build/tokenHelpers.js +11 -0
- package/build/wixClient.d.ts +70 -0
- package/build/wixClient.js +86 -0
- package/build/wixMedia.d.ts +46 -0
- package/build/wixMedia.js +156 -0
- package/cjs/build/ambassador-modules.d.ts +31 -0
- package/cjs/build/ambassador-modules.js +95 -0
- package/cjs/build/auth/ApiKeyAuthStrategy.d.ts +16 -0
- package/cjs/build/auth/ApiKeyAuthStrategy.js +26 -0
- package/cjs/build/auth/WixAppOAuthStrategy.d.ts +54 -0
- package/cjs/build/auth/WixAppOAuthStrategy.js +110 -0
- package/cjs/build/auth/oauth2/OAuthStrategy.d.ts +12 -0
- package/cjs/build/auth/oauth2/OAuthStrategy.js +361 -0
- package/cjs/build/auth/oauth2/constants.d.ts +5 -0
- package/cjs/build/auth/oauth2/constants.js +8 -0
- package/cjs/build/auth/oauth2/pkce-challenge.d.ts +5 -0
- package/cjs/build/auth/oauth2/pkce-challenge.js +41 -0
- package/cjs/build/auth/oauth2/types.d.ts +121 -0
- package/cjs/build/auth/oauth2/types.js +19 -0
- package/cjs/build/bi/biHeaderGenerator.d.ts +12 -0
- package/cjs/build/bi/biHeaderGenerator.js +21 -0
- package/cjs/build/common.d.ts +7 -0
- package/cjs/build/common.js +7 -0
- package/cjs/build/fetch-error.d.ts +9 -0
- package/cjs/build/fetch-error.js +35 -0
- package/cjs/build/helpers.d.ts +4 -0
- package/cjs/build/helpers.js +16 -0
- package/cjs/build/host-modules.d.ts +3 -0
- package/cjs/build/host-modules.js +10 -0
- package/cjs/build/iframeUtils.d.ts +4 -0
- package/cjs/build/iframeUtils.js +50 -0
- package/cjs/build/index.d.ts +9 -0
- package/cjs/build/index.js +28 -0
- package/cjs/build/rest-modules.d.ts +7 -0
- package/cjs/build/rest-modules.js +87 -0
- package/cjs/build/tokenHelpers.d.ts +4 -0
- package/cjs/build/tokenHelpers.js +17 -0
- package/cjs/build/wixClient.d.ts +70 -0
- package/cjs/build/wixClient.js +90 -0
- package/cjs/build/wixMedia.d.ts +46 -0
- package/cjs/build/wixMedia.js +160 -0
- package/cjs/package.json +3 -0
- package/client/package.json +3 -0
- package/package.json +45 -22
- package/build/browser/index.mjs +0 -1075
- package/build/index.d.mts +0 -389
- package/build/index.mjs +0 -1066
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ImageTransformOptions } from '@wix/image-kit';
|
|
2
|
+
declare function getScaledToFillImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
3
|
+
declare function getScaledToFitImageUrl(wixMediaIdentifier: string, targetWidth: number, targetHeight: number, options: ImageTransformOptions): string;
|
|
4
|
+
declare function getCroppedImageUrl(wixMediaIdentifier: string, cropX: number, cropY: number, cropWidth: number, cropHeight: number, targetWidth: number, targetHeight: number, options?: ImageTransformOptions): string;
|
|
5
|
+
declare function getImageUrl(val: string): {
|
|
6
|
+
id: string;
|
|
7
|
+
url: string;
|
|
8
|
+
height: number;
|
|
9
|
+
width: number;
|
|
10
|
+
altText?: string;
|
|
11
|
+
filename?: string;
|
|
12
|
+
};
|
|
13
|
+
declare function getVideoUrl(val: string, resolution?: VideoResolution): {
|
|
14
|
+
id: string;
|
|
15
|
+
url: string;
|
|
16
|
+
thumbnail: string;
|
|
17
|
+
filename?: string;
|
|
18
|
+
};
|
|
19
|
+
declare function getAudioUrl(val: string): {
|
|
20
|
+
id: string;
|
|
21
|
+
url: string;
|
|
22
|
+
duration: number;
|
|
23
|
+
filename?: string;
|
|
24
|
+
};
|
|
25
|
+
declare function getDocumentUrl(val: string): {
|
|
26
|
+
id: string;
|
|
27
|
+
url: string;
|
|
28
|
+
filename?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare function decodeText(s: string): string;
|
|
31
|
+
export declare enum VideoResolution {
|
|
32
|
+
MOBILE = "360p",
|
|
33
|
+
LOW = "480p",
|
|
34
|
+
MID = "720p",
|
|
35
|
+
HIGH = "1080p"
|
|
36
|
+
}
|
|
37
|
+
export declare const media: {
|
|
38
|
+
getCroppedImageUrl: typeof getCroppedImageUrl;
|
|
39
|
+
getScaledToFillImageUrl: typeof getScaledToFillImageUrl;
|
|
40
|
+
getScaledToFitImageUrl: typeof getScaledToFitImageUrl;
|
|
41
|
+
getImageUrl: typeof getImageUrl;
|
|
42
|
+
getVideoUrl: typeof getVideoUrl;
|
|
43
|
+
getAudioUrl: typeof getAudioUrl;
|
|
44
|
+
getDocumentUrl: typeof getDocumentUrl;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.media = exports.VideoResolution = exports.decodeText = void 0;
|
|
4
|
+
const image_kit_1 = require("@wix/image-kit");
|
|
5
|
+
const WIX_PROTOCOL = 'wix:';
|
|
6
|
+
const WIX_IMAGE = 'image';
|
|
7
|
+
const WIX_VIDEO = 'video';
|
|
8
|
+
const WIX_AUDIO = 'audio';
|
|
9
|
+
const WIX_DOCUMENT = 'document';
|
|
10
|
+
const WIX_IMAGE_URL = 'https://static.wixstatic.com/media/';
|
|
11
|
+
const WIX_VIDEO_URL = 'https://video.wixstatic.com/video/';
|
|
12
|
+
const WIX_AUDIO_URL = 'https://static.wixstatic.com/mp3/';
|
|
13
|
+
const WIX_DOCUMENT_URL = 'https://d945e594-8657-47e2-9cd9-e9033c3d8da0.usrfiles.com/ugd/';
|
|
14
|
+
function getScaledToFillImageUrl(wixMediaIdentifier, targetWidth, targetHeight, options) {
|
|
15
|
+
const img = getImageUrl(wixMediaIdentifier);
|
|
16
|
+
return image_kit_1.sdk.getScaleToFillImageURL(img.id, img.height, img.width, targetWidth, targetHeight, options);
|
|
17
|
+
}
|
|
18
|
+
function getScaledToFitImageUrl(wixMediaIdentifier, targetWidth, targetHeight, options) {
|
|
19
|
+
const img = getImageUrl(wixMediaIdentifier);
|
|
20
|
+
return image_kit_1.sdk.getScaleToFitImageURL(img.id, img.height, img.width, targetWidth, targetHeight, options);
|
|
21
|
+
}
|
|
22
|
+
function getCroppedImageUrl(wixMediaIdentifier, cropX, cropY, cropWidth, cropHeight, targetWidth, targetHeight, options) {
|
|
23
|
+
const img = getImageUrl(wixMediaIdentifier);
|
|
24
|
+
return image_kit_1.sdk.getCropImageURL(img.id, img.height, img.width, cropX, cropY, cropWidth, cropHeight, targetWidth, targetHeight, options);
|
|
25
|
+
}
|
|
26
|
+
function getImageUrl(val) {
|
|
27
|
+
let id, filenameOrAltText;
|
|
28
|
+
let height, width;
|
|
29
|
+
if (val.startsWith(WIX_IMAGE_URL)) {
|
|
30
|
+
id = val.split(WIX_IMAGE_URL).pop().split('/')[0];
|
|
31
|
+
width = val.split('/w_').pop().split(',')[0];
|
|
32
|
+
height = val.split(',h_').pop().split(',')[0];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const alignedImage = alignIfLegacy(val, WIX_IMAGE);
|
|
36
|
+
const { hash, pathname } = new URL(alignedImage);
|
|
37
|
+
const params = new URLSearchParams(hash.replace('#', ''));
|
|
38
|
+
height = params.get('originHeight');
|
|
39
|
+
width = params.get('originWidth');
|
|
40
|
+
[id, filenameOrAltText] = pathname
|
|
41
|
+
.replace(`${WIX_IMAGE}://v1/`, '')
|
|
42
|
+
.split('/');
|
|
43
|
+
}
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
const decodedFilenameOrAltText = decodeText(filenameOrAltText);
|
|
46
|
+
const res = {
|
|
47
|
+
id,
|
|
48
|
+
url: `${WIX_IMAGE_URL}${id}`,
|
|
49
|
+
height: Number(height),
|
|
50
|
+
width: Number(width),
|
|
51
|
+
};
|
|
52
|
+
if (!decodedFilenameOrAltText) {
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...res,
|
|
57
|
+
altText: decodedFilenameOrAltText,
|
|
58
|
+
filename: decodedFilenameOrAltText,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function getVideoUrl(val, resolution) {
|
|
62
|
+
let id, thumbnailId, thumbnailWidth, thumbnailHeight, decodedFilename = '';
|
|
63
|
+
if (val.startsWith(WIX_VIDEO_URL)) {
|
|
64
|
+
id = val.split(WIX_VIDEO_URL).pop().split('/')[0];
|
|
65
|
+
thumbnailId = `${id}.jpg`;
|
|
66
|
+
thumbnailWidth = '50';
|
|
67
|
+
thumbnailHeight = '50';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const alignedVideo = alignIfLegacy(val, WIX_VIDEO);
|
|
71
|
+
const { pathname, hash } = new URL(alignedVideo);
|
|
72
|
+
const hashParams = new URLSearchParams(hash.replace('#', ''));
|
|
73
|
+
const [_id, fileName] = pathname
|
|
74
|
+
.replace(`${WIX_VIDEO}://v1/`, '')
|
|
75
|
+
.split('/');
|
|
76
|
+
id = _id;
|
|
77
|
+
thumbnailId = hashParams.get('posterUri') || `${id}.jpg`;
|
|
78
|
+
thumbnailWidth = hashParams.get('posterWidth') || '50';
|
|
79
|
+
thumbnailHeight = hashParams.get('posterHeight') || '50';
|
|
80
|
+
decodedFilename = decodeText(fileName);
|
|
81
|
+
}
|
|
82
|
+
const res = {
|
|
83
|
+
id,
|
|
84
|
+
url: `${WIX_VIDEO_URL}${id}/${resolution ? `${resolution}/mp4/file.mp4` : 'file'}`,
|
|
85
|
+
thumbnail: `${WIX_PROTOCOL}${WIX_IMAGE}://v1/${thumbnailId}#originWidth=${thumbnailWidth}&originHeight=${thumbnailHeight}`,
|
|
86
|
+
};
|
|
87
|
+
if (!decodedFilename) {
|
|
88
|
+
return res;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
...res,
|
|
92
|
+
filename: decodedFilename,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function getAudioUrl(val) {
|
|
96
|
+
const alignedAudio = alignIfLegacy(val, WIX_AUDIO);
|
|
97
|
+
const { pathname, hash } = new URL(alignedAudio);
|
|
98
|
+
const [id, filename] = pathname.replace(`${WIX_AUDIO}://v1/`, '').split('/');
|
|
99
|
+
const decodedFilename = decodeText(filename);
|
|
100
|
+
const hashParams = new URLSearchParams(hash.replace('#', ''));
|
|
101
|
+
const res = {
|
|
102
|
+
id,
|
|
103
|
+
duration: Number(hashParams.get('duration') || ''),
|
|
104
|
+
url: `${WIX_AUDIO_URL}${id}`,
|
|
105
|
+
};
|
|
106
|
+
if (!decodedFilename) {
|
|
107
|
+
return res;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
...res,
|
|
111
|
+
filename: decodedFilename,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function getDocumentUrl(val) {
|
|
115
|
+
const valWithoutUGD = val.replace('v1/ugd', 'v1');
|
|
116
|
+
const alignedDocument = alignIfLegacy(valWithoutUGD, WIX_DOCUMENT);
|
|
117
|
+
const { pathname } = new URL(alignedDocument);
|
|
118
|
+
const [id, filename] = pathname
|
|
119
|
+
.replace(`${WIX_DOCUMENT}://v1/`, '')
|
|
120
|
+
.split('/');
|
|
121
|
+
const decodedFilename = decodeText(filename);
|
|
122
|
+
const res = {
|
|
123
|
+
id,
|
|
124
|
+
url: `${WIX_DOCUMENT_URL}${id}`,
|
|
125
|
+
};
|
|
126
|
+
if (!decodedFilename) {
|
|
127
|
+
return res;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
...res,
|
|
131
|
+
filename: decodedFilename,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function decodeText(s) {
|
|
135
|
+
if (!s) {
|
|
136
|
+
return s;
|
|
137
|
+
}
|
|
138
|
+
return decodeURIComponent(s);
|
|
139
|
+
}
|
|
140
|
+
exports.decodeText = decodeText;
|
|
141
|
+
function alignIfLegacy(url, type) {
|
|
142
|
+
const { protocol } = new URL(url);
|
|
143
|
+
return protocol === `${type}:` ? `${WIX_PROTOCOL}${url}` : url;
|
|
144
|
+
}
|
|
145
|
+
var VideoResolution;
|
|
146
|
+
(function (VideoResolution) {
|
|
147
|
+
VideoResolution["MOBILE"] = "360p";
|
|
148
|
+
VideoResolution["LOW"] = "480p";
|
|
149
|
+
VideoResolution["MID"] = "720p";
|
|
150
|
+
VideoResolution["HIGH"] = "1080p";
|
|
151
|
+
})(VideoResolution || (exports.VideoResolution = VideoResolution = {}));
|
|
152
|
+
exports.media = {
|
|
153
|
+
getCroppedImageUrl,
|
|
154
|
+
getScaledToFillImageUrl,
|
|
155
|
+
getScaledToFitImageUrl,
|
|
156
|
+
getImageUrl,
|
|
157
|
+
getVideoUrl,
|
|
158
|
+
getAudioUrl,
|
|
159
|
+
getDocumentUrl,
|
|
160
|
+
};
|
package/cjs/package.json
ADDED
package/package.json
CHANGED
|
@@ -1,25 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
7
7
|
"email": "ronnyr@wix.com"
|
|
8
8
|
},
|
|
9
|
-
"main": "build/index.js",
|
|
9
|
+
"main": "cjs/build/index.js",
|
|
10
10
|
"module": "build/index.mjs",
|
|
11
|
-
"
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./build/index.js",
|
|
15
|
+
"require": "./cjs/build/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
"./client": {
|
|
19
|
+
"import": "./build/wixClient.js",
|
|
20
|
+
"require": "./cjs/build/wixClient.js"
|
|
21
|
+
},
|
|
22
|
+
"./auth/oauth2": {
|
|
23
|
+
"import": "./build/auth/oauth2/OAuthStrategy.js",
|
|
24
|
+
"require": "./cjs/build/auth/oauth2/OAuthStrategy.js"
|
|
25
|
+
},
|
|
26
|
+
"./auth/api-key": {
|
|
27
|
+
"import": "./build/auth/ApiKeyAuthStrategy.js",
|
|
28
|
+
"require": "./cjs/build/auth/ApiKeyAuthStrategy.js"
|
|
29
|
+
},
|
|
30
|
+
"./auth/wix-app-oauth": {
|
|
31
|
+
"import": "./build/auth/WixAppOAuthStrategy.js",
|
|
32
|
+
"require": "./cjs/build/auth/WixAppOAuthStrategy.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
12
35
|
"sideEffects": false,
|
|
13
|
-
"types": "build/index.d.ts",
|
|
14
36
|
"files": [
|
|
15
|
-
"build"
|
|
37
|
+
"build",
|
|
38
|
+
"auth",
|
|
39
|
+
"client",
|
|
40
|
+
"cjs"
|
|
16
41
|
],
|
|
17
42
|
"publishConfig": {
|
|
18
43
|
"registry": "https://registry.npmjs.org/",
|
|
19
44
|
"access": "public"
|
|
20
45
|
},
|
|
21
46
|
"scripts": {
|
|
22
|
-
"build": "
|
|
47
|
+
"build": "tsc && tsc --project tsconfig.cjs.json",
|
|
23
48
|
"test": "vitest",
|
|
24
49
|
"lint": "eslint --max-warnings=0 .",
|
|
25
50
|
"lint:fix": "eslint --max-warnings=0 . --fix",
|
|
@@ -29,35 +54,33 @@
|
|
|
29
54
|
"*.{js,ts}": "yarn lint"
|
|
30
55
|
},
|
|
31
56
|
"dependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@wix/
|
|
34
|
-
"@wix/
|
|
35
|
-
"@wix/redirects": "^1.0.28",
|
|
57
|
+
"@wix/identity": "^1.0.71",
|
|
58
|
+
"@wix/image-kit": "^1.43.0",
|
|
59
|
+
"@wix/redirects": "^1.0.31",
|
|
36
60
|
"@wix/sdk-types": "^1.5.3",
|
|
37
|
-
"
|
|
38
|
-
"querystring": "^0.2.1",
|
|
61
|
+
"crypto-js": "^4.2.0",
|
|
39
62
|
"type-fest": "^4.8.3"
|
|
40
63
|
},
|
|
41
64
|
"optionalDependencies": {
|
|
42
65
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
43
66
|
},
|
|
44
67
|
"devDependencies": {
|
|
68
|
+
"@types/crypto-js": "^4.2.1",
|
|
45
69
|
"@types/is-ci": "^3.0.4",
|
|
46
|
-
"@types/node": "^20.10.
|
|
47
|
-
"@wix/ecom": "^1.0.
|
|
48
|
-
"@wix/events": "^1.0.
|
|
49
|
-
"@wix/metro": "^1.0.
|
|
50
|
-
"@wix/metro-runtime": "^1.
|
|
51
|
-
"eslint": "^
|
|
70
|
+
"@types/node": "^20.10.5",
|
|
71
|
+
"@wix/ecom": "^1.0.430",
|
|
72
|
+
"@wix/events": "^1.0.133",
|
|
73
|
+
"@wix/metro": "^1.0.72",
|
|
74
|
+
"@wix/metro-runtime": "^1.1581.0",
|
|
75
|
+
"eslint": "^8.56.0",
|
|
52
76
|
"eslint-config-sdk": "0.0.0",
|
|
53
77
|
"graphql": "^16.8.0",
|
|
54
78
|
"is-ci": "^3.0.1",
|
|
55
79
|
"jsdom": "^22.1.0",
|
|
56
|
-
"msw": "^2.0.
|
|
57
|
-
"tsup": "^7.3.0",
|
|
80
|
+
"msw": "^2.0.11",
|
|
58
81
|
"typescript": "^5.3.3",
|
|
59
82
|
"vitest": "^0.34.6",
|
|
60
|
-
"vitest-teamcity-reporter": "^0.2.
|
|
83
|
+
"vitest-teamcity-reporter": "^0.2.2"
|
|
61
84
|
},
|
|
62
85
|
"yoshiFlowLibrary": {
|
|
63
86
|
"buildEsmWithBabel": true
|
|
@@ -82,5 +105,5 @@
|
|
|
82
105
|
"wallaby": {
|
|
83
106
|
"autoDetect": true
|
|
84
107
|
},
|
|
85
|
-
"falconPackageHash": "
|
|
108
|
+
"falconPackageHash": "8e84d7d394c9d90bc2d1d7a96667746087642093402e6cbd48385725"
|
|
86
109
|
}
|