@shopify/shopify-api 1.4.0 → 2.0.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 (60) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +3 -0
  3. package/dist/auth/oauth/oauth.d.ts +4 -2
  4. package/dist/auth/oauth/oauth.d.ts.map +1 -1
  5. package/dist/auth/oauth/oauth.js +34 -38
  6. package/dist/auth/oauth/types.d.ts +1 -0
  7. package/dist/auth/oauth/types.d.ts.map +1 -1
  8. package/dist/auth/scopes/index.d.ts +3 -3
  9. package/dist/auth/scopes/index.d.ts.map +1 -1
  10. package/dist/auth/scopes/index.js +5 -3
  11. package/dist/auth/session/index.d.ts +1 -1
  12. package/dist/auth/session/index.d.ts.map +1 -1
  13. package/dist/auth/session/session.d.ts +4 -4
  14. package/dist/auth/session/session.d.ts.map +1 -1
  15. package/dist/auth/session/session.js +8 -6
  16. package/dist/auth/session/storage/custom.d.ts.map +1 -1
  17. package/dist/auth/session/storage/custom.js +1 -1
  18. package/dist/auth/session/storage/memory.d.ts.map +1 -1
  19. package/dist/auth/session/types.d.ts +2 -2
  20. package/dist/auth/session/types.d.ts.map +1 -1
  21. package/dist/base_types.d.ts +1 -0
  22. package/dist/base_types.d.ts.map +1 -1
  23. package/dist/base_types.js +1 -0
  24. package/dist/clients/graphql/graphql_client.d.ts.map +1 -1
  25. package/dist/clients/graphql/graphql_client.js +3 -1
  26. package/dist/clients/graphql/index.d.ts +1 -1
  27. package/dist/clients/graphql/index.d.ts.map +1 -1
  28. package/dist/clients/graphql/storefront_client.js +3 -1
  29. package/dist/clients/http_client/http_client.d.ts.map +1 -1
  30. package/dist/clients/http_client/http_client.js +25 -9
  31. package/dist/clients/http_client/types.d.ts.map +1 -1
  32. package/dist/clients/rest/rest_client.d.ts.map +1 -1
  33. package/dist/clients/rest/rest_client.js +6 -2
  34. package/dist/context.d.ts.map +1 -1
  35. package/dist/context.js +2 -1
  36. package/dist/error.d.ts.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/utils/decode-session-token.d.ts +1 -1
  39. package/dist/utils/decode-session-token.d.ts.map +1 -1
  40. package/dist/utils/decode-session-token.js +5 -1
  41. package/dist/utils/delete-current-session.d.ts.map +1 -1
  42. package/dist/utils/delete-offline-session.d.ts.map +1 -1
  43. package/dist/utils/graphql_proxy.d.ts.map +1 -1
  44. package/dist/utils/hmac-validator.d.ts +1 -1
  45. package/dist/utils/hmac-validator.d.ts.map +1 -1
  46. package/dist/utils/hmac-validator.js +8 -4
  47. package/dist/utils/load-current-session.d.ts.map +1 -1
  48. package/dist/utils/load-offline-session.d.ts.map +1 -1
  49. package/dist/utils/load-offline-session.js +4 -1
  50. package/dist/utils/version-compatible.d.ts.map +1 -1
  51. package/dist/utils/version-compatible.js +5 -2
  52. package/dist/utils/with-session.d.ts.map +1 -1
  53. package/dist/version.d.ts +1 -1
  54. package/dist/version.js +1 -1
  55. package/dist/webhooks/registry.d.ts +37 -3
  56. package/dist/webhooks/registry.d.ts.map +1 -1
  57. package/dist/webhooks/registry.js +107 -24
  58. package/dist/webhooks/types.d.ts +9 -4
  59. package/dist/webhooks/types.d.ts.map +1 -1
  60. package/package.json +5 -2
package/CHANGELOG.md CHANGED
@@ -7,27 +7,63 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## [2.0.0] - 2021-10-28
11
+
12
+ ### Added
13
+
14
+ - Add a 5 second `clockTolerance` to fix `jwt not active` error [#227](https://github.com/Shopify/shopify-node-api/pull/227)
15
+ - [Breaking] Change default for OAuth.beginAuth to online sessions [#203](https://github.com/Shopify/shopify-node-api/pull/203)
16
+ - see [oauth.md](https://github.com/Shopify/shopify-node-api/blob/main/docs/usage/oauth.md) for updated docs
17
+ - [Breaking] Return and delete session in `validateAuthCallback` [#217](https://github.com/Shopify/shopify-node-api/pull/217)
18
+ - see [oauth.md](https://github.com/Shopify/shopify-node-api/blob/main/docs/usage/oauth.md) for updated usage
19
+ - [Breaking] Extract `addHandler` and `getHandler` methods for webhooks out of `register` [#205](https://github.com/Shopify/shopify-node-api/pull/205)
20
+ - [Breaking] Sessions no longer default to `false` for `isOnline` [#169](https://github.com/Shopify/shopify-node-api/pull/169)
21
+ - Required `Session` arguments must be passed to the constructor [#169](https://github.com/Shopify/shopify-node-api/pull/169)
22
+ - Allow `undefined` in `AuthScopes` [#169](https://github.com/Shopify/shopify-node-api/pull/169)
23
+
24
+ ## [1.4.3] - 2021-10-22
25
+
26
+ ### Fixed
27
+
28
+ - Fixed the HTTP client error messages to expand objects [#252](https://github.com/Shopify/shopify-node-api/pull/252)
29
+
30
+ ## [1.4.2] - 2021-10-20
31
+
32
+ - Added `October21` to `ApiVersion` [#247](https://github.com/Shopify/shopify-node-api/pull/247)
33
+
34
+ ## [1.4.1] - 2021-06-11
35
+
36
+ - Don't include extra params when calculating local hmac [#196](https://github.com/Shopify/shopify-node-api/pull/196)
37
+
10
38
  ## [1.4.0] - 2021-05-21
39
+
11
40
  ### Added
41
+
12
42
  - Add support for registering Google Pub/Sub webhooks [#181](https://github.com/Shopify/shopify-node-api/pull/181)
13
43
  - Added `July21` to `ApiVersion` [#181](https://github.com/Shopify/shopify-node-api/pull/181)
14
44
 
15
45
  ## [1.3.0] - 2021-05-12
46
+
16
47
  ### Added
48
+
17
49
  - Added Storefront API client under `Shopify.Clients.Storefront`
18
50
  - Add `isActive()` method to `Session` class to check if session is active, replace `Session` with `SessionInterface` when used as a type [#153](https://github.com/Shopify/shopify-node-api/pull/153)
19
51
 
20
52
  ## [1.2.1] - 2021-03-26
53
+
21
54
  ### Added
55
+
22
56
  - Added `April21` to `ApiVersion` [#149](https://github.com/Shopify/shopify-node-api/pull/149)
23
57
 
24
58
  ## [1.2.0] - 2021-03-16
25
59
 
26
60
  ### Added
61
+
27
62
  - Allow plain objects to be returned from the `loadCallback` on `CustomSessionStorage` [#126](https://github.com/shopify/shopify-node-api/pull/126)
28
63
  - Documentation and example code for `CustomSessionStorage` [#129](https://github.com/shopify/shopify-node-api/pull/129)
29
64
 
30
65
  ### Fixed
66
+
31
67
  - Throw a different error for a missing cookie upon OAuth return [#131](https://github.com/shopify/shopify-node-api/pull/131)
32
68
  - Improved documentation for GraphQL and Rest Clients. [#123](https://github.com/Shopify/shopify-node-api/pull/123)
33
69
  - Made Docs directory more browseable in GitHub. [#136](https://github.com/Shopify/shopify-node-api/pull/136)
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # `@shopify/shopify-api`
2
2
 
3
3
  <!-- ![Build Status]() -->
4
+
4
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)
5
6
  [![npm version](https://badge.fury.io/js/%40shopify%2Fshopify-api.svg)](https://badge.fury.io/js/%40shopify%2Fshopify-api)
6
7
 
@@ -18,6 +19,7 @@ This library can be used in any application that has a Node.js backend, since it
18
19
  # Requirements
19
20
 
20
21
  To follow these usage guides, you will need to:
22
+
21
23
  - have a basic understanding of [Node.js](https://nodejs.org)
22
24
  - have a Shopify Partner account and development store
23
25
  - _OR_ have a test store where you can create a private app
@@ -27,6 +29,7 @@ To follow these usage guides, you will need to:
27
29
  - have [yarn](https://yarnpkg.com) installed
28
30
 
29
31
  <!-- Make sure this section is in sync with docs/README.md -->
32
+
30
33
  # Getting started
31
34
 
32
35
  You can follow our [getting started guide](docs/), which will provide instructions on how to create an app using plain Node.js code, or the [Express](https://expressjs.com/) framework. Both examples are written in Typescript.
@@ -1,4 +1,5 @@
1
1
  import http from 'http';
2
+ import { SessionInterface } from '../session/types';
2
3
  import { AuthQuery } from './types';
3
4
  declare const ShopifyOAuth: {
4
5
  SESSION_COOKIE_NAME: string;
@@ -11,7 +12,7 @@ declare const ShopifyOAuth: {
11
12
  * @param redirect Redirect url for callback
12
13
  * @param isOnline Boolean value. If true, appends 'per-user' grant options to authorization url to receive online access token.
13
14
  * During final oauth request, will receive back the online access token and current online session information.
14
- * Defaults to offline access.
15
+ * Defaults to online access.
15
16
  */
16
17
  beginAuth(request: http.IncomingMessage, response: http.ServerResponse, shop: string, redirectPath: string, isOnline?: boolean): Promise<string>;
17
18
  /**
@@ -23,8 +24,9 @@ declare const ShopifyOAuth: {
23
24
  * @param response Current HTTP Response
24
25
  * @param query Current HTTP Request Query, containing the information to be validated.
25
26
  * Depending on framework, this may need to be cast as "unknown" before being passed.
27
+ * @returns SessionInterface
26
28
  */
27
- validateAuthCallback(request: http.IncomingMessage, response: http.ServerResponse, query: AuthQuery): Promise<void>;
29
+ validateAuthCallback(request: http.IncomingMessage, response: http.ServerResponse, query: AuthQuery): Promise<SessionInterface>;
28
30
  /**
29
31
  * Loads the current session id from the session cookie.
30
32
  *
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAiBxB,OAAO,EAAC,SAAS,EAA8D,MAAM,SAAS,CAAC;AAE/F,QAAA,MAAM,YAAY;;IAGhB;;;;;;;;;;OAUG;uBAEQ,IAAI,CAAC,eAAe,YACnB,IAAI,CAAC,cAAc,QACvB,MAAM,gBACE,MAAM,uBAEnB,OAAO,CAAC,MAAM,CAAC;IA8ClB;;;;;;;;;OASG;kCAEQ,IAAI,CAAC,eAAe,YACnB,IAAI,CAAC,cAAc,SACtB,SAAS,GACf,OAAO,CAAC,IAAI,CAAC;IA4FhB;;;;;OAKG;gCACyB,IAAI,CAAC,eAAe,YAAY,IAAI,CAAC,cAAc,GAAG,MAAM,GAAG,SAAS;IAQpG;;;;;OAKG;0BACmB,MAAM,UAAU,MAAM,GAAG,MAAM;IAIrD;;;;OAIG;8BACuB,MAAM,GAAG,MAAM;IAIzC;;;;;;OAMG;iCAEQ,IAAI,CAAC,eAAe,YACnB,IAAI,CAAC,cAAc,uBAE5B,MAAM,GAAG,SAAS;CA+BtB,CAAC;AAYF,OAAO,EAAC,YAAY,EAAC,CAAC"}
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAgBxB,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAElD,OAAO,EACL,SAAS,EAIV,MAAM,SAAS,CAAC;AAEjB,QAAA,MAAM,YAAY;;IAGhB;;;;;;;;;;OAUG;uBAEQ,IAAI,CAAC,eAAe,YACnB,IAAI,CAAC,cAAc,QACvB,MAAM,gBACE,MAAM,uBAEnB,OAAO,CAAC,MAAM,CAAC;IAgDlB;;;;;;;;;;OAUG;kCAEQ,IAAI,CAAC,eAAe,YACnB,IAAI,CAAC,cAAc,SACtB,SAAS,GACf,OAAO,CAAC,gBAAgB,CAAC;IAmG5B;;;;;OAKG;gCAEQ,IAAI,CAAC,eAAe,YACnB,IAAI,CAAC,cAAc,GAC5B,MAAM,GAAG,SAAS;IAQrB;;;;;OAKG;0BACmB,MAAM,UAAU,MAAM,GAAG,MAAM;IAIrD;;;;OAIG;8BACuB,MAAM,GAAG,MAAM;IAIzC;;;;;;OAMG;iCAEQ,IAAI,CAAC,eAAe,YACnB,IAAI,CAAC,cAAc,uBAE5B,MAAM,GAAG,SAAS;CAiCtB,CAAC;AAgBF,OAAO,EAAC,YAAY,EAAC,CAAC"}
@@ -26,10 +26,10 @@ var ShopifyOAuth = {
26
26
  * @param redirect Redirect url for callback
27
27
  * @param isOnline Boolean value. If true, appends 'per-user' grant options to authorization url to receive online access token.
28
28
  * During final oauth request, will receive back the online access token and current online session information.
29
- * Defaults to offline access.
29
+ * Defaults to online access.
30
30
  */
31
31
  beginAuth: function (request, response, shop, redirectPath, isOnline) {
32
- if (isOnline === void 0) { isOnline = false; }
32
+ if (isOnline === void 0) { isOnline = true; }
33
33
  return tslib_1.__awaiter(this, void 0, void 0, function () {
34
34
  var cookies, state, session, sessionStored, query, queryString;
35
35
  return tslib_1.__generator(this, function (_a) {
@@ -42,10 +42,7 @@ var ShopifyOAuth = {
42
42
  secure: true,
43
43
  });
44
44
  state = nonce_1.default();
45
- session = new session_1.Session(isOnline ? uuid_1.v4() : this.getOfflineSessionId(shop));
46
- session.shop = shop;
47
- session.state = state;
48
- session.isOnline = isOnline;
45
+ session = new session_1.Session(isOnline ? uuid_1.v4() : this.getOfflineSessionId(shop), shop, state, isOnline);
49
46
  return [4 /*yield*/, context_1.Context.SESSION_STORAGE.storeSession(session)];
50
47
  case 1:
51
48
  sessionStored = _a.sent();
@@ -80,10 +77,11 @@ var ShopifyOAuth = {
80
77
  * @param response Current HTTP Response
81
78
  * @param query Current HTTP Request Query, containing the information to be validated.
82
79
  * Depending on framework, this may need to be cast as "unknown" before being passed.
80
+ * @returns SessionInterface
83
81
  */
84
82
  validateAuthCallback: function (request, response, query) {
85
83
  return tslib_1.__awaiter(this, void 0, void 0, function () {
86
- var cookies, sessionCookie, currentSession, body, postParams, client, postResponse, responseBody, access_token, scope, rest, sessionExpiration, responseBody, oauthSessionExpiration, onlineInfo, jwtSessionId, jwtSession, sessionStored;
84
+ var cookies, sessionCookie, currentSession, body, postParams, client, postResponse, responseBody, access_token, scope, rest, sessionExpiration, onlineInfo, jwtSessionId, jwtSession, sessionDeleted, responseBody, sessionStored;
87
85
  return tslib_1.__generator(this, function (_a) {
88
86
  switch (_a.label) {
89
87
  case 0:
@@ -120,50 +118,46 @@ var ShopifyOAuth = {
120
118
  return [4 /*yield*/, client.post(postParams)];
121
119
  case 2:
122
120
  postResponse = _a.sent();
123
- if (currentSession.isOnline) {
124
- responseBody = postResponse.body;
125
- access_token = responseBody.access_token, scope = responseBody.scope, rest = tslib_1.__rest(responseBody, ["access_token", "scope"]);
126
- sessionExpiration = new Date(Date.now() + responseBody.expires_in * 1000);
127
- currentSession.accessToken = access_token;
128
- currentSession.expires = sessionExpiration;
129
- currentSession.scope = scope;
130
- currentSession.onlineAccessInfo = rest;
131
- }
132
- else {
133
- responseBody = postResponse.body;
134
- currentSession.accessToken = responseBody.access_token;
135
- currentSession.scope = responseBody.scope;
136
- }
137
- oauthSessionExpiration = currentSession.expires;
138
- if (!!currentSession.isOnline) return [3 /*break*/, 3];
139
- oauthSessionExpiration = new Date();
140
- return [3 /*break*/, 5];
141
- case 3:
142
- if (!context_1.Context.IS_EMBEDDED_APP) return [3 /*break*/, 5];
121
+ if (!currentSession.isOnline) return [3 /*break*/, 5];
122
+ responseBody = postResponse.body;
123
+ access_token = responseBody.access_token, scope = responseBody.scope, rest = tslib_1.__rest(responseBody, ["access_token", "scope"]);
124
+ sessionExpiration = new Date(Date.now() + responseBody.expires_in * 1000);
125
+ currentSession.accessToken = access_token;
126
+ currentSession.expires = sessionExpiration;
127
+ currentSession.scope = scope;
128
+ currentSession.onlineAccessInfo = rest;
129
+ if (!context_1.Context.IS_EMBEDDED_APP) return [3 /*break*/, 4];
143
130
  onlineInfo = currentSession.onlineAccessInfo;
144
131
  jwtSessionId = this.getJwtSessionId(currentSession.shop, "" + onlineInfo.associated_user.id);
145
132
  jwtSession = session_1.Session.cloneSession(currentSession, jwtSessionId);
146
- return [4 /*yield*/, context_1.Context.SESSION_STORAGE.storeSession(jwtSession)];
147
- case 4:
148
- _a.sent();
149
- // Make sure the current OAuth session expires along with the cookie
150
- oauthSessionExpiration = new Date(Date.now() + 30000);
151
- currentSession.expires = oauthSessionExpiration;
152
- _a.label = 5;
133
+ return [4 /*yield*/, context_1.Context.SESSION_STORAGE.deleteSession(currentSession.id)];
134
+ case 3:
135
+ sessionDeleted = _a.sent();
136
+ if (!sessionDeleted) {
137
+ throw new ShopifyErrors.SessionStorageError('OAuth Session could not be deleted. Please check your session storage functionality.');
138
+ }
139
+ currentSession = jwtSession;
140
+ _a.label = 4;
141
+ case 4: return [3 /*break*/, 6];
153
142
  case 5:
143
+ responseBody = postResponse.body;
144
+ currentSession.accessToken = responseBody.access_token;
145
+ currentSession.scope = responseBody.scope;
146
+ _a.label = 6;
147
+ case 6:
154
148
  cookies.set(ShopifyOAuth.SESSION_COOKIE_NAME, currentSession.id, {
155
149
  signed: true,
156
- expires: oauthSessionExpiration,
150
+ expires: context_1.Context.IS_EMBEDDED_APP ? new Date() : currentSession.expires,
157
151
  sameSite: 'lax',
158
152
  secure: true,
159
153
  });
160
154
  return [4 /*yield*/, context_1.Context.SESSION_STORAGE.storeSession(currentSession)];
161
- case 6:
155
+ case 7:
162
156
  sessionStored = _a.sent();
163
157
  if (!sessionStored) {
164
158
  throw new ShopifyErrors.SessionStorageError('OAuth Session could not be saved. Please check your session storage functionality.');
165
159
  }
166
- return [2 /*return*/];
160
+ return [2 /*return*/, currentSession];
167
161
  }
168
162
  });
169
163
  });
@@ -243,5 +237,7 @@ exports.ShopifyOAuth = ShopifyOAuth;
243
237
  * @param session Current session
244
238
  */
245
239
  function validQuery(query, session) {
246
- return hmac_validator_1.default(query) && shop_validator_1.default(query.shop) && safe_compare_1.default(query.state, session.state);
240
+ return (hmac_validator_1.default(query) &&
241
+ shop_validator_1.default(query.shop) &&
242
+ safe_compare_1.default(query.state, session.state));
247
243
  }
@@ -3,6 +3,7 @@ export interface AuthQuery {
3
3
  timestamp: string;
4
4
  state: string;
5
5
  shop: string;
6
+ host?: string;
6
7
  hmac?: string;
7
8
  }
8
9
  export interface AccessTokenResponse {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE;QACf,EAAE,EAAE,MAAM,CAAC;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,EAAE,OAAO,CAAC;QACxB,aAAa,EAAE,OAAO,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAGD,MAAM,WAAW,oBACf,SAAQ,mBAAmB,EACzB,gBAAgB;CAAG"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE;QACf,EAAE,EAAE,MAAM,CAAC;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,cAAc,EAAE,OAAO,CAAC;QACxB,aAAa,EAAE,OAAO,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAGD,MAAM,WAAW,oBACf,SAAQ,mBAAmB,EACzB,gBAAgB;CAAG"}
@@ -2,9 +2,9 @@ declare class AuthScopes {
2
2
  static SCOPE_DELIMITER: string;
3
3
  private compressedScopes;
4
4
  private expandedScopes;
5
- constructor(scopes: string | string[]);
6
- has(scope: string | string[] | AuthScopes): boolean;
7
- equals(otherScopes: string | string[] | AuthScopes): boolean;
5
+ constructor(scopes: string | string[] | undefined);
6
+ has(scope: string | string[] | AuthScopes | undefined): boolean;
7
+ equals(otherScopes: string | string[] | AuthScopes | undefined): boolean;
8
8
  toString(): string;
9
9
  toArray(): string[];
10
10
  private getImpliedScopes;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/scopes/index.ts"],"names":[],"mappings":"AAAA,cAAM,UAAU;IACd,OAAc,eAAe,SAAO;IAEpC,OAAO,CAAC,gBAAgB,CAAc;IACtC,OAAO,CAAC,cAAc,CAAc;gBAExB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAmB9B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU;IAYzC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU;IAelD,QAAQ;IAIR,OAAO;IAId,OAAO,CAAC,gBAAgB;CAUzB;AAED,OAAO,EAAC,UAAU,EAAC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/scopes/index.ts"],"names":[],"mappings":"AACA,cAAM,UAAU;IACd,OAAc,eAAe,SAAO;IAEpC,OAAO,CAAC,gBAAgB,CAAc;IACtC,OAAO,CAAC,cAAc,CAAc;gBAExB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAyB1C,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,SAAS;IAcrD,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,SAAS;IAe9D,QAAQ;IAIR,OAAO;IAId,OAAO,CAAC,gBAAgB;CAUzB;AAED,OAAO,EAAC,UAAU,EAAC,CAAC"}
@@ -8,10 +8,12 @@ var AuthScopes = /** @class */ (function () {
8
8
  if (typeof scopes === 'string') {
9
9
  scopesArray = scopes.split(new RegExp(AuthScopes.SCOPE_DELIMITER + "\\s*"));
10
10
  }
11
- else {
11
+ else if (scopes) {
12
12
  scopesArray = scopes;
13
13
  }
14
- scopesArray = scopesArray.map(function (scope) { return scope.trim(); }).filter(function (scope) { return scope.length; });
14
+ scopesArray = scopesArray
15
+ .map(function (scope) { return scope.trim(); })
16
+ .filter(function (scope) { return scope.length; });
15
17
  var impliedScopes = this.getImpliedScopes(scopesArray);
16
18
  var scopeSet = new Set(scopesArray);
17
19
  var impliedSet = new Set(impliedScopes);
@@ -27,7 +29,7 @@ var AuthScopes = /** @class */ (function () {
27
29
  else {
28
30
  other = new AuthScopes(scope);
29
31
  }
30
- return other.toArray().filter(function (x) { return !_this.expandedScopes.has(x); }).length === 0;
32
+ return (other.toArray().filter(function (x) { return !_this.expandedScopes.has(x); }).length === 0);
31
33
  };
32
34
  AuthScopes.prototype.equals = function (otherScopes) {
33
35
  var other;
@@ -8,5 +8,5 @@ declare const ShopifySession: {
8
8
  CustomSessionStorage: typeof CustomSessionStorage;
9
9
  };
10
10
  export default ShopifySession;
11
- export { Session, SessionStorage, MemorySessionStorage, CustomSessionStorage, };
11
+ export { Session, SessionStorage, MemorySessionStorage, CustomSessionStorage };
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAEtD,QAAA,MAAM,cAAc;;;;CAInB,CAAC;AAEF,eAAe,cAAc,CAAC;AAC9B,OAAO,EACL,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GACrB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAEtD,QAAA,MAAM,cAAc;;;;CAInB,CAAC;AAEF,eAAe,cAAc,CAAC;AAC9B,OAAO,EAAC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,oBAAoB,EAAC,CAAC"}
@@ -5,15 +5,15 @@ import { SessionInterface } from './types';
5
5
  */
6
6
  declare class Session implements SessionInterface {
7
7
  readonly id: string;
8
- static cloneSession(session: Session, newId: string): Session;
9
8
  shop: string;
10
9
  state: string;
11
- scope: string;
10
+ isOnline: boolean;
11
+ static cloneSession(session: Session, newId: string): Session;
12
+ scope?: string;
12
13
  expires?: Date;
13
- isOnline?: boolean;
14
14
  accessToken?: string;
15
15
  onlineAccessInfo?: OnlineAccessInfo;
16
- constructor(id: string);
16
+ constructor(id: string, shop: string, state: string, isOnline: boolean);
17
17
  isActive(): boolean;
18
18
  }
19
19
  export { Session };
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/auth/session/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAEzC;;GAEG;AACH,cAAM,OAAQ,YAAW,gBAAgB;IAuB3B,QAAQ,CAAC,EAAE,EAAE,MAAM;WAtBjB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAc7D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;gBAEtB,EAAE,EAAE,MAAM;IAExB,QAAQ,IAAI,OAAO;CAO3B;AAED,OAAO,EAAC,OAAO,EAAC,CAAC"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/auth/session/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAEzC;;GAEG;AACH,cAAM,OAAQ,YAAW,gBAAgB;IAuBrC,QAAQ,CAAC,EAAE,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,OAAO;WAzBZ,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAgB7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;gBAGhC,EAAE,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO;IAGnB,QAAQ,IAAI,OAAO;CAW3B;AAED,OAAO,EAAC,OAAO,EAAC,CAAC"}
@@ -6,23 +6,25 @@ var context_1 = require("../../context");
6
6
  * Stores App information from logged in merchants so they can make authenticated requests to the Admin API.
7
7
  */
8
8
  var Session = /** @class */ (function () {
9
- function Session(id) {
9
+ function Session(id, shop, state, isOnline) {
10
10
  this.id = id;
11
+ this.shop = shop;
12
+ this.state = state;
13
+ this.isOnline = isOnline;
11
14
  }
12
15
  Session.cloneSession = function (session, newId) {
13
- var newSession = new Session(newId);
14
- newSession.shop = session.shop;
15
- newSession.state = session.state;
16
+ var newSession = new Session(newId, session.shop, session.state, session.isOnline);
16
17
  newSession.scope = session.scope;
17
18
  newSession.expires = session.expires;
18
- newSession.isOnline = session.isOnline;
19
19
  newSession.accessToken = session.accessToken;
20
20
  newSession.onlineAccessInfo = session.onlineAccessInfo;
21
21
  return newSession;
22
22
  };
23
23
  Session.prototype.isActive = function () {
24
24
  var scopesUnchanged = context_1.Context.SCOPES.equals(this.scope);
25
- if (scopesUnchanged && this.accessToken && (!this.expires || this.expires >= new Date())) {
25
+ if (scopesUnchanged &&
26
+ this.accessToken &&
27
+ (!this.expires || this.expires >= new Date())) {
26
28
  return true;
27
29
  }
28
30
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../../src/auth/session/storage/custom.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAGlD,qBAAa,oBAAqB,YAAW,cAAc;IAEvD,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC;IACvE,QAAQ,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACtG,QAAQ,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC;gBAFhD,aAAa,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC,EAC9D,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAC7F,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC;IAO9C,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUzD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAmC9D,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CASzD"}
1
+ {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../../src/auth/session/storage/custom.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAGlD,qBAAa,oBAAqB,YAAW,cAAc;IAEvD,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC;IACvE,QAAQ,CAAC,YAAY,EAAE,CACrB,EAAE,EAAE,MAAM,KACP,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACpE,QAAQ,CAAC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC;gBAJhD,aAAa,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,OAAO,CAAC,EAC9D,YAAY,EAAE,CACrB,EAAE,EAAE,MAAM,KACP,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAC3D,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC;IAO9C,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUzD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IA0C9D,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CASzD"}
@@ -53,7 +53,7 @@ var CustomSessionStorage = /** @class */ (function () {
53
53
  return [2 /*return*/, result];
54
54
  }
55
55
  else if (result instanceof Object && 'id' in result) {
56
- session = new session_1.Session(result.id);
56
+ session = new session_1.Session(result.id, result.shop, result.state, result.isOnline);
57
57
  session = tslib_1.__assign(tslib_1.__assign({}, session), result);
58
58
  if (session.expires && typeof session.expires === 'string') {
59
59
  session.expires = new Date(session.expires);
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/auth/session/storage/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElD,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAA2C;IAE9C,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAKzD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAI9D,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAMzD"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/auth/session/storage/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAElD,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAAyC;IAE5C,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAKzD,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAI9D,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAMzD"}
@@ -3,9 +3,9 @@ export interface SessionInterface {
3
3
  readonly id: string;
4
4
  shop: string;
5
5
  state: string;
6
- scope: string;
6
+ isOnline: boolean;
7
+ scope?: string;
7
8
  expires?: Date;
8
- isOnline?: boolean;
9
9
  accessToken?: string;
10
10
  onlineAccessInfo?: OnlineAccessInfo;
11
11
  isActive(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,IAAI,OAAO,CAAC;CACrB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/auth/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,IAAI,OAAO,CAAC;CACrB"}
@@ -24,6 +24,7 @@ export declare enum ApiVersion {
24
24
  January21 = "2021-01",
25
25
  April21 = "2021-04",
26
26
  July21 = "2021-07",
27
+ October21 = "2021-10",
27
28
  Unstable = "unstable",
28
29
  Unversioned = "unversioned"
29
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base_types.d.ts","sourceRoot":"","sources":["../src/base_types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAC,MAAM,gCAAgC,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,UAAU,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mCAAmC,CAAC,EAAE,MAAM,CAAC;CAC9C;AAED,oBAAY,UAAU;IACpB,OAAO,YAAY;IACnB,MAAM,YAAY;IAClB,SAAS,YAAY;IACrB,SAAS,YAAY;IACrB,OAAO,YAAY;IACnB,MAAM,YAAY;IAClB,SAAS,YAAY;IACrB,SAAS,YAAY;IACrB,OAAO,YAAY;IACnB,MAAM,YAAY;IAClB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;CAC5B;AAED,oBAAY,aAAa;IACvB,WAAW,2BAA2B;IACtC,qBAAqB,sCAAsC;IAC3D,IAAI,0BAA0B;IAC9B,KAAK,oBAAoB;IACzB,MAAM,0BAA0B;CACjC"}
1
+ {"version":3,"file":"base_types.d.ts","sourceRoot":"","sources":["../src/base_types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,cAAc,EAAC,MAAM,gCAAgC,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,UAAU,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mCAAmC,CAAC,EAAE,MAAM,CAAC;CAC9C;AAED,oBAAY,UAAU;IACpB,OAAO,YAAY;IACnB,MAAM,YAAY;IAClB,SAAS,YAAY;IACrB,SAAS,YAAY;IACrB,OAAO,YAAY;IACnB,MAAM,YAAY;IAClB,SAAS,YAAY;IACrB,SAAS,YAAY;IACrB,OAAO,YAAY;IACnB,MAAM,YAAY;IAClB,SAAS,YAAY;IACrB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;CAC5B;AAED,oBAAY,aAAa;IACvB,WAAW,2BAA2B;IACtC,qBAAqB,sCAAsC;IAC3D,IAAI,0BAA0B;IAC9B,KAAK,oBAAoB;IACzB,MAAM,0BAA0B;CACjC"}
@@ -13,6 +13,7 @@ var ApiVersion;
13
13
  ApiVersion["January21"] = "2021-01";
14
14
  ApiVersion["April21"] = "2021-04";
15
15
  ApiVersion["July21"] = "2021-07";
16
+ ApiVersion["October21"] = "2021-10";
16
17
  ApiVersion["Unstable"] = "unstable";
17
18
  ApiVersion["Unversioned"] = "unversioned";
18
19
  })(ApiVersion = exports.ApiVersion || (exports.ApiVersion = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"graphql_client.d.ts","sourceRoot":"","sources":["../../../src/clients/graphql/graphql_client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAG7D,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,aAAa;IAKZ,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,WAAW,CAAC;IAJ1D,SAAS,CAAC,WAAW,SAAgB;IAErC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,MAAM,EAAW,WAAW,CAAC,oBAAQ;IAQ5D,KAAK,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAwB1D,SAAS,CAAC,oBAAoB,IAAI,iBAAiB;CAMpD"}
1
+ {"version":3,"file":"graphql_client.d.ts","sourceRoot":"","sources":["../../../src/clients/graphql/graphql_client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAG7D,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,aAAa;IAKZ,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,WAAW,CAAC;IAJ1D,SAAS,CAAC,WAAW,SAAgB;IAErC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;gBAEf,MAAM,EAAE,MAAM,EAAW,WAAW,CAAC,oBAAQ;IAU5D,KAAK,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAwB1D,SAAS,CAAC,oBAAoB,IAAI,iBAAiB;CAQpD"}
@@ -42,7 +42,9 @@ var GraphqlClient = /** @class */ (function () {
42
42
  GraphqlClient.prototype.getAccessTokenHeader = function () {
43
43
  return {
44
44
  header: base_types_1.ShopifyHeader.AccessToken,
45
- value: context_1.Context.IS_PRIVATE_APP ? context_1.Context.API_SECRET_KEY : this.accessToken,
45
+ value: context_1.Context.IS_PRIVATE_APP
46
+ ? context_1.Context.API_SECRET_KEY
47
+ : this.accessToken,
46
48
  };
47
49
  };
48
50
  return GraphqlClient;
@@ -3,5 +3,5 @@ declare const ShopifyGraphqlClient: {
3
3
  GraphqlClient: typeof GraphqlClient;
4
4
  };
5
5
  export default ShopifyGraphqlClient;
6
- export { GraphqlClient, };
6
+ export { GraphqlClient };
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clients/graphql/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,QAAA,MAAM,oBAAoB;;CAEzB,CAAC;AAEF,eAAe,oBAAoB,CAAC;AAEpC,OAAO,EACL,aAAa,GACd,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clients/graphql/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,QAAA,MAAM,oBAAoB;;CAEzB,CAAC;AAEF,eAAe,oBAAoB,CAAC;AAEpC,OAAO,EAAC,aAAa,EAAC,CAAC"}
@@ -15,7 +15,9 @@ var StorefrontClient = /** @class */ (function (_super) {
15
15
  StorefrontClient.prototype.getAccessTokenHeader = function () {
16
16
  return {
17
17
  header: base_types_1.ShopifyHeader.StorefrontAccessToken,
18
- value: (context_1.Context.IS_PRIVATE_APP ? context_1.Context.PRIVATE_APP_STOREFRONT_ACCESS_TOKEN || this.accessToken : this.accessToken),
18
+ value: (context_1.Context.IS_PRIVATE_APP
19
+ ? context_1.Context.PRIVATE_APP_STOREFRONT_ACCESS_TOKEN || this.accessToken
20
+ : this.accessToken),
19
21
  };
20
22
  };
21
23
  return StorefrontClient;
@@ -1 +1 @@
1
- {"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../../src/clients/http_client/http_client.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,cAAM,UAAU;IAOK,OAAO,CAAC,MAAM;IALjC,MAAM,CAAC,QAAQ,CAAC,eAAe,QAAQ;IAEvC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,UAAU;IACjD,OAAO,CAAC,mBAAmB,CAA8B;gBAE9B,MAAM,EAAE,MAAM;IAQzC;;OAEG;IACU,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIlE;;OAEG;IACU,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIpE;;OAEG;IACU,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIlE;;OAEG;IACU,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;cAIxD,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;YAgGxD,SAAS;CA2ExB;AAED,OAAO,EAAC,UAAU,EAAC,CAAC"}
1
+ {"version":3,"file":"http_client.d.ts","sourceRoot":"","sources":["../../../src/clients/http_client/http_client.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,cAAM,UAAU;IAOK,OAAO,CAAC,MAAM;IALjC,MAAM,CAAC,QAAQ,CAAC,eAAe,QAAQ;IAEvC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,UAAU;IACjD,OAAO,CAAC,mBAAmB,CAA8B;gBAE9B,MAAM,EAAE,MAAM;IAQzC;;OAEG;IACU,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIlE;;OAEG;IACU,IAAI,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIpE;;OAEG;IACU,GAAG,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIlE;;OAEG;IACU,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;cAIxD,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;YA4GxD,SAAS;CAgGxB;AAED,OAAO,EAAC,UAAU,EAAC,CAAC"}
@@ -101,7 +101,10 @@ var HttpClient = /** @class */ (function () {
101
101
  body = typeof data === 'string' ? data : JSON.stringify(data);
102
102
  break;
103
103
  case types_1.DataType.URLEncoded:
104
- body = typeof data === 'string' ? data : querystring_1.default.stringify(data);
104
+ body =
105
+ typeof data === 'string'
106
+ ? data
107
+ : querystring_1.default.stringify(data);
105
108
  break;
106
109
  case types_1.DataType.GraphQL:
107
110
  body = data;
@@ -110,7 +113,9 @@ var HttpClient = /** @class */ (function () {
110
113
  headers = tslib_1.__assign({ 'Content-Type': type, 'Content-Length': Buffer.byteLength(body) }, params.extraHeaders);
111
114
  }
112
115
  }
113
- queryString = params.query ? "?" + querystring_1.default.stringify(params.query) : '';
116
+ queryString = params.query
117
+ ? "?" + querystring_1.default.stringify(params.query)
118
+ : '';
114
119
  url = "https://" + this.domain + params.path + queryString;
115
120
  options = {
116
121
  method: params.method.toString(),
@@ -132,7 +137,8 @@ var HttpClient = /** @class */ (function () {
132
137
  if (!(error_1 instanceof ShopifyErrors.HttpRetriableError)) return [3 /*break*/, 7];
133
138
  if (!(tries < maxTries)) return [3 /*break*/, 6];
134
139
  waitTime = HttpClient.RETRY_WAIT_TIME;
135
- if (error_1 instanceof ShopifyErrors.HttpThrottlingError && error_1.retryAfter) {
140
+ if (error_1 instanceof ShopifyErrors.HttpThrottlingError &&
141
+ error_1.retryAfter) {
136
142
  waitTime = error_1.retryAfter * 1000;
137
143
  }
138
144
  return [4 /*yield*/, sleep(waitTime)];
@@ -170,19 +176,27 @@ var HttpClient = /** @class */ (function () {
170
176
  case 1:
171
177
  body = _a.sent();
172
178
  if (response.ok) {
173
- if (response.headers && response.headers.has('X-Shopify-API-Deprecated-Reason')) {
179
+ if (response.headers &&
180
+ response.headers.has('X-Shopify-API-Deprecated-Reason')) {
174
181
  deprecation = {
175
182
  message: response.headers.get('X-Shopify-API-Deprecated-Reason'),
176
183
  path: url,
177
184
  };
178
- depHash = crypto_1.default.createHash('md5').update(JSON.stringify(deprecation)).digest('hex');
185
+ depHash = crypto_1.default
186
+ .createHash('md5')
187
+ .update(JSON.stringify(deprecation))
188
+ .digest('hex');
179
189
  if (!Object.keys(this.LOGGED_DEPRECATIONS).includes(depHash) ||
180
- Date.now() - this.LOGGED_DEPRECATIONS[depHash] >= HttpClient.DEPRECATION_ALERT_DELAY) {
190
+ Date.now() - this.LOGGED_DEPRECATIONS[depHash] >=
191
+ HttpClient.DEPRECATION_ALERT_DELAY) {
181
192
  this.LOGGED_DEPRECATIONS[depHash] = Date.now();
182
193
  if (context_1.Context.LOG_FILE) {
183
194
  stack = new Error().stack;
184
195
  log = "API Deprecation Notice " + new Date().toLocaleString() + " : " + JSON.stringify(deprecation) + "\n Stack Trace: " + stack + "\n";
185
- fs_1.default.writeFileSync(context_1.Context.LOG_FILE, log, { flag: 'a', encoding: 'utf-8' });
196
+ fs_1.default.writeFileSync(context_1.Context.LOG_FILE, log, {
197
+ flag: 'a',
198
+ encoding: 'utf-8',
199
+ });
186
200
  }
187
201
  else {
188
202
  console.warn('API Deprecation Notice:', deprecation);
@@ -197,12 +211,14 @@ var HttpClient = /** @class */ (function () {
197
211
  else {
198
212
  errorMessages = [];
199
213
  if (body.errors) {
200
- errorMessages.push(body.errors);
214
+ errorMessages.push(JSON.stringify(body.errors, null, 2));
201
215
  }
202
216
  if (response.headers && response.headers.get('x-request-id')) {
203
217
  errorMessages.push("If you report this error, please include this id: " + response.headers.get('x-request-id'));
204
218
  }
205
- errorMessage = errorMessages.length ? ": " + errorMessages.join('. ') : '';
219
+ errorMessage = errorMessages.length
220
+ ? ":\n" + errorMessages.join('\n')
221
+ : '';
206
222
  switch (true) {
207
223
  case response.status === network_1.StatusCode.TooManyRequests: {
208
224
  retryAfter = response.headers.get('Retry-After');
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/clients/http_client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,oBAAY,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAE3D,oBAAY,QAAQ;IAClB,IAAI,qBAAqB;IACzB,OAAO,wBAAwB;IAC/B,UAAU,sCAAsC;CACjD;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;CACxC,CAAC;AAEF,oBAAY,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,oBAAY,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD,oBAAY,aAAa,GAAG,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,GAAG;IAAC,MAAM,EAAE,MAAM,CAAC;CAAC,CAAC;AAEvF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/clients/http_client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,oBAAY,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAE3D,oBAAY,QAAQ;IAClB,IAAI,qBAAqB;IACzB,OAAO,wBAAwB;IAC/B,UAAU,sCAAsC;CACjD;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,iBAAiB,GAAG,gBAAgB,GAAG;IACjD,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;CACxC,CAAC;AAEF,oBAAY,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,oBAAY,mBAAmB,GAAG,gBAAgB,CAAC;AAEnD,oBAAY,aAAa,GAAG,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,GAAG;IACnE,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"rest_client.d.ts","sourceRoot":"","sources":["../../../src/clients/rest/rest_client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,aAAa,EAAmB,MAAM,sBAAsB,CAAC;AAGrE,OAAO,EAAC,iBAAiB,EAAW,MAAM,SAAS,CAAC;AAEpD,cAAM,UAAW,SAAQ,UAAU;IAIE,QAAQ,CAAC,WAAW,CAAC;IAHxD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA8B;IAC/D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAQ;gBAEjB,MAAM,EAAE,MAAM,EAAW,WAAW,CAAC,oBAAQ;cAQhD,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuD1E,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,kBAAkB;CAW3B;AAED,OAAO,EAAC,UAAU,EAAC,CAAC"}
1
+ {"version":3,"file":"rest_client.d.ts","sourceRoot":"","sources":["../../../src/clients/rest/rest_client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,aAAa,EAAmB,MAAM,sBAAsB,CAAC;AAGrE,OAAO,EAAC,iBAAiB,EAAW,MAAM,SAAS,CAAC;AAEpD,cAAM,UAAW,SAAQ,UAAU;IAIE,QAAQ,CAAC,WAAW,CAAC;IAHxD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA8B;IAC/D,OAAO,CAAC,MAAM,CAAC,aAAa,CAAQ;gBAEjB,MAAM,EAAE,MAAM,EAAW,WAAW,CAAC,oBAAQ;cAUhD,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA2D1E,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,kBAAkB;CAa3B;AAED,OAAO,EAAC,UAAU,EAAC,CAAC"}