@adtrackify/at-service-common 1.2.14 → 1.2.15

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 (74) hide show
  1. package/dist/__tests__/helpers/subscription-helper.spec.d.ts +1 -1
  2. package/dist/__tests__/helpers/subscription-helper.spec.js +27 -27
  3. package/dist/clients/generic/cognito-client.d.ts +19 -19
  4. package/dist/clients/generic/cognito-client.js +139 -139
  5. package/dist/clients/generic/dynamodb-client.d.ts +15 -15
  6. package/dist/clients/generic/dynamodb-client.js +122 -122
  7. package/dist/clients/generic/eventbridge-client.d.ts +14 -14
  8. package/dist/clients/generic/eventbridge-client.js +45 -45
  9. package/dist/clients/generic/http-client.d.ts +30 -30
  10. package/dist/clients/generic/http-client.js +28 -28
  11. package/dist/clients/generic/index.d.ts +6 -6
  12. package/dist/clients/generic/index.js +6 -6
  13. package/dist/clients/generic/s3-client.d.ts +6 -6
  14. package/dist/clients/generic/s3-client.js +28 -24
  15. package/dist/clients/generic/s3-client.js.map +1 -1
  16. package/dist/clients/generic/sqs-client.d.ts +14 -14
  17. package/dist/clients/generic/sqs-client.js +34 -34
  18. package/dist/clients/index.d.ts +3 -3
  19. package/dist/clients/index.js +3 -3
  20. package/dist/clients/internal-api/accounts-client.d.ts +82 -82
  21. package/dist/clients/internal-api/accounts-client.js +78 -78
  22. package/dist/clients/internal-api/destinations-client.d.ts +54 -54
  23. package/dist/clients/internal-api/destinations-client.js +36 -36
  24. package/dist/clients/internal-api/index.d.ts +4 -4
  25. package/dist/clients/internal-api/index.js +4 -4
  26. package/dist/clients/internal-api/shopify-app-install-client.d.ts +57 -57
  27. package/dist/clients/internal-api/shopify-app-install-client.js +42 -42
  28. package/dist/clients/internal-api/users-auth-client.d.ts +61 -61
  29. package/dist/clients/internal-api/users-auth-client.js +73 -73
  30. package/dist/clients/third-party/index.d.ts +1 -1
  31. package/dist/clients/third-party/index.js +1 -1
  32. package/dist/clients/third-party/shopify-client.d.ts +90 -90
  33. package/dist/clients/third-party/shopify-client.js +121 -121
  34. package/dist/helpers/index.d.ts +5 -5
  35. package/dist/helpers/index.js +5 -5
  36. package/dist/helpers/input-validation-helper.d.ts +2 -2
  37. package/dist/helpers/input-validation-helper.js +18 -18
  38. package/dist/helpers/logging-helper.d.ts +1 -1
  39. package/dist/helpers/logging-helper.js +9 -9
  40. package/dist/helpers/response-helper.d.ts +36 -36
  41. package/dist/helpers/response-helper.js +35 -35
  42. package/dist/helpers/shopify-helper.d.ts +9 -9
  43. package/dist/helpers/shopify-helper.js +23 -23
  44. package/dist/helpers/subscription-helper.d.ts +8 -8
  45. package/dist/helpers/subscription-helper.js +181 -181
  46. package/dist/index.d.ts +5 -5
  47. package/dist/index.esm.js +6 -2
  48. package/dist/index.esm.js.map +2 -2
  49. package/dist/index.js +5 -5
  50. package/dist/libs/crypto.d.ts +1 -1
  51. package/dist/libs/crypto.js +5 -5
  52. package/dist/libs/dates.d.ts +3 -3
  53. package/dist/libs/dates.js +10 -10
  54. package/dist/libs/http-error.d.ts +21 -21
  55. package/dist/libs/http-error.js +55 -55
  56. package/dist/libs/http-status-codes.d.ts +58 -58
  57. package/dist/libs/http-status-codes.js +59 -59
  58. package/dist/libs/index.d.ts +6 -6
  59. package/dist/libs/index.js +6 -6
  60. package/dist/libs/url.d.ts +1 -1
  61. package/dist/libs/url.js +9 -9
  62. package/dist/services/eventbridge-integration-service.d.ts +9 -9
  63. package/dist/services/eventbridge-integration-service.js +24 -24
  64. package/dist/services/index.d.ts +1 -1
  65. package/dist/services/index.js +1 -1
  66. package/dist/types/api-response.d.ts +6 -6
  67. package/dist/types/api-response.js +1 -1
  68. package/dist/types/index.d.ts +1 -1
  69. package/dist/types/index.js +1 -1
  70. package/dist/types/internal-events/event-detail-types.d.ts +20 -20
  71. package/dist/types/internal-events/event-detail-types.js +24 -24
  72. package/dist/types/internal-events/index.d.ts +1 -1
  73. package/dist/types/internal-events/index.js +1 -1
  74. package/package.json +2 -2
@@ -1,122 +1,122 @@
1
- import { axiosHttpService } from '../generic/http-client.js';
2
- import * as log from 'lambda-log';
3
- export class ShopifyClient {
4
- static _shopify_api_version = process.env.SHOPIFY_API_VERSION;
5
- static getConfig = (shopifyDomain, accessToken) => {
6
- const config = {
7
- baseURL: `https://${shopifyDomain}/admin/api/${this._shopify_api_version}`,
8
- headers: {
9
- common: {
10
- 'X-Shopify-Access-Token': accessToken,
11
- },
12
- },
13
- };
14
- return config;
15
- };
16
- static getClient = (shopifyDomain, accessToken) => {
17
- return axiosHttpService(this.getConfig(shopifyDomain, accessToken));
18
- };
19
- static registerApp = async (shop, code, appKey, appSecret) => {
20
- const client = axiosHttpService();
21
- const url = 'https://' + shop + '/admin/oauth/access_token';
22
- const payload = {
23
- client_id: appKey,
24
- client_secret: appSecret,
25
- code
26
- };
27
- const res = await client.post(url, payload);
28
- return res;
29
- };
30
- static registerWebhookTopic = async (shop, accessToken, eventBridgeArn, topic) => {
31
- const client = axiosHttpService();
32
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/webhooks.json`;
33
- const payload = {
34
- webhook: {
35
- topic,
36
- address: eventBridgeArn,
37
- format: 'json'
38
- }
39
- };
40
- const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
41
- if (res.status >= 400) {
42
- log.error('Failed to register Webhook Topic', { shop, accessToken, eventBridgeArn, topic, url, payload });
43
- }
44
- log.debug('Shopify Client Webhook Registration Response', { registrationResponse: res });
45
- return res;
46
- };
47
- static updateShopifyAppMetafield = async (shop, accessToken, pixelId) => {
48
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/metafields.json`;
49
- const payload = {
50
- metafield: {
51
- namespace: 'adtr',
52
- key: 'adtr.config',
53
- value: pixelId,
54
- type: 'single_line_text_field'
55
- }
56
- };
57
- const res = await this.genericShopifyPost(url, accessToken, payload);
58
- if (res.status >= 400) {
59
- log.error('Failed to update Shopify app Metafield ', { shop, accessToken, url, payload });
60
- }
61
- return res;
62
- };
63
- static getShopifyStoreProperties = async (shop, accessToken) => {
64
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/shop.json`;
65
- const res = await this.genericShopifyGet(url, accessToken);
66
- if (res.status >= 400) {
67
- log.error('Failed to get Shopify Store Properties', { shop, accessToken, url });
68
- }
69
- return res;
70
- };
71
- static createAppSubscription = async (shop, accessToken, planName, price, returnUrl, trialDays, test) => {
72
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
73
- const recurring_application_charge = {
74
- name: planName,
75
- price,
76
- return_url: returnUrl,
77
- trial_days: trialDays,
78
- test
79
- };
80
- const res = await this.genericShopifyPost(url, accessToken, { recurring_application_charge });
81
- if (res.status >= 400) {
82
- log.error('Failed to create App Subscription', { shop, accessToken, url });
83
- }
84
- return res;
85
- };
86
- static cancelAppSubscription = async (shop, accessToken, chargeId) => {
87
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges/${chargeId}.json`;
88
- const client = axiosHttpService();
89
- const res = await client.delete(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
90
- if (res.status !== 200) {
91
- log.error('Failed to cancel recurring App billing', { shop, accessToken, url });
92
- }
93
- return res;
94
- };
95
- static listAppSubscriptions = async (shop, accessToken) => {
96
- const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
97
- const res = await this.genericShopifyGet(url, accessToken);
98
- if (res.status >= 400) {
99
- log.error('Failed to get App Subscriptions', { shop, accessToken, url });
100
- }
101
- return res;
102
- };
103
- static genericShopifyPost = async (url, accessToken, payload) => {
104
- const client = axiosHttpService();
105
- const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken, 'Content-Type': 'application/json' } });
106
- log.debug('Shopify Client Response', { res });
107
- return res;
108
- };
109
- static genericShopifyGet = async (url, accessToken) => {
110
- const client = axiosHttpService();
111
- const res = await client.get(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
112
- log.debug('Shopify Client Response', { res });
113
- return res;
114
- };
115
- static genericShopifyPut = async (url, accessToken, payload) => {
116
- const client = axiosHttpService();
117
- const res = await client.put(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
118
- log.debug('Shopify Client Response', { res });
119
- return res;
120
- };
121
- }
1
+ import { axiosHttpService } from '../generic/http-client.js';
2
+ import * as log from 'lambda-log';
3
+ export class ShopifyClient {
4
+ static _shopify_api_version = process.env.SHOPIFY_API_VERSION;
5
+ static getConfig = (shopifyDomain, accessToken) => {
6
+ const config = {
7
+ baseURL: `https://${shopifyDomain}/admin/api/${this._shopify_api_version}`,
8
+ headers: {
9
+ common: {
10
+ 'X-Shopify-Access-Token': accessToken,
11
+ },
12
+ },
13
+ };
14
+ return config;
15
+ };
16
+ static getClient = (shopifyDomain, accessToken) => {
17
+ return axiosHttpService(this.getConfig(shopifyDomain, accessToken));
18
+ };
19
+ static registerApp = async (shop, code, appKey, appSecret) => {
20
+ const client = axiosHttpService();
21
+ const url = 'https://' + shop + '/admin/oauth/access_token';
22
+ const payload = {
23
+ client_id: appKey,
24
+ client_secret: appSecret,
25
+ code
26
+ };
27
+ const res = await client.post(url, payload);
28
+ return res;
29
+ };
30
+ static registerWebhookTopic = async (shop, accessToken, eventBridgeArn, topic) => {
31
+ const client = axiosHttpService();
32
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/webhooks.json`;
33
+ const payload = {
34
+ webhook: {
35
+ topic,
36
+ address: eventBridgeArn,
37
+ format: 'json'
38
+ }
39
+ };
40
+ const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
41
+ if (res.status >= 400) {
42
+ log.error('Failed to register Webhook Topic', { shop, accessToken, eventBridgeArn, topic, url, payload });
43
+ }
44
+ log.debug('Shopify Client Webhook Registration Response', { registrationResponse: res });
45
+ return res;
46
+ };
47
+ static updateShopifyAppMetafield = async (shop, accessToken, pixelId) => {
48
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/metafields.json`;
49
+ const payload = {
50
+ metafield: {
51
+ namespace: 'adtr',
52
+ key: 'adtr.config',
53
+ value: pixelId,
54
+ type: 'single_line_text_field'
55
+ }
56
+ };
57
+ const res = await this.genericShopifyPost(url, accessToken, payload);
58
+ if (res.status >= 400) {
59
+ log.error('Failed to update Shopify app Metafield ', { shop, accessToken, url, payload });
60
+ }
61
+ return res;
62
+ };
63
+ static getShopifyStoreProperties = async (shop, accessToken) => {
64
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/shop.json`;
65
+ const res = await this.genericShopifyGet(url, accessToken);
66
+ if (res.status >= 400) {
67
+ log.error('Failed to get Shopify Store Properties', { shop, accessToken, url });
68
+ }
69
+ return res;
70
+ };
71
+ static createAppSubscription = async (shop, accessToken, planName, price, returnUrl, trialDays, test) => {
72
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
73
+ const recurring_application_charge = {
74
+ name: planName,
75
+ price,
76
+ return_url: returnUrl,
77
+ trial_days: trialDays,
78
+ test
79
+ };
80
+ const res = await this.genericShopifyPost(url, accessToken, { recurring_application_charge });
81
+ if (res.status >= 400) {
82
+ log.error('Failed to create App Subscription', { shop, accessToken, url });
83
+ }
84
+ return res;
85
+ };
86
+ static cancelAppSubscription = async (shop, accessToken, chargeId) => {
87
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges/${chargeId}.json`;
88
+ const client = axiosHttpService();
89
+ const res = await client.delete(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
90
+ if (res.status !== 200) {
91
+ log.error('Failed to cancel recurring App billing', { shop, accessToken, url });
92
+ }
93
+ return res;
94
+ };
95
+ static listAppSubscriptions = async (shop, accessToken) => {
96
+ const url = `https://${shop}/admin/api/${this._shopify_api_version}/recurring_application_charges.json`;
97
+ const res = await this.genericShopifyGet(url, accessToken);
98
+ if (res.status >= 400) {
99
+ log.error('Failed to get App Subscriptions', { shop, accessToken, url });
100
+ }
101
+ return res;
102
+ };
103
+ static genericShopifyPost = async (url, accessToken, payload) => {
104
+ const client = axiosHttpService();
105
+ const res = await client.post(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken, 'Content-Type': 'application/json' } });
106
+ log.debug('Shopify Client Response', { res });
107
+ return res;
108
+ };
109
+ static genericShopifyGet = async (url, accessToken) => {
110
+ const client = axiosHttpService();
111
+ const res = await client.get(url, { headers: { 'X-Shopify-Access-Token': accessToken } });
112
+ log.debug('Shopify Client Response', { res });
113
+ return res;
114
+ };
115
+ static genericShopifyPut = async (url, accessToken, payload) => {
116
+ const client = axiosHttpService();
117
+ const res = await client.put(url, payload, { headers: { 'X-Shopify-Access-Token': accessToken } });
118
+ log.debug('Shopify Client Response', { res });
119
+ return res;
120
+ };
121
+ }
122
122
  //# sourceMappingURL=shopify-client.js.map
@@ -1,5 +1,5 @@
1
- export * from './input-validation-helper.js';
2
- export * from './logging-helper.js';
3
- export * from './response-helper.js';
4
- export * from './shopify-helper.js';
5
- export * from './subscription-helper.js';
1
+ export * from './input-validation-helper.js';
2
+ export * from './logging-helper.js';
3
+ export * from './response-helper.js';
4
+ export * from './shopify-helper.js';
5
+ export * from './subscription-helper.js';
@@ -1,6 +1,6 @@
1
- export * from './input-validation-helper.js';
2
- export * from './logging-helper.js';
3
- export * from './response-helper.js';
4
- export * from './shopify-helper.js';
5
- export * from './subscription-helper.js';
1
+ export * from './input-validation-helper.js';
2
+ export * from './logging-helper.js';
3
+ export * from './response-helper.js';
4
+ export * from './shopify-helper.js';
5
+ export * from './subscription-helper.js';
6
6
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import Joi from 'joi';
2
- export declare const validateInput: (schema: Joi.ObjectSchema<any>, input: any) => any;
1
+ import Joi from 'joi';
2
+ export declare const validateInput: (schema: Joi.ObjectSchema<any>, input: any) => any;
@@ -1,19 +1,19 @@
1
- import * as log from 'lambda-log';
2
- import { HttpError } from '../libs/http-error.js';
3
- export const validateInput = (schema, input) => {
4
- const { error, value } = schema.validate(input);
5
- if (error) {
6
- log.info('', { error });
7
- const httperr = HttpError.badRequest('Bad Request', {
8
- errors: error.details.map(detail => ({
9
- message: detail?.message,
10
- key: detail?.context?.key,
11
- path: detail?.path,
12
- }))
13
- });
14
- log.info('', { httperr });
15
- throw httperr;
16
- }
17
- return value;
18
- };
1
+ import * as log from 'lambda-log';
2
+ import { HttpError } from '../libs/http-error.js';
3
+ export const validateInput = (schema, input) => {
4
+ const { error, value } = schema.validate(input);
5
+ if (error) {
6
+ log.info('', { error });
7
+ const httperr = HttpError.badRequest('Bad Request', {
8
+ errors: error.details.map(detail => ({
9
+ message: detail?.message,
10
+ key: detail?.context?.key,
11
+ path: detail?.path,
12
+ }))
13
+ });
14
+ log.info('', { httperr });
15
+ throw httperr;
16
+ }
17
+ return value;
18
+ };
19
19
  //# sourceMappingURL=input-validation-helper.js.map
@@ -1 +1 @@
1
- export declare const configureLogger: (event: any, context: any, debug?: boolean) => void;
1
+ export declare const configureLogger: (event: any, context: any, debug?: boolean) => void;
@@ -1,10 +1,10 @@
1
- import * as log from 'lambda-log';
2
- const stage = process?.env?.STAGE;
3
- export const configureLogger = (event, context, debug = true) => {
4
- log.options.meta.stage = stage;
5
- log.options.meta.source_name = context?.functionName || 'unknown';
6
- log.options.meta.awsRequestId = context?.awsRequestId || 'unknown';
7
- log.options.meta.lambdaEvent = event;
8
- log.options.debug = debug;
9
- };
1
+ import * as log from 'lambda-log';
2
+ const stage = process?.env?.STAGE;
3
+ export const configureLogger = (event, context, debug = true) => {
4
+ log.options.meta.stage = stage;
5
+ log.options.meta.source_name = context?.functionName || 'unknown';
6
+ log.options.meta.awsRequestId = context?.awsRequestId || 'unknown';
7
+ log.options.meta.lambdaEvent = event;
8
+ log.options.debug = debug;
9
+ };
10
10
  //# sourceMappingURL=logging-helper.js.map
@@ -1,36 +1,36 @@
1
- export declare const success: (body: any) => {
2
- statusCode: number;
3
- headers: {
4
- 'Access-Control-Allow-Origin': string;
5
- 'Access-Control-Allow-Credentials': boolean;
6
- 'cache-control': string;
7
- Date: Date;
8
- 'Last-Modified': Date;
9
- 'Access-Control-Allow-Headers': string;
10
- };
11
- body: string;
12
- };
13
- export declare const failure: (error: any, statusCode?: number) => {
14
- statusCode: number;
15
- headers: {
16
- 'Access-Control-Allow-Origin': string;
17
- 'Access-Control-Allow-Credentials': boolean;
18
- 'cache-control': string;
19
- Date: Date;
20
- 'Last-Modified': Date;
21
- 'Access-Control-Allow-Headers': string;
22
- };
23
- body: string;
24
- };
25
- export declare const buildResponse: (statusCode: number, body?: any) => {
26
- statusCode: number;
27
- headers: {
28
- 'Access-Control-Allow-Origin': string;
29
- 'Access-Control-Allow-Credentials': boolean;
30
- 'cache-control': string;
31
- Date: Date;
32
- 'Last-Modified': Date;
33
- 'Access-Control-Allow-Headers': string;
34
- };
35
- body: string;
36
- };
1
+ export declare const success: (body: any) => {
2
+ statusCode: number;
3
+ headers: {
4
+ 'Access-Control-Allow-Origin': string;
5
+ 'Access-Control-Allow-Credentials': boolean;
6
+ 'cache-control': string;
7
+ Date: Date;
8
+ 'Last-Modified': Date;
9
+ 'Access-Control-Allow-Headers': string;
10
+ };
11
+ body: string;
12
+ };
13
+ export declare const failure: (error: any, statusCode?: number) => {
14
+ statusCode: number;
15
+ headers: {
16
+ 'Access-Control-Allow-Origin': string;
17
+ 'Access-Control-Allow-Credentials': boolean;
18
+ 'cache-control': string;
19
+ Date: Date;
20
+ 'Last-Modified': Date;
21
+ 'Access-Control-Allow-Headers': string;
22
+ };
23
+ body: string;
24
+ };
25
+ export declare const buildResponse: (statusCode: number, body?: any) => {
26
+ statusCode: number;
27
+ headers: {
28
+ 'Access-Control-Allow-Origin': string;
29
+ 'Access-Control-Allow-Credentials': boolean;
30
+ 'cache-control': string;
31
+ Date: Date;
32
+ 'Last-Modified': Date;
33
+ 'Access-Control-Allow-Headers': string;
34
+ };
35
+ body: string;
36
+ };
@@ -1,36 +1,36 @@
1
- export const success = (body) => {
2
- return buildResponse(200, body);
3
- };
4
- const defaultError = {
5
- message: 'internalServerError'
6
- };
7
- export const failure = (error, statusCode = 500) => {
8
- statusCode = error?.statusCode ?? statusCode;
9
- let body = defaultError;
10
- if (error?.body) {
11
- body = error.body;
12
- }
13
- else if (error?.message) {
14
- body = { message: error.message };
15
- }
16
- else if (statusCode === 500) {
17
- body = defaultError;
18
- }
19
- return buildResponse(statusCode, body);
20
- };
21
- export const buildResponse = (statusCode, body = {}) => {
22
- delete body.stack;
23
- return {
24
- statusCode: statusCode,
25
- headers: {
26
- 'Access-Control-Allow-Origin': '*',
27
- 'Access-Control-Allow-Credentials': true,
28
- 'cache-control': 'max-age=86400',
29
- Date: new Date(),
30
- 'Last-Modified': new Date(),
31
- 'Access-Control-Allow-Headers': 'Content-Type, Content-Encoding'
32
- },
33
- body: JSON.stringify(body),
34
- };
35
- };
1
+ export const success = (body) => {
2
+ return buildResponse(200, body);
3
+ };
4
+ const defaultError = {
5
+ message: 'internalServerError'
6
+ };
7
+ export const failure = (error, statusCode = 500) => {
8
+ statusCode = error?.statusCode ?? statusCode;
9
+ let body = defaultError;
10
+ if (error?.body) {
11
+ body = error.body;
12
+ }
13
+ else if (error?.message) {
14
+ body = { message: error.message };
15
+ }
16
+ else if (statusCode === 500) {
17
+ body = defaultError;
18
+ }
19
+ return buildResponse(statusCode, body);
20
+ };
21
+ export const buildResponse = (statusCode, body = {}) => {
22
+ delete body.stack;
23
+ return {
24
+ statusCode: statusCode,
25
+ headers: {
26
+ 'Access-Control-Allow-Origin': '*',
27
+ 'Access-Control-Allow-Credentials': true,
28
+ 'cache-control': 'max-age=86400',
29
+ Date: new Date(),
30
+ 'Last-Modified': new Date(),
31
+ 'Access-Control-Allow-Headers': 'Content-Type, Content-Encoding'
32
+ },
33
+ body: JSON.stringify(body),
34
+ };
35
+ };
36
36
  //# sourceMappingURL=response-helper.js.map
@@ -1,9 +1,9 @@
1
- export interface ShopifyRequestValidationParameters {
2
- code: string;
3
- hmac?: string;
4
- shop: string;
5
- state: string;
6
- timestamp: string;
7
- }
8
- export declare const isShopifyRequestValid: (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => boolean;
9
- export declare const validateShopifyRequest: (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => boolean;
1
+ export interface ShopifyRequestValidationParameters {
2
+ code: string;
3
+ hmac?: string;
4
+ shop: string;
5
+ state: string;
6
+ timestamp: string;
7
+ }
8
+ export declare const isShopifyRequestValid: (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => boolean;
9
+ export declare const validateShopifyRequest: (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => boolean;
@@ -1,24 +1,24 @@
1
- import { createHmac } from 'crypto';
2
- import * as log from 'lambda-log';
3
- import { HttpError } from '../libs/http-error.js';
4
- import { mapObjectToQueryString } from '../libs/url.js';
5
- export const isShopifyRequestValid = (validationParams, validationHmac, shopifyAppApiSecret) => {
6
- delete validationParams.hmac;
7
- const hmacString = mapObjectToQueryString(validationParams);
8
- const generatedHash = createHmac('sha256', shopifyAppApiSecret)
9
- .update(hmacString)
10
- .digest('hex');
11
- return generatedHash === validationHmac;
12
- };
13
- export const validateShopifyRequest = (validationParams, validationHmac, shopifyAppApiSecret) => {
14
- log.info('Validating shopify request is authentic', { validationParams });
15
- const isValid = isShopifyRequestValid(validationParams, validationHmac, shopifyAppApiSecret);
16
- if (!isValid) {
17
- const message = 'Failed: Shopify Request hmac validation';
18
- log.error(message);
19
- throw HttpError.badRequest(message);
20
- }
21
- log.info('Sucess: Shopify Request hmac validation');
22
- return true;
23
- };
1
+ import { createHmac } from 'crypto';
2
+ import * as log from 'lambda-log';
3
+ import { HttpError } from '../libs/http-error.js';
4
+ import { mapObjectToQueryString } from '../libs/url.js';
5
+ export const isShopifyRequestValid = (validationParams, validationHmac, shopifyAppApiSecret) => {
6
+ delete validationParams.hmac;
7
+ const hmacString = mapObjectToQueryString(validationParams);
8
+ const generatedHash = createHmac('sha256', shopifyAppApiSecret)
9
+ .update(hmacString)
10
+ .digest('hex');
11
+ return generatedHash === validationHmac;
12
+ };
13
+ export const validateShopifyRequest = (validationParams, validationHmac, shopifyAppApiSecret) => {
14
+ log.info('Validating shopify request is authentic', { validationParams });
15
+ const isValid = isShopifyRequestValid(validationParams, validationHmac, shopifyAppApiSecret);
16
+ if (!isValid) {
17
+ const message = 'Failed: Shopify Request hmac validation';
18
+ log.error(message);
19
+ throw HttpError.badRequest(message);
20
+ }
21
+ log.info('Sucess: Shopify Request hmac validation');
22
+ return true;
23
+ };
24
24
  //# sourceMappingURL=shopify-helper.js.map
@@ -1,8 +1,8 @@
1
- import { SubscriptionPlan } from '@adtrackify/at-tracking-event-types';
2
- export declare const StripeBillingMap: any;
3
- export declare const CommonPlanInfo: string[];
4
- export declare const SubscriptionPlanSeedItems: {
5
- items: SubscriptionPlan[];
6
- };
7
- export declare const getPlanDetails: (planId: number, stage: string) => SubscriptionPlan;
8
- export declare const getPlanByStripePriceId: (stripePriceId: string, stage: string) => SubscriptionPlan;
1
+ import { SubscriptionPlan } from '@adtrackify/at-tracking-event-types';
2
+ export declare const StripeBillingMap: any;
3
+ export declare const CommonPlanInfo: string[];
4
+ export declare const SubscriptionPlanSeedItems: {
5
+ items: SubscriptionPlan[];
6
+ };
7
+ export declare const getPlanDetails: (planId: number, stage: string) => SubscriptionPlan;
8
+ export declare const getPlanByStripePriceId: (stripePriceId: string, stage: string) => SubscriptionPlan;