@appwarden/middleware 1.5.0 → 1.5.1
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/README.md +1 -1
- package/{cloudflare-2PkEr25r.d.ts → cloudflare-0sboFQGC.d.ts} +1 -0
- package/cloudflare.d.ts +6 -3
- package/cloudflare.js +7 -3
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/{use-content-security-policy-Cgy0nz3J.d.ts → use-content-security-policy-D4ccKJVd.d.ts} +1 -1
- package/vercel.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @appwarden/middleware
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
[](https://www.npmjs.com/package/@appwarden/middleware)
|
|
5
5
|
[](https://docs.npmjs.com/generating-provenance-statements)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
package/cloudflare.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as Bindings } from './cloudflare-
|
|
1
|
+
import { B as Bindings } from './cloudflare-0sboFQGC.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { M as Middleware } from './use-content-security-policy-
|
|
4
|
-
export { u as useContentSecurityPolicy } from './use-content-security-policy-
|
|
3
|
+
import { M as Middleware } from './use-content-security-policy-D4ccKJVd.js';
|
|
4
|
+
export { u as useContentSecurityPolicy } from './use-content-security-policy-D4ccKJVd.js';
|
|
5
5
|
|
|
6
6
|
declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<{
|
|
7
7
|
env: CloudflareEnv;
|
|
@@ -22,6 +22,7 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<{
|
|
|
22
22
|
lockPageSlug: string;
|
|
23
23
|
}>>>;
|
|
24
24
|
appwardenApiToken: z.ZodEffects<z.ZodString, string, string>;
|
|
25
|
+
appwardenApiHostname: z.ZodOptional<z.ZodString>;
|
|
25
26
|
} & {
|
|
26
27
|
middleware: z.ZodDefault<z.ZodObject<{
|
|
27
28
|
before: z.ZodDefault<z.ZodArray<z.ZodType<Middleware, z.ZodTypeDef, Middleware>, "many">>;
|
|
@@ -40,6 +41,7 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<{
|
|
|
40
41
|
multidomainConfig?: Record<string, {
|
|
41
42
|
lockPageSlug: string;
|
|
42
43
|
}> | undefined;
|
|
44
|
+
appwardenApiHostname?: string | undefined;
|
|
43
45
|
}, {
|
|
44
46
|
appwardenApiToken: string;
|
|
45
47
|
lockPageSlug?: string | undefined;
|
|
@@ -47,6 +49,7 @@ declare const ConfigFnInputSchema: z.ZodFunction<z.ZodTuple<[z.ZodType<{
|
|
|
47
49
|
multidomainConfig?: Record<string, {
|
|
48
50
|
lockPageSlug: string;
|
|
49
51
|
}> | undefined;
|
|
52
|
+
appwardenApiHostname?: string | undefined;
|
|
50
53
|
middleware?: {
|
|
51
54
|
before?: Middleware[] | undefined;
|
|
52
55
|
} | undefined;
|
package/cloudflare.js
CHANGED
|
@@ -33,12 +33,13 @@ var UseAppwardenInputSchema = z.object({
|
|
|
33
33
|
debug: BooleanSchema.default(false),
|
|
34
34
|
lockPageSlug: z.string().optional(),
|
|
35
35
|
multidomainConfig: AppwardenMultidomainConfigSchema.optional(),
|
|
36
|
-
appwardenApiToken: z.string().refine((val) => !!val, { path: ["appwardenApiToken"] })
|
|
36
|
+
appwardenApiToken: z.string().refine((val) => !!val, { path: ["appwardenApiToken"] }),
|
|
37
|
+
appwardenApiHostname: z.string().optional()
|
|
37
38
|
});
|
|
38
39
|
var lockPageSlugRefinement = (schema) => schema.refine(
|
|
39
40
|
(data) => data.lockPageSlug || data.multidomainConfig,
|
|
40
41
|
{
|
|
41
|
-
message: "
|
|
42
|
+
message: "lockPageSlug must be provided"
|
|
42
43
|
}
|
|
43
44
|
);
|
|
44
45
|
|
|
@@ -213,10 +214,12 @@ var APIError = class extends Error {
|
|
|
213
214
|
this.name = "APIError";
|
|
214
215
|
}
|
|
215
216
|
};
|
|
217
|
+
var DEFAULT_API_HOSTNAME = "https://api.appwarden.io";
|
|
216
218
|
var syncEdgeValue = async (context) => {
|
|
217
219
|
debug(`syncing with api`);
|
|
218
220
|
try {
|
|
219
|
-
const
|
|
221
|
+
const apiHostname = context.appwardenApiHostname ?? DEFAULT_API_HOSTNAME;
|
|
222
|
+
const response = await fetch(new URL("/v1/status/check", apiHostname), {
|
|
220
223
|
method: "POST",
|
|
221
224
|
headers: { "content-type": "application/json" },
|
|
222
225
|
body: JSON.stringify({
|
|
@@ -340,6 +343,7 @@ var useAppwarden = (input) => async (context, next) => {
|
|
|
340
343
|
debug: input.debug,
|
|
341
344
|
lockPageSlug,
|
|
342
345
|
appwardenApiToken: input.appwardenApiToken,
|
|
346
|
+
appwardenApiHostname: input.appwardenApiHostname,
|
|
343
347
|
waitUntil: (fn) => context.waitUntil(fn)
|
|
344
348
|
};
|
|
345
349
|
await maybeQuarantine(innerContext, {
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { B as Bindings } from './cloudflare-
|
|
2
|
-
export { C as CSPDirectivesSchema, a as CSPModeSchema, M as Middleware, u as useContentSecurityPolicy } from './use-content-security-policy-
|
|
1
|
+
export { B as Bindings } from './cloudflare-0sboFQGC.js';
|
|
2
|
+
export { C as CSPDirectivesSchema, a as CSPModeSchema, M as Middleware, u as useContentSecurityPolicy } from './use-content-security-policy-D4ccKJVd.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
declare const LOCKDOWN_TEST_EXPIRY_MS: number;
|
package/package.json
CHANGED
package/vercel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as next_dist_server_web_types from 'next/dist/server/web/types';
|
|
2
2
|
import * as next_server from 'next/server';
|
|
3
|
-
import './cloudflare-
|
|
3
|
+
import './cloudflare-0sboFQGC.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
declare const BaseNextJsConfigSchema: z.ZodObject<{
|