@orello/auth 1.0.1 → 1.0.3

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.
@@ -0,0 +1,10 @@
1
+ import { OrelloAuthClientConfig } from "../core/interfaces/config";
2
+ import { UserData } from "../core/interfaces/data";
3
+ declare class OrelloAuthClient {
4
+ apiBaseUrl: string;
5
+ private appId;
6
+ private clientKey;
7
+ constructor(options: OrelloAuthClientConfig);
8
+ verifyToken(token: string): Promise<UserData | null>;
9
+ }
10
+ export default OrelloAuthClient;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
16
+ class OrelloAuthClient {
17
+ constructor(options) {
18
+ if (!options.appId)
19
+ throw new Error("App ID was not provided.");
20
+ if (!options.clientKey)
21
+ throw new Error("Client Key was not provided.");
22
+ this.appId = options.appId;
23
+ this.clientKey = options.clientKey;
24
+ this.apiBaseUrl = `https://api.accounts.orello.space/api/v${options.version}`;
25
+ }
26
+ verifyToken(token) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const url = `${this.apiBaseUrl}/auth/oauth/verify?token=${token}`;
29
+ const res = yield axios_1.default.get(url, {
30
+ headers: {
31
+ "Content-Type": "application/json",
32
+ "Client-Key": this.clientKey,
33
+ "App-Id": this.appId,
34
+ }
35
+ });
36
+ return res.data;
37
+ });
38
+ }
39
+ }
40
+ exports.default = OrelloAuthClient;
@@ -5,4 +5,9 @@ interface OrelloAuthConfig {
5
5
  redirectUri: string;
6
6
  state?: string;
7
7
  }
8
- export { OrelloAuthConfig };
8
+ interface OrelloAuthClientConfig {
9
+ version: string;
10
+ appId: string;
11
+ clientKey: string;
12
+ }
13
+ export { OrelloAuthConfig, OrelloAuthClientConfig };
@@ -0,0 +1,6 @@
1
+ export interface UserData {
2
+ id: string;
3
+ firstName: string;
4
+ lastName: string;
5
+ email: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import OrelloAuthProvider from "./providers/auth.provider";
2
+ import OrelloAuthClient from "./client/auth.client";
2
3
  export * from "./core/interfaces/config";
3
- export { OrelloAuthProvider };
4
+ export * from "./core/interfaces/data";
5
+ export { OrelloAuthProvider, OrelloAuthClient };
package/dist/index.js CHANGED
@@ -17,7 +17,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.OrelloAuthProvider = void 0;
20
+ exports.OrelloAuthClient = exports.OrelloAuthProvider = void 0;
21
21
  const auth_provider_1 = __importDefault(require("./providers/auth.provider"));
22
22
  exports.OrelloAuthProvider = auth_provider_1.default;
23
+ const auth_client_1 = __importDefault(require("./client/auth.client"));
24
+ exports.OrelloAuthClient = auth_client_1.default;
23
25
  __exportStar(require("./core/interfaces/config"), exports);
26
+ __exportStar(require("./core/interfaces/data"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orello/auth",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "description": "Authentication package for Orello.",
6
6
  "main": "dist/index.js",
@@ -32,6 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/hb-group/orello#readme",
34
34
  "dependencies": {
35
+ "axios": "^1.13.2",
35
36
  "dotenv": "^16.6.1"
36
37
  },
37
38
  "devDependencies": {