@agnostack/next-shopify 1.0.0 → 1.1.0-alpha.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 (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/handlers/appUninstalledHandler.d.ts +1 -0
  3. package/dist/handlers/appUninstalledHandler.js +18 -0
  4. package/dist/handlers/appUninstalledHandler.js.map +1 -0
  5. package/dist/handlers/authCallbackHandler.d.ts +9 -0
  6. package/dist/handlers/authCallbackHandler.js +59 -0
  7. package/dist/handlers/authCallbackHandler.js.map +1 -0
  8. package/dist/handlers/authHandler.d.ts +9 -0
  9. package/dist/handlers/authHandler.js +31 -0
  10. package/dist/handlers/authHandler.js.map +1 -0
  11. package/dist/handlers/index.d.ts +3 -0
  12. package/dist/handlers/index.js +16 -0
  13. package/dist/handlers/index.js.map +1 -0
  14. package/dist/index.d.ts +3 -4
  15. package/dist/index.js +3 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/protectRoute.d.ts +15 -0
  18. package/dist/protectRoute.js +45 -0
  19. package/dist/protectRoute.js.map +1 -0
  20. package/dist/utils/display.d.ts +2 -9
  21. package/dist/utils/display.js +9 -37
  22. package/dist/utils/display.js.map +1 -1
  23. package/dist/utils/firebase.d.ts +15 -0
  24. package/dist/utils/firebase.js +94 -0
  25. package/dist/utils/firebase.js.map +1 -0
  26. package/dist/utils/index.d.ts +2 -2
  27. package/dist/utils/index.js +2 -2
  28. package/dist/utils/index.js.map +1 -1
  29. package/dist/utils/shopify.d.ts +69 -0
  30. package/dist/utils/shopify.js +93 -0
  31. package/dist/utils/shopify.js.map +1 -0
  32. package/dist/withShopify.d.ts +4 -0
  33. package/dist/withShopify.js +150 -0
  34. package/dist/withShopify.js.map +1 -0
  35. package/package.json +7 -7
  36. package/dist/utils/data.d.ts +0 -70
  37. package/dist/utils/data.js +0 -270
  38. package/dist/utils/data.js.map +0 -1
  39. package/dist/utils/locations.d.ts +0 -20
  40. package/dist/utils/locations.js +0 -26
  41. package/dist/utils/locations.js.map +0 -1
  42. package/dist/withPlugins.d.ts +0 -6
  43. package/dist/withPlugins.js +0 -38
  44. package/dist/withPlugins.js.map +0 -1
  45. package/dist/withZendeskCLI.d.ts +0 -4
  46. package/dist/withZendeskCLI.js +0 -154
  47. package/dist/withZendeskCLI.js.map +0 -1
  48. package/dist/zendeskCLIHandler.d.ts +0 -1
  49. package/dist/zendeskCLIHandler.js +0 -109
  50. package/dist/zendeskCLIHandler.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [1.1.0-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.0.1-alpha.1...v1.1.0-alpha.1) (2022-11-07)
2
+
3
+
4
+ ### Features
5
+
6
+ * initial implementation of withShopify > serverRuntimeConfig ([8a4771d](https://github.com/agnostack/next-shopify/commit/8a4771db503fa9fcbec15c5690f31f85b154c40e))
7
+ * initial test implementation ([b212bff](https://github.com/agnostack/next-shopify/commit/b212bffc7aa76e12686444a09d3b6af71294a1dc))
8
+
9
+ ## [1.0.1-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.0.0...v1.0.1-alpha.1) (2022-11-07)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * updated broken lock file ([3515c81](https://github.com/agnostack/next-shopify/commit/3515c812f531bcd2f8eca264432346ef748afb0c))
15
+
1
16
  # 1.0.0 (2022-11-07)
2
17
 
3
18
 
@@ -0,0 +1 @@
1
+ export function handleAppUninstalled(_props: any): (shop: any) => Promise<boolean>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleAppUninstalled = void 0;
4
+ // NOTE: typically handling: "/api/webhooks/app/uninstalled"
5
+ const utils_1 = require("../utils");
6
+ // NOTE /api/webhooks/app/uninstalled
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+ const handleAppUninstalled = (_props) => async (shop) => {
9
+ var _a, _b, _c, _d;
10
+ const shopify = utils_1.getInitializedShopify(shop);
11
+ const existingSessions = await ((_b = (_a = shopify.Context.SESSION_STORAGE) === null || _a === void 0 ? void 0 : _a.findSessionsByShop) === null || _b === void 0 ? void 0 : _b.call(_a, shop));
12
+ if (utils_1.arrayNotEmpty(existingSessions)) {
13
+ await ((_d = (_c = shopify.Context.SESSION_STORAGE) === null || _c === void 0 ? void 0 : _c.deleteSessions) === null || _d === void 0 ? void 0 : _d.call(_c, existingSessions.map((session) => session.id)));
14
+ }
15
+ return true;
16
+ };
17
+ exports.handleAppUninstalled = handleAppUninstalled;
18
+ //# sourceMappingURL=appUninstalledHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appUninstalledHandler.js","sourceRoot":"","sources":["../../src/handlers/appUninstalledHandler.js"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,oCAGiB;AAEjB,qCAAqC;AACrC,6DAA6D;AACtD,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;;IAC7D,MAAM,OAAO,GAAG,6BAAqB,CAAC,IAAI,CAAC,CAAA;IAE3C,MAAM,gBAAgB,GAAG,MAAM,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,eAAe,0CAAE,kBAAkB,mDAAG,IAAI,CAAC,CAAA,CAAA;IAC1F,IAAI,qBAAa,CAAC,gBAAgB,CAAC,EAAE;QACnC,MAAM,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,eAAe,0CAAE,cAAc,mDAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA,CAAA;KACvG;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AATY,QAAA,oBAAoB,wBAShC"}
@@ -0,0 +1,9 @@
1
+ export function handleCallback(props: any): (req: any, res: any) => Promise<{
2
+ statusCode: number;
3
+ redirectUrl: string;
4
+ message?: undefined;
5
+ } | {
6
+ statusCode: number;
7
+ message: string;
8
+ redirectUrl?: undefined;
9
+ }>;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleCallback = void 0;
4
+ // NOTE: typically handling: "/api/auth/callback"
5
+ const utils_1 = require("../utils");
6
+ // NOTE: api routes do NOT work in `next export`
7
+ const handleCallback = (props) => async (req, res) => {
8
+ const { PAGE_PATHS, APP_WEBHOOKS } = props;
9
+ const { shop, host } = req.query;
10
+ if (!shop || !host) {
11
+ return {
12
+ statusCode: 303,
13
+ redirectUrl: `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?code=invalid_callback`,
14
+ };
15
+ }
16
+ const shopify = utils_1.getInitializedShopify(props, shop);
17
+ try {
18
+ const session = await shopify.Auth.validateAuthCallback(req, res, req.query);
19
+ await utils_1.registerWebhooks(props, APP_WEBHOOKS, session);
20
+ // TODO check for billing redirect
21
+ const redirectUrl = shopify.Utils.getEmbeddedAppUrl(req);
22
+ return {
23
+ statusCode: 302,
24
+ redirectUrl: `${redirectUrl}?${new URLSearchParams(req.query).toString()}`,
25
+ };
26
+ }
27
+ catch (error) {
28
+ const errorMessage = 'Error handling callback route';
29
+ console.error(errorMessage, error);
30
+ switch (true) {
31
+ case error instanceof shopify.Errors.InvalidOAuthError: {
32
+ return {
33
+ statusCode: 400,
34
+ message: errorMessage,
35
+ };
36
+ }
37
+ case error instanceof shopify.Errors.CookieNotFound:
38
+ case error instanceof shopify.Errors.SessionNotFound: {
39
+ return {
40
+ statusCode: 302,
41
+ redirectUrl: utils_1.getRedirectUrl(props, {
42
+ req,
43
+ res,
44
+ shop,
45
+ query: req.query,
46
+ }),
47
+ };
48
+ }
49
+ default: {
50
+ return {
51
+ statusCode: 500,
52
+ message: errorMessage,
53
+ };
54
+ }
55
+ }
56
+ }
57
+ };
58
+ exports.handleCallback = handleCallback;
59
+ //# sourceMappingURL=authCallbackH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,KAAK,KAAK,YAAY,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBACtD,OAAO;oBACL,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,YAAY;iBACtB,CAAA;aACF;YAED,KAAK,KAAK,YAAY,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC;YACpD,KAAK,KAAK,YAAY,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;gBACpD,OAAO;oBACL,UAAU,EAAE,GAAG;oBACf,WAAW,EAAE,sBAAc,CAAC,KAAK,EAAE;wBACjC,GAAG;wBACH,GAAG;wBACH,IAAI;wBACJ,KAAK,EAAE,GAAG,CAAC,KAAK;qBACjB,CAAC;iBACH,CAAA;aACF;YAED,OAAO,CAAC,CAAC;gBACP,OAAO;oBACL,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,YAAY;iBACtB,CAAA;aACF;SACF;KACF;AACH,CAAC,CAAA;AA3DY,QAAA,cAAc,kBA2D1B"}
@@ -0,0 +1,9 @@
1
+ export function handleAuth(props: any): (req: any, res: any) => Promise<{
2
+ statusCode: number;
3
+ redirectUrl: string;
4
+ message?: undefined;
5
+ } | {
6
+ statusCode: number;
7
+ message: string;
8
+ redirectUrl?: undefined;
9
+ }>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleAuth = void 0;
4
+ // NOTE: typically handling: "/api/auth"
5
+ const utils_1 = require("../utils");
6
+ // NOTE: api routes do NOT work in `next export`
7
+ const handleAuth = (props) => async (req, res) => {
8
+ const { query } = req;
9
+ const { shop } = query !== null && query !== void 0 ? query : {};
10
+ try {
11
+ return {
12
+ statusCode: 302,
13
+ redirectUrl: utils_1.getRedirectUrl(props, {
14
+ req,
15
+ res,
16
+ query,
17
+ shop,
18
+ }),
19
+ };
20
+ }
21
+ catch (error) {
22
+ const errorMessage = 'Error handling auth route';
23
+ console.error(errorMessage, error);
24
+ return {
25
+ statusCode: 500,
26
+ message: errorMessage,
27
+ };
28
+ }
29
+ };
30
+ exports.handleAuth = handleAuth;
31
+ //# sourceMappingURL=authHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authHandler.js","sourceRoot":"","sources":["../../src/handlers/authHandler.js"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,oCAAyC;AAEzC,gDAAgD;AACzC,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IACtD,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;IACrB,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAA;IAE5B,IAAI;QACF,OAAO;YACL,UAAU,EAAE,GAAG;YACf,WAAW,EAAE,sBAAc,CAAC,KAAK,EAAE;gBACjC,GAAG;gBACH,GAAG;gBACH,KAAK;gBACL,IAAI;aACL,CAAC;SACH,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,GAAG,2BAA2B,CAAA;QAChD,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;QAElC,OAAO;YACL,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,YAAY;SACtB,CAAA;KACF;AACH,CAAC,CAAA;AAvBY,QAAA,UAAU,cAuBtB"}
@@ -0,0 +1,3 @@
1
+ export * from "./appUninstalledHandler";
2
+ export * from "./authCallbackHandler";
3
+ export * from "./authHandler";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./appUninstalledHandler"), exports);
14
+ __exportStar(require("./authCallbackHandler"), exports);
15
+ __exportStar(require("./authHandler"), exports);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAuC;AACvC,wDAAqC;AACrC,gDAA6B"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { deepmerge, generateReplacements, arrowsReplace, getAppData, cleanURL, PRODUCTS, LOCATIONS } from './utils';
2
- export * from './withPlugins';
3
- export * from './withZendeskCLI';
4
- export * from './zendeskCLIHandler';
1
+ export * from './handlers';
2
+ export * from './protectRoute';
3
+ export * from './withShopify';
package/dist/index.js CHANGED
@@ -10,16 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.LOCATIONS = exports.PRODUCTS = exports.cleanURL = exports.getAppData = exports.arrowsReplace = exports.generateReplacements = exports.deepmerge = void 0;
14
- var utils_1 = require("./utils");
15
- Object.defineProperty(exports, "deepmerge", { enumerable: true, get: function () { return utils_1.deepmerge; } });
16
- Object.defineProperty(exports, "generateReplacements", { enumerable: true, get: function () { return utils_1.generateReplacements; } });
17
- Object.defineProperty(exports, "arrowsReplace", { enumerable: true, get: function () { return utils_1.arrowsReplace; } });
18
- Object.defineProperty(exports, "getAppData", { enumerable: true, get: function () { return utils_1.getAppData; } });
19
- Object.defineProperty(exports, "cleanURL", { enumerable: true, get: function () { return utils_1.cleanURL; } });
20
- Object.defineProperty(exports, "PRODUCTS", { enumerable: true, get: function () { return utils_1.PRODUCTS; } });
21
- Object.defineProperty(exports, "LOCATIONS", { enumerable: true, get: function () { return utils_1.LOCATIONS; } });
22
- __exportStar(require("./withPlugins"), exports);
23
- __exportStar(require("./withZendeskCLI"), exports);
24
- __exportStar(require("./zendeskCLIHandler"), exports);
13
+ __exportStar(require("./handlers"), exports);
14
+ __exportStar(require("./protectRoute"), exports);
15
+ __exportStar(require("./withShopify"), exports);
25
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAQgB;AAPd,kGAAA,SAAS,OAAA;AACT,6GAAA,oBAAoB,OAAA;AACpB,sGAAA,aAAa,OAAA;AACb,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,kGAAA,SAAS,OAAA;AAEX,gDAA6B;AAC7B,mDAAgC;AAChC,sDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B;AAC1B,iDAA8B;AAC9B,gDAA6B"}
@@ -0,0 +1,15 @@
1
+ export function protectRoute(props: any): ({ req, res, query, locale }: {
2
+ req: any;
3
+ res: any;
4
+ query: any;
5
+ locale: any;
6
+ }, data: any) => Promise<{
7
+ redirect: {
8
+ destination: string;
9
+ permanent: boolean;
10
+ };
11
+ props?: undefined;
12
+ } | {
13
+ props: any;
14
+ redirect?: undefined;
15
+ }>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.protectRoute = void 0;
4
+ const utils_1 = require("./utils");
5
+ const protectRoute = (props) => async ({ req, res, query, locale } = {}, data) => {
6
+ var _a, _b;
7
+ const { PAGE_PATHS } = props;
8
+ const { shop, embedded } = query !== null && query !== void 0 ? query : {};
9
+ if (!shop) {
10
+ return {
11
+ redirect: {
12
+ destination: `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?code=no_shop_provided`,
13
+ permanent: false,
14
+ },
15
+ };
16
+ }
17
+ const shopify = utils_1.getInitializedShopify(props, shop);
18
+ const shopSessions = await ((_b = (_a = shopify.Context.SESSION_STORAGE) === null || _a === void 0 ? void 0 : _a.findSessionsByShop) === null || _b === void 0 ? void 0 : _b.call(_a, shop));
19
+ if (utils_1.arrayEmpty(shopSessions)) {
20
+ return {
21
+ redirect: {
22
+ destination: utils_1.getRedirectUrl(props, {
23
+ req,
24
+ res,
25
+ query,
26
+ shop,
27
+ }),
28
+ permanent: false,
29
+ },
30
+ };
31
+ }
32
+ if (embedded !== '1') {
33
+ return {
34
+ redirect: {
35
+ destination: shopify.Utils.getEmbeddedAppUrl(req),
36
+ permanent: false,
37
+ },
38
+ };
39
+ }
40
+ return {
41
+ props: Object.assign({ locale }, data),
42
+ };
43
+ };
44
+ exports.protectRoute = protectRoute;
45
+ //# sourceMappingURL=protectRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protectRoute.js","sourceRoot":"","sources":["../src/protectRoute.js"],"names":[],"mappings":";;;AAAA,mCAKgB;AAET,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE;;IACtF,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IAE5B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAA;IACtC,IAAI,CAAC,IAAI,EAAE;QACT,OAAO;YACL,QAAQ,EAAE;gBACR,WAAW,EAAE,GAAG,UAAU,CAAC,wBAAgB,CAAC,KAAK,CAAC,wBAAwB;gBAC1E,SAAS,EAAE,KAAK;aACjB;SACF,CAAA;KACF;IAED,MAAM,OAAO,GAAG,6BAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAClD,MAAM,YAAY,GAAG,MAAM,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,eAAe,0CAAE,kBAAkB,mDAAG,IAAI,CAAC,CAAA,CAAA;IAEtF,IAAI,kBAAU,CAAC,YAAY,CAAC,EAAE;QAC5B,OAAO;YACL,QAAQ,EAAE;gBACR,WAAW,EAAE,sBAAc,CAAC,KAAK,EAAE;oBACjC,GAAG;oBACH,GAAG;oBACH,KAAK;oBACL,IAAI;iBACL,CAAC;gBACF,SAAS,EAAE,KAAK;aACjB;SACF,CAAA;KACF;IAED,IAAI,QAAQ,KAAK,GAAG,EAAE;QACpB,OAAO;YACL,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC;gBACjD,SAAS,EAAE,KAAK;aACjB;SACF,CAAA;KACF;IAED,OAAO;QACL,KAAK,kBACH,MAAM,IACH,IAAI,CACR;KACF,CAAA;AACH,CAAC,CAAA;AA7CY,QAAA,YAAY,gBA6CxB"}
@@ -1,16 +1,9 @@
1
- export { default as deepmerge } from "deepmerge";
2
1
  export function getGUID(): any;
3
2
  export function getInteger(): any;
4
- export function isType(value: any, type: any): boolean;
5
3
  export function ensureString(string: any): string;
6
4
  export function ensureArray(array?: any[]): any[];
7
- export function ensureObject(object: any): any;
8
- export function objectEmpty(object: any): boolean;
9
- export function objectNotEmpty(object: any): boolean;
10
- export function cleanObject(object: any): any;
11
- export function cleanURL(string: any): string;
12
- export function removeLeadingSlash(string: any): string;
13
- export function removeTrailingSlash(string: any): string;
14
5
  export function stringNotEmpty(stringable: any): boolean;
15
6
  export function stringEmpty(stringable: any): boolean;
7
+ export function arrayEmpty(array: any, disableEmptyString?: boolean): boolean;
8
+ export function arrayNotEmpty(array: any, disableEmptyString?: boolean): boolean;
16
9
  export function isTrue(value: any, falsy: any): boolean;
@@ -1,21 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isTrue = exports.stringEmpty = exports.stringNotEmpty = exports.removeTrailingSlash = exports.removeLeadingSlash = exports.cleanURL = exports.cleanObject = exports.objectNotEmpty = exports.objectEmpty = exports.ensureObject = exports.ensureArray = exports.ensureString = exports.isType = exports.getInteger = exports.getGUID = exports.deepmerge = void 0;
3
+ exports.isTrue = exports.arrayNotEmpty = exports.arrayEmpty = exports.stringEmpty = exports.stringNotEmpty = exports.ensureArray = exports.ensureString = exports.getInteger = exports.getGUID = void 0;
7
4
  /* eslint-disable no-use-before-define */
8
5
  const uuid_1 = require("uuid");
9
- var deepmerge_1 = require("deepmerge");
10
- Object.defineProperty(exports, "deepmerge", { enumerable: true, get: function () { return __importDefault(deepmerge_1).default; } });
11
6
  const getGUID = () => (uuid_1.v4());
12
7
  exports.getGUID = getGUID;
13
8
  const getInteger = () => (exports.getGUID().replace(/\D/g, ''));
14
9
  exports.getInteger = getInteger;
15
- const isType = (value, type) => (
16
- // eslint-disable-next-line eqeqeq, valid-typeof
17
- value != undefined && typeof value === type);
18
- exports.isType = isType;
19
10
  // TODO: keep in sync w/ lib-core
20
11
  const ensureString = (string) => (string ? `${string}` : '');
21
12
  exports.ensureString = ensureString;
@@ -23,33 +14,6 @@ const ensureArray = (array = []) => (
23
14
  // eslint-disable-next-line no-nested-ternary
24
15
  !array ? [] : Array.isArray(array) ? array : [array]);
25
16
  exports.ensureArray = ensureArray;
26
- const ensureObject = (object) => (object !== null && object !== void 0 ? object : {});
27
- exports.ensureObject = ensureObject;
28
- const objectEmpty = (object) => (!object || !Object.keys(object).length);
29
- exports.objectEmpty = objectEmpty;
30
- const objectNotEmpty = (object) => (!exports.objectEmpty(object));
31
- exports.objectNotEmpty = objectNotEmpty;
32
- const cleanObject = (object) => (Object.entries(exports.ensureObject(object)).reduce((_cleanedObject, [key, _value]) => {
33
- // eslint-disable-next-line eqeqeq
34
- if (_value == undefined) {
35
- return _cleanedObject; // skip key if null or undefined
36
- }
37
- const value = Array.isArray(_value)
38
- ? _value.reduce((_data, __value) => ([
39
- ..._data,
40
- cleanObjectValue(__value)
41
- ]), [])
42
- : cleanObjectValue(_value);
43
- return Object.assign(Object.assign({}, _cleanedObject), { [key]: value });
44
- }, {}));
45
- exports.cleanObject = cleanObject;
46
- const cleanObjectValue = (value) => (exports.isType(value, 'object') ? exports.cleanObject(value) : value);
47
- const cleanURL = (string) => (exports.ensureString(string).replace(/(?<!:)\/+/gm, '/'));
48
- exports.cleanURL = cleanURL;
49
- const removeLeadingSlash = (string) => (exports.ensureString(string).replace(/^\//, ''));
50
- exports.removeLeadingSlash = removeLeadingSlash;
51
- const removeTrailingSlash = (string) => (exports.ensureString(string).replace(/\/+$/, ''));
52
- exports.removeTrailingSlash = removeTrailingSlash;
53
17
  const stringNotEmpty = (stringable) => {
54
18
  const string = exports.ensureString(stringable);
55
19
  return ((string.length > 0) && !['null', 'undefined'].includes(string));
@@ -57,6 +21,14 @@ const stringNotEmpty = (stringable) => {
57
21
  exports.stringNotEmpty = stringNotEmpty;
58
22
  const stringEmpty = (stringable) => (!exports.stringNotEmpty(stringable));
59
23
  exports.stringEmpty = stringEmpty;
24
+ const arrayEmpty = (array, disableEmptyString = false) => (
25
+ // eslint-disable-next-line eqeqeq
26
+ !array || !array.length || (array.length === 1 && (array[0] == undefined || (disableEmptyString && exports.stringEmpty(array[0])))));
27
+ exports.arrayEmpty = arrayEmpty;
28
+ const arrayNotEmpty = (array, disableEmptyString = false) => (
29
+ // eslint-disable-next-line eqeqeq
30
+ !exports.arrayEmpty(array) && array[0] != undefined && (!disableEmptyString || exports.stringNotEmpty(array[0])));
31
+ exports.arrayNotEmpty = arrayNotEmpty;
60
32
  const isTrue = (value, falsy) => {
61
33
  const string = exports.ensureString(value);
62
34
  return ![...exports.ensureAr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,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,IAAI,CAAC,kBAAkB,IAAI,mBAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC5H,CAAA;AAHY,QAAA,UAAU,cAGtB;AAEM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,EAAE,EAAE,CAAC;AAClE,kCAAkC;AAClC,CAAC,kBAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,IAAI,CAAC,CAAC,kBAAkB,IAAI,sBAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CACjG,CAAA;AAHY,QAAA,aAAa,iBAGzB;AAEM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACrC,MAAM,MAAM,GAAG,oBAAY,CAAC,KAAK,CAAC,CAAA;IAClC,OAAO,CAAC,CAAC,GAAG,mBAAW,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC/D,CAAC,CAAA;AAHY,QAAA,MAAM,UAGlB"}
@@ -0,0 +1,15 @@
1
+ export class FirebaseSessionHandler {
2
+ constructor(config: any, { app, shop, collection }?: {
3
+ app: any;
4
+ shop: any;
5
+ collection?: string;
6
+ });
7
+ app: any;
8
+ shop: any;
9
+ collection: string;
10
+ firestore: import("firebase/firestore/lite").Firestore;
11
+ }
12
+ export function storeCallback(session: any, handler: any): Promise<boolean>;
13
+ export function loadCallback(sessionId: any, handler: any): Promise<import("firebase/firestore/lite").DocumentData>;
14
+ export function deleteSessionsCallback(sessionIds: any, handler: any): Promise<void>;
15
+ export function findSessionsByShop(shop: any, handler: any): Promise<any[]>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.findSessionsByShop = exports.deleteSessionsCallback = exports.loadCallback = exports.storeCallback = exports.FirebaseSessionHandler = void 0;
15
+ const app_1 = require("firebase/app");
16
+ // import { initializeApp } from 'firebase-admin/app' // TODO!!!: move to firebase-admin
17
+ const lite_1 = require("firebase/firestore/lite");
18
+ const display_1 = require("./display");
19
+ const COLLECTION_ROOT = 'oauth-data';
20
+ class FirebaseSessionHandler {
21
+ constructor(config, { app, shop, collection = COLLECTION_ROOT } = {}) {
22
+ this.app = app;
23
+ this.shop = shop;
24
+ this.collection = collection;
25
+ this.firestore = lite_1.getFirestore(app_1.initializeApp(config));
26
+ }
27
+ }
28
+ exports.FirebaseSessionHandler = FirebaseSessionHandler;
29
+ const storeCallback = async (session, handler) => {
30
+ try {
31
+ const docRef = lite_1.doc(handler.firestore, handler.collection, handler.shop, handler.app, session.id);
32
+ const _a = JSON.parse(JSON.stringify(session)), { onlineAccessInfo: _onlineAccessInfo } = _a, docData = __rest(_a, ["onlineAccessInfo"]);
33
+ // NOTE: destructuring out associated_user for DPA compliance
34
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
+ const _b = _onlineAccessInfo !== null && _onlineAccessInfo !== void 0 ? _onlineAccessInfo : {}, { associated_user } = _b, onlineAccessInfo = __rest(_b, ["associated_user"]);
36
+ await lite_1.setDoc(docRef, Object.assign({ onlineAccessInfo }, docData));
37
+ return true;
38
+ }
39
+ catch (err) {
40
+ console.error(`storeCallback error`, err);
41
+ throw err;
42
+ }
43
+ };
44
+ exports.storeCallback = storeCallback;
45
+ const loadCallback = async (sessionId, handler) => {
46
+ try {
47
+ const docRef = lite_1.doc(handler.firestore, handler.collection, handler.shop, handler.app, sessionId);
48
+ const document = await lite_1.getDoc(docRef);
49
+ if (document.exists()) {
50
+ return document.data();
51
+ }
52
+ return undefined;
53
+ }
54
+ catch (err) {
55
+ console.error(`loadCallback error`, err);
56
+ throw err;
57
+ }
58
+ };
59
+ exports.loadCallback = loadCallback;
60
+ const deleteSessionsCallback = async (sessionIds, handler) => {
61
+ const _deleteSessionCallback = async (_sessionId) => {
62
+ try {
63
+ const docRef = lite_1.doc(handler.firestore, handler.collection, handler.shop, handler.app, _sessionId);
64
+ await lite_1.deleteDoc(docRef);
65
+ return true;
66
+ }
67
+ catch (err) {
68
+ console.error(`deleteSessionsCallback error`, err);
69
+ throw err;
70
+ }
71
+ };
72
+ await Promise.all(display_1.ensureArray(sessionIds).map((sessionId) => _deleteSessionCallback(sessionId)));
73
+ };
74
+ exports.deleteSessionsCallback = deleteSessionsCallback;
75
+ const findSessionsByShop = async (shop, handler) => {
76
+ if (!shop) {
77
+ return [];
78
+ }
79
+ try {
80
+ const colRef = lite_1.collection(handler.firestore, handler.collection, shop, handler.app);
81
+ const querySnapshot = await lite_1.getDocs(colRef);
82
+ const data = [];
83
+ querySnapshot.forEach((_doc) => {
84
+ data.push(_doc.data());
85
+ });
86
+ return data;
87
+ }
88
+ catch (err) {
89
+ console.error(`findSessionsByShop error`, err);
90
+ throw err;
91
+ }
92
+ };
93
+ exports.findSessionsByShop = findSessionsByShop;
94
+ //# sourceMappingURL=firebase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../../src/utils/firebase.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sCAA4C;AAC5C,wFAAwF;AACxF,kDAQgC;AAEhC,uCAAuC;AAEvC,MAAM,eAAe,GAAG,YAAY,CAAA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AAG,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IACxD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAA;KACV;IAED,IAAI;QACF,MAAM,MAAM,GAAG,iBAAU,CACvB,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,UAAU,EAClB,IAAI,EACJ,OAAO,CAAC,GAAG,CACZ,CAAA;QAED,MAAM,aAAa,GAAG,MAAM,cAAO,CAAC,MAAM,CAAC,CAAA;QAC3C,MAAM,IAAI,GAAG,EAAE,CAAA;QACf,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACxB,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;KACZ;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAA;QAC9C,MAAM,GAAG,CAAA;KACV;AACH,CAAC,CAAA;AAxBY,QAAA,kBAAkB,sBAwB9B"}
@@ -1,3 +1,3 @@
1
- export * from "./data";
2
1
  export * from "./display";
3
- export * from "./locations";
2
+ export * from "./firebase";
3
+ export * from "./shopify";
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./data"), exports);
14
13
  __exportStar(require("./display"), exports);
15
- __exportStar(require("./locations"), exports);
14
+ __exportStar(require("./firebase"), exports);
15
+ __exportStar(require("./shopify"), exports);
16
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,4CAAyB;AACzB,8CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAyB;AACzB,6CAA0B;AAC1B,4CAAyB"}
@@ -0,0 +1,69 @@
1
+ /// <reference types="node" />
2
+ export namespace PAGE_ROUTE_NAMES {
3
+ const EXIT: string;
4
+ const ERROR: string;
5
+ }
6
+ export namespace API_ROUTE_NAMES {
7
+ const AUTH: string;
8
+ const AUTH_CALLBACK: string;
9
+ const APP_UNINSTALLED: string;
10
+ }
11
+ export function getInitializedShopify(props: any, _shop: any): {
12
+ Context: import("@shopify/shopify-api/dist/context").ContextInterface;
13
+ Auth: {
14
+ SESSION_COOKIE_NAME: string;
15
+ STATE_COOKIE_NAME: string;
16
+ beginAuth(request: import("http").IncomingMessage, response: import("http").ServerResponse, shop: string, redirectPath: string, isOnline?: boolean): Promise<string>;
17
+ validateAuthCallback(request: import("http").IncomingMessage, response: import("http").ServerResponse, query: import("@shopify/shopify-api").AuthQuery): Promise<import("@shopify/shopify-api").SessionInterface>;
18
+ getCookieSessionId(request: import("http").IncomingMessage, response: import("http").ServerResponse): string;
19
+ getJwtSessionId(shop: string, userId: string): string;
20
+ getOfflineSessionId(shop: string): string;
21
+ getCurrentSessionId(request: import("http").IncomingMessage, response: import("http").ServerResponse, isOnline?: boolean): string;
22
+ };
23
+ Billing: {
24
+ check: typeof import("@shopify/shopify-api/dist/billing/check").check;
25
+ };
26
+ Session: {
27
+ Session: typeof import("@shopify/shopify-api/dist/auth/session/session").Session;
28
+ MemorySessionStorage: typeof import("@shopify/shopify-api/dist/auth/session").MemorySessionStorage;
29
+ CustomSessionStorage: typeof import("@shopify/shopify-api/dist/auth/session").CustomSessionStorage;
30
+ MySQLSessionStorage: typeof import("@shopify/shopify-api/dist/auth/session").MySQLSessionStorage;
31
+ MongoDBSessionStorage: typeof import("@shopify/shopify-api/dist/auth/session").MongoDBSessionStorage;
32
+ PostgreSQLSessionStorage: typeof import("@shopify/shopify-api/dist/auth/session").PostgreSQLSessionStorage;
33
+ RedisSessionStorage: typeof import("@shopify/shopify-api/dist/auth/session").RedisSessionStorage;
34
+ SQLiteSessionStorage: typeof import("@shopify/shopify-api/dist/auth/session").SQLiteSessionStorage;
35
+ };
36
+ Clients: {
37
+ Rest: typeof import("@shopify/shopify-api/dist/clients/rest/rest_client").RestClient;
38
+ Graphql: typeof import("@shopify/shopify-api/dist/clients/graphql").GraphqlClient;
39
+ Storefront: typeof import("@shopify/shopify-api/dist/clients/graphql/storefront_client").StorefrontClient;
40
+ };
41
+ Utils: {
42
+ decodeSessionToken: typeof import("@shopify/shopify-api/dist/utils/decode-session-token").default;
43
+ deleteCurrentSession: typeof import("@shopify/shopify-api/dist/utils/delete-current-session").default;
44
+ deleteOfflineSession: typeof import("@shopify/shopify-api/dist/utils/delete-offline-session").default;
45
+ loadCurrentSession: typeof import("@shopify/shopify-api/dist/utils/load-current-session").default;
46
+ loadOfflineSession: typeof import("@shopify/shopify-api/dist/utils/load-offline-session").default;
47
+ nonce: typeof import("@shopify/shopify-api/dist/utils/nonce").default;
48
+ graphqlProxy: typeof import("@shopify/shopify-api/dist/utils/graphql_proxy").default;
49
+ safeCompare: typeof import("@shopify/shopify-api/dist/utils/safe-compare").default;
50
+ storeSession: typeof import("@shopify/shopify-api/dist/utils/store-session").default;
51
+ validateHmac: typeof import("@shopify/shopify-api/dist/utils/hmac-validator").default;
52
+ sanitizeShop: typeof import("@shopify/shopify-api/dist/utils/shop-validator").sanitizeShop;
53
+ sanitizeHost: typeof import("@shopify/shopify-api/dist/utils/shop-validator").sanitizeHost;
54
+ versionCompatible: typeof import("@shopify/shopify-api/dist/utils/version-compatible").default;
55
+ withSession: typeof import("@shopify/shopify-api/dist/utils/with-session").default;
56
+ getEmbeddedAppUrl: typeof import("@shopify/shopify-api/dist/utils/get-embedded-app-url").default;
57
+ };
58
+ Webhooks: {
59
+ Registry: import("@shopify/shopify-api/dist/webhooks/registry").RegistryInterface;
60
+ };
61
+ Errors: typeof import("@shopify/shopify-api/dist/error");
62
+ };
63
+ export function registerWebhooks(props: any, webhookRegistry: any, session: any): Promise<[any, any, any, any, any, any, any, any, any, any][]>;
64
+ export function getRedirectUrl(props: any, { req, res, query, shop: _shop, }: {
65
+ req: any;
66
+ res: any;
67
+ query: any;
68
+ shop: any;
69
+ }): string;