@shellicar/svelte-adapter-azure-functions 1.0.2 → 1.0.4
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 +118 -8
- package/dist/adapter.js +9 -1
- package/dist/adapter.js.map +1 -1
- package/dist/ambient.d.js +7 -1
- package/dist/ambient.d.js.map +1 -1
- package/dist/chunk-42KILSBR.js +58 -1
- package/dist/chunk-42KILSBR.js.map +1 -1
- package/dist/chunk-6TUT2TP2.js +23 -1
- package/dist/chunk-6TUT2TP2.js.map +1 -1
- package/dist/chunk-AW5NC2LL.js +57 -1
- package/dist/chunk-AW5NC2LL.js.map +1 -1
- package/dist/chunk-CV4SYBYR.js +245 -1
- package/dist/chunk-CV4SYBYR.js.map +1 -1
- package/dist/chunk-GKOGVGYC.js +21 -1
- package/dist/chunk-GKOGVGYC.js.map +1 -1
- package/dist/chunk-QGAJTWE2.js +53 -1
- package/dist/chunk-QGAJTWE2.js.map +1 -1
- package/dist/defaults.js +8 -1
- package/dist/defaults.js.map +1 -1
- package/dist/handler.js +10 -1
- package/dist/handler.js.map +1 -1
- package/dist/headers.js +12 -1
- package/dist/headers.js.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/server.js +8 -1
- package/dist/server.js.map +1 -1
- package/dist/shims.js +36 -1
- package/dist/shims.js.map +1 -1
- package/dist/trigger.js +3625 -429
- package/dist/trigger.js.map +1 -1
- package/dist/types.js +7 -1
- package/dist/types.js.map +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,17 +1,69 @@
|
|
|
1
1
|
# @shellicar/svelte-adapter-azure-functions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://npmjs.com/package/@shellicar/svelte-adapter-azure-functions)
|
|
4
|
+
[](https://github.com/shellicar/ecosystem/actions/workflows/node.js.yml)
|
|
5
|
+
[][azure-functions]
|
|
6
|
+
[][sveltekit]
|
|
7
|
+
[][typescript]
|
|
8
|
+
[][biome]
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
A [SvelteKit adapter](https://kit.svelte.dev/docs/adapters) that builds your app into an Azure Function.
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
<!-- BEGIN_ECOSYSTEM -->
|
|
13
|
+
|
|
14
|
+
## @shellicar TypeScript Ecosystem
|
|
15
|
+
|
|
16
|
+
### Core Libraries
|
|
17
|
+
|
|
18
|
+
- [`@shellicar/core-config`](https://github.com/shellicar/ecosystem/tree/main/packages/core-config) - A library for securely handling sensitive configuration values like connection strings, URLs, and secrets.
|
|
19
|
+
- [`@shellicar/core-di`](https://github.com/shellicar/ecosystem/tree/main/packages/core-di) - A basic dependency injection library.
|
|
20
|
+
|
|
21
|
+
### Reference Architectures
|
|
22
|
+
|
|
23
|
+
- [`@shellicar/reference-foundation`](https://github.com/shellicar/reference-foundation) - A comprehensive starter repository. Illustrates individual concepts.
|
|
24
|
+
- [`@shellicar/reference-enterprise`](https://github.com/shellicar/reference-enterprise) - A comprehensive starter repository. Can be used as the basis for creating a new Azure application workload.
|
|
25
|
+
|
|
26
|
+
### Build Tools
|
|
27
|
+
|
|
28
|
+
- [`@shellicar/build-clean`](https://github.com/shellicar/ecosystem/tree/main/packages/build-clean) - Build plugin that automatically cleans unused files from output directories.
|
|
29
|
+
- [`@shellicar/build-version`](https://github.com/shellicar/ecosystem/tree/main/packages/build-version) - Build plugin that calculates and exposes version information through a virtual module import.
|
|
30
|
+
- [`@shellicar/build-graphql`](https://github.com/shellicar/ecosystem/tree/main/packages/build-graphql) - Build plugin that loads GraphQL files and makes them available through a virtual module import.
|
|
31
|
+
|
|
32
|
+
### Framework Adapters
|
|
33
|
+
|
|
34
|
+
- [`@shellicar/svelte-adapter-azure-functions`](https://github.com/shellicar/ecosystem/tree/main/packages/svelte-adapter-azure-functions) - A [SvelteKit adapter](https://kit.svelte.dev/docs/adapters) that builds your app into an Azure Function.
|
|
35
|
+
- [`@shellicar/cosmos-query-builder`](https://github.com/shellicar/ecosystem/tree/main/packages/cosmos-query-builder) - Helper class for type safe advanced queries for Cosmos DB (Sql Core).
|
|
36
|
+
|
|
37
|
+
### Logging & Monitoring
|
|
38
|
+
|
|
39
|
+
- [`@shellicar/winston-azure-application-insights`](https://github.com/shellicar/ecosystem/tree/main/packages/winston-azure-application-insights) - An [Azure Application Insights](https://azure.microsoft.com/en-us/services/application-insights/) transport for [Winston](https://github.com/winstonjs/winston) logging library.
|
|
40
|
+
- [`@shellicar/pino-applicationinsights-transport`](https://github.com/shellicar/pino-applicationinsights-transport) - [Azure Application Insights](https://azure.microsoft.com/en-us/services/application-insights) transport for [pino](https://github.com/pinojs/pino)
|
|
41
|
+
|
|
42
|
+
<!-- END_ECOSYSTEM -->
|
|
43
|
+
|
|
44
|
+
## Motivation
|
|
45
|
+
|
|
46
|
+
Looking at the available SvelteKit adapters, there's one for Node.js and a community adapter for Azure Static Web Apps. I wanted to deploy to Azure Functions, so I created this adapter.
|
|
47
|
+
|
|
48
|
+
## Implementation
|
|
49
|
+
|
|
50
|
+
The adapter generates a single Azure Function:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
app.http('server', {
|
|
54
|
+
handler,
|
|
55
|
+
route: '{*url}',
|
|
56
|
+
methods: ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT']
|
|
57
|
+
});
|
|
9
58
|
```
|
|
10
59
|
|
|
11
|
-
|
|
12
|
-
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm add -D @shellicar/svelte-adapter-azure-functions
|
|
13
64
|
```
|
|
14
65
|
|
|
66
|
+
In `svelte.config.js`:
|
|
15
67
|
```js
|
|
16
68
|
import adapter from '@shellicar/svelte-adapter-azure-functions';
|
|
17
69
|
|
|
@@ -22,6 +74,64 @@ export default {
|
|
|
22
74
|
};
|
|
23
75
|
```
|
|
24
76
|
|
|
25
|
-
##
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
### esbuildOptions
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
adapter({
|
|
83
|
+
esbuildOptions: {
|
|
84
|
+
minify: false
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Default options in [defaults.ts](./src/defaults.ts):
|
|
90
|
+
```typescript
|
|
91
|
+
export const defaults = {
|
|
92
|
+
bundle: true,
|
|
93
|
+
platform: 'node',
|
|
94
|
+
target: 'node20',
|
|
95
|
+
format: 'esm',
|
|
96
|
+
// ...see defaults.ts for full options
|
|
97
|
+
};
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Function authLevel
|
|
101
|
+
|
|
102
|
+
The trigger uses the following code, and the authLevel can be changed using the `SERVER_AUTH_LEVEL` environment variable.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { app } from '@azure/functions';
|
|
106
|
+
import { handler } from './handler';
|
|
107
|
+
|
|
108
|
+
const getAuthLevel = (level: string | undefined) => {
|
|
109
|
+
switch(level) {
|
|
110
|
+
case 'function':
|
|
111
|
+
return 'function';
|
|
112
|
+
case 'admin':
|
|
113
|
+
return 'admin';
|
|
114
|
+
case 'anonymous':
|
|
115
|
+
return 'anonymous';
|
|
116
|
+
}
|
|
117
|
+
return 'anonymous';
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
app.http('server', {
|
|
121
|
+
handler,
|
|
122
|
+
authLevel: getAuthLevel(process.env.SERVER_AUTH_LEVEL),
|
|
123
|
+
route: '{*url}',
|
|
124
|
+
methods: ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT'],
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## Credits
|
|
130
|
+
|
|
131
|
+
* [svelte-adapter-azure-swa](https://github.com/geoffrich/svelte-adapter-azure-swa)
|
|
132
|
+
* [esbuild-azure-functions](https://github.com/beyerleinf/esbuild-azure-functions)
|
|
26
133
|
|
|
27
|
-
|
|
134
|
+
[azure-functions]: https://learn.microsoft.com/azure/azure-functions/functions-reference-node?tabs=typescript%2Cwindows%2Cazure-cli&pivots=nodejs-model-v4
|
|
135
|
+
[sveltekit]: https://kit.svelte.dev
|
|
136
|
+
[typescript]: https://www.typescriptlang.org
|
|
137
|
+
[biome]: https://biomejs.dev
|
package/dist/adapter.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
createAdapter
|
|
3
|
+
} from "./chunk-42KILSBR.js";
|
|
4
|
+
import "./chunk-6TUT2TP2.js";
|
|
5
|
+
import "./chunk-AW5NC2LL.js";
|
|
6
|
+
export {
|
|
7
|
+
createAdapter
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=adapter.js.map
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/ambient.d.js
CHANGED
package/dist/ambient.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ambient.d.ts"],"
|
|
1
|
+
{"version":3,"sources":["../src/ambient.d.ts"],"sourcesContent":["declare module 'SERVER' {\n export { Server } from '@sveltejs/kit';\n}\n\ndeclare module 'MANIFEST' {\n export const manifest: import('@sveltejs/kit').SSRManifest;\n}\n\ninterface String {\n split(separator: string | RegExp): [string, ...string[]];\n}\n\ndeclare namespace NodeJS {\n interface ProcessEnv {\n [key: string]: string;\n }\n}\n"],"mappings":";;;;;AAAA;","names":[]}
|
package/dist/chunk-42KILSBR.js
CHANGED
|
@@ -1 +1,58 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
defaults
|
|
3
|
+
} from "./chunk-6TUT2TP2.js";
|
|
4
|
+
import {
|
|
5
|
+
__name,
|
|
6
|
+
init_cjs_shim
|
|
7
|
+
} from "./chunk-AW5NC2LL.js";
|
|
8
|
+
|
|
9
|
+
// src/adapter.ts
|
|
10
|
+
init_cjs_shim();
|
|
11
|
+
import { writeFileSync } from "node:fs";
|
|
12
|
+
import { join, posix } from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
import { build } from "esbuild";
|
|
15
|
+
var createAdapter = /* @__PURE__ */ __name((options = {}) => {
|
|
16
|
+
return {
|
|
17
|
+
name: "adapter-azure-functions",
|
|
18
|
+
async adapt(builder) {
|
|
19
|
+
const { esbuildOptions = {} } = options;
|
|
20
|
+
const publish = "build";
|
|
21
|
+
const tmp = builder.getBuildDirectory("adapter-azure-functions");
|
|
22
|
+
const serverDir = join(publish, "server");
|
|
23
|
+
const staticDir = join(publish, "static");
|
|
24
|
+
builder.log.minor(`Publishing to "${publish}"`);
|
|
25
|
+
builder.rimraf(publish);
|
|
26
|
+
builder.rimraf(tmp);
|
|
27
|
+
builder.log.minor("Copying assets...");
|
|
28
|
+
builder.writeClient(staticDir);
|
|
29
|
+
builder.writePrerendered(staticDir);
|
|
30
|
+
const distFiles = fileURLToPath(new URL("../dist", import.meta.url));
|
|
31
|
+
const relativePath = posix.relative(tmp, join(builder.getServerDirectory()));
|
|
32
|
+
builder.log.minor("Generating serverless function...");
|
|
33
|
+
builder.copy(distFiles, tmp, {
|
|
34
|
+
replace: {
|
|
35
|
+
MANIFEST: "./manifest.js",
|
|
36
|
+
SERVER: `${relativePath}/index.js`,
|
|
37
|
+
SHIMS: "./shims.js"
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
writeFileSync(`${tmp}/manifest.js`, `export const manifest = ${builder.generateManifest({ relativePath })};
|
|
41
|
+
`);
|
|
42
|
+
await build({
|
|
43
|
+
entryPoints: [`${tmp}/trigger.js`],
|
|
44
|
+
outdir: join(serverDir, "dist"),
|
|
45
|
+
...defaults,
|
|
46
|
+
...esbuildOptions
|
|
47
|
+
});
|
|
48
|
+
const copyFiles = fileURLToPath(new URL("../files", import.meta.url));
|
|
49
|
+
builder.log.minor("Copying files to server directory");
|
|
50
|
+
builder.copy(copyFiles, serverDir);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}, "createAdapter");
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
createAdapter
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=chunk-42KILSBR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter.ts"],"
|
|
1
|
+
{"version":3,"sources":["../src/adapter.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { join, posix } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { Adapter, Builder } from '@sveltejs/kit';\nimport { type BuildOptions, build } from 'esbuild';\nimport { defaults } from './defaults';\n\nexport interface AzureFunctionsAdapterOptions {\n esbuildOptions?: BuildOptions;\n}\n\nexport const createAdapter = (options: AzureFunctionsAdapterOptions = {}): Adapter => {\n return {\n name: 'adapter-azure-functions',\n async adapt(builder: Builder) {\n const { esbuildOptions = {} } = options;\n const publish = 'build';\n const tmp = builder.getBuildDirectory('adapter-azure-functions');\n const serverDir = join(publish, 'server');\n const staticDir = join(publish, 'static');\n\n builder.log.minor(`Publishing to \"${publish}\"`);\n builder.rimraf(publish);\n builder.rimraf(tmp);\n\n builder.log.minor('Copying assets...');\n builder.writeClient(staticDir);\n builder.writePrerendered(staticDir);\n\n const distFiles = fileURLToPath(new URL('../dist', import.meta.url));\n\n const relativePath = posix.relative(tmp, join(builder.getServerDirectory()));\n\n builder.log.minor('Generating serverless function...');\n builder.copy(distFiles, tmp, {\n replace: {\n MANIFEST: './manifest.js',\n SERVER: `${relativePath}/index.js`,\n SHIMS: './shims.js',\n },\n });\n\n writeFileSync(`${tmp}/manifest.js`, `export const manifest = ${builder.generateManifest({ relativePath })};\\n`);\n\n await build({\n entryPoints: [`${tmp}/trigger.js`],\n outdir: join(serverDir, 'dist'),\n ...defaults,\n ...esbuildOptions,\n });\n\n const copyFiles = fileURLToPath(new URL('../files', import.meta.url));\n builder.log.minor('Copying files to server directory');\n builder.copy(copyFiles, serverDir);\n },\n };\n};\n"],"mappings":";;;;;;;;;AAAA;AAAA,SAAS,qBAAqB;AAC9B,SAAS,MAAM,aAAa;AAC5B,SAAS,qBAAqB;AAE9B,SAA4B,aAAa;AAOlC,IAAM,gBAAgB,wBAAC,UAAwC,CAAC,MAAe;AACpF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,MAAM,SAAkB;AAC5B,YAAM,EAAE,iBAAiB,CAAC,EAAE,IAAI;AAChC,YAAM,UAAU;AAChB,YAAM,MAAM,QAAQ,kBAAkB,yBAAyB;AAC/D,YAAM,YAAY,KAAK,SAAS,QAAQ;AACxC,YAAM,YAAY,KAAK,SAAS,QAAQ;AAExC,cAAQ,IAAI,MAAM,kBAAkB,OAAO,GAAG;AAC9C,cAAQ,OAAO,OAAO;AACtB,cAAQ,OAAO,GAAG;AAElB,cAAQ,IAAI,MAAM,mBAAmB;AACrC,cAAQ,YAAY,SAAS;AAC7B,cAAQ,iBAAiB,SAAS;AAElC,YAAM,YAAY,cAAc,IAAI,IAAI,WAAW,YAAY,GAAG,CAAC;AAEnE,YAAM,eAAe,MAAM,SAAS,KAAK,KAAK,QAAQ,mBAAmB,CAAC,CAAC;AAE3E,cAAQ,IAAI,MAAM,mCAAmC;AACrD,cAAQ,KAAK,WAAW,KAAK;AAAA,QAC3B,SAAS;AAAA,UACP,UAAU;AAAA,UACV,QAAQ,GAAG,YAAY;AAAA,UACvB,OAAO;AAAA,QACT;AAAA,MACF,CAAC;AAED,oBAAc,GAAG,GAAG,gBAAgB,2BAA2B,QAAQ,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAAA,CAAK;AAE9G,YAAM,MAAM;AAAA,QACV,aAAa,CAAC,GAAG,GAAG,aAAa;AAAA,QACjC,QAAQ,KAAK,WAAW,MAAM;AAAA,QAC9B,GAAG;AAAA,QACH,GAAG;AAAA,MACL,CAAC;AAED,YAAM,YAAY,cAAc,IAAI,IAAI,YAAY,YAAY,GAAG,CAAC;AACpE,cAAQ,IAAI,MAAM,mCAAmC;AACrD,cAAQ,KAAK,WAAW,SAAS;AAAA,IACnC;AAAA,EACF;AACF,GA7C6B;","names":[]}
|
package/dist/chunk-6TUT2TP2.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
init_cjs_shim
|
|
3
|
+
} from "./chunk-AW5NC2LL.js";
|
|
4
|
+
|
|
5
|
+
// src/defaults.ts
|
|
6
|
+
init_cjs_shim();
|
|
7
|
+
var defaults = {
|
|
8
|
+
bundle: true,
|
|
9
|
+
platform: "node",
|
|
10
|
+
target: "node20",
|
|
11
|
+
treeShaking: true,
|
|
12
|
+
format: "esm",
|
|
13
|
+
splitting: true,
|
|
14
|
+
minify: true,
|
|
15
|
+
keepNames: true,
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
outExtension: { ".js": ".mjs" }
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
defaults
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-6TUT2TP2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.ts"],"
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["import type { BuildOptions } from 'esbuild';\n\nexport const defaults: BuildOptions = {\n bundle: true,\n platform: 'node',\n target: 'node20',\n treeShaking: true,\n format: 'esm',\n splitting: true,\n minify: true,\n keepNames: true,\n sourcemap: true,\n outExtension: { '.js': '.mjs' },\n};\n"],"mappings":";;;;;AAAA;AAEO,IAAM,WAAyB;AAAA,EACpC,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX,cAAc,EAAE,OAAO,OAAO;AAChC;","names":[]}
|
package/dist/chunk-AW5NC2LL.js
CHANGED
|
@@ -1 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __esm = (fn, res) => function __init() {
|
|
15
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
|
|
37
|
+
// cjs-shim.mts
|
|
38
|
+
import { createRequire } from "node:module";
|
|
39
|
+
import path from "node:path";
|
|
40
|
+
import url from "node:url";
|
|
41
|
+
var init_cjs_shim = __esm({
|
|
42
|
+
"cjs-shim.mts"() {
|
|
43
|
+
"use strict";
|
|
44
|
+
globalThis.require = createRequire(import.meta.url);
|
|
45
|
+
globalThis.__filename = url.fileURLToPath(import.meta.url);
|
|
46
|
+
globalThis.__dirname = path.dirname(__filename);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
__name,
|
|
52
|
+
__require,
|
|
53
|
+
__commonJS,
|
|
54
|
+
__toESM,
|
|
55
|
+
init_cjs_shim
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=chunk-AW5NC2LL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cjs-shim.mts"],"
|
|
1
|
+
{"version":3,"sources":["../cjs-shim.mts"],"sourcesContent":["import { createRequire } from 'node:module';\nimport path from 'node:path';\nimport url from 'node:url';\n\nglobalThis.require = createRequire(import.meta.url);\nglobalThis.__filename = url.fileURLToPath(import.meta.url);\nglobalThis.__dirname = path.dirname(__filename);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AACjB,OAAO,SAAS;AAFhB;AAAA;AAAA;AAIA,eAAW,UAAU,cAAc,YAAY,GAAG;AAClD,eAAW,aAAa,IAAI,cAAc,YAAY,GAAG;AACzD,eAAW,YAAY,KAAK,QAAQ,UAAU;AAAA;AAAA;","names":[]}
|
package/dist/chunk-CV4SYBYR.js
CHANGED
|
@@ -1 +1,245 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__name,
|
|
4
|
+
__toESM,
|
|
5
|
+
init_cjs_shim
|
|
6
|
+
} from "./chunk-AW5NC2LL.js";
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/.pnpm/set-cookie-parser@2.7.2/node_modules/set-cookie-parser/lib/set-cookie.js
|
|
9
|
+
var require_set_cookie = __commonJS({
|
|
10
|
+
"../../node_modules/.pnpm/set-cookie-parser@2.7.2/node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
|
|
11
|
+
"use strict";
|
|
12
|
+
init_cjs_shim();
|
|
13
|
+
var defaultParseOptions = {
|
|
14
|
+
decodeValues: true,
|
|
15
|
+
map: false,
|
|
16
|
+
silent: false
|
|
17
|
+
};
|
|
18
|
+
function isForbiddenKey(key) {
|
|
19
|
+
return typeof key !== "string" || key in {};
|
|
20
|
+
}
|
|
21
|
+
__name(isForbiddenKey, "isForbiddenKey");
|
|
22
|
+
function createNullObj() {
|
|
23
|
+
return /* @__PURE__ */ Object.create(null);
|
|
24
|
+
}
|
|
25
|
+
__name(createNullObj, "createNullObj");
|
|
26
|
+
function isNonEmptyString(str) {
|
|
27
|
+
return typeof str === "string" && !!str.trim();
|
|
28
|
+
}
|
|
29
|
+
__name(isNonEmptyString, "isNonEmptyString");
|
|
30
|
+
function parseString(setCookieValue, options) {
|
|
31
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
32
|
+
var nameValuePairStr = parts.shift();
|
|
33
|
+
var parsed = parseNameValuePair(nameValuePairStr);
|
|
34
|
+
var name = parsed.name;
|
|
35
|
+
var value = parsed.value;
|
|
36
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
37
|
+
if (isForbiddenKey(name)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
value = options.decodeValues ? decodeURIComponent(value) : value;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(
|
|
44
|
+
"set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",
|
|
45
|
+
e
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
var cookie = createNullObj();
|
|
49
|
+
cookie.name = name;
|
|
50
|
+
cookie.value = value;
|
|
51
|
+
parts.forEach(function(part) {
|
|
52
|
+
var sides = part.split("=");
|
|
53
|
+
var key = sides.shift().trimLeft().toLowerCase();
|
|
54
|
+
if (isForbiddenKey(key)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
var value2 = sides.join("=");
|
|
58
|
+
if (key === "expires") {
|
|
59
|
+
cookie.expires = new Date(value2);
|
|
60
|
+
} else if (key === "max-age") {
|
|
61
|
+
var n = parseInt(value2, 10);
|
|
62
|
+
if (!Number.isNaN(n)) cookie.maxAge = n;
|
|
63
|
+
} else if (key === "secure") {
|
|
64
|
+
cookie.secure = true;
|
|
65
|
+
} else if (key === "httponly") {
|
|
66
|
+
cookie.httpOnly = true;
|
|
67
|
+
} else if (key === "samesite") {
|
|
68
|
+
cookie.sameSite = value2;
|
|
69
|
+
} else if (key === "partitioned") {
|
|
70
|
+
cookie.partitioned = true;
|
|
71
|
+
} else if (key) {
|
|
72
|
+
cookie[key] = value2;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return cookie;
|
|
76
|
+
}
|
|
77
|
+
__name(parseString, "parseString");
|
|
78
|
+
function parseNameValuePair(nameValuePairStr) {
|
|
79
|
+
var name = "";
|
|
80
|
+
var value = "";
|
|
81
|
+
var nameValueArr = nameValuePairStr.split("=");
|
|
82
|
+
if (nameValueArr.length > 1) {
|
|
83
|
+
name = nameValueArr.shift();
|
|
84
|
+
value = nameValueArr.join("=");
|
|
85
|
+
} else {
|
|
86
|
+
value = nameValuePairStr;
|
|
87
|
+
}
|
|
88
|
+
return { name, value };
|
|
89
|
+
}
|
|
90
|
+
__name(parseNameValuePair, "parseNameValuePair");
|
|
91
|
+
function parse2(input, options) {
|
|
92
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
93
|
+
if (!input) {
|
|
94
|
+
if (!options.map) {
|
|
95
|
+
return [];
|
|
96
|
+
} else {
|
|
97
|
+
return createNullObj();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (input.headers) {
|
|
101
|
+
if (typeof input.headers.getSetCookie === "function") {
|
|
102
|
+
input = input.headers.getSetCookie();
|
|
103
|
+
} else if (input.headers["set-cookie"]) {
|
|
104
|
+
input = input.headers["set-cookie"];
|
|
105
|
+
} else {
|
|
106
|
+
var sch = input.headers[Object.keys(input.headers).find(function(key) {
|
|
107
|
+
return key.toLowerCase() === "set-cookie";
|
|
108
|
+
})];
|
|
109
|
+
if (!sch && input.headers.cookie && !options.silent) {
|
|
110
|
+
console.warn(
|
|
111
|
+
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
input = sch;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!Array.isArray(input)) {
|
|
118
|
+
input = [input];
|
|
119
|
+
}
|
|
120
|
+
if (!options.map) {
|
|
121
|
+
return input.filter(isNonEmptyString).map(function(str) {
|
|
122
|
+
return parseString(str, options);
|
|
123
|
+
}).filter(Boolean);
|
|
124
|
+
} else {
|
|
125
|
+
var cookies = createNullObj();
|
|
126
|
+
return input.filter(isNonEmptyString).reduce(function(cookies2, str) {
|
|
127
|
+
var cookie = parseString(str, options);
|
|
128
|
+
if (cookie && !isForbiddenKey(cookie.name)) {
|
|
129
|
+
cookies2[cookie.name] = cookie;
|
|
130
|
+
}
|
|
131
|
+
return cookies2;
|
|
132
|
+
}, cookies);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
__name(parse2, "parse");
|
|
136
|
+
function splitCookiesString2(cookiesString) {
|
|
137
|
+
if (Array.isArray(cookiesString)) {
|
|
138
|
+
return cookiesString;
|
|
139
|
+
}
|
|
140
|
+
if (typeof cookiesString !== "string") {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
var cookiesStrings = [];
|
|
144
|
+
var pos = 0;
|
|
145
|
+
var start;
|
|
146
|
+
var ch;
|
|
147
|
+
var lastComma;
|
|
148
|
+
var nextStart;
|
|
149
|
+
var cookiesSeparatorFound;
|
|
150
|
+
function skipWhitespace() {
|
|
151
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
152
|
+
pos += 1;
|
|
153
|
+
}
|
|
154
|
+
return pos < cookiesString.length;
|
|
155
|
+
}
|
|
156
|
+
__name(skipWhitespace, "skipWhitespace");
|
|
157
|
+
function notSpecialChar() {
|
|
158
|
+
ch = cookiesString.charAt(pos);
|
|
159
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
160
|
+
}
|
|
161
|
+
__name(notSpecialChar, "notSpecialChar");
|
|
162
|
+
while (pos < cookiesString.length) {
|
|
163
|
+
start = pos;
|
|
164
|
+
cookiesSeparatorFound = false;
|
|
165
|
+
while (skipWhitespace()) {
|
|
166
|
+
ch = cookiesString.charAt(pos);
|
|
167
|
+
if (ch === ",") {
|
|
168
|
+
lastComma = pos;
|
|
169
|
+
pos += 1;
|
|
170
|
+
skipWhitespace();
|
|
171
|
+
nextStart = pos;
|
|
172
|
+
while (pos < cookiesString.length && notSpecialChar()) {
|
|
173
|
+
pos += 1;
|
|
174
|
+
}
|
|
175
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
176
|
+
cookiesSeparatorFound = true;
|
|
177
|
+
pos = nextStart;
|
|
178
|
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
179
|
+
start = pos;
|
|
180
|
+
} else {
|
|
181
|
+
pos = lastComma + 1;
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
pos += 1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
188
|
+
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return cookiesStrings;
|
|
192
|
+
}
|
|
193
|
+
__name(splitCookiesString2, "splitCookiesString");
|
|
194
|
+
module.exports = parse2;
|
|
195
|
+
module.exports.parse = parse2;
|
|
196
|
+
module.exports.parseString = parseString;
|
|
197
|
+
module.exports.splitCookiesString = splitCookiesString2;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// src/headers.ts
|
|
202
|
+
init_cjs_shim();
|
|
203
|
+
var import_set_cookie_parser = __toESM(require_set_cookie(), 1);
|
|
204
|
+
var splitCookiesFromHeaders = /* @__PURE__ */ __name((headers) => {
|
|
205
|
+
const resHeaders = {};
|
|
206
|
+
const resCookies = [];
|
|
207
|
+
headers.forEach((value, key) => {
|
|
208
|
+
if (key === "set-cookie") {
|
|
209
|
+
const cookieStrings = (0, import_set_cookie_parser.splitCookiesString)(value);
|
|
210
|
+
resCookies.push(...(0, import_set_cookie_parser.parse)(cookieStrings));
|
|
211
|
+
} else {
|
|
212
|
+
resHeaders[key] = value;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
return { headers: resHeaders, cookies: resCookies };
|
|
216
|
+
}, "splitCookiesFromHeaders");
|
|
217
|
+
var getClientIPFromHeaders = /* @__PURE__ */ __name((headers) => {
|
|
218
|
+
const resHeader = headers.get("x-forwarded-for") ?? "127.0.0.1";
|
|
219
|
+
const [origin] = resHeader.split(", ");
|
|
220
|
+
const [ipAddress] = origin.split(":");
|
|
221
|
+
return ipAddress;
|
|
222
|
+
}, "getClientIPFromHeaders");
|
|
223
|
+
function getClientPrincipalFromHeaders(headers) {
|
|
224
|
+
const header = headers.get("x-ms-client-principal");
|
|
225
|
+
if (!header) {
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const encoded = Buffer.from(header, "base64");
|
|
230
|
+
const decoded = encoded.toString("utf-8");
|
|
231
|
+
const clientPrincipal = JSON.parse(decoded);
|
|
232
|
+
return clientPrincipal;
|
|
233
|
+
} catch (e) {
|
|
234
|
+
console.log("Unable to parse client principal:", e);
|
|
235
|
+
return void 0;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
__name(getClientPrincipalFromHeaders, "getClientPrincipalFromHeaders");
|
|
239
|
+
|
|
240
|
+
export {
|
|
241
|
+
splitCookiesFromHeaders,
|
|
242
|
+
getClientIPFromHeaders,
|
|
243
|
+
getClientPrincipalFromHeaders
|
|
244
|
+
};
|
|
245
|
+
//# sourceMappingURL=chunk-CV4SYBYR.js.map
|