cloudcommerce 0.0.44 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/action.yml +8 -6
  3. package/package.json +1 -1
  4. package/packages/api/package.json +1 -1
  5. package/packages/apps/discounts/lib/index.js +3 -0
  6. package/packages/apps/discounts/lib/index.js.map +1 -1
  7. package/packages/apps/discounts/package.json +6 -3
  8. package/packages/apps/discounts/src/index.ts +2 -0
  9. package/packages/cli/package.json +1 -1
  10. package/packages/events/firebase.js +1 -0
  11. package/packages/events/lib/firebase.js +31 -0
  12. package/packages/events/lib/firebase.js.map +1 -0
  13. package/packages/events/lib/index.js +2 -0
  14. package/packages/events/lib/index.js.map +1 -0
  15. package/packages/events/package.json +2 -2
  16. package/packages/events/src/firebase.ts +6 -3
  17. package/packages/firebase/lib/config.js +3 -0
  18. package/packages/firebase/lib/config.js.map +1 -1
  19. package/packages/firebase/lib/env.d.ts +5 -2
  20. package/packages/firebase/lib/env.js +12 -3
  21. package/packages/firebase/lib/env.js.map +1 -1
  22. package/packages/firebase/lib/handlers/auth-callback.d.ts +3 -0
  23. package/packages/firebase/lib/handlers/auth-callback.js +45 -0
  24. package/packages/firebase/lib/handlers/auth-callback.js.map +1 -0
  25. package/packages/firebase/lib/handlers/check-store-events.js +4 -7
  26. package/packages/firebase/lib/handlers/check-store-events.js.map +1 -1
  27. package/packages/firebase/lib/index.d.ts +3 -1
  28. package/packages/firebase/lib/index.js +18 -4
  29. package/packages/firebase/lib/index.js.map +1 -1
  30. package/packages/firebase/package.json +1 -1
  31. package/packages/firebase/src/config.ts +3 -0
  32. package/packages/firebase/src/env.ts +15 -4
  33. package/packages/firebase/src/handlers/auth-callback.ts +49 -0
  34. package/packages/firebase/src/handlers/check-store-events.ts +4 -7
  35. package/packages/firebase/src/index.ts +20 -4
  36. package/packages/modules/lib/firebase.js +3 -6
  37. package/packages/modules/lib/firebase.js.map +1 -1
  38. package/packages/modules/package.json +1 -1
  39. package/packages/modules/src/firebase.ts +3 -6
  40. package/packages/passport/lib/firebase.js +1 -1
  41. package/packages/passport/lib/firebase.js.map +1 -1
  42. package/packages/passport/package.json +1 -1
  43. package/packages/passport/src/firebase.ts +1 -1
  44. package/packages/ssr/package.json +1 -1
  45. package/packages/storefront/package.json +1 -1
  46. package/packages/types/package.json +1 -1
  47. package/pnpm-lock.yaml +24 -10
package/CHANGELOG.md CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.47](https://github.com/ecomplus/cloud-commerce/compare/v0.0.46...v0.0.47) (2022-08-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * Setup app auth callback function to handle installation callback ([12d5780](https://github.com/ecomplus/cloud-commerce/commit/12d57808a8d742b4a29ac2ce3ea1ae3a5af836dc))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **events:** Add root `firebase.js` as complement to pkg named export ([178fd8c](https://github.com/ecomplus/cloud-commerce/commit/178fd8c128ed55b098a28abe70e6c5385043ec89))
16
+ * Set `ECOM_STORE_ID` env from `config.storeId` ([65e806e](https://github.com/ecomplus/cloud-commerce/commit/65e806ee2228392cfa3c9c6a58537e6248d1f862))
17
+
18
+ ### [0.0.46](https://github.com/ecomplus/cloud-commerce/compare/v0.0.45...v0.0.46) (2022-08-05)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * Set Firebase Functions v2 names with one word at all ([23d5f17](https://github.com/ecomplus/cloud-commerce/commit/23d5f17bbeca0bccc14047c6a5fa4a92753ae9b8))
24
+
25
+ ### [0.0.45](https://github.com/ecomplus/cloud-commerce/compare/v0.0.44...v0.0.45) (2022-08-05)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * GH Action must install dependencies of each functions codebase ([0e1212a](https://github.com/ecomplus/cloud-commerce/commit/0e1212a61c455de0e1b698e9086c1df2a6c24fd7))
31
+ * GH Action must install dependencies of each functions codebase ([7379f0e](https://github.com/ecomplus/cloud-commerce/commit/7379f0e01e9ce94a666735e12dd38a29f090d238))
32
+ * GH Action must install optional dependencies for functions deploy ([59b281e](https://github.com/ecomplus/cloud-commerce/commit/59b281e74346dbe360c2810eb9749304214df17c))
33
+ * Set Firebase Functions names with snake case ([2ec6a31](https://github.com/ecomplus/cloud-commerce/commit/2ec6a31a42cd7692f5b004d65dff6d2e0b3bad30))
34
+
5
35
  ### [0.0.44](https://github.com/ecomplus/cloud-commerce/compare/v0.0.43...v0.0.44) (2022-08-05)
6
36
 
7
37
 
package/action.yml CHANGED
@@ -29,17 +29,19 @@ runs:
29
29
 
30
30
  - if: github.event_name == 'push'
31
31
  shell: bash
32
- run: npm i --location=global firebase-tools@^11.2.1
32
+ run: npm i --location=global firebase-tools@11
33
33
 
34
34
  - shell: bash
35
- run: npm ci --only=production
35
+ run: npm ci --omit=dev
36
36
 
37
37
  - shell: bash
38
38
  working-directory: functions
39
- run: npm ci --only=production --no-optional
40
-
41
- - shell: bash
42
- run: npm run build
39
+ run: |
40
+ for d in */ ; do
41
+ cd $d
42
+ npm ci --omit=dev
43
+ cd ..
44
+ done
43
45
 
44
46
  - if: github.event_name == 'push'
45
47
  name: Deploy to Firebase live
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloudcommerce",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",
6
6
  "main": "packages/api/lib/index.js",
7
7
  "author": "E-Com Club Softwares para E-commerce <ti@e-com.club>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -1,6 +1,9 @@
1
+ import { logger } from 'firebase-functions';
2
+
1
3
  export const events = [];
2
4
 
3
5
  export const applyDiscount = async () => {
6
+ logger.info('Hello discounts app');
4
7
  return {};
5
8
  };
6
9
  // # sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAqB,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACtC,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAqB,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-discounts",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce app for complex discount rules",
6
6
  "main": "lib/index.js",
7
7
  "repository": {
@@ -19,9 +19,12 @@
19
19
  "build": "sh ../../../scripts/build-lib.sh"
20
20
  },
21
21
  "dependencies": {
22
- "@cloudcommerce/api": "workspace:*"
22
+ "@cloudcommerce/api": "workspace:*",
23
+ "firebase-admin": "^11.0.1",
24
+ "firebase-functions": "^3.22.0"
23
25
  },
24
26
  "devDependencies": {
25
- "@cloudcommerce/types": "workspace:*"
27
+ "@cloudcommerce/types": "workspace:*",
28
+ "@firebase/app-types": "^0.7.0"
26
29
  }
27
30
  }
@@ -1,7 +1,9 @@
1
1
  import type { AppEventsTopic } from '@cloudcommerce/types';
2
+ import { logger } from 'firebase-functions';
2
3
 
3
4
  export const events: AppEventsTopic[] = [];
4
5
 
5
6
  export const applyDiscount = async () => {
7
+ logger.info('Hello discounts app');
6
8
  return {};
7
9
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/cli",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce CLI tools",
6
6
  "bin": {
7
7
  "cloudcommerce": "./bin/run.mjs"
@@ -0,0 +1 @@
1
+ export * from './lib/firebase.js';
@@ -0,0 +1,31 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ import 'source-map-support/register.js';
3
+ // eslint-disable-next-line import/no-unresolved
4
+ import { initializeApp } from 'firebase-admin/app';
5
+ import functions from 'firebase-functions';
6
+ import config from '@cloudcommerce/firebase/lib/config';
7
+
8
+ const { logger } = functions;
9
+ initializeApp();
10
+ const eventMaxAgeMs = 60000;
11
+ const newOrderTopic = 'orders-new';
12
+ const { httpsFunctionOptions: { region } } = config.get();
13
+
14
+ export const onNewOrder = functions.region(region)
15
+ .runWith({ failurePolicy: true })
16
+ .pubsub.topic(newOrderTopic).onPublish((message, context) => {
17
+ const eventAgeMs = Date.now() - Date.parse(context.timestamp);
18
+ if (eventAgeMs > eventMaxAgeMs) {
19
+ logger.warn(`Dropping event ${context.eventId} with age[ms]: ${eventAgeMs}`);
20
+ return;
21
+ }
22
+ // Hide API key for security
23
+ process.env.ECOM_API_KEY = '***';
24
+ const { json } = message;
25
+ logger.info({
26
+ topic: newOrderTopic,
27
+ eventId: context.eventId,
28
+ json,
29
+ });
30
+ });
31
+ // # sourceMappingURL=firebase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAGjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,E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AAE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/events",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce app events",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/events#readme",
22
22
  "scripts": {
23
- "build": "echo '@ecomplus/events'"
23
+ "build": "sh ../../scripts/build-lib.sh"
24
24
  },
25
25
  "dependencies": {
26
26
  "@cloudcommerce/api": "workspace:*",
@@ -4,15 +4,18 @@ import type { AppEventsTopic } from '@cloudcommerce/types';
4
4
  import 'source-map-support/register.js';
5
5
  // eslint-disable-next-line import/no-unresolved
6
6
  import { initializeApp } from 'firebase-admin/app';
7
- // eslint-disable-next-line import/no-unresolved
8
- import { runWith, logger } from 'firebase-functions';
7
+ import functions from 'firebase-functions';
8
+ import config from '@cloudcommerce/firebase/lib/config';
9
9
 
10
+ const { logger } = functions;
10
11
  initializeApp();
11
12
 
12
13
  const eventMaxAgeMs = 60000;
13
14
  const newOrderTopic: AppEventsTopic = 'orders-new';
15
+ const { httpsFunctionOptions: { region } } = config.get();
14
16
 
15
- export const onNewOrder = runWith({ failurePolicy: true })
17
+ export const onNewOrder = functions.region(region)
18
+ .runWith({ failurePolicy: true })
16
19
  .pubsub.topic(newOrderTopic).onPublish((message, context) => {
17
20
  const eventAgeMs = Date.now() - Date.parse(context.timestamp);
18
21
  if (eventAgeMs > eventMaxAgeMs) {
@@ -29,6 +29,9 @@ export default {
29
29
  },
30
30
  set(config) {
31
31
  self.__config = deepmerge(self.__config, config);
32
+ if (config.storeId) {
33
+ process.env.ECOM_STORE_ID = config.storeId;
34
+ }
32
35
  },
33
36
  };
34
37
  // # sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA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,8BAA8B;QACrC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,YAAY;QAC3C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,gBAAgB;QACvD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,uBAAuB;QAC3E,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,oBAAoB;QAClE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;QAC1C,oBAAoB,EAAE;YACpB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,UAAU;SAChD;QACD,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,KAAK,EAAE,MAAM;aACd;SACF;KACF;CACF,CAAC;AAEF,eAAe;IACb,GAAG;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IACD,GAAG,CAAC,MAAM;QACR,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACjD,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC;SAC5C;IACH,CAAC;CACF,CAAC"}
@@ -1,6 +1,9 @@
1
1
  declare type Env = {
2
- authenticationId: string;
3
- apiKey: string;
2
+ storeId: number;
3
+ apiAuth: {
4
+ authenticationId: string;
5
+ apiKey: string;
6
+ };
4
7
  githubToken?: string;
5
8
  };
6
9
  declare const _default: () => Env;
@@ -1,5 +1,11 @@
1
1
  export default () => {
2
- const { ECOM_AUTHENTICATION_ID, ECOM_API_KEY, GITHUB_TOKEN } = process.env;
2
+ const {
3
+ ECOM_STORE_ID, ECOM_AUTHENTICATION_ID, ECOM_API_KEY, GITHUB_TOKEN,
4
+ } = process.env;
5
+ const storeId = ECOM_STORE_ID && parseInt(ECOM_STORE_ID, 10);
6
+ if (!storeId) {
7
+ throw new Error('ECOM_STORE_ID is not set or not a number');
8
+ }
3
9
  if (!ECOM_AUTHENTICATION_ID) {
4
10
  throw new Error('ECOM_AUTHENTICATION_ID is not set');
5
11
  }
@@ -10,8 +16,11 @@ export default () => {
10
16
  const apiKey = ECOM_API_KEY;
11
17
  const githubToken = GITHUB_TOKEN;
12
18
  const env = {
13
- authenticationId,
14
- apiKey,
19
+ storeId,
20
+ apiAuth: {
21
+ authenticationId,
22
+ apiKey,
23
+ },
15
24
  githubToken,
16
25
  };
17
26
  return env;
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAMA,eAAe,GAAG,EAAE;IAClB,MAAM,EACJ,sBAAsB,EACtB,YAAY,EACZ,YAAY,GACb,GAAG,OAAO,CAAC,GAAG,CAAC;IAChB,IAAI,CAAC,sBAAsB,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IACD,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IACD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC;IAC5B,MAAM,WAAW,GAAG,YAAY,CAAC;IACjC,MAAM,GAAG,GAAQ;QACf,gBAAgB;QAChB,MAAM;QACN,WAAW;KACZ,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AASA,eAAe,GAAG,EAAE;IAClB,MAAM,EACJ,aAAa,EACb,sBAAsB,EACtB,YAAY,EACZ,YAAY,GACb,GAAG,OAAO,CAAC,GAAG,CAAC;IAChB,MAAM,OAAO,GAAG,aAAa,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IACD,IAAI,CAAC,sBAAsB,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;IACD,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;IACD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC;IAC5B,MAAM,WAAW,GAAG,YAAY,CAAC;IACjC,MAAM,GAAG,GAAQ;QACf,OAAO;QACP,OAAO,EAAE;YACP,gBAAgB;YAChB,MAAM;SACP;QACD,WAAW;KACZ,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Request, Response } from 'firebase-functions';
2
+ declare const _default: (req: Request, res: Response) => Promise<void>;
3
+ export default _default;
@@ -0,0 +1,45 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import { getFirestore } from 'firebase-admin/firestore';
3
+ import api from '@cloudcommerce/api';
4
+ import config from '../config.js';
5
+
6
+ export default async (req, res) => {
7
+ const { storeId, apps } = config.get();
8
+ const { body } = req;
9
+ if (Number(req.get('X-Store-ID')) === storeId
10
+ && body && body.store_id === storeId) {
11
+ const { application, authentication } = body;
12
+ if (application && authentication) {
13
+ const matchApp = Object.keys(apps).find((slug) => {
14
+ return apps[slug].appId === application.app_id;
15
+ });
16
+ if (matchApp) {
17
+ const authenticationId = authentication.authentication_id;
18
+ const firestoreDoc = getFirestore().doc(`installedApps/${authenticationId}`);
19
+ const installedApp = await firestoreDoc.get();
20
+ if (installedApp.exists) {
21
+ res.sendStatus(200);
22
+ return;
23
+ }
24
+ const appDataEndpoint = `applications/${application._id}/hidden_data`;
25
+ try {
26
+ await api.patch(appDataEndpoint, {
27
+ __installedAt: new Date().toISOString(),
28
+ }, {
29
+ authenticationId: authentication._id,
30
+ apiKey: authentication.api_key,
31
+ });
32
+ } catch (e) {
33
+ res.sendStatus(403);
34
+ return;
35
+ }
36
+ // Received app authentication is valid
37
+ await firestoreDoc.set({ application, authentication });
38
+ res.sendStatus(201);
39
+ return;
40
+ }
41
+ }
42
+ }
43
+ res.sendStatus(400);
44
+ };
45
+ // # sourceMappingURL=auth-callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-callback.js","sourceRoot":"","sources":["../../src/handlers/auth-callback.ts"],"names":[],"mappings":"AACA,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,GAAoB,MAAM,oBAAoB,CAAC;AACtD,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,eAAe,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,EAAE;IACnD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;IACvC,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;IACrB,IACE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,KAAK,OAAO;WACtC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,EACpC;QACA,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;QAC7C,IAAI,WAAW,IAAI,cAAc,EAAE;YACjC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC;YACjD,CAAC,CAAC,CAAC;YACH,IAAI,QAAQ,EAAE;gBACZ,MAAM,gBAAgB,GAAG,cAAc,CAAC,iBAAiB,CAAC;gBAC1D,MAAM,YAAY,GAAG,YAAY,EAAE,CAAC,GAAG,CAAC,iBAAiB,gBAAgB,EAAE,CAAC,CAAC;gBAC7E,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC;gBAC9C,IAAI,YAAY,CAAC,MAAM,EAAE;oBACvB,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;oBACpB,OAAO;iBACR;gBAED,MAAM,eAAe,GAAgB,gBAAgB,WAAW,CAAC,GAAG,cAAc,CAAC;gBACnF,IAAI;oBACF,MAAM,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE;wBAC/B,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;qBACxC,EAAE;wBACD,gBAAgB,EAAE,cAAc,CAAC,GAAG;wBACpC,MAAM,EAAE,cAAc,CAAC,OAAO;qBAC/B,CAAC,CAAC;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACV,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;oBACpB,OAAO;iBACR;gBAED,uCAAuC;gBACvC,MAAM,YAAY,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;gBACxD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;gBACpB,OAAO;aACR;SACF;KACF;IACD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC,CAAC"}
@@ -1,11 +1,11 @@
1
1
  // eslint-disable-next-line import/no-unresolved
2
2
  import { getFirestore } from 'firebase-admin/firestore';
3
- import { logger } from 'firebase-functions';
3
+ import logger from 'firebase-functions/lib/logger';
4
4
  import api from '@cloudcommerce/api';
5
5
  import getEnv from '../env.js';
6
6
 
7
7
  export default async () => {
8
- const { authenticationId, apiKey } = getEnv();
8
+ const { apiAuth } = getEnv();
9
9
  const eventsSubs = await getFirestore().collection('eventsSubs').get();
10
10
  const listenedEvents = [];
11
11
  eventsSubs.forEach((doc) => {
@@ -20,11 +20,8 @@ export default async () => {
20
20
  'products',
21
21
  'carts',
22
22
  ].forEach(async (resource) => {
23
- const { data: { result } } = await api({
24
- authenticationId,
25
- apiKey,
26
- endpoint: `events/${resource}`,
27
- });
23
+ const { data: { result } } = await api
24
+ .get(`events/${resource}`, apiAuth);
28
25
  logger.info(`${resource} events: `, result);
29
26
  });
30
27
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"check-store-events.js","sourceRoot":"","sources":["../../src/handlers/check-store-events.ts"],"names":[],"mappings":"AACA,gDAAgD;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,eAAe,KAAK,IAAI,EAAE;IACxB,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,MAAM,UAAU,GAAG,MAAM,YAAY,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC;IACvE,MAAM,cAAc,GAAwB,EAAE,CAAC;IAC/C,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACzB,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,EAAc,CAAC;QACxC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC5C,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACrC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IAChC;QACE,QAAQ;QACR,UAAU;QACV,OAAO;KACR,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC3B,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,GAAG,CAAC;YACrC,gBAAgB;YAChB,MAAM;YACN,QAAQ,EAAE,UAAU,QAAoB,EAAE;S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,QAAQ,WAAW,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,3 +1,5 @@
1
1
  import 'source-map-support/register.js';
2
2
  import '@cloudcommerce/api/fetch-polyfill.js';
3
- export declare const cronStoreEvents: import("firebase-functions/v1").CloudFunction<unknown>;
3
+ import functions from 'firebase-functions';
4
+ export declare const cronStoreEvents: functions.CloudFunction<unknown>;
5
+ export declare const appAuthCallback: functions.HttpsFunction;
@@ -4,12 +4,26 @@ import '@cloudcommerce/api/fetch-polyfill.js';
4
4
  // https://github.com/import-js/eslint-plugin-import/issues/1810
5
5
  // eslint-disable-next-line import/no-unresolved
6
6
  import { initializeApp } from 'firebase-admin/app';
7
- import { pubsub } from 'firebase-functions';
7
+ import functions from 'firebase-functions';
8
+ import config from './config.js';
8
9
  import checkStoreEvents from './handlers/check-store-events.js';
10
+ import handleAuthCallback from './handlers/auth-callback.js';
9
11
 
10
12
  initializeApp();
13
+ const { httpsFunctionOptions: { region } } = config.get();
14
+ const functionBuilder = functions
15
+ .region(region)
16
+ .runWith({
17
+ timeoutSeconds: 300,
18
+ memory: '128MB',
19
+ });
11
20
 
12
- export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => {
13
- return checkStoreEvents();
14
- });
21
+ export const cronStoreEvents = functionBuilder.pubsub
22
+ .schedule('* * * * *')
23
+ .onRun(() => {
24
+ return checkStoreEvents();
25
+ });
26
+
27
+ export const appAuthCallback = functionBuilder.https
28
+ .onRequest(handleAuthCallback);
15
29
  // # sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,OAAO,sCAAsC,CAAC;AAC9C,gEAAgE;AAChE,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAA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3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce on Firebase",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -33,5 +33,8 @@ export default {
33
33
  },
34
34
  set(config) {
35
35
  self.__config = deepmerge(self.__config, config);
36
+ if (config.storeId) {
37
+ process.env.ECOM_STORE_ID = config.storeId;
38
+ }
36
39
  },
37
40
  };
@@ -1,15 +1,23 @@
1
1
  type Env = {
2
- authenticationId: string;
3
- apiKey: string;
2
+ storeId: number;
3
+ apiAuth: {
4
+ authenticationId: string;
5
+ apiKey: string;
6
+ },
4
7
  githubToken?: string;
5
8
  };
6
9
 
7
10
  export default () => {
8
11
  const {
12
+ ECOM_STORE_ID,
9
13
  ECOM_AUTHENTICATION_ID,
10
14
  ECOM_API_KEY,
11
15
  GITHUB_TOKEN,
12
16
  } = process.env;
17
+ const storeId = ECOM_STORE_ID && parseInt(ECOM_STORE_ID, 10);
18
+ if (!storeId) {
19
+ throw new Error('ECOM_STORE_ID is not set or not a number');
20
+ }
13
21
  if (!ECOM_AUTHENTICATION_ID) {
14
22
  throw new Error('ECOM_AUTHENTICATION_ID is not set');
15
23
  }
@@ -20,8 +28,11 @@ export default () => {
20
28
  const apiKey = ECOM_API_KEY;
21
29
  const githubToken = GITHUB_TOKEN;
22
30
  const env: Env = {
23
- authenticationId,
24
- apiKey,
31
+ storeId,
32
+ apiAuth: {
33
+ authenticationId,
34
+ apiKey,
35
+ },
25
36
  githubToken,
26
37
  };
27
38
  return env;
@@ -0,0 +1,49 @@
1
+ import type { Request, Response } from 'firebase-functions';
2
+ // eslint-disable-next-line import/no-unresolved
3
+ import { getFirestore } from 'firebase-admin/firestore';
4
+ import api, { ApiEndpoint } from '@cloudcommerce/api';
5
+ import config from '../config';
6
+
7
+ export default async (req: Request, res: Response) => {
8
+ const { storeId, apps } = config.get();
9
+ const { body } = req;
10
+ if (
11
+ Number(req.get('X-Store-ID')) === storeId
12
+ && body && body.store_id === storeId
13
+ ) {
14
+ const { application, authentication } = body;
15
+ if (application && authentication) {
16
+ const matchApp = Object.keys(apps).find((slug) => {
17
+ return apps[slug].appId === application.app_id;
18
+ });
19
+ if (matchApp) {
20
+ const authenticationId = authentication.authentication_id;
21
+ const firestoreDoc = getFirestore().doc(`installedApps/${authenticationId}`);
22
+ const installedApp = await firestoreDoc.get();
23
+ if (installedApp.exists) {
24
+ res.sendStatus(200);
25
+ return;
26
+ }
27
+
28
+ const appDataEndpoint: ApiEndpoint = `applications/${application._id}/hidden_data`;
29
+ try {
30
+ await api.patch(appDataEndpoint, {
31
+ __installedAt: new Date().toISOString(),
32
+ }, {
33
+ authenticationId: authentication._id,
34
+ apiKey: authentication.api_key,
35
+ });
36
+ } catch (e) {
37
+ res.sendStatus(403);
38
+ return;
39
+ }
40
+
41
+ // Received app authentication is valid
42
+ await firestoreDoc.set({ application, authentication });
43
+ res.sendStatus(201);
44
+ return;
45
+ }
46
+ }
47
+ }
48
+ res.sendStatus(400);
49
+ };
@@ -1,12 +1,12 @@
1
1
  import type { EventSub } from '../types';
2
2
  // eslint-disable-next-line import/no-unresolved
3
3
  import { getFirestore } from 'firebase-admin/firestore';
4
- import { logger } from 'firebase-functions';
4
+ import logger from 'firebase-functions/lib/logger';
5
5
  import api from '@cloudcommerce/api';
6
6
  import getEnv from '../env';
7
7
 
8
8
  export default async () => {
9
- const { authenticationId, apiKey } = getEnv();
9
+ const { apiAuth } = getEnv();
10
10
  const eventsSubs = await getFirestore().collection('eventsSubs').get();
11
11
  const listenedEvents: EventSub['event'][] = [];
12
12
  eventsSubs.forEach((doc) => {
@@ -21,11 +21,8 @@ export default async () => {
21
21
  'products',
22
22
  'carts',
23
23
  ].forEach(async (resource) => {
24
- const { data: { result } } = await api({
25
- authenticationId,
26
- apiKey,
27
- endpoint: `events/${resource as 'orders'}`,
28
- });
24
+ const { data: { result } } = await api
25
+ .get(`events/${resource as 'orders'}`, apiAuth);
29
26
  logger.info(`${resource} events: `, result);
30
27
  });
31
28
  return true;
@@ -5,11 +5,27 @@ import '@cloudcommerce/api/fetch-polyfill.js';
5
5
  // https://github.com/import-js/eslint-plugin-import/issues/1810
6
6
  // eslint-disable-next-line import/no-unresolved
7
7
  import { initializeApp } from 'firebase-admin/app';
8
- import { pubsub } from 'firebase-functions';
8
+ import functions from 'firebase-functions';
9
+ import config from './config';
9
10
  import checkStoreEvents from './handlers/check-store-events';
11
+ import handleAuthCallback from './handlers/auth-callback';
10
12
 
11
13
  initializeApp();
12
14
 
13
- export const cronStoreEvents = pubsub.schedule('* * * * *').onRun(() => {
14
- return checkStoreEvents();
15
- });
15
+ const { httpsFunctionOptions: { region } } = config.get();
16
+
17
+ const functionBuilder = functions
18
+ .region(region)
19
+ .runWith({
20
+ timeoutSeconds: 300,
21
+ memory: '128MB',
22
+ });
23
+
24
+ export const cronStoreEvents = functionBuilder.pubsub
25
+ .schedule('* * * * *')
26
+ .onRun(() => {
27
+ return checkStoreEvents();
28
+ });
29
+
30
+ export const appAuthCallback = functionBuilder.https
31
+ .onRequest(handleAuthCallback);
@@ -11,13 +11,10 @@ import serveModulesApi from './firebase/serve-modules-api.js';
11
11
  initializeApp();
12
12
  const { httpsFunctionOptions } = config.get();
13
13
 
14
- export const modulesApi = onRequest(httpsFunctionOptions, (req, res) => {
15
- const { authenticationId, apiKey } = getEnv();
14
+ export const modules = onRequest(httpsFunctionOptions, (req, res) => {
15
+ const { apiAuth } = getEnv();
16
16
  // Hide API key for security
17
17
  process.env.ECOM_API_KEY = '***';
18
- serveModulesApi(req, res, {
19
- authenticationId,
20
- apiKey,
21
- });
18
+ serveModulesApi(req, res, apiAuth);
22
19
  });
23
20
  // # sourceMappingURL=firebase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,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G,MAAM,EAAE,CAAC;IAC7B,4BAA4B;IAC5B,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/modules",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce modules API",
6
6
  "main": "lib/index.cjs",
7
7
  "exports": {
@@ -12,12 +12,9 @@ import serveModulesApi from './firebase/serve-modules-api';
12
12
  initializeApp();
13
13
  const { httpsFunctionOptions } = config.get();
14
14
 
15
- export const modulesApi = onRequest(httpsFunctionOptions, (req, res) => {
16
- const { authenticationId, apiKey } = getEnv();
15
+ export const modules = onRequest(httpsFunctionOptions, (req, res) => {
16
+ const { apiAuth } = getEnv();
17
17
  // Hide API key for security
18
18
  process.env.ECOM_API_KEY = '***';
19
- serveModulesApi(req, res, {
20
- authenticationId,
21
- apiKey,
22
- });
19
+ serveModulesApi(req, res, apiAuth);
23
20
  });
@@ -9,7 +9,7 @@ import config from '@cloudcommerce/firebase/lib/config';
9
9
  initializeApp();
10
10
  const options = config.get().httpsFunctionOptions;
11
11
 
12
- export const passportApi = onRequest(options, (request, response) => {
12
+ export const passport = onRequest(options, (request, response) => {
13
13
  process.env.ECOM_API_KEY = '***';
14
14
  response.send('Hello passport!');
15
15
  });
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,aAAa,EAAE,CAAC;AAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAClE,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../src/firebase.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,gCAAgC,CAAC;AACxC,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,aAAa,EAAE,CAAC;AAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC/D,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/passport",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce customers authentication (passport) API",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -10,7 +10,7 @@ import config from '@cloudcommerce/firebase/lib/config';
10
10
  initializeApp();
11
11
  const options = config.get().httpsFunctionOptions;
12
12
 
13
- export const passportApi = onRequest(options, (request, response) => {
13
+ export const passport = onRequest(options, (request, response) => {
14
14
  process.env.ECOM_API_KEY = '***';
15
15
  response.send('Hello passport!');
16
16
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "main": "src/index.js",
7
7
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "0.0.44",
4
+ "version": "0.0.47",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {
package/pnpm-lock.yaml CHANGED
@@ -60,10 +60,16 @@ importers:
60
60
  specifiers:
61
61
  '@cloudcommerce/api': workspace:*
62
62
  '@cloudcommerce/types': workspace:*
63
+ '@firebase/app-types': ^0.7.0
64
+ firebase-admin: ^11.0.1
65
+ firebase-functions: ^3.22.0
63
66
  dependencies:
64
67
  '@cloudcommerce/api': link:../../api
68
+ firebase-admin: 11.0.1_@firebase+app-types@0.7.0
69
+ firebase-functions: 3.22.0_firebase-admin@11.0.1
65
70
  devDependencies:
66
71
  '@cloudcommerce/types': link:../../types
72
+ '@firebase/app-types': 0.7.0
67
73
 
68
74
  packages/cli:
69
75
  specifiers:
@@ -78,7 +84,7 @@ importers:
78
84
  packages/events:
79
85
  specifiers:
80
86
  '@cloudcommerce/api': workspace:*
81
- '@cloudcommerce/firebase': workspace:^0.0.43
87
+ '@cloudcommerce/firebase': workspace:*
82
88
  '@cloudcommerce/types': workspace:*
83
89
  '@firebase/app-types': ^0.7.0
84
90
  firebase-admin: ^11.0.1
@@ -118,7 +124,7 @@ importers:
118
124
  packages/modules:
119
125
  specifiers:
120
126
  '@cloudcommerce/api': workspace:*
121
- '@cloudcommerce/app-discounts': workspace:^0.0.43
127
+ '@cloudcommerce/app-discounts': workspace:*
122
128
  '@cloudcommerce/firebase': workspace:*
123
129
  '@cloudcommerce/types': workspace:*
124
130
  '@firebase/app-types': ^0.7.0
@@ -198,36 +204,44 @@ importers:
198
204
 
199
205
  store:
200
206
  specifiers:
201
- '@cloudcommerce/cli': ^0.0.43
207
+ '@cloudcommerce/cli': ^0.0.46
202
208
  dependencies:
203
209
  '@cloudcommerce/cli': link:../packages/cli
204
210
 
205
211
  store/functions/core:
206
212
  specifiers:
207
- '@cloudcommerce/firebase': ^0.0.43
213
+ '@cloudcommerce/firebase': ^0.0.46
214
+ dependencies:
215
+ '@cloudcommerce/firebase': link:../../../packages/firebase
216
+
217
+ store/functions/events:
218
+ specifiers:
219
+ '@cloudcommerce/events': ^0.0.46
220
+ '@cloudcommerce/firebase': ^0.0.46
208
221
  dependencies:
222
+ '@cloudcommerce/events': link:../../../packages/events
209
223
  '@cloudcommerce/firebase': link:../../../packages/firebase
210
224
 
211
225
  store/functions/modules:
212
226
  specifiers:
213
- '@cloudcommerce/firebase': ^0.0.43
214
- '@cloudcommerce/modules': ^0.0.43
227
+ '@cloudcommerce/firebase': ^0.0.46
228
+ '@cloudcommerce/modules': ^0.0.46
215
229
  dependencies:
216
230
  '@cloudcommerce/firebase': link:../../../packages/firebase
217
231
  '@cloudcommerce/modules': link:../../../packages/modules
218
232
 
219
233
  store/functions/passport:
220
234
  specifiers:
221
- '@cloudcommerce/firebase': ^0.0.43
222
- '@cloudcommerce/passport': ^0.0.43
235
+ '@cloudcommerce/firebase': ^0.0.46
236
+ '@cloudcommerce/passport': ^0.0.46
223
237
  dependencies:
224
238
  '@cloudcommerce/firebase': link:../../../packages/firebase
225
239
  '@cloudcommerce/passport': link:../../../packages/passport
226
240
 
227
241
  store/functions/ssr:
228
242
  specifiers:
229
- '@cloudcommerce/firebase': ^0.0.43
230
- '@cloudcommerce/ssr': ^0.0.43
243
+ '@cloudcommerce/firebase': ^0.0.46
244
+ '@cloudcommerce/ssr': ^0.0.46
231
245
  dependencies:
232
246
  '@cloudcommerce/firebase': link:../../../packages/firebase
233
247
  '@cloudcommerce/ssr': link:../../../packages/ssr