@leancodepl/login-manager 7.8.2 → 8.1.0

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/index.cjs.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var buffer = require('buffer');
6
4
 
7
5
  function _extends() {
@@ -22,6 +20,15 @@ class BaseLoginManager {
22
20
  trySignInWithFacebook(accessToken) {
23
21
  return this.acquireToken(this.buildSignInWithFacebookRequest(accessToken));
24
22
  }
23
+ trySignInWithOneTimeToken(token) {
24
+ return this.acquireToken(this.buildSignInWithOneTimeTokenRequest(token));
25
+ }
26
+ trySignInWithGoogle(accessToken) {
27
+ return this.acquireToken(this.buildSignInWithGoogleRequest(accessToken));
28
+ }
29
+ trySignInWithLinkedIn(accessToken) {
30
+ return this.acquireToken(this.buildSignInWithLinkedInRequest(accessToken));
31
+ }
25
32
  async tryRefreshToken() {
26
33
  const token = await this.storage.getToken();
27
34
  if (token !== null) {
@@ -107,6 +114,42 @@ class BaseLoginManager {
107
114
  body: new URLSearchParams(data)
108
115
  };
109
116
  }
117
+ buildSignInWithOneTimeTokenRequest(token) {
118
+ const data = _extends({
119
+ grant_type: "onetime",
120
+ scope: this.scopes,
121
+ token
122
+ }, this.additionalParams);
123
+ return {
124
+ method: "POST",
125
+ headers: this.prepareHeaders(),
126
+ body: new URLSearchParams(data)
127
+ };
128
+ }
129
+ buildSignInWithGoogleRequest(accessToken) {
130
+ const data = _extends({
131
+ grant_type: "google",
132
+ scope: this.scopes,
133
+ assertion: accessToken
134
+ }, this.additionalParams);
135
+ return {
136
+ method: "POST",
137
+ headers: this.prepareHeaders(),
138
+ body: new URLSearchParams(data)
139
+ };
140
+ }
141
+ buildSignInWithLinkedInRequest(accessToken) {
142
+ const data = _extends({
143
+ grant_type: "linkedin",
144
+ scope: this.scopes,
145
+ assertion: accessToken
146
+ }, this.additionalParams);
147
+ return {
148
+ method: "POST",
149
+ headers: this.prepareHeaders(),
150
+ body: new URLSearchParams(data)
151
+ };
152
+ }
110
153
  buildRefreshRequest(token) {
111
154
  const data = _extends({
112
155
  grant_type: "refresh_token",
package/index.esm.js CHANGED
@@ -18,6 +18,15 @@ class BaseLoginManager {
18
18
  trySignInWithFacebook(accessToken) {
19
19
  return this.acquireToken(this.buildSignInWithFacebookRequest(accessToken));
20
20
  }
21
+ trySignInWithOneTimeToken(token) {
22
+ return this.acquireToken(this.buildSignInWithOneTimeTokenRequest(token));
23
+ }
24
+ trySignInWithGoogle(accessToken) {
25
+ return this.acquireToken(this.buildSignInWithGoogleRequest(accessToken));
26
+ }
27
+ trySignInWithLinkedIn(accessToken) {
28
+ return this.acquireToken(this.buildSignInWithLinkedInRequest(accessToken));
29
+ }
21
30
  async tryRefreshToken() {
22
31
  const token = await this.storage.getToken();
23
32
  if (token !== null) {
@@ -103,6 +112,42 @@ class BaseLoginManager {
103
112
  body: new URLSearchParams(data)
104
113
  };
105
114
  }
115
+ buildSignInWithOneTimeTokenRequest(token) {
116
+ const data = _extends({
117
+ grant_type: "onetime",
118
+ scope: this.scopes,
119
+ token
120
+ }, this.additionalParams);
121
+ return {
122
+ method: "POST",
123
+ headers: this.prepareHeaders(),
124
+ body: new URLSearchParams(data)
125
+ };
126
+ }
127
+ buildSignInWithGoogleRequest(accessToken) {
128
+ const data = _extends({
129
+ grant_type: "google",
130
+ scope: this.scopes,
131
+ assertion: accessToken
132
+ }, this.additionalParams);
133
+ return {
134
+ method: "POST",
135
+ headers: this.prepareHeaders(),
136
+ body: new URLSearchParams(data)
137
+ };
138
+ }
139
+ buildSignInWithLinkedInRequest(accessToken) {
140
+ const data = _extends({
141
+ grant_type: "linkedin",
142
+ scope: this.scopes,
143
+ assertion: accessToken
144
+ }, this.additionalParams);
145
+ return {
146
+ method: "POST",
147
+ headers: this.prepareHeaders(),
148
+ body: new URLSearchParams(data)
149
+ };
150
+ }
106
151
  buildRefreshRequest(token) {
107
152
  const data = _extends({
108
153
  grant_type: "refresh_token",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/login-manager",
3
- "version": "7.8.2",
3
+ "version": "8.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "dependencies": {
6
6
  "buffer": ">=6.0.0"
@@ -9,10 +9,12 @@
9
9
  "./package.json": "./package.json",
10
10
  ".": {
11
11
  "module": "./index.esm.js",
12
+ "types": "./index.esm.d.ts",
12
13
  "import": "./index.cjs.mjs",
13
14
  "default": "./index.cjs.js"
14
15
  }
15
16
  },
16
17
  "module": "./index.esm.js",
17
- "main": "./index.cjs.js"
18
+ "main": "./index.cjs.js",
19
+ "types": "./index.esm.d.ts"
18
20
  }
@@ -27,13 +27,19 @@ export declare abstract class BaseLoginManager<TStorage extends TokenStorage> {
27
27
  abstract getToken(): Promise<string | null>;
28
28
  trySignIn(username: string, password: string): Promise<LoginResult>;
29
29
  trySignInWithFacebook(accessToken: string): Promise<LoginResult>;
30
+ trySignInWithOneTimeToken(token: string): Promise<LoginResult>;
31
+ trySignInWithGoogle(accessToken: string): Promise<LoginResult>;
32
+ trySignInWithLinkedIn(accessToken: string): Promise<LoginResult>;
30
33
  tryRefreshToken(): Promise<boolean | null>;
31
34
  protected tryRefreshTokenInternal(token: Token): Promise<boolean>;
32
35
  onChange(callback: (isSignedIn: boolean) => void): void;
33
- removeOnChange(callback: () => void): void;
34
- private acquireToken;
36
+ removeOnChange(callback: (isSignedIn: boolean) => void): void;
37
+ acquireToken(init: RequestInit): Promise<LoginResult>;
35
38
  buildSignInRequest(username: string, password: string): RequestInit;
36
39
  private buildSignInWithFacebookRequest;
40
+ private buildSignInWithOneTimeTokenRequest;
41
+ private buildSignInWithGoogleRequest;
42
+ private buildSignInWithLinkedInRequest;
37
43
  private buildRefreshRequest;
38
44
  private prepareHeaders;
39
45
  protected notify(isSignedIn: boolean): void;