New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@stackframe/stack-shared

Package Overview
Dependencies
Maintainers
2
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackframe/stack-shared - npm Package Compare versions

Comparing version
1.1.0
to
1.2.0
+1
-0
dist/helpers/fetch-token.d.ts
export declare const fetchTokenPrefix = "#stack-auth--if-you-see-this-you-probably-forgot-to-add-an-auth-provider----";
//# sourceMappingURL=fetch-token.d.ts.map
export declare function getPasswordError(password: string): string | null;
//# sourceMappingURL=password.d.ts.map

@@ -5,1 +5,2 @@ import { AsyncResult } from "../utils/results";

};
//# sourceMappingURL=use-async-external-store.d.ts.map

@@ -7,1 +7,2 @@ /**

export declare function useStrictMemo<T>(callback: () => T, dependencies: any[]): T;
//# sourceMappingURL=use-strict-memo.d.ts.map
+3
-2

@@ -1,4 +0,5 @@

export { StackClientInterface, UserJson as UserJson, UserCustomizableJson, ClientProjectJson, ProjectJson, OauthProviderConfigJson, getProductionModeErrors, } from "./interface/clientInterface";
export { StackClientInterface, UserJson as UserJson, UserCustomizableJson, ClientProjectJson, ProjectJson, OAuthProviderConfigJson, getProductionModeErrors, } from "./interface/clientInterface";
export { StackServerInterface, ServerUserJson, ServerUserCustomizableJson, } from "./interface/serverInterface";
export { StackAdminInterface, ApiKeySetBase, ApiKeySetBaseJson, ApiKeySetFirstView, ApiKeySetFirstViewJson, ApiKeySetSummary, ApiKeySetSummaryJson, } from "./interface/adminInterface";
export { StackAdminInterface, ApiKeySetBaseJson, ApiKeySetFirstViewJson, ApiKeySetJson, } from "./interface/adminInterface";
export { fetchTokenPrefix } from "./helpers/fetch-token";
//# sourceMappingURL=index.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,QAAQ,IAAI,QAAQ,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,QAAQ,IAAI,QAAQ,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
import { ServerAuthApplicationOptions, StackServerInterface } from "./serverInterface";
import { AsyncValueCache } from "../utils/caches";
import { ProjectJson, TokenStore } from "./clientInterface";
import { ProjectJson, ReadonlyTokenStore, SharedProvider, StandardProvider, TokenStore } from "./clientInterface";
export type AdminAuthApplicationOptions = Readonly<ServerAuthApplicationOptions & ({
superSecretAdminKey: string;
} | {
internalAdminAccessToken: string;
projectOwnerTokens: ReadonlyTokenStore;
})>;
export type ApiKeySetBase = Readonly<{
export type OAuthProviderUpdateOptions = {
id: string;
description: string;
expiresAt: Date;
manuallyRevokedAt: Date | null;
createdAt: Date;
isValid(): boolean;
whyInvalid(): "expired" | "manually-revoked" | null;
}>;
export type ApiKeySetBaseJson = Readonly<{
enabled: boolean;
} & ({
type: SharedProvider;
} | {
type: StandardProvider;
clientId: string;
clientSecret: string;
tenantId?: string;
});
export type ProjectUpdateOptions = {
isProductionMode?: boolean;
config?: {
domains?: {
domain: string;
handlerPath: string;
}[];
oauthProviders?: OAuthProviderUpdateOptions[];
credentialEnabled?: boolean;
allowLocalhost?: boolean;
};
};
export type ApiKeySetBaseJson = {
id: string;

@@ -24,14 +37,9 @@ description: string;

createdAtMillis: number;
}>;
export type ApiKeySetFirstView = Readonly<ApiKeySetBase & {
};
export type ApiKeySetFirstViewJson = ApiKeySetBaseJson & {
publishableClientKey?: string;
secretServerKey?: string;
superSecretAdminKey?: string;
}>;
export type ApiKeySetFirstViewJson = Readonly<ApiKeySetBaseJson & {
publishableClientKey?: string;
secretServerKey?: string;
superSecretAdminKey?: string;
}>;
export type ApiKeySetSummary = Readonly<ApiKeySetBase & {
};
export type ApiKeySetJson = ApiKeySetBaseJson & {
publishableClientKey: null | {

@@ -46,17 +54,12 @@ lastFour: string;

};
}>;
export type ApiKeySetSummaryJson = Readonly<ApiKeySetBaseJson & {
publishableClientKey: null | {
lastFour: string;
};
secretServerKey: null | {
lastFour: string;
};
superSecretAdminKey: null | {
lastFour: string;
};
}>;
};
export type ApiKeySetCreateOptions = {
hasPublishableClientKey: boolean;
hasSecretServerKey: boolean;
hasSuperSecretAdminKey: boolean;
expiresAt: Date;
description: string;
};
export declare class StackAdminInterface extends StackServerInterface {
readonly options: AdminAuthApplicationOptions;
readonly projectCache: AsyncValueCache<ProjectJson>;
constructor(options: AdminAuthApplicationOptions);

@@ -69,23 +72,11 @@ protected sendAdminRequest(path: string, options: RequestInit, tokenStore: TokenStore | null): Promise<Response & {

}>;
refreshProject(): Promise<void>;
getProject(): Promise<ProjectJson>;
updateProject(update: {
isProductionMode?: boolean;
config?: {
domains?: {
domain: string;
handlerPath: string;
}[];
};
getProject(options?: {
showDisabledOAuth?: boolean;
}): Promise<ProjectJson>;
createApiKeySet(options: {
hasPublishableClientKey: boolean;
hasSecretServerKey: boolean;
hasSuperSecretAdminKey: boolean;
expiresAt: Date;
description: string;
}): Promise<ApiKeySetFirstView>;
listApiKeySets(): Promise<ApiKeySetSummary[]>;
updateProject(update: ProjectUpdateOptions): Promise<ProjectJson>;
createApiKeySet(options: ApiKeySetCreateOptions): Promise<ApiKeySetFirstViewJson>;
listApiKeySets(): Promise<ApiKeySetJson[]>;
revokeApiKeySetById(id: string): Promise<void>;
getApiKeySet(id: string, tokenStore: TokenStore): Promise<ApiKeySetSummary>;
getApiKeySet(id: string, tokenStore: TokenStore): Promise<ApiKeySetJson>;
}
//# sourceMappingURL=adminInterface.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"adminInterface.d.ts","sourceRoot":"","sources":["../../src/interface/adminInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAChD,4BAA4B,GAC5B,CACI;IACA,mBAAmB,EAAE,MAAM,CAAC;CAC7B,GACC;IACA,wBAAwB,EAAE,MAAM,CAAC;CAClC,CACF,CACF,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,IAAI,CAAC;IAChB,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,IAAI,OAAO,CAAC;IACnB,UAAU,IAAI,SAAS,GAAG,kBAAkB,GAAG,IAAI,CAAC;CACrD,CAAC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,EAAE,EAAE,MAAM,CA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AE,MAAM,CAAC;KAClB,CAAC;IACF,mBAAmB,EAAE,IAAI,GAAG;QAC1B,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,SAAS,EAAE,IAAI,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,oBAAoB;aAC/B,OAAO,EAAE,2BAA2B;gBAApC,OAAO,EAAE,2BAA2B;cAIhD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;;;;;;IAc5F,UAAU,CAAC,OAAO,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAe3E,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IAejE,eAAe,CACnB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,sBAAsB,CAAC;IAe5B,cAAc,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAM1C,mBAAmB,CAAC,EAAE,EAAE,MAAM;IAe9B,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;CAI/E"}
import { StackServerInterface } from "./serverInterface";
import { AsyncValueCache } from "../utils/caches";
import { throwErr } from "../utils/errors";
export class StackAdminInterface extends StackServerInterface {
options;
projectCache;
constructor(options) {
super(options);
this.options = options;
this.projectCache = new AsyncValueCache(async () => {
return await this.getProject() ?? throwErr("Can't fetch project because it was not found");
});
}

@@ -23,10 +17,10 @@ async sendAdminRequest(path, options, tokenStore) {

}
async refreshProject() {
await Promise.all([
super.refreshProject(),
this.projectCache.refresh(),
]);
}
async getProject() {
const response = await this.sendAdminRequest("/projects/" + encodeURIComponent(this.projectId), {}, null);
async getProject(options) {
const response = await this.sendAdminRequest("/projects/" + encodeURIComponent(this.projectId), {
method: "POST",
headers: {
"content-type": "application/json",
},
body: JSON.stringify(options ?? {}),
}, null);
return await response.json();

@@ -42,3 +36,2 @@ }

}, null);
await this.refreshProject();
return await response.json();

@@ -54,3 +47,3 @@ }

}, null);
return createApiKeySetFirstViewFromJson(await response.json());
return await response.json();
}

@@ -60,3 +53,3 @@ async listApiKeySets() {

const json = await response.json();
return json.map((k) => createApiKeySetSummaryFromJson(k));
return json.map((k) => k);
}

@@ -79,36 +72,1 @@ async revokeApiKeySetById(id) {

}
function createApiKeySetBaseFromJson(data) {
return {
id: data.id,
description: data.description,
expiresAt: new Date(data.expiresAtMillis),
manuallyRevokedAt: data.manuallyRevokedAtMillis ? new Date(data.manuallyRevokedAtMillis) : null,
createdAt: new Date(data.createdAtMillis),
isValid() {
return this.whyInvalid() === null;
},
whyInvalid() {
if (this.expiresAt.getTime() < Date.now())
return "expired";
if (this.manuallyRevokedAt)
return "manually-revoked";
return null;
},
};
}
function createApiKeySetSummaryFromJson(data) {
return {
...createApiKeySetBaseFromJson(data),
publishableClientKey: data.publishableClientKey ? { lastFour: data.publishableClientKey.lastFour } : null,
secretServerKey: data.secretServerKey ? { lastFour: data.secretServerKey.lastFour } : null,
superSecretAdminKey: data.superSecretAdminKey ? { lastFour: data.superSecretAdminKey.lastFour } : null,
};
}
function createApiKeySetFirstViewFromJson(data) {
return {
...createApiKeySetBaseFromJson(data),
publishableClientKey: data.publishableClientKey,
secretServerKey: data.secretServerKey,
superSecretAdminKey: data.superSecretAdminKey,
};
}

@@ -1,5 +0,5 @@

import { ReadonlyJson, SignInErrorCode, SignUpErrorCode, EmailVerificationLinkErrorCode, PasswordResetLinkErrorCode } from "../utils/types";
import { SignInErrorCode, SignUpErrorCode, EmailVerificationLinkErrorCode, PasswordResetLinkErrorCode, KnownErrorCode } from "../utils/types";
import { Result } from "../utils/results";
import { AsyncCache, AsyncValueCache } from '../utils/caches';
import { AsyncStore } from '../utils/stores';
import { ReadonlyJson } from '../utils/json';
import { AsyncStore, ReadonlyAsyncStore } from '../utils/stores';
export type UserCustomizableJson = {

@@ -21,4 +21,6 @@ readonly projectId: string;

readonly id: string;
readonly credentialEnabled: boolean;
readonly oauthProviders: readonly {
id: string;
enabled: boolean;
}[];

@@ -32,4 +34,11 @@ };

} | {
readonly internalAdminAccessToken: string;
readonly projectOwnerTokens: ReadonlyTokenStore;
});
export type SharedProvider = "shared-github" | "shared-google" | "shared-facebook" | "shared-microsoft";
export declare const sharedProviders: readonly ["shared-github", "shared-google", "shared-facebook", "shared-microsoft"];
export type StandardProvider = "github" | "facebook" | "google" | "microsoft";
export declare const standardProviders: readonly ["github", "facebook", "google", "microsoft"];
export declare function toStandardProvider(provider: SharedProvider | StandardProvider): StandardProvider;
export declare function toSharedProvider(provider: SharedProvider | StandardProvider): SharedProvider;
export type ReadonlyTokenStore = ReadonlyAsyncStore<TokenObject>;
export type TokenStore = AsyncStore<TokenObject>;

@@ -40,3 +49,3 @@ export type TokenObject = Readonly<{

}>;
export type ProjectJson = Readonly<{
export type ProjectJson = {
id: string;

@@ -51,13 +60,15 @@ displayName: string;

allowLocalhost: boolean;
oauthProviders: OauthProviderConfigJson[];
credentialEnabled: boolean;
oauthProviders: OAuthProviderConfigJson[];
emailConfig?: EmailConfigJson;
domains: DomainConfigJson[];
};
}>;
export type OauthProviderConfigJson = {
};
export type OAuthProviderConfigJson = {
id: string;
enabled: boolean;
} & ({
type: "shared-github" | "shared-google" | "shared-facebook" | "shared-slack" | "shared-twitter" | "shared-linkedin" | "shared-microsoft";
type: SharedProvider;
} | {
type: "github" | "facebook" | "slack" | "twitter" | "linkedin" | "google" | "microsoft";
type: StandardProvider;
clientId: string;

@@ -83,6 +94,8 @@ clientSecret: string;

};
export type ProductionModeError = {
errorMessage: string;
fixUrlRelative: string;
};
export declare class StackClientInterface {
readonly options: ClientInterfaceOptions;
readonly currentUserCache: AsyncCache<TokenStore, UserJson | null>;
readonly clientProjectCache: AsyncValueCache<ClientProjectJson>;
constructor(options: ClientInterfaceOptions);

@@ -92,4 +105,2 @@ get projectId(): string;

getApiUrl(): string;
refreshUser(tokenStore: TokenStore): Promise<void>;
refreshProject(): Promise<void>;
protected refreshAccessToken(tokenStore: TokenStore): Promise<void>;

@@ -102,3 +113,3 @@ protected sendClientRequest(path: string, requestOptions: RequestInit, tokenStoreOrNull: TokenStore | null): Promise<Response & {

}>;
protected sendClientRequestAndCatchKnownError<E>(path: string, requestOptions: RequestInit, tokenStoreOrNull: TokenStore | null, errorCodes: string[]): Promise<({
protected sendClientRequestAndCatchKnownError<E extends KnownErrorCode>(path: string, requestOptions: RequestInit, tokenStoreOrNull: TokenStore | null, errorCodes: readonly E[]): Promise<({
status: "ok";

@@ -129,4 +140,4 @@ data: Response & {

signUpWithCredential(email: string, password: string, emailVerificationRedirectUrl: string, tokenStore: TokenStore): Promise<SignUpErrorCode | undefined>;
getOauthUrl(provider: string, redirectUrl: string, codeChallenge: string, state: string): Promise<string>;
callOauthCallback(oauthParams: URLSearchParams, redirectUri: string, codeVerifier: string, state: string, tokenStore: TokenStore): Promise<void>;
getOAuthUrl(provider: string, redirectUrl: string, codeChallenge: string, state: string): Promise<string>;
callOAuthCallback(oauthParams: URLSearchParams, redirectUri: string, codeVerifier: string, state: string, tokenStore: TokenStore): Promise<void>;
signOut(tokenStore: TokenStore): Promise<void>;

@@ -139,5 +150,3 @@ getClientUserByToken(tokenStore: TokenStore): Promise<Result<UserJson>>;

}
export declare function getProductionModeErrors(project: ProjectJson): {
errorMessage: string;
fixUrlRelative: string;
}[];
export declare function getProductionModeErrors(project: ProjectJson): ProductionModeError[];
//# sourceMappingURL=clientInterface.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"clientInterface.d.ts","sourceRoot":"","sources":["../../src/interface/clientInterface.ts"],"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Z,OAAO,CAAC,MAAM,CAAC;IA0BZ,iBAAiB,CACrB,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,UAAU;IAgDlB,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB9C,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAWvE,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAOtD,6BAA6B,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,UAAU,EAAE,UAAU;IAc3F,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAU5D,aAAa,CACjB,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,aAAa,CAAC,EACzD,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,WAAW,CAAC;CAmBxB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,mBAAmB,EAAE,CA0CnF"}
import * as oauth from 'oauth4webapi';
import crypto from "crypto";
import { AccessTokenExpiredErrorCode, GrantInvalidErrorCode, KnownErrorCodes, KnownError, SignUpErrorCodes, SignInErrorCodes, EmailVerificationLinkErrorCodes, PasswordResetLinkErrorCodes } from "../utils/types";
import { Result } from "../utils/results";
import { AccessTokenExpiredErrorCode, GrantInvalidErrorCode, KnownErrorCodes, KnownError, SignUpErrorCodes, SignInErrorCodes, EmailVerificationLinkErrorCodes, PasswordResetLinkErrorCodes, } from "../utils/types";
import { AsyncResult, Result } from "../utils/results";
import { parseJson } from '../utils/json';
import { AsyncCache, AsyncValueCache } from '../utils/caches';
import { typedAssign } from '../utils/objects';
import { AsyncStore } from '../utils/stores';
import { neverResolve, runAsynchronously } from '../utils/promises';
export const sharedProviders = [
"shared-github",
"shared-google",
"shared-facebook",
"shared-microsoft",
];
export const standardProviders = [
"github",
"facebook",
"google",
"microsoft",
];
export function toStandardProvider(provider) {
return provider.replace("shared-", "");
}
export function toSharedProvider(provider) {
return "shared-" + provider;
}
function getSessionCookieName(projectId) {

@@ -15,22 +31,5 @@ return "__stack-token-" + crypto.createHash("sha256").update(projectId).digest("hex");

options;
// note that we intentionally use TokenStore (a reference type) as a key, as different token stores with the same tokens should be treated differently
// (if we wouldn't do that, we would cache users across requests, which may cause caching issues)
currentUserCache;
clientProjectCache;
constructor(options) {
this.options = options;
this.currentUserCache = new AsyncCache(async (key, isFirst) => {
if (isFirst) {
key.onChange((newValue, oldValue) => {
if (JSON.stringify(newValue) === JSON.stringify(oldValue))
return;
runAsynchronously(this.currentUserCache.refresh(key));
});
}
const user = await this.getClientUserByToken(key);
return Result.or(user, null);
});
this.clientProjectCache = new AsyncValueCache(async () => {
return Result.orThrow(await this.getClientProject());
});
// nothing here
}

@@ -46,8 +45,2 @@ get projectId() {

}
async refreshUser(tokenStore) {
await this.currentUserCache.refresh(tokenStore);
}
async refreshProject() {
await this.clientProjectCache.refresh();
}
async refreshAccessToken(tokenStore) {

@@ -113,14 +106,3 @@ if (!('publishableClientKey' in this.options)) {

});
try {
return await Result.orThrowAsync(Result.retry(() => this.sendClientRequestInner(path, requestOptions, tokenStore), 5, { exponentialDelayBase: 1000 }));
}
catch (error) {
// TODO this is a hack. Occurs when the admin access token is invalid, or expired. Has plenty of weird side effects so we should replace this
if ("internalAdminAccessToken" in this.options && error?.message?.includes?.("Invalid API key") && typeof window !== "undefined") {
alert("Your session has expired. The page will now reload." + (process.env.NODE_ENV == "development" ? "\n\nThis is a hack and we should probably fix this at some point." : ""));
window.location.reload();
await neverResolve();
}
throw error;
}
return await Result.orThrowAsync(Result.retry(() => this.sendClientRequestInner(path, requestOptions, tokenStore), 5, { exponentialDelayBase: 1000 }));
}

@@ -132,3 +114,3 @@ async sendClientRequestAndCatchKnownError(path, requestOptions, tokenStoreOrNull, errorCodes) {

catch (e) {
if (e instanceof KnownError && errorCodes.includes(e.errorCode)) {
if (e instanceof KnownError && errorCodes.some(code => code === e.errorCode)) {
return Result.error(e.errorCode);

@@ -160,4 +142,4 @@ }

} : {},
...'internalAdminAccessToken' in this.options ? {
"x-stack-admin-access-token": this.options.internalAdminAccessToken,
...'projectOwnerTokens' in this.options ? {
"x-stack-admin-access-token": AsyncResult.or(this.options.projectOwnerTokens?.get(), null)?.accessToken ?? "",
} : {},

@@ -272,3 +254,2 @@ ...options.headers,

});
await this.refreshUser(tokenStore);
}

@@ -295,5 +276,4 @@ async signUpWithCredential(email, password, emailVerificationRedirectUrl, tokenStore) {

});
await this.refreshUser(tokenStore);
}
async getOauthUrl(provider, redirectUrl, codeChallenge, state) {
async getOAuthUrl(provider, redirectUrl, codeChallenge, state) {
const updatedRedirectUrl = new URL(redirectUrl);

@@ -308,3 +288,3 @@ for (const key of ["code", "state"]) {

// TODO fix
throw new Error("Admin session token is currently not supported for Oauth");
throw new Error("Admin session token is currently not supported for OAuth");
}

@@ -323,6 +303,6 @@ const url = new URL(this.getApiUrl() + "/auth/authorize/" + provider.toLowerCase());

}
async callOauthCallback(oauthParams, redirectUri, codeVerifier, state, tokenStore) {
async callOAuthCallback(oauthParams, redirectUri, codeVerifier, state, tokenStore) {
if (!('publishableClientKey' in this.options)) {
// TODO fix
throw new Error("Admin session token is currently not supported for Oauth");
throw new Error("Admin session token is currently not supported for OAuth");
}

@@ -361,3 +341,2 @@ const as = {

}));
await this.refreshUser(tokenStore);
}

@@ -380,3 +359,2 @@ async signOut(tokenStore) {

});
await this.refreshUser(tokenStore);
}

@@ -405,3 +383,2 @@ async getClientUserByToken(tokenStore) {

}, tokenStore);
await this.refreshUser(tokenStore);
}

@@ -433,5 +410,10 @@ async listProjects(tokenStore) {

const errors = [];
for (const { domain, handlerPath } of project.evaluatedConfig.domains) {
// TODO: check if handlerPath is valid
const fixUrlRelative = `/projects/${encodeURIComponent(project.id)}/auth/urls-and-callbacks`;
const fixUrlRelative = `/projects/${encodeURIComponent(project.id)}/auth/urls-and-callbacks`;
if (project.evaluatedConfig.allowLocalhost) {
errors.push({
errorMessage: "Localhost is not allowed in production mode, turn off 'Allow localhost' in project settings",
fixUrlRelative,
});
}
for (const { domain } of project.evaluatedConfig.domains) {
let url;

@@ -462,3 +444,3 @@ try {

errors.push({
errorMessage: "Auth callback prefix should be HTTPS: " + domain,
errorMessage: "Domain should be HTTPS: " + domain,
fixUrlRelative,

@@ -465,0 +447,0 @@ });

@@ -1,5 +0,4 @@

import { ClientInterfaceOptions, UserCustomizableJson, UserJson, TokenStore, StackClientInterface } from "./clientInterface";
import { ClientInterfaceOptions, UserCustomizableJson, UserJson, TokenStore, StackClientInterface, ReadonlyTokenStore } from "./clientInterface";
import { Result } from "../utils/results";
import { ReadonlyJson } from "../utils/types";
import { AsyncCache } from "../utils/caches";
import { ReadonlyJson } from "../utils/json";
export type ServerUserJson = UserJson & {

@@ -16,9 +15,7 @@ readonly serverMetadata: ReadonlyJson;

} | {
readonly internalAdminAccessToken: string;
readonly projectOwnerTokens: ReadonlyTokenStore;
}));
export declare class StackServerInterface extends StackClientInterface {
options: ServerAuthApplicationOptions;
readonly currentServerUserCache: AsyncCache<TokenStore, ServerUserJson | null>;
constructor(options: ServerAuthApplicationOptions);
refreshUser(tokenStore: TokenStore): Promise<void>;
protected sendServerRequest(path: string, options: RequestInit, tokenStore: TokenStore | null): Promise<Response & {

@@ -35,1 +32,2 @@ usedTokens: Readonly<{

}
//# sourceMappingURL=serverInterface.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"serverInterface.d.ts","sourceRoot":"","sources":["../../src/interface/serverInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,k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interface/serverInterface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG;IACtC,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;CACxC,CAAA;AAGD,MAAM,MAAM,4BAA4B,GAAG,CACvC,sBAAsB,GACtB,CACE;IACA,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC,GACC;IACA,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;CACjD,CACF,CACF,CAAC;AAGF,qBAAa,oBAAqB,SAAQ,oBAAoB;IAChC,OAAO,EAAE,4BAA4B;gBAArC,OAAO,EAAE,4BAA4B;cAIjD,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;;;;;;IAc7F,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAW7E,SAAS,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAKtC,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,0BAA0B,CAAC;IAczF,gBAAgB,CAAC,MAAM,EAAE,MAAM;CAatC"}
import { StackClientInterface, } from "./clientInterface";
import { Result } from "../utils/results";
import { AsyncCache } from "../utils/caches";
import { runAsynchronously } from "../utils/promises";
export class StackServerInterface extends StackClientInterface {
options;
// note that we intentionally use TokenStore (a reference type) as a key, as different token stores with the same tokens should be treated differently
// (if we wouldn't do that, we would cache users across requests, which may cause caching issues)
currentServerUserCache;
constructor(options) {
super(options);
this.options = options;
this.currentServerUserCache = new AsyncCache(async (key, isFirst) => {
if (isFirst) {
key.onChange((newValue, oldValue) => {
if (JSON.stringify(newValue) === JSON.stringify(oldValue))
return;
runAsynchronously(this.currentServerUserCache.refresh(key));
});
}
const user = await this.getServerUserByToken(key);
return Result.or(user, null);
});
// TODO override the client user cache to use the server user cache, so we save some requests
}
async refreshUser(tokenStore) {
await Promise.all([
super.refreshUser(tokenStore),
this.currentServerUserCache.refresh(tokenStore),
]);
}
async sendServerRequest(path, options, tokenStore) {

@@ -33,0 +10,0 @@ return await this.sendClientRequest(path, {

@@ -11,1 +11,2 @@ export declare function typedIncludes<T extends readonly any[]>(arr: T, item: unknown): item is T[number];

export declare function shuffle<T>(arr: readonly T[]): T[];
//# sourceMappingURL=arrays.d.ts.map
export declare function encodeBase32(input: Uint8Array): string;
export declare function decodeBase32(input: string): Uint8Array;
//# sourceMappingURL=bytes.d.ts.map
import { RateLimitOptions, ReactPromise } from "./promises";
import { ReadonlyAsyncStore } from "./stores";
/**

@@ -7,12 +6,15 @@ * Can be used to cache the result of a function call, for example for the `use` hook in React.

export declare function cacheFunction<F extends Function>(f: F): F;
export declare class AsyncCache<K extends object, T> {
type CacheStrategy = "write-only" | "read-write" | "never";
export declare class AsyncCache<D extends any[], T> {
private readonly _fetcher;
private readonly _rateLimitOptions;
private _map;
constructor(_fetcher: (key: K, isFirst: boolean) => Promise<T>, _rateLimitOptions?: Omit<RateLimitOptions, "batchCalls">);
private readonly _options;
private readonly _map;
constructor(_fetcher: (dependencies: D) => Promise<T>, _options?: {
onSubscribe?: (key: D, refresh: () => void) => (() => void);
rateLimiter?: Omit<RateLimitOptions, "batchCalls">;
});
private _createKeyed;
getValueCache(key: K): AsyncValueCache<T>;
isAvailable: (key: K) => boolean;
setUnavailable: (key: K) => void;
get: (key: K) => ({
getValueCache(dependencies: D): AsyncValueCache<T>;
readonly isCacheAvailable: (key: D) => boolean;
readonly getIfCached: (key: D) => ({
status: "pending";

@@ -34,21 +36,22 @@ } & {

});
getOrWait: (key: K) => ReactPromise<T>;
refresh: (key: K) => Promise<T>;
invalidate: (key: K) => Promise<T>;
onChange: (key: K, callback: (value: T, oldValue: T | undefined) => void) => {
readonly getOrWait: (key: D, cacheStrategy: CacheStrategy) => ReactPromise<T>;
readonly refresh: (key: D) => Promise<T>;
readonly invalidate: (key: D) => Promise<T>;
readonly onChange: (key: D, callback: (value: T, oldValue: T | undefined) => void) => {
unsubscribe: () => void;
};
onceChange: (key: K, callback: (value: T, oldValue: T | undefined) => void) => {
unsubscribe: () => void;
};
}
export declare class AsyncValueCache<T> implements ReadonlyAsyncStore<T> {
declare class AsyncValueCache<T> {
private readonly _options;
private _store;
private _fetcher;
private readonly _rateLimitOptions;
private _store;
private _firstFetcher;
private _laterFetcher;
constructor(fetcher: (isFirst: boolean) => Promise<T>, _rateLimitOptions?: Omit<RateLimitOptions, "batchCalls">);
isAvailable(): boolean;
setUnavailable(): void;
get(): ({
private _subscriptionsCount;
private _unsubscribers;
constructor(fetcher: () => Promise<T>, _options?: {
onSubscribe?: (refresh: () => void) => (() => void);
rateLimiter?: Omit<RateLimitOptions, "batchCalls">;
});
isCacheAvailable(): boolean;
getIfCached(): ({
status: "pending";

@@ -70,3 +73,3 @@ } & {

});
getOrWait(): ReactPromise<T>;
getOrWait(cacheStrategy: CacheStrategy): ReactPromise<T>;
private _set;

@@ -80,5 +83,4 @@ private _setAsync;

};
onceChange(callback: (value: T, oldValue: T | undefined) => void): {
unsubscribe: () => void;
};
}
export {};
//# sourceMappingURL=caches.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"caches.d.ts","sourceRoot":"","sources":["../../src/utils/caches.ts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AAQ;IAahB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC;IAIrB,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC;IAK9B,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,GAAG;QAAE,WAAW,EAAE,MAAM,IAAI,CAAA;KAAE;CA0B7F"}
import { DependenciesMap } from "./maps";
import { rateLimited } from "./promises";
import { filterUndefined } from "./objects";
import { pending, rateLimited, resolved, runAsynchronously } from "./promises";
import { AsyncStore } from "./stores";

@@ -20,7 +21,7 @@ /**

_fetcher;
_rateLimitOptions;
_map = new Map();
constructor(_fetcher, _rateLimitOptions = { concurrency: 1, gapMs: 3_000 }) {
_options;
_map = new DependenciesMap();
constructor(_fetcher, _options = {}) {
this._fetcher = _fetcher;
this._rateLimitOptions = _rateLimitOptions;
this._options = _options;
// nothing here yet

@@ -34,15 +35,15 @@ }

}
getValueCache(key) {
let cache = this._map.get(key);
getValueCache(dependencies) {
let cache = this._map.get(dependencies);
if (!cache) {
cache = new AsyncValueCache(async (isFirst) => {
return await this._fetcher(key, isFirst);
}, this._rateLimitOptions);
this._map.set(key, cache);
cache = new AsyncValueCache(async () => await this._fetcher(dependencies), {
...this._options,
onSubscribe: this._options.onSubscribe ? (cb) => this._options.onSubscribe(dependencies, cb) : undefined,
});
this._map.set(dependencies, cache);
}
return cache;
}
isAvailable = this._createKeyed("isAvailable");
setUnavailable = this._createKeyed("setUnavailable");
get = this._createKeyed("get");
isCacheAvailable = this._createKeyed("isCacheAvailable");
getIfCached = this._createKeyed("getIfCached");
getOrWait = this._createKeyed("getOrWait");

@@ -52,36 +53,35 @@ refresh = this._createKeyed("refresh");

onChange = this._createKeyed("onChange");
onceChange = this._createKeyed("onceChange");
}
export class AsyncValueCache {
class AsyncValueCache {
_options;
_store;
_fetcher;
_rateLimitOptions;
_store;
_firstFetcher;
_laterFetcher;
constructor(fetcher, _rateLimitOptions = { concurrency: 1, debounceMs: 3_000 }) {
this._rateLimitOptions = _rateLimitOptions;
_subscriptionsCount = 0;
_unsubscribers = [];
constructor(fetcher, _options = {}) {
this._options = _options;
this._store = new AsyncStore();
this._firstFetcher = async () => {
return await fetcher(true);
this._rateLimitOptions = {
concurrency: 1,
debounceMs: 300,
...filterUndefined(_options.rateLimiter ?? {}),
};
this._laterFetcher = rateLimited(async () => {
return await fetcher(false);
}, {
this._fetcher = rateLimited(fetcher, {
...this._rateLimitOptions,
batchCalls: true,
});
this._refetch(true).catch(() => {
this._store.setRejected(new Error("unavailable"));
});
}
isAvailable() {
isCacheAvailable() {
return this._store.isAvailable();
}
setUnavailable() {
this._store.setUnavailable();
}
get() {
getIfCached() {
return this._store.get();
}
getOrWait() {
return this._store.getOrWait();
getOrWait(cacheStrategy) {
const cached = this.getIfCached();
if (cacheStrategy === "read-write" && cached.status === "ok") {
return resolved(cached.data);
}
return pending(this._refetch(cacheStrategy === "read-write" ? "write-only" : cacheStrategy));
}

@@ -94,6 +94,8 @@ _set(value) {

}
async _refetch(isFirst) {
async _refetch(cacheStrategy) {
try {
const res = isFirst ? this._firstFetcher() : this._laterFetcher();
await this._setAsync(res);
const res = this._fetcher();
if (cacheStrategy === "write-only") {
await this._setAsync(res);
}
return await res;

@@ -107,14 +109,32 @@ }

async refresh() {
return await this._refetch(false);
return await this.getOrWait("write-only");
}
async invalidate() {
this.setUnavailable();
return await this._refetch(false);
this._store.setUnavailable();
return await this.refresh();
}
onChange(callback) {
return this._store.onChange(callback);
const storeObj = this._store.onChange(callback);
if (this._subscriptionsCount++ === 0 && this._options.onSubscribe) {
const unsubscribe = this._options.onSubscribe(() => {
runAsynchronously(this.refresh());
});
this._unsubscribers.push(unsubscribe);
}
runAsynchronously(this.refresh());
let hasUnsubscribed = false;
return {
unsubscribe: () => {
if (hasUnsubscribed)
return;
hasUnsubscribed = true;
storeObj.unsubscribe();
if (--this._subscriptionsCount === 0) {
for (const unsubscribe of this._unsubscribers) {
unsubscribe();
}
}
},
};
}
onceChange(callback) {
return this._store.onceChange(callback);
}
}
export declare function generateSecureRandomString(minBitsOfEntropy?: number): string;
//# sourceMappingURL=crypto.d.ts.map

@@ -13,1 +13,2 @@ export declare function fromNow(date: Date): string;

export declare function getInputDatetimeLocalString(date: Date): string;
//# sourceMappingURL=dates.d.ts.map

@@ -5,1 +5,2 @@ /**

export declare function hasClickableParent(element: HTMLElement): boolean;
//# sourceMappingURL=dom.d.ts.map

@@ -5,1 +5,2 @@ /**

export declare function getEnvVariable(name: string): string;
//# sourceMappingURL=env.d.ts.map

@@ -185,1 +185,2 @@ export declare function throwErr(errorMessage: string): never;

export {};
//# sourceMappingURL=errors.d.ts.map
export declare function escapeHtml(unsafe: string): string;
export declare function html(strings: TemplateStringsArray, ...values: any[]): string;
//# sourceMappingURL=html.d.ts.map

@@ -11,1 +11,2 @@ import { Result } from "./results";

export declare function stringifyJson(json: Json): Result<string>;
//# sourceMappingURL=json.d.ts.map
import * as jose from "jose";
export declare function encryptJWT(payload: any, expirationTime?: string): Promise<string>;
export declare function decryptJWT(jwt: string): Promise<jose.JWTPayload>;
//# sourceMappingURL=jwt.d.ts.map

@@ -21,3 +21,5 @@ export declare class MaybeWeakMap<K, V> {

has(dependencies: K): boolean;
clear(): void;
[Symbol.toStringTag]: string;
}
//# sourceMappingURL=maps.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../src/utils/maps.tsx"],"names":[],"mappings":"AAEA,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC;IAC5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAY;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;gBAEvC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAMzD,OAAO,CAAC,mBAAmB;IAI3B,GAAG,CAAC,GAAG,EAAE,CAAC,G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,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAQpB,CAAC,MAAM,CAAC,WAAW,CAAC,SAAkB;CACvC;AAWD,qBAAa,eAAe,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC;IAC7C,OAAO,CAAC,MAAM,CAA2F;IAEzG,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,WAAW;IAqBnB,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAInC,GAAG,CAAC,YAAY,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAKpC,MAAM,CAAC,YAAY,EAAE,CAAC,GAAG,OAAO;IAIhC,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,OAAO;IAI7B,KAAK,IAAI,IAAI;IAIb,CAAC,MAAM,CAAC,WAAW,CAAC,SAAqB;CAC1C"}

@@ -106,3 +106,6 @@ import { Result } from "./results";

}
clear() {
this._inner = { map: new MaybeWeakMap(), hasValue: false, value: undefined };
}
[Symbol.toStringTag] = "DependenciesMap";
}

@@ -5,1 +5,2 @@ /**

export declare function remainder(n: number, d: number): number;
//# sourceMappingURL=math.d.ts.map
export declare function prettyPrintWithMagnitudes(num: number): string;
export declare function toFixedMax(num: number, maxDecimals: number): string;
//# sourceMappingURL=numbers.d.ts.map

@@ -19,1 +19,2 @@ /**

};
//# sourceMappingURL=objects.d.ts.map
export declare function hashPassword(password: string): Promise<string>;
export declare function comparePassword(password: string, hash: string): Promise<boolean>;
//# sourceMappingURL=password.d.ts.map

@@ -16,2 +16,3 @@ import { Result } from "./results";

export declare function neverResolve(): ReactPromise<never>;
export declare function pending<T>(promise: Promise<T>): ReactPromise<T>;
export declare function wait(ms: number): Promise<void>;

@@ -51,1 +52,2 @@ export declare function waitUntil(date: Date): Promise<void>;

export {};
//# sourceMappingURL=promises.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"promises.d.ts","sourceRoot":"","sources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C,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAKlG;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAEjF;AAGD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,WAAW,EAAE,CAAC,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,OAAO,EAAE,gBAAgB,GACxB,MAAM,OAAO,CAAC,CAAC,CAAC,CAoDlB;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAe3H"}

@@ -50,3 +50,6 @@ import { Result } from "./results";

export function neverResolve() {
return Object.assign(new Promise(() => { }), {
return pending(new Promise(() => { }));
}
export function pending(promise) {
return Object.assign(promise, {
status: "pending",

@@ -53,0 +56,0 @@ });

@@ -13,1 +13,2 @@ /// <reference types="react" />

export declare function suspendIfSsr(): void;
//# sourceMappingURL=react.d.ts.map

@@ -74,1 +74,2 @@ export type Result<T, E = unknown> = {

export {};
//# sourceMappingURL=results.d.ts.map

@@ -58,1 +58,2 @@ import { AsyncResult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AE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAQ9C,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,GAAG;QAAE,WAAW,EAAE,MAAM,IAAI,CAAA;KAAE;IAU5F,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,GAAG;QAAE,WAAW,EAAE,MAAM,IAAI,CAAA;KAAE;CAO/F"}
import { AsyncResult } from "./results";
import { generateUuid } from "./uuids";
import { rejected, resolved } from "./promises";
import { pending, rejected, resolved } from "./promises";
export class AsyncStore {

@@ -56,5 +56,3 @@ _isAvailable;

});
return Object.assign(withFinally, {
status: "pending",
});
return pending(withFinally);
}

@@ -61,0 +59,0 @@ _setIfLatest(value, curCounter) {

@@ -41,1 +41,2 @@ export declare function typedToLowercase<S extends string>(s: S): Lowercase<S>;

export declare function deindent(strings: TemplateStringsArray | readonly string[], ...values: any[]): string;
//# sourceMappingURL=strings.d.ts.map
import { StatusError } from "./errors";
export type ReadonlyJson = null | boolean | number | string | readonly ReadonlyJson[] | {
readonly [key: string]: ReadonlyJson;
};
export declare const AccessTokenExpiredErrorCode = "ACCESS_TOKEN_EXPIRED";

@@ -20,12 +17,12 @@ export declare const GrantInvalidErrorCode = "GRANT_INVALID";

export declare const PasswordResetLinkUsedErrorCode = "PASSWORD_RESET_LINK_USED";
export type KnownErrorCode = typeof GrantInvalidErrorCode | typeof AccessTokenExpiredErrorCode | typeof UserAlreadyExistErrorCode | typeof UserNotExistErrorCode | typeof UserNotVerifiedErrorCode | typeof EmailPasswordMissMatchErrorCode | typeof RedirectUrlInvalidErrorCode | typeof PasswordFormatInvalidErrorCode | typeof ProjectIdOrKeyInvalidErrorCode | typeof EmailVerificationLinkInvalidErrorCode | typeof EmailVerificationLinkExpiredErrorCode | typeof EmailVerificationLinkUsedErrorCode | typeof PasswordResetLinkInvalidErrorCode | typeof PasswordResetLinkExpiredErrorCode | typeof PasswordResetLinkUsedErrorCode;
export declare const KnownErrorCodes: string[];
export type SignUpErrorCode = typeof UserAlreadyExistErrorCode;
export declare const SignUpErrorCodes: string[];
export type SignInErrorCode = typeof EmailPasswordMissMatchErrorCode | typeof UserNotExistErrorCode;
export declare const SignInErrorCodes: string[];
export type EmailVerificationLinkErrorCode = typeof EmailVerificationLinkInvalidErrorCode | typeof EmailVerificationLinkExpiredErrorCode | typeof EmailVerificationLinkUsedErrorCode;
export declare const EmailVerificationLinkErrorCodes: string[];
export type PasswordResetLinkErrorCode = typeof PasswordResetLinkInvalidErrorCode | typeof PasswordResetLinkExpiredErrorCode | typeof PasswordResetLinkUsedErrorCode;
export declare const PasswordResetLinkErrorCodes: string[];
export declare const KnownErrorCodes: readonly ["ACCESS_TOKEN_EXPIRED", "GRANT_INVALID", "USER_ALREADY_EXIST", "USER_NOT_EXIST", "USER_NOT_VERIFIED", "EMAIL_PASSWORD_MISS_MATCH", "REDIRECT_URL_INVALID", "PASSWORD_FORMAT_INVALID", "PROJECT_ID_OR_KEY_INVALID", "EMAIL_VERIFICATION_LINK_INVALID", "EMAIL_VERIFICATION_LINK_EXPIRED", "EMAIL_VERIFICATION_LINK_USED", "PASSWORD_RESET_LINK_INVALID", "PASSWORD_RESET_LINK_EXPIRED", "PASSWORD_RESET_LINK_USED"];
export type KnownErrorCode = typeof KnownErrorCodes[number];
export declare const SignUpErrorCodes: readonly ["USER_ALREADY_EXIST"];
export type SignUpErrorCode = typeof SignUpErrorCodes[number];
export declare const SignInErrorCodes: readonly ["EMAIL_PASSWORD_MISS_MATCH", "USER_NOT_EXIST"];
export type SignInErrorCode = typeof SignInErrorCodes[number];
export declare const EmailVerificationLinkErrorCodes: readonly ["EMAIL_VERIFICATION_LINK_INVALID", "EMAIL_VERIFICATION_LINK_EXPIRED", "EMAIL_VERIFICATION_LINK_USED"];
export type EmailVerificationLinkErrorCode = typeof EmailVerificationLinkErrorCodes[number];
export declare const PasswordResetLinkErrorCodes: readonly ["PASSWORD_RESET_LINK_INVALID", "PASSWORD_RESET_LINK_EXPIRED", "PASSWORD_RESET_LINK_USED"];
export type PasswordResetLinkErrorCode = typeof PasswordResetLinkErrorCodes[number];
export declare class KnownError extends StatusError {

@@ -35,1 +32,2 @@ readonly errorCode: KnownErrorCode;

}
//# sourceMappingURL=types.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,MAAM,MAAM,YAAY,GACpB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,YAAY,EAAE,GACvB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,CAAC;AAE7C,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAClE,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AACrD,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAC9D,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AACtD,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,+BAA+B,8BAA8B,CAAC;AAC3E,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAClE,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AACxE,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E,eAAO,MAAM,qCAAqC,oCAAoC,CAAC;AACvF,eAAO,MAAM,qCAAqC,oCAAoC,CAAC;AACvF,eAAO,MAAM,kCAAkC,iCAAiC,CAAC;AACjF,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAC/E,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAC/E,eAAO,MAAM,8BAA8B,6BAA6B,CAAC;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AAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,+BAA+B,8BAA8B,CAAC;AAC3E,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAClE,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AACxE,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E,eAAO,MAAM,qCAAqC,oCAAoC,CAAC;AACvF,eAAO,MAAM,qCAAqC,oCAAoC,CAAC;AACvF,eAAO,MAAM,kCAAkC,iCAAiC,CAAC;AACjF,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAC/E,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAC/E,eAAO,MAAM,8BAA8B,6BAA6B,CAAC;AAEzE,eAAO,MAAM,eAAe,8ZAgBlB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAE5D,eAAO,MAAM,gBAAgB,iCAAuC,CAAC;AACrE,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE9D,eAAO,MAAM,gBAAgB,0DAGnB,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE9D,eAAO,MAAM,+BAA+B,iHAIlC,CAAC;AACX,MAAM,MAAM,8BAA8B,GAAG,OAAO,+BAA+B,CAAC,MAAM,CAAC,CAAA;AAE3F,eAAO,MAAM,2BAA2B,qGAI9B,CAAC;AACX,MAAM,MAAM,0BAA0B,GAAG,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAA;AAEnF,qBAAa,UAAW,SAAQ,WAAW;aACb,SAAS,EAAE,cAAc;gBAAzB,SAAS,EAAE,cAAc;CAatD"}
export declare function generateUuid(): string;
//# sourceMappingURL=uuids.d.ts.map
{
"name": "@stackframe/stack-shared",
"version": "1.1.0",
"version": "1.2.0",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts",