@shellicar/svelte-adapter-azure-functions 0.2.0 → 0.2.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/dist/{chunk-POAQL7D4.js → chunk-MZGTF76B.js} +1 -1
- package/dist/chunk-U5QCC3U4.js +1 -0
- package/dist/chunk-U5QCC3U4.js.map +1 -0
- package/dist/handler.js +1 -1
- package/dist/headers.js +1 -1
- package/dist/trigger.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-XDKFIHKQ.js +0 -1
- package/dist/chunk-XDKFIHKQ.js.map +0 -1
- /package/dist/{chunk-POAQL7D4.js.map → chunk-MZGTF76B.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellicar/svelte-adapter-azure-functions",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Stephen Hellicar",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@types/node": "^22.10.5",
|
|
41
41
|
"@types/set-cookie-parser": "^2.4.10",
|
|
42
42
|
"escape-string-regexp": "^5.0.0",
|
|
43
|
+
"set-cookie-parser": "^2.7.1",
|
|
43
44
|
"terser": "^5.37.0",
|
|
44
45
|
"tsup": "^8.3.5",
|
|
45
46
|
"tsx": "^4.19.2",
|
|
@@ -47,8 +48,7 @@
|
|
|
47
48
|
"vitest": "^2.1.8"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"esbuild": "^0.24.2"
|
|
51
|
-
"set-cookie-parser": "^2.7.1"
|
|
51
|
+
"esbuild": "^0.24.2"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "tsup",
|
package/dist/chunk-XDKFIHKQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__name as e,init_cjs_shim as r}from"./chunk-AW5NC2LL.js";r();import{parse as o,splitCookiesString as t}from"set-cookie-parser";var i=e((e=>{const r={},i=[];return e.forEach(((e,s)=>{if("set-cookie"===s){const r=t(e);i.push(...o(r))}else r[s]=e})),{headers:r,cookies:i}}),"splitCookiesFromHeaders"),s=e((e=>{const r=e.get("x-forwarded-for")??"127.0.0.1",[o]=r.split(", "),[t]=o.split(":");return t}),"getClientIPFromHeaders");function n(e){const r=e.get("x-ms-client-principal");if(r)try{const e=Buffer.from(r,"base64").toString("ascii");return JSON.parse(e)}catch(e){return void console.log("Unable to parse client principal:",e)}}e(n,"getClientPrincipalFromHeaders");export{i as splitCookiesFromHeaders,s as getClientIPFromHeaders,n as getClientPrincipalFromHeaders};//# sourceMappingURL=chunk-XDKFIHKQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/headers.ts"],"sourcesContent":["import type { Cookie } from '@azure/functions';\nimport { parse, splitCookiesString } from 'set-cookie-parser';\nimport type { ClientPrincipal } from './types';\n\n/**\n * Splits 'set-cookie' headers into individual cookies\n */\nexport const splitCookiesFromHeaders = (headers: Headers): { headers: Record<string, string>; cookies: Cookie[] } => {\n const resHeaders: Record<string, string> = {};\n const resCookies: Cookie[] = [];\n\n headers.forEach((value, key) => {\n if (key === 'set-cookie') {\n const cookieStrings = splitCookiesString(value);\n resCookies.push(...(parse(cookieStrings) as Cookie[]));\n } else {\n resHeaders[key] = value;\n }\n });\n\n return { headers: resHeaders, cookies: resCookies };\n};\n\nexport const getClientIPFromHeaders = (headers: Headers): string => {\n const resHeader = headers.get('x-forwarded-for') ?? '127.0.0.1';\n const [origin] = resHeader.split(', ');\n const [ipAddress] = origin.split(':');\n return ipAddress;\n};\n\n/**\n * Gets the client principal from `x-ms-client-principal` header.\n */\nexport function getClientPrincipalFromHeaders(headers: Headers): ClientPrincipal | undefined {\n // Code adapted from the official SWA documentation\n // https://learn.microsoft.com/en-us/azure/static-web-apps/user-information?tabs=javascript#api-functions\n const header = headers.get('x-ms-client-principal');\n if (!header) {\n return undefined;\n }\n\n try {\n const encoded = Buffer.from(header, 'base64');\n const decoded = encoded.toString('ascii');\n const clientPrincipal = JSON.parse(decoded);\n\n return clientPrincipal;\n } catch (e) {\n console.log('Unable to parse client principal:', e);\n return undefined;\n }\n}\n"],"mappings":";;;;;;AAAA;AACA,SAAS,OAAO,0BAA0B;AAMnC,IAAM,0BAA0B,wBAAC,YAA6E;AACnH,QAAM,aAAqC,CAAC;AAC5C,QAAM,aAAuB,CAAC;AAE9B,UAAQ,QAAQ,CAAC,OAAO,QAAQ;AAC9B,QAAI,QAAQ,cAAc;AACxB,YAAM,gBAAgB,mBAAmB,KAAK;AAC9C,iBAAW,KAAK,GAAI,MAAM,aAAa,CAAc;AAAA,IACvD,OAAO;AACL,iBAAW,GAAG,IAAI;AAAA,IACpB;AAAA,EACF,CAAC;AAED,SAAO,EAAE,SAAS,YAAY,SAAS,WAAW;AACpD,GAduC;AAgBhC,IAAM,yBAAyB,wBAAC,YAA6B;AAClE,QAAM,YAAY,QAAQ,IAAI,iBAAiB,KAAK;AACpD,QAAM,CAAC,MAAM,IAAI,UAAU,MAAM,IAAI;AACrC,QAAM,CAAC,SAAS,IAAI,OAAO,MAAM,GAAG;AACpC,SAAO;AACT,GALsC;AAU/B,SAAS,8BAA8B,SAA+C;AAG3F,QAAM,SAAS,QAAQ,IAAI,uBAAuB;AAClD,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,UAAU,OAAO,KAAK,QAAQ,QAAQ;AAC5C,UAAM,UAAU,QAAQ,SAAS,OAAO;AACxC,UAAM,kBAAkB,KAAK,MAAM,OAAO;AAE1C,WAAO;AAAA,EACT,SAAS,GAAG;AACV,YAAQ,IAAI,qCAAqC,CAAC;AAClD,WAAO;AAAA,EACT;AACF;AAlBgB;","names":[]}
|
|
File without changes
|