casualos 3.3.11-alpha.11060020867 → 3.3.11-alpha.11349749950

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 (2) hide show
  1. package/dist/cli.js +158 -22
  2. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -96760,7 +96760,7 @@ var trace = TraceAPI.getInstance();
96760
96760
  function hashLowEntropyPasswordWithSalt2(password, salt) {
96761
96761
  const tracer = trace.getTracer(
96762
96762
  "InstrumentedHashHelpers",
96763
- false ? void 0 : "v3.3.11-alpha.11060020867"
96763
+ false ? void 0 : "v3.3.11-alpha.11349749950"
96764
96764
  );
96765
96765
  return tracer.startActiveSpan(
96766
96766
  "hashLowEntropyPasswordWithSalt",
@@ -96778,7 +96778,7 @@ function hashLowEntropyPasswordWithSalt2(password, salt) {
96778
96778
  function hashHighEntropyPasswordWithSalt2(password, salt) {
96779
96779
  const tracer = trace.getTracer(
96780
96780
  "InstrumentedHashHelpers",
96781
- false ? void 0 : "v3.3.11-alpha.11060020867"
96781
+ false ? void 0 : "v3.3.11-alpha.11349749950"
96782
96782
  );
96783
96783
  return tracer.startActiveSpan(
96784
96784
  "hashHighEntropyPasswordWithSalt",
@@ -96796,7 +96796,7 @@ function hashHighEntropyPasswordWithSalt2(password, salt) {
96796
96796
  function verifyPasswordAgainstHashes2(password, salt, hashes) {
96797
96797
  const tracer = trace.getTracer(
96798
96798
  "InstrumentedHashHelpers",
96799
- false ? void 0 : "v3.3.11-alpha.11060020867"
96799
+ false ? void 0 : "v3.3.11-alpha.11349749950"
96800
96800
  );
96801
96801
  return tracer.startActiveSpan(
96802
96802
  "verifyPasswordAgainstHashes",
@@ -103397,7 +103397,7 @@ var import_semantic_conventions = __toESM(require_src3());
103397
103397
  function traced(tracerName, options = {}, metricOptions = {}) {
103398
103398
  const tracer = trace.getTracer(
103399
103399
  tracerName,
103400
- false ? void 0 : "v3.3.11-alpha.11060020867"
103400
+ false ? void 0 : "v3.3.11-alpha.11349749950"
103401
103401
  );
103402
103402
  return function(target, propertyKey, descriptor) {
103403
103403
  const originalMethod = descriptor.value;
@@ -103475,7 +103475,7 @@ function getHistogram(meter) {
103475
103475
  }
103476
103476
  return metrics.getMeter(
103477
103477
  meter.meter,
103478
- false ? void 0 : "v3.3.11-alpha.11060020867"
103478
+ false ? void 0 : "v3.3.11-alpha.11349749950"
103479
103479
  ).createHistogram(meter.name, meter.options);
103480
103480
  }
103481
103481
  function getCounter(meter) {
@@ -103484,7 +103484,7 @@ function getCounter(meter) {
103484
103484
  }
103485
103485
  return metrics.getMeter(
103486
103486
  meter.meter,
103487
- false ? void 0 : "v3.3.11-alpha.11060020867"
103487
+ false ? void 0 : "v3.3.11-alpha.11349749950"
103488
103488
  ).createCounter(meter.name, meter.options);
103489
103489
  }
103490
103490
  function traceHttpResponse(options = {}) {
@@ -103534,6 +103534,7 @@ var AuthController = class {
103534
103534
  this._forceAllowSubscriptionFeatures = forceAllowSubscriptionFeatures;
103535
103535
  this._privoClient = privoClient;
103536
103536
  this._webAuthNRelyingParties = relyingParties;
103537
+ this._privoEnabled = this._privoClient !== null;
103537
103538
  }
103538
103539
  get relyingParties() {
103539
103540
  return this._webAuthNRelyingParties;
@@ -103541,6 +103542,18 @@ var AuthController = class {
103541
103542
  set relyingParties(value) {
103542
103543
  this._webAuthNRelyingParties = value;
103543
103544
  }
103545
+ /**
103546
+ * Gets whether Privo-features are enabled.
103547
+ */
103548
+ get privoEnabled() {
103549
+ return this._privoEnabled;
103550
+ }
103551
+ /**
103552
+ * Sets whether Privo-features are enabled.
103553
+ */
103554
+ set privoEnabled(value) {
103555
+ this._privoEnabled = value;
103556
+ }
103544
103557
  async createAccount(request2) {
103545
103558
  try {
103546
103559
  const createSession = request2.createSession ?? true;
@@ -104139,6 +104152,13 @@ var AuthController = class {
104139
104152
  );
104140
104153
  const serviceId = result.userInfo.serviceId;
104141
104154
  const email = result.userInfo.email;
104155
+ if (result.userInfo.roleIdentifier !== config2.roleIds.adult && result.userInfo.roleIdentifier !== config2.roleIds.child) {
104156
+ return {
104157
+ success: false,
104158
+ errorCode: "invalid_request",
104159
+ errorMessage: "The login request is invalid. You attempted to sign into an account that is associated with a parent email address. This is not allowed because we don't ask consent for parent accounts, but all accounts must have consent. Please sign up with a new account instead."
104160
+ };
104161
+ }
104142
104162
  let user;
104143
104163
  if (serviceId) {
104144
104164
  user = await this._store.findUserByPrivoServiceId(
@@ -104262,6 +104282,7 @@ var AuthController = class {
104262
104282
  let updatePasswordUrl;
104263
104283
  let serviceId;
104264
104284
  let parentServiceId;
104285
+ let consentUrl;
104265
104286
  if (years < 0) {
104266
104287
  return {
104267
104288
  success: false,
@@ -104298,6 +104319,7 @@ var AuthController = class {
104298
104319
  serviceId = result.childServiceId;
104299
104320
  parentServiceId = result.parentServiceId;
104300
104321
  updatePasswordUrl = result.updatePasswordLink;
104322
+ consentUrl = result.consentUrl;
104301
104323
  privacyFeatures = getPrivacyFeaturesFromPermissions(
104302
104324
  config2.featureIds,
104303
104325
  result.features
@@ -104328,6 +104350,7 @@ var AuthController = class {
104328
104350
  }
104329
104351
  serviceId = result.adultServiceId;
104330
104352
  updatePasswordUrl = result.updatePasswordLink;
104353
+ consentUrl = result.consentUrl;
104331
104354
  privacyFeatures = getPrivacyFeaturesFromPermissions(
104332
104355
  config2.featureIds,
104333
104356
  result.features
@@ -104344,6 +104367,7 @@ var AuthController = class {
104344
104367
  currentLoginRequestId: null,
104345
104368
  privoServiceId: serviceId,
104346
104369
  privoParentServiceId: parentServiceId,
104370
+ privoConsentUrl: consentUrl,
104347
104371
  privacyFeatures
104348
104372
  };
104349
104373
  const saveUserResult = await this._store.saveNewUser(user);
@@ -105589,6 +105613,77 @@ var AuthController = class {
105589
105613
  };
105590
105614
  }
105591
105615
  }
105616
+ async requestPrivacyFeaturesChange(request2) {
105617
+ try {
105618
+ if (!this._privoClient) {
105619
+ return {
105620
+ success: false,
105621
+ errorCode: "not_supported",
105622
+ errorMessage: "Privo features are not supported on this server."
105623
+ };
105624
+ }
105625
+ const config2 = await this._config.getPrivoConfiguration();
105626
+ if (!config2) {
105627
+ return {
105628
+ success: false,
105629
+ errorCode: "not_supported",
105630
+ errorMessage: "Privo features are not supported on this server."
105631
+ };
105632
+ }
105633
+ const keyResult = await this.validateSessionKey(request2.sessionKey);
105634
+ if (keyResult.success === false) {
105635
+ return keyResult;
105636
+ } else if (keyResult.userId !== request2.userId && keyResult.role !== "superUser") {
105637
+ console.log(
105638
+ "[AuthController] [requestPrivacyFeaturesChange] Request User ID doesnt match session key User ID!"
105639
+ );
105640
+ return {
105641
+ success: false,
105642
+ errorCode: "invalid_key",
105643
+ errorMessage: INVALID_KEY_ERROR_MESSAGE
105644
+ };
105645
+ }
105646
+ const user = await this._store.findUser(request2.userId);
105647
+ if (!user) {
105648
+ throw new Error(
105649
+ "Unable to find user even though a valid session key was presented!"
105650
+ );
105651
+ }
105652
+ if (!user.privoServiceId) {
105653
+ return {
105654
+ success: false,
105655
+ errorCode: "not_supported",
105656
+ errorMessage: "Privo features are not supported on this server."
105657
+ };
105658
+ }
105659
+ const result = await this._privoClient.resendConsentRequest(
105660
+ user.privoServiceId,
105661
+ user.privoParentServiceId ?? user.privoServiceId
105662
+ );
105663
+ if (result.success === false) {
105664
+ return result;
105665
+ }
105666
+ console.log(
105667
+ `[AuthController] [requestPrivacyFeaturesChange] [userId: ${request2.userId}] Requested privacy features change.`
105668
+ );
105669
+ return {
105670
+ success: true
105671
+ };
105672
+ } catch (err) {
105673
+ const span = trace.getActiveSpan();
105674
+ span?.recordException(err);
105675
+ span?.setStatus({ code: SpanStatusCode.ERROR });
105676
+ console.error(
105677
+ "[AuthController] Error ocurred while requesting a change in privacy features",
105678
+ err
105679
+ );
105680
+ return {
105681
+ success: false,
105682
+ errorCode: "server_error",
105683
+ errorMessage: "A server error occurred."
105684
+ };
105685
+ }
105686
+ }
105592
105687
  async listEmailRules() {
105593
105688
  try {
105594
105689
  const rules = await this._store.listEmailRules();
@@ -105879,6 +105974,9 @@ __decorateClass([
105879
105974
  __decorateClass([
105880
105975
  traced(TRACE_NAME)
105881
105976
  ], AuthController.prototype, "updateUserInfo", 1);
105977
+ __decorateClass([
105978
+ traced(TRACE_NAME)
105979
+ ], AuthController.prototype, "requestPrivacyFeaturesChange", 1);
105882
105980
  __decorateClass([
105883
105981
  traced(TRACE_NAME)
105884
105982
  ], AuthController.prototype, "listEmailRules", 1);
@@ -110645,12 +110743,21 @@ var PolicyController = class {
110645
110743
  recordOwnerPrivacyFeatures = await this._policies.getUserPrivacyFeatures(ownerId);
110646
110744
  }
110647
110745
  if (!recordOwnerPrivacyFeatures) {
110648
- recordOwnerPrivacyFeatures = {
110649
- allowAI: true,
110650
- allowPublicData: true,
110651
- allowPublicInsts: true,
110652
- publishData: true
110653
- };
110746
+ if (this._auth.privoEnabled) {
110747
+ recordOwnerPrivacyFeatures = {
110748
+ allowAI: false,
110749
+ allowPublicData: false,
110750
+ allowPublicInsts: false,
110751
+ publishData: false
110752
+ };
110753
+ } else {
110754
+ recordOwnerPrivacyFeatures = {
110755
+ allowAI: true,
110756
+ allowPublicData: true,
110757
+ allowPublicInsts: true,
110758
+ publishData: true
110759
+ };
110760
+ }
110654
110761
  }
110655
110762
  if (request2.userId) {
110656
110763
  userPrivacyFeatures = await this._policies.getUserPrivacyFeatures(
@@ -110658,12 +110765,21 @@ var PolicyController = class {
110658
110765
  );
110659
110766
  }
110660
110767
  if (!userPrivacyFeatures) {
110661
- userPrivacyFeatures = {
110662
- allowAI: true,
110663
- allowPublicData: true,
110664
- allowPublicInsts: true,
110665
- publishData: true
110666
- };
110768
+ if (this._auth.privoEnabled) {
110769
+ userPrivacyFeatures = {
110770
+ allowAI: false,
110771
+ allowPublicData: false,
110772
+ allowPublicInsts: false,
110773
+ publishData: false
110774
+ };
110775
+ } else {
110776
+ userPrivacyFeatures = {
110777
+ allowAI: true,
110778
+ allowPublicData: true,
110779
+ allowPublicInsts: true,
110780
+ publishData: true
110781
+ };
110782
+ }
110667
110783
  }
110668
110784
  const context = {
110669
110785
  recordName,
@@ -114143,7 +114259,7 @@ var RecordsServer = class {
114143
114259
  this._webhooksController = webhooksController;
114144
114260
  this._tracer = trace.getTracer(
114145
114261
  "RecordsServer",
114146
- false ? void 0 : "v3.3.11-alpha.11060020867"
114262
+ false ? void 0 : "v3.3.11-alpha.11349749950"
114147
114263
  );
114148
114264
  this._procedures = this._createProcedures();
114149
114265
  this._setupRoutes();
@@ -114383,6 +114499,21 @@ var RecordsServer = class {
114383
114499
  return result;
114384
114500
  }
114385
114501
  ),
114502
+ requestPrivacyFeaturesChange: procedure().origins("account").http("POST", "/api/v2/privacyFeatures/change").inputs(
114503
+ z.object({
114504
+ userId: z.string()
114505
+ })
114506
+ ).handler(async ({ userId }, context) => {
114507
+ const sessionKey = context.sessionKey;
114508
+ if (!sessionKey) {
114509
+ return NOT_LOGGED_IN_RESULT;
114510
+ }
114511
+ const result = await this._auth.requestPrivacyFeaturesChange({
114512
+ userId,
114513
+ sessionKey
114514
+ });
114515
+ return result;
114516
+ }),
114386
114517
  getWebAuthnRegistrationOptions: procedure().origins(true).http("GET", "/api/v2/webauthn/register/options").handler(async (_3, context) => {
114387
114518
  const validation = await this._validateSessionKey(
114388
114519
  context.sessionKey
@@ -116222,8 +116353,8 @@ var RecordsServer = class {
116222
116353
  return {
116223
116354
  success: true,
116224
116355
  ...metadata,
116225
- version: true ? "v3.3.11-alpha.11060020867" : void 0,
116226
- versionHash: true ? "7781de97502b390b36df63d2cbcc1ab149e0dc90" : void 0
116356
+ version: true ? "v3.3.11-alpha.11349749950" : void 0,
116357
+ versionHash: true ? "619e0c7640cc4279dc1423c3bc0025ab5716b398" : void 0
116227
116358
  };
116228
116359
  })
116229
116360
  };
@@ -131568,6 +131699,7 @@ var WebhookRecordsController = class extends CrudRecordsController {
131568
131699
  errorMessage: "Invalid webhook target. The targeted record does not contain a valid AUX."
131569
131700
  };
131570
131701
  }
131702
+ let sessionUserId;
131571
131703
  let sessionKey;
131572
131704
  let connectionKey;
131573
131705
  if (webhook.userId) {
@@ -131579,6 +131711,7 @@ var WebhookRecordsController = class extends CrudRecordsController {
131579
131711
  lifetimeMs: checkMetrics.features.tokenLifetimeMs ?? 5 * 60 * 1e3
131580
131712
  });
131581
131713
  if (issueSessionResult.success === true) {
131714
+ sessionUserId = issueSessionResult.userId;
131582
131715
  sessionKey = issueSessionResult.sessionKey;
131583
131716
  connectionKey = issueSessionResult.connectionKey;
131584
131717
  } else {
@@ -131599,6 +131732,8 @@ var WebhookRecordsController = class extends CrudRecordsController {
131599
131732
  recordName: stateRecordName,
131600
131733
  inst: stateInstName,
131601
131734
  request: request2.request,
131735
+ requestUserId: request2.userId,
131736
+ sessionUserId,
131602
131737
  sessionKey,
131603
131738
  connectionKey,
131604
131739
  options
@@ -131614,6 +131749,7 @@ var WebhookRecordsController = class extends CrudRecordsController {
131614
131749
  runId,
131615
131750
  version: 1,
131616
131751
  request: request2.request,
131752
+ requestUserId: request2.userId,
131617
131753
  response: result.success === true ? result.response : null,
131618
131754
  logs: result.success === true ? result.logs : [],
131619
131755
  state,
@@ -144036,7 +144172,7 @@ var config = new Conf({
144036
144172
  projectName: "casualos-cli"
144037
144173
  });
144038
144174
  var program2 = new Command();
144039
- program2.name("casualos").description("A CLI for CasualOS").version("v3.3.11-alpha.11060020867").option(
144175
+ program2.name("casualos").description("A CLI for CasualOS").version("v3.3.11-alpha.11349749950").option(
144040
144176
  "-e, --endpoint <url>",
144041
144177
  "The endpoint to use for queries. Can be used to override the current endpoint."
144042
144178
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "casualos",
3
- "version": "3.3.11-alpha.11060020867",
3
+ "version": "3.3.11-alpha.11349749950",
4
4
  "description": "Command line interface for CasualOS.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "index.d.ts",
@@ -35,8 +35,8 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@casual-simulation/aux-common": "^3.3.11-alpha.11060020867",
39
- "@casual-simulation/aux-records": "^3.3.11-alpha.11060020867",
38
+ "@casual-simulation/aux-common": "^3.3.11-alpha.11349749950",
39
+ "@casual-simulation/aux-records": "^3.3.11-alpha.11349749950",
40
40
  "@octokit/app": "^15.1.0",
41
41
  "@octokit/auth-oauth-device": "^7.1.1",
42
42
  "@octokit/core": "^6.1.2",
@@ -63,5 +63,5 @@
63
63
  "**/*.def",
64
64
  "templates/**"
65
65
  ],
66
- "gitHead": "7781de97502b390b36df63d2cbcc1ab149e0dc90"
66
+ "gitHead": "619e0c7640cc4279dc1423c3bc0025ab5716b398"
67
67
  }