@agnostack/next-shopify 1.0.1-alpha.1 → 1.1.0-alpha.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [1.1.0-alpha.2](https://github.com/agnostack/next-shopify/compare/v1.1.0-alpha.1...v1.1.0-alpha.2) (2022-11-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * small refactor on apiHandlers ([fc9315d](https://github.com/agnostack/next-shopify/commit/fc9315d4de6c69096399ae1573f8bc2d4982dffe))
7
+
8
+ # [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)
9
+
10
+
11
+ ### Features
12
+
13
+ * initial implementation of withShopify > serverRuntimeConfig ([8a4771d](https://github.com/agnostack/next-shopify/commit/8a4771db503fa9fcbec15c5690f31f85b154c40e))
14
+ * initial test implementation ([b212bff](https://github.com/agnostack/next-shopify/commit/b212bffc7aa76e12686444a09d3b6af71294a1dc))
15
+
1
16
  ## [1.0.1-alpha.1](https://github.com/agnostack/next-shopify/compare/v1.0.0...v1.0.1-alpha.1) (2022-11-07)
2
17
 
3
18
 
@@ -0,0 +1,19 @@
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
+ }>;
10
+ export function handleCallback(props: any): (req: any, res: any) => Promise<{
11
+ statusCode: number;
12
+ redirectUrl: string;
13
+ message?: undefined;
14
+ } | {
15
+ statusCode: number;
16
+ message: string;
17
+ redirectUrl?: undefined;
18
+ }>;
19
+ export function handleAppUninstalled(_props: any): (shop: any) => Promise<boolean>;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleAppUninstalled = exports.handleCallback = exports.handleAuth = void 0;
4
+ // NOTE: api routes do NOT work in `next export`
5
+ const utils_1 = require("./utils");
6
+ // NOTE: typically handling: "/api/auth"
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
+ // NOTE: typically handling: "/api/auth/callback"
32
+ const handleCallback = (props) => async (req, res) => {
33
+ const { PAGE_PATHS, APP_WEBHOOKS } = props;
34
+ const { shop, host } = req.query;
35
+ if (!shop || !host) {
36
+ return {
37
+ statusCode: 303,
38
+ redirectUrl: `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?code=invalid_callback`,
39
+ };
40
+ }
41
+ const shopify = utils_1.getInitializedShopify(props, shop);
42
+ try {
43
+ const session = await shopify.Auth.validateAuthCallback(req, res, req.query);
44
+ await utils_1.registerWebhooks(props, APP_WEBHOOKS, session);
45
+ // TODO check for billing redirect
46
+ const redirectUrl = shopify.Utils.getEmbeddedAppUrl(req);
47
+ return {
48
+ statusCode: 302,
49
+ redirectUrl: `${redirectUrl}?${new URLSearchParams(req.query).toString()}`,
50
+ };
51
+ }
52
+ catch (error) {
53
+ const errorMessage = 'Error handling callback route';
54
+ console.error(errorMessage, error);
55
+ switch (true) {
56
+ case error instanceof shopify.Errors.InvalidOAuthError: {
57
+ return {
58
+ statusCode: 400,
59
+ message: errorMessage,
60
+ };
61
+ }
62
+ case error instanceof shopify.Errors.CookieNotFound:
63
+ case error instanceof shopify.Errors.SessionNotFound: {
64
+ return {
65
+ statusCode: 302,
66
+ redirectUrl: utils_1.getRedirectUrl(props, {
67
+ req,
68
+ res,
69
+ shop,
70
+ query: req.query,
71
+ }),
72
+ };
73
+ }
74
+ default: {
75
+ return {
76
+ statusCode: 500,
77
+ message: errorMessage,
78
+ };
79
+ }
80
+ }
81
+ }
82
+ };
83
+ exports.handleCallback = handleCallback;
84
+ // NOTE: typically handling: "/api/webhooks/app/uninstalled"
85
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
86
+ const handleAppUninstalled = (_props) => async (shop) => {
87
+ var _a, _b, _c, _d;
88
+ const shopify = utils_1.getInitializedShopify(shop);
89
+ 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));
90
+ if (utils_1.arrayNotEmpty(existingSessions)) {
91
+ 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)));
92
+ }
93
+ return true;
94
+ };
95
+ exports.handleAppUninstalled = handleAppUninstalled;
96
+ //# sourceMappingURL=apiHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiHandlers.js","sourceRoot":"","sources":["../src/apiHandlers.js"],"names":[],"mappings":";;;AAAA,gDAAgD;AAChD,mCAMgB;AAEhB,wCAAwC;AACjC,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,IAA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CAAC,EAAE,CAAC,CAAC,CAAA,CAAA;KACvG;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AATY,QAAA,oBAAoB,wBAShC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { generateReplacements, arrowsReplace, getAppData, cleanURL } from './utils';
2
- export * from './withZendeskCLI';
3
- export * from './zendeskCLIHandler';
1
+ export * from './apiHandlers';
2
+ export * from './protectRoute';
3
+ export * from './withShopify';
package/dist/index.js CHANGED
@@ -10,12 +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.cleanURL = exports.getAppData = exports.arrowsReplace = exports.generateReplacements = void 0;
14
- var utils_1 = require("./utils");
15
- Object.defineProperty(exports, "generateReplacements", { enumerable: true, get: function () { return utils_1.generateReplacements; } });
16
- Object.defineProperty(exports, "arrowsReplace", { enumerable: true, get: function () { return utils_1.arrowsReplace; } });
17
- Object.defineProperty(exports, "getAppData", { enumerable: true, get: function () { return utils_1.getAppData; } });
18
- Object.defineProperty(exports, "cleanURL", { enumerable: true, get: function () { return utils_1.cleanURL; } });
19
- __exportStar(require("./withZendeskCLI"), exports);
20
- __exportStar(require("./zendeskCLIHandler"), exports);
13
+ __exportStar(require("./apiHandlers"), exports);
14
+ __exportStar(require("./protectRoute"), exports);
15
+ __exportStar(require("./withShopify"), exports);
21
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,iCAKgB;AAJd,6GAAA,oBAAoB,OAAA;AACpB,sGAAA,aAAa,OAAA;AACb,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AAEV,mDAAgC;AAChC,sDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA6B;AAC7B,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,15 +1,9 @@
1
1
  export function getGUID(): any;
2
2
  export function getInteger(): any;
3
- export function isType(value: any, type: any): boolean;
4
3
  export function ensureString(string: any): string;
5
4
  export function ensureArray(array?: any[]): any[];
6
- export function ensureObject(object: any): any;
7
- export function objectEmpty(object: any): boolean;
8
- export function objectNotEmpty(object: any): boolean;
9
- export function cleanObject(object: any): any;
10
- export function cleanURL(string: any): string;
11
- export function removeLeadingSlash(string: any): string;
12
- export function removeTrailingSlash(string: any): string;
13
5
  export function stringNotEmpty(stringable: any): boolean;
14
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;
15
9
  export function isTrue(value: any, falsy: any): boolean;
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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 = void 0;
3
+ exports.isTrue = exports.arrayNotEmpty = exports.arrayEmpty = exports.stringEmpty = exports.stringNotEmpty = exports.ensureArray = exports.ensureString = exports.getInteger = exports.getGUID = void 0;
4
4
  /* eslint-disable no-use-before-define */
5
5
  const uuid_1 = require("uuid");
6
6
  const getGUID = () => (uuid_1.v4());
7
7
  exports.getGUID = getGUID;
8
8
  const getInteger = () => (exports.getGUID().replace(/\D/g, ''));
9
9
  exports.getInteger = getInteger;
10
- const isType = (value, type) => (
11
- // eslint-disable-next-line eqeqeq, valid-typeof
12
- value != undefined && typeof value === type);
13
- exports.isType = isType;
14
10
  // TODO: keep in sync w/ lib-core
15
11
  const ensureString = (string) => (string ? `${string}` : '');
16
12
  exports.ensureString = ensureString;
@@ -18,33 +14,6 @@ const ensureArray = (array = []) => (
18
14
  // eslint-disable-next-line no-nested-ternary
19
15
  !array ? [] : Array.isArray(array) ? array : [array]);
20
16
  exports.ensureArray = ensureArray;
21
- const ensureObject = (object) => (object !== null && object !== void 0 ? object : {});
22
- exports.ensureObject = ensureObject;
23
- const objectEmpty = (object) => (!object || !Object.keys(object).length);
24
- exports.objectEmpty = objectEmpty;
25
- const objectNotEmpty = (object) => (!exports.objectEmpty(object));
26
- exports.objectNotEmpty = objectNotEmpty;
27
- const cleanObject = (object) => (Object.entries(exports.ensureObject(object)).reduce((_cleanedObject, [key, _value]) => {
28
- // eslint-disable-next-line eqeqeq
29
- if (_value == undefined) {
30
- return _cleanedObject; // skip key if null or undefined
31
- }
32
- const value = Array.isArray(_value)
33
- ? _value.reduce((_data, __value) => ([
34
- ..._data,
35
- cleanObjectValue(__value)
36
- ]), [])
37
- : cleanObjectValue(_value);
38
- return Object.assign(Object.assign({}, _cleanedObject), { [key]: value });
39
- }, {}));
40
- exports.cleanObject = cleanObject;
41
- const cleanObjectValue = (value) => (exports.isType(value, 'object') ? exports.cleanObject(value) : value);
42
- const cleanURL = (string) => (exports.ensureString(string).replace(/(?<!:)\/+/gm, '/'));
43
- exports.cleanURL = cleanURL;
44
- const removeLeadingSlash = (string) => (exports.ensureString(string).replace(/^\//, ''));
45
- exports.removeLeadingSlash = removeLeadingSlash;
46
- const removeTrailingSlash = (string) => (exports.ensureString(string).replace(/\/+$/, ''));
47
- exports.removeTrailingSlash = removeTrailingSlash;
48
17
  const stringNotEmpty = (stringable) => {
49
18
  const string = exports.ensureString(stringable);
50
19
  return ((string.length > 0) && !['null', 'undefined'].includes(string));
@@ -52,6 +21,14 @@ const stringNotEmpty = (stringable) => {
52
21
  exports.stringNotEmpty = stringNotEmpty;
53
22
  const stringEmpty = (stringable) => (!exports.stringNotEmpty(stringable));
54
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;
55
32
  const isTrue = (value, falsy) => {
56
33
  const string = exports.ensureString(value);
57
34
  return ![...exports.ensureArray(falsy), '', 'false'].includes(string);
@@ -1 +1 @@
1
- {"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/utils/display.js"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,+BAAmC;AAE5B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAC3B,SAAM,EAAE,CACT,CAAA;AAFY,QAAA,OAAO,WAEnB;AAEM,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CAC9B,eAAO,EAAE,CAAC,OAAO,CAAC,KAAK,EAAC,EAAE,CAAC,CAC5B,CAAA;AAFY,QAAA,UAAU,cAEtB;AAEM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;AACrC,gDAAgD;AAChD,KAAK,IAAI,SAAS,IAAI,OAAO,KAAK,KAAK,IAAI,CAC5C,CAAA;AAHY,QAAA,MAAM,UAGlB;AAED,iCAAiC;AAC1B,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CACtC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAC1B,CAAA;AAFY,QAAA,YAAY,gBAExB;AAEM,MAAM,WAAW,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC;AACzC,6CAA6C;AAC7C,CAAC,KAAK,CAAC,CAAC,C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+ 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;AAEpC,MAAa,sBAAsB;IACjC,YAAY,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,GAAG,eAAe,EAAE,GAAG,EAAE;QAClE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,SAAS,GAAG,mBAAY,CAC3B,mBAAa,CAAC,MAAM,CAAC,CACtB,CAAA;IACH,CAAC;CACF;AATD,wDASC;AAEM,MAAM,aAAa,GAAG,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IACtD,IAAI;QACF,MAAM,MAAM,GAAG,UAAG,CAChB,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,EAAE,CACX,CAAA;QAED,MAAM,KAAsD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAzF,EAAE,gBAAgB,EAAE,iBAAiB,OAAoD,EAA/C,OAAO,cAAjD,oBAAmD,CAAsC,CAAA;QAC/F,6DAA6D;QAC7D,6DAA6D;QAC7D,MAAM,KAA2C,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,EAAE,EAAlE,EAAE,eAAe,OAAiD,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OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;YAClD,MAAM,GAAG,CAAA;SACV;IACH,CAAC,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,qBAAW,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAC9E,CAAA;AACH,CAAC,CAAA;AArBY,QAAA,sBAAsB,0BAqBlC;AAEM,MAAM,kBAAkB,GAAG,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,2 +1,3 @@
1
- export * from "./data";
2
1
  export * from "./display";
2
+ export * from "./firebase";
3
+ export * from "./shopify";
@@ -10,6 +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);
14
+ __exportStar(require("./firebase"), exports);
15
+ __exportStar(require("./shopify"), exports);
15
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"}
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;