@stackframe/stack 2.7.14 → 2.7.17
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 +29 -0
- package/README.md +1 -1
- package/dist/components/iframe-preventer.d.mts +8 -0
- package/dist/components/iframe-preventer.d.ts +8 -0
- package/dist/components/iframe-preventer.js +52 -0
- package/dist/components/iframe-preventer.js.map +1 -0
- package/dist/components/oauth-button.js +11 -122
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components-page/stack-handler.js +3 -2
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components/iframe-preventer.js +28 -0
- package/dist/esm/components/iframe-preventer.js.map +1 -0
- package/dist/esm/components/oauth-button.js +12 -123
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +3 -2
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/lib/stack-app.js +57 -24
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/lib/auth.d.mts +1 -1
- package/dist/lib/auth.d.ts +1 -1
- package/dist/lib/stack-app.d.mts +11 -2
- package/dist/lib/stack-app.d.ts +11 -2
- package/dist/lib/stack-app.js +57 -24
- package/dist/lib/stack-app.js.map +1 -1
- package/package.json +4 -4
package/dist/lib/auth.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ declare function callOAuthCallback(iface: StackClientInterface, redirectUrl: str
|
|
|
22
22
|
status: "ok";
|
|
23
23
|
data: {
|
|
24
24
|
newUser: boolean;
|
|
25
|
-
afterCallbackRedirectUrl?: string
|
|
25
|
+
afterCallbackRedirectUrl?: string;
|
|
26
26
|
accessToken: string;
|
|
27
27
|
refreshToken: string;
|
|
28
28
|
};
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare function callOAuthCallback(iface: StackClientInterface, redirectUrl: str
|
|
|
22
22
|
status: "ok";
|
|
23
23
|
data: {
|
|
24
24
|
newUser: boolean;
|
|
25
|
-
afterCallbackRedirectUrl?: string
|
|
25
|
+
afterCallbackRedirectUrl?: string;
|
|
26
26
|
accessToken: string;
|
|
27
27
|
refreshToken: string;
|
|
28
28
|
};
|
package/dist/lib/stack-app.d.mts
CHANGED
|
@@ -43,7 +43,10 @@ type OAuthScopesOnSignIn = {
|
|
|
43
43
|
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
44
44
|
type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
|
|
45
45
|
type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {
|
|
46
|
-
baseUrl?: string
|
|
46
|
+
baseUrl?: string | {
|
|
47
|
+
browser: string;
|
|
48
|
+
server: string;
|
|
49
|
+
};
|
|
47
50
|
projectId?: ProjectId;
|
|
48
51
|
publishableClientKey?: string;
|
|
49
52
|
urls?: Partial<HandlerUrls>;
|
|
@@ -318,6 +321,7 @@ type ServerBaseUser = {
|
|
|
318
321
|
readonly serverMetadata: any;
|
|
319
322
|
setServerMetadata(metadata: any): Promise<void>;
|
|
320
323
|
setClientReadOnlyMetadata(metadata: any): Promise<void>;
|
|
324
|
+
createTeam(data: Omit<ServerTeamCreateOptions, "creatorUserId">): Promise<ServerTeam>;
|
|
321
325
|
useContactChannels(): ServerContactChannel[];
|
|
322
326
|
listContactChannels(): Promise<ServerContactChannel[]>;
|
|
323
327
|
createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>;
|
|
@@ -357,6 +361,9 @@ type ServerUserCreateOptions = {
|
|
|
357
361
|
otpAuthEnabled?: boolean;
|
|
358
362
|
displayName?: string;
|
|
359
363
|
primaryEmailVerified?: boolean;
|
|
364
|
+
clientMetadata?: any;
|
|
365
|
+
clientReadOnlyMetadata?: any;
|
|
366
|
+
serverMetadata?: any;
|
|
360
367
|
};
|
|
361
368
|
type Project = {
|
|
362
369
|
readonly id: string;
|
|
@@ -573,7 +580,9 @@ type ServerListUsersOptions = {
|
|
|
573
580
|
desc?: boolean;
|
|
574
581
|
query?: string;
|
|
575
582
|
};
|
|
576
|
-
type ServerTeamCreateOptions = TeamCreateOptions
|
|
583
|
+
type ServerTeamCreateOptions = TeamCreateOptions & {
|
|
584
|
+
creatorUserId?: string;
|
|
585
|
+
};
|
|
577
586
|
type ServerTeamUpdateOptions = TeamUpdateOptions & {
|
|
578
587
|
clientReadOnlyMetadata?: ReadonlyJson;
|
|
579
588
|
serverMetadata?: ReadonlyJson;
|
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -43,7 +43,10 @@ type OAuthScopesOnSignIn = {
|
|
|
43
43
|
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
44
44
|
type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
|
|
45
45
|
type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {
|
|
46
|
-
baseUrl?: string
|
|
46
|
+
baseUrl?: string | {
|
|
47
|
+
browser: string;
|
|
48
|
+
server: string;
|
|
49
|
+
};
|
|
47
50
|
projectId?: ProjectId;
|
|
48
51
|
publishableClientKey?: string;
|
|
49
52
|
urls?: Partial<HandlerUrls>;
|
|
@@ -318,6 +321,7 @@ type ServerBaseUser = {
|
|
|
318
321
|
readonly serverMetadata: any;
|
|
319
322
|
setServerMetadata(metadata: any): Promise<void>;
|
|
320
323
|
setClientReadOnlyMetadata(metadata: any): Promise<void>;
|
|
324
|
+
createTeam(data: Omit<ServerTeamCreateOptions, "creatorUserId">): Promise<ServerTeam>;
|
|
321
325
|
useContactChannels(): ServerContactChannel[];
|
|
322
326
|
listContactChannels(): Promise<ServerContactChannel[]>;
|
|
323
327
|
createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>;
|
|
@@ -357,6 +361,9 @@ type ServerUserCreateOptions = {
|
|
|
357
361
|
otpAuthEnabled?: boolean;
|
|
358
362
|
displayName?: string;
|
|
359
363
|
primaryEmailVerified?: boolean;
|
|
364
|
+
clientMetadata?: any;
|
|
365
|
+
clientReadOnlyMetadata?: any;
|
|
366
|
+
serverMetadata?: any;
|
|
360
367
|
};
|
|
361
368
|
type Project = {
|
|
362
369
|
readonly id: string;
|
|
@@ -573,7 +580,9 @@ type ServerListUsersOptions = {
|
|
|
573
580
|
desc?: boolean;
|
|
574
581
|
query?: string;
|
|
575
582
|
};
|
|
576
|
-
type ServerTeamCreateOptions = TeamCreateOptions
|
|
583
|
+
type ServerTeamCreateOptions = TeamCreateOptions & {
|
|
584
|
+
creatorUserId?: string;
|
|
585
|
+
};
|
|
577
586
|
type ServerTeamUpdateOptions = TeamUpdateOptions & {
|
|
578
587
|
clientReadOnlyMetadata?: ReadonlyJson;
|
|
579
588
|
serverMetadata?: ReadonlyJson;
|
package/dist/lib/stack-app.js
CHANGED
|
@@ -39,7 +39,6 @@ __export(stack_app_exports, {
|
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(stack_app_exports);
|
|
41
41
|
var import_browser = require("@simplewebauthn/browser");
|
|
42
|
-
var import_stack_sc = require("@stackframe/stack-sc");
|
|
43
42
|
var import_stack_shared = require("@stackframe/stack-shared");
|
|
44
43
|
var import_production_mode = require("@stackframe/stack-shared/dist/helpers/production-mode");
|
|
45
44
|
var import_sessions = require("@stackframe/stack-shared/dist/sessions");
|
|
@@ -63,8 +62,14 @@ var import_react2 = __toESM(require("react"));
|
|
|
63
62
|
var import_url = require("../utils/url");
|
|
64
63
|
var import_auth = require("./auth");
|
|
65
64
|
var import_cookie = require("./cookie");
|
|
65
|
+
var sc = __toESM(require("@stackframe/stack-sc"));
|
|
66
|
+
var isReactServer2 = false;
|
|
67
|
+
isReactServer2 = sc.isReactServer;
|
|
66
68
|
var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
|
|
67
|
-
var clientVersion = "js @stackframe/stack@2.7.
|
|
69
|
+
var clientVersion = "js @stackframe/stack@2.7.17";
|
|
70
|
+
if (clientVersion.startsWith("STACK_COMPILE_TIME")) {
|
|
71
|
+
throw new import_errors.StackAssertionError("Client version was not replaced. Something went wrong during build!");
|
|
72
|
+
}
|
|
68
73
|
function getUrls(partial) {
|
|
69
74
|
const handler = partial.handler ?? "/handler";
|
|
70
75
|
const home = partial.home ?? "/";
|
|
@@ -101,8 +106,26 @@ function getDefaultSecretServerKey() {
|
|
|
101
106
|
function getDefaultSuperSecretAdminKey() {
|
|
102
107
|
return process.env.STACK_SUPER_SECRET_ADMIN_KEY || (0, import_errors.throwErr)(new Error("No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable."));
|
|
103
108
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
109
|
+
function getBaseUrl(userSpecifiedBaseUrl) {
|
|
110
|
+
let url;
|
|
111
|
+
if (userSpecifiedBaseUrl) {
|
|
112
|
+
if (typeof userSpecifiedBaseUrl === "string") {
|
|
113
|
+
url = userSpecifiedBaseUrl;
|
|
114
|
+
} else {
|
|
115
|
+
if ((0, import_env.isBrowserLike)()) {
|
|
116
|
+
url = userSpecifiedBaseUrl.browser;
|
|
117
|
+
} else {
|
|
118
|
+
url = userSpecifiedBaseUrl.server;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
if ((0, import_env.isBrowserLike)()) {
|
|
123
|
+
url = process.env.NEXT_PUBLIC_BROWSER_STACK_API_URL;
|
|
124
|
+
} else {
|
|
125
|
+
url = process.env.NEXT_PUBLIC_SERVER_STACK_API_URL;
|
|
126
|
+
}
|
|
127
|
+
url = url || process.env.NEXT_PUBLIC_STACK_API_URL || process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
128
|
+
}
|
|
106
129
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
107
130
|
}
|
|
108
131
|
var defaultBaseUrl = "https://api.stack-auth.com";
|
|
@@ -254,7 +277,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
254
277
|
this._interface = _options.interface;
|
|
255
278
|
} else {
|
|
256
279
|
this._interface = new import_stack_shared.StackClientInterface({
|
|
257
|
-
|
|
280
|
+
getBaseUrl: () => getBaseUrl(_options.baseUrl),
|
|
258
281
|
projectId: _options.projectId ?? getDefaultProjectId(),
|
|
259
282
|
clientVersion,
|
|
260
283
|
publishableClientKey: _options.publishableClientKey ?? getDefaultPublishableClientKey()
|
|
@@ -803,10 +826,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
803
826
|
return (0, import_react2.useMemo)(() => teams.map((crud2) => app._clientTeamFromCrud(crud2, session)), [teams]);
|
|
804
827
|
},
|
|
805
828
|
async createTeam(data) {
|
|
806
|
-
const crud2 = await app._interface.createClientTeam(
|
|
807
|
-
...teamCreateOptionsToCrud(data),
|
|
808
|
-
creator_user_id: "me"
|
|
809
|
-
}, session);
|
|
829
|
+
const crud2 = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
|
|
810
830
|
await app._currentUserTeamsCache.refresh([session]);
|
|
811
831
|
return app._clientTeamFromCrud(crud2, session);
|
|
812
832
|
},
|
|
@@ -912,7 +932,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
912
932
|
_getOwnedAdminApp(forProjectId, session) {
|
|
913
933
|
if (!this._ownedAdminApps.has([session, forProjectId])) {
|
|
914
934
|
this._ownedAdminApps.set([session, forProjectId], new _StackAdminAppImpl({
|
|
915
|
-
baseUrl: this._interface.options.
|
|
935
|
+
baseUrl: this._interface.options.getBaseUrl(),
|
|
916
936
|
projectId: forProjectId,
|
|
917
937
|
tokenStore: null,
|
|
918
938
|
projectOwnerSession: session,
|
|
@@ -940,7 +960,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
940
960
|
if (this._redirectMethod === "none") {
|
|
941
961
|
return;
|
|
942
962
|
}
|
|
943
|
-
if (
|
|
963
|
+
if (isReactServer2 && this._redirectMethod === "nextjs") {
|
|
944
964
|
NextNavigation.redirect(options.url.toString(), options.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
|
|
945
965
|
} else {
|
|
946
966
|
if (options.replace) {
|
|
@@ -964,7 +984,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
964
984
|
}
|
|
965
985
|
if (!options?.noRedirectBack) {
|
|
966
986
|
if (handlerName === "afterSignIn" || handlerName === "afterSignUp") {
|
|
967
|
-
if (
|
|
987
|
+
if (isReactServer2 || typeof window === "undefined") {
|
|
968
988
|
try {
|
|
969
989
|
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
970
990
|
} catch (e) {
|
|
@@ -974,7 +994,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
974
994
|
url = queryParams.get("after_auth_return_to") || url;
|
|
975
995
|
}
|
|
976
996
|
} else if (handlerName === "signIn" || handlerName === "signUp") {
|
|
977
|
-
if (
|
|
997
|
+
if (isReactServer2 || typeof window === "undefined") {
|
|
978
998
|
try {
|
|
979
999
|
await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
|
|
980
1000
|
} catch (e) {
|
|
@@ -1413,7 +1433,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
1413
1433
|
throw new import_errors.StackAssertionError("Cannot serialize to JSON from an application without a publishable client key");
|
|
1414
1434
|
}
|
|
1415
1435
|
return {
|
|
1416
|
-
baseUrl: this.
|
|
1436
|
+
baseUrl: this._options.baseUrl,
|
|
1417
1437
|
projectId: this.projectId,
|
|
1418
1438
|
publishableClientKey: this._interface.options.publishableClientKey,
|
|
1419
1439
|
tokenStore: this._tokenStoreInit,
|
|
@@ -1442,12 +1462,15 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1442
1462
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
1443
1463
|
} : {
|
|
1444
1464
|
interface: new import_stack_shared.StackServerInterface({
|
|
1445
|
-
|
|
1465
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1446
1466
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1447
1467
|
clientVersion,
|
|
1448
1468
|
publishableClientKey: options.publishableClientKey ?? getDefaultPublishableClientKey(),
|
|
1449
1469
|
secretServerKey: options.secretServerKey ?? getDefaultSecretServerKey()
|
|
1450
1470
|
}),
|
|
1471
|
+
baseUrl: options.baseUrl,
|
|
1472
|
+
projectId: options.projectId,
|
|
1473
|
+
publishableClientKey: options.publishableClientKey,
|
|
1451
1474
|
tokenStore: options.tokenStore,
|
|
1452
1475
|
urls: options.urls ?? {},
|
|
1453
1476
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn ?? {}
|
|
@@ -1644,10 +1667,10 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
1644
1667
|
return (0, import_react2.useMemo)(() => teams.map((t) => app._serverTeamFromCrud(t)), [teams]);
|
|
1645
1668
|
},
|
|
1646
1669
|
createTeam: async (data) => {
|
|
1647
|
-
const team = await app._interface.createServerTeam({
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
});
|
|
1670
|
+
const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({
|
|
1671
|
+
creatorUserId: crud.id,
|
|
1672
|
+
...data
|
|
1673
|
+
}));
|
|
1651
1674
|
await app._serverTeamsCache.refresh([void 0]);
|
|
1652
1675
|
return app._serverTeamFromCrud(team);
|
|
1653
1676
|
},
|
|
@@ -1943,7 +1966,7 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1943
1966
|
constructor(options) {
|
|
1944
1967
|
super({
|
|
1945
1968
|
interface: new import_stack_shared.StackAdminInterface({
|
|
1946
|
-
|
|
1969
|
+
getBaseUrl: () => getBaseUrl(options.baseUrl),
|
|
1947
1970
|
projectId: options.projectId ?? getDefaultProjectId(),
|
|
1948
1971
|
clientVersion,
|
|
1949
1972
|
..."projectOwnerSession" in options ? {
|
|
@@ -1954,6 +1977,8 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
|
|
|
1954
1977
|
superSecretAdminKey: options.superSecretAdminKey ?? getDefaultSuperSecretAdminKey()
|
|
1955
1978
|
}
|
|
1956
1979
|
}),
|
|
1980
|
+
baseUrl: options.baseUrl,
|
|
1981
|
+
projectId: options.projectId,
|
|
1957
1982
|
tokenStore: options.tokenStore,
|
|
1958
1983
|
urls: options.urls,
|
|
1959
1984
|
oauthScopesOnSignIn: options.oauthScopesOnSignIn
|
|
@@ -2273,7 +2298,10 @@ function serverUserCreateOptionsToCrud(options) {
|
|
|
2273
2298
|
otp_auth_enabled: options.otpAuthEnabled,
|
|
2274
2299
|
primary_email_auth_enabled: options.primaryEmailAuthEnabled,
|
|
2275
2300
|
display_name: options.displayName,
|
|
2276
|
-
primary_email_verified: options.primaryEmailVerified
|
|
2301
|
+
primary_email_verified: options.primaryEmailVerified,
|
|
2302
|
+
client_metadata: options.clientMetadata,
|
|
2303
|
+
client_read_only_metadata: options.clientReadOnlyMetadata,
|
|
2304
|
+
server_metadata: options.serverMetadata
|
|
2277
2305
|
};
|
|
2278
2306
|
}
|
|
2279
2307
|
function adminProjectUpdateOptionsToCrud(options) {
|
|
@@ -2344,14 +2372,19 @@ function teamUpdateOptionsToCrud(options) {
|
|
|
2344
2372
|
client_metadata: options.clientMetadata
|
|
2345
2373
|
};
|
|
2346
2374
|
}
|
|
2347
|
-
function teamCreateOptionsToCrud(options) {
|
|
2375
|
+
function teamCreateOptionsToCrud(options, creatorUserId) {
|
|
2348
2376
|
return {
|
|
2349
2377
|
display_name: options.displayName,
|
|
2350
|
-
profile_image_url: options.profileImageUrl
|
|
2378
|
+
profile_image_url: options.profileImageUrl,
|
|
2379
|
+
creator_user_id: creatorUserId
|
|
2351
2380
|
};
|
|
2352
2381
|
}
|
|
2353
2382
|
function serverTeamCreateOptionsToCrud(options) {
|
|
2354
|
-
return
|
|
2383
|
+
return {
|
|
2384
|
+
display_name: options.displayName,
|
|
2385
|
+
profile_image_url: options.profileImageUrl,
|
|
2386
|
+
creator_user_id: options.creatorUserId
|
|
2387
|
+
};
|
|
2355
2388
|
}
|
|
2356
2389
|
function serverTeamUpdateOptionsToCrud(options) {
|
|
2357
2390
|
return {
|