@stackframe/stack-shared 2.2.1 → 2.3.0
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/dist/helpers/password.d.ts +0 -1
- package/dist/hooks/use-async-callback.d.ts +0 -1
- package/dist/hooks/use-async-external-store.d.ts +0 -1
- package/dist/hooks/use-strict-memo.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/interface/adminInterface.d.ts +0 -1
- package/dist/interface/clientInterface.d.ts +9 -1
- package/dist/interface/clientInterface.d.ts.map +1 -1
- package/dist/interface/clientInterface.js +39 -4
- package/dist/interface/serverInterface.d.ts +0 -1
- package/dist/known-errors.d.ts +15 -1
- package/dist/known-errors.d.ts.map +1 -1
- package/dist/known-errors.js +19 -0
- package/dist/utils/arrays.d.ts +0 -1
- package/dist/utils/bytes.d.ts +0 -1
- package/dist/utils/caches.d.ts +0 -1
- package/dist/utils/crypto.d.ts +0 -1
- package/dist/utils/dates.d.ts +0 -1
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/env.d.ts +0 -1
- package/dist/utils/errors.d.ts +0 -1
- package/dist/utils/functions.d.ts +0 -1
- package/dist/utils/html.d.ts +0 -1
- package/dist/utils/json.d.ts +0 -1
- package/dist/utils/jwt.d.ts +0 -1
- package/dist/utils/maps.d.ts +0 -1
- package/dist/utils/math.d.ts +0 -1
- package/dist/utils/numbers.d.ts +0 -1
- package/dist/utils/objects.d.ts +0 -1
- package/dist/utils/password.d.ts +0 -1
- package/dist/utils/promises.d.ts +0 -1
- package/dist/utils/react.d.ts +0 -1
- package/dist/utils/results.d.ts +0 -1
- package/dist/utils/stores.d.ts +0 -1
- package/dist/utils/strings.d.ts +0 -1
- package/dist/utils/uuids.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export declare function useAsyncCallback<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean, error: unknown | undefined];
|
|
3
3
|
export declare function useAsyncCallbackWithLoggedError<A extends any[], R>(callback: (...args: A) => Promise<R>, deps: React.DependencyList): [cb: (...args: A) => Promise<R>, loading: boolean];
|
|
4
|
-
//# sourceMappingURL=use-async-callback.d.ts.map
|
|
@@ -4,4 +4,3 @@
|
|
|
4
4
|
* The most recent value will be kept from garbage collection until one of the dependencies becomes unreachable. This may be true even after the component no longer renders. Be wary of memory leaks.
|
|
5
5
|
*/
|
|
6
6
|
export declare function useStrictMemo<T>(callback: () => T, dependencies: any[]): T;
|
|
7
|
-
//# sourceMappingURL=use-strict-memo.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ export { StackClientInterface, UserJson as UserJson, UserCustomizableJson, Clien
|
|
|
2
2
|
export { StackServerInterface, ServerUserJson, ServerUserCustomizableJson, } from "./interface/serverInterface";
|
|
3
3
|
export { StackAdminInterface, ApiKeySetBaseJson, ApiKeySetFirstViewJson, ApiKeySetJson, } from "./interface/adminInterface";
|
|
4
4
|
export { KnownError, KnownErrors, } from "./known-errors";
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -17,10 +17,14 @@ export type UserJson = UserCustomizableJson & {
|
|
|
17
17
|
readonly profileImageUrl: string | null;
|
|
18
18
|
readonly signedUpAtMillis: number;
|
|
19
19
|
readonly authMethod: "credential" | "oauth";
|
|
20
|
+
readonly hasPassword: boolean;
|
|
21
|
+
readonly authWithEmail: boolean;
|
|
22
|
+
readonly oauthProviders: readonly string[];
|
|
20
23
|
};
|
|
21
24
|
export type ClientProjectJson = {
|
|
22
25
|
readonly id: string;
|
|
23
26
|
readonly credentialEnabled: boolean;
|
|
27
|
+
readonly magicLinkEnabled: boolean;
|
|
24
28
|
readonly oauthProviders: readonly {
|
|
25
29
|
id: string;
|
|
26
30
|
enabled: boolean;
|
|
@@ -57,6 +61,7 @@ export type ProjectJson = {
|
|
|
57
61
|
id: string;
|
|
58
62
|
allowLocalhost: boolean;
|
|
59
63
|
credentialEnabled: boolean;
|
|
64
|
+
magicLinkEnabled: boolean;
|
|
60
65
|
oauthProviders: OAuthProviderConfigJson[];
|
|
61
66
|
emailConfig?: EmailConfigJson;
|
|
62
67
|
domains: DomainConfigJson[];
|
|
@@ -113,6 +118,7 @@ export declare class StackClientInterface {
|
|
|
113
118
|
private _processResponse;
|
|
114
119
|
sendForgotPasswordEmail(email: string, redirectUrl: string): Promise<KnownErrors["UserNotFound"] | undefined>;
|
|
115
120
|
sendVerificationEmail(emailVerificationRedirectUrl: string, tokenStore: TokenStore): Promise<KnownErrors["EmailAlreadyVerified"] | undefined>;
|
|
121
|
+
sendMagicLinkEmail(email: string, redirectUrl: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | undefined>;
|
|
116
122
|
resetPassword(options: {
|
|
117
123
|
code: string;
|
|
118
124
|
} & ({
|
|
@@ -128,6 +134,9 @@ export declare class StackClientInterface {
|
|
|
128
134
|
verifyEmail(code: string): Promise<KnownErrors["EmailVerificationError"] | undefined>;
|
|
129
135
|
signInWithCredential(email: string, password: string, tokenStore: TokenStore): Promise<KnownErrors["EmailPasswordMismatch"] | undefined>;
|
|
130
136
|
signUpWithCredential(email: string, password: string, emailVerificationRedirectUrl: string, tokenStore: TokenStore): Promise<KnownErrors["UserEmailAlreadyExists"] | undefined>;
|
|
137
|
+
signInWithMagicLink(code: string, tokenStore: TokenStore): Promise<KnownErrors["MagicLinkError"] | {
|
|
138
|
+
newUser: boolean;
|
|
139
|
+
}>;
|
|
131
140
|
getOAuthUrl(provider: string, redirectUrl: string, codeChallenge: string, state: string): Promise<string>;
|
|
132
141
|
callOAuthCallback(oauthParams: URLSearchParams, redirectUri: string, codeVerifier: string, state: string, tokenStore: TokenStore): Promise<oauth.OAuth2TokenEndpointResponse>;
|
|
133
142
|
signOut(tokenStore: TokenStore): Promise<void>;
|
|
@@ -138,4 +147,3 @@ export declare class StackClientInterface {
|
|
|
138
147
|
createProject(project: Pick<ProjectJson, "displayName" | "description">, tokenStore: TokenStore): Promise<ProjectJson>;
|
|
139
148
|
}
|
|
140
149
|
export declare function getProductionModeErrors(project: ProjectJson): ProductionModeError[];
|
|
141
|
-
//# sourceMappingURL=clientInterface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientInterface.d.ts","sourceRoot":"","sources":["../../src/interface/clientInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAc,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,oBAAoB,GAAG;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,YAAY,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"clientInterface.d.ts","sourceRoot":"","sources":["../../src/interface/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AoB,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"}
|
|
@@ -227,6 +227,21 @@ export class StackClientInterface {
|
|
|
227
227
|
return res.error;
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
+
async sendMagicLinkEmail(email, redirectUrl) {
|
|
231
|
+
const res = await this.sendClientRequestAndCatchKnownError("/auth/send-magic-link", {
|
|
232
|
+
method: "POST",
|
|
233
|
+
headers: {
|
|
234
|
+
"Content-Type": "application/json"
|
|
235
|
+
},
|
|
236
|
+
body: JSON.stringify({
|
|
237
|
+
email,
|
|
238
|
+
redirectUrl,
|
|
239
|
+
}),
|
|
240
|
+
}, null, [KnownErrors.RedirectUrlNotWhitelisted]);
|
|
241
|
+
if (res.status === "error") {
|
|
242
|
+
return res.error;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
230
245
|
async resetPassword(options) {
|
|
231
246
|
const res = await this.sendClientRequestAndCatchKnownError("/auth/password-reset", {
|
|
232
247
|
method: "POST",
|
|
@@ -288,8 +303,8 @@ export class StackClientInterface {
|
|
|
288
303
|
}
|
|
289
304
|
const result = await res.data.json();
|
|
290
305
|
tokenStore.set({
|
|
291
|
-
accessToken: result.
|
|
292
|
-
refreshToken: result.
|
|
306
|
+
accessToken: result.accessToken,
|
|
307
|
+
refreshToken: result.refreshToken,
|
|
293
308
|
});
|
|
294
309
|
}
|
|
295
310
|
async signUpWithCredential(email, password, emailVerificationRedirectUrl, tokenStore) {
|
|
@@ -309,9 +324,29 @@ export class StackClientInterface {
|
|
|
309
324
|
}
|
|
310
325
|
const result = await res.data.json();
|
|
311
326
|
tokenStore.set({
|
|
312
|
-
accessToken: result.
|
|
313
|
-
refreshToken: result.
|
|
327
|
+
accessToken: result.accessToken,
|
|
328
|
+
refreshToken: result.refreshToken,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
async signInWithMagicLink(code, tokenStore) {
|
|
332
|
+
const res = await this.sendClientRequestAndCatchKnownError("/auth/magic-link-verification", {
|
|
333
|
+
method: "POST",
|
|
334
|
+
headers: {
|
|
335
|
+
"Content-Type": "application/json"
|
|
336
|
+
},
|
|
337
|
+
body: JSON.stringify({
|
|
338
|
+
code,
|
|
339
|
+
}),
|
|
340
|
+
}, null, [KnownErrors.MagicLinkError]);
|
|
341
|
+
if (res.status === "error") {
|
|
342
|
+
return res.error;
|
|
343
|
+
}
|
|
344
|
+
const result = await res.data.json();
|
|
345
|
+
tokenStore.set({
|
|
346
|
+
accessToken: result.accessToken,
|
|
347
|
+
refreshToken: result.refreshToken,
|
|
314
348
|
});
|
|
349
|
+
return { newUser: result.newUser };
|
|
315
350
|
}
|
|
316
351
|
async getOAuthUrl(provider, redirectUrl, codeChallenge, state) {
|
|
317
352
|
const updatedRedirectUrl = new URL(redirectUrl);
|
|
@@ -28,4 +28,3 @@ export declare class StackServerInterface extends StackClientInterface {
|
|
|
28
28
|
setServerUserCustomizableData(userId: string, update: Partial<ServerUserCustomizableJson>): Promise<void>;
|
|
29
29
|
deleteServerUser(userId: string): Promise<void>;
|
|
30
30
|
}
|
|
31
|
-
//# sourceMappingURL=serverInterface.d.ts.map
|
package/dist/known-errors.d.ts
CHANGED
|
@@ -178,6 +178,21 @@ export declare const KnownErrors: {
|
|
|
178
178
|
EmailVerificationCodeAlreadyUsed: KnownErrorConstructor<KnownError & KnownErrorBrand<"EMAIL_VERIFICATION_ERROR"> & KnownErrorBrand<"EMAIL_VERIFICATION_CODE_ERROR"> & KnownErrorBrand<"EMAIL_VERIFICATION_CODE_ALREADY_USED">, []> & {
|
|
179
179
|
errorCode: "EMAIL_VERIFICATION_CODE_ALREADY_USED";
|
|
180
180
|
};
|
|
181
|
+
MagicLinkError: KnownErrorConstructor<KnownError & KnownErrorBrand<"MAGIC_LINK_ERROR">, [statusCode: number, humanReadableMessage: string, details?: Json | undefined]> & {
|
|
182
|
+
errorCode: "MAGIC_LINK_ERROR";
|
|
183
|
+
};
|
|
184
|
+
MagicLinkCodeError: KnownErrorConstructor<KnownError & KnownErrorBrand<"MAGIC_LINK_ERROR"> & KnownErrorBrand<"MAGIC_LINK_CODE_ERROR">, [statusCode: number, humanReadableMessage: string, details?: Json | undefined]> & {
|
|
185
|
+
errorCode: "MAGIC_LINK_CODE_ERROR";
|
|
186
|
+
};
|
|
187
|
+
MagicLinkCodeNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"MAGIC_LINK_ERROR"> & KnownErrorBrand<"MAGIC_LINK_CODE_ERROR"> & KnownErrorBrand<"MAGIC_LINK_CODE_NOT_FOUND">, []> & {
|
|
188
|
+
errorCode: "MAGIC_LINK_CODE_NOT_FOUND";
|
|
189
|
+
};
|
|
190
|
+
MagicLinkCodeExpired: KnownErrorConstructor<KnownError & KnownErrorBrand<"MAGIC_LINK_ERROR"> & KnownErrorBrand<"MAGIC_LINK_CODE_ERROR"> & KnownErrorBrand<"MAGIC_LINK_CODE_EXPIRED">, []> & {
|
|
191
|
+
errorCode: "MAGIC_LINK_CODE_EXPIRED";
|
|
192
|
+
};
|
|
193
|
+
MagicLinkCodeAlreadyUsed: KnownErrorConstructor<KnownError & KnownErrorBrand<"MAGIC_LINK_ERROR"> & KnownErrorBrand<"MAGIC_LINK_CODE_ERROR"> & KnownErrorBrand<"MAGIC_LINK_CODE_ALREADY_USED">, []> & {
|
|
194
|
+
errorCode: "MAGIC_LINK_CODE_ALREADY_USED";
|
|
195
|
+
};
|
|
181
196
|
PasswordResetError: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSWORD_RESET_ERROR">, [statusCode: number, humanReadableMessage: string, details?: Json | undefined]> & {
|
|
182
197
|
errorCode: "PASSWORD_RESET_ERROR";
|
|
183
198
|
};
|
|
@@ -201,4 +216,3 @@ export declare const KnownErrors: {
|
|
|
201
216
|
};
|
|
202
217
|
};
|
|
203
218
|
export {};
|
|
204
|
-
//# sourceMappingURL=known-errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"known-errors.d.ts","sourceRoot":"","sources":["../src/known-errors.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2B,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,6BAA6B,CAAC,IAAI,SAAS,GAAG,EAAE,IACxD,CAAC,QAAQ,MAAM,GAAG,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,GAC5C;IACA,uBAAuB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;CACzD,CAAC;AAEJ,MAAM,MAAM,qBAAqB,CAAC,QAAQ,SAAS,UAAU,EAAE,IAAI,SAAS,GAAG,EAAE,IAAI;IACnF,KAAK,GAAG,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;CACzD,CAAC;AAEF,8BAAsB,UAAW,SAAQ,WAAW;aAIhC,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errors.js
CHANGED
|
@@ -232,6 +232,20 @@ const EmailVerificationCodeAlreadyUsed = createKnownErrorConstructor(EmailVerifi
|
|
|
232
232
|
400,
|
|
233
233
|
"The e-mail verification link has already been used.",
|
|
234
234
|
], () => []);
|
|
235
|
+
const MagicLinkError = createKnownErrorConstructor(KnownError, "MAGIC_LINK_ERROR", "inherit", "inherit");
|
|
236
|
+
const MagicLinkCodeError = createKnownErrorConstructor(MagicLinkError, "MAGIC_LINK_CODE_ERROR", "inherit", "inherit");
|
|
237
|
+
const MagicLinkCodeNotFound = createKnownErrorConstructor(MagicLinkCodeError, "MAGIC_LINK_CODE_NOT_FOUND", () => [
|
|
238
|
+
404,
|
|
239
|
+
"The e-mail verification code does not exist for this project.",
|
|
240
|
+
], () => []);
|
|
241
|
+
const MagicLinkCodeExpired = createKnownErrorConstructor(MagicLinkCodeError, "MAGIC_LINK_CODE_EXPIRED", () => [
|
|
242
|
+
400,
|
|
243
|
+
"The e-mail verification code has expired.",
|
|
244
|
+
], () => []);
|
|
245
|
+
const MagicLinkCodeAlreadyUsed = createKnownErrorConstructor(MagicLinkCodeError, "MAGIC_LINK_CODE_ALREADY_USED", () => [
|
|
246
|
+
400,
|
|
247
|
+
"The e-mail verification link has already been used.",
|
|
248
|
+
], () => []);
|
|
235
249
|
const PasswordMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_MISMATCH", () => [
|
|
236
250
|
400,
|
|
237
251
|
"Passwords do not match.",
|
|
@@ -300,6 +314,11 @@ export const KnownErrors = {
|
|
|
300
314
|
EmailVerificationCodeNotFound,
|
|
301
315
|
EmailVerificationCodeExpired,
|
|
302
316
|
EmailVerificationCodeAlreadyUsed,
|
|
317
|
+
MagicLinkError,
|
|
318
|
+
MagicLinkCodeError,
|
|
319
|
+
MagicLinkCodeNotFound,
|
|
320
|
+
MagicLinkCodeExpired,
|
|
321
|
+
MagicLinkCodeAlreadyUsed,
|
|
303
322
|
PasswordResetError,
|
|
304
323
|
PasswordResetCodeError,
|
|
305
324
|
PasswordResetCodeNotFound,
|
package/dist/utils/arrays.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export declare function range(startInclusive: number, endExclusive: number, step
|
|
|
8
8
|
export declare function rotateLeft(arr: readonly any[], n: number): any[];
|
|
9
9
|
export declare function rotateRight(arr: readonly any[], n: number): any[];
|
|
10
10
|
export declare function shuffle<T>(arr: readonly T[]): T[];
|
|
11
|
-
//# sourceMappingURL=arrays.d.ts.map
|
package/dist/utils/bytes.d.ts
CHANGED
package/dist/utils/caches.d.ts
CHANGED
package/dist/utils/crypto.d.ts
CHANGED
package/dist/utils/dates.d.ts
CHANGED
|
@@ -10,4 +10,3 @@ export declare function fromNowDetailed(date: Date): {
|
|
|
10
10
|
* Returns a string representation of the given date in the format expected by the `datetime-local` input type.
|
|
11
11
|
*/
|
|
12
12
|
export declare function getInputDatetimeLocalString(date: Date): string;
|
|
13
|
-
//# sourceMappingURL=dates.d.ts.map
|
package/dist/utils/dom.d.ts
CHANGED
package/dist/utils/env.d.ts
CHANGED
package/dist/utils/errors.d.ts
CHANGED
package/dist/utils/html.d.ts
CHANGED
package/dist/utils/json.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export type ReadonlyJson = null | boolean | number | string | readonly ReadonlyJ
|
|
|
8
8
|
export declare function isJson(value: unknown): value is Json;
|
|
9
9
|
export declare function parseJson(json: string): Result<Json>;
|
|
10
10
|
export declare function stringifyJson(json: Json): Result<string>;
|
|
11
|
-
//# sourceMappingURL=json.d.ts.map
|
package/dist/utils/jwt.d.ts
CHANGED
package/dist/utils/maps.d.ts
CHANGED
package/dist/utils/math.d.ts
CHANGED
package/dist/utils/numbers.d.ts
CHANGED
package/dist/utils/objects.d.ts
CHANGED
|
@@ -21,4 +21,3 @@ export declare function filterUndefined<T extends {}>(obj: T): {
|
|
|
21
21
|
};
|
|
22
22
|
export declare function pick<T extends {}, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
23
23
|
export declare function omit<T extends {}, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
24
|
-
//# sourceMappingURL=objects.d.ts.map
|
package/dist/utils/password.d.ts
CHANGED
package/dist/utils/promises.d.ts
CHANGED
|
@@ -50,4 +50,3 @@ export type RateLimitOptions = {
|
|
|
50
50
|
export declare function rateLimited<T>(func: () => Promise<T>, options: RateLimitOptions): () => Promise<T>;
|
|
51
51
|
export declare function throttled<T, A extends any[]>(func: (...args: A) => Promise<T>, delayMs: number): (...args: A) => Promise<T>;
|
|
52
52
|
export {};
|
|
53
|
-
//# sourceMappingURL=promises.d.ts.map
|
package/dist/utils/react.d.ts
CHANGED
|
@@ -10,4 +10,3 @@ export declare function suspend(): never;
|
|
|
10
10
|
* Use this in a component or a hook to disable SSR. Should be wrapped in a Suspense boundary, or it will throw an error.
|
|
11
11
|
*/
|
|
12
12
|
export declare function suspendIfSsr(caller?: string): void;
|
|
13
|
-
//# sourceMappingURL=react.d.ts.map
|
package/dist/utils/results.d.ts
CHANGED
package/dist/utils/stores.d.ts
CHANGED
package/dist/utils/strings.d.ts
CHANGED
|
@@ -38,4 +38,3 @@ export declare function trimLines(s: string): string;
|
|
|
38
38
|
export declare function templateIdentity(strings: TemplateStringsArray | readonly string[], ...values: any[]): string;
|
|
39
39
|
export declare function deindent(code: string): string;
|
|
40
40
|
export declare function deindent(strings: TemplateStringsArray | readonly string[], ...values: any[]): string;
|
|
41
|
-
//# sourceMappingURL=strings.d.ts.map
|
package/dist/utils/uuids.d.ts
CHANGED