@snokam/auth 2.2.0-alpha.4 → 2.2.0-alpha.5
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/CHANGELOG.md +11 -0
- package/lib/options.js +1 -1
- package/lib/options.js.map +1 -1
- package/lib/server.js +1 -1
- package/lib/server.js.map +1 -1
- package/lib/utils/params.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.2.0-alpha.5](https://github.com/snokam/components/compare/@snokam/auth@2.2.0-alpha.4...@snokam/auth@2.2.0-alpha.5) (2025-06-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* pass domain_hint ([613f8aa](https://github.com/snokam/components/commit/613f8aafe90a2cd712897a7fb018a67a2a2123ae))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.2.0-alpha.4](https://github.com/snokam/components/compare/@snokam/auth@2.2.0-alpha.3...@snokam/auth@2.2.0-alpha.4) (2025-06-01)
|
|
7
18
|
|
|
8
19
|
|
package/lib/options.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={542:e=>{e.exports=require("next-auth")}},t={};function n(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={542:e=>{e.exports=require("next-auth")}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{default:()=>d,getNextAuthOptions:()=>u});var r=n(542),a=n.n(r);const i=require("next-auth/providers/azure-ad");var s=n.n(i);const c=()=>{const e="undefined"!=typeof window,t=e&&window.location.hostname.includes("test."),n={scope:"openid profile email offline_access https://graph.microsoft.com/User.Read"};return e&&(n.domain_hint=t?"test.snokam.no":"snokam.no"),n};const u=e=>({secret:e.nextAuthSecret,pages:{signIn:"/auth/login"},providers:[s()({clientId:e.clientId,clientSecret:e.clientSecret,tenantId:e.tenantId,authorization:{params:c()}})],callbacks:{jwt(e){return t=this,n=arguments,r=function*({token:e,account:t}){return(null==t?void 0:t.access_token)&&(e.refreshToken=t.refresh_token,e.expiresAt=t.expires_at),e},new((o=void 0)||(o=Promise))((function(e,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(i,s)}c((r=r.apply(t,n||[])).next())}));var t,n,o,r}}}),d=e=>a()(u(e));return o})()));
|
|
2
2
|
//# sourceMappingURL=options.js.map
|
package/lib/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9C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ACZC,SAAUN,EAAOM,SACjBC,aAAcP,EAAOO,aACrBC,SAAUR,EAAOQ,SACjBC,cAAe,CACXb,OAAQP,QAIpBqB,UAAW,CACP,GAAAC,CAAIC,GACA,OA9BsCC,EA8BrBrD,KA9B8BsD,EA8BxBC,UA9BuCC,EA8BpB,WAAW,MAAEC,EAAK,QAAEC,IAK1D,OAJIA,aAAyC,EAASA,EAAQC,gBAC1DF,EAAMG,aAAeF,EAAQG,cAC7BJ,EAAMK,UAAYJ,EAAQK,YAEvBN,CACX,EAlCL,KAFgEO,OA8BzB,KA5B5BA,EAAIC,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUxC,GAAS,IAAMyC,EAAKb,EAAUc,KAAK1C,GAAS,CAAE,MAAO2C,GAAKJ,EAAOI,EAAI,CAAE,CAC1F,SAASC,EAAS5C,GAAS,IAAMyC,EAAKb,EAAiB,MAAE5B,GAAS,CAAE,MAAO2C,GAAKJ,EAAOI,EAAI,CAAE,CAC7F,SAASF,EAAKI,GAJlB,IAAe7C,EAIa6C,EAAOC,KAAOR,EAAQO,EAAO7C,QAJ1CA,EAIyD6C,EAAO7C,MAJhDA,aAAiBoC,EAAIpC,EAAQ,IAAIoC,GAAE,SAAUE,GAAWA,EAAQtC,EAAQ,KAIjB+C,KAAKP,EAAWI,EAAW,CAC7GH,GAAMb,EAAYA,EAAUoB,MAAMvB,EAASC,GAAc,KAAKgB,OAClE,IAPwC,IAAUjB,EAASC,EAAYU,EAAGR,CAqClE,KAIZ,EAAgBhB,GAAW,IAASD,EAAmBC,I","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/external commonjs \"next-auth\"","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/compat get default export","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"next-auth/providers/azure-ad\"","webpack://snokam/./src/utils/params.ts","webpack://snokam/./src/options.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"snokam\"] = factory();\n\telse\n\t\troot[\"snokam\"] = factory();\n})(this, () => {\nreturn ","module.exports = require(\"next-auth\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/providers/azure-ad\");","export const getDefaultAuthParams = () => {\n const isBrowser = typeof window !== \"undefined\";\n const isTest = isBrowser && window.location.hostname.includes(\"test.\");\n const params = {\n scope: `openid profile email offline_access https://graph.microsoft.com/User.Read`,\n };\n if (isBrowser) {\n params.domain_hint = isTest ? \"test.snokam.no\" : \"snokam.no\";\n }\n return params;\n};\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport NextAuth from \"next-auth\";\nimport AzureADProvider from \"next-auth/providers/azure-ad\";\nimport { getDefaultAuthParams } from \"./utils/params\";\nexport const getNextAuthOptions = (config) => {\n return {\n secret: config.nextAuthSecret,\n pages: {\n signIn: \"/auth/login\",\n },\n providers: [\n AzureADProvider({\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n tenantId: config.tenantId,\n authorization: {\n params: getDefaultAuthParams(),\n },\n }),\n ],\n callbacks: {\n jwt(_a) {\n return __awaiter(this, arguments, void 0, function* ({ token, account }) {\n if (account === null || account === void 0 ? void 0 : account.access_token) {\n token.refreshToken = account.refresh_token;\n token.expiresAt = account.expires_at;\n }\n return token;\n });\n },\n },\n };\n};\nexport default (config) => NextAuth(getNextAuthOptions(config));\n"],"names":["root","factory","exports","module","define","amd","this","require","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","getDefaultAuthParams","isBrowser","window","isTest","location","hostname","includes","params","scope","domain_hint","getNextAuthOptions","config","secret","nextAuthSecret","pages","signIn","providers","clientId","clientSecret","tenantId","authorization","callbacks","jwt","_a","thisArg","_arguments","arguments","generator","token","account","access_token","refreshToken","refresh_token","expiresAt","expires_at","P","Promise","resolve","reject","fulfilled","step","next","e","rejected","result","done","then","apply"],"sourceRoot":""}
|
package/lib/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.snokam=t():e.snokam=t()}(this,(()=>(()=>{"use strict";var e={542:e=>{e.exports=require("next-auth")},659:(e,t,n)=>{n.d(t,{default:()=>u,getNextAuthOptions:()=>a});var o=n(542),r=n.n(o);const i=require("next-auth/providers/azure-ad");var c=n.n(i);const s=()=>{const e="undefined"!=typeof window,t=e&&window.location.hostname.includes("test."),n={scope:"openid profile email offline_access https://graph.microsoft.com/User.Read"};return e&&(n.domain_hint=t?"test.snokam.no":"snokam.no"),n};const a=e=>({secret:e.nextAuthSecret,pages:{signIn:"/auth/login"},providers:[c()({clientId:e.clientId,clientSecret:e.clientSecret,tenantId:e.tenantId,authorization:{params:s()}})],callbacks:{jwt(e){return t=this,n=arguments,r=function*({token:e,account:t}){return(null==t?void 0:t.access_token)&&(e.refreshToken=t.refresh_token,e.expiresAt=t.expires_at),e},new((o=void 0)||(o=Promise))((function(e,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,s)}a((r=r.apply(t,n||[])).next())}));var t,n,o,r}}}),u=e=>r()(a(e))}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{default:()=>l,getServerSession:()=>u.getServerSession,getServerToken:()=>i});const r=require("@azure/msal-node");const i=e=>{return t=void 0,n=void 0,i=function*(){const{scopes:t}=e,n=new r.ConfidentialClientApplication({auth:{clientId:`${e.clientId}`,authority:`https://login.microsoftonline.com/${e.tenantId}/oauth2/v2.0`,clientSecret:`${e.secret}`}}),o=yield n.acquireTokenByClientCredential({scopes:t.map((e=>e.replace("user_impersonation",".default")))}).catch((e=>{throw console.error(e),e}));return`Bearer ${null==o?void 0:o.accessToken}`},new((o=void 0)||(o=Promise))((function(e,r){function c(e){try{a(i.next(e))}catch(e){r(e)}}function s(e){try{a(i.throw(e))}catch(e){r(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,s)}a((i=i.apply(t,n||[])).next())}));var t,n,o,i};var c=n(659);const s=require("next-auth/jwt");var a=n(542);const u=require("next-auth/next"),l={Routes:c.default,Token:function(e){return t=this,n=void 0,i=function*(){const{req:t,res:n,authConfig:o}=e,i=yield(0,a.getServerSession)(t,n,(0,c.getNextAuthOptions)(o));if(!(null==i?void 0:i.user))return n.status(401).end("Not authenticated");if(!t.body.scope)return n.status(400).end("Invalid or missing scope");try{const{nextAuthSecret:e}=o,i=yield(0,s.getToken)({req:t,secret:e});if(!i)return n.status(500).end("Failed to get refetch token");const c=new r.ConfidentialClientApplication({auth:{clientId:o.clientId,clientSecret:o.clientSecret,authority:`https://login.microsoftonline.com/${o.tenantId}`}}),a=yield c.acquireTokenByRefreshToken({scopes:[t.body.scope],refreshToken:null==i?void 0:i.refreshToken});return a?n.status(200).json({accessToken:null==a?void 0:a.accessToken,expiresOn:Math.floor(a.expiresOn.getTime()/1e3)}):n.status(500).end("Failed to get access token")}catch(e){console.error("Token exchange error:",e),n.status(500).end("Token exchange failed")}},new((o=void 0)||(o=Promise))((function(e,r){function c(e){try{a(i.next(e))}catch(e){r(e)}}function s(e){try{a(i.throw(e))}catch(e){r(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(c,s)}a((i=i.apply(t,n||[])).next())}));var t,n,o,i}};return o})()));
|
|
2
2
|
//# sourceMappingURL=server.js.map
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,8GCTT,MAAM,EAA+BC,QAAQ,gC,aCWtC,MAAMC,EAAsBC,IAAW,CAC1CC,OAAQD,EAAOE,eACfC,MAAO,CACHC,OAAQ,eAEZC,UAAW,CACP,IAAgB,CACZC,SAAUN,EAAOM,SACjBC,aAAcP,EAAOO,aACrBC,SAAUR,EAAOQ,SACjBC,cAAe,CACXC,OAAQ,CACJC,MAAO,iFAKvBC,UAAW,CACP,GAAAC,CAAIC,GACA,OA9B0CC,EA8BzBlB,KA9BkCmB,EA8B5BC,UA9B2CC,EA8BxB,WAAW,MAAEC,EAAK,QAAEC,IAK1D,OAJIA,aAAyC,EAASA,EAAQC,gBAC1DF,EAAMG,aAAeF,EAAQG,cAC7BJ,EAAMK,UAAYJ,EAAQK,YAEvBN,CACX,EAlCD,KAFgEO,OA8B7B,KA5BxBA,EAAIC,WAAU,SAAUC,EA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,IAAMC,EAAKd,EAAUe,KAAKF,GAAS,CAAE,MAAOG,GAAKL,EAAOK,EAAI,CAAE,CAC1F,SAASC,EAASJ,GAAS,IAAMC,EAAKd,EAAiB,MAAEa,GAAS,CAAE,MAAOG,GAAKL,EAAOK,EAAI,CAAE,CAC7F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBL,EAAIK,EAAQ,IAAIL,GAAE,SAAUE,GAAWA,EAAQG,EAAQ,KAIjBO,KAAKR,EAAWK,EAAW,CAC7GH,GAAMd,EAAYA,EAAUqB,MAAMxB,EAASC,GAAc,KAAKiB,OAClE,IAPwC,IAAUlB,EAASC,EAAYU,EAAGR,CAqD9E,G","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/external commonjs \"next-auth/providers/azure-ad\"","webpack://snokam/./src/options.tsx","webpack://snokam/external commonjs \"next-auth\"","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/compat get default export","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"@azure/msal-node\"","webpack://snokam/./src/server/token.tsx","webpack://snokam/external commonjs \"next-auth/jwt\"","webpack://snokam/external commonjs \"next-auth/next\"","webpack://snokam/./src/server.tsx","webpack://snokam/./src/server/handler.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"snokam\"] = factory();\n\telse\n\t\troot[\"snokam\"] = factory();\n})(this, () => {\nreturn ","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/providers/azure-ad\");","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport NextAuth from \"next-auth\";\nimport AzureADProvider from \"next-auth/providers/azure-ad\";\nexport const getNextAuthOptions = (config) => ({\n secret: config.nextAuthSecret,\n pages: {\n signIn: \"/auth/login\",\n },\n providers: [\n AzureADProvider({\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n tenantId: config.tenantId,\n authorization: {\n params: {\n scope: \"openid profile email offline_access https://graph.microsoft.com/User.Read\",\n },\n },\n }),\n ],\n callbacks: {\n jwt(_a) {\n return __awaiter(this, arguments, void 0, function* ({ token, account }) {\n if (account === null || account === void 0 ? void 0 : account.access_token) {\n token.refreshToken = account.refresh_token;\n token.expiresAt = account.expires_at;\n }\n return token;\n });\n },\n },\n});\nexport default (config) => NextAuth(getNextAuthOptions(config));\n","module.exports = require(\"next-auth\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@azure/msal-node\");","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { ConfidentialClientApplication } from \"@azure/msal-node\";\nexport const getServerToken = (props) => __awaiter(void 0, void 0, void 0, function* () {\n const { scopes } = props;\n const cca = new ConfidentialClientApplication({\n auth: {\n clientId: `${props.clientId}`,\n authority: `https://login.microsoftonline.com/${props.tenantId}/oauth2/v2.0`,\n clientSecret: `${props.secret}`,\n },\n });\n const response = yield cca\n .acquireTokenByClientCredential({\n scopes: scopes.map((scope) => scope.replace(\"user_impersonation\", \".default\")),\n })\n .catch((e) => {\n console.error(e);\n throw e;\n });\n return `Bearer ${response === null || response === void 0 ? void 0 : response.accessToken}`;\n});\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/jwt\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/next\");","import { getServerToken } from \"./server/token\";\nimport { default as Routes } from \"./options\";\nimport { default as Token } from \"./server/handler\";\nexport { getServerToken };\nexport { getServerSession } from \"next-auth/next\";\nexport default {\n Routes,\n Token,\n};\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { getToken } from \"next-auth/jwt\";\nimport { ConfidentialClientApplication } from \"@azure/msal-node\";\nimport { getServerSession } from \"next-auth\";\nimport { getNextAuthOptions } from \"../options\";\nexport default function handler(props) {\n return __awaiter(this, void 0, void 0, function* () {\n const { req, res, authConfig } = props;\n const session = yield getServerSession(req, res, getNextAuthOptions(authConfig));\n if (!(session === null || session === void 0 ? void 0 : session.user)) {\n return res.status(401).end(\"Not authenticated\");\n }\n if (!req.body.scope) {\n return res.status(400).end(\"Invalid or missing scope\");\n }\n try {\n const { nextAuthSecret } = authConfig;\n const refetchTokenResult = yield getToken({ req, secret: nextAuthSecret });\n if (!refetchTokenResult) {\n return res.status(500).end(\"Failed to get refetch token\");\n }\n const cca = new ConfidentialClientApplication({\n auth: {\n clientId: authConfig.clientId,\n clientSecret: authConfig.clientSecret,\n authority: `https://login.microsoftonline.com/${authConfig.tenantId}`,\n },\n });\n const accessTokenResult = yield cca.acquireTokenByRefreshToken({\n scopes: [req.body.scope],\n refreshToken: refetchTokenResult === null || refetchTokenResult === void 0 ? void 0 : refetchTokenResult.refreshToken,\n });\n if (!accessTokenResult) {\n return res.status(500).end(\"Failed to get access token\");\n }\n return res.status(200).json({\n accessToken: accessTokenResult === null || accessTokenResult === void 0 ? void 0 : accessTokenResult.accessToken,\n expiresOn: Math.floor(accessTokenResult.expiresOn.getTime() / 1000),\n });\n }\n catch (e) {\n console.error(\"Token exchange error:\", e);\n res.status(500).end(\"Token exchange failed\");\n }\n });\n}\n"],"names":["root","factory","exports","module","define","amd","this","require","getNextAuthOptions","config","secret","nextAuthSecret","pages","signIn","providers","clientId","clientSecret","tenantId","authorization","params","scope","callbacks","jwt","_a","thisArg","_arguments","arguments","generator","token","account","access_token","refreshToken","refresh_token","expiresAt","expires_at","P","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","getServerToken","props","__awaiter","scopes","cca","ConfidentialClientApplication","auth","authority","response","acquireTokenByClientCredential","map","replace","catch","console","error","accessToken","Routes","Token","req","res","authConfig","session","getServerSession","user","status","end","body","refetchTokenResult","getToken","accessTokenResult","acquireTokenByRefreshToken","json","expiresOn","Math","floor","getTime"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"server.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,kCCTTH,EAAOD,QAAUK,QAAQ,Y,sFCAzB,MAAM,EAA+BA,QAAQ,gC,aCAtC,MAAMC,EAAuB,KAChC,MAAMC,EAA8B,oBAAXC,OACnBC,EAASF,GAAaC,OAAOE,SAASC,SAASC,SAAS,SACxDC,EAAS,CACXC,MAAO,6EAKX,OAHIP,IACAM,EAAOE,YAAcN,EAAS,iBAAmB,aAE9CI,CAAM,ECGV,MAAMG,EAAsBC,IACxB,CACHC,OAAQD,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,KAAK7F,OAClBuB,aAAcuE,aAA+D,EAASA,EAAmBvE,eAE7G,OAAKyE,EAGEV,EAAIK,OAAO,KAAKO,KAAK,CACxBhB,YAAac,aAA6D,EAASA,EAAkBd,YACrGiB,UAAWC,KAAKC,MAAML,EAAkBG,UAAUG,UAAY,OAJvDhB,EAAIK,OAAO,KAAKC,IAAI,6BAMnC,CACA,MAAOzD,GACH6C,QAAQC,MAAM,wBAAyB9C,GACvCmD,EAAIK,OAAO,KAAKC,IAAI,wBACxB,CACJ,EAlDO,KAFgEjE,OAcxC,KAZbA,EAAIC,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKd,EAAUe,KAAKF,GAAS,CAAE,MAAOG,GAAKL,EAAOK,EAAI,CAAE,CAC1F,SAASC,EAASJ,GAAS,IAAMC,EAAKd,EAAiB,MAAEa,GAAS,CAAE,MAAOG,GAAKL,EAAOK,EAAI,CAAE,CAC7F,SAASF,EAAKI,GAJlB,IAAeL,EAIaK,EAAOC,KAAOT,EAAQQ,EAAOL,QAJ1CA,EAIyDK,EAAOL,MAJhDA,aAAiBL,EAAIK,EAAQ,IAAIL,GAAE,SAAUE,GAAWA,EAAQG,EAAQ,KAIjBO,KAAKR,EAAWK,EAAW,CAC7GH,GAAMd,EAAYA,EAAUqB,MAAMxB,EAASC,GAAc,KAAKiB,OAClE,IAPwC,IAAUlB,EAASC,EAAYU,EAAGR,CAqD9E,G","sources":["webpack://snokam/webpack/universalModuleDefinition","webpack://snokam/external commonjs \"next-auth\"","webpack://snokam/external commonjs \"next-auth/providers/azure-ad\"","webpack://snokam/./src/utils/params.ts","webpack://snokam/./src/options.tsx","webpack://snokam/webpack/bootstrap","webpack://snokam/webpack/runtime/compat get default export","webpack://snokam/webpack/runtime/define property getters","webpack://snokam/webpack/runtime/hasOwnProperty shorthand","webpack://snokam/webpack/runtime/make namespace object","webpack://snokam/external commonjs \"@azure/msal-node\"","webpack://snokam/./src/server/token.tsx","webpack://snokam/external commonjs \"next-auth/jwt\"","webpack://snokam/external commonjs \"next-auth/next\"","webpack://snokam/./src/server.tsx","webpack://snokam/./src/server/handler.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"snokam\"] = factory();\n\telse\n\t\troot[\"snokam\"] = factory();\n})(this, () => {\nreturn ","module.exports = require(\"next-auth\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/providers/azure-ad\");","export const getDefaultAuthParams = () => {\n const isBrowser = typeof window !== \"undefined\";\n const isTest = isBrowser && window.location.hostname.includes(\"test.\");\n const params = {\n scope: `openid profile email offline_access https://graph.microsoft.com/User.Read`,\n };\n if (isBrowser) {\n params.domain_hint = isTest ? \"test.snokam.no\" : \"snokam.no\";\n }\n return params;\n};\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport NextAuth from \"next-auth\";\nimport AzureADProvider from \"next-auth/providers/azure-ad\";\nimport { getDefaultAuthParams } from \"./utils/params\";\nexport const getNextAuthOptions = (config) => {\n return {\n secret: config.nextAuthSecret,\n pages: {\n signIn: \"/auth/login\",\n },\n providers: [\n AzureADProvider({\n clientId: config.clientId,\n clientSecret: config.clientSecret,\n tenantId: config.tenantId,\n authorization: {\n params: getDefaultAuthParams(),\n },\n }),\n ],\n callbacks: {\n jwt(_a) {\n return __awaiter(this, arguments, void 0, function* ({ token, account }) {\n if (account === null || account === void 0 ? void 0 : account.access_token) {\n token.refreshToken = account.refresh_token;\n token.expiresAt = account.expires_at;\n }\n return token;\n });\n },\n },\n };\n};\nexport default (config) => NextAuth(getNextAuthOptions(config));\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@azure/msal-node\");","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { ConfidentialClientApplication } from \"@azure/msal-node\";\nexport const getServerToken = (props) => __awaiter(void 0, void 0, void 0, function* () {\n const { scopes } = props;\n const cca = new ConfidentialClientApplication({\n auth: {\n clientId: `${props.clientId}`,\n authority: `https://login.microsoftonline.com/${props.tenantId}/oauth2/v2.0`,\n clientSecret: `${props.secret}`,\n },\n });\n const response = yield cca\n .acquireTokenByClientCredential({\n scopes: scopes.map((scope) => scope.replace(\"user_impersonation\", \".default\")),\n })\n .catch((e) => {\n console.error(e);\n throw e;\n });\n return `Bearer ${response === null || response === void 0 ? void 0 : response.accessToken}`;\n});\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/jwt\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"next-auth/next\");","import { getServerToken } from \"./server/token\";\nimport { default as Routes } from \"./options\";\nimport { default as Token } from \"./server/handler\";\nexport { getServerToken };\nexport { getServerSession } from \"next-auth/next\";\nexport default {\n Routes,\n Token,\n};\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { getToken } from \"next-auth/jwt\";\nimport { ConfidentialClientApplication } from \"@azure/msal-node\";\nimport { getServerSession } from \"next-auth\";\nimport { getNextAuthOptions } from \"../options\";\nexport default function handler(props) {\n return __awaiter(this, void 0, void 0, function* () {\n const { req, res, authConfig } = props;\n const session = yield getServerSession(req, res, getNextAuthOptions(authConfig));\n if (!(session === null || session === void 0 ? void 0 : session.user)) {\n return res.status(401).end(\"Not authenticated\");\n }\n if (!req.body.scope) {\n return res.status(400).end(\"Invalid or missing scope\");\n }\n try {\n const { nextAuthSecret } = authConfig;\n const refetchTokenResult = yield getToken({ req, secret: nextAuthSecret });\n if (!refetchTokenResult) {\n return res.status(500).end(\"Failed to get refetch token\");\n }\n const cca = new ConfidentialClientApplication({\n auth: {\n clientId: authConfig.clientId,\n clientSecret: authConfig.clientSecret,\n authority: `https://login.microsoftonline.com/${authConfig.tenantId}`,\n },\n });\n const accessTokenResult = yield cca.acquireTokenByRefreshToken({\n scopes: [req.body.scope],\n refreshToken: refetchTokenResult === null || refetchTokenResult === void 0 ? void 0 : refetchTokenResult.refreshToken,\n });\n if (!accessTokenResult) {\n return res.status(500).end(\"Failed to get access token\");\n }\n return res.status(200).json({\n accessToken: accessTokenResult === null || accessTokenResult === void 0 ? void 0 : accessTokenResult.accessToken,\n expiresOn: Math.floor(accessTokenResult.expiresOn.getTime() / 1000),\n });\n }\n catch (e) {\n console.error(\"Token exchange error:\", e);\n res.status(500).end(\"Token exchange failed\");\n }\n });\n}\n"],"names":["root","factory","exports","module","define","amd","this","require","getDefaultAuthParams","isBrowser","window","isTest","location","hostname","includes","params","scope","domain_hint","getNextAuthOptions","config","secret","nextAuthSecret","pages","signIn","providers","clientId","clientSecret","tenantId","authorization","callbacks","jwt","_a","thisArg","_arguments","arguments","generator","token","account","access_token","refreshToken","refresh_token","expiresAt","expires_at","P","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","getServerToken","props","__awaiter","scopes","cca","ConfidentialClientApplication","auth","authority","response","acquireTokenByClientCredential","map","replace","catch","console","error","accessToken","Routes","Token","req","res","authConfig","session","getServerSession","user","status","end","body","refetchTokenResult","getToken","accessTokenResult","acquireTokenByRefreshToken","json","expiresOn","Math","floor","getTime"],"sourceRoot":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDefaultAuthParams: () => Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snokam/auth",
|
|
3
3
|
"description": "Snøkam auth components",
|
|
4
|
-
"version": "2.2.0-alpha.
|
|
4
|
+
"version": "2.2.0-alpha.5",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
]
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "1c01b1c74d97fd0e7b3ff235e542eb749bee1611"
|
|
71
71
|
}
|