@christianriedl/rest 1.0.32 → 1.0.33
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/dist/authorize.d.ts +4 -4
- package/dist/authorize.js +12 -11
- package/dist/authorize.js.map +1 -1
- package/package.json +2 -2
package/dist/authorize.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILocalStorage, ILogger, IAppConfig, EScope, Dictionary } from '@christianriedl/utils';
|
|
1
|
+
import { ILocalStorage, ILogger, IAppConfig, IAppState, EScope, Dictionary } from '@christianriedl/utils';
|
|
2
2
|
import { Rest } from './rest';
|
|
3
3
|
export interface IAuthorizeResult {
|
|
4
4
|
mediaSecret: string;
|
|
@@ -28,16 +28,16 @@ export declare class Authorize {
|
|
|
28
28
|
storage: ILocalStorage;
|
|
29
29
|
secretSmarthome: string;
|
|
30
30
|
secretMedia: string;
|
|
31
|
-
scopes: EScope;
|
|
32
31
|
routes: Dictionary<IRoute>;
|
|
33
32
|
password: string;
|
|
34
|
-
|
|
33
|
+
appConfig: IAppConfig;
|
|
34
|
+
appState: IAppState;
|
|
35
35
|
authorizations: IAuthorizationResult[];
|
|
36
36
|
get user(): string;
|
|
37
37
|
set user(value: string);
|
|
38
38
|
get name(): string;
|
|
39
39
|
set name(value: string);
|
|
40
|
-
constructor(url: string, storage: ILocalStorage,
|
|
40
|
+
constructor(url: string, storage: ILocalStorage, appConfig: IAppConfig, appState: IAppState, logger: ILogger);
|
|
41
41
|
setScopes(scopes: string): void;
|
|
42
42
|
setRoutes(routes: IRoute[]): void;
|
|
43
43
|
checkScopeNames(scopes: string[]): boolean;
|
package/dist/authorize.js
CHANGED
|
@@ -6,27 +6,28 @@ export class Authorize {
|
|
|
6
6
|
storage;
|
|
7
7
|
secretSmarthome;
|
|
8
8
|
secretMedia;
|
|
9
|
-
scopes = EScope.None;
|
|
10
9
|
routes = {};
|
|
11
10
|
password;
|
|
12
|
-
|
|
11
|
+
appConfig;
|
|
12
|
+
appState;
|
|
13
13
|
authorizations = [];
|
|
14
14
|
get user() {
|
|
15
|
-
return this.
|
|
15
|
+
return this.appConfig.user;
|
|
16
16
|
}
|
|
17
17
|
set user(value) {
|
|
18
|
-
this.
|
|
18
|
+
this.appConfig.user = value;
|
|
19
19
|
}
|
|
20
20
|
get name() {
|
|
21
|
-
return this.
|
|
21
|
+
return this.appConfig.name;
|
|
22
22
|
}
|
|
23
23
|
set name(value) {
|
|
24
|
-
this.
|
|
24
|
+
this.appConfig.name = value;
|
|
25
25
|
}
|
|
26
|
-
constructor(url, storage,
|
|
26
|
+
constructor(url, storage, appConfig, appState, logger) {
|
|
27
27
|
this.rest = new Rest(url, 'same-origin', new DummyOAuth(), logger);
|
|
28
28
|
this.storage = storage;
|
|
29
|
-
this.
|
|
29
|
+
this.appConfig = appConfig;
|
|
30
|
+
this.appState = appState;
|
|
30
31
|
this.secretMedia = storage.getItemString('secretMedia', '');
|
|
31
32
|
this.secretSmarthome = storage.getItemString('secretSmarthome', '');
|
|
32
33
|
this.password = storage.getItemString('password', '');
|
|
@@ -37,7 +38,7 @@ export class Authorize {
|
|
|
37
38
|
setScopes(scopes) {
|
|
38
39
|
const splitScopes = scopes.split('|');
|
|
39
40
|
for (let i = 0; i < splitScopes.length; i++) {
|
|
40
|
-
this.scopes = this.scopes | Helper.stringToEnum(EScope, splitScopes[i]);
|
|
41
|
+
this.appState.scopes = this.appState.scopes | Helper.stringToEnum(EScope, splitScopes[i]);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
setRoutes(routes) {
|
|
@@ -48,13 +49,13 @@ export class Authorize {
|
|
|
48
49
|
checkScopeNames(scopes) {
|
|
49
50
|
for (let i = 0; i < scopes.length; i++) {
|
|
50
51
|
const scope = Helper.stringToEnum(EScope, scopes[i]);
|
|
51
|
-
if ((scope & this.scopes) == 0)
|
|
52
|
+
if ((scope & this.appState.scopes) == 0)
|
|
52
53
|
return false;
|
|
53
54
|
}
|
|
54
55
|
return true;
|
|
55
56
|
}
|
|
56
57
|
checkScope(scopes) {
|
|
57
|
-
return (this.scopes & scopes) == scopes;
|
|
58
|
+
return (this.appState.scopes & scopes) == scopes;
|
|
58
59
|
}
|
|
59
60
|
checkRoute(path) {
|
|
60
61
|
const route = this.routes[path];
|
package/dist/authorize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../src/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../src/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,MAAM,EAAc,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAElH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA6BrC,MAAM,OAAO,SAAS;IAClB,IAAI,CAAO;IACX,OAAO,CAAgB;IACvB,eAAe,CAAS;IACxB,WAAW,CAAS;IACpB,MAAM,GAAuB,EAAE,CAAC;IAChC,QAAQ,CAAS;IACjB,SAAS,CAAa;IACtB,QAAQ,CAAY;IACpB,cAAc,GAA2B,EAAE,CAAC;IAE5C,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC/B,CAAC;IACD,IAAI,IAAI,CAAC,KAAa;QAClB,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC;IAChC,CAAC;IACD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC/B,CAAC;IACD,IAAI,IAAI,CAAC,KAAa;QAClB,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC;IAChC,CAAC;IACD,YAAY,GAAW,EAAE,OAAsB,EAAE,SAAqB,EAAE,QAAmB,EAAE,MAAe;QACxG,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,C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G,CAAC,IAAI,CAAC;YACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;YAC7B,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC;YACnC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC,WAAW,CAAC;YACvC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;YACrD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC;SAChE;IACL,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christianriedl/rest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
4
4
|
"description": "REST and OAuth library based on fetch API",
|
|
5
5
|
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "Christian Riedl",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@christianriedl/utils": "^1.0.
|
|
20
|
+
"@christianriedl/utils": "^1.0.63"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"typescript": "^4.6.3",
|