@retter/sdk 0.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/README.MD +3 -0
- package/dist/api.d.ts +1 -0
- package/dist/api.js +50 -0
- package/dist/api.js.map +1 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +134 -0
- package/dist/app.js.map +1 -0
- package/dist/axiosSetup.d.ts +3 -0
- package/dist/axiosSetup.js +17 -0
- package/dist/axiosSetup.js.map +1 -0
- package/dist/base64.d.ts +2 -0
- package/dist/base64.js +29 -0
- package/dist/base64.js.map +1 -0
- package/dist/helpers.d.ts +63 -0
- package/dist/helpers.js +146 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +221 -0
- package/dist/index.js +1123 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { LogLevelDesc } from 'loglevel';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
4
|
+
import { createResponse, ActionEvent, RESPONSE_TYPE, parseClassValidatorErrors, ValidationError } from './helpers';
|
|
5
|
+
export { ActionEvent, createResponse, RESPONSE_TYPE, parseClassValidatorErrors, ValidationError };
|
|
6
|
+
declare enum LogLevel {
|
|
7
|
+
VERBOSE = 1,
|
|
8
|
+
DEBUG = 2,
|
|
9
|
+
ERROR = 3
|
|
10
|
+
}
|
|
11
|
+
interface LogMessage {
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
message: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ServiceResponse {
|
|
16
|
+
errorCode: string;
|
|
17
|
+
serviceId: string;
|
|
18
|
+
status: number;
|
|
19
|
+
errors: string[];
|
|
20
|
+
response: any;
|
|
21
|
+
durationInMilliseconds: number;
|
|
22
|
+
executionDurationInMilliseconds: number;
|
|
23
|
+
headers: {
|
|
24
|
+
[key: string]: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface RbsJwtPayload {
|
|
28
|
+
serviceId?: string;
|
|
29
|
+
projectId?: string;
|
|
30
|
+
clientId?: string;
|
|
31
|
+
userId?: string;
|
|
32
|
+
anonymous?: boolean;
|
|
33
|
+
identity?: string;
|
|
34
|
+
iat?: number;
|
|
35
|
+
exp?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface RBSTokenData {
|
|
38
|
+
accessToken: string;
|
|
39
|
+
refreshToken: string;
|
|
40
|
+
firebaseToken?: string;
|
|
41
|
+
accessTokenExpiresAt: number;
|
|
42
|
+
refreshTokenExpiresAt: number;
|
|
43
|
+
isServiceToken: boolean;
|
|
44
|
+
firebase?: FirebaseConfig;
|
|
45
|
+
}
|
|
46
|
+
declare type SuccessCallBack = (resp: any) => any;
|
|
47
|
+
declare type ErrorCallBack = (e: any) => any;
|
|
48
|
+
export interface RBSAction {
|
|
49
|
+
action?: string;
|
|
50
|
+
targetServiceId?: string;
|
|
51
|
+
relatedUserId?: string;
|
|
52
|
+
data?: any;
|
|
53
|
+
culture?: string;
|
|
54
|
+
headers?: {
|
|
55
|
+
[key: string]: string;
|
|
56
|
+
};
|
|
57
|
+
pop?: boolean;
|
|
58
|
+
token?: string;
|
|
59
|
+
generateGetUrl?: boolean;
|
|
60
|
+
onSuccess?: SuccessCallBack;
|
|
61
|
+
onError?: ErrorCallBack;
|
|
62
|
+
}
|
|
63
|
+
interface FirebaseConfig {
|
|
64
|
+
apiKey: string;
|
|
65
|
+
projectId: string;
|
|
66
|
+
customToken: string;
|
|
67
|
+
}
|
|
68
|
+
interface RBSActionWrapper {
|
|
69
|
+
action?: RBSAction;
|
|
70
|
+
tokenData?: RBSTokenData;
|
|
71
|
+
response?: any;
|
|
72
|
+
responseError?: Error;
|
|
73
|
+
url?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface RbsRegionConfiguration {
|
|
76
|
+
regionId?: RbsRegion;
|
|
77
|
+
getUrl: string;
|
|
78
|
+
url: string;
|
|
79
|
+
apiUrl: string;
|
|
80
|
+
}
|
|
81
|
+
export declare enum RbsRegion {
|
|
82
|
+
euWest1 = 0,
|
|
83
|
+
euWest1Beta = 1
|
|
84
|
+
}
|
|
85
|
+
interface RBSClientConfig {
|
|
86
|
+
projectId: string;
|
|
87
|
+
secretKey?: string;
|
|
88
|
+
developerId?: string;
|
|
89
|
+
serviceId?: string;
|
|
90
|
+
region?: RbsRegion;
|
|
91
|
+
regionConfiguration?: RbsRegionConfiguration;
|
|
92
|
+
anonymTokenTTL?: number;
|
|
93
|
+
logLevel?: LogLevelDesc;
|
|
94
|
+
platform?: string;
|
|
95
|
+
}
|
|
96
|
+
export declare enum RBSAuthStatus {
|
|
97
|
+
SIGNED_IN = "SIGNED_IN",
|
|
98
|
+
SIGNED_IN_ANONYM = "SIGNED_IN_ANONYM",
|
|
99
|
+
SIGNED_OUT = "SIGNED_OUT",
|
|
100
|
+
AUTH_FAILED = "AUTH_FAILED"
|
|
101
|
+
}
|
|
102
|
+
export interface RBSAuthChangedEvent {
|
|
103
|
+
authStatus: RBSAuthStatus;
|
|
104
|
+
identity?: string;
|
|
105
|
+
uid?: string;
|
|
106
|
+
message?: string;
|
|
107
|
+
}
|
|
108
|
+
interface RBSCloudObjectStates {
|
|
109
|
+
role: Observable<any> | null;
|
|
110
|
+
user: Observable<any> | null;
|
|
111
|
+
public: Observable<any> | null;
|
|
112
|
+
}
|
|
113
|
+
interface RBSCloudObjectMethod {
|
|
114
|
+
tag?: string;
|
|
115
|
+
name: string;
|
|
116
|
+
sync?: boolean;
|
|
117
|
+
readonly?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface RBSCloudObjectState {
|
|
120
|
+
role: {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
};
|
|
123
|
+
user: {
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
};
|
|
126
|
+
public: {
|
|
127
|
+
[key: string]: any;
|
|
128
|
+
};
|
|
129
|
+
private: {
|
|
130
|
+
[key: string]: any;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export declare type RBSCallResponse<T> = Omit<AxiosResponse<T>, 'config' | 'request'>;
|
|
134
|
+
export interface RBSCloudObject {
|
|
135
|
+
instanceId: string;
|
|
136
|
+
isNewInstance: boolean;
|
|
137
|
+
methods: RBSCloudObjectMethod[];
|
|
138
|
+
call(params: RBSCloudObjectCallData): Promise<RBSCallResponse<any>>;
|
|
139
|
+
getState(params?: RBSCloudObjectRequest): Promise<RBSCallResponse<RBSCloudObjectState>>;
|
|
140
|
+
state?: RBSCloudObjectStates;
|
|
141
|
+
}
|
|
142
|
+
export interface RBSCloudObjectData {
|
|
143
|
+
classId: string;
|
|
144
|
+
key?: {
|
|
145
|
+
name: string;
|
|
146
|
+
value: string;
|
|
147
|
+
};
|
|
148
|
+
instanceId?: string;
|
|
149
|
+
method?: string;
|
|
150
|
+
headers?: {
|
|
151
|
+
[key: string]: string;
|
|
152
|
+
};
|
|
153
|
+
querystring?: {
|
|
154
|
+
[key: string]: string;
|
|
155
|
+
};
|
|
156
|
+
httpMethod?: 'get' | 'delete' | 'post' | 'put';
|
|
157
|
+
payload?: {
|
|
158
|
+
[key: string]: any;
|
|
159
|
+
};
|
|
160
|
+
useLocal?: boolean;
|
|
161
|
+
token?: string;
|
|
162
|
+
}
|
|
163
|
+
export declare type RBSCloudObjectRequest = Omit<RBSCloudObjectData, 'classId' | 'useLocal'>;
|
|
164
|
+
export interface RBSCloudObjectCallData extends RBSCloudObjectRequest {
|
|
165
|
+
method: string;
|
|
166
|
+
}
|
|
167
|
+
export default class RBS {
|
|
168
|
+
private static instances;
|
|
169
|
+
private firebaseApp;
|
|
170
|
+
private firestore;
|
|
171
|
+
private firebaseAuth;
|
|
172
|
+
private cloudObjects;
|
|
173
|
+
private commandQueue;
|
|
174
|
+
private customAuthQueue;
|
|
175
|
+
private clientConfig;
|
|
176
|
+
private axiosInstance;
|
|
177
|
+
private latestTokenData?;
|
|
178
|
+
private initialized;
|
|
179
|
+
isNode(): boolean;
|
|
180
|
+
private authStatusSubject;
|
|
181
|
+
get authStatus(): Observable<RBSAuthChangedEvent>;
|
|
182
|
+
private getServiceEndpoint;
|
|
183
|
+
private getRegion;
|
|
184
|
+
private getApiUrl;
|
|
185
|
+
private getBaseUrl;
|
|
186
|
+
private constructor();
|
|
187
|
+
static clearTokens(): void;
|
|
188
|
+
static getInstance(config?: RBSClientConfig | null): RBS;
|
|
189
|
+
static dispose(): void;
|
|
190
|
+
init(config: RBSClientConfig): void;
|
|
191
|
+
getAuthChangedEvent: (tokenData: RBSTokenData | undefined) => RBSAuthChangedEvent;
|
|
192
|
+
fireAuthStatus: (tokenData: RBSTokenData | undefined) => void;
|
|
193
|
+
_getStoredTokenData: () => Promise<RBSTokenData | undefined>;
|
|
194
|
+
logMessage: (logMessage: LogMessage) => void;
|
|
195
|
+
getActionWithTokenData: (actionWrapper: RBSActionWrapper) => Promise<RBSActionWrapper>;
|
|
196
|
+
getP: <T>(url: string, queryParams?: object | undefined) => Promise<T>;
|
|
197
|
+
getPlatform: () => string;
|
|
198
|
+
request: (url: string, actionWrapper: RBSActionWrapper) => Promise<RBSActionWrapper>;
|
|
199
|
+
post: (url: string, actionWrapper: RBSActionWrapper) => Promise<RBSActionWrapper>;
|
|
200
|
+
getParams: (actionWrapper: RBSActionWrapper) => any;
|
|
201
|
+
get: (url: string, actionWrapper: RBSActionWrapper) => Promise<RBSActionWrapper>;
|
|
202
|
+
getPlain: (url: string, params: any, actionWrapper: RBSActionWrapper) => Promise<RBSActionWrapper>;
|
|
203
|
+
getSafeNow: () => number;
|
|
204
|
+
getTokenDataKey: () => string;
|
|
205
|
+
setTokenData: (tokenData: RBSTokenData) => Promise<void>;
|
|
206
|
+
getStoredTokenData: () => Promise<RBSTokenData | undefined>;
|
|
207
|
+
getUser: () => Promise<RbsJwtPayload | null>;
|
|
208
|
+
generatePublicGetActionUrl: (action: RBSAction) => string;
|
|
209
|
+
generateGetActionUrl: (action: RBSAction) => Promise<string>;
|
|
210
|
+
send: (action: RBSAction) => Promise<ServiceResponse[] | any>;
|
|
211
|
+
authenticateWithCustomToken: (userId: string, token: string) => Promise<RBSAuthChangedEvent>;
|
|
212
|
+
signInAnonymously: () => Promise<void>;
|
|
213
|
+
signOut: () => Promise<boolean>;
|
|
214
|
+
protected logoutUser: () => Promise<boolean>;
|
|
215
|
+
protected initFirebase: () => Promise<void>;
|
|
216
|
+
private getFirebaseListeners;
|
|
217
|
+
private cleanInitFirebase;
|
|
218
|
+
private isCosAction;
|
|
219
|
+
private getCosEndpoint;
|
|
220
|
+
getCloudObject: (data: RBSCloudObjectData) => Promise<RBSCloudObject>;
|
|
221
|
+
}
|