@casual-simulation/aux-records 3.8.1 → 3.10.2
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/AIChatInterface.d.ts +7 -43
- package/AIChatInterface.js +8 -6
- package/AIChatInterface.js.map +1 -1
- package/AIController.js +44 -49
- package/AIController.js.map +1 -1
- package/AIOpenAIRealtimeInterface.d.ts +1 -1
- package/AnthropicAIChatInterface.js +4 -4
- package/AnthropicAIChatInterface.js.map +1 -1
- package/AuthController.d.ts +78 -10
- package/AuthController.js +230 -166
- package/AuthController.js.map +1 -1
- package/AuthStore.d.ts +317 -4
- package/BigIntPatch.d.ts +1 -0
- package/BigIntPatch.js +24 -0
- package/BigIntPatch.js.map +1 -0
- package/BlockadeLabsGenerateSkyboxInterface.js +4 -4
- package/BlockadeLabsGenerateSkyboxInterface.js.map +1 -1
- package/CachingConfigStore.d.ts +8 -1
- package/CachingConfigStore.js +50 -0
- package/CachingConfigStore.js.map +1 -1
- package/ComIdConfig.d.ts +132 -86
- package/ComIdConfig.js +5 -5
- package/ComIdConfig.js.map +1 -1
- package/ConfigurationStore.d.ts +1393 -3
- package/ConfigurationStore.js +49 -0
- package/ConfigurationStore.js.map +1 -1
- package/DataRecordsController.js +28 -28
- package/DataRecordsController.js.map +1 -1
- package/EventRecordsController.js +9 -9
- package/EventRecordsController.js.map +1 -1
- package/FileRecordsController.js +18 -17
- package/FileRecordsController.js.map +1 -1
- package/GoogleAIChatInterface.js +4 -4
- package/GoogleAIChatInterface.js.map +1 -1
- package/HttpTestUtils.d.ts +48 -0
- package/HttpTestUtils.js +256 -0
- package/HttpTestUtils.js.map +1 -0
- package/LivekitController.js +2 -2
- package/LivekitController.js.map +1 -1
- package/LoomController.js +3 -4
- package/LoomController.js.map +1 -1
- package/MemoryStore.d.ts +60 -7
- package/MemoryStore.js +427 -59
- package/MemoryStore.js.map +1 -1
- package/MetricsStore.d.ts +11 -0
- package/ModerationConfiguration.d.ts +11 -85
- package/ModerationConfiguration.js +17 -17
- package/ModerationConfiguration.js.map +1 -1
- package/ModerationController.js +9 -11
- package/ModerationController.js.map +1 -1
- package/OpenAIChatInterface.js +8 -13
- package/OpenAIChatInterface.js.map +1 -1
- package/OpenAIImageInterface.js +4 -5
- package/OpenAIImageInterface.js.map +1 -1
- package/PolicyController.js +66 -73
- package/PolicyController.js.map +1 -1
- package/PolicyStore.d.ts +59 -33
- package/PolicyStore.js +35 -1
- package/PolicyStore.js.map +1 -1
- package/PrivoClient.d.ts +3 -1
- package/PrivoClient.js +2 -4
- package/PrivoClient.js.map +1 -1
- package/PrivoConfiguration.d.ts +6 -72
- package/PrivoConfiguration.js +30 -31
- package/PrivoConfiguration.js.map +1 -1
- package/README.md +276 -2
- package/RateLimitController.js +2 -2
- package/RateLimitController.js.map +1 -1
- package/RecordsClient.d.ts +3 -1
- package/RecordsClient.js +6 -6
- package/RecordsClient.js.map +1 -1
- package/RecordsController.d.ts +145 -3
- package/RecordsController.js +399 -61
- package/RecordsController.js.map +1 -1
- package/RecordsServer.d.ts +1932 -1109
- package/RecordsStore.d.ts +99 -14
- package/RecordsStore.js +8 -10
- package/RecordsStore.js.map +1 -1
- package/ServerConfig.d.ts +698 -9867
- package/ServerConfig.js +457 -377
- package/ServerConfig.js.map +1 -1
- package/SloydInterface.js +1 -1
- package/SloydInterface.js.map +1 -1
- package/StabilityAIImageInterface.js +6 -9
- package/StabilityAIImageInterface.js.map +1 -1
- package/StripeInterface.d.ts +431 -287
- package/StripeInterface.js +21 -1
- package/StripeInterface.js.map +1 -1
- package/SubscriptionConfigBuilder.d.ts +10 -1
- package/SubscriptionConfigBuilder.js +72 -41
- package/SubscriptionConfigBuilder.js.map +1 -1
- package/SubscriptionConfiguration.d.ts +606 -6334
- package/SubscriptionConfiguration.js +460 -277
- package/SubscriptionConfiguration.js.map +1 -1
- package/SubscriptionController.d.ts +677 -4
- package/SubscriptionController.js +2986 -186
- package/SubscriptionController.js.map +1 -1
- package/SystemNotificationMessenger.d.ts +14 -70
- package/SystemNotificationMessenger.js +17 -20
- package/SystemNotificationMessenger.js.map +1 -1
- package/TestUtils.d.ts +18 -3
- package/TestUtils.js +84 -8
- package/TestUtils.js.map +1 -1
- package/TypeUtils.d.ts +991 -0
- package/TypeUtils.js +2 -0
- package/TypeUtils.js.map +1 -0
- package/Utils.d.ts +59 -0
- package/Utils.js +507 -3
- package/Utils.js.map +1 -1
- package/Validations.d.ts +24 -108
- package/Validations.js +62 -45
- package/Validations.js.map +1 -1
- package/ViewTemplateRenderer.d.ts +39 -0
- package/ViewTemplateRenderer.js +19 -0
- package/ViewTemplateRenderer.js.map +1 -0
- package/contracts/ContractRecordsController.d.ts +58 -0
- package/contracts/ContractRecordsController.js +144 -0
- package/contracts/ContractRecordsController.js.map +1 -0
- package/contracts/ContractRecordsStore.d.ts +285 -0
- package/contracts/ContractRecordsStore.js +19 -0
- package/contracts/ContractRecordsStore.js.map +1 -0
- package/contracts/MemoryContractRecordsStore.d.ts +27 -0
- package/contracts/MemoryContractRecordsStore.js +124 -0
- package/contracts/MemoryContractRecordsStore.js.map +1 -0
- package/contracts/index.d.ts +4 -0
- package/contracts/index.js +21 -0
- package/contracts/index.js.map +1 -0
- package/crud/CrudHelpers.d.ts +25 -26
- package/crud/CrudHelpers.js +1 -1
- package/crud/CrudHelpers.js.map +1 -1
- package/crud/CrudRecordsController.js +13 -16
- package/crud/CrudRecordsController.js.map +1 -1
- package/crud/CrudRecordsControllerTests.d.ts +2 -2
- package/crud/CrudRecordsControllerTests.js +605 -580
- package/crud/CrudRecordsControllerTests.js.map +1 -1
- package/crud/MemoryCrudRecordsStore.js +1 -2
- package/crud/MemoryCrudRecordsStore.js.map +1 -1
- package/crud/sub/MemorySubCrudRecordsStore.js +4 -6
- package/crud/sub/MemorySubCrudRecordsStore.js.map +1 -1
- package/crud/sub/SubCrudRecordsController.js +8 -8
- package/crud/sub/SubCrudRecordsController.js.map +1 -1
- package/database/DatabaseRecordsController.js +1 -2
- package/database/DatabaseRecordsController.js.map +1 -1
- package/database/SqliteDatabaseInterface.js +1 -2
- package/database/SqliteDatabaseInterface.js.map +1 -1
- package/dns/DNSDomainNameValidator.d.ts +11 -0
- package/dns/DNSDomainNameValidator.js +59 -0
- package/dns/DNSDomainNameValidator.js.map +1 -0
- package/dns/DomainNameValidator.d.ts +36 -0
- package/dns/DomainNameValidator.js +19 -0
- package/dns/DomainNameValidator.js.map +1 -0
- package/dns/index.d.ts +3 -0
- package/dns/index.js +20 -0
- package/dns/index.js.map +1 -0
- package/financial/FinancialController.d.ts +272 -0
- package/financial/FinancialController.js +762 -0
- package/financial/FinancialController.js.map +1 -0
- package/financial/FinancialInterface.d.ts +352 -0
- package/financial/FinancialInterface.js +642 -0
- package/financial/FinancialInterface.js.map +1 -0
- package/financial/FinancialStore.d.ts +186 -0
- package/financial/FinancialStore.js +19 -0
- package/financial/FinancialStore.js.map +1 -0
- package/financial/MemoryFinancialInterface.d.ts +23 -0
- package/financial/MemoryFinancialInterface.js +592 -0
- package/financial/MemoryFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleFinancialInterface.d.ts +46 -0
- package/financial/TigerBeetleFinancialInterface.js +109 -0
- package/financial/TigerBeetleFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleTestUtils.d.ts +40 -0
- package/financial/TigerBeetleTestUtils.js +185 -0
- package/financial/TigerBeetleTestUtils.js.map +1 -0
- package/financial/Types.d.ts +1 -0
- package/financial/Types.js +801 -0
- package/financial/Types.js.map +1 -0
- package/financial/index.d.ts +6 -0
- package/financial/index.js +24 -0
- package/financial/index.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/notifications/NotificationRecordsController.js +14 -14
- package/notifications/NotificationRecordsController.js.map +1 -1
- package/notifications/WebPushInterface.d.ts +24 -155
- package/notifications/WebPushInterface.js +2 -2
- package/notifications/WebPushInterface.js.map +1 -1
- package/package.json +72 -70
- package/packages/version/MemoryPackageVersionRecordsStore.js +12 -15
- package/packages/version/MemoryPackageVersionRecordsStore.js.map +1 -1
- package/packages/version/PackageVersionRecordsController.d.ts +19 -0
- package/packages/version/PackageVersionRecordsController.js +102 -22
- package/packages/version/PackageVersionRecordsController.js.map +1 -1
- package/packages/version/PackageVersionRecordsStore.js +6 -8
- package/packages/version/PackageVersionRecordsStore.js.map +1 -1
- package/purchasable-items/MemoryPurchasableItemRecordsStore.d.ts +7 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js +33 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsController.d.ts +16 -0
- package/purchasable-items/PurchasableItemRecordsController.js +72 -0
- package/purchasable-items/PurchasableItemRecordsController.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsStore.d.ts +66 -0
- package/purchasable-items/PurchasableItemRecordsStore.js +2 -0
- package/purchasable-items/PurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/index.d.ts +4 -0
- package/purchasable-items/index.js +21 -0
- package/purchasable-items/index.js.map +1 -0
- package/queue/MemoryQueue.js +1 -1
- package/queue/MemoryQueue.js.map +1 -1
- package/search/MemorySearchInterface.js +1 -2
- package/search/MemorySearchInterface.js.map +1 -1
- package/search/SearchRecordsController.d.ts +66 -244
- package/search/SearchRecordsController.js +35 -36
- package/search/SearchRecordsController.js.map +1 -1
- package/search/SearchSyncProcessor.d.ts +7 -83
- package/search/TypesenseSearchInterface.js +8 -11
- package/search/TypesenseSearchInterface.js.map +1 -1
- package/tracing/TracingDecorators.js +5 -8
- package/tracing/TracingDecorators.js.map +1 -1
- package/webhooks/WebhookEnvironment.d.ts +36 -560
- package/webhooks/WebhookEnvironment.js +1 -1
- package/webhooks/WebhookEnvironment.js.map +1 -1
- package/webhooks/WebhookRecordsController.js +14 -16
- package/webhooks/WebhookRecordsController.js.map +1 -1
- package/websockets/MemoryLockStore.d.ts +18 -0
- package/websockets/MemoryLockStore.js +2 -0
- package/websockets/MemoryLockStore.js.map +1 -0
- package/websockets/MemoryTempInstRecordsStore.js +15 -27
- package/websockets/MemoryTempInstRecordsStore.js.map +1 -1
- package/websockets/MemoryWebsocketConnectionStore.js +6 -8
- package/websockets/MemoryWebsocketConnectionStore.js.map +1 -1
- package/websockets/MemoryWebsocketMessenger.js +1 -2
- package/websockets/MemoryWebsocketMessenger.js.map +1 -1
- package/websockets/SplitInstRecordsStore.js +2 -2
- package/websockets/SplitInstRecordsStore.js.map +1 -1
- package/websockets/WebsocketController.d.ts +5 -0
- package/websockets/WebsocketController.js +122 -83
- package/websockets/WebsocketController.js.map +1 -1
- package/RecordsServer.js +0 -6435
- package/RecordsServer.js.map +0 -1
package/AuthController.js
CHANGED
|
@@ -10,7 +10,7 @@ import { hashHighEntropyPasswordWithSalt, hashLowEntropyPasswordWithSalt, verify
|
|
|
10
10
|
import { fromByteArray } from 'base64-js';
|
|
11
11
|
import { cleanupObject, isActiveSubscription, isStringValid } from './Utils';
|
|
12
12
|
import { randomCode } from './CryptoUtils';
|
|
13
|
-
import { getSubscription, } from './SubscriptionConfiguration';
|
|
13
|
+
import { getContractFeatures, getSubscription, } from './SubscriptionConfiguration';
|
|
14
14
|
import { parseConnectionToken, formatV1ConnectionKey, formatV1SessionKey, isSuperUserRole, parseSessionKey, verifyConnectionToken, } from '@casual-simulation/aux-common';
|
|
15
15
|
import { DateTime } from 'luxon';
|
|
16
16
|
import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse, } from '@simplewebauthn/server';
|
|
@@ -93,11 +93,12 @@ export class AuthController {
|
|
|
93
93
|
set relyingParties(value) {
|
|
94
94
|
this._webAuthNRelyingParties = value;
|
|
95
95
|
}
|
|
96
|
-
constructor(authStore, messenger, configStore, privoClient = null, relyingParties = []) {
|
|
96
|
+
constructor(authStore, messenger, configStore, recordsStore, privoClient = null, relyingParties = []) {
|
|
97
97
|
this._privoClient = null;
|
|
98
98
|
this._store = authStore;
|
|
99
99
|
this._messenger = messenger;
|
|
100
100
|
this._config = configStore;
|
|
101
|
+
this._records = recordsStore;
|
|
101
102
|
this._privoClient = privoClient;
|
|
102
103
|
this._webAuthNRelyingParties = relyingParties;
|
|
103
104
|
this._privoEnabled = this._privoClient !== null;
|
|
@@ -127,9 +128,8 @@ export class AuthController {
|
|
|
127
128
|
this._privoClient = value;
|
|
128
129
|
}
|
|
129
130
|
async createAccount(request) {
|
|
130
|
-
var _a;
|
|
131
131
|
try {
|
|
132
|
-
const createSession =
|
|
132
|
+
const createSession = request.createSession ?? true;
|
|
133
133
|
if (!isSuperUserRole(request.userRole)) {
|
|
134
134
|
return {
|
|
135
135
|
success: false,
|
|
@@ -178,8 +178,8 @@ export class AuthController {
|
|
|
178
178
|
}
|
|
179
179
|
catch (err) {
|
|
180
180
|
const span = trace.getActiveSpan();
|
|
181
|
-
span
|
|
182
|
-
span
|
|
181
|
+
span?.recordException(err);
|
|
182
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
183
183
|
console.error('[AuthController] Error occurred while creating account', err);
|
|
184
184
|
return {
|
|
185
185
|
success: false,
|
|
@@ -212,8 +212,8 @@ export class AuthController {
|
|
|
212
212
|
}
|
|
213
213
|
catch (err) {
|
|
214
214
|
const span = trace.getActiveSpan();
|
|
215
|
-
span
|
|
216
|
-
span
|
|
215
|
+
span?.recordException(err);
|
|
216
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
217
217
|
console.error('[AuthController] Error occurred while issuing session', err);
|
|
218
218
|
return {
|
|
219
219
|
success: false,
|
|
@@ -268,6 +268,13 @@ export class AuthController {
|
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
+
if (request.loginStudioId && request.comId) {
|
|
272
|
+
return {
|
|
273
|
+
success: false,
|
|
274
|
+
errorCode: 'unacceptable_request',
|
|
275
|
+
errorMessage: 'Cannot specify both loginStudioId and comId.',
|
|
276
|
+
};
|
|
277
|
+
}
|
|
271
278
|
try {
|
|
272
279
|
let newUser = false;
|
|
273
280
|
const supported = await this._messenger.supportsAddressType(request.addressType);
|
|
@@ -280,7 +287,27 @@ export class AuthController {
|
|
|
280
287
|
: 'Phone numbers are not supported',
|
|
281
288
|
};
|
|
282
289
|
}
|
|
283
|
-
let
|
|
290
|
+
let loginStudioId = request.loginStudioId;
|
|
291
|
+
if (request.comId) {
|
|
292
|
+
const studio = await this._records.getStudioByComId(request.comId);
|
|
293
|
+
if (!studio) {
|
|
294
|
+
return {
|
|
295
|
+
success: false,
|
|
296
|
+
errorCode: 'not_found',
|
|
297
|
+
errorMessage: 'The specified comID was not found.',
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
console.log(`[AuthController] [requestLogin] Logging into studio (${studio.id}) for comID: ${request.comId}.`);
|
|
301
|
+
loginStudioId = studio.id;
|
|
302
|
+
}
|
|
303
|
+
else if (request.customDomain) {
|
|
304
|
+
const customDomain = await this._records.getVerifiedCustomDomainByName(request.customDomain);
|
|
305
|
+
if (customDomain) {
|
|
306
|
+
console.log(`[AuthController] [requestLogin] Logging into studio (${customDomain.studioId}) for custom domain: ${request.customDomain}.`);
|
|
307
|
+
loginStudioId = customDomain.studioId;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
let user = await this._store.findUserByAddress(request.address, request.addressType, loginStudioId);
|
|
284
311
|
if (!user) {
|
|
285
312
|
newUser = true;
|
|
286
313
|
user = {
|
|
@@ -293,7 +320,9 @@ export class AuthController {
|
|
|
293
320
|
: null,
|
|
294
321
|
allSessionRevokeTimeMs: null,
|
|
295
322
|
currentLoginRequestId: null,
|
|
323
|
+
loginStudioId: loginStudioId,
|
|
296
324
|
};
|
|
325
|
+
console.log(`[AuthController] [requestLogin] Creating new user (${user.id}).`);
|
|
297
326
|
if (!(await this._validateAddress(request.address, request.addressType))) {
|
|
298
327
|
console.log(`[AuthController] [requestLogin] Login attempt rejected for new user with address (type: ${request.addressType}) that is not allowed.`);
|
|
299
328
|
return {
|
|
@@ -332,7 +361,7 @@ export class AuthController {
|
|
|
332
361
|
if (newUser) {
|
|
333
362
|
const result = await this._store.saveNewUser(user);
|
|
334
363
|
if (result.success === false) {
|
|
335
|
-
user = await this._store.findUserByAddress(request.address, request.addressType);
|
|
364
|
+
user = await this._store.findUserByAddress(request.address, request.addressType, loginStudioId);
|
|
336
365
|
if (!user) {
|
|
337
366
|
console.log('[AuthController] Could not find user even though it is supposed to already exist.');
|
|
338
367
|
return {
|
|
@@ -365,8 +394,8 @@ export class AuthController {
|
|
|
365
394
|
}
|
|
366
395
|
catch (err) {
|
|
367
396
|
const span = trace.getActiveSpan();
|
|
368
|
-
span
|
|
369
|
-
span
|
|
397
|
+
span?.recordException(err);
|
|
398
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
370
399
|
console.error('[AuthController] Error Occurred while Creating Login Request', err);
|
|
371
400
|
return {
|
|
372
401
|
success: false,
|
|
@@ -497,8 +526,8 @@ export class AuthController {
|
|
|
497
526
|
}
|
|
498
527
|
catch (err) {
|
|
499
528
|
const span = trace.getActiveSpan();
|
|
500
|
-
span
|
|
501
|
-
span
|
|
529
|
+
span?.recordException(err);
|
|
530
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
502
531
|
console.error('[AuthController] Error occurred while completing login request', err);
|
|
503
532
|
return {
|
|
504
533
|
success: false,
|
|
@@ -557,8 +586,8 @@ export class AuthController {
|
|
|
557
586
|
}
|
|
558
587
|
catch (err) {
|
|
559
588
|
const span = trace.getActiveSpan();
|
|
560
|
-
span
|
|
561
|
-
span
|
|
589
|
+
span?.recordException(err);
|
|
590
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
562
591
|
console.error('[AuthController] Error occurred while requesting Privo login', err);
|
|
563
592
|
return {
|
|
564
593
|
success: false,
|
|
@@ -628,8 +657,8 @@ export class AuthController {
|
|
|
628
657
|
}
|
|
629
658
|
catch (err) {
|
|
630
659
|
const span = trace.getActiveSpan();
|
|
631
|
-
span
|
|
632
|
-
span
|
|
660
|
+
span?.recordException(err);
|
|
661
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
633
662
|
console.error('[AuthController] Error occurred while processing Privo authorization code', err);
|
|
634
663
|
return {
|
|
635
664
|
success: false,
|
|
@@ -639,7 +668,6 @@ export class AuthController {
|
|
|
639
668
|
}
|
|
640
669
|
}
|
|
641
670
|
async completeOpenIDLogin(request) {
|
|
642
|
-
var _a, _b, _c, _d;
|
|
643
671
|
try {
|
|
644
672
|
if (!this._privoClient) {
|
|
645
673
|
return {
|
|
@@ -747,12 +775,12 @@ export class AuthController {
|
|
|
747
775
|
};
|
|
748
776
|
}
|
|
749
777
|
const privacyFeatures = getPrivacyFeaturesFromPermissions(config.featureIds, result.userInfo.permissions);
|
|
750
|
-
if (
|
|
778
|
+
if (user.privacyFeatures?.publishData !==
|
|
751
779
|
privacyFeatures.publishData ||
|
|
752
|
-
|
|
780
|
+
user.privacyFeatures?.allowPublicData !==
|
|
753
781
|
privacyFeatures.allowPublicData ||
|
|
754
|
-
|
|
755
|
-
|
|
782
|
+
user.privacyFeatures?.allowAI !== privacyFeatures.allowAI ||
|
|
783
|
+
user.privacyFeatures?.allowPublicInsts !==
|
|
756
784
|
privacyFeatures.allowPublicInsts) {
|
|
757
785
|
console.log(`[AuthController] [completeOpenIDLogin] Updating user privacy features.`);
|
|
758
786
|
user = {
|
|
@@ -785,8 +813,8 @@ export class AuthController {
|
|
|
785
813
|
}
|
|
786
814
|
catch (err) {
|
|
787
815
|
const span = trace.getActiveSpan();
|
|
788
|
-
span
|
|
789
|
-
span
|
|
816
|
+
span?.recordException(err);
|
|
817
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
790
818
|
console.error('[AuthController] Error occurred while completing Privo login', err);
|
|
791
819
|
return {
|
|
792
820
|
success: false,
|
|
@@ -946,8 +974,8 @@ export class AuthController {
|
|
|
946
974
|
}
|
|
947
975
|
catch (err) {
|
|
948
976
|
const span = trace.getActiveSpan();
|
|
949
|
-
span
|
|
950
|
-
span
|
|
977
|
+
span?.recordException(err);
|
|
978
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
951
979
|
console.error(`[AuthController] Error occurred while requesting Privo sign up`, err);
|
|
952
980
|
return {
|
|
953
981
|
success: false,
|
|
@@ -957,7 +985,6 @@ export class AuthController {
|
|
|
957
985
|
}
|
|
958
986
|
}
|
|
959
987
|
async requestWebAuthnRegistration(request) {
|
|
960
|
-
var _a;
|
|
961
988
|
try {
|
|
962
989
|
if (this._webAuthNRelyingParties.length <= 0) {
|
|
963
990
|
return {
|
|
@@ -987,7 +1014,7 @@ export class AuthController {
|
|
|
987
1014
|
rpName: relyingParty.name,
|
|
988
1015
|
rpID: relyingParty.id,
|
|
989
1016
|
userID: user.id,
|
|
990
|
-
userName:
|
|
1017
|
+
userName: user.email ?? user.phoneNumber,
|
|
991
1018
|
attestationType: 'none',
|
|
992
1019
|
excludeCredentials: authenticators.map((auth) => ({
|
|
993
1020
|
id: base64URLStringToBuffer(auth.credentialId),
|
|
@@ -1008,8 +1035,8 @@ export class AuthController {
|
|
|
1008
1035
|
}
|
|
1009
1036
|
catch (err) {
|
|
1010
1037
|
const span = trace.getActiveSpan();
|
|
1011
|
-
span
|
|
1012
|
-
span
|
|
1038
|
+
span?.recordException(err);
|
|
1039
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1013
1040
|
console.error(`[AuthController] Error occurred while requesting WebAuthn registration options`, err);
|
|
1014
1041
|
return {
|
|
1015
1042
|
success: false,
|
|
@@ -1092,8 +1119,8 @@ export class AuthController {
|
|
|
1092
1119
|
}
|
|
1093
1120
|
catch (err) {
|
|
1094
1121
|
const span = trace.getActiveSpan();
|
|
1095
|
-
span
|
|
1096
|
-
span
|
|
1122
|
+
span?.recordException(err);
|
|
1123
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1097
1124
|
console.error(`[AuthController] Error occurred while completing WebAuthn registration`, err);
|
|
1098
1125
|
return {
|
|
1099
1126
|
success: false,
|
|
@@ -1142,8 +1169,8 @@ export class AuthController {
|
|
|
1142
1169
|
}
|
|
1143
1170
|
catch (err) {
|
|
1144
1171
|
const span = trace.getActiveSpan();
|
|
1145
|
-
span
|
|
1146
|
-
span
|
|
1172
|
+
span?.recordException(err);
|
|
1173
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1147
1174
|
console.error(`[AuthController] Error occurred while requesting WebAuthn login`, err);
|
|
1148
1175
|
return {
|
|
1149
1176
|
success: false,
|
|
@@ -1260,8 +1287,8 @@ export class AuthController {
|
|
|
1260
1287
|
}
|
|
1261
1288
|
catch (err) {
|
|
1262
1289
|
const span = trace.getActiveSpan();
|
|
1263
|
-
span
|
|
1264
|
-
span
|
|
1290
|
+
span?.recordException(err);
|
|
1291
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1265
1292
|
console.error(`[AuthController] Error occurred while requesting WebAuthn login`, err);
|
|
1266
1293
|
return {
|
|
1267
1294
|
success: false,
|
|
@@ -1298,8 +1325,8 @@ export class AuthController {
|
|
|
1298
1325
|
}
|
|
1299
1326
|
catch (err) {
|
|
1300
1327
|
const span = trace.getActiveSpan();
|
|
1301
|
-
span
|
|
1302
|
-
span
|
|
1328
|
+
span?.recordException(err);
|
|
1329
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1303
1330
|
console.error(`[AuthController] Error occurred while listing user authenticators`, err);
|
|
1304
1331
|
return {
|
|
1305
1332
|
success: false,
|
|
@@ -1331,8 +1358,8 @@ export class AuthController {
|
|
|
1331
1358
|
}
|
|
1332
1359
|
catch (err) {
|
|
1333
1360
|
const span = trace.getActiveSpan();
|
|
1334
|
-
span
|
|
1335
|
-
span
|
|
1361
|
+
span?.recordException(err);
|
|
1362
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1336
1363
|
console.error(`[AuthController] Error occurred while deleting a user authenticator`, err);
|
|
1337
1364
|
return {
|
|
1338
1365
|
success: false,
|
|
@@ -1431,16 +1458,16 @@ export class AuthController {
|
|
|
1431
1458
|
userId: session.userId,
|
|
1432
1459
|
sessionId: session.sessionId,
|
|
1433
1460
|
allSessionsRevokedTimeMs: userInfo.allSessionRevokeTimeMs,
|
|
1434
|
-
subscriptionId: subscriptionId
|
|
1435
|
-
subscriptionTier: subscriptionTier
|
|
1461
|
+
subscriptionId: subscriptionId ?? undefined,
|
|
1462
|
+
subscriptionTier: subscriptionTier ?? undefined,
|
|
1436
1463
|
privacyFeatures: userInfo.privacyFeatures,
|
|
1437
1464
|
role: userInfo.role,
|
|
1438
1465
|
};
|
|
1439
1466
|
}
|
|
1440
1467
|
catch (err) {
|
|
1441
1468
|
const span = trace.getActiveSpan();
|
|
1442
|
-
span
|
|
1443
|
-
span
|
|
1469
|
+
span?.recordException(err);
|
|
1470
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1444
1471
|
console.error('[AuthController] Error ocurred while validating a session key', err);
|
|
1445
1472
|
return {
|
|
1446
1473
|
success: false,
|
|
@@ -1545,15 +1572,15 @@ export class AuthController {
|
|
|
1545
1572
|
recordName: recordName,
|
|
1546
1573
|
inst: inst,
|
|
1547
1574
|
allSessionsRevokedTimeMs: userInfo.allSessionRevokeTimeMs,
|
|
1548
|
-
subscriptionId: subscriptionId
|
|
1549
|
-
subscriptionTier: subscriptionTier
|
|
1575
|
+
subscriptionId: subscriptionId ?? undefined,
|
|
1576
|
+
subscriptionTier: subscriptionTier ?? undefined,
|
|
1550
1577
|
privacyFeatures: userInfo.privacyFeatures,
|
|
1551
1578
|
};
|
|
1552
1579
|
}
|
|
1553
1580
|
catch (err) {
|
|
1554
1581
|
const span = trace.getActiveSpan();
|
|
1555
|
-
span
|
|
1556
|
-
span
|
|
1582
|
+
span?.recordException(err);
|
|
1583
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1557
1584
|
console.error('[AuthController] Error ocurred while validating a connection token', err);
|
|
1558
1585
|
return {
|
|
1559
1586
|
success: false,
|
|
@@ -1563,7 +1590,6 @@ export class AuthController {
|
|
|
1563
1590
|
}
|
|
1564
1591
|
}
|
|
1565
1592
|
async revokeSession(request) {
|
|
1566
|
-
var _a;
|
|
1567
1593
|
if (typeof request.userId !== 'string' || request.userId === '') {
|
|
1568
1594
|
return {
|
|
1569
1595
|
success: false,
|
|
@@ -1628,7 +1654,7 @@ export class AuthController {
|
|
|
1628
1654
|
await this._store.saveSession(newSession);
|
|
1629
1655
|
let logoutUrl;
|
|
1630
1656
|
if (session.oidProvider === PRIVO_OPEN_ID_PROVIDER) {
|
|
1631
|
-
logoutUrl = await this._privoClient.generateLogoutUrl(
|
|
1657
|
+
logoutUrl = await this._privoClient.generateLogoutUrl(session.oidIdToken ?? session.oidAccessToken);
|
|
1632
1658
|
}
|
|
1633
1659
|
return {
|
|
1634
1660
|
success: true,
|
|
@@ -1637,8 +1663,8 @@ export class AuthController {
|
|
|
1637
1663
|
}
|
|
1638
1664
|
catch (err) {
|
|
1639
1665
|
const span = trace.getActiveSpan();
|
|
1640
|
-
span
|
|
1641
|
-
span
|
|
1666
|
+
span?.recordException(err);
|
|
1667
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1642
1668
|
console.error('[AuthController] Error ocurred while revoking session', err);
|
|
1643
1669
|
return {
|
|
1644
1670
|
success: false,
|
|
@@ -1686,8 +1712,8 @@ export class AuthController {
|
|
|
1686
1712
|
}
|
|
1687
1713
|
catch (err) {
|
|
1688
1714
|
const span = trace.getActiveSpan();
|
|
1689
|
-
span
|
|
1690
|
-
span
|
|
1715
|
+
span?.recordException(err);
|
|
1716
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1691
1717
|
console.error('[AuthController] Error ocurred while revoking all sessions', err);
|
|
1692
1718
|
return {
|
|
1693
1719
|
success: false,
|
|
@@ -1753,8 +1779,8 @@ export class AuthController {
|
|
|
1753
1779
|
}
|
|
1754
1780
|
catch (err) {
|
|
1755
1781
|
const span = trace.getActiveSpan();
|
|
1756
|
-
span
|
|
1757
|
-
span
|
|
1782
|
+
span?.recordException(err);
|
|
1783
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1758
1784
|
console.error('[AuthController] Error ocurred while replacing session', err);
|
|
1759
1785
|
return {
|
|
1760
1786
|
success: false,
|
|
@@ -1829,8 +1855,8 @@ export class AuthController {
|
|
|
1829
1855
|
}
|
|
1830
1856
|
catch (err) {
|
|
1831
1857
|
const span = trace.getActiveSpan();
|
|
1832
|
-
span
|
|
1833
|
-
span
|
|
1858
|
+
span?.recordException(err);
|
|
1859
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1834
1860
|
console.error('[AuthController] Error ocurred while listing sessions', err);
|
|
1835
1861
|
return {
|
|
1836
1862
|
success: false,
|
|
@@ -1844,100 +1870,30 @@ export class AuthController {
|
|
|
1844
1870
|
* @param request The request.
|
|
1845
1871
|
*/
|
|
1846
1872
|
async getUserInfo(request) {
|
|
1847
|
-
var _a, _b, _c, _d, _e;
|
|
1848
|
-
if (typeof request.userId !== 'string' || request.userId === '') {
|
|
1849
|
-
return {
|
|
1850
|
-
success: false,
|
|
1851
|
-
errorCode: 'unacceptable_user_id',
|
|
1852
|
-
errorMessage: 'The given userId is invalid. It must be a string.',
|
|
1853
|
-
};
|
|
1854
|
-
}
|
|
1855
|
-
else if (typeof request.sessionKey !== 'string' ||
|
|
1856
|
-
request.sessionKey === '') {
|
|
1857
|
-
return {
|
|
1858
|
-
success: false,
|
|
1859
|
-
errorCode: 'unacceptable_session_key',
|
|
1860
|
-
errorMessage: 'The given session key is invalid. It must be a string.',
|
|
1861
|
-
};
|
|
1862
|
-
}
|
|
1863
1873
|
try {
|
|
1864
|
-
const
|
|
1865
|
-
if (
|
|
1866
|
-
|
|
1867
|
-
}
|
|
1868
|
-
else if (!isSuperUserRole(keyResult.role) &&
|
|
1869
|
-
keyResult.userId !== request.userId) {
|
|
1870
|
-
console.log('[AuthController] [getUserInfo] Request User ID doesnt match session key User ID!');
|
|
1874
|
+
const requestedUserId = request.requestedUserId ?? request.userId;
|
|
1875
|
+
if (!isSuperUserRole(request.userRole) &&
|
|
1876
|
+
request.userId !== requestedUserId) {
|
|
1871
1877
|
return {
|
|
1872
1878
|
success: false,
|
|
1873
|
-
errorCode: '
|
|
1874
|
-
errorMessage:
|
|
1879
|
+
errorCode: 'not_authorized',
|
|
1880
|
+
errorMessage: 'You are not authorized to perform this action.',
|
|
1875
1881
|
};
|
|
1876
1882
|
}
|
|
1877
|
-
const result = await this._store.findUser(
|
|
1883
|
+
const result = await this._store.findUser(requestedUserId);
|
|
1878
1884
|
if (!result) {
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
let displayName = null;
|
|
1884
|
-
let email = result.email;
|
|
1885
|
-
let name = result.name;
|
|
1886
|
-
const privoConfig = await this._config.getPrivoConfiguration();
|
|
1887
|
-
if (privoConfig && result.privoServiceId) {
|
|
1888
|
-
const userInfo = await this._privoClient.getUserInfo(result.privoServiceId);
|
|
1889
|
-
privacyFeatures = getPrivacyFeaturesFromPermissions(privoConfig.featureIds, userInfo.permissions);
|
|
1890
|
-
displayName = userInfo.displayName;
|
|
1891
|
-
email = userInfo.email;
|
|
1892
|
-
name = userInfo.givenName;
|
|
1893
|
-
if (((_a = result.privacyFeatures) === null || _a === void 0 ? void 0 : _a.publishData) !==
|
|
1894
|
-
privacyFeatures.publishData ||
|
|
1895
|
-
((_b = result.privacyFeatures) === null || _b === void 0 ? void 0 : _b.allowPublicData) !==
|
|
1896
|
-
privacyFeatures.allowPublicData ||
|
|
1897
|
-
((_c = result.privacyFeatures) === null || _c === void 0 ? void 0 : _c.allowAI) !==
|
|
1898
|
-
privacyFeatures.allowAI ||
|
|
1899
|
-
((_d = result.privacyFeatures) === null || _d === void 0 ? void 0 : _d.allowPublicInsts) !==
|
|
1900
|
-
privacyFeatures.allowPublicInsts) {
|
|
1901
|
-
await this._store.saveUser({
|
|
1902
|
-
...result,
|
|
1903
|
-
privacyFeatures: {
|
|
1904
|
-
...privacyFeatures,
|
|
1905
|
-
},
|
|
1906
|
-
});
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
else if (result.privacyFeatures) {
|
|
1910
|
-
privacyFeatures = {
|
|
1911
|
-
...result.privacyFeatures,
|
|
1912
|
-
};
|
|
1913
|
-
}
|
|
1914
|
-
else {
|
|
1915
|
-
privacyFeatures = {
|
|
1916
|
-
publishData: true,
|
|
1917
|
-
allowPublicData: true,
|
|
1918
|
-
allowAI: true,
|
|
1919
|
-
allowPublicInsts: true,
|
|
1885
|
+
return {
|
|
1886
|
+
success: false,
|
|
1887
|
+
errorCode: 'user_not_found',
|
|
1888
|
+
errorMessage: 'The user was not found.',
|
|
1920
1889
|
};
|
|
1921
1890
|
}
|
|
1922
|
-
return
|
|
1923
|
-
success: true,
|
|
1924
|
-
userId: result.id,
|
|
1925
|
-
name: name,
|
|
1926
|
-
displayName,
|
|
1927
|
-
email: email,
|
|
1928
|
-
phoneNumber: result.phoneNumber,
|
|
1929
|
-
avatarPortraitUrl: result.avatarPortraitUrl,
|
|
1930
|
-
avatarUrl: result.avatarUrl,
|
|
1931
|
-
hasActiveSubscription: hasActiveSubscription,
|
|
1932
|
-
subscriptionTier: tier !== null && tier !== void 0 ? tier : null,
|
|
1933
|
-
privacyFeatures: privacyFeatures,
|
|
1934
|
-
role: (_e = result.role) !== null && _e !== void 0 ? _e : 'none',
|
|
1935
|
-
};
|
|
1891
|
+
return await this.getPrivateInfoForUser(result);
|
|
1936
1892
|
}
|
|
1937
1893
|
catch (err) {
|
|
1938
1894
|
const span = trace.getActiveSpan();
|
|
1939
|
-
span
|
|
1940
|
-
span
|
|
1895
|
+
span?.recordException(err);
|
|
1896
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1941
1897
|
console.error('[AuthController] Error ocurred while getting user info', err);
|
|
1942
1898
|
return {
|
|
1943
1899
|
success: false,
|
|
@@ -1946,6 +1902,106 @@ export class AuthController {
|
|
|
1946
1902
|
};
|
|
1947
1903
|
}
|
|
1948
1904
|
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Gets the user info for the given auth user.
|
|
1907
|
+
*
|
|
1908
|
+
* Not for public use.
|
|
1909
|
+
* @param user The user to get the info for.
|
|
1910
|
+
* @returns
|
|
1911
|
+
*/
|
|
1912
|
+
async getPrivateInfoForUser(user) {
|
|
1913
|
+
const { hasActiveSubscription, subscriptionTier: tier } = await this._getSubscriptionInfo(user);
|
|
1914
|
+
const { privacyFeatures, displayName, email, name } = await this._getUserPrivoInfo(user);
|
|
1915
|
+
// let accountBalance: number | null = undefined;
|
|
1916
|
+
// let accountCurrency: string | null = undefined;
|
|
1917
|
+
// if (this._financialController && user.accountId) {
|
|
1918
|
+
// const account = await this._financialController.getAccount(
|
|
1919
|
+
// user.accountId
|
|
1920
|
+
// );
|
|
1921
|
+
// if (isSuccess(account)) {
|
|
1922
|
+
// accountBalance = getAccountBalance(account.value);
|
|
1923
|
+
// accountCurrency = getAccountCurrency(account.value);
|
|
1924
|
+
// } else {
|
|
1925
|
+
// console.error(
|
|
1926
|
+
// '[AuthController] Error getting account balance for user',
|
|
1927
|
+
// account.error
|
|
1928
|
+
// );
|
|
1929
|
+
// }
|
|
1930
|
+
// }
|
|
1931
|
+
const subscriptionConfig = await this._config.getSubscriptionConfiguration();
|
|
1932
|
+
const contractFeatures = getContractFeatures(subscriptionConfig, user.subscriptionStatus, user.subscriptionId, 'user', user.subscriptionPeriodStartMs, user.subscriptionPeriodEndMs);
|
|
1933
|
+
return {
|
|
1934
|
+
success: true,
|
|
1935
|
+
userId: user.id,
|
|
1936
|
+
name: name,
|
|
1937
|
+
displayName,
|
|
1938
|
+
email: email,
|
|
1939
|
+
phoneNumber: user.phoneNumber,
|
|
1940
|
+
avatarPortraitUrl: user.avatarPortraitUrl,
|
|
1941
|
+
avatarUrl: user.avatarUrl,
|
|
1942
|
+
hasActiveSubscription: hasActiveSubscription,
|
|
1943
|
+
subscriptionTier: tier ?? null,
|
|
1944
|
+
privacyFeatures: privacyFeatures,
|
|
1945
|
+
role: user.role ?? 'none',
|
|
1946
|
+
// accountId: user.accountId,
|
|
1947
|
+
// accountBalance,
|
|
1948
|
+
// accountCurrency,
|
|
1949
|
+
requestedRate: user.requestedRate,
|
|
1950
|
+
stripeAccountId: user.stripeAccountId,
|
|
1951
|
+
stripeAccountRequirementsStatus: user.stripeAccountRequirementsStatus,
|
|
1952
|
+
stripeAccountStatus: user.stripeAccountStatus,
|
|
1953
|
+
contractFeatures: contractFeatures.allowed
|
|
1954
|
+
? contractFeatures
|
|
1955
|
+
: undefined,
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
async _getUserPrivoInfo(user) {
|
|
1959
|
+
let privacyFeatures;
|
|
1960
|
+
let displayName = null;
|
|
1961
|
+
let email = user.email;
|
|
1962
|
+
let name = user.name;
|
|
1963
|
+
const privoConfig = await this._config.getPrivoConfiguration();
|
|
1964
|
+
if (privoConfig && user.privoServiceId) {
|
|
1965
|
+
const userInfo = await this._privoClient.getUserInfo(user.privoServiceId);
|
|
1966
|
+
privacyFeatures = getPrivacyFeaturesFromPermissions(privoConfig.featureIds, userInfo.permissions);
|
|
1967
|
+
displayName = userInfo.displayName;
|
|
1968
|
+
email = userInfo.email;
|
|
1969
|
+
name = userInfo.givenName;
|
|
1970
|
+
if (user.privacyFeatures?.publishData !==
|
|
1971
|
+
privacyFeatures.publishData ||
|
|
1972
|
+
user.privacyFeatures?.allowPublicData !==
|
|
1973
|
+
privacyFeatures.allowPublicData ||
|
|
1974
|
+
user.privacyFeatures?.allowAI !== privacyFeatures.allowAI ||
|
|
1975
|
+
user.privacyFeatures?.allowPublicInsts !==
|
|
1976
|
+
privacyFeatures.allowPublicInsts) {
|
|
1977
|
+
await this._store.saveUser({
|
|
1978
|
+
...user,
|
|
1979
|
+
privacyFeatures: {
|
|
1980
|
+
...privacyFeatures,
|
|
1981
|
+
},
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
else if (user.privacyFeatures) {
|
|
1986
|
+
privacyFeatures = {
|
|
1987
|
+
...user.privacyFeatures,
|
|
1988
|
+
};
|
|
1989
|
+
}
|
|
1990
|
+
else {
|
|
1991
|
+
privacyFeatures = {
|
|
1992
|
+
publishData: true,
|
|
1993
|
+
allowPublicData: true,
|
|
1994
|
+
allowAI: true,
|
|
1995
|
+
allowPublicInsts: true,
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
return {
|
|
1999
|
+
privacyFeatures,
|
|
2000
|
+
displayName,
|
|
2001
|
+
email,
|
|
2002
|
+
name,
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
1949
2005
|
/**
|
|
1950
2006
|
* Gets the public information for a specific user.
|
|
1951
2007
|
* @param userId The ID of the user whose information is being requested.
|
|
@@ -1984,8 +2040,8 @@ export class AuthController {
|
|
|
1984
2040
|
}
|
|
1985
2041
|
catch (err) {
|
|
1986
2042
|
const span = trace.getActiveSpan();
|
|
1987
|
-
span
|
|
1988
|
-
span
|
|
2043
|
+
span?.recordException(err);
|
|
2044
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
1989
2045
|
console.error('[AuthController] Error ocurred while getting user info', err);
|
|
1990
2046
|
return {
|
|
1991
2047
|
success: false,
|
|
@@ -2004,10 +2060,20 @@ export class AuthController {
|
|
|
2004
2060
|
return {
|
|
2005
2061
|
hasActiveSubscription: !!sub &&
|
|
2006
2062
|
isActiveSubscription(user.subscriptionStatus, user.subscriptionPeriodStartMs, user.subscriptionPeriodEndMs),
|
|
2007
|
-
subscriptionId: sub
|
|
2063
|
+
subscriptionId: sub?.id,
|
|
2008
2064
|
subscriptionTier: tier,
|
|
2009
2065
|
};
|
|
2010
2066
|
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Gets the subscription information for a user.
|
|
2069
|
+
*
|
|
2070
|
+
* Not for public use.
|
|
2071
|
+
* @param user The user to get the subscription information for.
|
|
2072
|
+
* @returns
|
|
2073
|
+
*/
|
|
2074
|
+
getUserSubscriptionInfo(user) {
|
|
2075
|
+
return this._getSubscriptionInfo(user);
|
|
2076
|
+
}
|
|
2011
2077
|
/**
|
|
2012
2078
|
* Attempts to update a user's metadata.
|
|
2013
2079
|
* @param request The request for the operation.
|
|
@@ -2072,8 +2138,8 @@ export class AuthController {
|
|
|
2072
2138
|
}
|
|
2073
2139
|
catch (err) {
|
|
2074
2140
|
const span = trace.getActiveSpan();
|
|
2075
|
-
span
|
|
2076
|
-
span
|
|
2141
|
+
span?.recordException(err);
|
|
2142
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2077
2143
|
console.error('[AuthController] Error ocurred while getting user info', err);
|
|
2078
2144
|
return {
|
|
2079
2145
|
success: false,
|
|
@@ -2086,7 +2152,6 @@ export class AuthController {
|
|
|
2086
2152
|
* Attempts to request a change in privacy features for a user.
|
|
2087
2153
|
*/
|
|
2088
2154
|
async requestPrivacyFeaturesChange(request) {
|
|
2089
|
-
var _a;
|
|
2090
2155
|
try {
|
|
2091
2156
|
if (!this._privoClient) {
|
|
2092
2157
|
return {
|
|
@@ -2127,7 +2192,7 @@ export class AuthController {
|
|
|
2127
2192
|
errorMessage: 'Privo features are not supported on this server.',
|
|
2128
2193
|
};
|
|
2129
2194
|
}
|
|
2130
|
-
const result = await this._privoClient.resendConsentRequest(user.privoServiceId,
|
|
2195
|
+
const result = await this._privoClient.resendConsentRequest(user.privoServiceId, user.privoParentServiceId ?? user.privoServiceId);
|
|
2131
2196
|
if (result.success === false) {
|
|
2132
2197
|
return result;
|
|
2133
2198
|
}
|
|
@@ -2138,8 +2203,8 @@ export class AuthController {
|
|
|
2138
2203
|
}
|
|
2139
2204
|
catch (err) {
|
|
2140
2205
|
const span = trace.getActiveSpan();
|
|
2141
|
-
span
|
|
2142
|
-
span
|
|
2206
|
+
span?.recordException(err);
|
|
2207
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2143
2208
|
console.error('[AuthController] Error ocurred while requesting a change in privacy features', err);
|
|
2144
2209
|
return {
|
|
2145
2210
|
success: false,
|
|
@@ -2161,8 +2226,8 @@ export class AuthController {
|
|
|
2161
2226
|
}
|
|
2162
2227
|
catch (err) {
|
|
2163
2228
|
const span = trace.getActiveSpan();
|
|
2164
|
-
span
|
|
2165
|
-
span
|
|
2229
|
+
span?.recordException(err);
|
|
2230
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2166
2231
|
console.error('[AuthController] Error ocurred while listing email rules', err);
|
|
2167
2232
|
return {
|
|
2168
2233
|
success: false,
|
|
@@ -2184,8 +2249,8 @@ export class AuthController {
|
|
|
2184
2249
|
}
|
|
2185
2250
|
catch (err) {
|
|
2186
2251
|
const span = trace.getActiveSpan();
|
|
2187
|
-
span
|
|
2188
|
-
span
|
|
2252
|
+
span?.recordException(err);
|
|
2253
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2189
2254
|
console.error('[AuthController] Error ocurred while listing email rules', err);
|
|
2190
2255
|
return {
|
|
2191
2256
|
success: false,
|
|
@@ -2223,8 +2288,8 @@ export class AuthController {
|
|
|
2223
2288
|
}
|
|
2224
2289
|
catch (err) {
|
|
2225
2290
|
const span = trace.getActiveSpan();
|
|
2226
|
-
span
|
|
2227
|
-
span
|
|
2291
|
+
span?.recordException(err);
|
|
2292
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2228
2293
|
console.error('[AuthController] Error ocurred while checking if email address is valid', err);
|
|
2229
2294
|
return {
|
|
2230
2295
|
success: false,
|
|
@@ -2268,8 +2333,8 @@ export class AuthController {
|
|
|
2268
2333
|
}
|
|
2269
2334
|
catch (err) {
|
|
2270
2335
|
const span = trace.getActiveSpan();
|
|
2271
|
-
span
|
|
2272
|
-
span
|
|
2336
|
+
span?.recordException(err);
|
|
2337
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
2273
2338
|
console.error('[AuthController] Error ocurred while checking if display name is valid', err);
|
|
2274
2339
|
return {
|
|
2275
2340
|
success: false,
|
|
@@ -2286,7 +2351,6 @@ export class AuthController {
|
|
|
2286
2351
|
* @param ipAddress The IP address that the session is being issued to. Should be null if the ip address is not known.
|
|
2287
2352
|
*/
|
|
2288
2353
|
async _issueSession({ userId, lifetimeMs, previousSession, ipAddress, requestId, ...rest }) {
|
|
2289
|
-
var _a, _b, _c, _d, _e;
|
|
2290
2354
|
const now = Date.now();
|
|
2291
2355
|
const newSessionId = fromByteArray(randomBytes(SESSION_ID_BYTE_LENGTH));
|
|
2292
2356
|
const newSessionSecret = fromByteArray(randomBytes(SESSION_SECRET_BYTE_LENGTH));
|
|
@@ -2295,13 +2359,13 @@ export class AuthController {
|
|
|
2295
2359
|
...rest,
|
|
2296
2360
|
userId: userId,
|
|
2297
2361
|
sessionId: newSessionId,
|
|
2298
|
-
requestId: requestId
|
|
2362
|
+
requestId: requestId ?? null,
|
|
2299
2363
|
secretHash: this._hashHighEntropyPasswordWithSalt(newSessionSecret, newSessionId),
|
|
2300
2364
|
connectionSecret: newConnectionSecret,
|
|
2301
2365
|
grantedTimeMs: now,
|
|
2302
2366
|
revokeTimeMs: null,
|
|
2303
2367
|
expireTimeMs: lifetimeMs ? now + lifetimeMs : null,
|
|
2304
|
-
previousSessionId:
|
|
2368
|
+
previousSessionId: previousSession?.sessionId ?? null,
|
|
2305
2369
|
nextSessionId: null,
|
|
2306
2370
|
ipAddress: ipAddress,
|
|
2307
2371
|
};
|
|
@@ -2327,10 +2391,10 @@ export class AuthController {
|
|
|
2327
2391
|
connectionKey: formatV1ConnectionKey(userId, newSessionId, newConnectionSecret, newSession.expireTimeMs),
|
|
2328
2392
|
expireTimeMs: newSession.expireTimeMs,
|
|
2329
2393
|
metadata: {
|
|
2330
|
-
hasUserAuthenticator:
|
|
2331
|
-
userAuthenticatorCredentialIds:
|
|
2332
|
-
hasPushSubscription:
|
|
2333
|
-
pushSubscriptionIds:
|
|
2394
|
+
hasUserAuthenticator: metadata?.hasUserAuthenticator ?? false,
|
|
2395
|
+
userAuthenticatorCredentialIds: metadata?.userAuthenticatorCredentialIds ?? [],
|
|
2396
|
+
hasPushSubscription: metadata?.hasPushSubscription ?? false,
|
|
2397
|
+
pushSubscriptionIds: metadata?.pushSubscriptionIds ?? [],
|
|
2334
2398
|
},
|
|
2335
2399
|
};
|
|
2336
2400
|
console.log(`[AuthController] [issueSession userId: ${userId} newSessionId: ${newSessionId} expiresAt: ${newSession.expireTimeMs}] Issued session.`);
|