@christianriedl/rest 1.0.52 → 1.0.54

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,55 +1,57 @@
1
- import { ILocalStorage, ILogger, IAppConfig, IAppState, EScope, Dictionary, InjectionKey } from '@christianriedl/utils';
2
- import { Rest } from './rest';
3
- export declare const authorizeSymbol: InjectionKey<Authorize>;
4
- export interface IAuthorizeResult {
5
- mediaSecret: string;
6
- smarthomeSecret: string;
7
- googleMapsKey: string;
8
- bigEndian: boolean;
9
- scopes: string;
10
- user: string;
11
- name: string;
12
- password: string;
13
- enabled: boolean;
14
- }
15
- export interface IAuthorizationResult {
16
- scopes: string;
17
- user: string;
18
- name: string;
19
- enabled: boolean;
20
- lastLogin: Date;
21
- }
22
- export interface IMeta {
23
- scopes: EScope;
24
- }
25
- export interface IRoute {
26
- path: string;
27
- meta?: IMeta;
28
- }
29
- export declare class Authorize {
30
- rest: Rest;
31
- storage: ILocalStorage;
32
- secretSmarthome: string;
33
- secretMedia: string;
34
- keyGoogleMaps: string;
35
- bigEndian: boolean;
36
- routes: Dictionary<IRoute>;
37
- password: string;
38
- appConfig: IAppConfig;
39
- appState: IAppState;
40
- authorizations: IAuthorizationResult[];
41
- get user(): string;
42
- set user(value: string);
43
- get name(): string;
44
- set name(value: string);
45
- constructor(url: string, storage: ILocalStorage, appConfig: IAppConfig, appState: IAppState, logger: ILogger);
46
- setScopes(scopes: string): void;
47
- setRoutes(routes: IRoute[]): void;
48
- checkScopeNames(scopes: string[]): boolean;
49
- checkScope(scopes: EScope): boolean;
50
- checkRoute(path: string): boolean;
51
- getAuthorizations(): Promise<IAuthorizationResult[]>;
52
- authorize(user: string, password: string): Promise<IAuthorizeResult>;
53
- login(user: string, password: string): Promise<IAuthorizeResult>;
54
- processResult(res: IAuthorizeResult, all: boolean): void;
55
- }
1
+ import { ILocalStorage, ILogger, IAppConfig, IAppState, EScope, Dictionary, InjectionKey } from '@christianriedl/utils';
2
+ import { Rest } from './rest';
3
+ export declare const authorizeSymbol: InjectionKey<Authorize>;
4
+ export interface IAuthorizeResult {
5
+ mediaSecret: string;
6
+ smarthomeSecret: string;
7
+ googleMapsKey: string;
8
+ openAIKey: string;
9
+ bigEndian: boolean;
10
+ scopes: string;
11
+ user: string;
12
+ name: string;
13
+ password: string;
14
+ enabled: boolean;
15
+ }
16
+ export interface IAuthorizationResult {
17
+ scopes: string;
18
+ user: string;
19
+ name: string;
20
+ enabled: boolean;
21
+ lastLogin: Date;
22
+ }
23
+ export interface IMeta {
24
+ scopes: EScope;
25
+ }
26
+ export interface IRoute {
27
+ path: string;
28
+ meta?: IMeta;
29
+ }
30
+ export declare class Authorize {
31
+ rest: Rest;
32
+ storage: ILocalStorage;
33
+ secretSmarthome: string;
34
+ secretMedia: string;
35
+ keyGoogleMaps: string;
36
+ keyOpenAI: string;
37
+ bigEndian: boolean;
38
+ routes: Dictionary<IRoute>;
39
+ password: string;
40
+ appConfig: IAppConfig;
41
+ appState: IAppState;
42
+ authorizations: IAuthorizationResult[];
43
+ get user(): string;
44
+ set user(value: string);
45
+ get name(): string;
46
+ set name(value: string);
47
+ constructor(url: string, storage: ILocalStorage, appConfig: IAppConfig, appState: IAppState, logger: ILogger);
48
+ setScopes(scopes: string): void;
49
+ setRoutes(routes: IRoute[]): void;
50
+ checkScopeNames(scopes: string[]): boolean;
51
+ checkScope(scopes: EScope): boolean;
52
+ checkRoute(path: string): boolean;
53
+ getAuthorizations(): Promise<IAuthorizationResult[]>;
54
+ authorize(user: string, password: string): Promise<IAuthorizeResult>;
55
+ login(user: string, password: string): Promise<IAuthorizeResult>;
56
+ processResult(res: IAuthorizeResult, all: boolean): void;
57
+ }
package/dist/authorize.js CHANGED
@@ -1,132 +1,138 @@
1
- import { EScope, Helper } from '@christianriedl/utils';
2
- import { Rest } from './rest';
3
- import { DummyOAuth } from './dummyOauth';
4
- export const authorizeSymbol = Symbol('authorize');
5
- export class Authorize {
6
- rest;
7
- storage;
8
- secretSmarthome;
9
- secretMedia;
10
- keyGoogleMaps;
11
- bigEndian;
12
- routes = {};
13
- password;
14
- appConfig;
15
- appState;
16
- authorizations = [];
17
- get user() {
18
- return this.appConfig.user;
19
- }
20
- set user(value) {
21
- this.appConfig.user = value;
22
- }
23
- get name() {
24
- return this.appConfig.name;
25
- }
26
- set name(value) {
27
- this.appConfig.name = value;
28
- }
29
- constructor(url, storage, appConfig, appState, logger) {
30
- this.rest = new Rest(url, 'same-origin', new DummyOAuth(), logger, true);
31
- this.storage = storage;
32
- this.appConfig = appConfig;
33
- this.appState = appState;
34
- this.secretMedia = storage.getItemString('secretMedia', '');
35
- this.secretSmarthome = storage.getItemString('secretSmarthome', '');
36
- this.keyGoogleMaps = storage.getItemString('keyGoogleMaps', '');
37
- this.password = storage.getItemString('password', '');
38
- this.bigEndian = storage.getItemBoolean('bigEndian', true);
39
- const scopes = storage.getItemString('scopes');
40
- if (scopes)
41
- this.setScopes(scopes);
42
- }
43
- setScopes(scopes) {
44
- const splitScopes = scopes.split('|');
45
- for (let i = 0; i < splitScopes.length; i++) {
46
- this.appState.scopes = this.appState.scopes | Helper.stringToEnum(EScope, splitScopes[i]);
47
- }
48
- }
49
- setRoutes(routes) {
50
- for (let i = 0; i < routes.length; i++) {
51
- this.routes[routes[i].path] = routes[i];
52
- }
53
- }
54
- checkScopeNames(scopes) {
55
- for (let i = 0; i < scopes.length; i++) {
56
- const scope = Helper.stringToEnum(EScope, scopes[i]);
57
- if ((scope & this.appState.scopes) == 0)
58
- return false;
59
- }
60
- return true;
61
- }
62
- checkScope(scopes) {
63
- return (this.appState.scopes & scopes) == scopes;
64
- }
65
- checkRoute(path) {
66
- const route = this.routes[path];
67
- if (!route)
68
- return false;
69
- if (route.meta)
70
- return this.checkScope(route.meta.scopes);
71
- return true;
72
- }
73
- async getAuthorizations() {
74
- const result = await this.rest.getData("apiauth/authorizations");
75
- if (result.ok && result.result) {
76
- this.authorizations = result.result;
77
- for (let i = 0; i < this.authorizations.length; i++) {
78
- const auth = this.authorizations[i];
79
- if (typeof auth.lastLogin === 'string')
80
- auth.lastLogin == new Date(auth.lastLogin);
81
- }
82
- this.authorizations;
83
- }
84
- return null;
85
- }
86
- async authorize(user, password) {
87
- const result = await this.rest.postDataEx("apiauth/authorize", { user: user, password: password });
88
- if (result.ok && result.result) {
89
- const res = result.result;
90
- this.processResult(res, true);
91
- return res;
92
- }
93
- return null;
94
- }
95
- async login(user, password) {
96
- const result = await this.rest.postDataEx("apiauth/login", { user: user, password: password });
97
- if (result.ok && result.result) {
98
- const res = result.result;
99
- this.processResult(res, false);
100
- return res;
101
- }
102
- return null;
103
- }
104
- processResult(res, all) {
105
- this.storage.setItem('scopes', res.scopes);
106
- this.setScopes(res.scopes);
107
- if (all) {
108
- this.user = res.user;
109
- this.name = res.name;
110
- this.appConfig.save();
111
- this.password = res.password;
112
- this.storage.setItem('password', res.password);
113
- }
114
- if (this.secretMedia != res.mediaSecret) {
115
- this.secretMedia = res.mediaSecret;
116
- this.storage.setItem('secretMedia', res.mediaSecret);
117
- }
118
- if (this.secretSmarthome != res.smarthomeSecret) {
119
- this.secretSmarthome = res.smarthomeSecret;
120
- this.storage.setItem('secretSmarthome', res.smarthomeSecret);
121
- }
122
- if (this.keyGoogleMaps != res.googleMapsKey) {
123
- this.keyGoogleMaps = res.googleMapsKey;
124
- this.storage.setItem('keyGoogleMaps', res.googleMapsKey);
125
- }
126
- if (this.bigEndian != res.bigEndian) {
127
- this.bigEndian = res.bigEndian;
128
- this.storage.setItem('bigEndian', res.bigEndian);
129
- }
130
- }
131
- }
1
+ import { EScope, Helper } from '@christianriedl/utils';
2
+ import { Rest } from './rest';
3
+ import { DummyOAuth } from './dummyOauth';
4
+ export const authorizeSymbol = Symbol('authorize');
5
+ export class Authorize {
6
+ rest;
7
+ storage;
8
+ secretSmarthome;
9
+ secretMedia;
10
+ keyGoogleMaps;
11
+ keyOpenAI;
12
+ bigEndian;
13
+ routes = {};
14
+ password;
15
+ appConfig;
16
+ appState;
17
+ authorizations = [];
18
+ get user() {
19
+ return this.appConfig.user;
20
+ }
21
+ set user(value) {
22
+ this.appConfig.user = value;
23
+ }
24
+ get name() {
25
+ return this.appConfig.name;
26
+ }
27
+ set name(value) {
28
+ this.appConfig.name = value;
29
+ }
30
+ constructor(url, storage, appConfig, appState, logger) {
31
+ this.rest = new Rest(url, 'same-origin', new DummyOAuth(), logger, true);
32
+ this.storage = storage;
33
+ this.appConfig = appConfig;
34
+ this.appState = appState;
35
+ this.secretMedia = storage.getItemString('secretMedia', '');
36
+ this.secretSmarthome = storage.getItemString('secretSmarthome', '');
37
+ this.keyGoogleMaps = storage.getItemString('keyGoogleMaps', '');
38
+ this.keyOpenAI = storage.getItemString('keyOpenAI', '');
39
+ this.password = storage.getItemString('password', '');
40
+ this.bigEndian = storage.getItemBoolean('bigEndian', true);
41
+ const scopes = storage.getItemString('scopes');
42
+ if (scopes)
43
+ this.setScopes(scopes);
44
+ }
45
+ setScopes(scopes) {
46
+ const splitScopes = scopes.split('|');
47
+ for (let i = 0; i < splitScopes.length; i++) {
48
+ this.appState.scopes = this.appState.scopes | Helper.stringToEnum(EScope, splitScopes[i]);
49
+ }
50
+ }
51
+ setRoutes(routes) {
52
+ for (let i = 0; i < routes.length; i++) {
53
+ this.routes[routes[i].path] = routes[i];
54
+ }
55
+ }
56
+ checkScopeNames(scopes) {
57
+ for (let i = 0; i < scopes.length; i++) {
58
+ const scope = Helper.stringToEnum(EScope, scopes[i]);
59
+ if ((scope & this.appState.scopes) == 0)
60
+ return false;
61
+ }
62
+ return true;
63
+ }
64
+ checkScope(scopes) {
65
+ return (this.appState.scopes & scopes) == scopes;
66
+ }
67
+ checkRoute(path) {
68
+ const route = this.routes[path];
69
+ if (!route)
70
+ return false;
71
+ if (route.meta)
72
+ return this.checkScope(route.meta.scopes);
73
+ return true;
74
+ }
75
+ async getAuthorizations() {
76
+ const result = await this.rest.getData("apiauth/authorizations");
77
+ if (result.ok && result.result) {
78
+ this.authorizations = result.result;
79
+ for (let i = 0; i < this.authorizations.length; i++) {
80
+ const auth = this.authorizations[i];
81
+ if (typeof auth.lastLogin === 'string')
82
+ auth.lastLogin == new Date(auth.lastLogin);
83
+ }
84
+ this.authorizations;
85
+ }
86
+ return null;
87
+ }
88
+ async authorize(user, password) {
89
+ const result = await this.rest.postDataEx("apiauth/authorize", { user: user, password: password });
90
+ if (result.ok && result.result) {
91
+ const res = result.result;
92
+ this.processResult(res, true);
93
+ return res;
94
+ }
95
+ return null;
96
+ }
97
+ async login(user, password) {
98
+ const result = await this.rest.postDataEx("apiauth/login", { user: user, password: password });
99
+ if (result.ok && result.result) {
100
+ const res = result.result;
101
+ this.processResult(res, false);
102
+ return res;
103
+ }
104
+ return null;
105
+ }
106
+ processResult(res, all) {
107
+ this.storage.setItem('scopes', res.scopes);
108
+ this.setScopes(res.scopes);
109
+ if (all) {
110
+ this.user = res.user;
111
+ this.name = res.name;
112
+ this.appConfig.save();
113
+ this.password = res.password;
114
+ this.storage.setItem('password', res.password);
115
+ }
116
+ if (this.secretMedia != res.mediaSecret) {
117
+ this.secretMedia = res.mediaSecret;
118
+ this.storage.setItem('secretMedia', res.mediaSecret);
119
+ }
120
+ if (this.secretSmarthome != res.smarthomeSecret) {
121
+ this.secretSmarthome = res.smarthomeSecret;
122
+ this.storage.setItem('secretSmarthome', res.smarthomeSecret);
123
+ }
124
+ if (this.keyGoogleMaps != res.googleMapsKey) {
125
+ this.keyGoogleMaps = res.googleMapsKey;
126
+ this.storage.setItem('keyGoogleMaps', res.googleMapsKey);
127
+ }
128
+ if (this.keyOpenAI != res.openAIKey) {
129
+ this.keyOpenAI = res.openAIKey;
130
+ this.storage.setItem('keyOpenAI', res.openAIKey);
131
+ }
132
+ if (this.bigEndian != res.bigEndian) {
133
+ this.bigEndian = res.bigEndian;
134
+ this.storage.setItem('bigEndian', res.bigEndian);
135
+ }
136
+ }
137
+ }
132
138
  //# sourceMappingURL=authorize.js.map
@@ -1 +1 @@
1
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S,GAAG,GAAG,CAAC,SAAS,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;CACJ"}
@@ -1,10 +1,10 @@
1
- import { IOAuth } from './iOauth';
2
- export declare class DummyOAuth implements IOAuth {
3
- mode: RequestMode;
4
- token: string;
5
- clientId: string;
6
- role: string;
7
- constructor(mode?: RequestMode, role?: string);
8
- getToken(): Promise<string>;
9
- getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
10
- }
1
+ import { IOAuth } from './iOauth';
2
+ export declare class DummyOAuth implements IOAuth {
3
+ mode: RequestMode;
4
+ token: string;
5
+ clientId: string;
6
+ role: string;
7
+ constructor(mode?: RequestMode, role?: string);
8
+ getToken(): Promise<string>;
9
+ getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
10
+ }
@@ -1,24 +1,24 @@
1
- export class DummyOAuth {
2
- mode = "same-origin";
3
- token = "";
4
- clientId = "";
5
- role = "";
6
- constructor(mode, role) {
7
- if (mode)
8
- this.mode = mode;
9
- if (role)
10
- this.role = role;
11
- }
12
- getToken() {
13
- return new Promise((resolve, reject) => {
14
- resolve(this.token);
15
- });
16
- }
17
- getAccessToken(clientId, clientSecret) {
18
- this.clientId = clientId;
19
- return new Promise((resolve, reject) => {
20
- resolve(true);
21
- });
22
- }
23
- }
1
+ export class DummyOAuth {
2
+ mode = "same-origin";
3
+ token = "";
4
+ clientId = "";
5
+ role = "";
6
+ constructor(mode, role) {
7
+ if (mode)
8
+ this.mode = mode;
9
+ if (role)
10
+ this.role = role;
11
+ }
12
+ getToken() {
13
+ return new Promise((resolve, reject) => {
14
+ resolve(this.token);
15
+ });
16
+ }
17
+ getAccessToken(clientId, clientSecret) {
18
+ this.clientId = clientId;
19
+ return new Promise((resolve, reject) => {
20
+ resolve(true);
21
+ });
22
+ }
23
+ }
24
24
  //# sourceMappingURL=dummyOauth.js.map
package/dist/iOauth.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export interface IOAuth {
2
- mode: RequestMode;
3
- clientId: string;
4
- role: string;
5
- getToken(): Promise<string>;
6
- getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
7
- }
1
+ export interface IOAuth {
2
+ mode: RequestMode;
3
+ clientId: string;
4
+ role: string;
5
+ getToken(): Promise<string>;
6
+ getAccessToken(clientId: string, clientSecret: string): Promise<boolean>;
7
+ }
package/dist/iOauth.js CHANGED
@@ -1,3 +1,3 @@
1
- ;
2
- export {};
1
+ ;
2
+ export {};
3
3
  //# sourceMappingURL=iOauth.js.map
package/dist/iRest.d.ts CHANGED
@@ -1,35 +1,35 @@
1
- declare type Dictionary<T> = {
2
- [key: string]: T;
3
- };
4
- export interface IProblemResult {
5
- statusCode: number;
6
- errors: Dictionary<string> | string;
7
- detail: string;
8
- instance: string;
9
- title: string;
10
- type: string;
11
- }
12
- export interface IValueResult<T> {
13
- result: T;
14
- }
15
- export interface IRestResult<T> {
16
- statusCode: number;
17
- ok: boolean;
18
- statusText?: string;
19
- headers?: Headers;
20
- result?: IProblemResult | T | IValueResult<T>;
21
- }
22
- export interface IRest {
23
- serviceUrl: string;
24
- getData<T>(path: string, queryParameter?: Dictionary<any>, adjustResult?: (result: IRestResult<T>) => void): Promise<IRestResult<T>>;
25
- postData<T>(path: string, data?: T): Promise<IRestResult<boolean>>;
26
- postDataEx<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
27
- putData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
28
- deleteData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
29
- getBlob(path: string, mediaType: string, queryParameter?: Dictionary<any>, headers?: Dictionary<string>): Promise<IRestResult<Blob>>;
30
- postBlob<RESP>(path: string, blob: Blob, mediaType?: string, responseType?: string): Promise<IRestResult<RESP>>;
31
- toBoolean(result: Promise<IRestResult<boolean>>): Promise<boolean>;
32
- toData<T>(result: Promise<IRestResult<T>>): Promise<T>;
33
- toPromise<T>(data: T): Promise<T>;
34
- }
35
- export {};
1
+ type Dictionary<T> = {
2
+ [key: string]: T;
3
+ };
4
+ export interface IProblemResult {
5
+ statusCode: number;
6
+ errors: Dictionary<string> | string;
7
+ detail: string;
8
+ instance: string;
9
+ title: string;
10
+ type: string;
11
+ }
12
+ export interface IValueResult<T> {
13
+ result: T;
14
+ }
15
+ export interface IRestResult<T> {
16
+ statusCode: number;
17
+ ok: boolean;
18
+ statusText?: string;
19
+ headers?: Headers;
20
+ result?: IProblemResult | T | IValueResult<T>;
21
+ }
22
+ export interface IRest {
23
+ serviceUrl: string;
24
+ getData<T>(path: string, queryParameter?: Dictionary<any>, adjustResult?: (result: IRestResult<T>) => void): Promise<IRestResult<T>>;
25
+ postData<T>(path: string, data?: T): Promise<IRestResult<boolean>>;
26
+ postDataEx<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
27
+ putData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
28
+ deleteData<T, R>(path: string, data?: T, adjustResult?: (result: IRestResult<R>) => void): Promise<IRestResult<R>>;
29
+ getBlob(path: string, mediaType: string, queryParameter?: Dictionary<any>, headers?: Dictionary<string>): Promise<IRestResult<Blob>>;
30
+ postBlob<RESP>(path: string, blob: Blob, mediaType?: string, responseType?: string): Promise<IRestResult<RESP>>;
31
+ toBoolean(result: Promise<IRestResult<boolean>>): Promise<boolean>;
32
+ toData<T>(result: Promise<IRestResult<T>>): Promise<T>;
33
+ toPromise<T>(data: T): Promise<T>;
34
+ }
35
+ export {};
package/dist/iRest.js CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=iRest.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './rest';
2
- export * from './oauth';
3
- export * from './dummyOauth';
4
- export * from './authorize';
1
+ export * from './rest';
2
+ export * from './oauth';
3
+ export * from './dummyOauth';
4
+ export * from './authorize';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from './rest';
2
- export * from './oauth';
3
- export * from './dummyOauth';
4
- export * from './authorize';
1
+ export * from './rest';
2
+ export * from './oauth';
3
+ export * from './dummyOauth';
4
+ export * from './authorize';
5
5
  //# sourceMappingURL=index.js.map