@lemoncloud/clipbiz-backend-api 0.25.1019
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 +4 -0
- package/dist/cores/types.d.ts +217 -0
- package/dist/modules/auth/model.d.ts +285 -0
- package/dist/modules/auth/oauth2/oauth2-model.d.ts +350 -0
- package/dist/modules/auth/oauth2/oauth2-types.d.ts +421 -0
- package/dist/modules/auth/types.d.ts +318 -0
- package/dist/modules/auth/views.d.ts +266 -0
- package/dist/modules/mock/model.d.ts +100 -0
- package/dist/modules/mock/types.d.ts +42 -0
- package/dist/modules/mock/views.d.ts +49 -0
- package/dist/modules/request/model.d.ts +88 -0
- package/dist/modules/request/types.d.ts +96 -0
- package/dist/modules/request/views.d.ts +34 -0
- package/dist/modules/terms/model.d.ts +81 -0
- package/dist/modules/terms/types.d.ts +44 -0
- package/dist/modules/terms/views.d.ts +30 -0
- package/dist/service/backend-types.d.ts +189 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/view/types.d.ts +205 -0
- package/package.json +24 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `oauth2-types.ts`
|
|
3
|
+
* - common type definitions for oauth2-service
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* @author Steve Jung <steve@lemoncloud.io>
|
|
7
|
+
* @date 2023-03-03 optimized with `lemon-core#3.2.5`
|
|
8
|
+
*
|
|
9
|
+
* @copyright (C) lemoncloud.io 2023 - All Rights Reserved.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Lookup Table
|
|
13
|
+
*
|
|
14
|
+
* WARN! DO NOT EXPORT AS `$LUT`. use default export instead.
|
|
15
|
+
*/
|
|
16
|
+
declare const $LUT: {
|
|
17
|
+
/**
|
|
18
|
+
* SiteStereo.
|
|
19
|
+
*/
|
|
20
|
+
SiteStereo: {
|
|
21
|
+
/** empty */
|
|
22
|
+
'': string;
|
|
23
|
+
/** (internal) alias type */
|
|
24
|
+
'#alias': string;
|
|
25
|
+
/** created per domain automatically (aliased by `@<domain>`) */
|
|
26
|
+
domain: string;
|
|
27
|
+
/** created by session(identity-token) automatically (alias by `@<iss>/sites/<sid>`) */
|
|
28
|
+
session: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* HostStereo.
|
|
32
|
+
*/
|
|
33
|
+
HostStereo: {
|
|
34
|
+
/** empty */
|
|
35
|
+
'': string;
|
|
36
|
+
/** (internal) alias type */
|
|
37
|
+
'#alias': string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* AccountStereo w/ prefix
|
|
41
|
+
*/
|
|
42
|
+
AccountStereo: {
|
|
43
|
+
/** empty */
|
|
44
|
+
'': string;
|
|
45
|
+
/** (internal) alias type */
|
|
46
|
+
'#alias': string;
|
|
47
|
+
/** iid (ex: identity-id) */
|
|
48
|
+
iid: string;
|
|
49
|
+
/** login (ex: admin) */
|
|
50
|
+
login: string;
|
|
51
|
+
/** phone (ex: 01012345678) */
|
|
52
|
+
phone: string;
|
|
53
|
+
/** email (ex: abc@test.com) */
|
|
54
|
+
email: string;
|
|
55
|
+
/** social (ex: google:123455) */
|
|
56
|
+
social: string;
|
|
57
|
+
/** session (see `user.alias`) */
|
|
58
|
+
session: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* UserStereo.
|
|
62
|
+
*/
|
|
63
|
+
UserStereo: {
|
|
64
|
+
/** empty */
|
|
65
|
+
'': string;
|
|
66
|
+
/** (internal) alias type */
|
|
67
|
+
'#alias': string;
|
|
68
|
+
/** created by session(identity-token) automatically (alias by `@<iss>/users/<uid>`) */
|
|
69
|
+
session: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* GroupStereo.
|
|
73
|
+
*/
|
|
74
|
+
GroupStereo: {
|
|
75
|
+
/** empty */
|
|
76
|
+
'': string;
|
|
77
|
+
/** (internal) alias type */
|
|
78
|
+
'#alias': string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* RoleStereo.
|
|
82
|
+
*/
|
|
83
|
+
RoleStereo: {
|
|
84
|
+
/** empty */
|
|
85
|
+
'': string;
|
|
86
|
+
/** (internal) alias type */
|
|
87
|
+
'#alias': string;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* AuthStereo.
|
|
91
|
+
*/
|
|
92
|
+
AuthStereo: {
|
|
93
|
+
/** empty */
|
|
94
|
+
'': string;
|
|
95
|
+
/** (internal) alias type */
|
|
96
|
+
'#alias': string;
|
|
97
|
+
/** created by session(identity-token) automatically (alias by `@<iss>/auths/<aid>`) */
|
|
98
|
+
session: string;
|
|
99
|
+
/** login by phone */
|
|
100
|
+
phone: string;
|
|
101
|
+
/** login by email */
|
|
102
|
+
email: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* InviteStereo.
|
|
106
|
+
*/
|
|
107
|
+
InviteStereo: {
|
|
108
|
+
/** empty */
|
|
109
|
+
'': string;
|
|
110
|
+
/** (internal) alias type */
|
|
111
|
+
'#alias': string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* type: `AccountStereo`
|
|
116
|
+
*/
|
|
117
|
+
export declare type AccountStereo = keyof typeof $LUT.AccountStereo;
|
|
118
|
+
/**
|
|
119
|
+
* type: `SiteStereo`
|
|
120
|
+
*/
|
|
121
|
+
export declare type SiteStereo = keyof typeof $LUT.SiteStereo;
|
|
122
|
+
/**
|
|
123
|
+
* type: `HostStereo`
|
|
124
|
+
*/
|
|
125
|
+
export declare type HostStereo = keyof typeof $LUT.HostStereo;
|
|
126
|
+
/**
|
|
127
|
+
* type: `UserStereo`
|
|
128
|
+
*/
|
|
129
|
+
export declare type UserStereo = keyof typeof $LUT.UserStereo;
|
|
130
|
+
/**
|
|
131
|
+
* type: `GroupStereo`
|
|
132
|
+
*/
|
|
133
|
+
export declare type GroupStereo = keyof typeof $LUT.GroupStereo;
|
|
134
|
+
/**
|
|
135
|
+
* type: `RoleStereo`
|
|
136
|
+
*/
|
|
137
|
+
export declare type RoleStereo = keyof typeof $LUT.RoleStereo;
|
|
138
|
+
/**
|
|
139
|
+
* type: `AuthStereo`
|
|
140
|
+
*/
|
|
141
|
+
export declare type AuthStereo = keyof typeof $LUT.AuthStereo;
|
|
142
|
+
/**
|
|
143
|
+
* type: `InviteStereo`
|
|
144
|
+
*/
|
|
145
|
+
export declare type InviteStereo = keyof typeof $LUT.InviteStereo;
|
|
146
|
+
/**
|
|
147
|
+
* AWS Credentials to use
|
|
148
|
+
*/
|
|
149
|
+
export interface AWSCredentials {
|
|
150
|
+
/**
|
|
151
|
+
* The Access Key portion of the credentials.
|
|
152
|
+
*/
|
|
153
|
+
AccessKeyId?: string;
|
|
154
|
+
/**
|
|
155
|
+
* The Secret Access Key portion of the credentials
|
|
156
|
+
*/
|
|
157
|
+
SecretKey?: string;
|
|
158
|
+
/**
|
|
159
|
+
* The Session Token portion of the credentials
|
|
160
|
+
*/
|
|
161
|
+
SessionToken?: string;
|
|
162
|
+
/**
|
|
163
|
+
* The date at which these credentials will expire.
|
|
164
|
+
*/
|
|
165
|
+
Expiration?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* token-result from final authentication.
|
|
169
|
+
*/
|
|
170
|
+
export interface OAuthTokenResult {
|
|
171
|
+
/**
|
|
172
|
+
* error message if failed
|
|
173
|
+
*/
|
|
174
|
+
error?: string;
|
|
175
|
+
/**
|
|
176
|
+
* auth-id via origin authorize request.
|
|
177
|
+
*/
|
|
178
|
+
authId?: string;
|
|
179
|
+
/**
|
|
180
|
+
* account-id if logged successfully.
|
|
181
|
+
*/
|
|
182
|
+
accountId?: string;
|
|
183
|
+
/**
|
|
184
|
+
* identity-pool-id of STS
|
|
185
|
+
*/
|
|
186
|
+
identityPoolId?: string;
|
|
187
|
+
/**
|
|
188
|
+
* identity-id of authorized.
|
|
189
|
+
*/
|
|
190
|
+
identityId?: string;
|
|
191
|
+
/**
|
|
192
|
+
* known as `identity-token` in format `jwt`
|
|
193
|
+
* - application에서 세션 정보(sid, uid)를 JWT형태로 저장해두기위해 이용됨
|
|
194
|
+
*/
|
|
195
|
+
identityToken?: string;
|
|
196
|
+
/**
|
|
197
|
+
* access credentials to use.
|
|
198
|
+
*/
|
|
199
|
+
credential?: AWSCredentials;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* API request-param
|
|
203
|
+
* - param of `/oauth/<id>/refresh`
|
|
204
|
+
*/
|
|
205
|
+
export interface OAuthRefreshParam {
|
|
206
|
+
/**
|
|
207
|
+
* expired time of identity-token in second (default 1day)
|
|
208
|
+
* - if less than 1000000000, expired-time will be `current + expires`
|
|
209
|
+
* - otherwise, the timestampe of expired-time (in sec)
|
|
210
|
+
* - min: current, max: current + 1day.
|
|
211
|
+
* - use `env.MAX_JWT_EXPIRES_DAY`
|
|
212
|
+
*/
|
|
213
|
+
expires?: number;
|
|
214
|
+
/**
|
|
215
|
+
* (optional) refresh-token timeout for credential in second (default 1d)
|
|
216
|
+
* - aws credential timeout is 1hour (static).
|
|
217
|
+
* - min: 0 (1s), max: 60 * 60 * 24 (24h)
|
|
218
|
+
*/
|
|
219
|
+
timeout?: number;
|
|
220
|
+
/**
|
|
221
|
+
* (optional) force to issue token if role has chaned w/o 40X error.
|
|
222
|
+
*/
|
|
223
|
+
force?: string | number;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* body of `/oauth/refresh`
|
|
227
|
+
*/
|
|
228
|
+
export interface OAuthRefreshBody {
|
|
229
|
+
/**
|
|
230
|
+
* the current timestamp(ISO) of client
|
|
231
|
+
*
|
|
232
|
+
* ```ts
|
|
233
|
+
* const time = 1678793532758;
|
|
234
|
+
* const current = new Date(time).toISOString();
|
|
235
|
+
* expect(current).toEqual('2023-03-14T11:32:12.758Z');
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
current?: string;
|
|
239
|
+
/**
|
|
240
|
+
* the calclated signature string
|
|
241
|
+
*
|
|
242
|
+
* **[WORKFLOW]**
|
|
243
|
+
* 1. (pre) save identity-token in local-storage when issuing token.
|
|
244
|
+
* 2. load auth-id, account-id, identity-token, identity-id.
|
|
245
|
+
* 3. set current := new Date().toISOString()
|
|
246
|
+
* 4. set signature := Signature([current, account-id, identity-id, identity-token, user-agent].join('&'), auth-id)
|
|
247
|
+
* 5. post /refresh with current, auth-id, signature.
|
|
248
|
+
* 6. fails if time-diff is over 30min, or wrong signature.
|
|
249
|
+
*
|
|
250
|
+
* ```ts
|
|
251
|
+
* const hmac = (data: string, sig: string) => this.hmac(data, sig);
|
|
252
|
+
* const data = [current, accountId, identityId, identityToken, userAgent].join('&');
|
|
253
|
+
* const signature = hmac(hmac(hmac(data, authId), accountId), identityId);
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
signature?: string;
|
|
257
|
+
/**
|
|
258
|
+
* (optional) user-agent to override.
|
|
259
|
+
*/
|
|
260
|
+
userAgent?: string;
|
|
261
|
+
/**
|
|
262
|
+
* target domain to get `identity-token`
|
|
263
|
+
* - only used to get new `identity-token`
|
|
264
|
+
*/
|
|
265
|
+
domain?: string;
|
|
266
|
+
/**
|
|
267
|
+
* (optional) target user+site to switch (or get token)
|
|
268
|
+
* - `<uid>@<sid>`
|
|
269
|
+
*/
|
|
270
|
+
target?: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* type: `asAccountKeyParams`
|
|
274
|
+
*/
|
|
275
|
+
export interface asAccountKeyOptions {
|
|
276
|
+
/** prefix string (default undefined) */
|
|
277
|
+
prefix?: string;
|
|
278
|
+
/** delimiter between token (default '.') */
|
|
279
|
+
delim?: string;
|
|
280
|
+
/** (default true) */
|
|
281
|
+
useHash?: boolean;
|
|
282
|
+
/** (default true) */
|
|
283
|
+
useLength?: boolean;
|
|
284
|
+
/** (default true) */
|
|
285
|
+
throwable?: boolean;
|
|
286
|
+
/** errScope to override */
|
|
287
|
+
errScope?: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* type: `AccountKey`
|
|
291
|
+
* - the detailed key component
|
|
292
|
+
*/
|
|
293
|
+
export interface AccountKey {
|
|
294
|
+
/** the final id like <prefix>.<key>.<len> */
|
|
295
|
+
_id: string;
|
|
296
|
+
/** the hashed key */
|
|
297
|
+
key: string;
|
|
298
|
+
/** the length of alias */
|
|
299
|
+
len: string;
|
|
300
|
+
/** the prefix string */
|
|
301
|
+
prefix: string;
|
|
302
|
+
/** (optional) original alias */
|
|
303
|
+
alias?: string;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* common jwt properties
|
|
307
|
+
*/
|
|
308
|
+
export interface JwtCommonPart {
|
|
309
|
+
/**
|
|
310
|
+
* expired at (sec)
|
|
311
|
+
*/
|
|
312
|
+
exp?: number;
|
|
313
|
+
/**
|
|
314
|
+
* issued at (sec)
|
|
315
|
+
* = Math.floor(current_ms / 1000)
|
|
316
|
+
*/
|
|
317
|
+
iat?: number;
|
|
318
|
+
/**
|
|
319
|
+
* issuer name.
|
|
320
|
+
*/
|
|
321
|
+
iss?: string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* type: `Domain$`
|
|
325
|
+
*/
|
|
326
|
+
export interface Domain$ {
|
|
327
|
+
/** site-code or host-name */
|
|
328
|
+
host: string;
|
|
329
|
+
/** base domain if applicable */
|
|
330
|
+
base: string;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Response
|
|
334
|
+
*/
|
|
335
|
+
export interface OAuthAPITokenResult<S = any, U = any> extends OAuthTokenResult {
|
|
336
|
+
/** (optional) the current site-info */
|
|
337
|
+
readonly $site?: S;
|
|
338
|
+
/**
|
|
339
|
+
* (optional) the linked user-info
|
|
340
|
+
*/
|
|
341
|
+
readonly $user?: U;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* API request-body
|
|
345
|
+
* - body of `/oauth/<id>/token`
|
|
346
|
+
*/
|
|
347
|
+
export interface OAuthTokenBody {
|
|
348
|
+
/**
|
|
349
|
+
* code to verify token
|
|
350
|
+
*/
|
|
351
|
+
code: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* body of `/verify-native-token`.
|
|
355
|
+
*/
|
|
356
|
+
export interface VerifyNativeTokenBody {
|
|
357
|
+
/**
|
|
358
|
+
* provider of this token
|
|
359
|
+
*/
|
|
360
|
+
provider?: string | 'test';
|
|
361
|
+
/**
|
|
362
|
+
* (optional) id-token
|
|
363
|
+
* - google: https://developers.google.com/identity/sign-in/web/backend-auth?hl=ko
|
|
364
|
+
*/
|
|
365
|
+
idToken?: string;
|
|
366
|
+
/**
|
|
367
|
+
* (optional) identity-token for apple-id
|
|
368
|
+
* - google: https://developers.google.com/identity/sign-in/web/backend-auth?hl=ko
|
|
369
|
+
*/
|
|
370
|
+
identityToken?: string;
|
|
371
|
+
/**
|
|
372
|
+
* access-token (in format of jwt)
|
|
373
|
+
*/
|
|
374
|
+
accessToken?: string;
|
|
375
|
+
/**
|
|
376
|
+
* refresh-token
|
|
377
|
+
*/
|
|
378
|
+
refreshToken?: string;
|
|
379
|
+
/** (optional) signature for `test` provider */
|
|
380
|
+
signature?: string;
|
|
381
|
+
/** (optional) client-id if used */
|
|
382
|
+
clientId?: string;
|
|
383
|
+
/**
|
|
384
|
+
* timestamp of client (ex: 2025-07-03T06:51:54.603Z)
|
|
385
|
+
*
|
|
386
|
+
* TODO - support `current` as string
|
|
387
|
+
* - if not provided, use `new Date().toISOString()`
|
|
388
|
+
* - used to save the time gap between server and client.
|
|
389
|
+
*/
|
|
390
|
+
current?: string;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* boolean style parameter
|
|
394
|
+
*/
|
|
395
|
+
export declare type BoolParam = boolean | 1 | 0 | '' | '1' | '0';
|
|
396
|
+
/**
|
|
397
|
+
* param of `/login-user`
|
|
398
|
+
*/
|
|
399
|
+
export interface OAuthLoginUserParam {
|
|
400
|
+
/** loginId is phone */
|
|
401
|
+
phone?: BoolParam;
|
|
402
|
+
/** loginId is email */
|
|
403
|
+
email?: BoolParam;
|
|
404
|
+
/** flag to issue token */
|
|
405
|
+
token?: BoolParam;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* body of `/login-user`
|
|
409
|
+
*/
|
|
410
|
+
export interface OAuthLoginUserBody {
|
|
411
|
+
/**
|
|
412
|
+
* user-id (or phone)
|
|
413
|
+
*/
|
|
414
|
+
uid?: string;
|
|
415
|
+
/**
|
|
416
|
+
* password (or code)
|
|
417
|
+
*/
|
|
418
|
+
pwd?: string;
|
|
419
|
+
}
|
|
420
|
+
/** must export $LUT as default */
|
|
421
|
+
export default $LUT;
|