@adtrackify/at-service-common 1.0.36 → 1.0.38

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.
package/dist/index.d.ts CHANGED
@@ -503,6 +503,23 @@ declare module '@adtrackify/at-service-common/libs/index' {
503
503
  export * from '@adtrackify/at-service-common/libs/dates';
504
504
  export * from '@adtrackify/at-service-common/libs/http-error';
505
505
  export * from '@adtrackify/at-service-common/libs/http-status-codes';
506
+ export * from '@adtrackify/at-service-common/libs/shopify';
507
+ export * from '@adtrackify/at-service-common/libs/url';
508
+
509
+ }
510
+ declare module '@adtrackify/at-service-common/libs/shopify' {
511
+ export interface ShopifyRequestValidationParameters {
512
+ code: string;
513
+ hmac?: string;
514
+ shop: string;
515
+ state: string;
516
+ timestamp: string;
517
+ }
518
+ export const validateShopifyAppParameters: (validationParams: ShopifyRequestValidationParameters, validationHmac: string, shopifyAppApiSecret: string) => boolean;
519
+
520
+ }
521
+ declare module '@adtrackify/at-service-common/libs/url' {
522
+ export const mapObjectToQueryString: (inputObj: any) => string;
506
523
 
507
524
  }
508
525
  declare module '@adtrackify/at-service-common/types/api-response' {
package/dist/index.js CHANGED
@@ -628597,6 +628597,28 @@ var HttpStatusCodes = /* @__PURE__ */ ((HttpStatusCodes2) => {
628597
628597
  return HttpStatusCodes2;
628598
628598
  })(HttpStatusCodes || {});
628599
628599
 
628600
+ // src/libs/shopify.ts
628601
+ import { createHmac } from "crypto";
628602
+
628603
+ // src/libs/url.ts
628604
+ var mapObjectToQueryString = (inputObj) => {
628605
+ const qsp = Object.entries(inputObj).sort((a, b) => a[0] < b[0] ? -1 : 1);
628606
+ const urlParams = new URLSearchParams();
628607
+ qsp.map((p) => {
628608
+ urlParams.append(p[0], p[1]);
628609
+ });
628610
+ const qs = urlParams.toString();
628611
+ return qs;
628612
+ };
628613
+
628614
+ // src/libs/shopify.ts
628615
+ var validateShopifyAppParameters = (validationParams, validationHmac, shopifyAppApiSecret) => {
628616
+ delete validationParams.hmac;
628617
+ const hmacString = mapObjectToQueryString(validationParams);
628618
+ const generatedHash = createHmac("sha256", shopifyAppApiSecret).update(hmacString).digest("hex");
628619
+ return generatedHash === validationHmac;
628620
+ };
628621
+
628600
628622
  // src/types/internal-events/event-detail-types.ts
628601
628623
  var ADTRACKIFY_EVENT_TYPES = /* @__PURE__ */ ((ADTRACKIFY_EVENT_TYPES2) => {
628602
628624
  ADTRACKIFY_EVENT_TYPES2["NOTIFY_SHOPIFY_SUBSCRIPTION_CREATED"] = "shopifySubscriptionCreated";
@@ -628628,8 +628650,10 @@ export {
628628
628650
  getCurrentDate,
628629
628651
  getCurrentTimestamp,
628630
628652
  getDateFromTimestamp,
628653
+ mapObjectToQueryString,
628631
628654
  success,
628632
- validateInput
628655
+ validateInput,
628656
+ validateShopifyAppParameters
628633
628657
  };
628634
628658
  /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
628635
628659
  //# sourceMappingURL=index.js.map