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