@theshelf/authentication 0.3.0 → 0.3.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.
@@ -1,10 +1,8 @@
1
- import type { ConnectionState } from './definitions/constants.js';
2
1
  import type { Driver } from './definitions/interfaces.js';
3
2
  import type { Session } from './definitions/types.js';
4
3
  export default class IdentityProvider implements Driver {
5
4
  #private;
6
5
  constructor(driver: Driver);
7
- get connectionState(): ConnectionState;
8
6
  get connected(): boolean;
9
7
  connect(): Promise<void>;
10
8
  disconnect(): Promise<void>;
@@ -1,23 +1,16 @@
1
- import { ConnectionStates } from './definitions/constants.js';
2
- import ConnectionManager from './ConnectionManager.js';
3
1
  export default class IdentityProvider {
4
2
  #driver;
5
- #connectionManager;
6
3
  constructor(driver) {
7
4
  this.#driver = driver;
8
- this.#connectionManager = new ConnectionManager(driver);
9
- }
10
- get connectionState() {
11
- return this.#connectionManager.state;
12
5
  }
13
6
  get connected() {
14
- return this.connectionState === ConnectionStates.CONNECTED;
7
+ return this.#driver.connected;
15
8
  }
16
9
  connect() {
17
- return this.#connectionManager.connect();
10
+ return this.#driver.connect();
18
11
  }
19
12
  disconnect() {
20
- return this.#connectionManager.disconnect();
13
+ return this.#driver.disconnect();
21
14
  }
22
15
  getLoginUrl(origin) {
23
16
  return this.#driver.getLoginUrl(origin);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@theshelf/authentication",
3
3
  "private": false,
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "url": "git+https://github.com/MaskingTechnology/theshelf.git"
@@ -1,9 +0,0 @@
1
- import type { ConnectionState } from './definitions/constants.js';
2
- import type { Driver } from './definitions/interfaces.js';
3
- export default class ConnectionManager {
4
- #private;
5
- constructor(driver: Driver);
6
- get state(): ConnectionState;
7
- connect(): Promise<void>;
8
- disconnect(): Promise<void>;
9
- }
@@ -1,53 +0,0 @@
1
- import { ConnectionStates } from './definitions/constants.js';
2
- export default class ConnectionManager {
3
- #driver;
4
- #state = ConnectionStates.DISCONNECTED;
5
- #connectPromise;
6
- #disconnectPromise;
7
- constructor(driver) {
8
- this.#driver = driver;
9
- }
10
- get state() { return this.#state; }
11
- async connect() {
12
- if (this.#connectPromise !== undefined) {
13
- return this.#connectPromise;
14
- }
15
- if (this.#state !== ConnectionStates.DISCONNECTED) {
16
- return;
17
- }
18
- this.#state = ConnectionStates.CONNECTING;
19
- try {
20
- this.#connectPromise = this.#driver.connect();
21
- await this.#connectPromise;
22
- this.#state = ConnectionStates.CONNECTED;
23
- }
24
- catch (error) {
25
- this.#state = ConnectionStates.DISCONNECTED;
26
- throw error;
27
- }
28
- finally {
29
- this.#connectPromise = undefined;
30
- }
31
- }
32
- async disconnect() {
33
- if (this.#disconnectPromise !== undefined) {
34
- return this.#disconnectPromise;
35
- }
36
- if (this.#state !== ConnectionStates.CONNECTED) {
37
- return;
38
- }
39
- this.#state = ConnectionStates.DISCONNECTING;
40
- try {
41
- this.#disconnectPromise = this.#driver.disconnect();
42
- await this.#disconnectPromise;
43
- this.#state = ConnectionStates.DISCONNECTED;
44
- }
45
- catch (error) {
46
- this.#state = ConnectionStates.CONNECTED;
47
- throw error;
48
- }
49
- finally {
50
- this.#disconnectPromise = undefined;
51
- }
52
- }
53
- }
@@ -1,7 +0,0 @@
1
- export declare const ConnectionStates: {
2
- readonly DISCONNECTED: "DISCONNECTED";
3
- readonly DISCONNECTING: "DISCONNECTING";
4
- readonly CONNECTING: "CONNECTING";
5
- readonly CONNECTED: "CONNECTED";
6
- };
7
- export type ConnectionState = typeof ConnectionStates[keyof typeof ConnectionStates];
@@ -1,6 +0,0 @@
1
- export const ConnectionStates = {
2
- DISCONNECTED: 'DISCONNECTED',
3
- DISCONNECTING: 'DISCONNECTING',
4
- CONNECTING: 'CONNECTING',
5
- CONNECTED: 'CONNECTED'
6
- };