curtain-web-api 1.0.28 → 1.0.29
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,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="pouchdb-core" />
|
|
1
2
|
import { User } from "./curtain-user";
|
|
2
3
|
export declare const replacer: (key: any, value: any) => any;
|
|
3
4
|
export declare const reviver: (key: any, value: any) => any;
|
|
@@ -13,11 +14,11 @@ export declare class CurtainWebAPI {
|
|
|
13
14
|
axiosInstance: import("axios").AxiosInstance;
|
|
14
15
|
baseURL: string;
|
|
15
16
|
constructor(baseURL?: string);
|
|
16
|
-
login(username: string, password: string): Promise<
|
|
17
|
+
login(username: string, password: string): Promise<PouchDB.Core.Response>;
|
|
17
18
|
getUserInfo(): Promise<User>;
|
|
18
19
|
logout(): Promise<void>;
|
|
19
20
|
refresh(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
20
|
-
ORCIDLogin(authorizationCode: string, redirectURI: string): Promise<
|
|
21
|
+
ORCIDLogin(authorizationCode: string, redirectURI: string): Promise<PouchDB.Core.Response>;
|
|
21
22
|
checkIfRefreshTokenExpired(): boolean;
|
|
22
23
|
deleteCurtainLink(curtainLinkID: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
23
24
|
putSettings(settings: any, enable?: boolean, description?: string, sessionType?: string, onUploadProgress?: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -139,8 +139,7 @@ class CurtainWebAPI {
|
|
|
139
139
|
this.user.access_token = response.data.access;
|
|
140
140
|
this.user.refresh_token = response.data.refresh;
|
|
141
141
|
this.user.loginStatus = true;
|
|
142
|
-
this.user.saveIntoDB()
|
|
143
|
-
return this.getUserInfo();
|
|
142
|
+
return this.user.saveIntoDB();
|
|
144
143
|
});
|
|
145
144
|
}
|
|
146
145
|
getUserInfo() {
|
|
@@ -189,8 +188,7 @@ class CurtainWebAPI {
|
|
|
189
188
|
this.user.refresh_token = response.data.refresh;
|
|
190
189
|
this.user.loginStatus = true;
|
|
191
190
|
console.log(this.user.loginStatus);
|
|
192
|
-
this.user.saveIntoDB()
|
|
193
|
-
return this.getUserInfo();
|
|
191
|
+
return this.user.saveIntoDB();
|
|
194
192
|
});
|
|
195
193
|
}
|
|
196
194
|
checkIfRefreshTokenExpired() {
|
|
@@ -24,7 +24,7 @@ export declare class User {
|
|
|
24
24
|
init(): Promise<void | undefined>;
|
|
25
25
|
initiateDB(): Promise<void>;
|
|
26
26
|
updateDB(): Promise<void>;
|
|
27
|
-
saveIntoDB(): Promise<
|
|
27
|
+
saveIntoDB(): Promise<PouchDB.Core.Response>;
|
|
28
28
|
loadFromDB(): Promise<void>;
|
|
29
29
|
clearDB(): Promise<void>;
|
|
30
30
|
reset(): void;
|
|
@@ -87,7 +87,8 @@ class User {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
saveIntoDB() {
|
|
90
|
-
|
|
90
|
+
console.log(this.loginStatus);
|
|
91
|
+
return this.db.get("user").catch((error) => {
|
|
91
92
|
if (error.name === "not_found") {
|
|
92
93
|
console.log(this.loginStatus);
|
|
93
94
|
return {
|
|
@@ -128,29 +129,6 @@ class User {
|
|
|
128
129
|
lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
|
|
129
130
|
});
|
|
130
131
|
});
|
|
131
|
-
return this.db.put({
|
|
132
|
-
_id: "user",
|
|
133
|
-
access_token: this.access_token,
|
|
134
|
-
refresh_token: this.refresh_token,
|
|
135
|
-
username: this.username,
|
|
136
|
-
loginStatus: this.loginStatus,
|
|
137
|
-
isStaff: this.isStaff,
|
|
138
|
-
id: this.id,
|
|
139
|
-
totalCurtain: this.totalCurtain,
|
|
140
|
-
canDelete: this.canDelete,
|
|
141
|
-
curtainLinkLimit: this.curtainLinkLimit,
|
|
142
|
-
curtainLinkLimitExceeded: this.curtainLinkLimitExceeded,
|
|
143
|
-
lastAccessTokenUpdate: this.lastAccessTokenUpdate,
|
|
144
|
-
lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
|
|
145
|
-
}).then((response) => {
|
|
146
|
-
console.log(response);
|
|
147
|
-
}).catch((error) => {
|
|
148
|
-
console.log(error);
|
|
149
|
-
console.log(this.loginStatus);
|
|
150
|
-
if (error.name === "conflict") {
|
|
151
|
-
return this.updateDB();
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
132
|
}
|
|
155
133
|
loadFromDB() {
|
|
156
134
|
return this.db.get("user").then((doc) => {
|
package/package.json
CHANGED
|
@@ -117,8 +117,7 @@ export class CurtainWebAPI {
|
|
|
117
117
|
this.user.access_token = response.data.access;
|
|
118
118
|
this.user.refresh_token = response.data.refresh;
|
|
119
119
|
this.user.loginStatus = true;
|
|
120
|
-
this.user.saveIntoDB()
|
|
121
|
-
return this.getUserInfo();
|
|
120
|
+
return this.user.saveIntoDB()
|
|
122
121
|
});
|
|
123
122
|
}
|
|
124
123
|
|
|
@@ -173,8 +172,7 @@ export class CurtainWebAPI {
|
|
|
173
172
|
this.user.refresh_token = response.data.refresh;
|
|
174
173
|
this.user.loginStatus = true;
|
|
175
174
|
console.log(this.user.loginStatus)
|
|
176
|
-
this.user.saveIntoDB()
|
|
177
|
-
return this.getUserInfo();
|
|
175
|
+
return this.user.saveIntoDB()
|
|
178
176
|
})
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -95,7 +95,8 @@ export class User {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
saveIntoDB() {
|
|
98
|
-
|
|
98
|
+
console.log(this.loginStatus)
|
|
99
|
+
return this.db.get("user").catch((error) => {
|
|
99
100
|
if (error.name === "not_found") {
|
|
100
101
|
console.log(this.loginStatus)
|
|
101
102
|
return {
|
|
@@ -135,29 +136,6 @@ export class User {
|
|
|
135
136
|
lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
|
|
136
137
|
})
|
|
137
138
|
})
|
|
138
|
-
return this.db.put({
|
|
139
|
-
_id: "user",
|
|
140
|
-
access_token: this.access_token,
|
|
141
|
-
refresh_token: this.refresh_token,
|
|
142
|
-
username: this.username,
|
|
143
|
-
loginStatus: this.loginStatus,
|
|
144
|
-
isStaff: this.isStaff,
|
|
145
|
-
id: this.id,
|
|
146
|
-
totalCurtain: this.totalCurtain,
|
|
147
|
-
canDelete: this.canDelete,
|
|
148
|
-
curtainLinkLimit: this.curtainLinkLimit,
|
|
149
|
-
curtainLinkLimitExceeded: this.curtainLinkLimitExceeded,
|
|
150
|
-
lastAccessTokenUpdate: this.lastAccessTokenUpdate,
|
|
151
|
-
lastRefreshTokenUpdate: this.lastRefreshTokenUpdate
|
|
152
|
-
}).then((response) => {
|
|
153
|
-
console.log(response);
|
|
154
|
-
}).catch((error) => {
|
|
155
|
-
console.log(error);
|
|
156
|
-
console.log(this.loginStatus);
|
|
157
|
-
if (error.name === "conflict") {
|
|
158
|
-
return this.updateDB();
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
139
|
}
|
|
162
140
|
|
|
163
141
|
loadFromDB() {
|