@stackframe/stack 2.8.32 → 2.8.35
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 +30 -0
- package/dist/components/team-switcher.js +1 -1
- package/dist/components/team-switcher.js.map +1 -1
- package/dist/esm/components/team-switcher.js +3 -3
- package/dist/esm/components/team-switcher.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/lib/auth.js +3 -2
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +25 -8
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +40 -13
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +73 -23
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/providers/stack-provider.js +1 -1
- package/dist/esm/providers/stack-provider.js.map +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/index.d.mts +92 -46
- package/dist/index.d.ts +92 -46
- package/dist/lib/auth.js +3 -2
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +25 -8
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +40 -13
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +73 -23
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/common.js.map +1 -1
- package/dist/lib/stack-app/customers/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/dist/providers/stack-provider.js +1 -1
- package/dist/providers/stack-provider.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,8 @@ import { KnownErrors } from '@stackframe/stack-shared';
|
|
|
2
2
|
import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
|
|
3
3
|
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
4
4
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
5
|
+
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
6
|
+
import * as yup from 'yup';
|
|
5
7
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
6
8
|
import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
|
|
7
9
|
import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
|
|
@@ -10,8 +12,6 @@ import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/cru
|
|
|
10
12
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
11
13
|
import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
12
14
|
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
13
|
-
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
14
|
-
import * as yup from 'yup';
|
|
15
15
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
16
16
|
import * as lucide_react from 'lucide-react';
|
|
17
17
|
import React$1 from 'react';
|
|
@@ -38,7 +38,7 @@ type RedirectMethod = "window" | "nextjs" | "none" | {
|
|
|
38
38
|
navigate?: (to: string) => void;
|
|
39
39
|
};
|
|
40
40
|
type GetUserOptions$1<HasTokenStore> = {
|
|
41
|
-
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | 'anonymous-if-exists';
|
|
41
|
+
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
|
|
42
42
|
tokenStore?: TokenStoreInit;
|
|
43
43
|
} & (HasTokenStore extends false ? {
|
|
44
44
|
tokenStore: TokenStoreInit;
|
|
@@ -77,6 +77,44 @@ type OAuthScopesOnSignIn = {
|
|
|
77
77
|
/** @internal */
|
|
78
78
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
79
79
|
|
|
80
|
+
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
81
|
+
type Item = {
|
|
82
|
+
displayName: string;
|
|
83
|
+
/**
|
|
84
|
+
* May be negative.
|
|
85
|
+
*/
|
|
86
|
+
quantity: number;
|
|
87
|
+
/**
|
|
88
|
+
* Equal to Math.max(0, quantity).
|
|
89
|
+
*/
|
|
90
|
+
nonNegativeQuantity: number;
|
|
91
|
+
};
|
|
92
|
+
type ServerItem = Item & {
|
|
93
|
+
increaseQuantity(amount: number): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Decreases the quantity by the given amount.
|
|
96
|
+
*
|
|
97
|
+
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
98
|
+
*/
|
|
99
|
+
decreaseQuantity(amount: number): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
102
|
+
*
|
|
103
|
+
* Most useful for pre-paid credits.
|
|
104
|
+
*/
|
|
105
|
+
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
106
|
+
};
|
|
107
|
+
type Customer<IsServer extends boolean = false> = {
|
|
108
|
+
readonly id: string;
|
|
109
|
+
createCheckoutUrl(options: ({
|
|
110
|
+
offerId: string;
|
|
111
|
+
} | (IsServer extends true ? {
|
|
112
|
+
offer: InlineOffer;
|
|
113
|
+
} : never))): Promise<string>;
|
|
114
|
+
} & AsyncStoreProperty<"item", [
|
|
115
|
+
itemId: string
|
|
116
|
+
], IsServer extends true ? ServerItem : Item, false>;
|
|
117
|
+
|
|
80
118
|
type AdminSentEmail = {
|
|
81
119
|
id: string;
|
|
82
120
|
to: string[];
|
|
@@ -259,40 +297,6 @@ type NotificationCategory = {
|
|
|
259
297
|
setEnabled(enabled: boolean): Promise<void>;
|
|
260
298
|
};
|
|
261
299
|
|
|
262
|
-
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
263
|
-
type Item = {
|
|
264
|
-
displayName: string;
|
|
265
|
-
/**
|
|
266
|
-
* May be negative.
|
|
267
|
-
*/
|
|
268
|
-
quantity: number;
|
|
269
|
-
/**
|
|
270
|
-
* Equal to Math.max(0, quantity).
|
|
271
|
-
*/
|
|
272
|
-
nonNegativeQuantity: number;
|
|
273
|
-
};
|
|
274
|
-
type ServerItem = Item & {
|
|
275
|
-
increaseQuantity(amount: number): Promise<void>;
|
|
276
|
-
/**
|
|
277
|
-
* Decreases the quantity by the given amount.
|
|
278
|
-
*
|
|
279
|
-
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
280
|
-
*/
|
|
281
|
-
decreaseQuantity(amount: number): Promise<void>;
|
|
282
|
-
/**
|
|
283
|
-
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
284
|
-
*
|
|
285
|
-
* Most useful for pre-paid credits.
|
|
286
|
-
*/
|
|
287
|
-
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
288
|
-
};
|
|
289
|
-
type Customer<IsServer extends boolean = false> = {
|
|
290
|
-
readonly id: string;
|
|
291
|
-
createCheckoutUrl(offerIdOrInline: string | InlineOffer): Promise<string>;
|
|
292
|
-
} & AsyncStoreProperty<"item", [
|
|
293
|
-
itemId: string
|
|
294
|
-
], IsServer extends true ? ServerItem : Item, false>;
|
|
295
|
-
|
|
296
300
|
type Session = {
|
|
297
301
|
getTokens(): Promise<{
|
|
298
302
|
accessToken: string | null;
|
|
@@ -681,6 +685,7 @@ type ServerListUsersOptions = {
|
|
|
681
685
|
orderBy?: 'signedUpAt';
|
|
682
686
|
desc?: boolean;
|
|
683
687
|
query?: string;
|
|
688
|
+
includeAnonymous?: boolean;
|
|
684
689
|
};
|
|
685
690
|
type ServerTeamCreateOptions = TeamCreateOptions & {
|
|
686
691
|
creatorUserId?: string;
|
|
@@ -747,7 +752,18 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
747
752
|
nextCursor: string | null;
|
|
748
753
|
}>;
|
|
749
754
|
sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors["RequiresCustomEmailServer"] | KnownErrors["SchemaError"] | KnownErrors["UserIdDoesNotExist"]>>;
|
|
750
|
-
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> &
|
|
755
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"item", [
|
|
756
|
+
{
|
|
757
|
+
itemId: string;
|
|
758
|
+
userId: string;
|
|
759
|
+
} | {
|
|
760
|
+
itemId: string;
|
|
761
|
+
teamId: string;
|
|
762
|
+
} | {
|
|
763
|
+
itemId: string;
|
|
764
|
+
customCustomerId: string;
|
|
765
|
+
}
|
|
766
|
+
], ServerItem, false> & StackClientApp<HasTokenStore, ProjectId>);
|
|
751
767
|
declare const StackServerApp: StackServerAppConstructor;
|
|
752
768
|
|
|
753
769
|
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
@@ -772,7 +788,12 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
772
788
|
displayName: string;
|
|
773
789
|
themeId?: string;
|
|
774
790
|
tsxSource: string;
|
|
775
|
-
}[], true> & {
|
|
791
|
+
}[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
|
|
792
|
+
account_id: string;
|
|
793
|
+
charges_enabled: boolean;
|
|
794
|
+
details_submitted: boolean;
|
|
795
|
+
payouts_enabled: boolean;
|
|
796
|
+
} | null, false> & {
|
|
776
797
|
useEmailTemplates(): {
|
|
777
798
|
id: string;
|
|
778
799
|
displayName: string;
|
|
@@ -829,16 +850,29 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
829
850
|
createStripeWidgetAccountSession(): Promise<{
|
|
830
851
|
client_secret: string;
|
|
831
852
|
}>;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
offerId: string;
|
|
835
|
-
}): Promise<string>;
|
|
836
|
-
createItemQuantityChange(options: {
|
|
837
|
-
customerId: string;
|
|
853
|
+
createItemQuantityChange(options: ({
|
|
854
|
+
userId: string;
|
|
838
855
|
itemId: string;
|
|
839
856
|
quantity: number;
|
|
840
857
|
expiresAt?: string;
|
|
841
858
|
description?: string;
|
|
859
|
+
} | {
|
|
860
|
+
teamId: string;
|
|
861
|
+
itemId: string;
|
|
862
|
+
quantity: number;
|
|
863
|
+
expiresAt?: string;
|
|
864
|
+
description?: string;
|
|
865
|
+
} | {
|
|
866
|
+
customCustomerId: string;
|
|
867
|
+
itemId: string;
|
|
868
|
+
quantity: number;
|
|
869
|
+
expiresAt?: string;
|
|
870
|
+
description?: string;
|
|
871
|
+
})): Promise<void>;
|
|
872
|
+
testModePurchase(options: {
|
|
873
|
+
priceId: string;
|
|
874
|
+
fullCode: string;
|
|
875
|
+
quantity?: number;
|
|
842
876
|
}): Promise<void>;
|
|
843
877
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
844
878
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
@@ -950,6 +984,7 @@ type AdminProject = {
|
|
|
950
984
|
readonly config: AdminProjectConfig;
|
|
951
985
|
update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
|
|
952
986
|
delete(this: AdminProject): Promise<void>;
|
|
987
|
+
transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
|
|
953
988
|
getConfig(this: AdminProject): Promise<CompleteConfig>;
|
|
954
989
|
useConfig(this: AdminProject): CompleteConfig;
|
|
955
990
|
updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
|
|
@@ -1073,7 +1108,18 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1073
1108
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
1074
1109
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
1075
1110
|
};
|
|
1076
|
-
} & AsyncStoreProperty<"project", [], Project, false> &
|
|
1111
|
+
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1112
|
+
{
|
|
1113
|
+
itemId: string;
|
|
1114
|
+
userId: string;
|
|
1115
|
+
} | {
|
|
1116
|
+
itemId: string;
|
|
1117
|
+
teamId: string;
|
|
1118
|
+
} | {
|
|
1119
|
+
itemId: string;
|
|
1120
|
+
customCustomerId: string;
|
|
1121
|
+
}
|
|
1122
|
+
], Item, false> & {
|
|
1077
1123
|
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
|
|
1078
1124
|
});
|
|
1079
1125
|
declare const StackClientApp: StackClientAppConstructor;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { KnownErrors } from '@stackframe/stack-shared';
|
|
|
2
2
|
import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
|
|
3
3
|
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
4
4
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
5
|
+
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
6
|
+
import * as yup from 'yup';
|
|
5
7
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
6
8
|
import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
|
|
7
9
|
import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
|
|
@@ -10,8 +12,6 @@ import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/cru
|
|
|
10
12
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
11
13
|
import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
12
14
|
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
13
|
-
import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
14
|
-
import * as yup from 'yup';
|
|
15
15
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
16
16
|
import * as lucide_react from 'lucide-react';
|
|
17
17
|
import React$1 from 'react';
|
|
@@ -38,7 +38,7 @@ type RedirectMethod = "window" | "nextjs" | "none" | {
|
|
|
38
38
|
navigate?: (to: string) => void;
|
|
39
39
|
};
|
|
40
40
|
type GetUserOptions$1<HasTokenStore> = {
|
|
41
|
-
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | 'anonymous-if-exists';
|
|
41
|
+
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
|
|
42
42
|
tokenStore?: TokenStoreInit;
|
|
43
43
|
} & (HasTokenStore extends false ? {
|
|
44
44
|
tokenStore: TokenStoreInit;
|
|
@@ -77,6 +77,44 @@ type OAuthScopesOnSignIn = {
|
|
|
77
77
|
/** @internal */
|
|
78
78
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
79
79
|
|
|
80
|
+
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
81
|
+
type Item = {
|
|
82
|
+
displayName: string;
|
|
83
|
+
/**
|
|
84
|
+
* May be negative.
|
|
85
|
+
*/
|
|
86
|
+
quantity: number;
|
|
87
|
+
/**
|
|
88
|
+
* Equal to Math.max(0, quantity).
|
|
89
|
+
*/
|
|
90
|
+
nonNegativeQuantity: number;
|
|
91
|
+
};
|
|
92
|
+
type ServerItem = Item & {
|
|
93
|
+
increaseQuantity(amount: number): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Decreases the quantity by the given amount.
|
|
96
|
+
*
|
|
97
|
+
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
98
|
+
*/
|
|
99
|
+
decreaseQuantity(amount: number): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
102
|
+
*
|
|
103
|
+
* Most useful for pre-paid credits.
|
|
104
|
+
*/
|
|
105
|
+
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
106
|
+
};
|
|
107
|
+
type Customer<IsServer extends boolean = false> = {
|
|
108
|
+
readonly id: string;
|
|
109
|
+
createCheckoutUrl(options: ({
|
|
110
|
+
offerId: string;
|
|
111
|
+
} | (IsServer extends true ? {
|
|
112
|
+
offer: InlineOffer;
|
|
113
|
+
} : never))): Promise<string>;
|
|
114
|
+
} & AsyncStoreProperty<"item", [
|
|
115
|
+
itemId: string
|
|
116
|
+
], IsServer extends true ? ServerItem : Item, false>;
|
|
117
|
+
|
|
80
118
|
type AdminSentEmail = {
|
|
81
119
|
id: string;
|
|
82
120
|
to: string[];
|
|
@@ -259,40 +297,6 @@ type NotificationCategory = {
|
|
|
259
297
|
setEnabled(enabled: boolean): Promise<void>;
|
|
260
298
|
};
|
|
261
299
|
|
|
262
|
-
type InlineOffer = yup.InferType<typeof inlineOfferSchema>;
|
|
263
|
-
type Item = {
|
|
264
|
-
displayName: string;
|
|
265
|
-
/**
|
|
266
|
-
* May be negative.
|
|
267
|
-
*/
|
|
268
|
-
quantity: number;
|
|
269
|
-
/**
|
|
270
|
-
* Equal to Math.max(0, quantity).
|
|
271
|
-
*/
|
|
272
|
-
nonNegativeQuantity: number;
|
|
273
|
-
};
|
|
274
|
-
type ServerItem = Item & {
|
|
275
|
-
increaseQuantity(amount: number): Promise<void>;
|
|
276
|
-
/**
|
|
277
|
-
* Decreases the quantity by the given amount.
|
|
278
|
-
*
|
|
279
|
-
* Note that you may want to use tryDecreaseQuantity instead, as it will prevent the quantity from going below 0 in a race-condition-free way.
|
|
280
|
-
*/
|
|
281
|
-
decreaseQuantity(amount: number): Promise<void>;
|
|
282
|
-
/**
|
|
283
|
-
* Decreases the quantity by the given amount and returns true if the result is non-negative; returns false and does nothing if the result would be negative.
|
|
284
|
-
*
|
|
285
|
-
* Most useful for pre-paid credits.
|
|
286
|
-
*/
|
|
287
|
-
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
288
|
-
};
|
|
289
|
-
type Customer<IsServer extends boolean = false> = {
|
|
290
|
-
readonly id: string;
|
|
291
|
-
createCheckoutUrl(offerIdOrInline: string | InlineOffer): Promise<string>;
|
|
292
|
-
} & AsyncStoreProperty<"item", [
|
|
293
|
-
itemId: string
|
|
294
|
-
], IsServer extends true ? ServerItem : Item, false>;
|
|
295
|
-
|
|
296
300
|
type Session = {
|
|
297
301
|
getTokens(): Promise<{
|
|
298
302
|
accessToken: string | null;
|
|
@@ -681,6 +685,7 @@ type ServerListUsersOptions = {
|
|
|
681
685
|
orderBy?: 'signedUpAt';
|
|
682
686
|
desc?: boolean;
|
|
683
687
|
query?: string;
|
|
688
|
+
includeAnonymous?: boolean;
|
|
684
689
|
};
|
|
685
690
|
type ServerTeamCreateOptions = TeamCreateOptions & {
|
|
686
691
|
creatorUserId?: string;
|
|
@@ -747,7 +752,18 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
747
752
|
nextCursor: string | null;
|
|
748
753
|
}>;
|
|
749
754
|
sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors["RequiresCustomEmailServer"] | KnownErrors["SchemaError"] | KnownErrors["UserIdDoesNotExist"]>>;
|
|
750
|
-
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> &
|
|
755
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"item", [
|
|
756
|
+
{
|
|
757
|
+
itemId: string;
|
|
758
|
+
userId: string;
|
|
759
|
+
} | {
|
|
760
|
+
itemId: string;
|
|
761
|
+
teamId: string;
|
|
762
|
+
} | {
|
|
763
|
+
itemId: string;
|
|
764
|
+
customCustomerId: string;
|
|
765
|
+
}
|
|
766
|
+
], ServerItem, false> & StackClientApp<HasTokenStore, ProjectId>);
|
|
751
767
|
declare const StackServerApp: StackServerAppConstructor;
|
|
752
768
|
|
|
753
769
|
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
@@ -772,7 +788,12 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
772
788
|
displayName: string;
|
|
773
789
|
themeId?: string;
|
|
774
790
|
tsxSource: string;
|
|
775
|
-
}[], true> & {
|
|
791
|
+
}[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
|
|
792
|
+
account_id: string;
|
|
793
|
+
charges_enabled: boolean;
|
|
794
|
+
details_submitted: boolean;
|
|
795
|
+
payouts_enabled: boolean;
|
|
796
|
+
} | null, false> & {
|
|
776
797
|
useEmailTemplates(): {
|
|
777
798
|
id: string;
|
|
778
799
|
displayName: string;
|
|
@@ -829,16 +850,29 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
829
850
|
createStripeWidgetAccountSession(): Promise<{
|
|
830
851
|
client_secret: string;
|
|
831
852
|
}>;
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
offerId: string;
|
|
835
|
-
}): Promise<string>;
|
|
836
|
-
createItemQuantityChange(options: {
|
|
837
|
-
customerId: string;
|
|
853
|
+
createItemQuantityChange(options: ({
|
|
854
|
+
userId: string;
|
|
838
855
|
itemId: string;
|
|
839
856
|
quantity: number;
|
|
840
857
|
expiresAt?: string;
|
|
841
858
|
description?: string;
|
|
859
|
+
} | {
|
|
860
|
+
teamId: string;
|
|
861
|
+
itemId: string;
|
|
862
|
+
quantity: number;
|
|
863
|
+
expiresAt?: string;
|
|
864
|
+
description?: string;
|
|
865
|
+
} | {
|
|
866
|
+
customCustomerId: string;
|
|
867
|
+
itemId: string;
|
|
868
|
+
quantity: number;
|
|
869
|
+
expiresAt?: string;
|
|
870
|
+
description?: string;
|
|
871
|
+
})): Promise<void>;
|
|
872
|
+
testModePurchase(options: {
|
|
873
|
+
priceId: string;
|
|
874
|
+
fullCode: string;
|
|
875
|
+
quantity?: number;
|
|
842
876
|
}): Promise<void>;
|
|
843
877
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
844
878
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
@@ -950,6 +984,7 @@ type AdminProject = {
|
|
|
950
984
|
readonly config: AdminProjectConfig;
|
|
951
985
|
update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
|
|
952
986
|
delete(this: AdminProject): Promise<void>;
|
|
987
|
+
transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
|
|
953
988
|
getConfig(this: AdminProject): Promise<CompleteConfig>;
|
|
954
989
|
useConfig(this: AdminProject): CompleteConfig;
|
|
955
990
|
updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
|
|
@@ -1073,7 +1108,18 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1073
1108
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
1074
1109
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
1075
1110
|
};
|
|
1076
|
-
} & AsyncStoreProperty<"project", [], Project, false> &
|
|
1111
|
+
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1112
|
+
{
|
|
1113
|
+
itemId: string;
|
|
1114
|
+
userId: string;
|
|
1115
|
+
} | {
|
|
1116
|
+
itemId: string;
|
|
1117
|
+
teamId: string;
|
|
1118
|
+
} | {
|
|
1119
|
+
itemId: string;
|
|
1120
|
+
customCustomerId: string;
|
|
1121
|
+
}
|
|
1122
|
+
], Item, false> & {
|
|
1077
1123
|
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
|
|
1078
1124
|
});
|
|
1079
1125
|
declare const StackClientApp: StackClientAppConstructor;
|
package/dist/lib/auth.js
CHANGED
|
@@ -32,7 +32,7 @@ var import_results = require("@stackframe/stack-shared/dist/utils/results");
|
|
|
32
32
|
var import_strings = require("@stackframe/stack-shared/dist/utils/strings");
|
|
33
33
|
var import_url = require("../utils/url.js");
|
|
34
34
|
var import_cookie = require("./cookie.js");
|
|
35
|
-
async function signInWithOAuth(iface, options) {
|
|
35
|
+
async function signInWithOAuth(iface, options, session) {
|
|
36
36
|
const { codeChallenge, state } = await (0, import_cookie.saveVerifierAndState)();
|
|
37
37
|
const location = await iface.getOAuthUrl({
|
|
38
38
|
provider: options.provider,
|
|
@@ -41,7 +41,8 @@ async function signInWithOAuth(iface, options) {
|
|
|
41
41
|
codeChallenge,
|
|
42
42
|
state,
|
|
43
43
|
type: "authenticate",
|
|
44
|
-
providerScope: options.providerScope
|
|
44
|
+
providerScope: options.providerScope,
|
|
45
|
+
session
|
|
45
46
|
});
|
|
46
47
|
window.location.assign(location);
|
|
47
48
|
await (0, import_promises.neverResolve)();
|
package/dist/lib/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownError, StackClientInterface } from \"@stackframe/stack-shared\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { neverResolve } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { consumeVerifierAndStateCookie, saveVerifierAndState } from \"./cookie\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n }
|
|
1
|
+
{"version":3,"sources":["../../src/lib/auth.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownError, StackClientInterface } from \"@stackframe/stack-shared\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { neverResolve } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport { constructRedirectUrl } from \"../utils/url\";\nimport { consumeVerifierAndStateCookie, saveVerifierAndState } from \"./cookie\";\n\nexport async function signInWithOAuth(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n },\n session: InternalSession,\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl, \"redirectUrl\"),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl, \"errorRedirectUrl\"),\n codeChallenge,\n state,\n type: \"authenticate\",\n providerScope: options.providerScope,\n session,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\nexport async function addNewOAuthProviderOrScope(\n iface: StackClientInterface,\n options: {\n provider: string,\n redirectUrl: string,\n errorRedirectUrl: string,\n providerScope?: string,\n },\n session: InternalSession,\n) {\n const { codeChallenge, state } = await saveVerifierAndState();\n const location = await iface.getOAuthUrl({\n provider: options.provider,\n redirectUrl: constructRedirectUrl(options.redirectUrl, \"redirectUrl\"),\n errorRedirectUrl: constructRedirectUrl(options.errorRedirectUrl, \"errorRedirectUrl\"),\n afterCallbackRedirectUrl: constructRedirectUrl(window.location.href, \"afterCallbackRedirectUrl\"),\n codeChallenge,\n state,\n type: \"link\",\n session,\n providerScope: options.providerScope,\n });\n window.location.assign(location);\n await neverResolve();\n}\n\n/**\n * Checks if the current URL has the query parameters for an OAuth callback, and if so, removes them.\n *\n * Must be synchronous for the logic in callOAuthCallback to work without race conditions.\n */\nfunction consumeOAuthCallbackQueryParams() {\n const requiredParams = [\"code\", \"state\"];\n const originalUrl = new URL(window.location.href);\n for (const param of requiredParams) {\n if (!originalUrl.searchParams.has(param)) {\n console.warn(new Error(`Missing required query parameter on OAuth callback: ${param}. Maybe you opened or reloaded the oauth-callback page from your history?`));\n return null;\n }\n }\n\n const expectedState = originalUrl.searchParams.get(\"state\") ?? throwErr(\"This should never happen; isn't state required above?\");\n const cookieResult = consumeVerifierAndStateCookie(expectedState);\n\n if (!cookieResult) {\n // If the state can't be found in the cookies, then the callback wasn't meant for us.\n // Maybe the website uses another OAuth library?\n console.warn(deindent`\n Stack found an outer OAuth callback state in the query parameters, but not in cookies.\n \n This could have multiple reasons:\n - The cookie expired, because the OAuth flow took too long.\n - The user's browser deleted the cookie, either manually or because of a very strict cookie policy.\n - The cookie was already consumed by this page, and the user already logged in.\n - You are using another OAuth client library with the same callback URL as Stack.\n - The user opened the OAuth callback page from their history.\n\n Either way, it is probably safe to ignore this warning unless you are debugging an OAuth issue.\n `);\n return null;\n }\n\n\n const newUrl = new URL(originalUrl);\n for (const param of requiredParams) {\n newUrl.searchParams.delete(param);\n }\n\n // let's get rid of the authorization code in the history as we\n // don't redirect to `redirectUrl` if there's a validation error\n // (as the redirectUrl might be malicious!).\n //\n // We use history.replaceState instead of location.assign(...) to\n // prevent an unnecessary reload\n window.history.replaceState({}, \"\", newUrl.toString());\n\n return {\n originalUrl,\n codeVerifier: cookieResult.codeVerifier,\n state: expectedState,\n };\n}\n\nexport async function callOAuthCallback(\n iface: StackClientInterface,\n redirectUrl: string,\n) {\n // note: this part of the function (until the return) needs\n // to be synchronous, to prevent race conditions when\n // callOAuthCallback is called multiple times in parallel\n const consumed = consumeOAuthCallbackQueryParams();\n if (!consumed) return Result.ok(undefined);\n\n // the rest can be asynchronous (we now know that we are the\n // intended recipient of the callback, and the only instance\n // of callOAuthCallback that's running)\n try {\n return Result.ok(await iface.callOAuthCallback({\n oauthParams: consumed.originalUrl.searchParams,\n redirectUri: constructRedirectUrl(redirectUrl, \"redirectUri\"),\n codeVerifier: consumed.codeVerifier,\n state: consumed.state,\n }));\n } catch (e) {\n if (KnownError.isKnownError(e)) {\n throw e;\n }\n throw new StackAssertionError(\"Error signing in during OAuth callback. Please try again.\", { cause: e });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAiD;AAEjD,oBAA8C;AAC9C,sBAA6B;AAC7B,qBAAuB;AACvB,qBAAyB;AACzB,iBAAqC;AACrC,oBAAoE;AAEpE,eAAsB,gBACpB,OACA,SAMA,SACA;AACA,QAAM,EAAE,eAAe,MAAM,IAAI,UAAM,oCAAqB;AAC5D,QAAM,WAAW,MAAM,MAAM,YAAY;AAAA,IACvC,UAAU,QAAQ;AAAA,IAClB,iBAAa,iCAAqB,QAAQ,aAAa,aAAa;AAAA,IACpE,sBAAkB,iCAAqB,QAAQ,kBAAkB,kBAAkB;AAAA,IACnF;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,eAAe,QAAQ;AAAA,IACvB;AAAA,EACF,CAAC;AACD,SAAO,SAAS,OAAO,QAAQ;AAC/B,YAAM,8BAAa;AACrB;AAEA,eAAsB,2BACpB,OACA,SAMA,SACA;AACA,QAAM,EAAE,eAAe,MAAM,IAAI,UAAM,oCAAqB;AAC5D,QAAM,WAAW,MAAM,MAAM,YAAY;AAAA,IACvC,UAAU,QAAQ;AAAA,IAClB,iBAAa,iCAAqB,QAAQ,aAAa,aAAa;AAAA,IACpE,sBAAkB,iCAAqB,QAAQ,kBAAkB,kBAAkB;AAAA,IACnF,8BAA0B,iCAAqB,OAAO,SAAS,MAAM,0BAA0B;AAAA,IAC/F;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA,eAAe,QAAQ;AAAA,EACzB,CAAC;AACD,SAAO,SAAS,OAAO,QAAQ;AAC/B,YAAM,8BAAa;AACrB;AAOA,SAAS,kCAAkC;AACzC,QAAM,iBAAiB,CAAC,QAAQ,OAAO;AACvC,QAAM,cAAc,IAAI,IAAI,OAAO,SAAS,IAAI;AAChD,aAAW,SAAS,gBAAgB;AAClC,QAAI,CAAC,YAAY,aAAa,IAAI,KAAK,GAAG;AACxC,cAAQ,KAAK,IAAI,MAAM,uDAAuD,KAAK,2EAA2E,CAAC;AAC/J,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,gBAAgB,YAAY,aAAa,IAAI,OAAO,SAAK,wBAAS,uDAAuD;AAC/H,QAAM,mBAAe,6CAA8B,aAAa;AAEhE,MAAI,CAAC,cAAc;AAGjB,YAAQ,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAWZ;AACD,WAAO;AAAA,EACT;AAGA,QAAM,SAAS,IAAI,IAAI,WAAW;AAClC,aAAW,SAAS,gBAAgB;AAClC,WAAO,aAAa,OAAO,KAAK;AAAA,EAClC;AAQA,SAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,OAAO,SAAS,CAAC;AAErD,SAAO;AAAA,IACL;AAAA,IACA,cAAc,aAAa;AAAA,IAC3B,OAAO;AAAA,EACT;AACF;AAEA,eAAsB,kBACpB,OACA,aACA;AAIA,QAAM,WAAW,gCAAgC;AACjD,MAAI,CAAC,SAAU,QAAO,sBAAO,GAAG,MAAS;AAKzC,MAAI;AACF,WAAO,sBAAO,GAAG,MAAM,MAAM,kBAAkB;AAAA,MAC7C,aAAa,SAAS,YAAY;AAAA,MAClC,iBAAa,iCAAqB,aAAa,aAAa;AAAA,MAC5D,cAAc,SAAS;AAAA,MACvB,OAAO,SAAS;AAAA,IAClB,CAAC,CAAC;AAAA,EACJ,SAAS,GAAG;AACV,QAAI,+BAAW,aAAa,CAAC,GAAG;AAC9B,YAAM;AAAA,IACR;AACA,UAAM,IAAI,kCAAoB,6DAA6D,EAAE,OAAO,EAAE,CAAC;AAAA,EACzG;AACF;","names":[]}
|
|
@@ -94,6 +94,16 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
94
94
|
this._configOverridesCache = (0, import_common2.createCache)(async () => {
|
|
95
95
|
return await this._interface.getConfig();
|
|
96
96
|
});
|
|
97
|
+
this._stripeAccountInfoCache = (0, import_common2.createCache)(async () => {
|
|
98
|
+
try {
|
|
99
|
+
return await this._interface.getStripeAccountInfo();
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error?.status === 404) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
97
107
|
}
|
|
98
108
|
_adminConfigFromCrud(data) {
|
|
99
109
|
return JSON.parse(data.config_string);
|
|
@@ -183,6 +193,10 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
183
193
|
async delete() {
|
|
184
194
|
await app._interface.deleteProject();
|
|
185
195
|
},
|
|
196
|
+
async transfer(user, newTeamId) {
|
|
197
|
+
await app._interface.transferProject(user._internalSession, newTeamId);
|
|
198
|
+
await onRefresh();
|
|
199
|
+
},
|
|
186
200
|
async getProductionModeErrors() {
|
|
187
201
|
return (0, import_production_mode.getProductionModeErrors)(data);
|
|
188
202
|
},
|
|
@@ -445,16 +459,9 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
445
459
|
async createStripeWidgetAccountSession() {
|
|
446
460
|
return await this._interface.createStripeWidgetAccountSession();
|
|
447
461
|
}
|
|
448
|
-
async createPurchaseUrl(options) {
|
|
449
|
-
return await this._interface.createPurchaseUrl({
|
|
450
|
-
customer_id: options.customerId,
|
|
451
|
-
offer_id: options.offerId
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
462
|
async createItemQuantityChange(options) {
|
|
455
463
|
await this._interface.updateItemQuantity(
|
|
456
|
-
options.
|
|
457
|
-
options.itemId,
|
|
464
|
+
{ itemId: options.itemId, ..."userId" in options ? { userId: options.userId } : "teamId" in options ? { teamId: options.teamId } : { customCustomerId: options.customCustomerId } },
|
|
458
465
|
{
|
|
459
466
|
delta: options.quantity,
|
|
460
467
|
expires_at: options.expiresAt,
|
|
@@ -462,6 +469,16 @@ var _StackAdminAppImplIncomplete = class extends import_server_app_impl._StackSe
|
|
|
462
469
|
}
|
|
463
470
|
);
|
|
464
471
|
}
|
|
472
|
+
async testModePurchase(options) {
|
|
473
|
+
await this._interface.testModePurchase({ price_id: options.priceId, full_code: options.fullCode, quantity: options.quantity });
|
|
474
|
+
}
|
|
475
|
+
async getStripeAccountInfo() {
|
|
476
|
+
return await this._interface.getStripeAccountInfo();
|
|
477
|
+
}
|
|
478
|
+
useStripeAccountInfo() {
|
|
479
|
+
const data = (0, import_common3.useAsyncCache)(this._stripeAccountInfoCache, [], "useStripeAccountInfo()");
|
|
480
|
+
return data;
|
|
481
|
+
}
|
|
465
482
|
};
|
|
466
483
|
// Annotate the CommonJS export names for ESM import in node:
|
|
467
484
|
0 && (module.exports = {
|