@agnostack/next-shopify 1.13.10-alpha.1 → 1.14.0-beta.2

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 (95) hide show
  1. package/CHANGELOG.md +69 -36
  2. package/dist/lib/handlers/api/index.d.ts +1 -5
  3. package/dist/lib/handlers/api/index.d.ts.map +1 -1
  4. package/dist/lib/handlers/api/index.js +1 -5
  5. package/dist/lib/handlers/api/index.js.map +1 -1
  6. package/dist/lib/handlers/api/verifiable/appInstallation.d.ts.map +1 -0
  7. package/dist/lib/handlers/api/verifiable/appInstallation.js.map +1 -0
  8. package/dist/lib/handlers/api/verifiable/graph.d.ts.map +1 -0
  9. package/dist/lib/handlers/api/verifiable/graph.js +98 -0
  10. package/dist/lib/handlers/api/verifiable/graph.js.map +1 -0
  11. package/dist/lib/handlers/api/verifiable/index.d.ts +6 -0
  12. package/dist/lib/handlers/api/verifiable/index.d.ts.map +1 -0
  13. package/dist/lib/handlers/api/verifiable/index.js +9 -0
  14. package/dist/lib/handlers/api/verifiable/index.js.map +1 -0
  15. package/dist/lib/handlers/api/verifiable/proxy.d.ts.map +1 -0
  16. package/dist/lib/handlers/api/verifiable/proxy.js +143 -0
  17. package/dist/lib/handlers/api/verifiable/proxy.js.map +1 -0
  18. package/dist/lib/handlers/api/verifiable/rest.d.ts.map +1 -0
  19. package/dist/lib/handlers/api/verifiable/rest.js +85 -0
  20. package/dist/lib/handlers/api/verifiable/rest.js.map +1 -0
  21. package/dist/lib/handlers/api/verifiable/token.d.ts.map +1 -0
  22. package/dist/lib/handlers/api/{token.js → verifiable/token.js} +2 -3
  23. package/dist/lib/handlers/api/verifiable/token.js.map +1 -0
  24. package/dist/lib/handlers/ssr/protect.d.ts.map +1 -1
  25. package/dist/lib/handlers/ssr/protect.js +1 -7
  26. package/dist/lib/handlers/ssr/protect.js.map +1 -1
  27. package/dist/lib/index.d.ts +1 -1
  28. package/dist/lib/index.d.ts.map +1 -1
  29. package/dist/lib/index.js +5 -4
  30. package/dist/lib/index.js.map +1 -1
  31. package/dist/lib/utils/firebase.d.ts.map +1 -1
  32. package/dist/lib/utils/firebase.js +0 -2
  33. package/dist/lib/utils/firebase.js.map +1 -1
  34. package/dist/lib/utils/index.d.ts +1 -0
  35. package/dist/lib/utils/index.js +1 -0
  36. package/dist/lib/utils/index.js.map +1 -1
  37. package/dist/lib/utils/session.d.ts.map +1 -1
  38. package/dist/lib/utils/session.js +2 -4
  39. package/dist/lib/utils/session.js.map +1 -1
  40. package/dist/lib/utils/verification.d.ts +2 -0
  41. package/dist/lib/utils/verification.d.ts.map +1 -0
  42. package/dist/lib/utils/verification.js +69 -0
  43. package/dist/lib/utils/verification.js.map +1 -0
  44. package/dist/react/hooks/index.d.ts +2 -0
  45. package/dist/react/hooks/index.d.ts.map +1 -0
  46. package/dist/react/hooks/index.js +5 -0
  47. package/dist/react/hooks/index.js.map +1 -0
  48. package/dist/react/hooks/useVerification.d.ts +9 -0
  49. package/dist/react/hooks/useVerification.d.ts.map +1 -0
  50. package/dist/react/hooks/useVerification.js +63 -0
  51. package/dist/react/hooks/useVerification.js.map +1 -0
  52. package/dist/react/index.d.ts +2 -0
  53. package/dist/react/index.d.ts.map +1 -0
  54. package/dist/react/index.js +5 -0
  55. package/dist/react/index.js.map +1 -0
  56. package/dist/react/types.d.ts +1 -0
  57. package/dist/react/types.d.ts.map +1 -0
  58. package/dist/react/types.js +1 -0
  59. package/dist/react/types.js.map +1 -0
  60. package/dist/shared/datetime.d.ts +96 -0
  61. package/dist/shared/datetime.d.ts.map +1 -0
  62. package/dist/shared/datetime.js +285 -0
  63. package/dist/shared/datetime.js.map +1 -0
  64. package/dist/shared/display.d.ts +88 -23
  65. package/dist/shared/display.d.ts.map +1 -1
  66. package/dist/shared/display.js +409 -104
  67. package/dist/shared/display.js.map +1 -1
  68. package/dist/shared/index.d.ts +1 -0
  69. package/dist/shared/index.d.ts.map +1 -1
  70. package/dist/shared/index.js +1 -0
  71. package/dist/shared/index.js.map +1 -1
  72. package/dist/shared/shopify.d.ts +0 -6
  73. package/dist/shared/shopify.d.ts.map +1 -1
  74. package/dist/shared/shopify.js +1 -28
  75. package/dist/shared/shopify.js.map +1 -1
  76. package/package.json +6 -1
  77. package/dist/lib/handlers/api/appInstallation.d.ts.map +0 -1
  78. package/dist/lib/handlers/api/appInstallation.js.map +0 -1
  79. package/dist/lib/handlers/api/graph.d.ts.map +0 -1
  80. package/dist/lib/handlers/api/graph.js +0 -93
  81. package/dist/lib/handlers/api/graph.js.map +0 -1
  82. package/dist/lib/handlers/api/proxy.d.ts.map +0 -1
  83. package/dist/lib/handlers/api/proxy.js +0 -184
  84. package/dist/lib/handlers/api/proxy.js.map +0 -1
  85. package/dist/lib/handlers/api/rest.d.ts.map +0 -1
  86. package/dist/lib/handlers/api/rest.js +0 -80
  87. package/dist/lib/handlers/api/rest.js.map +0 -1
  88. package/dist/lib/handlers/api/token.d.ts.map +0 -1
  89. package/dist/lib/handlers/api/token.js.map +0 -1
  90. /package/dist/lib/handlers/api/{appInstallation.d.ts → verifiable/appInstallation.d.ts} +0 -0
  91. /package/dist/lib/handlers/api/{appInstallation.js → verifiable/appInstallation.js} +0 -0
  92. /package/dist/lib/handlers/api/{graph.d.ts → verifiable/graph.d.ts} +0 -0
  93. /package/dist/lib/handlers/api/{proxy.d.ts → verifiable/proxy.d.ts} +0 -0
  94. /package/dist/lib/handlers/api/{rest.d.ts → verifiable/rest.d.ts} +0 -0
  95. /package/dist/lib/handlers/api/{token.d.ts → verifiable/token.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,44 +1,52 @@
1
- ## [1.13.10-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.13.9...v1.13.10-alpha.1) (2023-12-01)
1
+ # [1.14.0-beta.2](https://github.com/agnostack/next-shopify/compare/v1.14.0-beta.1...v1.14.0-beta.2) (2023-12-01)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * wip ([2f1e033](https://github.com/agnostack/next-shopify/commit/2f1e0332e8df38c91ad1e65209b6c40589d154f1))
6
+ * wip ([dab5398](https://github.com/agnostack/next-shopify/commit/dab5398a3f20fd0c8c61289fe88011d10b762e5d))
7
7
 
8
- ## [1.13.9](https://github.com/agnostack/next-shopify/compare/v1.13.8...v1.13.9) (2023-12-01)
8
+ ## [1.13.8](https://github.com/agnostack/next-shopify/compare/v1.13.7...v1.13.8) (2023-12-01)
9
9
 
10
10
 
11
11
  ### Bug Fixes
12
12
 
13
- * wip ([dab5398](https://github.com/agnostack/next-shopify/commit/dab5398a3f20fd0c8c61289fe88011d10b762e5d))
14
-
15
- ## [1.13.9-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.13.8...v1.13.9-alpha.1) (2023-12-01)
13
+ * wip ([c28c0a0](https://github.com/agnostack/next-shopify/commit/c28c0a0c5416b0dcb7040fb9e12583a44916e1a1))
16
14
 
17
15
 
18
- ### Bug Fixes
16
+ ### Features
19
17
 
20
- * wip ([dab5398](https://github.com/agnostack/next-shopify/commit/dab5398a3f20fd0c8c61289fe88011d10b762e5d))
18
+ * separated out verifiable helpers ([9db80b9](https://github.com/agnostack/next-shopify/commit/9db80b90debc1712259d95afd8c82ac6822049ef))
21
19
 
22
- ## [1.13.8](https://github.com/agnostack/next-shopify/compare/v1.13.7...v1.13.8) (2023-12-01)
20
+ ## [1.13.9-beta.2](https://github.com/agnostack/next-shopify/compare/v1.13.9-beta.1...v1.13.9-beta.2) (2023-12-01)
23
21
 
24
22
 
25
23
  ### Bug Fixes
26
24
 
27
- * wip ([a7931e0](https://github.com/agnostack/next-shopify/commit/a7931e064b5921e4bd469968f6a006c09cd4729d))
28
- * wip ([c53a4dc](https://github.com/agnostack/next-shopify/commit/c53a4dcdffe9fc7252ad4e3584b9f8a23da6697a))
25
+ * wip ([4b5f06c](https://github.com/agnostack/next-shopify/commit/4b5f06cdeb2e6faa6cfd7f40c8962b8f9312cfc3))
29
26
 
30
- ## [1.13.8-alpha.2](https://github.com/agnostack/next-shopify/compare/v1.13.8-alpha.1...v1.13.8-alpha.2) (2023-12-01)
27
+ ## [1.13.9-beta.1](https://github.com/agnostack/next-shopify/compare/v1.13.8...v1.13.9-beta.1) (2023-12-01)
31
28
 
32
29
 
33
30
  ### Bug Fixes
34
31
 
35
- * wip ([a7931e0](https://github.com/agnostack/next-shopify/commit/a7931e064b5921e4bd469968f6a006c09cd4729d))
32
+ * added react export and useVerification ([7131369](https://github.com/agnostack/next-shopify/commit/71313698da5b30b94a0b28fa9a0d6e595e16c5bd))
33
+ * reverted pubblic-key vs api-key ([b3b40ac](https://github.com/agnostack/next-shopify/commit/b3b40ace673090d321635e011818ea130b7ddd3c))
34
+ * wip ([088e2f8](https://github.com/agnostack/next-shopify/commit/088e2f84ecb27dc435f1d9a7e1a53eb955fc6fd6))
35
+ * wip ([b0eb414](https://github.com/agnostack/next-shopify/commit/b0eb414b9a3c3d02aaef66b72569dba6c1bdccb0))
36
+ * wip ([cd8d260](https://github.com/agnostack/next-shopify/commit/cd8d260f40672cc066da5695c7a72a790f71d4a1))
37
+ * wip ([f8d453a](https://github.com/agnostack/next-shopify/commit/f8d453a850ead76d6d2c536fe1f8f472f380c1c6))
38
+ * wip ([82e20e8](https://github.com/agnostack/next-shopify/commit/82e20e8e9878ac7f9424ff990e8959c3cbe66e9d))
39
+ * wip ([ecd3625](https://github.com/agnostack/next-shopify/commit/ecd36257e4cde1bbdea48b895934e82ecedf0612))
40
+ * wip ([825f688](https://github.com/agnostack/next-shopify/commit/825f688f614be631c13a70e1c652c45f742408ed))
41
+ * wip ([a66af1e](https://github.com/agnostack/next-shopify/commit/a66af1e574e9e1cc08b2718c4a49f46caf42db9f))
42
+ * wip ([ab11674](https://github.com/agnostack/next-shopify/commit/ab116749073075133350e46d272b5475bb6e9d1b))
36
43
 
37
- ## [1.13.8-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.13.7...v1.13.8-alpha.1) (2023-12-01)
44
+ ## [1.13.8](https://github.com/agnostack/next-shopify/compare/v1.13.7...v1.13.8) (2023-12-01)
38
45
 
39
46
 
40
47
  ### Bug Fixes
41
48
 
49
+ * wip ([a7931e0](https://github.com/agnostack/next-shopify/commit/a7931e064b5921e4bd469968f6a006c09cd4729d))
42
50
  * wip ([c53a4dc](https://github.com/agnostack/next-shopify/commit/c53a4dcdffe9fc7252ad4e3584b9f8a23da6697a))
43
51
 
44
52
  ## [1.13.7](https://github.com/agnostack/next-shopify/compare/v1.13.6...v1.13.7) (2023-12-01)
@@ -46,22 +54,34 @@
46
54
 
47
55
  ### Bug Fixes
48
56
 
49
- * wip ([6f3d3f5](https://github.com/agnostack/next-shopify/commit/6f3d3f515831fce0f30e6a34b3603ad89114ae38))
50
- * wip ([d3d121f](https://github.com/agnostack/next-shopify/commit/d3d121f402b46648cad0b1767a5ddd03de8d9dd7))
51
-
52
- ## [1.13.7-alpha.2](https://github.com/agnostack/next-shopify/compare/v1.13.7-alpha.1...v1.13.7-alpha.2) (2023-12-01)
57
+ * added react export and useVerification ([7131369](https://github.com/agnostack/next-shopify/commit/71313698da5b30b94a0b28fa9a0d6e595e16c5bd))
58
+ * reverted pubblic-key vs api-key ([b3b40ac](https://github.com/agnostack/next-shopify/commit/b3b40ace673090d321635e011818ea130b7ddd3c))
59
+ * wip ([088e2f8](https://github.com/agnostack/next-shopify/commit/088e2f84ecb27dc435f1d9a7e1a53eb955fc6fd6))
60
+ * wip ([b0eb414](https://github.com/agnostack/next-shopify/commit/b0eb414b9a3c3d02aaef66b72569dba6c1bdccb0))
61
+ * wip ([cd8d260](https://github.com/agnostack/next-shopify/commit/cd8d260f40672cc066da5695c7a72a790f71d4a1))
62
+ * wip ([f8d453a](https://github.com/agnostack/next-shopify/commit/f8d453a850ead76d6d2c536fe1f8f472f380c1c6))
63
+ * wip ([82e20e8](https://github.com/agnostack/next-shopify/commit/82e20e8e9878ac7f9424ff990e8959c3cbe66e9d))
64
+ * wip ([ecd3625](https://github.com/agnostack/next-shopify/commit/ecd36257e4cde1bbdea48b895934e82ecedf0612))
65
+ * wip ([825f688](https://github.com/agnostack/next-shopify/commit/825f688f614be631c13a70e1c652c45f742408ed))
66
+ * wip ([a66af1e](https://github.com/agnostack/next-shopify/commit/a66af1e574e9e1cc08b2718c4a49f46caf42db9f))
67
+ * wip ([ab11674](https://github.com/agnostack/next-shopify/commit/ab116749073075133350e46d272b5475bb6e9d1b))
53
68
 
54
-
55
- ### Bug Fixes
56
-
57
- * wip ([6f3d3f5](https://github.com/agnostack/next-shopify/commit/6f3d3f515831fce0f30e6a34b3603ad89114ae38))
58
-
59
- ## [1.13.7-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.13.6...v1.13.7-alpha.1) (2023-12-01)
69
+ ## [1.13.6](https://github.com/agnostack/next-shopify/compare/v1.13.5...v1.13.6) (2023-12-01)
60
70
 
61
71
 
62
72
  ### Bug Fixes
63
73
 
64
- * wip ([d3d121f](https://github.com/agnostack/next-shopify/commit/d3d121f402b46648cad0b1767a5ddd03de8d9dd7))
74
+ * added react export and useVerification ([7131369](https://github.com/agnostack/next-shopify/commit/71313698da5b30b94a0b28fa9a0d6e595e16c5bd))
75
+ * reverted pubblic-key vs api-key ([b3b40ac](https://github.com/agnostack/next-shopify/commit/b3b40ace673090d321635e011818ea130b7ddd3c))
76
+ * wip ([088e2f8](https://github.com/agnostack/next-shopify/commit/088e2f84ecb27dc435f1d9a7e1a53eb955fc6fd6))
77
+ * wip ([b0eb414](https://github.com/agnostack/next-shopify/commit/b0eb414b9a3c3d02aaef66b72569dba6c1bdccb0))
78
+ * wip ([cd8d260](https://github.com/agnostack/next-shopify/commit/cd8d260f40672cc066da5695c7a72a790f71d4a1))
79
+ * wip ([f8d453a](https://github.com/agnostack/next-shopify/commit/f8d453a850ead76d6d2c536fe1f8f472f380c1c6))
80
+ * wip ([82e20e8](https://github.com/agnostack/next-shopify/commit/82e20e8e9878ac7f9424ff990e8959c3cbe66e9d))
81
+ * wip ([ecd3625](https://github.com/agnostack/next-shopify/commit/ecd36257e4cde1bbdea48b895934e82ecedf0612))
82
+ * wip ([825f688](https://github.com/agnostack/next-shopify/commit/825f688f614be631c13a70e1c652c45f742408ed))
83
+ * wip ([a66af1e](https://github.com/agnostack/next-shopify/commit/a66af1e574e9e1cc08b2718c4a49f46caf42db9f))
84
+ * wip ([ab11674](https://github.com/agnostack/next-shopify/commit/ab116749073075133350e46d272b5475bb6e9d1b))
65
85
 
66
86
  ## [1.13.6](https://github.com/agnostack/next-shopify/compare/v1.13.5...v1.13.6) (2023-12-01)
67
87
 
@@ -69,12 +89,6 @@
69
89
  ### Bug Fixes
70
90
 
71
91
  * wip ([a0e6d9b](https://github.com/agnostack/next-shopify/commit/a0e6d9b293964314160a9eb8f13d7992c7116af8))
72
-
73
- ## [1.13.6-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.13.5...v1.13.6-alpha.1) (2023-12-01)
74
-
75
-
76
- ### Bug Fixes
77
-
78
92
  * wip ([a0e6d9b](https://github.com/agnostack/next-shopify/commit/a0e6d9b293964314160a9eb8f13d7992c7116af8))
79
93
 
80
94
  ## [1.13.5](https://github.com/agnostack/next-shopify/compare/v1.13.4...v1.13.5) (2023-11-30)
@@ -82,21 +96,40 @@
82
96
 
83
97
  ### Bug Fixes
84
98
 
85
- * wip ([d0e3583](https://github.com/agnostack/next-shopify/commit/d0e35831a73f4c8ffc0a8f073a25bf37f6877502))
86
- * wip ([6bc1e78](https://github.com/agnostack/next-shopify/commit/6bc1e78c764fde2673669c80ad525f733f413d7f))
99
+ * added react export and useVerification ([7131369](https://github.com/agnostack/next-shopify/commit/71313698da5b30b94a0b28fa9a0d6e595e16c5bd))
100
+ * wip ([088e2f8](https://github.com/agnostack/next-shopify/commit/088e2f84ecb27dc435f1d9a7e1a53eb955fc6fd6))
101
+ * wip ([b0eb414](https://github.com/agnostack/next-shopify/commit/b0eb414b9a3c3d02aaef66b72569dba6c1bdccb0))
102
+ * wip ([cd8d260](https://github.com/agnostack/next-shopify/commit/cd8d260f40672cc066da5695c7a72a790f71d4a1))
103
+ * wip ([f8d453a](https://github.com/agnostack/next-shopify/commit/f8d453a850ead76d6d2c536fe1f8f472f380c1c6))
104
+ * wip ([82e20e8](https://github.com/agnostack/next-shopify/commit/82e20e8e9878ac7f9424ff990e8959c3cbe66e9d))
105
+ * wip ([ecd3625](https://github.com/agnostack/next-shopify/commit/ecd36257e4cde1bbdea48b895934e82ecedf0612))
106
+ * wip ([825f688](https://github.com/agnostack/next-shopify/commit/825f688f614be631c13a70e1c652c45f742408ed))
107
+ * wip ([a66af1e](https://github.com/agnostack/next-shopify/commit/a66af1e574e9e1cc08b2718c4a49f46caf42db9f))
108
+ * wip ([ab11674](https://github.com/agnostack/next-shopify/commit/ab116749073075133350e46d272b5475bb6e9d1b))
87
109
 
88
- ## [1.13.5-alpha.2](https://github.com/agnostack/next-shopify/compare/v1.13.5-alpha.1...v1.13.5-alpha.2) (2023-11-30)
110
+ ## [1.13.6-beta.1](https://github.com/agnostack/next-shopify/compare/v1.13.5-beta.7...v1.13.5-beta.8) (2023-11-30)
89
111
 
90
112
 
91
113
  ### Bug Fixes
92
114
 
93
- * wip ([d0e3583](https://github.com/agnostack/next-shopify/commit/d0e35831a73f4c8ffc0a8f073a25bf37f6877502))
115
+ * wip ([b0eb414](https://github.com/agnostack/next-shopify/commit/b0eb414b9a3c3d02aaef66b72569dba6c1bdccb0))
116
+ * wip ([cd8d260](https://github.com/agnostack/next-shopify/commit/cd8d260f40672cc066da5695c7a72a790f71d4a1))
117
+ * wip ([f8d453a](https://github.com/agnostack/next-shopify/commit/f8d453a850ead76d6d2c536fe1f8f472f380c1c6))
118
+ * wip ([82e20e8](https://github.com/agnostack/next-shopify/commit/82e20e8e9878ac7f9424ff990e8959c3cbe66e9d))
119
+ * wip ([ecd3625](https://github.com/agnostack/next-shopify/commit/ecd36257e4cde1bbdea48b895934e82ecedf0612))
120
+ * wip ([825f688](https://github.com/agnostack/next-shopify/commit/825f688f614be631c13a70e1c652c45f742408ed))
121
+ * wip ([a66af1e](https://github.com/agnostack/next-shopify/commit/a66af1e574e9e1cc08b2718c4a49f46caf42db9f))
122
+ * added react export and useVerification ([7131369](https://github.com/agnostack/next-shopify/commit/71313698da5b30b94a0b28fa9a0d6e595e16c5bd))
123
+ * wip ([ab11674](https://github.com/agnostack/next-shopify/commit/ab116749073075133350e46d272b5475bb6e9d1b))
94
124
 
95
- ## [1.13.5-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.13.4...v1.13.5-alpha.1) (2023-11-30)
125
+ ## [1.13.5](https://github.com/agnostack/next-shopify/compare/v1.13.4...v1.13.5) (2023-11-30)
96
126
 
97
127
 
98
128
  ### Bug Fixes
99
129
 
130
+ * wip ([d0e3583](https://github.com/agnostack/next-shopify/commit/d0e35831a73f4c8ffc0a8f073a25bf37f6877502))
131
+ * wip ([6bc1e78](https://github.com/agnostack/next-shopify/commit/6bc1e78c764fde2673669c80ad525f733f413d7f))
132
+ * wip ([d0e3583](https://github.com/agnostack/next-shopify/commit/d0e35831a73f4c8ffc0a8f073a25bf37f6877502))
100
133
  * wip ([6bc1e78](https://github.com/agnostack/next-shopify/commit/6bc1e78c764fde2673669c80ad525f733f413d7f))
101
134
 
102
135
  ## [1.13.4](https://github.com/agnostack/next-shopify/compare/v1.13.3...v1.13.4) (2023-11-29)
@@ -1,12 +1,8 @@
1
- export * from "./appInstallation";
2
1
  export * from "./auth";
3
2
  export * from "./billing";
4
3
  export * from "./callback";
5
- export * from "./graph";
6
- export * from "./proxy";
7
- export * from "./rest";
8
- export * from "./token";
9
4
  export * from "./uninstall";
5
+ export * from "./verifiable";
10
6
  export * from "./webhook";
11
7
  export function getAPIConfig(config: any): {
12
8
  api: any;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/handlers/api/index.js"],"names":[],"mappings":";;;;;;;;;;AAYO;;EAKL"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/handlers/api/index.js"],"names":[],"mappings":";;;;;;AAQO;;EAKL"}
@@ -2,15 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAPIConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./appInstallation"), exports);
6
5
  tslib_1.__exportStar(require("./auth"), exports);
7
6
  tslib_1.__exportStar(require("./billing"), exports);
8
7
  tslib_1.__exportStar(require("./callback"), exports);
9
- tslib_1.__exportStar(require("./graph"), exports);
10
- tslib_1.__exportStar(require("./proxy"), exports);
11
- tslib_1.__exportStar(require("./rest"), exports);
12
- tslib_1.__exportStar(require("./token"), exports);
13
8
  tslib_1.__exportStar(require("./uninstall"), exports);
9
+ tslib_1.__exportStar(require("./verifiable"), exports);
14
10
  tslib_1.__exportStar(require("./webhook"), exports);
15
11
  // NOTE raw request body is required for Shopify webhook validation
16
12
  const getAPIConfig = (config) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/handlers/api/index.js"],"names":[],"mappings":";;;;AAAA,4DAAiC;AACjC,iDAAsB;AACtB,oDAAyB;AACzB,qDAA0B;AAC1B,kDAAuB;AACvB,kDAAuB;AACvB,iDAAsB;AACtB,kDAAuB;AACvB,sDAA2B;AAC3B,oDAAyB;AAEzB,mEAAmE;AAC5D,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvC,GAAG,kBACD,UAAU,EAAE,KAAK,IACd,MAAM,CACV;CACF,CAAC,CAAA;AALW,QAAA,YAAY,gBAKvB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/handlers/api/index.js"],"names":[],"mappings":";;;;AAAA,iDAAsB;AACtB,oDAAyB;AACzB,qDAA0B;AAC1B,sDAA2B;AAC3B,uDAA4B;AAC5B,oDAAyB;AAEzB,mEAAmE;AAC5D,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvC,GAAG,kBACD,UAAU,EAAE,KAAK,IACd,MAAM,CACV;CACF,CAAC,CAAA;AALW,QAAA,YAAY,gBAKvB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appInstallation.d.ts","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/appInstallation.js"],"names":[],"mappings":"AAIO,uHAcN"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appInstallation.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/appInstallation.js"],"names":[],"mappings":";;;;AAAA,4CAAmE;AACnE,mCAAqC;AAErC,gGAAgG;AACzF,MAAM,yBAAyB,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;IAC3F,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAA;IAE9B,IAAI,IAAA,oBAAW,EAAC,KAAK,CAAC,EAAE;QACtB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC,CAAA;KACnE;IAED,MAAM,YAAY,GAAG,IAAA,mBAAW,EAAC,mBAAmB,CAAC,CAAA;IAErD,OAAO,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE;QAC5B,KAAK,EAAE,kBAAS,CAAC,YAAY;QAC7B,SAAS,EAAE,EAAE,SAAS,EAAE,GAAG,KAAK,aAAa,EAAE;QAC/C,SAAS,EAAE,kBAAS,CAAC,SAAS;KAC/B,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AAdY,QAAA,yBAAyB,6BAcrC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/graph.js"],"names":[],"mappings":"AAmBO,yGAiHN"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleGraph = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const shopify_api_1 = require("@shopify/shopify-api");
6
+ const utils_1 = require("../../utils");
7
+ const shared_1 = require("../../../shared");
8
+ const handleGraph = (serverRuntimeConfig) => {
9
+ const _getVerifiedBody = (0, utils_1.getVerifiedBody)(serverRuntimeConfig);
10
+ return (req, res, params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
11
+ var _a, _b, _c;
12
+ const [requestBody, processResponse] = yield _getVerifiedBody(req, res);
13
+ const _d = (_a = req.query) !== null && _a !== void 0 ? _a : {}, { shop, apiVersion } = _d, _query = tslib_1.__rest(_d, ["shop", "apiVersion"]);
14
+ const _e = params !== null && params !== void 0 ? params : requestBody, { isOnline, query: graphQuery, variables: graphVariables, transform = (_data) => _data } = _e, graphParams = tslib_1.__rest(_e, ["isOnline", "query", "variables", "transform"]);
15
+ let query = _query;
16
+ if ((0, shared_1.isType)(query, 'string')) {
17
+ query = (0, shared_1.querystringToObject)(query);
18
+ }
19
+ if ((0, shared_1.stringEmpty)(shop) || (0, shared_1.stringEmpty)(graphQuery)) {
20
+ return res.status(400).json({ message: 'Invalid arguments' });
21
+ }
22
+ let statusCode;
23
+ let response;
24
+ let headers = {};
25
+ let message = 'Error handling query call';
26
+ try {
27
+ const { getVerifiedClients } = yield (0, utils_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
28
+ const { Graphql } = yield getVerifiedClients({ req, res, shop, apiVersion, isOnline });
29
+ response = yield Graphql.query(Object.assign(Object.assign({ data: graphVariables ? {
30
+ query: graphQuery,
31
+ variables: graphVariables,
32
+ } : graphQuery }, (0, shared_1.objectNotEmpty)(query) && { query }), graphParams))
33
+ .then(processResponse);
34
+ statusCode = 200;
35
+ }
36
+ catch (error) {
37
+ statusCode = 500;
38
+ // TODO: clean up to share between rest and graph (pr at least keep in sync)
39
+ switch (true) {
40
+ case error instanceof shared_1.ShopifyAuthenticationError: {
41
+ console.error(`${message}. Authentication Error.`, error);
42
+ const errorResponse = (0, utils_1.getAuthErrorResponse)(serverRuntimeConfig, { error, shop });
43
+ statusCode = errorResponse.statusCode;
44
+ message = errorResponse.message;
45
+ // HMMMM, should this be:
46
+ // message = `${message}. Authentication Error - ${errroResponse.message}.`
47
+ headers = errorResponse.headers;
48
+ break;
49
+ }
50
+ case error instanceof shopify_api_1.BillingError: {
51
+ // HMMMM, should this be:
52
+ // message = `${message}. Billing Error - ${error.message}.`
53
+ console.error(`${message}. Billing Error - ${error.message}.`, error.errorData);
54
+ statusCode = 402;
55
+ if (error === null || error === void 0 ? void 0 : error.message) {
56
+ message = error.message;
57
+ }
58
+ break;
59
+ }
60
+ case error instanceof shopify_api_1.GraphqlQueryError: {
61
+ const errorMessages = (0, shared_1.ensureArray)((_b = error.response) === null || _b === void 0 ? void 0 : _b.errors).map(({ message }) => (0, shared_1.ensureString)(message));
62
+ console.error(`${message}. ${errorMessages.join('. ')}.`);
63
+ // HMMMM, should this be:
64
+ // message = `${message}. ${errorMessages.join('. ')}.`
65
+ // TODO: why are these not sending back different error codes?
66
+ break;
67
+ }
68
+ default: {
69
+ console.error(`${message}. HandleGraph Error - ${error.message}.`);
70
+ break;
71
+ }
72
+ }
73
+ }
74
+ Object.entries(headers).forEach(([key, value]) => {
75
+ res.setHeader(key, value);
76
+ });
77
+ if (!(response === null || response === void 0 ? void 0 : response.body)) {
78
+ return res.status(statusCode).json({ message });
79
+ }
80
+ try {
81
+ const responseBody = (_c = response.body.data) !== null && _c !== void 0 ? _c : response.body;
82
+ const [_responseData] = Object.values((0, shared_1.ensureObject)(responseBody));
83
+ const _f = (0, shared_1.ensureObject)(_responseData), { userErrors } = _f, responseData = tslib_1.__rest(_f, ["userErrors"]);
84
+ if ((0, shared_1.arrayNotEmpty)(userErrors)) {
85
+ const errorMessages = (0, shared_1.ensureArray)(userErrors).map(({ message }) => (0, shared_1.ensureString)(message));
86
+ return res.status(500).json({ message: `${message}. ${errorMessages.join('. ')}.` });
87
+ }
88
+ // NOTE: sending in both to transform in case someone needs the userErrors
89
+ return res.status(statusCode).json(transform(responseData, responseBody));
90
+ }
91
+ catch (error) {
92
+ console.error(`${message}. Transformation Error.`, error);
93
+ return res.status(500).json({ message });
94
+ }
95
+ });
96
+ };
97
+ exports.handleGraph = handleGraph;
98
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/graph.js"],"names":[],"mappings":";;;;AAAA,sDAAsE;AAEtE,uCAIoB;AACpB,4CAUwB;AAEjB,MAAM,WAAW,GAAG,CAAC,mBAAmB,EAAE,EAAE;IACjD,MAAM,gBAAgB,GAAG,IAAA,uBAAe,EAAC,mBAAmB,CAAC,CAAA;IAE7D,OAAO,CAAO,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;;QAChC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAEvE,MAAM,KAAkC,MAAA,GAAG,CAAC,KAAK,mCAAI,EAAE,EAAjD,EAAE,IAAI,EAAE,UAAU,OAA+B,EAA1B,MAAM,sBAA7B,sBAA+B,CAAkB,CAAA;QACvD,MAAM,KAMF,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,WAAW,EANnB,EACJ,QAAQ,EACR,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,cAAc,EACzB,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,OAEL,EADpB,WAAW,sBALV,+CAML,CAAwB,CAAA;QAEzB,IAAI,KAAK,GAAG,MAAM,CAAA;QAClB,IAAI,IAAA,eAAM,EAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;YAC3B,KAAK,GAAG,IAAA,4BAAmB,EAAC,KAAK,CAAC,CAAA;SACnC;QAED,IAAI,IAAA,oBAAW,EAAC,IAAI,CAAC,IAAI,IAAA,oBAAW,EAAC,UAAU,C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jHY,QAAA,WAAW,eAiHvB"}
@@ -0,0 +1,6 @@
1
+ export * from "./appInstallation";
2
+ export * from "./graph";
3
+ export * from "./proxy";
4
+ export * from "./rest";
5
+ export * from "./token";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./appInstallation"), exports);
5
+ tslib_1.__exportStar(require("./graph"), exports);
6
+ tslib_1.__exportStar(require("./proxy"), exports);
7
+ tslib_1.__exportStar(require("./rest"), exports);
8
+ tslib_1.__exportStar(require("./token"), exports);
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/index.js"],"names":[],"mappings":";;;AAAA,4DAAiC;AACjC,kDAAuB;AACvB,kDAAuB;AACvB,iDAAsB;AACtB,kDAAuB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/proxy.js"],"names":[],"mappings":"AAmCO,sHAwLN"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleProxy = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /* eslint-disable @typescript-eslint/no-unused-vars */
6
+ const nextjs_cors_1 = tslib_1.__importDefault(require("nextjs-cors"));
7
+ const http_proxy_1 = tslib_1.__importDefault(require("http-proxy"));
8
+ const node_http_proxy_json_1 = tslib_1.__importDefault(require("node-http-proxy-json"));
9
+ const utils_1 = require("../../utils");
10
+ const shared_1 = require("../../../shared");
11
+ const PROXY_TIMEOUT = 6000; // NOTE: 6 seconds
12
+ const verifyAppProxySignature = (signature, verifiable, hmacSecret) => {
13
+ const hmac = (0, utils_1.generateHMAC)((0, shared_1.objectToSortedString)(verifiable), hmacSecret);
14
+ return (0, utils_1.compareHashes)(signature, hmac);
15
+ };
16
+ const handleProxy = (serverRuntimeConfig, config) => {
17
+ const { generateReplacements } = config !== null && config !== void 0 ? config : {};
18
+ const { API_PATHS, APP_CONFIG, APP_BASE_URL, TARGET_SAFELIST, ORIGIN_SAFELIST, } = serverRuntimeConfig;
19
+ const _getVerifiedBody = (0, utils_1.getVerifiedBody)(serverRuntimeConfig);
20
+ return (req, res, params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
21
+ var _a, _b;
22
+ const _c = (_a = req.headers) !== null && _a !== void 0 ? _a : {}, { origin, 'x-forwarded-for': _forwardFor, 'x-forwarded-proto': _forwardProto, 'x-forwarded-host': forwardHost, 'x-proxy-origin': proxyOrigin } = _c, _headers = tslib_1.__rest(_c, ["origin", 'x-forwarded-for', 'x-forwarded-proto', 'x-forwarded-host', 'x-proxy-origin']);
23
+ const { 'x-extension-session': sessionToken, 'x-extension-point': extensionPoint, 'x-shop-domain': shopDomainHeader, 'x-shopify-shop-domain': shopifyShopDomainHeader, 'x-shopify-shop': shopHeader = shopifyShopDomainHeader !== null && shopifyShopDomainHeader !== void 0 ? shopifyShopDomainHeader : shopDomainHeader, 'x-shopify-app-id': shopifyAppId, 'x-app-id': appId = shopifyAppId,
24
+ // 'x-shopify-app-installation-id': shopifyAppInstallationId,
25
+ // 'x-app-installation-id': appInstallationId = shopifyAppInstallationId, // TODO: pass along installationId??
26
+ // TODO: pass along providerSetId???
27
+ } = _headers;
28
+ let targetPath;
29
+ try {
30
+ // NOTE: GET requests are not always sending along origin
31
+ if ((0, shared_1.stringEmpty)(origin)) {
32
+ req.headers = Object.assign(Object.assign({}, req.headers), { origin: proxyOrigin || forwardHost });
33
+ }
34
+ const _d = (_b = req.query) !== null && _b !== void 0 ? _b : {}, { signature, proxyEncoded } = _d, verifiable = tslib_1.__rest(_d, ["signature", "proxyEncoded"]);
35
+ const { shop: _shop, host, timestamp, path_prefix } = verifiable;
36
+ const shop = _shop || shopHeader;
37
+ yield (0, nextjs_cors_1.default)(req, res, {
38
+ methods: ['PUT', 'PATCH', 'POST', 'DELETE'],
39
+ origin: (origin, callback) => {
40
+ const isSafelisted = (0, shared_1.matchHostname)(origin, [
41
+ ...ORIGIN_SAFELIST,
42
+ 'cdn.shopify.com' // NOTE: this is the domain for checkout UI extensions
43
+ ]);
44
+ if (isSafelisted) {
45
+ return callback(null, true);
46
+ }
47
+ return callback(new Error('Invalid CORS origin'));
48
+ },
49
+ optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
50
+ });
51
+ const { target: targetParam } = params !== null && params !== void 0 ? params : {};
52
+ // eslint-disable-next-line max-len
53
+ const _targetUrl = ((0, shared_1.stringEmpty)(targetParam) || targetParam.startsWith('http')) ? targetParam : `${APP_BASE_URL}/${(0, shared_1.removeLeadingSlash)(targetParam)}`;
54
+ const { origin: target, hostname, pathname, search } = (0, shared_1.stringNotEmpty)(_targetUrl) ? new URL(_targetUrl) : {};
55
+ targetPath = [pathname, search].filter(shared_1.stringNotEmpty).join('');
56
+ const safelistedTarget = (0, shared_1.matchHostname)(hostname, Object.assign({ [new URL(APP_BASE_URL).hostname]: {
57
+ // HMMM: can we generate our own session token (or use the current one) so as to not have to tell handleGraph/Rest to behave as offline?
58
+ // headers: {
59
+ // Authorization: 'Bearer {{setting.zendesk.token}}',
60
+ // },
61
+ params: {
62
+ shop,
63
+ host,
64
+ },
65
+ } }, TARGET_SAFELIST));
66
+ if ((0, shared_1.stringEmpty)(targetPath) || (safelistedTarget == undefined)) {
67
+ return res.status(407).json({ message: 'Unproxyable target' });
68
+ }
69
+ if (!shop || !host || !extensionPoint || !signature || !proxyEncoded) {
70
+ return res.status(400).json({ message: 'Invalid or missing headers', extensionPoint });
71
+ }
72
+ const isShopifyOriginOrRelative = (0, shared_1.stringNotEmpty)((0, shared_1.ensureString)(path_prefix).startsWith('http')
73
+ ? (0, shared_1.sanitizeShop)(new URL(path_prefix).hostname)
74
+ : path_prefix);
75
+ // TODO: once Shopify fixes CORS issue when origin is cdn.shopify.com, update this!
76
+ if (!verifyAppProxySignature(signature, verifiable, isShopifyOriginOrRelative ? APP_CONFIG.apiSecretKey : timestamp)) {
77
+ return res.status(403).json({ message: 'Invalid signature' });
78
+ }
79
+ // TODO: clean up targetParam.startsWith??
80
+ if (!targetParam.startsWith(API_PATHS[shared_1.API_ROUTE_NAMES.SESSION_TOKEN])) {
81
+ const _getVerifiedSessionData = (0, utils_1.getVerifiedSessionData)(serverRuntimeConfig);
82
+ if (!_getVerifiedSessionData(sessionToken, { shop, host }).catch((_error) => {
83
+ if (_error instanceof shared_1.ShopifySessionInvalidError) {
84
+ return res.status(403).json({ message: _error.message });
85
+ }
86
+ throw _error;
87
+ })) {
88
+ return res.status(403).json({ message: 'Unverified signature' });
89
+ }
90
+ }
91
+ const { headers: targetHeaders, params: targetParams } = (0, shared_1.ensureObject)(safelistedTarget);
92
+ if ((0, shared_1.objectNotEmpty)(targetParams)) {
93
+ targetPath = (0, shared_1.appendQuery)(targetPath, new URLSearchParams(targetParams).toString());
94
+ }
95
+ const [requestBody, processResponse] = yield _getVerifiedBody(req, res, targetPath);
96
+ console.log(`>>> > handleProxy > requestBody, processResponse:`, requestBody, processResponse);
97
+ const _prepareHeaders = (0, utils_1.prepareHeaders)(serverRuntimeConfig);
98
+ const headers = yield _prepareHeaders({
99
+ generateReplacements,
100
+ shop,
101
+ appId,
102
+ headers: Object.assign(Object.assign({}, _headers), targetHeaders),
103
+ });
104
+ const proxy = http_proxy_1.default.createProxy();
105
+ return new Promise((resolve, reject) => {
106
+ req.url = targetPath;
107
+ if (headers) {
108
+ req.headers = headers;
109
+ }
110
+ proxy.on('proxyReq', (proxyReq, proxyReqRequest, proxyReqResponse, options) => {
111
+ if ((0, shared_1.objectNotEmpty)(requestBody)) {
112
+ const bodyData = JSON.stringify(requestBody);
113
+ proxyReq.setHeader('Content-Length', Buffer.byteLength(bodyData));
114
+ proxyReq.write(bodyData);
115
+ }
116
+ });
117
+ proxy.on('proxyRes', function (proxyRes, proxyResRequest, proxyResResponse) {
118
+ (0, node_http_proxy_json_1.default)(proxyResResponse, proxyRes, function (proxyResBody) {
119
+ return processResponse(proxyResBody);
120
+ });
121
+ });
122
+ proxy.once('error', (error) => {
123
+ console.error('Proxy error', error);
124
+ reject(error);
125
+ });
126
+ proxy.web(req, res, {
127
+ target,
128
+ timeout: PROXY_TIMEOUT,
129
+ proxyTimeout: PROXY_TIMEOUT,
130
+ followRedirects: false,
131
+ changeOrigin: true,
132
+ secure: true,
133
+ });
134
+ });
135
+ }
136
+ catch (error) {
137
+ console.error(`Error handling proxy request for '${targetPath}'`, error);
138
+ return res.status(200).json({ message: (error === null || error === void 0 ? void 0 : error.message) || 'Error handling proxy request', targetPath });
139
+ }
140
+ });
141
+ };
142
+ exports.handleProxy = handleProxy;
143
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/proxy.js"],"names":[],"mappings":";;;;AAAA,sDAAsD;AACtD,sEAAkC;AAClC,oEAAkC;AAClC,wFAAkD;AAElD,uCAMoB;AACpB,4CAawB;AAExB,MAAM,aAAa,GAAG,IAAI,CAAA,CAAC,kBAAkB;AAE7C,MAAM,uBAAuB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE;IACpE,MAAM,IAAI,GAAG,IAAA,oBAAY,EAAC,IAAA,6BAAoB,EAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAA;IAEvE,OAAO,IAAA,qBAAa,EAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC,CAAA;AAEM,MAAM,WAAW,GAAG,CAAC,mBAAmB,EAAE,MAAM,EAAE,EAAE;IACzD,MAAM,EAAE,oBAAoB,EA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,EAAE;oBAClB,MAAM;oBACN,OAAO,EAAE,aAAa;oBACtB,YAAY,EAAE,aAAa;oBAC3B,eAAe,EAAE,KAAK;oBACtB,YAAY,EAAE,IAAI;oBAClB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,qCAAqC,UAAU,GAAG,EAAE,KAAK,CAAC,CAAA;YACxE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,8BAA8B,EAAE,UAAU,EAAE,CAAC,CAAA;SACvG;IACH,CAAC,CAAA,CAAA;AACH,CAAC,CAAA;AAxLY,QAAA,WAAW,eAwLvB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../../../src/lib/handlers/api/verifiable/rest.js"],"names":[],"mappings":"AAgBO,yGAuGN"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleRest = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const shopify_api_1 = require("@shopify/shopify-api");
6
+ const utils_1 = require("../../utils");
7
+ const shared_1 = require("../../../shared");
8
+ const handleRest = (serverRuntimeConfig) => {
9
+ const _getVerifiedBody = (0, utils_1.getVerifiedBody)(serverRuntimeConfig);
10
+ return (req, res, _params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
11
+ const [requestBody, processResponse] = yield _getVerifiedBody(req, res);
12
+ const { query: _query, method: _method } = req;
13
+ const { shop } = _query !== null && _query !== void 0 ? _query : {};
14
+ const _a = _params !== null && _params !== void 0 ? _params : {}, { path, isOnline, method: methodParam, query: queryParam, body: bodyParam, transform = (_data) => _data } = _a, params = tslib_1.__rest(_a, ["path", "isOnline", "method", "query", "body", "transform"]);
15
+ if ((0, shared_1.stringEmpty)(shop) || (0, shared_1.stringEmpty)(path)) {
16
+ return {
17
+ statusCode: 400,
18
+ message: 'Invalid arguments',
19
+ };
20
+ }
21
+ let statusCode;
22
+ let response;
23
+ let message;
24
+ let headers = {};
25
+ try {
26
+ let queryData = queryParam !== null && queryParam !== void 0 ? queryParam : _query;
27
+ if ((0, shared_1.isType)(queryData, 'string')) {
28
+ queryData = (0, shared_1.querystringToObject)(queryData);
29
+ }
30
+ const _b = (0, shared_1.ensureObject)(queryData), { apiVersion } = _b, query = tslib_1.__rest(_b, ["apiVersion"]);
31
+ const body = bodyParam !== null && bodyParam !== void 0 ? bodyParam : requestBody;
32
+ const method = (0, shared_1.ensureString)(methodParam !== null && methodParam !== void 0 ? methodParam : _method).toLowerCase();
33
+ const { getVerifiedClients } = yield (0, utils_1.getShopifyHelpers)(serverRuntimeConfig, { shop });
34
+ const { Rest } = yield getVerifiedClients({ req, res, shop, apiVersion, isOnline });
35
+ response = yield Rest[method](Object.assign({ path,
36
+ query,
37
+ body, type: shopify_api_1.DataType.JSON }, params))
38
+ .then(processResponse);
39
+ statusCode = 200;
40
+ }
41
+ catch (error) {
42
+ message = 'Error handling rest call';
43
+ statusCode = 500;
44
+ // TODO: clean up to share between rest and graph (pr at least keep in sync)
45
+ switch (true) {
46
+ case error instanceof shared_1.ShopifyAuthenticationError: {
47
+ console.error(`${message}. Authentication Error.`, error);
48
+ const errorResponse = (0, utils_1.getAuthErrorResponse)(serverRuntimeConfig, { error, shop });
49
+ statusCode = errorResponse.statusCode;
50
+ message = errorResponse.message;
51
+ headers = errorResponse.headers;
52
+ break;
53
+ }
54
+ case error instanceof shopify_api_1.BillingError: {
55
+ console.error(`${message}. Billing Error - ${error.message}.`, error.errorData);
56
+ statusCode = 402;
57
+ if (error === null || error === void 0 ? void 0 : error.message) {
58
+ message = error.message;
59
+ }
60
+ break;
61
+ }
62
+ default: {
63
+ console.error(message, error);
64
+ break;
65
+ }
66
+ }
67
+ }
68
+ Object.entries(headers).forEach(([key, value]) => {
69
+ res.setHeader(key, value);
70
+ });
71
+ if (!response) {
72
+ return res.status(statusCode).json({ message });
73
+ }
74
+ // HMMMMM???
75
+ if ((params === null || params === void 0 ? void 0 : params.type) && ![shopify_api_1.DataType.GraphQL, shopify_api_1.DataType.JSON].includes(params.type)) {
76
+ return res.status(statusCode).send(response);
77
+ }
78
+ if (!(response === null || response === void 0 ? void 0 : response.body)) {
79
+ return res.status(statusCode).json({ message });
80
+ }
81
+ return res.status(statusCode).json(transform(response.body));
82
+ });
83
+ };
84
+ exports.handleRest = handleRest;
85
+ //# sourceMappingURL=rest.js.map