@quatrain/auth-firebase 1.1.11 → 1.1.12

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.
@@ -16,4 +16,5 @@ export declare class FirebaseAuthAdapter extends AbstractAuthAdapter {
16
16
  delete(user: User): Promise<any>;
17
17
  revokeAuthToken(token: string): Promise<void>;
18
18
  setCustomUserClaims(id: string, claims: any): Promise<void>;
19
+ refreshToken(refreshToken: string): Promise<any>;
19
20
  }
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -13,6 +36,7 @@ exports.FirebaseAuthAdapter = void 0;
13
36
  const auth_1 = require("@quatrain/auth");
14
37
  const auth_2 = require("firebase-admin/auth");
15
38
  const app_1 = require("firebase-admin/app");
39
+ const nativeFetch = __importStar(require("node-fetch-native"));
16
40
  class FirebaseAuthAdapter extends auth_1.AbstractAuthAdapter {
17
41
  constructor(params = {}) {
18
42
  super(params);
@@ -80,5 +104,23 @@ class FirebaseAuthAdapter extends auth_1.AbstractAuthAdapter {
80
104
  setCustomUserClaims(id, claims) {
81
105
  return __awaiter(this, void 0, void 0, function* () { });
82
106
  }
107
+ refreshToken(refreshToken) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ if (!this._params.config.apiKey) {
110
+ auth_1.Auth.warn(`Can't get refresh token, no API key provided`);
111
+ return {};
112
+ }
113
+ const response = yield nativeFetch.fetch(`https://securetoken.googleapis.com/v1/token?key=${this._params.config.apiKey}`, {
114
+ method: 'POST',
115
+ body: JSON.stringify({
116
+ grant_type: 'refresh_token',
117
+ refresh_token: refreshToken,
118
+ }),
119
+ headers: { 'Content-Type': 'application/json' }, //, crossdomain: true },
120
+ });
121
+ const data = response.json();
122
+ return data;
123
+ });
124
+ }
83
125
  }
84
126
  exports.FirebaseAuthAdapter = FirebaseAuthAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/auth-firebase",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -10,10 +10,10 @@
10
10
  ],
11
11
  "author": "Quatrain Développement SAS <developers@quatrain.com>",
12
12
  "peerDependencies": {
13
- "@quatrain/core": "^1.1.11"
13
+ "@quatrain/core": "^1.1.15"
14
14
  },
15
15
  "dependencies": {
16
- "@quatrain/auth": "^1.1.12",
16
+ "@quatrain/auth": "^1.1.16",
17
17
  "firebase-admin": "^13.0.1"
18
18
  },
19
19
  "devDependencies": {
@@ -30,12 +30,13 @@
30
30
  "typescript": "^5.1.5"
31
31
  },
32
32
  "scripts": {
33
- "pretest": "tsc",
34
- "test": "clear && firebase emulators:exec 'jest -i --verbose'",
35
- "test-ci": "jest --runInBand",
36
33
  "build": "tsc",
37
34
  "wbuild": "tsc --watch",
38
35
  "bump-to": "yarn version",
39
- "publish": "yarn build && yarn npm publish --access public"
36
+ "hash": "node ../../bin/hashFolder.js",
37
+ "hash:persist": "yarn hash > .hash_latest.txt",
38
+ "hash:compare": "yarn hash > .hash_newest.txt && cmp -s .hash_latest.txt .hash_newest.txt",
39
+ "publish": "yarn hash:compare || yarn publish:process",
40
+ "publish:process": "yarn version patch && yarn build && yarn npm publish --access public && yarn hash:persist"
40
41
  }
41
42
  }