@or-sdk/authorizer 0.25.0-beta.647.0 → 0.25.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.
Files changed (140) hide show
  1. package/CHANGELOG.md +341 -0
  2. package/README.md +12 -32
  3. package/dist/cjs/Basic/BasicCollection.js +261 -28
  4. package/dist/cjs/Basic/BasicCollection.js.map +1 -1
  5. package/dist/cjs/Basic/index.js +21 -0
  6. package/dist/cjs/Basic/index.js.map +1 -0
  7. package/dist/cjs/Basic/utils/createAuthKey.js +4 -0
  8. package/dist/cjs/Basic/utils/createAuthKey.js.map +1 -1
  9. package/dist/cjs/OAuth/OAuth.js +115 -132
  10. package/dist/cjs/OAuth/OAuth.js.map +1 -1
  11. package/dist/cjs/OAuth/index.js +21 -0
  12. package/dist/cjs/OAuth/index.js.map +1 -0
  13. package/dist/cjs/OAuth/types.js +1 -1
  14. package/dist/cjs/OAuth/types.js.map +1 -1
  15. package/dist/cjs/OAuth/utils/ServiceDefinition.js.map +1 -1
  16. package/dist/cjs/OAuth/utils/createAuthKey.js +4 -0
  17. package/dist/cjs/OAuth/utils/createAuthKey.js.map +1 -1
  18. package/dist/cjs/OAuth/utils/createOAuthHelper.js +379 -0
  19. package/dist/cjs/OAuth/utils/createOAuthHelper.js.map +1 -0
  20. package/dist/cjs/OAuth/utils/formatScope.js.map +1 -1
  21. package/dist/cjs/OAuthCollection/OAuthCollection.js +312 -0
  22. package/dist/cjs/OAuthCollection/OAuthCollection.js.map +1 -0
  23. package/dist/cjs/OAuthCollection/index.js +21 -0
  24. package/dist/cjs/OAuthCollection/index.js.map +1 -0
  25. package/dist/cjs/Token/TokenCollection.js +238 -27
  26. package/dist/cjs/Token/TokenCollection.js.map +1 -1
  27. package/dist/cjs/Token/index.js +21 -0
  28. package/dist/cjs/Token/index.js.map +1 -0
  29. package/dist/cjs/Token/utils/createAuthKey.js +4 -0
  30. package/dist/cjs/Token/utils/createAuthKey.js.map +1 -1
  31. package/dist/cjs/constants.js +3 -2
  32. package/dist/cjs/constants.js.map +1 -1
  33. package/dist/cjs/index.js +9 -13
  34. package/dist/cjs/index.js.map +1 -1
  35. package/dist/esm/Basic/BasicCollection.js +204 -33
  36. package/dist/esm/Basic/BasicCollection.js.map +1 -1
  37. package/dist/esm/Basic/index.js +3 -0
  38. package/dist/esm/Basic/index.js.map +1 -0
  39. package/dist/esm/Basic/utils/createAuthKey.js +3 -0
  40. package/dist/esm/Basic/utils/createAuthKey.js.map +1 -1
  41. package/dist/esm/OAuth/OAuth.js +189 -211
  42. package/dist/esm/OAuth/OAuth.js.map +1 -1
  43. package/dist/esm/OAuth/index.js +3 -0
  44. package/dist/esm/OAuth/index.js.map +1 -0
  45. package/dist/esm/OAuth/types.js.map +1 -1
  46. package/dist/esm/OAuth/utils/ServiceDefinition.js +0 -17
  47. package/dist/esm/OAuth/utils/ServiceDefinition.js.map +1 -1
  48. package/dist/esm/OAuth/utils/createAuthKey.js +3 -0
  49. package/dist/esm/OAuth/utils/createAuthKey.js.map +1 -1
  50. package/dist/esm/OAuth/utils/createOAuthHelper.js +262 -0
  51. package/dist/esm/OAuth/utils/createOAuthHelper.js.map +1 -0
  52. package/dist/esm/OAuth/utils/formatScope.js.map +1 -1
  53. package/dist/esm/OAuthCollection/OAuthCollection.js +190 -0
  54. package/dist/esm/OAuthCollection/OAuthCollection.js.map +1 -0
  55. package/dist/esm/OAuthCollection/index.js +3 -0
  56. package/dist/esm/OAuthCollection/index.js.map +1 -0
  57. package/dist/esm/Token/TokenCollection.js +181 -32
  58. package/dist/esm/Token/TokenCollection.js.map +1 -1
  59. package/dist/esm/Token/index.js +3 -0
  60. package/dist/esm/Token/index.js.map +1 -0
  61. package/dist/esm/Token/utils/createAuthKey.js +3 -0
  62. package/dist/esm/Token/utils/createAuthKey.js.map +1 -1
  63. package/dist/esm/constants.js +1 -0
  64. package/dist/esm/constants.js.map +1 -1
  65. package/dist/esm/index.js +4 -6
  66. package/dist/esm/index.js.map +1 -1
  67. package/dist/types/Basic/BasicCollection.d.ts +20 -8
  68. package/dist/types/Basic/BasicCollection.d.ts.map +1 -1
  69. package/dist/types/Basic/index.d.ts +3 -0
  70. package/dist/types/Basic/index.d.ts.map +1 -0
  71. package/dist/types/Basic/types.d.ts +23 -12
  72. package/dist/types/Basic/types.d.ts.map +1 -1
  73. package/dist/types/Basic/utils/createAuthKey.d.ts +1 -0
  74. package/dist/types/Basic/utils/createAuthKey.d.ts.map +1 -1
  75. package/dist/types/OAuth/OAuth.d.ts +9 -6
  76. package/dist/types/OAuth/OAuth.d.ts.map +1 -1
  77. package/dist/types/OAuth/index.d.ts +3 -0
  78. package/dist/types/OAuth/index.d.ts.map +1 -0
  79. package/dist/types/OAuth/types.d.ts +102 -18
  80. package/dist/types/OAuth/types.d.ts.map +1 -1
  81. package/dist/types/OAuth/utils/createAuthKey.d.ts +1 -0
  82. package/dist/types/OAuth/utils/createAuthKey.d.ts.map +1 -1
  83. package/dist/types/OAuth/utils/createOAuthHelper.d.ts +33 -0
  84. package/dist/types/OAuth/utils/createOAuthHelper.d.ts.map +1 -0
  85. package/dist/types/OAuthCollection/OAuthCollection.d.ts +27 -0
  86. package/dist/types/OAuthCollection/OAuthCollection.d.ts.map +1 -0
  87. package/dist/types/OAuthCollection/index.d.ts +3 -0
  88. package/dist/types/OAuthCollection/index.d.ts.map +1 -0
  89. package/dist/types/Token/TokenCollection.d.ts +12 -8
  90. package/dist/types/Token/TokenCollection.d.ts.map +1 -1
  91. package/dist/types/Token/index.d.ts +3 -0
  92. package/dist/types/Token/index.d.ts.map +1 -0
  93. package/dist/types/Token/types.d.ts +21 -5
  94. package/dist/types/Token/types.d.ts.map +1 -1
  95. package/dist/types/Token/utils/createAuthKey.d.ts +1 -0
  96. package/dist/types/Token/utils/createAuthKey.d.ts.map +1 -1
  97. package/dist/types/constants.d.ts +1 -0
  98. package/dist/types/constants.d.ts.map +1 -1
  99. package/dist/types/index.d.ts +4 -6
  100. package/dist/types/index.d.ts.map +1 -1
  101. package/package.json +47 -8
  102. package/src/Basic/BasicCollection.ts +295 -32
  103. package/src/Basic/index.ts +3 -0
  104. package/src/Basic/types.ts +20 -15
  105. package/src/Basic/utils/createAuthKey.ts +4 -0
  106. package/src/OAuth/OAuth.ts +148 -174
  107. package/src/OAuth/index.ts +3 -0
  108. package/src/OAuth/types.ts +198 -13
  109. package/src/OAuth/utils/createAuthKey.ts +8 -0
  110. package/src/OAuth/utils/createOAuthHelper.ts +374 -0
  111. package/src/OAuthCollection/OAuthCollection.ts +348 -0
  112. package/src/OAuthCollection/index.ts +3 -0
  113. package/src/Token/TokenCollection.ts +259 -31
  114. package/src/Token/index.ts +3 -0
  115. package/src/Token/types.ts +17 -0
  116. package/src/Token/utils/createAuthKey.ts +4 -0
  117. package/src/constants.ts +1 -0
  118. package/src/index.ts +4 -8
  119. package/tsconfig.esm.json +1 -1
  120. package/dist/cjs/Basic/BasicAuth.js +0 -162
  121. package/dist/cjs/Basic/BasicAuth.js.map +0 -1
  122. package/dist/cjs/OAuth/OAuthCollection.js +0 -138
  123. package/dist/cjs/OAuth/OAuthCollection.js.map +0 -1
  124. package/dist/cjs/Token/TokenAuth.js +0 -140
  125. package/dist/cjs/Token/TokenAuth.js.map +0 -1
  126. package/dist/esm/Basic/BasicAuth.js +0 -77
  127. package/dist/esm/Basic/BasicAuth.js.map +0 -1
  128. package/dist/esm/OAuth/OAuthCollection.js +0 -60
  129. package/dist/esm/OAuth/OAuthCollection.js.map +0 -1
  130. package/dist/esm/Token/TokenAuth.js +0 -59
  131. package/dist/esm/Token/TokenAuth.js.map +0 -1
  132. package/dist/types/Basic/BasicAuth.d.ts +0 -20
  133. package/dist/types/Basic/BasicAuth.d.ts.map +0 -1
  134. package/dist/types/OAuth/OAuthCollection.d.ts +0 -15
  135. package/dist/types/OAuth/OAuthCollection.d.ts.map +0 -1
  136. package/dist/types/Token/TokenAuth.d.ts +0 -12
  137. package/dist/types/Token/TokenAuth.d.ts.map +0 -1
  138. package/src/Basic/BasicAuth.ts +0 -129
  139. package/src/OAuth/OAuthCollection.ts +0 -118
  140. package/src/Token/TokenAuth.ts +0 -102
@@ -1,78 +1,341 @@
1
- import { Token } from '@or-sdk/base';
1
+ import { List, makeList } from '@or-sdk/base';
2
+ import { Providers } from '@or-sdk/providers';
2
3
  import { KeyValueStorage } from '@or-sdk/key-value-storage';
3
- import { BasicAuth } from './BasicAuth';
4
+ import { createAuthKey, createDynamicKey } from './utils/createAuthKey';
5
+ import { v4 as uuidv4 } from 'uuid';
4
6
 
5
7
  import {
8
+ BasicAuthData,
6
9
  BasicCollectionConfig,
7
10
  CreateBasicAuthInCollectionConfig,
11
+ BasicDynamicCollection,
8
12
  } from './types';
9
13
 
10
14
  export class BasicCollection {
11
- private readonly serviceName: string;
15
+ private serviceName: string;
12
16
  private readonly keyValueStorage: KeyValueStorage;
13
- private readonly localToken: Token;
14
- private readonly localDiscoveryUrl: string;
17
+ private readonly providers: Providers;
15
18
 
16
19
  constructor(params: BasicCollectionConfig) {
17
- const { token, discoveryUrl, serviceName } = params;
20
+ const { token, discoveryUrl, serviceName, accountId } = params;
18
21
 
19
- this.localToken = token;
20
- this.localDiscoveryUrl = discoveryUrl;
21
- this.serviceName = serviceName;
22
+ this.serviceName = serviceName || '';
22
23
  this.keyValueStorage = new KeyValueStorage({
23
24
  token,
24
25
  discoveryUrl,
26
+ accountId,
27
+ });
28
+ this.providers = new Providers({
29
+ token,
30
+ discoveryUrl,
25
31
  });
26
32
  }
27
33
 
34
+
35
+ /**
36
+ * Allows to explicitly (re-)set authorization service name
37
+ */
38
+ public init(serviceName: string) {
39
+ if (!serviceName) throw new Error('Service name is required.');
40
+
41
+ this.serviceName = serviceName;
42
+ }
43
+
44
+
45
+ /**
46
+ * Encodes username and password into Basic authorization token
47
+ */
48
+ static encodeAccessToken(username: string, password: string): string {
49
+ return btoa(`${username}:${password}`);
50
+ }
51
+
52
+ /**
53
+ * Decodes base64 encoded token and parses it to username and password
54
+ */
55
+ static decodeAccessToken(token: string): {username: string; password: string;} {
56
+ const [username, password] = atob(token).split(':');
57
+ return {
58
+ username,
59
+ password,
60
+ };
61
+ }
62
+
63
+
28
64
  /**
29
65
  * Returns array of auth keys from this collection
30
66
  */
31
- public async listAuthorizations(): Promise<string[]> {
67
+ public async listAuthorizations(dynamicCollectionName?: string): Promise<List<string>> {
32
68
  const { items: records } = await this.keyValueStorage.listKeys(this.serviceName);
33
69
 
34
- return records.map((record) => record.key);
70
+ const pattern = dynamicCollectionName ? '::basic-collection::' + dynamicCollectionName : '::basic::';
71
+
72
+ return makeList<string>(records.map((record) => record.key).filter(key => key.includes(pattern)));
35
73
  }
36
74
 
75
+
37
76
  /**
38
77
  * Returns BasicAuth instance for given key
39
78
  */
40
- public async getAuthorization(key: string): Promise<BasicAuth> {
41
- const record = await this.keyValueStorage.getValueByKey(this.serviceName, key);
79
+ public async getAuthorization(key: string, dynamicCollectionName?: string): Promise<BasicAuthData> {
80
+ if (!this.serviceName) throw new Error('Service name is not defined.');
81
+
82
+ if (dynamicCollectionName) {
83
+ const collectionRecord = await this.keyValueStorage.getValueByKey(
84
+ '__authorizer_dynamic_collections',
85
+ dynamicCollectionName
86
+ );
87
+
88
+ const collection = collectionRecord.value as BasicDynamicCollection;
89
+ if (!collection || collection.type !== 'basic') throw new Error('Dynamic collection name is invalid');
90
+
91
+ key = collection.authorizations[key];
92
+ if (!key) throw new Error('Dynamic collection does not have such key');
93
+
94
+ }
95
+ if (!key.includes('::basic')) {
96
+ throw new Error('The basic authorization key should contain "basic" type specifier.');
97
+ }
98
+
99
+ const record = await this.keyValueStorage.getValueByKey(this.serviceName, encodeURIComponent(key));
100
+
42
101
  if (!record.value) {
43
- throw new Error('Authorization does not exist');
102
+ throw new Error('Authorization does not exist.');
44
103
  }
45
104
 
46
- return new BasicAuth({
47
- serviceName: this.serviceName,
48
- authKey: key,
49
- discoveryUrl: this.localDiscoveryUrl,
50
- token: this.localToken,
51
- });
105
+ const authRecord = record.value as Omit<BasicAuthData, 'key'>;
106
+
107
+ if (
108
+ !authRecord.auth_name ||
109
+ !authRecord.access_token ||
110
+ !(authRecord.date_created || authRecord._date_created)
111
+ ) {
112
+ throw new Error('Authorization does not exist or invalid.');
113
+ }
114
+
115
+ return {
116
+ ...authRecord,
117
+ key,
118
+ } as BasicAuthData;
52
119
  }
53
120
 
121
+
54
122
  /**
55
123
  * Creates a new auth record in current collection with the given config.
56
- * @returns BasicAuth instance connected to created auth
124
+ * @returns BasicAuthData object
57
125
  *
58
126
  * ```typescript
59
- * const basicAuthInstance = await basicCollectionInstance.createAuthorization({
127
+ * const basicAuthData = await basicCollectionInstance.createAuthorization({
60
128
  * authName: 'my-auth-name',
61
129
  * username: 'user',
62
- * password: 'pass'
130
+ * password: 'pass',
131
+ * dynamicCollection: 'my-dynamic-collection' // Optional
63
132
  * });
64
133
  * ```
65
134
  */
66
135
  public async createAuthorization(
67
136
  params: CreateBasicAuthInCollectionConfig
68
- ): Promise<BasicAuth> {
69
- return await BasicAuth.create({
70
- discoveryUrl: this.localDiscoveryUrl,
71
- token: this.localToken,
72
- serviceName: this.serviceName,
73
- authName: params.authName,
74
- password: params.password,
75
- username: params.username,
76
- });
137
+ ): Promise<BasicAuthData> {
138
+
139
+ const { authName, password, username, dynamicCollection, destinationAccount = 'CURRENT', customAccountId } = params;
140
+
141
+ if (!authName || !username || !password) {
142
+ throw new Error('Invalid authorization config passed.');
143
+ }
144
+
145
+ if (!this.serviceName) throw new Error('Service name is not defined.');
146
+
147
+
148
+ const id = uuidv4();
149
+ const authKey = dynamicCollection ? createDynamicKey(id, dynamicCollection) : createAuthKey(id, authName);
150
+
151
+ const authData = {
152
+ auth_name: authName,
153
+ access_token: BasicCollection.encodeAccessToken(username, password),
154
+ _date_created: new Date().toISOString(),
155
+ } as Omit<BasicAuthData, 'key'>;
156
+
157
+ if (dynamicCollection) {
158
+ const { value } = await this.keyValueStorage.getValueByKey(
159
+ '__authorizer_dynamic_collections',
160
+ dynamicCollection
161
+ );
162
+
163
+ const collection = value as BasicDynamicCollection;
164
+
165
+ if (!collection) throw new Error('Dynamic collection name is invalid');
166
+ if (collection.type !== 'basic' || collection.service !== this.serviceName) {
167
+ throw new Error('Dynamic collection\'s type or service is invalid');
168
+ }
169
+
170
+ collection.authorizations[authName] = authKey;
171
+ await this.keyValueStorage.setValueByKey(
172
+ '__authorizer_dynamic_collections',
173
+ dynamicCollection,
174
+ collection
175
+ );
176
+ }
177
+
178
+ // Accounts handling
179
+ if (destinationAccount === 'CURRENT') {
180
+ await this.keyValueStorage.setValueByKey(this.serviceName, encodeURIComponent(authKey), authData);
181
+ } else {
182
+ const localRecord = {
183
+ auth_name: authData.auth_name,
184
+ isRemote: true,
185
+ id,
186
+ };
187
+
188
+ if (destinationAccount === 'CUSTOM' && !customAccountId) {
189
+ throw new Error('Custom Account ID is required if destinationAccount === "CUSTOM"');
190
+ }
191
+
192
+ await this.providers.makeRequest({
193
+ route: 'authorizer/redirect',
194
+ params: {
195
+ method: 'PUT',
196
+ data: {
197
+ authData,
198
+ id,
199
+ storeAccount: destinationAccount,
200
+ storeCustomAccountId: destinationAccount === 'CUSTOM' ? customAccountId : undefined,
201
+ },
202
+ },
203
+ }).catch(() => { throw new Error('Could not save basic credentials to the specified account');});
204
+
205
+ await this.keyValueStorage.setValueByKey(this.serviceName, encodeURIComponent(authKey), localRecord);
206
+ }
207
+
208
+ return {
209
+ ...authData,
210
+ key: authKey,
211
+ } as BasicAuthData;
212
+ }
213
+
214
+
215
+ /**
216
+ * Returns array of auth keys from this collection
217
+ */
218
+ public async updateAuthorization(
219
+ basicAuth: BasicAuthData,
220
+ newCredentials: { username?: string; password?: string; }
221
+ ): Promise<BasicAuthData> {
222
+ if (!basicAuth || !basicAuth.key || !basicAuth.access_token) {
223
+ throw new Error('Authorization is invalid.');
224
+ }
225
+
226
+ if (!this.serviceName) throw new Error('Service name is not defined.');
227
+
228
+
229
+ let { username, password } = BasicCollection.decodeAccessToken(basicAuth.access_token);
230
+
231
+ if (newCredentials.username) {
232
+ username = newCredentials.username;
233
+ }
234
+ if (newCredentials.password) {
235
+ password = newCredentials.password;
236
+ }
237
+
238
+ const access_token = BasicCollection.encodeAccessToken(username, password);
239
+ const response = await this.keyValueStorage.setValueByKey(
240
+ this.serviceName,
241
+ encodeURIComponent(basicAuth.key),
242
+ {
243
+ auth_name: basicAuth.auth_name,
244
+ _date_created: basicAuth.date_created || basicAuth._date_created,
245
+ access_token,
246
+ }
247
+ );
248
+
249
+ const updatedData = response.value as Omit<BasicAuthData, 'key'>;
250
+ return {
251
+ ...updatedData,
252
+ key: basicAuth.key,
253
+ } as BasicAuthData;
254
+ }
255
+
256
+
257
+ /**
258
+ * Deletes authorization from collection
259
+ */
260
+ public async deleteAuthorization(authKey: string): Promise<void> {
261
+ if (!this.serviceName) throw new Error('Service name is not defined.');
262
+
263
+ if (authKey.includes('::basic-collection::')) {
264
+ const dynamicCollectionName = authKey.split('::')[2].split(' ')[0];
265
+ const { value } = await this.keyValueStorage.getValueByKey(
266
+ '__authorizer_dynamic_collections',
267
+ dynamicCollectionName
268
+ );
269
+
270
+ const collection = value as BasicDynamicCollection;
271
+ if (collection) {
272
+ const authName = Object.keys(collection.authorizations)
273
+ .find(name => collection.authorizations[name] === authKey);
274
+
275
+ if (authName) {
276
+ delete collection.authorizations[authName];
277
+ await this.keyValueStorage.setValueByKey(
278
+ '__authorizer_dynamic_collections',
279
+ dynamicCollectionName,
280
+ collection
281
+ );
282
+ }
283
+ }
284
+ }
285
+
286
+ await this.keyValueStorage.deleteKey(this.serviceName, encodeURIComponent(authKey));
287
+ }
288
+
289
+
290
+ /**
291
+ * Creates a Dynamic Token collection
292
+ */
293
+ public async createDynamicCollection(dynamicCollectionName: string): Promise<void> {
294
+ if (!dynamicCollectionName) throw new Error('Dynamic collection name is empty or invalid');
295
+ const { value } = await this.keyValueStorage.getValueByKey(
296
+ '__authorizer_dynamic_collections',
297
+ dynamicCollectionName
298
+ );
299
+ const collection = value as BasicDynamicCollection;
300
+
301
+ if (!value) {
302
+ await this.keyValueStorage.setValueByKey(
303
+ '__authorizer_dynamic_collections',
304
+ dynamicCollectionName,
305
+ {
306
+ name: dynamicCollectionName,
307
+ type: 'basic',
308
+ service: this.serviceName,
309
+ serviceConfigName: this.serviceName,
310
+ authorizations: {},
311
+ });
312
+ } else if (collection.type === 'oauth' && collection.service === this.serviceName) {
313
+ throw new Error('Same collection already exists');
314
+ } else {
315
+ throw new Error('Different collection exists with this name');
316
+ }
317
+ }
318
+
319
+
320
+ /**
321
+ * Deletes a Dynamic collection
322
+ */
323
+ public async deleteDynamicCollection(dynamicCollectionName: string): Promise<void> {
324
+ if (!dynamicCollectionName) throw new Error('Dynamic collection name is empty or invalid');
325
+ const { value } = await this.keyValueStorage.getValueByKey('__authorizer_dynamic_collections', dynamicCollectionName);
326
+ const collection = value as BasicDynamicCollection;
327
+
328
+ await Promise.all(
329
+ Object.keys(collection.authorizations)
330
+ .map(authName => {
331
+ return this.keyValueStorage.deleteKey(
332
+ collection.service,
333
+ encodeURIComponent(collection.authorizations[authName])
334
+ );
335
+ })
336
+ ).catch(() => {});
337
+
338
+ await this.keyValueStorage.deleteKey('__authorizer_dynamic_collections', dynamicCollectionName);
77
339
  }
78
340
  }
341
+
@@ -0,0 +1,3 @@
1
+ export { BasicCollection } from './BasicCollection';
2
+
3
+ export * from './types';
@@ -1,19 +1,7 @@
1
1
  import { Token } from '@or-sdk/base';
2
2
 
3
- export type BasicAuthConfig = {
4
- /**
5
- * token
6
- */
7
- token: Token;
8
- /**
9
- * function which return token
10
- */
11
- discoveryUrl: string;
12
- serviceName: string;
13
- authKey: string;
14
- };
15
-
16
3
  export type BasicAuthData = {
4
+ key: string;
17
5
  auth_name: string;
18
6
 
19
7
  /**
@@ -24,7 +12,8 @@ export type BasicAuthData = {
24
12
  /**
25
13
  * Datetime of auth creation in YYYY-MM-DDTHH:MM:SSZ format
26
14
  */
27
- date_created: string;
15
+ date_created?: string;
16
+ _date_created?: string;
28
17
  };
29
18
 
30
19
  export type CreateBasicAuthConfig = {
@@ -37,6 +26,9 @@ export type CreateBasicAuthConfig = {
37
26
  * token
38
27
  */
39
28
  token: Token;
29
+ dynamicCollection?: string;
30
+ destinationAccount: 'CURRENT' | 'CUSTOM' | 'PROVIDER';
31
+ customAccountId?: string;
40
32
  };
41
33
 
42
34
  export type CreateBasicAuthInCollectionConfig = Omit<CreateBasicAuthConfig, 'serviceName' | 'discoveryUrl' | 'token'>;
@@ -50,5 +42,18 @@ export type BasicCollectionConfig = {
50
42
  * function which return token
51
43
  */
52
44
  discoveryUrl: string;
53
- serviceName: string;
45
+ accountId?: string;
46
+ serviceName?: string;
47
+ };
48
+
49
+ export type BasicDynamicCollection = {
50
+ name: string;
51
+ type: string;
52
+ service: string;
53
+ serviceConfigName: string;
54
+ authorizations: {
55
+ [key: string]: string;
56
+ };
57
+ appId?: string;
58
+ scope?: string;
54
59
  };
@@ -1,3 +1,7 @@
1
1
  export const createAuthKey = (id: string, authName: string): string => {
2
2
  return `${id}::basic::${authName}`;
3
3
  };
4
+
5
+ export function createDynamicKey(id: string, dynamicCollection: string): string {
6
+ return `${id}::basic-collection::${dynamicCollection} collection auth`;
7
+ }