@stackframe/stack 2.6.11 → 2.6.12
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/CHANGELOG.md +10 -0
- package/dist/components-page/account-settings.js +287 -103
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/account-settings.js +288 -104
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.js +2137 -1813
- package/dist/esm/generated/quetzal-translations.js.map +1 -1
- package/dist/esm/lib/stack-app.js +132 -11
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/generated/global-css.d.mts +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/generated/quetzal-translations.d.mts +2 -2
- package/dist/generated/quetzal-translations.d.ts +2 -2
- package/dist/generated/quetzal-translations.js +2137 -1813
- package/dist/generated/quetzal-translations.js.map +1 -1
- package/dist/lib/stack-app.d.mts +51 -17
- package/dist/lib/stack-app.d.ts +51 -17
- package/dist/lib/stack-app.js +132 -11
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +4 -4
|
@@ -24,7 +24,7 @@ import { constructRedirectUrl } from "../utils/url";
|
|
|
24
24
|
import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
|
|
25
25
|
import { deleteCookie, getCookie, setOrDeleteCookie } from "./cookie";
|
|
26
26
|
var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
|
|
27
|
-
var clientVersion = "js @stackframe/stack@2.6.
|
|
27
|
+
var clientVersion = "js @stackframe/stack@2.6.12";
|
|
28
28
|
function getUrls(partial) {
|
|
29
29
|
const handler = partial.handler ?? "/handler";
|
|
30
30
|
const home = partial.home ?? "/";
|
|
@@ -62,10 +62,10 @@ async function _redirectTo(url, options) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function getDefaultProjectId() {
|
|
65
|
-
return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || throwErr(new Error("Welcome to Stack! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
|
|
65
|
+
return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || throwErr(new Error("Welcome to Stack Auth! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
|
|
66
66
|
}
|
|
67
67
|
function getDefaultPublishableClientKey() {
|
|
68
|
-
return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || throwErr(new Error("Welcome to Stack! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
|
|
68
|
+
return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || throwErr(new Error("Welcome to Stack Auth! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
|
|
69
69
|
}
|
|
70
70
|
function getDefaultSecretServerKey() {
|
|
71
71
|
return process.env.STACK_SECRET_SERVER_KEY || throwErr(new Error("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable."));
|
|
@@ -187,6 +187,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
187
187
|
return await this._interface.getTeamMemberProfile({ teamId, userId: "me" }, session);
|
|
188
188
|
}
|
|
189
189
|
);
|
|
190
|
+
this._clientContactChannelsCache = createCacheBySession(
|
|
191
|
+
async (session) => {
|
|
192
|
+
return await this._interface.listClientContactChannels(session);
|
|
193
|
+
}
|
|
194
|
+
);
|
|
190
195
|
this._memoryTokenStore = createEmptyTokenStore();
|
|
191
196
|
this._requestTokenStores = /* @__PURE__ */ new WeakMap();
|
|
192
197
|
this._storedCookieTokenStore = null;
|
|
@@ -550,6 +555,28 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
550
555
|
}
|
|
551
556
|
};
|
|
552
557
|
}
|
|
558
|
+
_clientContactChannelFromCrud(crud) {
|
|
559
|
+
const app = this;
|
|
560
|
+
return {
|
|
561
|
+
id: crud.id,
|
|
562
|
+
value: crud.value,
|
|
563
|
+
type: crud.type,
|
|
564
|
+
isVerified: crud.is_verified,
|
|
565
|
+
isPrimary: crud.is_primary,
|
|
566
|
+
usedForAuth: crud.used_for_auth,
|
|
567
|
+
async sendVerificationEmail() {
|
|
568
|
+
return await app._interface.sendCurrentUserContactChannelVerificationEmail(crud.id, constructRedirectUrl(app.urls.emailVerification), app._getSession());
|
|
569
|
+
},
|
|
570
|
+
async update(data) {
|
|
571
|
+
await app._interface.updateClientContactChannel(crud.id, contactChannelUpdateOptionsToCrud(data), app._getSession());
|
|
572
|
+
await app._clientContactChannelsCache.refresh([app._getSession()]);
|
|
573
|
+
},
|
|
574
|
+
async delete() {
|
|
575
|
+
await app._interface.deleteClientContactChannel(crud.id, app._getSession());
|
|
576
|
+
await app._clientContactChannelsCache.refresh([app._getSession()]);
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
}
|
|
553
580
|
_createAuth(session) {
|
|
554
581
|
const app = this;
|
|
555
582
|
return {
|
|
@@ -592,6 +619,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
592
619
|
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
593
620
|
hasPassword: crud.has_password,
|
|
594
621
|
emailAuthEnabled: crud.auth_with_email,
|
|
622
|
+
otpAuthEnabled: crud.otp_auth_enabled,
|
|
595
623
|
oauthProviders: crud.oauth_providers,
|
|
596
624
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team),
|
|
597
625
|
isMultiFactorRequired: crud.requires_totp_mfa,
|
|
@@ -700,7 +728,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
700
728
|
return await app._sendVerificationEmail(crud.primary_email, session);
|
|
701
729
|
},
|
|
702
730
|
async updatePassword(options) {
|
|
703
|
-
|
|
731
|
+
const result = await app._interface.updatePassword(options, session);
|
|
732
|
+
await app._currentUserCache.refresh([session]);
|
|
733
|
+
return result;
|
|
734
|
+
},
|
|
735
|
+
async setPassword(options) {
|
|
736
|
+
const result = await app._interface.setPassword(options, session);
|
|
737
|
+
await app._currentUserCache.refresh([session]);
|
|
738
|
+
return result;
|
|
704
739
|
},
|
|
705
740
|
async getTeamProfile(team) {
|
|
706
741
|
const result = await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only");
|
|
@@ -713,6 +748,19 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
713
748
|
async delete() {
|
|
714
749
|
await app._interface.deleteCurrentUser(session);
|
|
715
750
|
session.markInvalid();
|
|
751
|
+
},
|
|
752
|
+
async listContactChannels() {
|
|
753
|
+
const result = await app._clientContactChannelsCache.getOrWait([session], "write-only");
|
|
754
|
+
return result.map((crud2) => app._clientContactChannelFromCrud(crud2));
|
|
755
|
+
},
|
|
756
|
+
useContactChannels() {
|
|
757
|
+
const result = useAsyncCache(app._clientContactChannelsCache, [session], "user.useContactChannels()");
|
|
758
|
+
return result.map((crud2) => app._clientContactChannelFromCrud(crud2));
|
|
759
|
+
},
|
|
760
|
+
async createContactChannel(data) {
|
|
761
|
+
const crud2 = await app._interface.createClientContactChannel(contactChannelCreateOptionsToCrud("me", data), session);
|
|
762
|
+
await app._clientContactChannelsCache.refresh([session]);
|
|
763
|
+
return app._clientContactChannelFromCrud(crud2);
|
|
716
764
|
}
|
|
717
765
|
};
|
|
718
766
|
}
|
|
@@ -895,7 +943,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
895
943
|
}
|
|
896
944
|
}
|
|
897
945
|
async verifyEmail(code) {
|
|
898
|
-
|
|
946
|
+
const result = await this._interface.verifyEmail(code);
|
|
947
|
+
await this._currentUserCache.refresh([this._getSession()]);
|
|
948
|
+
await this._clientContactChannelsCache.refresh([this._getSession()]);
|
|
949
|
+
return result;
|
|
899
950
|
}
|
|
900
951
|
async getUser(options) {
|
|
901
952
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
@@ -1092,9 +1143,6 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1092
1143
|
const emailVerificationRedirectUrl = constructRedirectUrl(this.urls.emailVerification);
|
|
1093
1144
|
return await this._interface.sendVerificationEmail(email, emailVerificationRedirectUrl, session);
|
|
1094
1145
|
}
|
|
1095
|
-
async _updatePassword(options, session) {
|
|
1096
|
-
return await this._interface.updatePassword(options, session);
|
|
1097
|
-
}
|
|
1098
1146
|
async signOut() {
|
|
1099
1147
|
const user = await this.getUser();
|
|
1100
1148
|
if (user) {
|
|
@@ -1264,6 +1312,11 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1264
1312
|
return await this._interface.getServerTeamMemberProfile({ teamId, userId });
|
|
1265
1313
|
}
|
|
1266
1314
|
);
|
|
1315
|
+
this._serverContactChannelsCache = createCache(
|
|
1316
|
+
async ([userId]) => {
|
|
1317
|
+
return await this._interface.listServerContactChannels(userId);
|
|
1318
|
+
}
|
|
1319
|
+
);
|
|
1267
1320
|
}
|
|
1268
1321
|
async _updateServerUser(userId, update) {
|
|
1269
1322
|
const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));
|
|
@@ -1281,6 +1334,21 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1281
1334
|
}
|
|
1282
1335
|
};
|
|
1283
1336
|
}
|
|
1337
|
+
_serverContactChannelFromCrud(userId, crud) {
|
|
1338
|
+
const app = this;
|
|
1339
|
+
return {
|
|
1340
|
+
...this._clientContactChannelFromCrud(crud),
|
|
1341
|
+
async sendVerificationEmail() {
|
|
1342
|
+
return await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, constructRedirectUrl(app.urls.emailVerification));
|
|
1343
|
+
},
|
|
1344
|
+
async update(data) {
|
|
1345
|
+
await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));
|
|
1346
|
+
},
|
|
1347
|
+
async delete() {
|
|
1348
|
+
await app._interface.deleteServerContactChannel(userId, crud.id);
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1284
1352
|
_serverUserFromCrud(crud) {
|
|
1285
1353
|
const app = this;
|
|
1286
1354
|
async function getConnectedAccount(id, options) {
|
|
@@ -1397,7 +1465,14 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1397
1465
|
return await app._checkFeatureSupport("sendVerificationEmail() on ServerUser", {});
|
|
1398
1466
|
},
|
|
1399
1467
|
async updatePassword(options) {
|
|
1400
|
-
|
|
1468
|
+
const result = await this.update({ password: options.newPassword });
|
|
1469
|
+
await app._serverUserCache.refresh([crud.id]);
|
|
1470
|
+
return result;
|
|
1471
|
+
},
|
|
1472
|
+
async setPassword(options) {
|
|
1473
|
+
const result = await this.update(options);
|
|
1474
|
+
await app._serverUserCache.refresh([crud.id]);
|
|
1475
|
+
return result;
|
|
1401
1476
|
},
|
|
1402
1477
|
async getTeamProfile(team) {
|
|
1403
1478
|
const result = await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], "write-only");
|
|
@@ -1406,6 +1481,19 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1406
1481
|
useTeamProfile(team) {
|
|
1407
1482
|
const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id], "user.useTeamProfile()");
|
|
1408
1483
|
return useMemo(() => app._serverEditableTeamProfileFromCrud(result), [result]);
|
|
1484
|
+
},
|
|
1485
|
+
async listContactChannels() {
|
|
1486
|
+
const result = await app._serverContactChannelsCache.getOrWait([crud.id], "write-only");
|
|
1487
|
+
return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));
|
|
1488
|
+
},
|
|
1489
|
+
useContactChannels() {
|
|
1490
|
+
const result = useAsyncCache(app._serverContactChannelsCache, [crud.id], "user.useContactChannels()");
|
|
1491
|
+
return useMemo(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);
|
|
1492
|
+
},
|
|
1493
|
+
createContactChannel: async (data) => {
|
|
1494
|
+
const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));
|
|
1495
|
+
await app._serverContactChannelsCache.refresh([crud.id]);
|
|
1496
|
+
return app._serverContactChannelFromCrud(crud.id, contactChannel);
|
|
1409
1497
|
}
|
|
1410
1498
|
};
|
|
1411
1499
|
}
|
|
@@ -1854,13 +1942,45 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1854
1942
|
await this._apiKeysCache.refresh([]);
|
|
1855
1943
|
}
|
|
1856
1944
|
};
|
|
1945
|
+
function contactChannelCreateOptionsToCrud(userId, options) {
|
|
1946
|
+
return {
|
|
1947
|
+
value: options.value,
|
|
1948
|
+
type: options.type,
|
|
1949
|
+
used_for_auth: options.usedForAuth,
|
|
1950
|
+
user_id: userId
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
function contactChannelUpdateOptionsToCrud(options) {
|
|
1954
|
+
return {
|
|
1955
|
+
value: options.value,
|
|
1956
|
+
used_for_auth: options.usedForAuth,
|
|
1957
|
+
is_primary: options.isPrimary
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
function serverContactChannelUpdateOptionsToCrud(options) {
|
|
1961
|
+
return {
|
|
1962
|
+
value: options.value,
|
|
1963
|
+
is_verified: options.isVerified,
|
|
1964
|
+
used_for_auth: options.usedForAuth
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
function serverContactChannelCreateOptionsToCrud(userId, options) {
|
|
1968
|
+
return {
|
|
1969
|
+
type: options.type,
|
|
1970
|
+
value: options.value,
|
|
1971
|
+
is_verified: options.isVerified,
|
|
1972
|
+
user_id: userId,
|
|
1973
|
+
used_for_auth: options.usedForAuth
|
|
1974
|
+
};
|
|
1975
|
+
}
|
|
1857
1976
|
function userUpdateOptionsToCrud(options) {
|
|
1858
1977
|
return {
|
|
1859
1978
|
display_name: options.displayName,
|
|
1860
1979
|
client_metadata: options.clientMetadata,
|
|
1861
1980
|
selected_team_id: options.selectedTeamId,
|
|
1862
1981
|
totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,
|
|
1863
|
-
profile_image_url: options.profileImageUrl
|
|
1982
|
+
profile_image_url: options.profileImageUrl,
|
|
1983
|
+
otp_auth_enabled: options.otpAuthEnabled
|
|
1864
1984
|
};
|
|
1865
1985
|
}
|
|
1866
1986
|
function serverUserUpdateOptionsToCrud(options) {
|
|
@@ -1882,7 +2002,8 @@ function serverUserCreateOptionsToCrud(options) {
|
|
|
1882
2002
|
return {
|
|
1883
2003
|
primary_email: options.primaryEmail,
|
|
1884
2004
|
password: options.password,
|
|
1885
|
-
|
|
2005
|
+
otp_auth_enabled: options.otpAuthEnabled,
|
|
2006
|
+
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
1886
2007
|
display_name: options.displayName,
|
|
1887
2008
|
primary_email_verified: options.primaryEmailVerified
|
|
1888
2009
|
};
|