@shopify/shopify-app-remix 1.0.0-rc.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 (161) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +373 -0
  3. package/build/cjs/adapters/node/index.js +13 -0
  4. package/build/cjs/auth/admin/authenticate.js +599 -0
  5. package/build/cjs/auth/admin/graphql-client.js +57 -0
  6. package/build/cjs/auth/admin/rest-client.js +124 -0
  7. package/build/cjs/auth/const.js +17 -0
  8. package/build/cjs/auth/helpers/add-response-headers.js +69 -0
  9. package/build/cjs/auth/helpers/begin-auth.js +18 -0
  10. package/build/cjs/auth/helpers/get-session-token-header.js +10 -0
  11. package/build/cjs/auth/helpers/handle-client-error.js +37 -0
  12. package/build/cjs/auth/helpers/redirect-to-auth-page.js +22 -0
  13. package/build/cjs/auth/helpers/redirect-with-app-bridge-headers.js +31 -0
  14. package/build/cjs/auth/helpers/redirect-with-exitiframe.js +23 -0
  15. package/build/cjs/auth/helpers/reject-bot-request.js +23 -0
  16. package/build/cjs/auth/helpers/validate-session-token.js +25 -0
  17. package/build/cjs/auth/login/login.js +54 -0
  18. package/build/cjs/auth/public/authenticate.js +32 -0
  19. package/build/cjs/auth/webhooks/authenticate.js +68 -0
  20. package/build/cjs/auth/webhooks/register.js +40 -0
  21. package/build/cjs/billing/cancel.js +40 -0
  22. package/build/cjs/billing/request.js +83 -0
  23. package/build/cjs/billing/require.js +47 -0
  24. package/build/cjs/index.js +140 -0
  25. package/build/cjs/override-logger.js +55 -0
  26. package/build/cjs/types.js +25 -0
  27. package/build/cjs/version.js +7 -0
  28. package/build/ts/adapters/node/index.d.ts +2 -0
  29. package/build/ts/adapters/node/index.d.ts.map +1 -0
  30. package/build/ts/adapters/node/index.js +10 -0
  31. package/build/ts/adapters/node/index.js.map +1 -0
  32. package/build/ts/auth/admin/authenticate.d.ts +32 -0
  33. package/build/ts/auth/admin/authenticate.d.ts.map +1 -0
  34. package/build/ts/auth/admin/authenticate.js +571 -0
  35. package/build/ts/auth/admin/authenticate.js.map +1 -0
  36. package/build/ts/auth/admin/graphql-client.d.ts +22 -0
  37. package/build/ts/auth/admin/graphql-client.d.ts.map +1 -0
  38. package/build/ts/auth/admin/graphql-client.js +53 -0
  39. package/build/ts/auth/admin/graphql-client.js.map +1 -0
  40. package/build/ts/auth/admin/rest-client.d.ts +34 -0
  41. package/build/ts/auth/admin/rest-client.d.ts.map +1 -0
  42. package/build/ts/auth/admin/rest-client.js +134 -0
  43. package/build/ts/auth/admin/rest-client.js.map +1 -0
  44. package/build/ts/auth/admin/types.d.ts +100 -0
  45. package/build/ts/auth/admin/types.d.ts.map +1 -0
  46. package/build/ts/auth/admin/types.js +3 -0
  47. package/build/ts/auth/admin/types.js.map +1 -0
  48. package/build/ts/auth/const.d.ts +9 -0
  49. package/build/ts/auth/const.d.ts.map +1 -0
  50. package/build/ts/auth/const.js +12 -0
  51. package/build/ts/auth/const.js.map +1 -0
  52. package/build/ts/auth/helpers/add-response-headers.d.ts +5 -0
  53. package/build/ts/auth/helpers/add-response-headers.d.ts.map +1 -0
  54. package/build/ts/auth/helpers/add-response-headers.js +60 -0
  55. package/build/ts/auth/helpers/add-response-headers.js.map +1 -0
  56. package/build/ts/auth/helpers/begin-auth.d.ts +3 -0
  57. package/build/ts/auth/helpers/begin-auth.d.ts.map +1 -0
  58. package/build/ts/auth/helpers/begin-auth.js +24 -0
  59. package/build/ts/auth/helpers/begin-auth.js.map +1 -0
  60. package/build/ts/auth/helpers/get-session-token-header.d.ts +2 -0
  61. package/build/ts/auth/helpers/get-session-token-header.d.ts.map +1 -0
  62. package/build/ts/auth/helpers/get-session-token-header.js +9 -0
  63. package/build/ts/auth/helpers/get-session-token-header.js.map +1 -0
  64. package/build/ts/auth/helpers/handle-client-error.d.ts +11 -0
  65. package/build/ts/auth/helpers/handle-client-error.d.ts.map +1 -0
  66. package/build/ts/auth/helpers/handle-client-error.js +40 -0
  67. package/build/ts/auth/helpers/handle-client-error.js.map +1 -0
  68. package/build/ts/auth/helpers/index.d.ts +8 -0
  69. package/build/ts/auth/helpers/index.d.ts.map +1 -0
  70. package/build/ts/auth/helpers/index.js +18 -0
  71. package/build/ts/auth/helpers/index.js.map +1 -0
  72. package/build/ts/auth/helpers/redirect-to-auth-page.d.ts +3 -0
  73. package/build/ts/auth/helpers/redirect-to-auth-page.d.ts.map +1 -0
  74. package/build/ts/auth/helpers/redirect-to-auth-page.js +33 -0
  75. package/build/ts/auth/helpers/redirect-to-auth-page.js.map +1 -0
  76. package/build/ts/auth/helpers/redirect-with-app-bridge-headers.d.ts +4 -0
  77. package/build/ts/auth/helpers/redirect-with-app-bridge-headers.d.ts.map +1 -0
  78. package/build/ts/auth/helpers/redirect-with-app-bridge-headers.js +24 -0
  79. package/build/ts/auth/helpers/redirect-with-app-bridge-headers.js.map +1 -0
  80. package/build/ts/auth/helpers/redirect-with-exitiframe.d.ts +3 -0
  81. package/build/ts/auth/helpers/redirect-with-exitiframe.d.ts.map +1 -0
  82. package/build/ts/auth/helpers/redirect-with-exitiframe.js +18 -0
  83. package/build/ts/auth/helpers/redirect-with-exitiframe.js.map +1 -0
  84. package/build/ts/auth/helpers/reject-bot-request.d.ts +3 -0
  85. package/build/ts/auth/helpers/reject-bot-request.d.ts.map +1 -0
  86. package/build/ts/auth/helpers/reject-bot-request.js +14 -0
  87. package/build/ts/auth/helpers/reject-bot-request.js.map +1 -0
  88. package/build/ts/auth/helpers/validate-session-token.d.ts +4 -0
  89. package/build/ts/auth/helpers/validate-session-token.d.ts.map +1 -0
  90. package/build/ts/auth/helpers/validate-session-token.js +36 -0
  91. package/build/ts/auth/helpers/validate-session-token.js.map +1 -0
  92. package/build/ts/auth/login/login.d.ts +3 -0
  93. package/build/ts/auth/login/login.d.ts.map +1 -0
  94. package/build/ts/auth/login/login.js +56 -0
  95. package/build/ts/auth/login/login.js.map +1 -0
  96. package/build/ts/auth/public/authenticate.d.ts +4 -0
  97. package/build/ts/auth/public/authenticate.d.ts.map +1 -0
  98. package/build/ts/auth/public/authenticate.js +35 -0
  99. package/build/ts/auth/public/authenticate.js.map +1 -0
  100. package/build/ts/auth/public/types.d.ts +27 -0
  101. package/build/ts/auth/public/types.d.ts.map +1 -0
  102. package/build/ts/auth/public/types.js +3 -0
  103. package/build/ts/auth/public/types.js.map +1 -0
  104. package/build/ts/auth/webhooks/authenticate.d.ts +5 -0
  105. package/build/ts/auth/webhooks/authenticate.d.ts.map +1 -0
  106. package/build/ts/auth/webhooks/authenticate.js +71 -0
  107. package/build/ts/auth/webhooks/authenticate.js.map +1 -0
  108. package/build/ts/auth/webhooks/index.d.ts +2 -0
  109. package/build/ts/auth/webhooks/index.d.ts.map +1 -0
  110. package/build/ts/auth/webhooks/index.js +6 -0
  111. package/build/ts/auth/webhooks/index.js.map +1 -0
  112. package/build/ts/auth/webhooks/register.d.ts +4 -0
  113. package/build/ts/auth/webhooks/register.d.ts.map +1 -0
  114. package/build/ts/auth/webhooks/register.js +39 -0
  115. package/build/ts/auth/webhooks/register.js.map +1 -0
  116. package/build/ts/auth/webhooks/types.d.ts +18 -0
  117. package/build/ts/auth/webhooks/types.d.ts.map +1 -0
  118. package/build/ts/auth/webhooks/types.js +3 -0
  119. package/build/ts/auth/webhooks/types.js.map +1 -0
  120. package/build/ts/billing/cancel.d.ts +5 -0
  121. package/build/ts/billing/cancel.d.ts.map +1 -0
  122. package/build/ts/billing/cancel.js +43 -0
  123. package/build/ts/billing/cancel.js.map +1 -0
  124. package/build/ts/billing/index.d.ts +4 -0
  125. package/build/ts/billing/index.d.ts.map +1 -0
  126. package/build/ts/billing/index.js +10 -0
  127. package/build/ts/billing/index.js.map +1 -0
  128. package/build/ts/billing/request.d.ts +6 -0
  129. package/build/ts/billing/request.d.ts.map +1 -0
  130. package/build/ts/billing/request.js +84 -0
  131. package/build/ts/billing/request.js.map +1 -0
  132. package/build/ts/billing/require.d.ts +6 -0
  133. package/build/ts/billing/require.d.ts.map +1 -0
  134. package/build/ts/billing/require.js +55 -0
  135. package/build/ts/billing/require.js.map +1 -0
  136. package/build/ts/billing/types.d.ts +228 -0
  137. package/build/ts/billing/types.d.ts.map +1 -0
  138. package/build/ts/billing/types.js +3 -0
  139. package/build/ts/billing/types.js.map +1 -0
  140. package/build/ts/config-types.d.ts +325 -0
  141. package/build/ts/config-types.d.ts.map +1 -0
  142. package/build/ts/config-types.js +3 -0
  143. package/build/ts/config-types.js.map +1 -0
  144. package/build/ts/index.d.ts +29 -0
  145. package/build/ts/index.d.ts.map +1 -0
  146. package/build/ts/index.js +108 -0
  147. package/build/ts/index.js.map +1 -0
  148. package/build/ts/override-logger.d.ts +3 -0
  149. package/build/ts/override-logger.d.ts.map +1 -0
  150. package/build/ts/override-logger.js +40 -0
  151. package/build/ts/override-logger.js.map +1 -0
  152. package/build/ts/types.d.ts +353 -0
  153. package/build/ts/types.d.ts.map +1 -0
  154. package/build/ts/types.js +17 -0
  155. package/build/ts/types.js.map +1 -0
  156. package/build/ts/version.d.ts +2 -0
  157. package/build/ts/version.d.ts.map +1 -0
  158. package/build/ts/version.js +5 -0
  159. package/build/ts/version.js.map +1 -0
  160. package/build/tsconfig.tsbuildinfo +1 -0
  161. package/package.json +65 -0
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.graphqlClientFactory = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var runtime_1 = require("@shopify/shopify-api/runtime");
6
+ var handle_client_error_1 = require("../helpers/handle-client-error");
7
+ // eslint-disable-next-line no-warning-comments
8
+ // TODO: This is actually just a call through to the Shopify API client, but with a different API. We should eventually
9
+ // move this over to the library layer. While doing that, we should also allow the apiVersion to be passed into the REST
10
+ // client request calls.
11
+ function graphqlClientFactory(_a) {
12
+ var params = _a.params, request = _a.request, session = _a.session;
13
+ return function query(query, options) {
14
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
15
+ var api, config, logger, client, apiResponse, error_1;
16
+ return tslib_1.__generator(this, function (_a) {
17
+ switch (_a.label) {
18
+ case 0:
19
+ api = params.api, config = params.config, logger = params.logger;
20
+ client = new api.clients.Graphql({
21
+ session: session,
22
+ apiVersion: options === null || options === void 0 ? void 0 : options.apiVersion,
23
+ });
24
+ _a.label = 1;
25
+ case 1:
26
+ _a.trys.push([1, 3, , 5]);
27
+ return [4 /*yield*/, client.query({
28
+ data: { query: query, variables: options === null || options === void 0 ? void 0 : options.variables },
29
+ tries: options === null || options === void 0 ? void 0 : options.tries,
30
+ extraHeaders: options === null || options === void 0 ? void 0 : options.headers,
31
+ })];
32
+ case 2:
33
+ apiResponse = _a.sent();
34
+ return [2 /*return*/, new Response(JSON.stringify(apiResponse.body), {
35
+ headers: (0, runtime_1.flatHeaders)(apiResponse.headers),
36
+ })];
37
+ case 3:
38
+ error_1 = _a.sent();
39
+ return [4 /*yield*/, (0, handle_client_error_1.handleClientError)({
40
+ params: { api: api, config: config, logger: logger },
41
+ request: request,
42
+ error: error_1,
43
+ shop: session.shop,
44
+ })];
45
+ case 4: throw _a.sent();
46
+ case 5: return [2 /*return*/];
47
+ }
48
+ });
49
+ });
50
+ };
51
+ }
52
+ exports.graphqlClientFactory = graphqlClientFactory;
53
+ //# sourceMappingURL=graphql-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-client.js","sourceRoot":"","sources":["../../../../src/auth/admin/graphql-client.ts"],"names":[],"mappings":";;;;AACA,wDAAyD;AAGzD,sEAAiE;AAwBjE,+CAA+C;AAC/C,uHAAuH;AACvH,wHAAwH;AACxH,wBAAwB;AACxB,SAAgB,oBAAoB,CAAC,EAIZ;QAHvB,MAAM,YAAA,EACN,OAAO,aAAA,EACP,OAAO,aAAA;IAEP,OAAO,SAAe,KAAK,CAAC,KAAa,EAAE,OAAsB;;;;;;wBACxD,GAAG,GAAoB,MAAM,IAA1B,EAAE,MAAM,GAAY,MAAM,OAAlB,EAAE,MAAM,GAAI,MAAM,OAAV,CAAW;wBAE/B,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;4BACrC,OAAO,SAAA;4BACP,UAAU,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;yBAChC,CAAC,CAAC;;;;wBAImB,qBAAM,MAAM,CAAC,KAAK,CAAC;gCACrC,IAAI,EAAE,EAAC,KAAK,OAAA,EAAE,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAC;gCAC5C,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK;gCACrB,YAAY,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO;6BAC/B,CAAC,EAAA;;wBAJI,WAAW,GAAG,SAIlB;wBAEF,sBAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;gCACpD,OAAO,EAAE,IAAA,qBAAW,EAAC,WAAW,CAAC,OAAO,CAAC;6BAC1C,CAAC,EAAC;;;wBAEG,qBAAM,IAAA,uCAAiB,EAAC;gCAC5B,MAAM,EAAE,EAAC,GAAG,KAAA,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAC;gCAC7B,OAAO,SAAA;gCACP,KAAK,SAAA;gCACL,IAAI,EAAE,OAAO,CAAC,IAAI;6BACnB,CAAC,EAAA;4BALF,MAAM,SAKJ,CAAC;;;;;KAEN,CAAC;AACJ,CAAC;AAjCD,oDAiCC"}
@@ -0,0 +1,34 @@
1
+ import { DeleteRequestParams, GetRequestParams, PostRequestParams, PutRequestParams, RequestParams, Session, Shopify, ShopifyRestResources } from '@shopify/shopify-api';
2
+ import type { BasicParams } from '../../types';
3
+ interface RestClientOptions {
4
+ params: BasicParams;
5
+ request: Request;
6
+ session: Session;
7
+ }
8
+ export declare class RemixRestClient<Resources extends ShopifyRestResources> {
9
+ session: Session;
10
+ resources: Resources;
11
+ private params;
12
+ private request;
13
+ constructor({ params, request, session }: RestClientOptions);
14
+ /**
15
+ * Performs a GET request on the given path.
16
+ */
17
+ get(params: GetRequestParams): Promise<Response>;
18
+ /**
19
+ * Performs a POST request on the given path.
20
+ */
21
+ post(params: PostRequestParams): Promise<Response>;
22
+ /**
23
+ * Performs a PUT request on the given path.
24
+ */
25
+ put(params: PutRequestParams): Promise<Response>;
26
+ /**
27
+ * Performs a DELETE request on the given path.
28
+ */
29
+ delete(params: DeleteRequestParams): Promise<Response>;
30
+ protected makeRequest(params: RequestParams): Promise<Response>;
31
+ }
32
+ export declare function restResourceClientFactory({ params, request, session, }: RestClientOptions): Shopify['clients']['Rest'];
33
+ export {};
34
+ //# sourceMappingURL=rest-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-client.d.ts","sourceRoot":"","sources":["../../../../src/auth/admin/rest-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,OAAO,EACP,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAG7C,UAAU,iBAAiB;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,eAAe,CAAC,SAAS,SAAS,oBAAoB;IAC1D,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IAC5B,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAAU;gBAEb,EAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAC,EAAE,iBAAiB;IAMzD;;OAEG;IACU,GAAG,CAAC,MAAM,EAAE,gBAAgB;IAOzC;;OAEG;IACU,IAAI,CAAC,MAAM,EAAE,iBAAiB;IAO3C;;OAEG;IACU,GAAG,CAAC,MAAM,EAAE,gBAAgB;IAOzC;;OAEG;IACU,MAAM,CAAC,MAAM,EAAE,mBAAmB;cAO/B,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;CAuBtE;AAED,wBAAgB,yBAAyB,CAAC,EACxC,MAAM,EACN,OAAO,EACP,OAAO,GACR,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAuBhD"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restResourceClientFactory = exports.RemixRestClient = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var helpers_1 = require("../helpers");
6
+ var RemixRestClient = /** @class */ (function () {
7
+ function RemixRestClient(_a) {
8
+ var params = _a.params, request = _a.request, session = _a.session;
9
+ this.params = params;
10
+ this.request = request;
11
+ this.session = session;
12
+ }
13
+ /**
14
+ * Performs a GET request on the given path.
15
+ */
16
+ RemixRestClient.prototype.get = function (params) {
17
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
18
+ return tslib_1.__generator(this, function (_a) {
19
+ return [2 /*return*/, this.makeRequest(tslib_1.__assign({ method: 'GET' }, params))];
20
+ });
21
+ });
22
+ };
23
+ /**
24
+ * Performs a POST request on the given path.
25
+ */
26
+ RemixRestClient.prototype.post = function (params) {
27
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
28
+ return tslib_1.__generator(this, function (_a) {
29
+ return [2 /*return*/, this.makeRequest(tslib_1.__assign({ method: 'POST' }, params))];
30
+ });
31
+ });
32
+ };
33
+ /**
34
+ * Performs a PUT request on the given path.
35
+ */
36
+ RemixRestClient.prototype.put = function (params) {
37
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
38
+ return tslib_1.__generator(this, function (_a) {
39
+ return [2 /*return*/, this.makeRequest(tslib_1.__assign({ method: 'PUT' }, params))];
40
+ });
41
+ });
42
+ };
43
+ /**
44
+ * Performs a DELETE request on the given path.
45
+ */
46
+ RemixRestClient.prototype.delete = function (params) {
47
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
48
+ return tslib_1.__generator(this, function (_a) {
49
+ return [2 /*return*/, this.makeRequest(tslib_1.__assign({ method: 'DELETE' }, params))];
50
+ });
51
+ });
52
+ };
53
+ RemixRestClient.prototype.makeRequest = function (params) {
54
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
55
+ var originalClient, originalRequest, apiResponse, error_1;
56
+ return tslib_1.__generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0:
59
+ originalClient = new this.params.api.clients.Rest({
60
+ session: this.session,
61
+ });
62
+ originalRequest = Reflect.get(originalClient, 'request');
63
+ _a.label = 1;
64
+ case 1:
65
+ _a.trys.push([1, 3, , 5]);
66
+ return [4 /*yield*/, originalRequest.call(originalClient, params)];
67
+ case 2:
68
+ apiResponse = _a.sent();
69
+ // We use a separate client for REST requests and REST resources because we want to override the API library
70
+ // client class to return a Response object instead.
71
+ return [2 /*return*/, new Response(JSON.stringify(apiResponse.body), {
72
+ headers: apiResponse.headers,
73
+ })];
74
+ case 3:
75
+ error_1 = _a.sent();
76
+ return [4 /*yield*/, (0, helpers_1.handleClientError)({
77
+ params: this.params,
78
+ request: this.request,
79
+ shop: this.session.shop,
80
+ error: error_1,
81
+ })];
82
+ case 4: throw _a.sent();
83
+ case 5: return [2 /*return*/];
84
+ }
85
+ });
86
+ });
87
+ };
88
+ return RemixRestClient;
89
+ }());
90
+ exports.RemixRestClient = RemixRestClient;
91
+ function restResourceClientFactory(_a) {
92
+ var params = _a.params, request = _a.request, session = _a.session;
93
+ var api = params.api, config = params.config, logger = params.logger;
94
+ var ApiClient = api.clients.Rest;
95
+ return /** @class */ (function (_super) {
96
+ tslib_1.__extends(RestResourceClient, _super);
97
+ function RestResourceClient() {
98
+ return _super !== null && _super.apply(this, arguments) || this;
99
+ }
100
+ RestResourceClient.prototype.request = function (params) {
101
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
102
+ var originalClient, originalRequest, error_2;
103
+ return tslib_1.__generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0:
106
+ originalClient = new api.clients.Rest({ session: session });
107
+ originalRequest = Reflect.get(originalClient, 'request');
108
+ _a.label = 1;
109
+ case 1:
110
+ _a.trys.push([1, 3, , 5]);
111
+ return [4 /*yield*/, originalRequest.call(originalClient, params)];
112
+ case 2:
113
+ // We just call through to the API library client, and handle the error response here, so that data parsing
114
+ // behaves the same way.
115
+ return [2 /*return*/, _a.sent()];
116
+ case 3:
117
+ error_2 = _a.sent();
118
+ return [4 /*yield*/, (0, helpers_1.handleClientError)({
119
+ params: { api: api, config: config, logger: logger },
120
+ request: request,
121
+ shop: session.shop,
122
+ error: error_2,
123
+ })];
124
+ case 4: throw _a.sent();
125
+ case 5: return [2 /*return*/];
126
+ }
127
+ });
128
+ });
129
+ };
130
+ return RestResourceClient;
131
+ }(ApiClient));
132
+ }
133
+ exports.restResourceClientFactory = restResourceClientFactory;
134
+ //# sourceMappingURL=rest-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest-client.js","sourceRoot":"","sources":["../../../../src/auth/admin/rest-client.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,100 @@
1
+ import { JwtPayload, Session, ShopifyRestResources } from '@shopify/shopify-api';
2
+ import type { AdminApiContext, AppConfigArg } from '../../config-types';
3
+ import type { BillingContext } from '../../billing/types';
4
+ interface AdminContextInternal<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> {
5
+ /**
6
+ * The session for the user who made the request.
7
+ *
8
+ * This comes from the session storage which `shopifyApp` uses to store sessions in your database of choice. If you did not provide a session storage adaptor `shopifyApp` uses `SQLiteSessionStorage`
9
+ *
10
+ * Use this to get shop or user specific data.
11
+ *
12
+ * @example
13
+ * Getting your app's shop specific widget data using an offline session
14
+ * ```ts
15
+ * // app/routes/**\/.ts
16
+ * import { LoaderArgs, json } from "@remix-run/node";
17
+ * import { shopify } from "../shopify.server";
18
+ * import { getWidgets } from "~/db/widgets.server";
19
+ *
20
+ * export const loader = async ({ request }: LoaderArgs) => {
21
+ * const { session } = await shopify.authenticate.admin(
22
+ * request
23
+ * );
24
+ * return json(await getWidgets({shop: session.shop));
25
+ * };
26
+ * ```
27
+ *
28
+ * @example
29
+ * Getting your app's user specific widget data using an online session
30
+ * ```ts
31
+ * // shopify.server.ts
32
+ * import { shopifyApp } from "@shopify/shopify-app-remix";
33
+ *
34
+ * export const shopify = shopifyApp({
35
+ * // ...etc
36
+ * useOnlineTokens: true,
37
+ * });
38
+ *
39
+ * // app/routes/**\/.ts
40
+ * import { LoaderArgs, json } from "@remix-run/node";
41
+ * import { shopify } from "../shopify.server";
42
+ * import { getWidgets } from "~/db/widgets.server";
43
+ *
44
+ * export const loader = async ({ request }: LoaderArgs) => {
45
+ * const { session } = await shopify.authenticate.admin(
46
+ * request
47
+ * );
48
+ * return json(await getWidgets({user: session.onlineAccessInfo!.id}));
49
+ * };
50
+ * ```
51
+ */
52
+ session: Session;
53
+ /**
54
+ * Methods for interacting with the Shopify GraphQL / REST Admin APIs for the store that made the request
55
+ */
56
+ admin: AdminApiContext<Resources>;
57
+ /**
58
+ * Billing methods for this store, based on the plans defined in the `billing` config option.
59
+ *
60
+ * {@link https://shopify.dev/docs/apps/billing}
61
+ */
62
+ billing: BillingContext<Config>;
63
+ }
64
+ export interface EmbeddedAdminContext<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> extends AdminContextInternal<Config, Resources> {
65
+ /**
66
+ * The decoded and validated session token for the request
67
+ *
68
+ * {@link https://shopify.dev/docs/apps/auth/oauth/session-tokens#payload}
69
+ *
70
+ * @example
71
+ * Getting your app's user specific widget data using the session token
72
+ * ```ts
73
+ * // shopify.server.ts
74
+ * import { shopifyApp } from "@shopify/shopify-app-remix";
75
+ *
76
+ * export const shopify = shopifyApp({
77
+ * // ...etc
78
+ * useOnlineTokens: true,
79
+ * });
80
+ *
81
+ * // app/routes/**\/.ts
82
+ * import { LoaderArgs, json } from "@remix-run/node";
83
+ * import { shopify } from "../shopify.server";
84
+ * import { getWidgets } from "~/db/widgets.server";
85
+ *
86
+ * export const loader = async ({ request }: LoaderArgs) => {
87
+ * const { sessionToken } = await shopify.authenticate.public(
88
+ * request
89
+ * );
90
+ * return json(await getWidgets({user: sessionToken.sub}));
91
+ * };
92
+ * ```
93
+ */
94
+ sessionToken: JwtPayload;
95
+ }
96
+ export interface NonEmbeddedAdminContext<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> extends AdminContextInternal<Config, Resources> {
97
+ }
98
+ export type AdminContext<Config extends AppConfigArg, Resources extends ShopifyRestResources = ShopifyRestResources> = Config['isEmbeddedApp'] extends false ? NonEmbeddedAdminContext<Config, Resources> : EmbeddedAdminContext<Config, Resources>;
99
+ export {};
100
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/auth/admin/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,OAAO,EAAE,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AAE/E,OAAO,KAAK,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAExD,UAAU,oBAAoB,CAC5B,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB;IAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAClC;;;;OAIG;IACH,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB,CACnC,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,CAC7D,SAAQ,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC;IAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,YAAY,EAAE,UAAU,CAAC;CAC1B;AACD,MAAM,WAAW,uBAAuB,CACtC,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,CAC7D,SAAQ,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC;CAAG;AAEpD,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,YAAY,EAC3B,SAAS,SAAS,oBAAoB,GAAG,oBAAoB,IAC3D,MAAM,CAAC,eAAe,CAAC,SAAS,KAAK,GACrC,uBAAuB,CAAC,MAAM,EAAE,SAAS,CAAC,GAC1C,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/auth/admin/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ export declare const APP_BRIDGE_NEXT_URL = "https://cdn.shopify.com/shopifycloud/app-bridge-next.js";
2
+ export declare const REAUTH_URL_HEADER = "X-Shopify-API-Request-Failure-Reauthorize-Url";
3
+ export declare const APP_BRIDGE_HEADERS: {
4
+ 'Access-Control-Allow-Origin': string;
5
+ 'Access-Control-Allow-Headers': string;
6
+ 'Access-Control-Expose-Headers': string;
7
+ };
8
+ export declare const DEFAULT_CSP_VALUE = "frame-ancestors https://*.myshopify.com https://admin.shopify.com;";
9
+ //# sourceMappingURL=const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/auth/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,4DAC2B,CAAC;AAE5D,eAAO,MAAM,iBAAiB,kDACmB,CAAC;AAElD,eAAO,MAAM,kBAAkB;;;;CAI9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,uEAAuE,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CSP_VALUE = exports.APP_BRIDGE_HEADERS = exports.REAUTH_URL_HEADER = exports.APP_BRIDGE_NEXT_URL = void 0;
4
+ exports.APP_BRIDGE_NEXT_URL = 'https://cdn.shopify.com/shopifycloud/app-bridge-next.js';
5
+ exports.REAUTH_URL_HEADER = 'X-Shopify-API-Request-Failure-Reauthorize-Url';
6
+ exports.APP_BRIDGE_HEADERS = {
7
+ 'Access-Control-Allow-Origin': '*',
8
+ 'Access-Control-Allow-Headers': 'Authorization',
9
+ 'Access-Control-Expose-Headers': exports.REAUTH_URL_HEADER,
10
+ };
11
+ exports.DEFAULT_CSP_VALUE = "frame-ancestors https://*.myshopify.com https://admin.shopify.com;";
12
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/auth/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAC9B,yDAAyD,CAAC;AAE/C,QAAA,iBAAiB,GAC5B,+CAA+C,CAAC;AAErC,QAAA,kBAAkB,GAAG;IAChC,6BAA6B,EAAE,GAAG;IAClC,8BAA8B,EAAE,eAAe;IAC/C,+BAA+B,EAAE,yBAAiB;CACnD,CAAC;AAEW,QAAA,iBAAiB,GAAG,oEAAoE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { BasicParams } from '../../types';
2
+ export declare function addResponseHeadersFactory(params: BasicParams): (request: Request, headers: Headers) => void;
3
+ export declare function addResponseHeaders(headers: Headers, isEmbeddedApp: boolean, shop: string | null | undefined): void;
4
+ export declare function installGlobalResponseHeaders(isEmbeddedApp: boolean): void;
5
+ //# sourceMappingURL=add-response-headers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-response-headers.d.ts","sourceRoot":"","sources":["../../../../src/auth/helpers/add-response-headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAS7C,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,aAGjC,OAAO,WAAW,OAAO,UAMpD;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,QAQhC;AAED,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,OAAO,QAkDlE"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installGlobalResponseHeaders = exports.addResponseHeaders = exports.addResponseHeadersFactory = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var const_1 = require("../const");
6
+ var ORIGINAL_HEADERS = Symbol.for('originalHeaders');
7
+ function addResponseHeadersFactory(params) {
8
+ var api = params.api, config = params.config;
9
+ return function (request, headers) {
10
+ var searchParams = new URL(request.url).searchParams;
11
+ var shop = api.utils.sanitizeShop(searchParams.get('shop'));
12
+ addResponseHeaders(headers, config.isEmbeddedApp, shop);
13
+ };
14
+ }
15
+ exports.addResponseHeadersFactory = addResponseHeadersFactory;
16
+ function addResponseHeaders(headers, isEmbeddedApp, shop) {
17
+ if (isEmbeddedApp && shop) {
18
+ // Set or update the CSP with the shop subdomain instead of a wildcard:
19
+ var csp = headers.get('Content-Security-Policy') || const_1.DEFAULT_CSP_VALUE;
20
+ if (shop)
21
+ csp = csp.replace('*.myshopify.com', shop);
22
+ headers.set('Content-Security-Policy', csp);
23
+ }
24
+ }
25
+ exports.addResponseHeaders = addResponseHeaders;
26
+ function installGlobalResponseHeaders(isEmbeddedApp) {
27
+ var headersDescriptor = Object.getOwnPropertyDescriptor(Response.prototype, ORIGINAL_HEADERS) ||
28
+ Object.getOwnPropertyDescriptor(Response.prototype, 'headers');
29
+ // Store the original Response.prototype.headers descriptor so we can use it when live-reloading the server:
30
+ Object.defineProperty(Response.prototype, ORIGINAL_HEADERS, headersDescriptor);
31
+ // Overwrite the Response.prototype.headers getter with one that injects our global headers:
32
+ Object.defineProperty(Response.prototype, 'headers', tslib_1.__assign(tslib_1.__assign({}, headersDescriptor), { get: function () {
33
+ // Note: this is not an empty Headers, it will contain any headers passed to new Response():
34
+ var headers = headersDescriptor.get.call(this);
35
+ try {
36
+ // Inject CORS headers required by both Embedded Apps and UI Extensions:
37
+ if (isEmbeddedApp) {
38
+ for (var key in const_1.APP_BRIDGE_HEADERS) {
39
+ if (!headers.get(key)) {
40
+ var value = const_1.APP_BRIDGE_HEADERS[key];
41
+ headers.set(key, value);
42
+ }
43
+ }
44
+ }
45
+ // Apply a default CSP unless a more specific one (no wildcard) is present:
46
+ if (!headers.get('Content-Security-Policy')) {
47
+ headers.set('Content-Security-Policy', isEmbeddedApp ? const_1.DEFAULT_CSP_VALUE : "frame-ancestors 'none';");
48
+ }
49
+ if (!headers.get('Link')) {
50
+ headers.set('Link', "<".concat(const_1.APP_BRIDGE_NEXT_URL, ">; rel=\"preload\""));
51
+ }
52
+ }
53
+ catch (err) {
54
+ // Do nothing, this is not a standard Response object.
55
+ }
56
+ return headers;
57
+ } }));
58
+ }
59
+ exports.installGlobalResponseHeaders = installGlobalResponseHeaders;
60
+ //# sourceMappingURL=add-response-headers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-response-headers.js","sourceRoot":"","sources":["../../../../src/auth/helpers/add-response-headers.ts"],"names":[],"mappings":";;;;AACA,kCAIkB;AAElB,IAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAEvD,SAAgB,yBAAyB,CAAC,MAAmB;IACpD,IAAA,GAAG,GAAY,MAAM,IAAlB,EAAE,MAAM,GAAI,MAAM,OAAV,CAAW;IAE7B,OAAO,UAAU,OAAgB,EAAE,OAAgB;QAC1C,IAAA,YAAY,GAAI,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAxB,CAAyB;QAC5C,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC,CAAC;QAE/D,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC;AATD,8DASC;AAED,SAAgB,kBAAkB,CAChC,OAAgB,EAChB,aAAsB,EACtB,IAA+B;IAE/B,IAAI,aAAa,IAAI,IAAI,EAAE;QACzB,uEAAuE;QACvE,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,yBAAiB,CAAC;QACtE,IAAI,IAAI;YAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;KAC7C;AACH,CAAC;AAXD,gDAWC;AAED,SAAgB,4BAA4B,CAAC,aAAsB;IACjE,IAAM,iBAAiB,GACrB,MAAM,CAAC,wBAAwB,CAAC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;QACrE,MAAM,CAAC,wBAAwB,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAE,CAAC;IAElE,4GAA4G;IAC5G,MAAM,CAAC,cAAc,CACnB,QAAQ,CAAC,SAAS,EAClB,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;IAEF,4FAA4F;IAC5F,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,wCAC9C,iBAAiB,KACpB,GAAG;YACD,4FAA4F;YAC5F,IAAM,OAAO,GAAG,iBAAiB,CAAC,GAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAElD,IAAI;gBACF,wEAAwE;gBACxE,IAAI,aAAa,EAAE;oBACjB,KAAK,IAAM,GAAG,IAAI,0BAAkB,EAAE;wBACpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;4BACrB,IAAM,KAAK,GACT,0BAAkB,CAAC,GAAsC,CAAC,CAAC;4BAE7D,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;yBACzB;qBACF;iBACF;gBAED,2EAA2E;gBAC3E,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE;oBAC3C,OAAO,CAAC,GAAG,CACT,yBAAyB,EACzB,aAAa,CAAC,CAAC,CAAC,yBAAiB,CAAC,CAAC,CAAC,yBAAyB,CAC9D,CAAC;iBACH;gBAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACxB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAI,2BAAmB,uBAAkB,CAAC,CAAC;iBAChE;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,sDAAsD;aACvD;YAED,OAAO,OAAO,CAAC;QACjB,CAAC,IACD,CAAC;AACL,CAAC;AAlDD,oEAkDC"}
@@ -0,0 +1,3 @@
1
+ import type { BasicParams } from '../../types';
2
+ export declare function beginAuth(params: BasicParams, request: Request, isOnline: boolean, shop: string): Promise<never>;
3
+ //# sourceMappingURL=begin-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"begin-auth.d.ts","sourceRoot":"","sources":["../../../../src/auth/helpers/begin-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAE7C,wBAAsB,SAAS,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,KAAK,CAAC,CAShB"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.beginAuth = void 0;
4
+ var tslib_1 = require("tslib");
5
+ function beginAuth(params, request, isOnline, shop) {
6
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
7
+ var api, config;
8
+ return tslib_1.__generator(this, function (_a) {
9
+ switch (_a.label) {
10
+ case 0:
11
+ api = params.api, config = params.config;
12
+ return [4 /*yield*/, api.auth.begin({
13
+ shop: shop,
14
+ callbackPath: config.auth.callbackPath,
15
+ isOnline: isOnline,
16
+ rawRequest: request,
17
+ })];
18
+ case 1: throw _a.sent();
19
+ }
20
+ });
21
+ });
22
+ }
23
+ exports.beginAuth = beginAuth;
24
+ //# sourceMappingURL=begin-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"begin-auth.js","sourceRoot":"","sources":["../../../../src/auth/helpers/begin-auth.ts"],"names":[],"mappings":";;;;AAEA,SAAsB,SAAS,CAC7B,MAAmB,EACnB,OAAgB,EAChB,QAAiB,EACjB,IAAY;;;;;;oBAEL,GAAG,GAAY,MAAM,IAAlB,EAAE,MAAM,GAAI,MAAM,OAAV,CAAW;oBAEvB,qBAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;4BACzB,IAAI,MAAA;4BACJ,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY;4BACtC,QAAQ,UAAA;4BACR,UAAU,EAAE,OAAO;yBACpB,CAAC,EAAA;wBALF,MAAM,SAKJ,CAAC;;;;CACJ;AAdD,8BAcC"}
@@ -0,0 +1,2 @@
1
+ export declare function getSessionTokenHeader(request: Request): string | undefined;
2
+ //# sourceMappingURL=get-session-token-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-session-token-header.d.ts","sourceRoot":"","sources":["../../../../src/auth/helpers/get-session-token-header.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE1E"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSessionTokenHeader = void 0;
4
+ function getSessionTokenHeader(request) {
5
+ var _a;
6
+ return (_a = request.headers.get('authorization')) === null || _a === void 0 ? void 0 : _a.replace('Bearer ', '');
7
+ }
8
+ exports.getSessionTokenHeader = getSessionTokenHeader;
9
+ //# sourceMappingURL=get-session-token-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-session-token-header.js","sourceRoot":"","sources":["../../../../src/auth/helpers/get-session-token-header.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qBAAqB,CAAC,OAAgB;;IACpD,OAAO,MAAA,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,0CAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACtE,CAAC;AAFD,sDAEC"}
@@ -0,0 +1,11 @@
1
+ import { HttpResponseError } from '@shopify/shopify-api';
2
+ import type { BasicParams } from '../../types';
3
+ interface HandleClientErrorOptions {
4
+ params: BasicParams;
5
+ request: Request;
6
+ error: Error | HttpResponseError;
7
+ shop: string;
8
+ }
9
+ export declare function handleClientError({ params, request, error, shop, }: HandleClientErrorOptions): Promise<never>;
10
+ export {};
11
+ //# sourceMappingURL=handle-client-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-client-error.d.ts","sourceRoot":"","sources":["../../../../src/auth/helpers/handle-client-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAI7C,UAAU,wBAAwB;IAChC,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,iBAAiB,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,iBAAiB,CAAC,EACtC,MAAM,EACN,OAAO,EACP,KAAK,EACL,IAAI,GACL,EAAE,wBAAwB,GAAG,OAAO,CAAC,KAAK,CAAC,CA0B3C"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleClientError = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var shopify_api_1 = require("@shopify/shopify-api");
6
+ var redirect_to_auth_page_1 = require("./redirect-to-auth-page");
7
+ function handleClientError(_a) {
8
+ var params = _a.params, request = _a.request, error = _a.error, shop = _a.shop;
9
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
10
+ return tslib_1.__generator(this, function (_b) {
11
+ switch (_b.label) {
12
+ case 0:
13
+ if (!(error instanceof shopify_api_1.HttpResponseError)) return [3 /*break*/, 4];
14
+ params.logger.debug("Got an HTTP response error from the API: ".concat(error.message), {
15
+ code: error.response.code,
16
+ statusText: error.response.statusText,
17
+ body: JSON.stringify(error.response.body),
18
+ });
19
+ if (!(error.response.code === 401)) return [3 /*break*/, 2];
20
+ return [4 /*yield*/, (0, redirect_to_auth_page_1.redirectToAuthPage)(params, request, shop)];
21
+ case 1: throw _b.sent();
22
+ case 2:
23
+ // forward a minimal copy of the upstream HTTP response instead of an Error:
24
+ throw new Response(JSON.stringify(error.response.body), {
25
+ status: error.response.code,
26
+ headers: {
27
+ 'Content-Type': error.response.headers['Content-Type'],
28
+ },
29
+ });
30
+ case 3: return [3 /*break*/, 5];
31
+ case 4:
32
+ params.logger.debug("Got a response error from the API: ".concat(error.message));
33
+ throw error;
34
+ case 5: return [2 /*return*/];
35
+ }
36
+ });
37
+ });
38
+ }
39
+ exports.handleClientError = handleClientError;
40
+ //# sourceMappingURL=handle-client-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-client-error.js","sourceRoot":"","sources":["../../../../src/auth/helpers/handle-client-error.ts"],"names":[],"mappings":";;;;AAAA,oDAAuD;AAIvD,iEAA2D;AAS3D,SAAsB,iBAAiB,CAAC,EAKb;QAJzB,MAAM,YAAA,EACN,OAAO,aAAA,EACP,KAAK,WAAA,EACL,IAAI,UAAA;;;;;yBAEA,CAAA,KAAK,YAAY,+BAAiB,CAAA,EAAlC,wBAAkC;oBACpC,MAAM,CAAC,MAAM,CAAC,KAAK,CACjB,mDAA4C,KAAK,CAAC,OAAO,CAAE,EAC3D;wBACE,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;wBACzB,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU;wBACrC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;qBAC1C,CACF,CAAC;yBAEE,CAAA,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,GAAG,CAAA,EAA3B,wBAA2B;oBACvB,qBAAM,IAAA,0CAAkB,EAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAA;wBAArD,MAAM,SAA+C,CAAC;;gBAEtD,4EAA4E;gBAC5E,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;oBACtD,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;oBAC3B,OAAO,EAAE;wBACP,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAQ,CAAC,cAAc,CAAW;qBAClE;iBACF,CAAC,CAAC;;;oBAGL,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,6CAAsC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC;oBAC3E,MAAM,KAAK,CAAC;;;;;CAEf;AA/BD,8CA+BC"}
@@ -0,0 +1,8 @@
1
+ export { redirectToAuthPage } from './redirect-to-auth-page';
2
+ export { redirectWithExitIframe } from './redirect-with-exitiframe';
3
+ export { beginAuth } from './begin-auth';
4
+ export { validateSessionToken } from './validate-session-token';
5
+ export { getSessionTokenHeader } from './get-session-token-header';
6
+ export { rejectBotRequest } from './reject-bot-request';
7
+ export { handleClientError } from './handle-client-error';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleClientError = exports.rejectBotRequest = exports.getSessionTokenHeader = exports.validateSessionToken = exports.beginAuth = exports.redirectWithExitIframe = exports.redirectToAuthPage = void 0;
4
+ var redirect_to_auth_page_1 = require("./redirect-to-auth-page");
5
+ Object.defineProperty(exports, "redirectToAuthPage", { enumerable: true, get: function () { return redirect_to_auth_page_1.redirectToAuthPage; } });
6
+ var redirect_with_exitiframe_1 = require("./redirect-with-exitiframe");
7
+ Object.defineProperty(exports, "redirectWithExitIframe", { enumerable: true, get: function () { return redirect_with_exitiframe_1.redirectWithExitIframe; } });
8
+ var begin_auth_1 = require("./begin-auth");
9
+ Object.defineProperty(exports, "beginAuth", { enumerable: true, get: function () { return begin_auth_1.beginAuth; } });
10
+ var validate_session_token_1 = require("./validate-session-token");
11
+ Object.defineProperty(exports, "validateSessionToken", { enumerable: true, get: function () { return validate_session_token_1.validateSessionToken; } });
12
+ var get_session_token_header_1 = require("./get-session-token-header");
13
+ Object.defineProperty(exports, "getSessionTokenHeader", { enumerable: true, get: function () { return get_session_token_header_1.getSessionTokenHeader; } });
14
+ var reject_bot_request_1 = require("./reject-bot-request");
15
+ Object.defineProperty(exports, "rejectBotRequest", { enumerable: true, get: function () { return reject_bot_request_1.rejectBotRequest; } });
16
+ var handle_client_error_1 = require("./handle-client-error");
17
+ Object.defineProperty(exports, "handleClientError", { enumerable: true, get: function () { return handle_client_error_1.handleClientError; } });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/auth/helpers/index.ts"],"names":[],"mappings":";;;AAAA,iEAA2D;AAAnD,2HAAA,kBAAkB,OAAA;AAC1B,uEAAkE;AAA1D,kIAAA,sBAAsB,OAAA;AAC9B,2CAAuC;AAA/B,uGAAA,SAAS,OAAA;AACjB,mEAA8D;AAAtD,8HAAA,oBAAoB,OAAA;AAC5B,uEAAiE;AAAzD,iIAAA,qBAAqB,OAAA;AAC7B,2DAAsD;AAA9C,sHAAA,gBAAgB,OAAA;AACxB,6DAAwD;AAAhD,wHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,3 @@
1
+ import type { BasicParams } from '../../types';
2
+ export declare function redirectToAuthPage(params: BasicParams, request: Request, shop: string, isOnline?: boolean): Promise<never>;
3
+ //# sourceMappingURL=redirect-to-auth-page.d.ts.map