@ankhorage/atlas 0.19.0 → 0.19.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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +4 -4
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page/build-manifest.json +1 -1
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page/build-manifest.json +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/auth/github/callback/route.js +2 -2
- package/.next/server/app/api/auth/github/callback/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/github/login/route.js +2 -2
- package/.next/server/app/api/auth/github/login/route.js.nft.json +1 -1
- package/.next/server/app/api/auth/github/logout/route.js +2 -2
- package/.next/server/app/api/auth/github/logout/route.js.nft.json +1 -1
- package/.next/server/app/api/dependency-graph/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/retry/route.js +3 -3
- package/.next/server/app/api/workspace/retry/route.js.nft.json +1 -1
- package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next/server/app/page/build-manifest.json +1 -1
- package/.next/server/app/page/server-reference-manifest.json +5 -5
- package/.next/server/app/page.js +3 -3
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/chunks/[externals]__16594cb._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__112op4w._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__112op4w._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__1z32dpt._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__1z32dpt._.js.map +1 -0
- package/.next/server/chunks/[turbopack]_runtime.js +0 -132
- package/.next/server/chunks/[turbopack]_runtime.js.map +4 -5
- package/.next/server/chunks/_0clm3_5._.js +3 -0
- package/.next/server/chunks/_0clm3_5._.js.map +1 -0
- package/.next/server/chunks/_12-q8rr._.js +3 -0
- package/.next/server/chunks/_12-q8rr._.js.map +1 -0
- package/.next/server/chunks/_1m2ujwq._.js +3 -0
- package/.next/server/chunks/_1m2ujwq._.js.map +1 -0
- package/.next/server/chunks/_1upfrua._.js +3 -0
- package/.next/server/chunks/_1upfrua._.js.map +1 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0_6mxrx._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1rpv02p._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__1qwwuix._.js.map → [root-of-the-server]__1rpv02p._.js.map} +1 -1
- package/.next/server/chunks/ssr/[turbopack]_runtime.js +0 -132
- package/.next/server/chunks/ssr/[turbopack]_runtime.js.map +4 -5
- package/.next/server/chunks/ssr/{_0itx4l8._.js → _0lahb16._.js} +4 -4
- package/.next/server/chunks/ssr/_0lahb16._.js.map +1 -0
- package/.next/server/chunks/ssr/{_0jl3v86._.js → _14-yori._.js} +4 -21
- package/.next/server/chunks/ssr/_14-yori._.js.map +1 -0
- package/.next/server/middleware-build-manifest.js +4 -4
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +6 -6
- package/.next/static/chunks/turbopack-16xk2dc34e79s.js +1 -0
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/package.json +1 -3
- package/paradox/badges/npm.svg +3 -3
- package/paradox/diagrams/architecture-overview.mmd +9 -10
- package/paradox/diagrams/export-graph.mmd +2 -3
- package/paradox/diagrams/module-relationships.mmd +7 -7
- package/paradox/index.html +138 -177
- package/paradox/paradox.json +295 -519
- package/src/app/api/auth/github/callback/route.ts +5 -8
- package/src/app/api/auth/github/login/route.ts +6 -10
- package/src/app/api/auth/github/logout/route.ts +5 -2
- package/src/features/github-auth/adapters/inbound/next/createGitHubAuthCookieStores.ts +58 -0
- package/src/features/github-auth/adapters/inbound/next/createGitHubCallbackRoute.ts +9 -39
- package/src/features/github-auth/adapters/inbound/next/createGitHubLogoutRoute.ts +3 -9
- package/src/features/github-auth/adapters/inbound/next/githubAuthCookies.ts +102 -14
- package/src/features/github-auth/adapters/inbound/next/readGitHubAuthViewAsync.ts +7 -7
- package/src/features/github-auth/composition/createGitHubAuthAdapterAsync.ts +23 -48
- package/.next/server/chunks/[externals]__047_j9_._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0kl17_6._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0kl17_6._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__0zc0_9_._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0zc0_9_._.js.map +0 -1
- package/.next/server/chunks/[root-of-the-server]__1-qgr16._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__1-qgr16._.js.map +0 -1
- package/.next/server/chunks/_0-0lsnu._.js +0 -3
- package/.next/server/chunks/_0-0lsnu._.js.map +0 -1
- package/.next/server/chunks/_0fcwlfe._.js +0 -20
- package/.next/server/chunks/_0fcwlfe._.js.map +0 -1
- package/.next/server/chunks/_0y7dqpe._.js +0 -20
- package/.next/server/chunks/_0y7dqpe._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__1qwwuix._.js +0 -3
- package/.next/server/chunks/ssr/_0itx4l8._.js.map +0 -1
- package/.next/server/chunks/ssr/_0jl3v86._.js.map +0 -1
- package/.next/static/chunks/turbopack-07w1w1kq0_rvo.js +0 -1
- package/src/features/github-auth/adapters/outbound/postgres/createPostgresGitHubAuthPersistence.ts +0 -235
- package/src/features/github-auth/ports/githubAuthPersistence.ts +0 -18
- /package/.next/server/chunks/{[externals]__047_j9_._.js.map → [externals]__16594cb._.js.map} +0 -0
- /package/.next/static/{jK4WG3twdKtlEqfqG7nM8 → NwI5a9X0nGevMfhoRcBQT}/_buildManifest.js +0 -0
- /package/.next/static/{jK4WG3twdKtlEqfqG7nM8 → NwI5a9X0nGevMfhoRcBQT}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{jK4WG3twdKtlEqfqG7nM8 → NwI5a9X0nGevMfhoRcBQT}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,{otherChunks:["static/chunks/1inwntv0b4r-7.js","static/chunks/2vhk3g7voy753.js","static/chunks/2xdvt7r80o5vc.js","static/chunks/34wvn5zw0a69w.js"],runtimeModuleIds:[94553]}]),(()=>{let e;if(!Array.isArray(globalThis.TURBOPACK))return;var t,r=function(){if(null!=self.TURBOPACK_ASSET_SUFFIX)return self.TURBOPACK_ASSET_SUFFIX;let e=document?.currentScript?.getAttribute?.("src")??"",t=e.indexOf("?");return t>=0?e.slice(t):""}(),n=((t=n||{})[t.Runtime=0]="Runtime",t[t.Parent=1]="Parent",t[t.Update=2]="Update",t);let o=new WeakMap;function i(e,t){this.m=e,this.e=t}let l=i.prototype,u=Object.prototype.hasOwnProperty,s="u">typeof Symbol&&Symbol.toStringTag;function c(e,t,r){u.call(e,t)||Object.defineProperty(e,t,r)}function a(e,t){let r=e[t];return r||(r=f(t),e[t]=r),r}function f(e){return{exports:{},error:void 0,id:e,namespaceObject:void 0}}function p(e,t,r){c(e,"__esModule",{value:!0}),s&&c(e,s,{value:"Module"});let n=0;for(;n<t.length;){let r=t[n++],o=t[n++];if("number"==typeof o)if(0===o)c(e,r,{value:t[n++],enumerable:!0,writable:!1});else throw Error(`unexpected tag: ${o}`);else"function"==typeof t[n]?c(e,r,{get:o,set:t[n++],enumerable:!0}):c(e,r,{get:o,enumerable:!0})}r||Object.seal(e)}function h(e,t){(null!=t?a(this.c,t):this.m).exports=e}l.s=function(e,t,r){let n,o;null!=t?o=(n=a(this.c,t)).exports:(n=this.m,o=this.e),n.namespaceObject=o,p(o,e,r)},l.j=function(e,t){let r,n;null!=t?n=(r=a(this.c,t)).exports:(r=this.m,n=this.e);let i=function(e,t){let r=o.get(e);if(!r){o.set(e,r=[]);let n=e=>{if("default"!==e){for(let t of r)if(u.call(t,e))return t}};e.exports=e.namespaceObject=new Proxy(t,{get(e,t){if(u.call(e,t)||"default"===t||"__esModule"===t)return Reflect.get(e,t);let r=n(t);return r&&Reflect.get(r,t)},set:()=>!1,defineProperty:()=>!1,deleteProperty:()=>!1,has:(e,t)=>!!Reflect.has(e,t)||"default"!==t&&"__esModule"!==t&&void 0!==n(t),ownKeys(e){let t=Reflect.ownKeys(e);for(let e of r)for(let r of Reflect.ownKeys(e))"default"===r||t.includes(r)||t.push(r);return t},getOwnPropertyDescriptor(e,t){let r=Reflect.getOwnPropertyDescriptor(e,t);if(r||"default"===t||"__esModule"===t)return r;let o=n(t);if(o)return{enumerable:!0,configurable:!0,get:()=>Reflect.get(o,t)}}})}return r}(r,n);"object"==typeof e&&null!==e&&i.push(e)},l.v=h,l.n=function(e,t){let r;(r=null!=t?a(this.c,t):this.m).exports=r.namespaceObject=e};let d=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,m=[null,d({}),d([]),d(d)];function y(e,t,r){let n=[],o=-1;for(let t=e;("object"==typeof t||"function"==typeof t)&&!m.includes(t);t=d(t))for(let r of Object.getOwnPropertyNames(t))n.push(r,function(e,t){return()=>e[t]}(e,r)),-1===o&&"default"===r&&(o=n.length-1);return r&&o>=0||(o>=0?n.splice(o,1,0,e):n.push("default",0,e)),p(t,n),t}function g(e){let t=I(e,this.m);if(t.namespaceObject)return t.namespaceObject;let r=t.exports;return t.namespaceObject=y(r,"function"==typeof r?function(...e){return r.apply(this,e)}:Object.create(null),r&&r.__esModule)}function b(e){let t=e.indexOf("#");-1!==t&&(e=e.substring(0,t));let r=e.indexOf("?");return -1!==r&&(e=e.substring(0,r)),e}l.i=g,l.A=function(e){return this.r(e)(g.bind(this))},l.t="function"==typeof require?require:function(){throw Error("Unexpected use of runtime require")},l.r=function(e){return I(e,this.m).exports},l.f=function(e){function t(t){if(t=b(t),u.call(e,t))return e[t].module();let r=Error(`Cannot find module '${t}'`);throw r.code="MODULE_NOT_FOUND",r}return t.keys=()=>Object.keys(e),t.resolve=t=>{if(t=b(t),u.call(e,t))return e[t].id();let r=Error(`Cannot find module '${t}'`);throw r.code="MODULE_NOT_FOUND",r},t.import=async e=>await t(e),t};let O=function(e){let t=new URL(e,"x:/"),r={};for(let e in t)r[e]=t[e];for(let t in r.href=e,r.pathname=e.replace(/[?#].*/,""),r.origin=r.protocol="",r.toString=r.toJSON=(...t)=>e,r)Object.defineProperty(this,t,{enumerable:!0,configurable:!0,value:r[t]})};function w(e,t){throw Error(`Invariant: ${t(e)}`)}O.prototype=URL.prototype,l.U=O,l.z=function(e){throw Error("dynamic usage of require is not supported")},l.g=globalThis;let v=Symbol("turbopack queues"),k=Symbol("turbopack exports"),j=Symbol("turbopack error");function C(){let e,t;return{promise:new Promise((r,n)=>{t=n,e=r}),resolve:e,reject:t}}function R(e){e&&1!==e.status&&(e.status=1,e.forEach(e=>e.queueCount--),e.forEach(e=>e.queueCount--?e.queueCount++:e()))}l.a=function(e,t){let r=this.m,n=t?Object.assign([],{status:-1}):void 0,o=new Set,{resolve:i,reject:l,promise:u}=C(),s=Object.assign(u,{[k]:r.exports,[v]:e=>{n&&e(n),o.forEach(e),s.catch(()=>{})}}),c={get:()=>s,set(e){e!==s&&(s[k]=e)}};Object.defineProperty(r,"exports",c),Object.defineProperty(r,"namespaceObject",c),e(function(e){let t=e.map(e=>{if(null!==e&&"object"==typeof e){if(v in e)return e;if(null!=e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then){let t=Object.assign([],{status:0}),r={[k]:{},[v]:e=>e(t)};return e.then(e=>{r[k]=e,R(t)},e=>{r[j]=e,R(t)}),r}}return{[k]:e,[v]:()=>{}}}),r=()=>t.map(e=>{if(e[j])throw e[j];return e[k]}),{promise:i,resolve:l}=C(),u=Object.assign(()=>l(r),{queueCount:0});function s(e){e!==n&&!o.has(e)&&(o.add(e),e&&0===e.status&&(u.queueCount++,e.push(u)))}return t.map(e=>e[v](s)),u.queueCount?i:r()},function(e){e?l(s[j]=e):i(s[k]),R(n)}),n&&-1===n.status&&(n.status=0)};let U=i.prototype,P="string"==typeof TURBOPACK_CHUNK_BASE_PATH?TURBOPACK_CHUNK_BASE_PATH:"/_next/",_=new Map;l.M=_;let $=new Map,A=new Map,T=new Map;async function E(e,t,r){let n;if("string"==typeof r)return function(e,t,r){return M(e,t,r)}(e,t,q(r));let o=r.included||[],i=o.map(e=>!!_.has(e)||$.get(e));if(i.length>0&&i.every(e=>e))return void await Promise.all(i);for(let i of(n=M(e,t,q(r.path)),o))$.has(i)||$.set(i,n);await n}U.l=function(e){return E(n.Parent,this.m.id,e)};let S=Promise.resolve(void 0),x=new WeakMap;function M(t,r,o){let i=e.loadChunkCached(t,o),l=x.get(i);if(void 0===l){let e=x.set.bind(x,i,S);l=i.then(e).catch(e=>{let i;switch(t){case n.Runtime:i=`as a runtime dependency of chunk ${r}`;break;case n.Parent:i=`from module ${r}`;break;case n.Update:i="from an HMR update";break;default:w(t,e=>`Unknown source type: ${e}`)}let l=Error(`Failed to load chunk ${o} ${i}${e?`: ${e}`:""}`,e?{cause:e}:void 0);throw l.name="ChunkLoadError",l}),x.set(i,l)}return l}U.L=function(e){var t,r;return t=n.Parent,r=this.m.id,M(t,r,e)};U.R=function(e){let t=this.r(e);return t?.default??t},U.P=function(e){return`/ROOT/${e??""}`},U.F=function(e){return e?`file:///ROOT/${e.split("/").map(encodeURIComponent).join("/")}`:"file:///ROOT/"},U.q=function(e,t){h.call(this,`${e}${r}`,t)};let K=/[^A-Za-z0-9\-_.!~*'()/]/;function q(e,t=P){let n=K.test(e)?e.split("/").map(encodeURIComponent).join("/"):e;return`${t}${n}${r}`}function N(e,t){let r,n=e.indexOf("?");if(-1!==n)r=n;else{let t=e.indexOf("#");r=-1!==t?t:e.length}return r>=t.length&&e.startsWith(t,r-t.length)}U.b=P,U.X=r,U.h=q;function B(e){return N(e,".css")}let L={};l.c=L;let I=(e,t)=>{let r=L[e];if(r){if(r.error)throw r.error;return r}return H(e,n.Parent,t.id)};function H(e,t,r){let n=_.get(e);if("function"!=typeof n)throw Error(function(e,t,r){let n;switch(t){case 0:n=`as a runtime entry of chunk ${r}`;break;case 1:n=`because it was required from module ${r}`;break;case 2:n="because of an HMR update";break;default:w(t,e=>`Unknown source type: ${e}`)}return`Module ${e} was instantiated ${n}, but the module factory is not available.`}(e,t,r));let o=f(e),l=o.exports;L[e]=o;let u=new i(o,l);try{n(u,o,l)}catch(e){throw o.error=e,e}return o.namespaceObject&&o.exports!==o.namespaceObject&&y(o.exports,o.namespaceObject),o}function F(t){let r;if(!Array.isArray(t))return e.registerChunk(void 0,t);let n=function(e){if("string"==typeof e)return e;if(e)return{src:e.getAttribute("src")};if("u">typeof TURBOPACK_NEXT_CHUNK_URLS)return{src:TURBOPACK_NEXT_CHUNK_URLS.pop()};throw Error("chunk path empty but not in a worker")}(t[0]);return 2===t.length?r=t[1]:(r=void 0,!function(e,t){let r=1;for(;r<e.length;){let n,o=r+1;for(;o<e.length&&"function"!=typeof e[o];)o++;if(o===e.length)throw Error("malformed chunk format, expected a factory function");let i=e[o];for(let i=r;i<o;i++){let r=e[i],o=t.get(r);if(o){n=o;break}}let l=n??i,u=!1;for(let n=r;n<o;n++){let r=e[n];t.has(r)||(u||(l===i&&Object.defineProperty(i,"name",{value:"module evaluation"}),u=!0),t.set(r,l))}r=o+1}}(t,_)),e.registerChunk(n,r)}let D=new Map;function W(e){let t=D.get(e);if(!t){let r,n;t={resolved:!1,loadingStarted:!1,retryAttempts:0,promise:new Promise((e,t)=>{r=e,n=t}),resolve:()=>{t.resolved=!0,r()},reject:n},D.set(e,t)}return t}function X(e,t,r,n,o){!(null==n||n instanceof DOMException&&"NetworkError"===n.name)||r.retryAttempts>=1||D.get(t)!==r?(D.get(t)===r&&D.delete(t),r.reject(n)):(r.retryAttempts++,setTimeout(()=>{r.resolved||D.get(t)!==r||(o?o():(r.loadingStarted=!1,z(e,t)))},200+Math.floor(401*Math.random())))}function z(e,t){let r=W(t);if(r.loadingStarted)return r.promise;if(e===n.Runtime)return r.loadingStarted=!0,B(t)&&r.resolve(),r.promise;if("function"==typeof importScripts)if(B(t));else if(N(t,".js")){self.TURBOPACK_NEXT_CHUNK_URLS.push(t);try{importScripts(t)}catch(n){X(e,t,r,n)}}else throw Error(`can't infer type of chunk from URL ${t} in worker`);else{let n=decodeURI(t);if(B(t))if(document.querySelectorAll(`link[rel=stylesheet][href="${t}"],link[rel=stylesheet][href^="${t}?"],link[rel=stylesheet][href="${n}"],link[rel=stylesheet][href^="${n}?"]`).length>0)r.resolve();else{let n=()=>{let o=document.createElement("link");return o.rel="stylesheet",o.crossOrigin=null,o.href=t,o.onerror=()=>{let i=document.createComment("");o.replaceWith(i),X(e,t,r,void 0,()=>i.replaceWith(n()))},o.onload=()=>{r.resolve()},o};document.head.appendChild(n())}else if(N(t,".js")){let o=document.querySelectorAll(`script[src="${t}"],script[src^="${t}?"],script[src="${n}"],script[src^="${n}?"]`);if(o.length>0)for(let n of Array.from(o))n.addEventListener("error",()=>{n.remove(),X(e,t,r)},{once:!0});else{let n=document.createElement("script");n.crossOrigin=null,n.src=t,n.onerror=()=>{n.remove(),X(e,t,r)},document.head.appendChild(n)}}else throw Error(`can't infer type of chunk from URL ${t}`)}return r.loadingStarted=!0,r.promise}e={async registerChunk(e,t){let r;if(null!=e&&(r=function(e){if("string"==typeof e)return e;let t=decodeURIComponent(e.src.replace(/[?#].*$/,""));return t.startsWith(P)?t.slice(P.length):t}(e),W("string"==typeof e?q(e):e.src).resolve()),null!=t){for(let e of t.otherChunks)W(q("string"==typeof e?e:e.path));if(await Promise.all(t.otherChunks.map(e=>{var t;return t=r,E(n.Runtime,t,e)})),t.runtimeModuleIds.length>0)for(let e of t.runtimeModuleIds)!function(e,t){let r=L[t];if(r){if(r.error)throw r.error;return}H(t,n.Runtime,e)}(r,e)}},loadChunkCached:(e,t)=>z(e,t)};var J=globalThis.TURBOPACK;globalThis.TURBOPACK={push:F},J.forEach(F)})();
|
package/src/features/github-auth/adapters/outbound/postgres/createPostgresGitHubAuthPersistence.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'node:crypto';
|
|
2
|
-
|
|
3
|
-
import type { GitHubAuthorizationAttempt } from '@ankhorage/auth-github';
|
|
4
|
-
import type { AuthSession } from '@ankhorage/contracts/auth';
|
|
5
|
-
import { Pool, type PoolClient } from 'pg';
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
GitHubAuthPersistence,
|
|
9
|
-
GitHubAuthSessionWriteState,
|
|
10
|
-
} from '@/features/github-auth/ports/githubAuthPersistence';
|
|
11
|
-
|
|
12
|
-
/*** Create encrypted, server-only PostgreSQL persistence for the GitHub OAuth port. */
|
|
13
|
-
export function createPostgresGitHubAuthPersistence(
|
|
14
|
-
configuration: PostgresGitHubAuthPersistenceConfiguration
|
|
15
|
-
): GitHubAuthPersistence {
|
|
16
|
-
const key = readEncryptionKey(configuration.encryptionKey);
|
|
17
|
-
const pool = new Pool({
|
|
18
|
-
connectionString: configuration.databaseUrl,
|
|
19
|
-
max: 5,
|
|
20
|
-
ssl: configuration.tls === false ? false : { rejectUnauthorized: true },
|
|
21
|
-
});
|
|
22
|
-
return {
|
|
23
|
-
createAuthorizationAttemptStore: sessionId =>
|
|
24
|
-
createAuthorizationAttemptStore(pool, key, sessionId),
|
|
25
|
-
createSessionStore: (sessionId, writeState = 'active') =>
|
|
26
|
-
createSessionStore(pool, key, sessionId, writeState),
|
|
27
|
-
rotateSessionAsync: (previousSessionId, nextSessionId, session) =>
|
|
28
|
-
rotateSessionAsync(pool, key, previousSessionId, nextSessionId, session),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/*** Atomically replace the adapter-created pre-login session so crashes and database failures never authorize both cookie identifiers. */
|
|
33
|
-
async function rotateSessionAsync(
|
|
34
|
-
pool: Pool,
|
|
35
|
-
key: Buffer,
|
|
36
|
-
previousSessionId: string,
|
|
37
|
-
nextSessionId: string,
|
|
38
|
-
session: AuthSession
|
|
39
|
-
): Promise<void> {
|
|
40
|
-
if (previousSessionId === nextSessionId)
|
|
41
|
-
throw new Error('GitHub OAuth session rotation requires a new identifier.');
|
|
42
|
-
const previousSessionHash = hashOpaqueId(previousSessionId);
|
|
43
|
-
const nextSessionHash = hashOpaqueId(nextSessionId);
|
|
44
|
-
const payload = encryptPayload(session, key, sessionAad(nextSessionHash));
|
|
45
|
-
const client = await pool.connect();
|
|
46
|
-
try {
|
|
47
|
-
await client.query('BEGIN');
|
|
48
|
-
const previous = await client.query(
|
|
49
|
-
'SELECT 1 FROM atlas_oauth.sessions WHERE session_id_hash = $1 FOR UPDATE',
|
|
50
|
-
[previousSessionHash]
|
|
51
|
-
);
|
|
52
|
-
const next = await client.query(
|
|
53
|
-
'SELECT 1 FROM atlas_oauth.sessions WHERE session_id_hash = $1 FOR UPDATE',
|
|
54
|
-
[nextSessionHash]
|
|
55
|
-
);
|
|
56
|
-
if (previous.rowCount === 0) {
|
|
57
|
-
if (next.rowCount === 0)
|
|
58
|
-
throw new Error('GitHub OAuth session rotation source is unavailable.');
|
|
59
|
-
await client.query('COMMIT');
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (next.rowCount !== 0)
|
|
63
|
-
throw new Error('GitHub OAuth session rotation target already exists.');
|
|
64
|
-
await saveSessionAsync(client, nextSessionHash, payload, session.expiresAt, 'active');
|
|
65
|
-
await client.query('DELETE FROM atlas_oauth.sessions WHERE session_id_hash = $1', [
|
|
66
|
-
previousSessionHash,
|
|
67
|
-
]);
|
|
68
|
-
await client.query('COMMIT');
|
|
69
|
-
} catch (error) {
|
|
70
|
-
await client.query('ROLLBACK').catch(() => undefined);
|
|
71
|
-
throw error;
|
|
72
|
-
} finally {
|
|
73
|
-
client.release();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function createAuthorizationAttemptStore(pool: Pool, key: Buffer, sessionId: string) {
|
|
78
|
-
const sessionHash = hashOpaqueId(sessionId);
|
|
79
|
-
return {
|
|
80
|
-
create: async (attempt: GitHubAuthorizationAttempt): Promise<void> => {
|
|
81
|
-
const attemptHash = hashOpaqueId(attempt.attemptId);
|
|
82
|
-
const payload = encryptPayload(attempt, key, authorizationAttemptAad(sessionHash));
|
|
83
|
-
await pool.query(
|
|
84
|
-
`INSERT INTO atlas_oauth.authorization_attempts
|
|
85
|
-
(attempt_id_hash, browser_session_id_hash, encrypted_payload, expires_at)
|
|
86
|
-
VALUES ($1, $2, $3, to_timestamp($4 / 1000.0))`,
|
|
87
|
-
[attemptHash, sessionHash, payload, attempt.expiresAt]
|
|
88
|
-
);
|
|
89
|
-
},
|
|
90
|
-
consume: async (attemptId: string, now: number): Promise<GitHubAuthorizationAttempt | null> => {
|
|
91
|
-
const result = await pool.query<{ readonly encrypted_payload: string }>(
|
|
92
|
-
`DELETE FROM atlas_oauth.authorization_attempts
|
|
93
|
-
WHERE attempt_id_hash = $1
|
|
94
|
-
AND browser_session_id_hash = $2
|
|
95
|
-
AND expires_at > to_timestamp($3 / 1000.0)
|
|
96
|
-
RETURNING encrypted_payload`,
|
|
97
|
-
[hashOpaqueId(attemptId), sessionHash, now]
|
|
98
|
-
);
|
|
99
|
-
if (result.rowCount === 0) return null;
|
|
100
|
-
const [row] = result.rows;
|
|
101
|
-
return decryptPayload<GitHubAuthorizationAttempt>(
|
|
102
|
-
row.encrypted_payload,
|
|
103
|
-
key,
|
|
104
|
-
authorizationAttemptAad(sessionHash)
|
|
105
|
-
);
|
|
106
|
-
},
|
|
107
|
-
purgeExpired: async (now: number): Promise<void> => {
|
|
108
|
-
await pool.query(
|
|
109
|
-
'DELETE FROM atlas_oauth.authorization_attempts WHERE expires_at <= to_timestamp($1 / 1000.0)',
|
|
110
|
-
[now]
|
|
111
|
-
);
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function createSessionStore(
|
|
117
|
-
pool: Pool,
|
|
118
|
-
key: Buffer,
|
|
119
|
-
sessionId: string,
|
|
120
|
-
writeState: GitHubAuthSessionWriteState
|
|
121
|
-
) {
|
|
122
|
-
const sessionHash = hashOpaqueId(sessionId);
|
|
123
|
-
return {
|
|
124
|
-
get: async (): Promise<AuthSession | null> => {
|
|
125
|
-
const result = await pool.query<{
|
|
126
|
-
readonly encrypted_payload: string;
|
|
127
|
-
readonly expires_at: Date | null;
|
|
128
|
-
}>(
|
|
129
|
-
`SELECT encrypted_payload, expires_at
|
|
130
|
-
FROM atlas_oauth.sessions
|
|
131
|
-
WHERE session_id_hash = $1
|
|
132
|
-
AND status = 'active'`,
|
|
133
|
-
[sessionHash]
|
|
134
|
-
);
|
|
135
|
-
if (result.rowCount === 0) return null;
|
|
136
|
-
const [row] = result.rows;
|
|
137
|
-
if (row.expires_at !== null && row.expires_at.getTime() <= Date.now()) {
|
|
138
|
-
await pool.query('DELETE FROM atlas_oauth.sessions WHERE session_id_hash = $1', [
|
|
139
|
-
sessionHash,
|
|
140
|
-
]);
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
return decryptPayload<AuthSession>(row.encrypted_payload, key, sessionAad(sessionHash));
|
|
144
|
-
},
|
|
145
|
-
save: async (session: AuthSession): Promise<void> => {
|
|
146
|
-
await saveSessionAsync(
|
|
147
|
-
pool,
|
|
148
|
-
sessionHash,
|
|
149
|
-
encryptPayload(session, key, sessionAad(sessionHash)),
|
|
150
|
-
session.expiresAt,
|
|
151
|
-
writeState
|
|
152
|
-
);
|
|
153
|
-
},
|
|
154
|
-
clear: async (): Promise<void> => {
|
|
155
|
-
await pool.query('DELETE FROM atlas_oauth.sessions WHERE session_id_hash = $1', [
|
|
156
|
-
sessionHash,
|
|
157
|
-
]);
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/*** Write an encrypted session through either a pooled query or the rotation transaction. */
|
|
163
|
-
function saveSessionAsync(
|
|
164
|
-
database: Pool | PoolClient,
|
|
165
|
-
sessionHash: string,
|
|
166
|
-
payload: string,
|
|
167
|
-
expiresAt: number | undefined,
|
|
168
|
-
status: GitHubAuthSessionWriteState
|
|
169
|
-
): Promise<unknown> {
|
|
170
|
-
return database.query(
|
|
171
|
-
`INSERT INTO atlas_oauth.sessions
|
|
172
|
-
(session_id_hash, encrypted_payload, status, expires_at, encryption_key_version)
|
|
173
|
-
VALUES ($1, $2, $3, CASE WHEN $4::bigint IS NULL THEN NULL ELSE to_timestamp($4 / 1000.0) END, 1)
|
|
174
|
-
ON CONFLICT (session_id_hash) DO UPDATE
|
|
175
|
-
SET encrypted_payload = EXCLUDED.encrypted_payload,
|
|
176
|
-
status = EXCLUDED.status,
|
|
177
|
-
expires_at = EXCLUDED.expires_at,
|
|
178
|
-
encryption_key_version = EXCLUDED.encryption_key_version,
|
|
179
|
-
updated_at = now()`,
|
|
180
|
-
[sessionHash, payload, status, expiresAt ?? null]
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/*** Reject malformed deployment secrets before any OAuth record can be read or written. */
|
|
185
|
-
function readEncryptionKey(value: string): Buffer {
|
|
186
|
-
const key = Buffer.from(value, 'base64');
|
|
187
|
-
if (key.length !== 32 || key.toString('base64') !== value)
|
|
188
|
-
throw new Error('ATLAS_OAUTH_ENCRYPTION_KEY must be 32 Base64-encoded bytes.');
|
|
189
|
-
return key;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/*** Hash browser-controlled opaque identifiers before durable storage. */
|
|
193
|
-
function hashOpaqueId(value: string): string {
|
|
194
|
-
return createHash('sha256').update(value).digest('hex');
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/*** Encrypt one JSON payload with independent authenticated encryption material. */
|
|
198
|
-
function encryptPayload(value: unknown, key: Buffer, aad: string): string {
|
|
199
|
-
const iv = randomBytes(12);
|
|
200
|
-
const cipher = createCipheriv('aes-256-gcm', key, iv);
|
|
201
|
-
cipher.setAAD(Buffer.from(aad));
|
|
202
|
-
const ciphertext = Buffer.concat([cipher.update(JSON.stringify(value), 'utf8'), cipher.final()]);
|
|
203
|
-
return [iv, cipher.getAuthTag(), ciphertext].map(part => part.toString('base64')).join('.');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/*** Decrypt only an authenticated record bound to its storage role and opaque session identifier. */
|
|
207
|
-
function decryptPayload<T>(value: string, key: Buffer, aad: string): T {
|
|
208
|
-
const [ivText, tagText, ciphertextText, ...unexpected] = value.split('.');
|
|
209
|
-
if (unexpected.length > 0) throw new Error('Invalid encrypted OAuth record.');
|
|
210
|
-
const decipher = createDecipheriv('aes-256-gcm', key, Buffer.from(ivText, 'base64'));
|
|
211
|
-
decipher.setAAD(Buffer.from(aad));
|
|
212
|
-
decipher.setAuthTag(Buffer.from(tagText, 'base64'));
|
|
213
|
-
return JSON.parse(
|
|
214
|
-
Buffer.concat([
|
|
215
|
-
decipher.update(Buffer.from(ciphertextText, 'base64')),
|
|
216
|
-
decipher.final(),
|
|
217
|
-
]).toString('utf8')
|
|
218
|
-
) as T;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/*** Bind authorization attempts to their record purpose and their originating browser session. */
|
|
222
|
-
function authorizationAttemptAad(sessionHash: string): string {
|
|
223
|
-
return `atlas_oauth:authorization_attempt:v1:${sessionHash}`;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/*** Bind sessions to their record purpose and their opaque browser identifier. */
|
|
227
|
-
function sessionAad(sessionHash: string): string {
|
|
228
|
-
return `atlas_oauth:session:v1:${sessionHash}`;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
interface PostgresGitHubAuthPersistenceConfiguration {
|
|
232
|
-
readonly databaseUrl: string;
|
|
233
|
-
readonly encryptionKey: string;
|
|
234
|
-
readonly tls?: boolean;
|
|
235
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { GitHubAuthorizationAttemptStore, GitHubSessionStore } from '@ankhorage/auth-github';
|
|
2
|
-
import type { AuthSession } from '@ankhorage/contracts/auth';
|
|
3
|
-
|
|
4
|
-
/*** Define the host-owned durable storage boundary required by the published GitHub OAuth adapter. */
|
|
5
|
-
export interface GitHubAuthPersistence {
|
|
6
|
-
createAuthorizationAttemptStore(sessionId: string): GitHubAuthorizationAttemptStore;
|
|
7
|
-
createSessionStore(
|
|
8
|
-
sessionId: string,
|
|
9
|
-
writeState?: GitHubAuthSessionWriteState
|
|
10
|
-
): GitHubSessionStore;
|
|
11
|
-
rotateSessionAsync(
|
|
12
|
-
previousSessionId: string,
|
|
13
|
-
nextSessionId: string,
|
|
14
|
-
session: AuthSession
|
|
15
|
-
): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type GitHubAuthSessionWriteState = 'active' | 'pending';
|
/package/.next/server/chunks/{[externals]__047_j9_._.js.map → [externals]__16594cb._.js.map}
RENAMED
|
File without changes
|
|
File without changes
|
/package/.next/static/{jK4WG3twdKtlEqfqG7nM8 → NwI5a9X0nGevMfhoRcBQT}/_clientMiddlewareManifest.js
RENAMED
|
File without changes
|
|
File without changes
|