@shopify/shopify-api 14.0.1 → 15.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cjs/lib/auth/oauth/oauth.js +2 -0
  2. package/dist/cjs/lib/auth/oauth/oauth.js.map +1 -1
  3. package/dist/cjs/lib/clients/common.js +1 -0
  4. package/dist/cjs/lib/clients/common.js.map +1 -1
  5. package/dist/cjs/lib/types.js +0 -2
  6. package/dist/cjs/lib/types.js.map +1 -1
  7. package/dist/cjs/lib/version.js +1 -1
  8. package/dist/cjs/lib/version.js.map +1 -1
  9. package/dist/cjs/lib/webhooks/types.js +0 -2
  10. package/dist/cjs/lib/webhooks/types.js.map +1 -1
  11. package/dist/cjs/lib/webhooks/validate.js +0 -5
  12. package/dist/cjs/lib/webhooks/validate.js.map +1 -1
  13. package/dist/cjs/runtime/http/cookies.js +9 -3
  14. package/dist/cjs/runtime/http/cookies.js.map +1 -1
  15. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  16. package/dist/esm/lib/auth/oauth/oauth.mjs +2 -0
  17. package/dist/esm/lib/auth/oauth/oauth.mjs.map +1 -1
  18. package/dist/esm/lib/clients/common.mjs +1 -0
  19. package/dist/esm/lib/clients/common.mjs.map +1 -1
  20. package/dist/esm/lib/types.mjs +0 -2
  21. package/dist/esm/lib/types.mjs.map +1 -1
  22. package/dist/esm/lib/version.mjs +1 -1
  23. package/dist/esm/lib/version.mjs.map +1 -1
  24. package/dist/esm/lib/webhooks/types.mjs +0 -2
  25. package/dist/esm/lib/webhooks/types.mjs.map +1 -1
  26. package/dist/esm/lib/webhooks/validate.mjs +0 -5
  27. package/dist/esm/lib/webhooks/validate.mjs.map +1 -1
  28. package/dist/esm/runtime/http/cookies.mjs +9 -3
  29. package/dist/esm/runtime/http/cookies.mjs.map +1 -1
  30. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  31. package/dist/ts/lib/auth/oauth/oauth.d.ts.map +1 -1
  32. package/dist/ts/lib/clients/common.d.ts.map +1 -1
  33. package/dist/ts/lib/types.d.ts +0 -2
  34. package/dist/ts/lib/types.d.ts.map +1 -1
  35. package/dist/ts/lib/version.d.ts +1 -1
  36. package/dist/ts/lib/webhooks/types.d.ts +0 -4
  37. package/dist/ts/lib/webhooks/types.d.ts.map +1 -1
  38. package/dist/ts/runtime/http/cookies.d.ts.map +1 -1
  39. package/dist/ts/tsconfig.build.tsbuildinfo +1 -1
  40. package/lib/auth/oauth/oauth.ts +2 -0
  41. package/lib/clients/common.ts +1 -0
  42. package/lib/types.ts +0 -2
  43. package/lib/version.ts +1 -1
  44. package/lib/webhooks/types.ts +0 -4
  45. package/lib/webhooks/validate.ts +0 -9
  46. package/package.json +4 -4
  47. package/runtime/http/cookies.ts +14 -5
@@ -96,6 +96,7 @@ export function begin(config: ConfigInterface): OAuthBegin {
96
96
  expires: new Date(Date.now() + 60000),
97
97
  sameSite: 'lax',
98
98
  secure: true,
99
+ httpOnly: true,
99
100
  path: callbackPath,
100
101
  });
101
102
 
@@ -225,6 +226,7 @@ export function callback(config: ConfigInterface): OAuthCallback {
225
226
  expires: session.expires,
226
227
  sameSite: 'lax',
227
228
  secure: true,
229
+ httpOnly: true,
228
230
  path: cookiePath,
229
231
  });
230
232
  }
@@ -28,6 +28,7 @@ export function getUserAgent(config: ConfigInterface): string {
28
28
  const REDACTED_LOG_VALUE = '****';
29
29
 
30
30
  // These headers carry reusable credentials and must not reach the logs.
31
+ // Keep in sync with SENSITIVE_HEADERS in @shopify/graphql-client.
31
32
  const SENSITIVE_LOG_HEADERS = new Set([
32
33
  'authorization',
33
34
  'cookie',
package/lib/types.ts CHANGED
@@ -42,11 +42,9 @@ export const ShopifyEventsHeader = {
42
42
  Topic: 'shopify-topic',
43
43
  Domain: 'shopify-shop-domain',
44
44
  ApiVersion: 'shopify-api-version',
45
- EventId: 'shopify-event-id',
46
45
  WebhookId: 'shopify-webhook-id',
47
46
  Handle: 'shopify-handle',
48
47
  Action: 'shopify-action',
49
- ResourceId: 'shopify-resource-id',
50
48
  TriggeredAt: 'shopify-triggered-at',
51
49
  } as const;
52
50
 
package/lib/version.ts CHANGED
@@ -1 +1 @@
1
- export const SHOPIFY_API_LIBRARY_VERSION = '14.0.1';
1
+ export const SHOPIFY_API_LIBRARY_VERSION = '15.0.1';
@@ -27,10 +27,8 @@ export const WEBHOOK_HEADER_NAMES = {
27
27
  domain: ShopifyEventsHeader.Domain,
28
28
  apiVersion: ShopifyEventsHeader.ApiVersion,
29
29
  webhookId: ShopifyEventsHeader.WebhookId,
30
- eventId: ShopifyEventsHeader.EventId,
31
30
  handle: ShopifyEventsHeader.Handle,
32
31
  action: ShopifyEventsHeader.Action,
33
- resourceId: ShopifyEventsHeader.ResourceId,
34
32
  triggeredAt: ShopifyEventsHeader.TriggeredAt,
35
33
  },
36
34
  } as const;
@@ -187,10 +185,8 @@ export interface WebhooksWebhookFields extends BaseWebhookFields {
187
185
  export interface EventsWebhookFields extends BaseWebhookFields {
188
186
  webhookType: typeof WebhookType.Events;
189
187
  webhookId: string;
190
- eventId: string;
191
188
  handle?: string;
192
189
  action?: string;
193
- resourceId?: string;
194
190
  }
195
191
 
196
192
  export type WebhookFields = WebhooksWebhookFields | EventsWebhookFields;
@@ -164,11 +164,6 @@ function checkEventsHeaders(
164
164
  headerNames.webhookId,
165
165
  missingHeaders,
166
166
  );
167
- const eventId = getRequiredHeader(
168
- headers,
169
- headerNames.eventId,
170
- missingHeaders,
171
- );
172
167
 
173
168
  if (missingHeaders.length) {
174
169
  return {
@@ -185,7 +180,6 @@ function checkEventsHeaders(
185
180
  domain: domain!,
186
181
  apiVersion: apiVersion!,
187
182
  webhookId: webhookId!,
188
- eventId: eventId!,
189
183
  };
190
184
 
191
185
  const handle = getHeader(headers, headerNames.handle);
@@ -194,9 +188,6 @@ function checkEventsHeaders(
194
188
  const action = getHeader(headers, headerNames.action);
195
189
  if (action) fields.action = action;
196
190
 
197
- const resourceId = getHeader(headers, headerNames.resourceId);
198
- if (resourceId) fields.resourceId = resourceId;
199
-
200
191
  const triggeredAt = getHeader(headers, headerNames.triggeredAt);
201
192
  if (triggeredAt) fields.triggeredAt = triggeredAt;
202
193
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/shopify-api",
3
- "version": "14.0.1",
3
+ "version": "15.0.1",
4
4
  "description": "Shopify API Library for Node - accelerate development with support for authentication, graphql proxy, webhooks",
5
5
  "types": "./dist/ts/lib/index.d.ts",
6
6
  "module": "./dist/esm/lib/index.mjs",
@@ -71,9 +71,9 @@
71
71
  "Storefront API"
72
72
  ],
73
73
  "dependencies": {
74
- "@shopify/admin-api-client": "^2.0.0",
75
- "@shopify/graphql-client": "^2.0.0",
76
- "@shopify/storefront-api-client": "^2.0.0",
74
+ "@shopify/admin-api-client": "^2.0.1",
75
+ "@shopify/graphql-client": "^2.0.1",
76
+ "@shopify/storefront-api-client": "^2.0.1",
77
77
  "compare-versions": "^6.1.1",
78
78
  "isbot": "^5.2.0",
79
79
  "jose": "^5.9.6",
@@ -91,9 +91,13 @@ export class Cookies {
91
91
  name,
92
92
  value,
93
93
  ...Object.fromEntries(
94
- opts.map((opt) =>
95
- splitN(opt, '=', 2).map((value) => value.trim()),
96
- ),
94
+ opts.map((opt) => {
95
+ const [key, value] = splitN(opt, '=', 2).map((value) =>
96
+ value.trim(),
97
+ );
98
+ // Flag attributes like HttpOnly have no value
99
+ return [key, value ?? true];
100
+ }),
97
101
  ),
98
102
  },
99
103
  ];
@@ -111,8 +115,12 @@ export class Cookies {
111
115
  let result = '';
112
116
  result += `${data.name}=${data.value};`;
113
117
  result += Object.entries(data)
114
- .filter(([key]) => !['name', 'value', 'expires'].includes(key))
115
- .map(([key, value]) => `${key}=${value}`)
118
+ .filter(
119
+ ([key, value]) =>
120
+ !['name', 'value', 'expires'].includes(key) && value !== false,
121
+ )
122
+ // Boolean attributes are flags, so only write them when true
123
+ .map(([key, value]) => (value === true ? key : `${key}=${value}`))
116
124
  .join('; ');
117
125
  if (data.expires) {
118
126
  result += ';';
@@ -180,6 +188,7 @@ export class Cookies {
180
188
 
181
189
  set(name: string, value: string, opts: Partial<CookieData> = {}): void {
182
190
  this.outgoingCookieJar[name] = {
191
+ httpOnly: true,
183
192
  ...opts,
184
193
  name,
185
194
  value,