@stackframe/stack 2.4.3 → 2.4.6

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.
@@ -53,6 +53,7 @@ var import_objects = require("@stackframe/stack-shared/dist/utils/objects");
53
53
  var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
54
54
  var import_caches = require("@stackframe/stack-shared/dist/utils/caches");
55
55
  var import_react3 = require("@stackframe/stack-shared/dist/utils/react");
56
+ var clientVersion = "js @stackframe/stack@2.4.6";
56
57
  function permissionDefinitionScopeToType(scope) {
57
58
  return { "any-team": "team", "specific-team": "team", "global": "global" }[scope.type];
58
59
  }
@@ -232,6 +233,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
232
233
  this._interface = new import_stack_shared.StackClientInterface({
233
234
  baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
234
235
  projectId: options.projectId ?? getDefaultProjectId(),
236
+ clientVersion,
235
237
  publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey()
236
238
  });
237
239
  }
@@ -345,8 +347,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
345
347
  return permissions.find((p) => p.id === permissionId) ?? null;
346
348
  },
347
349
  async hasPermission(scope, permissionId) {
348
- const permissions = await this.listPermissions(scope);
349
- return permissions.some((p) => p.id === permissionId);
350
+ return await this.getPermission(scope, permissionId) !== null;
350
351
  },
351
352
  toJson() {
352
353
  return json;
@@ -405,22 +406,6 @@ var _StackClientAppImpl = class __StackClientAppImpl {
405
406
  return currentUser;
406
407
  }
407
408
  }
408
- _userToJson(user) {
409
- return {
410
- projectId: user.projectId,
411
- id: user.id,
412
- displayName: user.displayName,
413
- primaryEmail: user.primaryEmail,
414
- primaryEmailVerified: user.primaryEmailVerified,
415
- profileImageUrl: user.profileImageUrl,
416
- signedUpAtMillis: user.signedUpAt.getTime(),
417
- clientMetadata: user.clientMetadata,
418
- authMethod: user.authMethod,
419
- hasPassword: user.hasPassword,
420
- authWithEmail: user.authWithEmail,
421
- oauthProviders: user.oauthProviders
422
- };
423
- }
424
409
  _projectAdminFromJson(data, adminInterface, onRefresh) {
425
410
  if (data.id !== adminInterface.projectId) {
426
411
  throw new Error(`The project ID of the provided project JSON (${data.id}) does not match the project ID of the app (${adminInterface.projectId})! This is a Stack bug.`);
@@ -458,6 +443,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
458
443
  return new import_stack_shared.StackAdminInterface({
459
444
  baseUrl: this._interface.options.baseUrl,
460
445
  projectId: forProjectId,
446
+ clientVersion,
461
447
  projectOwnerTokens: tokenStore
462
448
  });
463
449
  }
@@ -467,12 +453,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
467
453
  get urls() {
468
454
  return getUrls(this._urlOptions);
469
455
  }
470
- _redirectTo(handlerName) {
456
+ async _redirectTo(handlerName) {
471
457
  if (!this.urls[handlerName]) {
472
458
  throw new Error(`No URL for handler name ${handlerName}`);
473
459
  }
474
460
  window.location.href = this.urls[handlerName];
475
- return (0, import_promises.wait)(2e3);
461
+ return await (0, import_promises.wait)(2e3);
476
462
  }
477
463
  async redirectToSignIn() {
478
464
  return await this._redirectTo("signIn");
@@ -792,24 +778,21 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
792
778
  return await this._interface.listTeamMemberPermissions({ teamId, userId, type, direct });
793
779
  });
794
780
  constructor(options) {
795
- if ("interface" in options) {
796
- super({
797
- interface: options.interface,
798
- tokenStore: options.tokenStore,
799
- urls: options.urls
800
- });
801
- } else {
802
- super({
803
- interface: new import_stack_shared.StackServerInterface({
804
- baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
805
- projectId: options.projectId ?? getDefaultProjectId(),
806
- publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
807
- secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
808
- }),
809
- tokenStore: options.tokenStore,
810
- urls: options.urls ?? {}
811
- });
812
- }
781
+ super("interface" in options ? {
782
+ interface: options.interface,
783
+ tokenStore: options.tokenStore,
784
+ urls: options.urls
785
+ } : {
786
+ interface: new import_stack_shared.StackServerInterface({
787
+ baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
788
+ projectId: options.projectId ?? getDefaultProjectId(),
789
+ clientVersion,
790
+ publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
791
+ secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
792
+ }),
793
+ tokenStore: options.tokenStore,
794
+ urls: options.urls ?? {}
795
+ });
813
796
  }
814
797
  _serverUserFromJson(json) {
815
798
  if (json === null)
@@ -893,7 +876,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
893
876
  return permissions.some((p) => p.id === permissionId);
894
877
  },
895
878
  toJson() {
896
- return app._serverUserToJson(this);
879
+ return json;
897
880
  }
898
881
  };
899
882
  }
@@ -965,23 +948,6 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
965
948
  }
966
949
  };
967
950
  }
968
- _serverUserToJson(user) {
969
- return {
970
- projectId: user.projectId,
971
- id: user.id,
972
- displayName: user.displayName,
973
- primaryEmail: user.primaryEmail,
974
- primaryEmailVerified: user.primaryEmailVerified,
975
- profileImageUrl: user.profileImageUrl,
976
- signedUpAtMillis: user.signedUpAt.getTime(),
977
- clientMetadata: user.clientMetadata,
978
- serverMetadata: user.serverMetadata,
979
- authMethod: user.authMethod,
980
- hasPassword: user.hasPassword,
981
- authWithEmail: user.authWithEmail,
982
- oauthProviders: user.oauthProviders
983
- };
984
- }
985
951
  _serverTeamFromJson(json) {
986
952
  const app = this;
987
953
  return {
@@ -1142,6 +1108,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1142
1108
  interface: new import_stack_shared.StackAdminInterface({
1143
1109
  baseUrl: options.baseUrl ?? getDefaultBaseUrl(),
1144
1110
  projectId: options.projectId ?? getDefaultProjectId(),
1111
+ clientVersion,
1145
1112
  ..."projectOwnerTokens" in options ? {
1146
1113
  projectOwnerTokens: options.projectOwnerTokens
1147
1114
  } : {