@pofsis-nbt/pofsis-auth 2.0.0 → 2.1.0
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/Documentation.md +151 -143
- package/README.md +143 -130
- package/dist/PofsisAuth.d.ts +1 -1
- package/dist/PofsisAuth.d.ts.map +1 -1
- package/dist/{PofsisAuthClient-CEw_lL5S.js → PofsisAuthClient-Duybofpq.js} +162 -46
- package/dist/PofsisAuthClient-Duybofpq.js.map +1 -0
- package/dist/PofsisAuthClient-c4lzLzjV.cjs +2 -0
- package/dist/PofsisAuthClient-c4lzLzjV.cjs.map +1 -0
- package/dist/{RequireAuth-CPhXupYh.cjs → RequireAuth-BkYhk-9p.cjs} +2 -2
- package/dist/{RequireAuth-CPhXupYh.cjs.map → RequireAuth-BkYhk-9p.cjs.map} +1 -1
- package/dist/{RequireAuth-DFa8_MR1.js → RequireAuth-DroX56rd.js} +67 -62
- package/dist/{RequireAuth-DFa8_MR1.js.map → RequireAuth-DroX56rd.js.map} +1 -1
- package/dist/auth/authLaunch.d.ts.map +1 -1
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/core/PofsisAuthClient.d.ts +2 -0
- package/dist/core/PofsisAuthClient.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/popupProtocol.d.ts +11 -1
- package/dist/core/popupProtocol.d.ts.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +2 -2
- package/dist/elements/index.d.ts.map +1 -1
- package/dist/elements.cjs +1 -1
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.js +8 -3
- package/dist/elements.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/pofsis-auth-elements.js +1 -1
- package/dist/pofsis-auth-elements.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/types.d.ts +13 -2
- package/dist/types.d.ts.map +1 -1
- package/docs/application-id-consumer-migration.md +180 -0
- package/docs/popup-integration.md +188 -162
- package/package.json +87 -87
- package/dist/PofsisAuthClient-B3YHqgZL.cjs +0 -2
- package/dist/PofsisAuthClient-B3YHqgZL.cjs.map +0 -1
- package/dist/PofsisAuthClient-CEw_lL5S.js.map +0 -1
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACvE,YAAY,EACR,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,cAAc,EACd,aAAa,GAChB,MAAM,UAAU,CAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const POPUP_MESSAGE_TYPE = "pofsis-auth:callback";
|
|
2
|
+
export declare const MODAL_INIT_MESSAGE_TYPE = "pofsis-auth:frame-init";
|
|
3
|
+
export declare const MODAL_READY_MESSAGE_TYPE = "pofsis-auth:frame-ready";
|
|
2
4
|
export type PopupCallbackMessage = {
|
|
3
5
|
type: typeof POPUP_MESSAGE_TYPE;
|
|
4
6
|
code?: string;
|
|
@@ -6,6 +8,14 @@ export type PopupCallbackMessage = {
|
|
|
6
8
|
error?: string;
|
|
7
9
|
correlationId?: string;
|
|
8
10
|
};
|
|
11
|
+
export type ModalProtocolMessage = {
|
|
12
|
+
type: typeof MODAL_INIT_MESSAGE_TYPE | typeof MODAL_READY_MESSAGE_TYPE;
|
|
13
|
+
state: string;
|
|
14
|
+
correlationId: string;
|
|
15
|
+
applicationId: string;
|
|
16
|
+
};
|
|
9
17
|
export declare function correlationFromState(state: string | null): string | undefined;
|
|
10
|
-
export declare function
|
|
18
|
+
export declare function relayAuthCallback(targetOrigin?: string): boolean;
|
|
19
|
+
/** @deprecated Use relayAuthCallback for both popup and modal callbacks. */
|
|
20
|
+
export declare const relayPopupCallback: typeof relayAuthCallback;
|
|
11
21
|
//# sourceMappingURL=popupProtocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popupProtocol.d.ts","sourceRoot":"","sources":["../../src/core/popupProtocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"popupProtocol.d.ts","sourceRoot":"","sources":["../../src/core/popupProtocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,yBAAyB,CAAA;AACxD,eAAO,MAAM,uBAAuB,2BAA2B,CAAA;AAC/D,eAAO,MAAM,wBAAwB,4BAA4B,CAAA;AAEjE,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,OAAO,kBAAkB,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,OAAO,uBAAuB,GAAG,OAAO,wBAAwB,CAAA;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,sBAIxD;AAED,wBAAgB,iBAAiB,CAAC,YAAY,SAAyB,WAmBtE;AAED,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,0BAAoB,CAAA"}
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./PofsisAuthClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./PofsisAuthClient-c4lzLzjV.cjs");exports.PofsisAuthClient=e.t,exports.createPofsisAuth=e.n,exports.relayAuthCallback=e.r,exports.relayPopupCallback=e.i;
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./PofsisAuthClient-Duybofpq.js";
|
|
2
|
+
export { r as PofsisAuthClient, t as createPofsisAuth, n as relayAuthCallback, e as relayPopupCallback };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/elements/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/elements/index.ts"],"names":[],"mappings":"AAeA,qBAAa,mBAAoB,SAAQ,WAAW;IAChD,MAAM,KAAK,kBAAkB,aAE5B;IACD,OAAO,CAAC,MAAM,CAAgC;IAC9C,OAAO,CAAC,MAAM,CAAiC;IAE/C,iBAAiB;IAGjB,oBAAoB;IAGpB,wBAAwB;IAIxB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,MAAM;YAkBA,MAAM;CAmCvB"}
|
package/dist/elements.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./PofsisAuthClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./PofsisAuthClient-c4lzLzjV.cjs");require("./core.cjs");var t=[`application-id`,`api-base-url`,`auth-url`,`scope`,`return-url`,`screen`,`method`,`login-hint`,`presentation`],n=class extends HTMLElement{static get observedAttributes(){return t}client=null;button=null;connectedCallback(){this.render()}disconnectedCallback(){this.client?.destroy()}attributeChangedCallback(){this.isConnected&&this.render()}required(e){let t=this.getAttribute(e)?.trim();if(!t)throw Error(`<pofsis-sign-in> requires ${e}`);return t}render(){this.client?.destroy(),this.client=e.n({applicationId:this.required(`application-id`),apiBaseUrl:this.required(`api-base-url`),authUrl:this.required(`auth-url`),scope:this.getAttribute(`scope`)||void 0});let t=this.textContent?.trim()||`Sign in`;this.replaceChildren(),this.button=document.createElement(`button`),this.button.type=`button`,this.button.part.add(`button`),this.button.textContent=t,this.button.addEventListener(`click`,()=>void this.launch()),this.append(this.button)}async launch(){if(!this.client||!this.button)return;this.button.disabled=!0;let e={presentation:[`popup`,`modal`,`redirect`].includes(this.getAttribute(`presentation`)||``)?this.getAttribute(`presentation`):`popup`,returnUrl:this.getAttribute(`return-url`)||void 0,screen:this.getAttribute(`screen`)||`login`,method:this.getAttribute(`method`)||void 0,loginHint:this.getAttribute(`login-hint`)||void 0};try{let t=await this.client.login(e);this.dispatchEvent(new CustomEvent(`pofsis-auth-${t.status}`,{bubbles:!0,composed:!0,detail:t}))}catch(e){this.dispatchEvent(new CustomEvent(`pofsis-auth-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}finally{this.button.disabled=!1}}};customElements.get(`pofsis-sign-in`)||customElements.define(`pofsis-sign-in`,n),exports.PofsisSignInElement=n;
|
|
2
2
|
//# sourceMappingURL=elements.cjs.map
|
package/dist/elements.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.cjs","names":[],"sources":["../src/elements/index.ts"],"sourcesContent":["import { createPofsisAuth, type PofsisAuthClient } from '../core'\
|
|
1
|
+
{"version":3,"file":"elements.cjs","names":[],"sources":["../src/elements/index.ts"],"sourcesContent":["import { createPofsisAuth, type PofsisAuthClient } from '../core'\nimport type { AuthLaunchOptions } from '../types'\n\nconst observed = [\n 'application-id',\n 'api-base-url',\n 'auth-url',\n 'scope',\n 'return-url',\n 'screen',\n 'method',\n 'login-hint',\n 'presentation',\n]\n\nexport class PofsisSignInElement extends HTMLElement {\n static get observedAttributes() {\n return observed\n }\n private client: PofsisAuthClient | null = null\n private button: HTMLButtonElement | null = null\n\n connectedCallback() {\n this.render()\n }\n disconnectedCallback() {\n this.client?.destroy()\n }\n attributeChangedCallback() {\n if (this.isConnected) this.render()\n }\n\n private required(name: string) {\n const value = this.getAttribute(name)?.trim()\n if (!value) throw new Error(`<pofsis-sign-in> requires ${name}`)\n return value\n }\n\n private render() {\n this.client?.destroy()\n this.client = createPofsisAuth({\n applicationId: this.required('application-id'),\n apiBaseUrl: this.required('api-base-url'),\n authUrl: this.required('auth-url'),\n scope: this.getAttribute('scope') || undefined,\n })\n const label = this.textContent?.trim() || 'Sign in'\n this.replaceChildren()\n this.button = document.createElement('button')\n this.button.type = 'button'\n this.button.part.add('button')\n this.button.textContent = label\n this.button.addEventListener('click', () => void this.launch())\n this.append(this.button)\n }\n\n private async launch() {\n if (!this.client || !this.button) return\n this.button.disabled = true\n const options: AuthLaunchOptions = {\n presentation: (['popup', 'modal', 'redirect'].includes(\n this.getAttribute('presentation') || '',\n )\n ? this.getAttribute('presentation')\n : 'popup') as AuthLaunchOptions['presentation'],\n returnUrl: this.getAttribute('return-url') || undefined,\n screen: (this.getAttribute('screen') || 'login') as AuthLaunchOptions['screen'],\n method: (this.getAttribute('method') || undefined) as AuthLaunchOptions['method'],\n loginHint: this.getAttribute('login-hint') || undefined,\n }\n try {\n const result = await this.client.login(options)\n this.dispatchEvent(\n new CustomEvent(`pofsis-auth-${result.status}`, {\n bubbles: true,\n composed: true,\n detail: result,\n }),\n )\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('pofsis-auth-error', {\n bubbles: true,\n composed: true,\n detail: { error },\n }),\n )\n } finally {\n this.button.disabled = false\n }\n }\n}\n\nif (!customElements.get('pofsis-sign-in')) {\n customElements.define('pofsis-sign-in', PofsisSignInElement)\n}\n"],"mappings":"4IAGA,IAAM,EAAW,CACb,iBACA,eACA,WACA,QACA,aACA,SACA,SACA,aACA,cACJ,EAEa,EAAb,cAAyC,WAAY,CACjD,WAAW,oBAAqB,CAC5B,OAAO,CACX,CACA,OAA0C,KAC1C,OAA2C,KAE3C,mBAAoB,CAChB,KAAK,OAAO,CAChB,CACA,sBAAuB,CACnB,KAAK,QAAQ,QAAQ,CACzB,CACA,0BAA2B,CACnB,KAAK,aAAa,KAAK,OAAO,CACtC,CAEA,SAAiB,EAAc,CAC3B,IAAM,EAAQ,KAAK,aAAa,CAAI,CAAC,EAAE,KAAK,EAC5C,GAAI,CAAC,EAAO,MAAU,MAAM,6BAA6B,GAAM,EAC/D,OAAO,CACX,CAEA,QAAiB,CACb,KAAK,QAAQ,QAAQ,EACrB,KAAK,OAAS,EAAA,EAAiB,CAC3B,cAAe,KAAK,SAAS,gBAAgB,EAC7C,WAAY,KAAK,SAAS,cAAc,EACxC,QAAS,KAAK,SAAS,UAAU,EACjC,MAAO,KAAK,aAAa,OAAO,GAAK,IAAA,EACzC,CAAC,EACD,IAAM,EAAQ,KAAK,aAAa,KAAK,GAAK,UAC1C,KAAK,gBAAgB,EACrB,KAAK,OAAS,SAAS,cAAc,QAAQ,EAC7C,KAAK,OAAO,KAAO,SACnB,KAAK,OAAO,KAAK,IAAI,QAAQ,EAC7B,KAAK,OAAO,YAAc,EAC1B,KAAK,OAAO,iBAAiB,YAAe,KAAK,KAAK,OAAO,CAAC,EAC9D,KAAK,OAAO,KAAK,MAAM,CAC3B,CAEA,MAAc,QAAS,CACnB,GAAI,CAAC,KAAK,QAAU,CAAC,KAAK,OAAQ,OAClC,KAAK,OAAO,SAAW,GACvB,IAAM,EAA6B,CAC/B,aAAe,CAAC,QAAS,QAAS,UAAU,CAAC,CAAC,SAC1C,KAAK,aAAa,cAAc,GAAK,EACzC,EACM,KAAK,aAAa,cAAc,EAChC,QACN,UAAW,KAAK,aAAa,YAAY,GAAK,IAAA,GAC9C,OAAS,KAAK,aAAa,QAAQ,GAAK,QACxC,OAAS,KAAK,aAAa,QAAQ,GAAK,IAAA,GACxC,UAAW,KAAK,aAAa,YAAY,GAAK,IAAA,EAClD,EACA,GAAI,CACA,IAAM,EAAS,MAAM,KAAK,OAAO,MAAM,CAAO,EAC9C,KAAK,cACD,IAAI,YAAY,eAAe,EAAO,SAAU,CAC5C,QAAS,GACT,SAAU,GACV,OAAQ,CACZ,CAAC,CACL,CACJ,OAAS,EAAO,CACZ,KAAK,cACD,IAAI,YAAY,oBAAqB,CACjC,QAAS,GACT,SAAU,GACV,OAAQ,CAAE,OAAM,CACpB,CAAC,CACL,CACJ,QAAU,CACN,KAAK,OAAO,SAAW,EAC3B,CACJ,CACJ,EAEK,eAAe,IAAI,gBAAgB,GACpC,eAAe,OAAO,iBAAkB,CAAmB"}
|
package/dist/elements.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./PofsisAuthClient-
|
|
1
|
+
import { n as e } from "./PofsisAuthClient-Duybofpq.js";
|
|
2
2
|
import "./core.js";
|
|
3
3
|
//#region src/elements/index.ts
|
|
4
4
|
var t = [
|
|
@@ -9,7 +9,8 @@ var t = [
|
|
|
9
9
|
"return-url",
|
|
10
10
|
"screen",
|
|
11
11
|
"method",
|
|
12
|
-
"login-hint"
|
|
12
|
+
"login-hint",
|
|
13
|
+
"presentation"
|
|
13
14
|
], n = class extends HTMLElement {
|
|
14
15
|
static get observedAttributes() {
|
|
15
16
|
return t;
|
|
@@ -44,7 +45,11 @@ var t = [
|
|
|
44
45
|
if (!this.client || !this.button) return;
|
|
45
46
|
this.button.disabled = !0;
|
|
46
47
|
let e = {
|
|
47
|
-
presentation:
|
|
48
|
+
presentation: [
|
|
49
|
+
"popup",
|
|
50
|
+
"modal",
|
|
51
|
+
"redirect"
|
|
52
|
+
].includes(this.getAttribute("presentation") || "") ? this.getAttribute("presentation") : "popup",
|
|
48
53
|
returnUrl: this.getAttribute("return-url") || void 0,
|
|
49
54
|
screen: this.getAttribute("screen") || "login",
|
|
50
55
|
method: this.getAttribute("method") || void 0,
|
package/dist/elements.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.js","names":[],"sources":["../src/elements/index.ts"],"sourcesContent":["import { createPofsisAuth, type PofsisAuthClient } from '../core'\
|
|
1
|
+
{"version":3,"file":"elements.js","names":[],"sources":["../src/elements/index.ts"],"sourcesContent":["import { createPofsisAuth, type PofsisAuthClient } from '../core'\nimport type { AuthLaunchOptions } from '../types'\n\nconst observed = [\n 'application-id',\n 'api-base-url',\n 'auth-url',\n 'scope',\n 'return-url',\n 'screen',\n 'method',\n 'login-hint',\n 'presentation',\n]\n\nexport class PofsisSignInElement extends HTMLElement {\n static get observedAttributes() {\n return observed\n }\n private client: PofsisAuthClient | null = null\n private button: HTMLButtonElement | null = null\n\n connectedCallback() {\n this.render()\n }\n disconnectedCallback() {\n this.client?.destroy()\n }\n attributeChangedCallback() {\n if (this.isConnected) this.render()\n }\n\n private required(name: string) {\n const value = this.getAttribute(name)?.trim()\n if (!value) throw new Error(`<pofsis-sign-in> requires ${name}`)\n return value\n }\n\n private render() {\n this.client?.destroy()\n this.client = createPofsisAuth({\n applicationId: this.required('application-id'),\n apiBaseUrl: this.required('api-base-url'),\n authUrl: this.required('auth-url'),\n scope: this.getAttribute('scope') || undefined,\n })\n const label = this.textContent?.trim() || 'Sign in'\n this.replaceChildren()\n this.button = document.createElement('button')\n this.button.type = 'button'\n this.button.part.add('button')\n this.button.textContent = label\n this.button.addEventListener('click', () => void this.launch())\n this.append(this.button)\n }\n\n private async launch() {\n if (!this.client || !this.button) return\n this.button.disabled = true\n const options: AuthLaunchOptions = {\n presentation: (['popup', 'modal', 'redirect'].includes(\n this.getAttribute('presentation') || '',\n )\n ? this.getAttribute('presentation')\n : 'popup') as AuthLaunchOptions['presentation'],\n returnUrl: this.getAttribute('return-url') || undefined,\n screen: (this.getAttribute('screen') || 'login') as AuthLaunchOptions['screen'],\n method: (this.getAttribute('method') || undefined) as AuthLaunchOptions['method'],\n loginHint: this.getAttribute('login-hint') || undefined,\n }\n try {\n const result = await this.client.login(options)\n this.dispatchEvent(\n new CustomEvent(`pofsis-auth-${result.status}`, {\n bubbles: true,\n composed: true,\n detail: result,\n }),\n )\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('pofsis-auth-error', {\n bubbles: true,\n composed: true,\n detail: { error },\n }),\n )\n } finally {\n this.button.disabled = false\n }\n }\n}\n\nif (!customElements.get('pofsis-sign-in')) {\n customElements.define('pofsis-sign-in', PofsisSignInElement)\n}\n"],"mappings":";;;AAGA,IAAM,IAAW;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,GAEa,IAAb,cAAyC,YAAY;CACjD,WAAW,qBAAqB;EAC5B,OAAO;CACX;CACA,SAA0C;CAC1C,SAA2C;CAE3C,oBAAoB;EAChB,KAAK,OAAO;CAChB;CACA,uBAAuB;EACnB,KAAK,QAAQ,QAAQ;CACzB;CACA,2BAA2B;EACvB,AAAI,KAAK,eAAa,KAAK,OAAO;CACtC;CAEA,SAAiB,GAAc;EAC3B,IAAM,IAAQ,KAAK,aAAa,CAAI,CAAC,EAAE,KAAK;EAC5C,IAAI,CAAC,GAAO,MAAU,MAAM,6BAA6B,GAAM;EAC/D,OAAO;CACX;CAEA,SAAiB;EAEb,AADA,KAAK,QAAQ,QAAQ,GACrB,KAAK,SAAS,EAAiB;GAC3B,eAAe,KAAK,SAAS,gBAAgB;GAC7C,YAAY,KAAK,SAAS,cAAc;GACxC,SAAS,KAAK,SAAS,UAAU;GACjC,OAAO,KAAK,aAAa,OAAO,KAAK,KAAA;EACzC,CAAC;EACD,IAAM,IAAQ,KAAK,aAAa,KAAK,KAAK;EAO1C,AANA,KAAK,gBAAgB,GACrB,KAAK,SAAS,SAAS,cAAc,QAAQ,GAC7C,KAAK,OAAO,OAAO,UACnB,KAAK,OAAO,KAAK,IAAI,QAAQ,GAC7B,KAAK,OAAO,cAAc,GAC1B,KAAK,OAAO,iBAAiB,eAAe,KAAK,KAAK,OAAO,CAAC,GAC9D,KAAK,OAAO,KAAK,MAAM;CAC3B;CAEA,MAAc,SAAS;EACnB,IAAI,CAAC,KAAK,UAAU,CAAC,KAAK,QAAQ;EAClC,KAAK,OAAO,WAAW;EACvB,IAAM,IAA6B;GAC/B,cAAe;IAAC;IAAS;IAAS;GAAU,CAAC,CAAC,SAC1C,KAAK,aAAa,cAAc,KAAK,EACzC,IACM,KAAK,aAAa,cAAc,IAChC;GACN,WAAW,KAAK,aAAa,YAAY,KAAK,KAAA;GAC9C,QAAS,KAAK,aAAa,QAAQ,KAAK;GACxC,QAAS,KAAK,aAAa,QAAQ,KAAK,KAAA;GACxC,WAAW,KAAK,aAAa,YAAY,KAAK,KAAA;EAClD;EACA,IAAI;GACA,IAAM,IAAS,MAAM,KAAK,OAAO,MAAM,CAAO;GAC9C,KAAK,cACD,IAAI,YAAY,eAAe,EAAO,UAAU;IAC5C,SAAS;IACT,UAAU;IACV,QAAQ;GACZ,CAAC,CACL;EACJ,SAAS,GAAO;GACZ,KAAK,cACD,IAAI,YAAY,qBAAqB;IACjC,SAAS;IACT,UAAU;IACV,QAAQ,EAAE,SAAM;GACpB,CAAC,CACL;EACJ,UAAU;GACN,KAAK,OAAO,WAAW;EAC3B;CACJ;AACJ;AAEK,eAAe,IAAI,gBAAgB,KACpC,eAAe,OAAO,kBAAkB,CAAmB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./PofsisAuthClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./PofsisAuthClient-c4lzLzjV.cjs"),t=require("./RequireAuth-BkYhk-9p.cjs");require("./core.cjs"),exports.AuthErrorScreen=t.o,exports.AuthLoadingScreen=t.a,exports.PofsisAuth=t.i,exports.PofsisAuthClient=e.t,exports.RequireAuth=t.t,exports.attachAuthInterceptor=t.r,exports.createPofsisAuth=e.n,exports.relayAuthCallback=e.r,exports.relayPopupCallback=e.i,exports.resolveConfig=e.o,exports.useAuth=t.n;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { PofsisAuth } from './PofsisAuth';
|
|
2
|
-
export { createPofsisAuth, PofsisAuthClient, relayPopupCallback } from './core';
|
|
2
|
+
export { createPofsisAuth, PofsisAuthClient, relayAuthCallback, relayPopupCallback } from './core';
|
|
3
3
|
export { attachAuthInterceptor } from './attachAuthInterceptor';
|
|
4
4
|
export { resolveConfig } from './auth/config';
|
|
5
5
|
export type { ConfigOverrides } from './auth/config';
|
|
6
6
|
export { AuthErrorScreen, AuthLoadingScreen, RequireAuth } from './components';
|
|
7
7
|
export type { RequireAuthProps } from './components';
|
|
8
8
|
export { useAuth } from './context/useAuth';
|
|
9
|
-
export type { AccountProfile, AuthComponentOverrides, AuthContextValue, AuthErrorScreenProps, AuthLaunchOptions, AuthLoadingScreenProps, AuthMethod, AuthPopupOptions, AuthResult, AuthScreen, OAuthClientConfig, PofsisAuthConfig, PofsisAuthClientConfig, PofsisAuthProps, PofsisUser, SessionPayload, TokenResponse, } from './types';
|
|
9
|
+
export type { AccountProfile, AuthComponentOverrides, AuthContextValue, AuthErrorScreenProps, AuthLaunchOptions, AuthLoadingScreenProps, AuthMethod, AuthModalOptions, AuthPopupOptions, AuthResult, AuthScreen, OAuthClientConfig, PofsisAuthConfig, PofsisAuthClientConfig, PofsisAuthProps, PofsisUser, SessionPayload, TokenResponse, } from './types';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAClG,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC9E,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,YAAY,EACR,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,GAChB,MAAM,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a
|
|
1
|
+
import { i as e, n as t, o as n, r, t as i } from "./PofsisAuthClient-Duybofpq.js";
|
|
2
|
+
import { a, i as o, n as s, o as c, r as l, t as u } from "./RequireAuth-DroX56rd.js";
|
|
3
3
|
import "./core.js";
|
|
4
|
-
export {
|
|
4
|
+
export { c as AuthErrorScreen, a as AuthLoadingScreen, o as PofsisAuth, i as PofsisAuthClient, u as RequireAuth, l as attachAuthInterceptor, t as createPofsisAuth, r as relayAuthCallback, e as relayPopupCallback, n as resolveConfig, s as useAuth };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var PofsisAuthElements=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});async function t(e){if(e.status===204)return null;let t=await e.text();return t?JSON.parse(t):null}async function n(e,n,r){let i=await fetch(`${e.apiBaseUrl}${n}`,{credentials:`include`,...r,headers:{Accept:`application/json`,...r?.body&&!(r.body instanceof FormData)?{"Content-Type":`application/json`}:{},...r?.headers}});if(!i.ok){let e=Error(`Auth API ${n} failed (${i.status})`);throw e.status=i.status,e}return{status:i.status,data:await t(i)}}async function r(e){let{data:t}=await n(e,`/oauth/applications/${encodeURIComponent(e.applicationId)}/client?origin=${encodeURIComponent(window.location.origin)}`);return t}async function i(e,t,r,i){let{data:a}=await n(e,`/oauth/token`,{method:`POST`,body:JSON.stringify({grant_type:`authorization_code`,client_id:i.client_id,redirect_uri:i.redirect_uri,code:t,code_verifier:r})});return a}async function a(e,t){let{data:r}=await n(e,`/oauth/token`,{method:`POST`,body:JSON.stringify({grant_type:`refresh_token`,client_id:t})});return r||null}async function o(e){try{return await n(e,`/auth/session`),!0}catch{return!1}}async function s(e){await n(e,`/auth/logout`,{method:`POST`})}var c=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,l=/^(?:\+63|63|0)?9\d{9}$/,u=new Set([`password`,`passkey`,`otp`]),d=new Set([`login`,`signup`,`reset`]),f=320;function p(e,t=!1){let n=typeof e==`string`?e.trim():``;if(!n||n.length>f)return;if(c.test(n))return n.toLowerCase();let r=n.replace(/[\s()-]/g,``);if(!t&&l.test(r))return`+63${r.replace(/^(?:\+63|63|0)/,``)}`}function m(e,t=`login`){let n=typeof e==`string`?{returnUrl:e}:e||{},r=n.screen===`register`?`signup`:n.screen,i=d.has(r)?r:t,a=u.has(n.method)?n.method:void 0,o=i===`login`||i===`signup`&&(a===`password`||a===`otp`)?a:void 0;return{returnUrl:n.returnUrl,screen:i,loginHint:p(n.loginHint),method:o}}function h({authUrl:e,query:t,options:n}){let r=m(n),i=new URL(e);if(i.search=t.toString(),r.loginHint&&i.searchParams.set(`login_hint`,r.loginHint),r.screen===`login`&&r.method&&i.searchParams.set(`method`,r.method),r.screen===`login`)return i.toString();let a=r.screen===`signup`?`/signup`:`/forgot-password`,o=new URL(a,i),s=t.get(`client_id`);return s&&o.searchParams.set(`client_id`,s),o.searchParams.set(`return_to`,`${i.pathname}${i.search}`),r.loginHint&&o.searchParams.set(`login_hint`,r.loginHint),r.screen===`signup`&&o.searchParams.set(`method`,r.method||`password`),o.toString()}function g(e){return e.replace(/\/$/,``)}function _(e={}){let t=e.applicationId?.trim(),n=e.apiBaseUrl?.trim(),r=e.authUrl?.trim(),i=e.scope?.trim()||`openid profile email`,a=e.callbackPath?.trim()||`/auth/callback`,o={width:e.popup?.width??480,height:e.popup?.height??720,name:e.popup?.name?.trim()||`pofsis-auth`,timeoutMs:e.popup?.timeoutMs??3e5},s=[];if(t||s.push(`applicationId`),n||s.push(`apiBaseUrl`),r||s.push(`authUrl`),s.length)throw Error(`@pofsis-nbt/pofsis-auth missing config: ${s.join(`, `)}`);if(!t||!n||!r)throw Error(`@pofsis-nbt/pofsis-auth missing config`);if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t))throw Error(`@pofsis-nbt/pofsis-auth applicationId must be a UUID`);if(!a.startsWith(`/`)||a.startsWith(`//`))throw Error(`@pofsis-nbt/pofsis-auth callbackPath must be application-relative`);if(o.width<=0||o.height<=0||o.timeoutMs<=0)throw Error(`@pofsis-nbt/pofsis-auth popup dimensions and timeout must be positive`);return{applicationId:t.toLowerCase(),apiBaseUrl:g(n),authUrl:g(r),scope:i,callbackPath:a,popup:o}}var v=e=>btoa(String.fromCharCode(...e)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``),y=()=>v(crypto.getRandomValues(new Uint8Array(32)));async function b(e){return v(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))))}function x(e){if(!e)return;let t=e.indexOf(`.`);return t>0?e.slice(0,t):void 0}var S=e=>e?.startsWith(`/`)&&!e.startsWith(`//`)?e:void 0,C=e=>({token_type:e.token_type,expires_in:e.expires_in,user:e.user}),w=class{config;token=null;session=null;client=null;clientPromise=null;refreshPromise=null;subscribers=new Set;attempt=null;listening=!1;constructor(e){this.config=_(e),this.attach()}attach(){this.listening||=(window.addEventListener(`message`,this.onPopupMessage),!0)}destroy(){window.removeEventListener(`message`,this.onPopupMessage),this.listening=!1;let e=this.finishAttempt();e&&(e.popup.close(),e.resolve({status:`cancelled`})),this.subscribers.clear()}getUser(){return this.session?.user??null}getSession(){return this.session}getAccessToken(){return this.token}subscribe(e){return this.attach(),this.subscribers.add(e),e(this.session),()=>{this.subscribers.delete(e)}}emit(){for(let e of this.subscribers)e(this.session)}accept(e){this.token=e.access_token,this.session=C(e),this.emit()}loadClient(){return this.clientPromise||=r(this.config).then(e=>this.client=e).catch(e=>{throw this.clientPromise=null,e}),this.clientPromise}getOAuthClient(){return this.loadClient()}async refreshSession(){let e=await this.loadClient();return this.refreshPromise||=a(this.config,e.client_id).then(e=>{e?this.accept(e):this.clearSession()}).finally(()=>this.refreshPromise=null),this.refreshPromise}async isRemoteSessionActive(){return o(this.config)}clearSession(){this.token=null,this.session=null,this.emit()}replaceUser(e){this.session&&(this.session={...this.session,user:e},this.emit())}async logout(){try{await s(this.config)}finally{this.clearSession()}}signup(e={}){return this.login({...e,screen:`signup`})}resetPassword(e={}){return this.login({...e,screen:`reset`})}async login(e={}){let t=m(e);return(e.presentation??`popup`)===`popup`?this.openPopup({...e,...t}):this.startRedirect({...e,...t})}async authorizationUrl(e,t,n){let r=await this.loadClient(),i=new URLSearchParams({client_id:r.client_id,redirect_uri:r.redirect_uri,response_type:`code`,scope:this.config.scope,state:t,code_challenge:await b(n),code_challenge_method:`S256`});return h({authUrl:this.config.authUrl,query:i,options:e})}storageKey(e){return`${this.config.applicationId}.auth.${e}`}async startRedirect(e){let t=y(),n=y();sessionStorage.setItem(this.storageKey(`state`),t),sessionStorage.setItem(this.storageKey(`verifier`),n);let r=S(e.returnUrl);return r?sessionStorage.setItem(this.storageKey(`return-path`),r):sessionStorage.removeItem(this.storageKey(`return-path`)),window.location.assign(await this.authorizationUrl(e,t,n)),{status:`redirecting`}}async openPopup(e){if(this.attempt&&!this.attempt.popup.closed)return this.attempt.popup.focus(),new Promise((e,t)=>{let n=this.attempt,r=n.resolve,i=n.reject;n.resolve=t=>{r(t),e(t)},n.reject=e=>{i(e),t(e)}});let{width:t,height:n,name:r,timeoutMs:i}=this.config.popup,a=Math.max(0,window.screenX+(window.outerWidth-t)/2),o=Math.max(0,window.screenY+(window.outerHeight-n)/2),s=window.open(`about:blank`,r,`popup=yes,width=${t},height=${n},left=${Math.round(a)},top=${Math.round(o)}`);if(!s)return this.startRedirect({...e,presentation:`redirect`});let c=y(),l=`${c}.${y()}`,u=y(),d=S(e.returnUrl);return new Promise((t,n)=>{let r=setInterval(()=>{s.closed&&this.finishAttempt()?.resolve({status:`cancelled`})},250),a=setTimeout(()=>{let e=this.finishAttempt();s.close(),e?.reject(Error(`POFSIS Auth popup timed out.`))},i);this.attempt={popup:s,state:l,verifier:u,correlationId:c,returnUrl:d,resolve:t,reject:n,timer:r,timeout:a},this.authorizationUrl(e,l,u).then(e=>s.location.replace(e)).catch(e=>{let t=this.finishAttempt();s.close(),t?.reject(e instanceof Error?e:Error(String(e)))})})}finishAttempt(){let e=this.attempt;return e?(clearInterval(e.timer),clearTimeout(e.timeout),this.attempt=null,e):null}onPopupMessage=e=>{let t=this.attempt,n=e.data;if(!t||e.origin!==window.location.origin||e.source!==t.popup||n?.type!==`pofsis-auth:callback`||n.correlationId!==t.correlationId||x(n.state||null)!==t.correlationId||n.state!==t.state)return;let r=this.finishAttempt();if(r){if(n.error||!n.code){r.popup.close(),r.reject(Error(n.error||`POFSIS Auth callback was incomplete.`));return}this.completeCode(n.code,n.state,r.verifier).then(()=>{r.popup.close(),r.returnUrl&&window.history.replaceState(null,``,r.returnUrl),r.resolve({status:`authenticated`,user:this.getUser()})}).catch(e=>{r.popup.close(),r.reject(e instanceof Error?e:Error(String(e)))})}};async completeCode(e,t,n){if(!t||!n)throw Error(`Authentication state could not be verified.`);let r=await this.loadClient();this.accept(await i(this.config,e,n,r))}async completeRedirectCallback(e,t){let n=sessionStorage.getItem(this.storageKey(`state`)),r=sessionStorage.getItem(this.storageKey(`verifier`));if(sessionStorage.removeItem(this.storageKey(`state`)),sessionStorage.removeItem(this.storageKey(`verifier`)),!n||!r||t!==n)throw Error(`Authentication state could not be verified.`);await this.completeCode(e,t,r)}};function T(e){return new w(e)}var E=[`application-id`,`api-base-url`,`auth-url`,`scope`,`return-url`,`screen`,`method`,`login-hint`],D=class extends HTMLElement{static get observedAttributes(){return E}client=null;button=null;connectedCallback(){this.render()}disconnectedCallback(){this.client?.destroy()}attributeChangedCallback(){this.isConnected&&this.render()}required(e){let t=this.getAttribute(e)?.trim();if(!t)throw Error(`<pofsis-sign-in> requires ${e}`);return t}render(){this.client?.destroy(),this.client=T({applicationId:this.required(`application-id`),apiBaseUrl:this.required(`api-base-url`),authUrl:this.required(`auth-url`),scope:this.getAttribute(`scope`)||void 0});let e=this.textContent?.trim()||`Sign in`;this.replaceChildren(),this.button=document.createElement(`button`),this.button.type=`button`,this.button.part.add(`button`),this.button.textContent=e,this.button.addEventListener(`click`,()=>void this.launch()),this.append(this.button)}async launch(){if(!this.client||!this.button)return;this.button.disabled=!0;let e={presentation:`popup`,returnUrl:this.getAttribute(`return-url`)||void 0,screen:this.getAttribute(`screen`)||`login`,method:this.getAttribute(`method`)||void 0,loginHint:this.getAttribute(`login-hint`)||void 0};try{let t=await this.client.login(e);this.dispatchEvent(new CustomEvent(`pofsis-auth-${t.status}`,{bubbles:!0,composed:!0,detail:t}))}catch(e){this.dispatchEvent(new CustomEvent(`pofsis-auth-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}finally{this.button.disabled=!1}}};return customElements.get(`pofsis-sign-in`)||customElements.define(`pofsis-sign-in`,D),e.PofsisSignInElement=D,e})({});
|
|
1
|
+
var PofsisAuthElements=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});async function t(e){if(e.status===204)return null;let t=await e.text();return t?JSON.parse(t):null}async function n(e,n,r){let i=await fetch(`${e.apiBaseUrl}${n}`,{credentials:`include`,...r,headers:{Accept:`application/json`,...r?.body&&!(r.body instanceof FormData)?{"Content-Type":`application/json`}:{},...r?.headers}});if(!i.ok){let e=Error(`Auth API ${n} failed (${i.status})`);throw e.status=i.status,e}return{status:i.status,data:await t(i)}}async function r(e){let{data:t}=await n(e,`/oauth/applications/${encodeURIComponent(e.applicationId)}/client?origin=${encodeURIComponent(window.location.origin)}`);return t}async function i(e,t,r,i){let{data:a}=await n(e,`/oauth/token`,{method:`POST`,body:JSON.stringify({grant_type:`authorization_code`,client_id:i.client_id,redirect_uri:i.redirect_uri,code:t,code_verifier:r})});return a}async function a(e,t){let{data:r}=await n(e,`/oauth/token`,{method:`POST`,body:JSON.stringify({grant_type:`refresh_token`,client_id:t})});return r||null}async function o(e){try{return await n(e,`/auth/session`),!0}catch{return!1}}async function s(e){await n(e,`/auth/logout`,{method:`POST`})}var c=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,l=/^(?:\+63|63|0)?9\d{9}$/,u=new Set([`password`,`passkey`,`otp`]),d=new Set([`login`,`signup`,`reset`]),f=320;function p(e,t=!1){let n=typeof e==`string`?e.trim():``;if(!n||n.length>f)return;if(c.test(n))return n.toLowerCase();let r=n.replace(/[\s()-]/g,``);if(!t&&l.test(r))return`+63${r.replace(/^(?:\+63|63|0)/,``)}`}function m(e,t=`login`){let n=typeof e==`string`?{returnUrl:e}:e||{},r=n.screen===`register`?`signup`:n.screen,i=d.has(r)?r:t,a=u.has(n.method)?n.method:void 0,o=i===`login`||i===`signup`&&(a===`password`||a===`otp`)?a:void 0;return{returnUrl:n.returnUrl,screen:i,loginHint:p(n.loginHint),method:o}}function h({authUrl:e,query:t,options:n}){let r=m(n),i=new URL(e);if(i.search=t.toString(),n?.presentation===`modal`&&i.searchParams.set(`presentation`,`modal`),r.loginHint&&i.searchParams.set(`login_hint`,r.loginHint),r.screen===`login`&&r.method&&i.searchParams.set(`method`,r.method),r.screen===`login`)return i.toString();let a=r.screen===`signup`?`/signup`:`/forgot-password`,o=new URL(a,i),s=t.get(`client_id`);return s&&o.searchParams.set(`client_id`,s),n?.presentation===`modal`&&o.searchParams.set(`presentation`,`modal`),o.searchParams.set(`return_to`,`${i.pathname}${i.search}`),r.loginHint&&o.searchParams.set(`login_hint`,r.loginHint),r.screen===`signup`&&o.searchParams.set(`method`,r.method||`password`),o.toString()}function g(e){return e.replace(/\/$/,``)}function _(e={}){let t=e.applicationId?.trim(),n=e.apiBaseUrl?.trim(),r=e.authUrl?.trim(),i=e.scope?.trim()||`openid profile email`,a=e.callbackPath?.trim()||`/auth/callback`,o={width:e.popup?.width??480,height:e.popup?.height??720,name:e.popup?.name?.trim()||`pofsis-auth`,timeoutMs:e.popup?.timeoutMs??3e5},s={width:e.modal?.width??480,height:e.modal?.height??720,timeoutMs:e.modal?.timeoutMs??3e5,readyTimeoutMs:e.modal?.readyTimeoutMs??15e3},c=[];if(t||c.push(`applicationId`),n||c.push(`apiBaseUrl`),r||c.push(`authUrl`),c.length)throw Error(`@pofsis-nbt/pofsis-auth missing config: ${c.join(`, `)}`);if(!t||!n||!r)throw Error(`@pofsis-nbt/pofsis-auth missing config`);if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t))throw Error(`@pofsis-nbt/pofsis-auth applicationId must be a UUID`);if(!a.startsWith(`/`)||a.startsWith(`//`))throw Error(`@pofsis-nbt/pofsis-auth callbackPath must be application-relative`);if(o.width<=0||o.height<=0||o.timeoutMs<=0)throw Error(`@pofsis-nbt/pofsis-auth popup dimensions and timeout must be positive`);if(s.width<=0||s.height<=0||s.timeoutMs<=0||s.readyTimeoutMs<=0)throw Error(`@pofsis-nbt/pofsis-auth modal dimensions and timeouts must be positive`);return{applicationId:t.toLowerCase(),apiBaseUrl:g(n),authUrl:g(r),scope:i,callbackPath:a,popup:o,modal:s}}var v=e=>btoa(String.fromCharCode(...e)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``),y=()=>v(crypto.getRandomValues(new Uint8Array(32)));async function b(e){return v(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))))}var x=`pofsis-auth:frame-init`;function S(e){if(!e)return;let t=e.indexOf(`.`);return t>0?e.slice(0,t):void 0}var C=e=>e?.startsWith(`/`)&&!e.startsWith(`//`)?e:void 0,w=e=>({token_type:e.token_type,expires_in:e.expires_in,user:e.user}),T=class{config;token=null;session=null;client=null;clientPromise=null;refreshPromise=null;subscribers=new Set;attempt=null;listening=!1;constructor(e){this.config=_(e),this.attach()}attach(){this.listening||=(window.addEventListener(`message`,this.onPopupMessage),!0)}destroy(){window.removeEventListener(`message`,this.onPopupMessage),this.listening=!1;let e=this.finishAttempt();e&&e.resolve({status:`cancelled`}),this.subscribers.clear()}getUser(){return this.session?.user??null}getSession(){return this.session}getAccessToken(){return this.token}subscribe(e){return this.attach(),this.subscribers.add(e),e(this.session),()=>{this.subscribers.delete(e)}}emit(){for(let e of this.subscribers)e(this.session)}accept(e){this.token=e.access_token,this.session=w(e),this.emit()}loadClient(){return this.clientPromise||=r(this.config).then(e=>this.client=e).catch(e=>{throw this.clientPromise=null,e}),this.clientPromise}getOAuthClient(){return this.loadClient()}async refreshSession(){let e=await this.loadClient();return this.refreshPromise||=a(this.config,e.client_id).then(e=>{e?this.accept(e):this.clearSession()}).finally(()=>this.refreshPromise=null),this.refreshPromise}async isRemoteSessionActive(){return o(this.config)}clearSession(){this.token=null,this.session=null,this.emit()}replaceUser(e){this.session&&(this.session={...this.session,user:e},this.emit())}async logout(){try{await s(this.config)}finally{this.clearSession()}}signup(e={}){return this.login({...e,screen:`signup`})}resetPassword(e={}){return this.login({...e,screen:`reset`})}async login(e={}){let t=m(e),n=e.presentation??`popup`;return n===`popup`?this.openPopup({...e,...t}):n===`modal`?this.openModal({...e,...t}):this.startRedirect({...e,...t})}async authorizationUrl(e,t,n){let r=await this.loadClient(),i=new URLSearchParams({client_id:r.client_id,redirect_uri:r.redirect_uri,response_type:`code`,scope:this.config.scope,state:t,code_challenge:await b(n),code_challenge_method:`S256`});return h({authUrl:this.config.authUrl,query:i,options:e})}storageKey(e){return`${this.config.applicationId}.auth.${e}`}async startRedirect(e){let t=y(),n=y();sessionStorage.setItem(this.storageKey(`state`),t),sessionStorage.setItem(this.storageKey(`verifier`),n);let r=C(e.returnUrl);return r?sessionStorage.setItem(this.storageKey(`return-path`),r):sessionStorage.removeItem(this.storageKey(`return-path`)),window.location.assign(await this.authorizationUrl(e,t,n)),{status:`redirecting`}}async openPopup(e){if(this.attempt)return this.joinAttempt(this.attempt);let{width:t,height:n,name:r,timeoutMs:i}=this.config.popup,a=Math.max(0,window.screenX+(window.outerWidth-t)/2),o=Math.max(0,window.screenY+(window.outerHeight-n)/2),s=window.open(`about:blank`,r,`popup=yes,width=${t},height=${n},left=${Math.round(a)},top=${Math.round(o)}`);if(!s)return this.startRedirect({...e,presentation:`redirect`});let c=y(),l=`${c}.${y()}`,u=y(),d=C(e.returnUrl);return new Promise((t,n)=>{let r=setInterval(()=>{s.closed&&this.finishAttempt()?.resolve({status:`cancelled`})},250),a=setTimeout(()=>{let e=this.finishAttempt();s.close(),e?.reject(Error(`POFSIS Auth popup timed out.`))},i);this.attempt={presentation:`popup`,source:s,state:l,verifier:u,correlationId:c,returnUrl:d,resolve:t,reject:n,timer:r,timeout:a,focus:()=>s.focus(),cleanup:()=>s.close()},this.authorizationUrl(e,l,u).then(e=>s.location.replace(e)).catch(e=>{let t=this.finishAttempt();s.close(),t?.reject(e instanceof Error?e:Error(String(e)))})})}async openModal(e){if(this.attempt)return this.joinAttempt(this.attempt);let{width:t,height:n,timeoutMs:r,readyTimeoutMs:i}=this.config.modal,a=document.activeElement instanceof HTMLElement?document.activeElement:null,o=document.createElement(`dialog`),s=document.createElement(`div`),c=document.createElement(`span`),l=document.createElement(`button`),u=document.createElement(`iframe`);o.setAttribute(`aria-label`,`POFSIS authentication`),o.dataset.pofsisAuthModal=``,Object.assign(o.style,{width:`min(${t}px, calc(100vw - 32px))`,height:`min(${n}px, calc(100dvh - 32px))`,maxWidth:`none`,maxHeight:`none`,padding:`0`,border:`0`,borderRadius:`12px`,boxShadow:`0 24px 80px rgba(0, 0, 0, 0.28)`,overflow:`hidden`}),Object.assign(s.style,{height:`48px`,padding:`0 10px 0 16px`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,background:`#fff`,borderBottom:`1px solid rgba(0, 0, 0, 0.10)`,font:`500 14px/20px Inter, sans-serif`}),c.textContent=e.screen===`signup`?`Create account`:e.screen===`reset`?`Reset password`:`Sign in`,l.type=`button`,l.setAttribute(`aria-label`,`Close authentication`),l.textContent=`×`,Object.assign(l.style,{width:`36px`,height:`36px`,padding:`0`,border:`0`,borderRadius:`8px`,background:`transparent`,color:`#0a0a0a`,cursor:`pointer`,font:`400 26px/36px sans-serif`}),u.title=c.textContent,u.setAttribute(`sandbox`,`allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox`),u.setAttribute(`allow`,`publickey-credentials-get *; publickey-credentials-create *`),Object.assign(u.style,{display:`block`,width:`100%`,height:`calc(100% - 48px)`,border:`0`,background:`#fff`}),s.append(c,l),o.append(s,u),document.body.append(o);let d=`pofsis-auth-modal-style`;if(!document.getElementById(d)){let e=document.createElement(`style`);e.id=d,e.textContent=`[data-pofsis-auth-modal]::backdrop{background:rgba(10,10,10,.56);backdrop-filter:blur(2px)}`,document.head.append(e)}let f=y(),p=`${f}.${y()}`,m=y(),h=C(e.returnUrl);return new Promise((t,n)=>{let s,c=()=>{this.attempt===s&&this.finishAttempt()?.resolve({status:`cancelled`})};l.addEventListener(`click`,c),o.addEventListener(`cancel`,e=>{e.preventDefault(),c()}),o.addEventListener(`click`,e=>{if(e.target!==o)return;let t=o.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&c()});let d=setTimeout(()=>{this.finishAttempt()?.reject(Error(`POFSIS Auth modal timed out.`))},r),g=u.contentWindow;if(!g){o.remove(),clearTimeout(d),n(Error(`POFSIS Auth modal could not be created.`));return}s={presentation:`modal`,source:g,state:p,verifier:m,correlationId:f,returnUrl:h,resolve:t,reject:n,timeout:d,focus:()=>l.focus(),cleanup:()=>{o.remove(),a?.focus()}},this.attempt=s,o.showModal(),l.focus(),this.authorizationUrl(e,p,m).then(e=>{if(this.attempt!==s)return;let t=new URL(e).origin;s.authOrigin=t;let n={type:x,state:p,correlationId:f,applicationId:this.config.applicationId},r=()=>u.contentWindow?.postMessage(n,t);u.addEventListener(`load`,r),u.src=e,r(),s.timer=setInterval(r,250),s.readyTimeout=setTimeout(()=>{this.finishAttempt()?.reject(Error(`POFSIS Auth modal could not be embedded.`))},i)}).catch(e=>{this.finishAttempt()?.reject(e instanceof Error?e:Error(String(e)))})})}joinAttempt(e){return e.focus(),new Promise((t,n)=>{let r=e.resolve,i=e.reject;e.resolve=e=>{r(e),t(e)},e.reject=e=>{i(e),n(e)}})}finishAttempt(){let e=this.attempt;return e?(e.timer&&clearInterval(e.timer),clearTimeout(e.timeout),e.readyTimeout&&clearTimeout(e.readyTimeout),this.attempt=null,e.cleanup(),e):null}onPopupMessage=e=>{let t=this.attempt,n=e.data;if(t?.presentation===`modal`&&n?.type===`pofsis-auth:frame-ready`&&e.origin===t.authOrigin&&e.source===t.source&&n.applicationId===this.config.applicationId&&n.correlationId===t.correlationId&&n.state===t.state){t.ready=!0,t.timer&&clearInterval(t.timer),t.readyTimeout&&clearTimeout(t.readyTimeout),t.timer=void 0,t.readyTimeout=void 0;return}if(!t||t.presentation===`modal`&&!t.ready||e.origin!==window.location.origin||e.source!==t.source||n?.type!==`pofsis-auth:callback`||n.correlationId!==t.correlationId||S(n.state||null)!==t.correlationId||n.state!==t.state)return;let r=this.finishAttempt();if(r){if(n.error||!n.code){r.reject(Error(n.error||`POFSIS Auth callback was incomplete.`));return}this.completeCode(n.code,n.state,r.verifier).then(()=>{r.returnUrl&&window.history.replaceState(null,``,r.returnUrl),r.resolve({status:`authenticated`,user:this.getUser()})}).catch(e=>{r.reject(e instanceof Error?e:Error(String(e)))})}};async completeCode(e,t,n){if(!t||!n)throw Error(`Authentication state could not be verified.`);let r=await this.loadClient();this.accept(await i(this.config,e,n,r))}async completeRedirectCallback(e,t){let n=sessionStorage.getItem(this.storageKey(`state`)),r=sessionStorage.getItem(this.storageKey(`verifier`));if(sessionStorage.removeItem(this.storageKey(`state`)),sessionStorage.removeItem(this.storageKey(`verifier`)),!n||!r||t!==n)throw Error(`Authentication state could not be verified.`);await this.completeCode(e,t,r)}};function E(e){return new T(e)}var D=[`application-id`,`api-base-url`,`auth-url`,`scope`,`return-url`,`screen`,`method`,`login-hint`,`presentation`],O=class extends HTMLElement{static get observedAttributes(){return D}client=null;button=null;connectedCallback(){this.render()}disconnectedCallback(){this.client?.destroy()}attributeChangedCallback(){this.isConnected&&this.render()}required(e){let t=this.getAttribute(e)?.trim();if(!t)throw Error(`<pofsis-sign-in> requires ${e}`);return t}render(){this.client?.destroy(),this.client=E({applicationId:this.required(`application-id`),apiBaseUrl:this.required(`api-base-url`),authUrl:this.required(`auth-url`),scope:this.getAttribute(`scope`)||void 0});let e=this.textContent?.trim()||`Sign in`;this.replaceChildren(),this.button=document.createElement(`button`),this.button.type=`button`,this.button.part.add(`button`),this.button.textContent=e,this.button.addEventListener(`click`,()=>void this.launch()),this.append(this.button)}async launch(){if(!this.client||!this.button)return;this.button.disabled=!0;let e={presentation:[`popup`,`modal`,`redirect`].includes(this.getAttribute(`presentation`)||``)?this.getAttribute(`presentation`):`popup`,returnUrl:this.getAttribute(`return-url`)||void 0,screen:this.getAttribute(`screen`)||`login`,method:this.getAttribute(`method`)||void 0,loginHint:this.getAttribute(`login-hint`)||void 0};try{let t=await this.client.login(e);this.dispatchEvent(new CustomEvent(`pofsis-auth-${t.status}`,{bubbles:!0,composed:!0,detail:t}))}catch(e){this.dispatchEvent(new CustomEvent(`pofsis-auth-error`,{bubbles:!0,composed:!0,detail:{error:e}}))}finally{this.button.disabled=!1}}};return customElements.get(`pofsis-sign-in`)||customElements.define(`pofsis-sign-in`,O),e.PofsisSignInElement=O,e})({});
|
|
2
2
|
//# sourceMappingURL=pofsis-auth-elements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pofsis-auth-elements.js","names":[],"sources":["../src/auth/api.ts","../src/auth/authLaunch.ts","../src/auth/config.ts","../src/auth/pkce.ts","../src/core/popupProtocol.ts","../src/core/PofsisAuthClient.ts","../src/elements/index.ts"],"sourcesContent":["import type { AccountProfile, OAuthClientConfig, PofsisAuthConfig, TokenResponse } from '../types'\r\n\r\nasync function parseJson<T>(response: Response): Promise<T> {\r\n if (response.status === 204) return null as T\r\n const text = await response.text()\r\n if (!text) return null as T\r\n return JSON.parse(text) as T\r\n}\r\n\r\nasync function request<T>(\r\n config: PofsisAuthConfig,\r\n path: string,\r\n init?: RequestInit,\r\n): Promise<{ status: number; data: T }> {\r\n const response = await fetch(`${config.apiBaseUrl}${path}`, {\r\n credentials: 'include',\r\n ...init,\r\n headers: {\r\n Accept: 'application/json',\r\n ...(init?.body && !(init.body instanceof FormData)\r\n ? { 'Content-Type': 'application/json' }\r\n : {}),\r\n ...init?.headers,\r\n },\r\n })\r\n if (!response.ok) {\r\n const error = new Error(`Auth API ${path} failed (${response.status})`)\r\n ;(error as Error & { status?: number }).status = response.status\r\n throw error\r\n }\r\n return { status: response.status, data: await parseJson<T>(response) }\r\n}\r\n\r\nexport async function fetchOAuthClient(config: PofsisAuthConfig) {\r\n const applicationId = encodeURIComponent(config.applicationId)\r\n const origin = encodeURIComponent(window.location.origin)\r\n const { data } = await request<OAuthClientConfig>(\r\n config,\r\n `/oauth/applications/${applicationId}/client?origin=${origin}`,\r\n )\r\n return data\r\n}\r\n\r\nexport async function exchangeCode(\r\n config: PofsisAuthConfig,\r\n code: string,\r\n verifier: string,\r\n client: Pick<OAuthClientConfig, 'client_id' | 'redirect_uri'>,\r\n) {\r\n const { data } = await request<TokenResponse>(config, '/oauth/token', {\r\n method: 'POST',\r\n body: JSON.stringify({\r\n grant_type: 'authorization_code',\r\n client_id: client.client_id,\r\n redirect_uri: client.redirect_uri,\r\n code,\r\n code_verifier: verifier,\r\n }),\r\n })\r\n return data\r\n}\r\n\r\nexport async function refresh(config: PofsisAuthConfig, clientId: string) {\r\n const { data } = await request<TokenResponse | null>(config, '/oauth/token', {\r\n method: 'POST',\r\n body: JSON.stringify({\r\n grant_type: 'refresh_token',\r\n client_id: clientId,\r\n }),\r\n })\r\n return data || null\r\n}\r\n\r\nexport async function checkSession(config: PofsisAuthConfig) {\r\n try {\r\n await request(config, '/auth/session')\r\n return true\r\n } catch {\r\n return false\r\n }\r\n}\r\n\r\nexport async function signOut(config: PofsisAuthConfig) {\r\n await request(config, '/auth/logout', { method: 'POST' })\r\n}\r\n\r\nexport async function getAccountProfile(config: PofsisAuthConfig, accessToken: string) {\r\n const { data } = await request<AccountProfile>(config, '/auth/profile/me', {\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n })\r\n return data\r\n}\r\n\r\nexport async function updateAccountProfile(\r\n config: PofsisAuthConfig,\r\n accessToken: string,\r\n profile: { firstName?: string | null; lastName?: string | null },\r\n) {\r\n const { data } = await request<AccountProfile>(config, '/auth/profile/me', {\r\n method: 'PATCH',\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n body: JSON.stringify(profile),\r\n })\r\n return data\r\n}\r\n\r\nexport async function uploadAccountProfileImage(\r\n config: PofsisAuthConfig,\r\n accessToken: string,\r\n kind: 'profile' | 'cover',\r\n file: File,\r\n) {\r\n const body = new FormData()\r\n body.append('file', file)\r\n const { data } = await request<AccountProfile>(config, `/auth/profile/me/images/${kind}`, {\r\n method: 'POST',\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n body,\r\n })\r\n return data\r\n}\r\n\r\nexport async function deleteAccountProfileImage(\r\n config: PofsisAuthConfig,\r\n accessToken: string,\r\n kind: 'profile' | 'cover',\r\n) {\r\n const { data } = await request<AccountProfile>(config, `/auth/profile/me/images/${kind}`, {\r\n method: 'DELETE',\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n })\r\n return data\r\n}\r\n","import type { AuthLaunchOptions, AuthMethod, AuthScreen } from '../types'\r\n\r\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\r\nconst PHILIPPINE_MOBILE = /^(?:\\+63|63|0)?9\\d{9}$/\r\nconst METHODS = new Set<AuthMethod>(['password', 'passkey', 'otp'])\r\nconst SCREENS = new Set<AuthScreen>(['login', 'signup', 'reset'])\r\nconst MAX_HINT_LENGTH = 320\r\n\r\nfunction normalizeHint(value: unknown, emailOnly = false): string | undefined {\r\n const candidate = typeof value === 'string' ? value.trim() : ''\r\n if (!candidate || candidate.length > MAX_HINT_LENGTH) return undefined\r\n if (EMAIL.test(candidate)) return candidate.toLowerCase()\r\n const compact = candidate.replace(/[\\s()-]/g, '')\r\n if (emailOnly || !PHILIPPINE_MOBILE.test(compact)) return undefined\r\n return `+63${compact.replace(/^(?:\\+63|63|0)/, '')}`\r\n}\r\n\r\nexport function normalizeAuthLaunchOptions(\r\n value?: AuthLaunchOptions | string | null,\r\n defaultScreen: AuthScreen = 'login',\r\n) {\r\n const options = typeof value === 'string' ? { returnUrl: value } : value || {}\r\n const requestedScreen = options.screen === 'register' ? 'signup' : options.screen\r\n const screen = SCREENS.has(requestedScreen as AuthScreen)\r\n ? (requestedScreen as AuthScreen)\r\n : defaultScreen\r\n const requestedMethod = METHODS.has(options.method as AuthMethod)\r\n ? (options.method as AuthMethod)\r\n : undefined\r\n const method =\r\n screen === 'login' ||\r\n (screen === 'signup' && (requestedMethod === 'password' || requestedMethod === 'otp'))\r\n ? requestedMethod\r\n : undefined\r\n return {\r\n returnUrl: options.returnUrl,\r\n screen,\r\n loginHint: normalizeHint(options.loginHint),\r\n method,\r\n }\r\n}\r\n\r\nexport function authLaunchOptionsFromSearch(search: string) {\r\n const params = new URLSearchParams(search)\r\n const canonicalHint = params.get('login_hint')\r\n const loginHint =\r\n canonicalHint !== null\r\n ? normalizeHint(canonicalHint)\r\n : normalizeHint(params.get('email'), true)\r\n return normalizeAuthLaunchOptions({\r\n screen: (params.get('screen') || undefined) as AuthLaunchOptions['screen'],\r\n loginHint,\r\n method: (params.get('method') || undefined) as AuthLaunchOptions['method'],\r\n })\r\n}\r\n\r\nexport function buildAuthDestination({\r\n authUrl,\r\n query,\r\n options,\r\n}: {\r\n authUrl: string\r\n query: URLSearchParams\r\n options?: AuthLaunchOptions\r\n}) {\r\n const launch = normalizeAuthLaunchOptions(options)\r\n const authorizationUrl = new URL(authUrl)\r\n authorizationUrl.search = query.toString()\r\n if (launch.loginHint) authorizationUrl.searchParams.set('login_hint', launch.loginHint)\r\n if (launch.screen === 'login' && launch.method) {\r\n authorizationUrl.searchParams.set('method', launch.method)\r\n }\r\n if (launch.screen === 'login') return authorizationUrl.toString()\r\n\r\n const pathname = launch.screen === 'signup' ? '/signup' : '/forgot-password'\r\n const destination = new URL(pathname, authorizationUrl)\r\n const clientId = query.get('client_id')\r\n if (clientId) destination.searchParams.set('client_id', clientId)\r\n destination.searchParams.set(\r\n 'return_to',\r\n `${authorizationUrl.pathname}${authorizationUrl.search}`,\r\n )\r\n if (launch.loginHint) destination.searchParams.set('login_hint', launch.loginHint)\r\n if (launch.screen === 'signup') {\r\n destination.searchParams.set('method', launch.method || 'password')\r\n }\r\n return destination.toString()\r\n}\r\n","import type { PofsisAuthClientConfig, ResolvedPofsisAuthConfig } from '../types'\r\n\r\nfunction stripTrailingSlash(value: string) {\r\n return value.replace(/\\/$/, '')\r\n}\r\n\r\nexport type ConfigOverrides = Partial<PofsisAuthClientConfig>\r\n\r\n/**\r\n * Validate and normalize explicitly supplied runtime configuration.\r\n */\r\nexport function resolveConfig(overrides: ConfigOverrides = {}): ResolvedPofsisAuthConfig {\r\n const applicationId = overrides.applicationId?.trim()\r\n const apiBaseUrl = overrides.apiBaseUrl?.trim()\r\n const authUrl = overrides.authUrl?.trim()\r\n const scope = overrides.scope?.trim() || 'openid profile email'\r\n const callbackPath = overrides.callbackPath?.trim() || '/auth/callback'\r\n const popup = {\r\n width: overrides.popup?.width ?? 480,\r\n height: overrides.popup?.height ?? 720,\r\n name: overrides.popup?.name?.trim() || 'pofsis-auth',\r\n timeoutMs: overrides.popup?.timeoutMs ?? 300_000,\r\n }\r\n\r\n const missing: string[] = []\r\n if (!applicationId) missing.push('applicationId')\r\n if (!apiBaseUrl) missing.push('apiBaseUrl')\r\n if (!authUrl) missing.push('authUrl')\r\n if (missing.length) {\r\n throw new Error(`@pofsis-nbt/pofsis-auth missing config: ${missing.join(', ')}`)\r\n }\r\n if (!applicationId || !apiBaseUrl || !authUrl) {\r\n throw new Error('@pofsis-nbt/pofsis-auth missing config')\r\n }\r\n if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(applicationId)) {\r\n throw new Error('@pofsis-nbt/pofsis-auth applicationId must be a UUID')\r\n }\r\n if (!callbackPath.startsWith('/') || callbackPath.startsWith('//')) {\r\n throw new Error('@pofsis-nbt/pofsis-auth callbackPath must be application-relative')\r\n }\r\n if (popup.width <= 0 || popup.height <= 0 || popup.timeoutMs <= 0) {\r\n throw new Error('@pofsis-nbt/pofsis-auth popup dimensions and timeout must be positive')\r\n }\r\n\r\n return {\r\n applicationId: applicationId.toLowerCase(),\r\n apiBaseUrl: stripTrailingSlash(apiBaseUrl),\r\n authUrl: stripTrailingSlash(authUrl),\r\n scope,\r\n callbackPath,\r\n popup,\r\n }\r\n}\r\n","const encode = (bytes: Uint8Array) =>\r\n btoa(String.fromCharCode(...bytes))\r\n .replace(/\\+/g, '-')\r\n .replace(/\\//g, '_')\r\n .replace(/=+$/, '')\r\n\r\nexport const randomValue = () => encode(crypto.getRandomValues(new Uint8Array(32)))\r\n\r\nexport async function pkceChallenge(verifier: string) {\r\n return encode(\r\n new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier))),\r\n )\r\n}\r\n","export const POPUP_MESSAGE_TYPE = 'pofsis-auth:callback'\r\n\r\nexport type PopupCallbackMessage = {\r\n type: typeof POPUP_MESSAGE_TYPE\r\n code?: string\r\n state?: string\r\n error?: string\r\n correlationId?: string\r\n}\r\n\r\nexport function correlationFromState(state: string | null) {\r\n if (!state) return undefined\r\n const separator = state.indexOf('.')\r\n return separator > 0 ? state.slice(0, separator) : undefined\r\n}\r\n\r\nexport function relayPopupCallback(targetOrigin = window.location.origin) {\r\n if (!window.opener || window.opener.closed) return false\r\n const params = new URLSearchParams(window.location.search)\r\n const state = params.get('state') || undefined\r\n const message: PopupCallbackMessage = {\r\n type: POPUP_MESSAGE_TYPE,\r\n code: params.get('code') || undefined,\r\n state,\r\n error: params.get('error') || undefined,\r\n correlationId: correlationFromState(state || null),\r\n }\r\n window.opener.postMessage(message, targetOrigin)\r\n window.close()\r\n return true\r\n}\r\n","import { checkSession, exchangeCode, fetchOAuthClient, refresh, signOut } from '../auth/api'\r\nimport { buildAuthDestination, normalizeAuthLaunchOptions } from '../auth/authLaunch'\r\nimport { resolveConfig } from '../auth/config'\r\nimport { pkceChallenge, randomValue } from '../auth/pkce'\r\nimport type {\r\n AuthLaunchOptions,\r\n AuthResult,\r\n OAuthClientConfig,\r\n PofsisAuthClientConfig,\r\n ResolvedPofsisAuthConfig,\r\n PofsisUser,\r\n SessionPayload,\r\n} from '../types'\r\nimport {\r\n correlationFromState,\r\n POPUP_MESSAGE_TYPE,\r\n type PopupCallbackMessage,\r\n} from './popupProtocol'\r\n\r\ntype Subscriber = (session: SessionPayload | null) => void\r\ntype PopupAttempt = {\r\n popup: Window\r\n state: string\r\n verifier: string\r\n correlationId: string\r\n returnUrl?: string\r\n resolve: (result: AuthResult) => void\r\n reject: (error: Error) => void\r\n timer: ReturnType<typeof setInterval>\r\n timeout: ReturnType<typeof setTimeout>\r\n}\r\n\r\nconst safeLocalPath = (value?: string) =>\r\n value?.startsWith('/') && !value.startsWith('//') ? value : undefined\r\n\r\nconst toSession = (result: { token_type: string; expires_in: number; user: PofsisUser }) => ({\r\n token_type: result.token_type,\r\n expires_in: result.expires_in,\r\n user: result.user,\r\n})\r\n\r\nexport class PofsisAuthClient {\r\n readonly config: ResolvedPofsisAuthConfig\r\n private token: string | null = null\r\n private session: SessionPayload | null = null\r\n private client: OAuthClientConfig | null = null\r\n private clientPromise: Promise<OAuthClientConfig> | null = null\r\n private refreshPromise: Promise<void> | null = null\r\n private subscribers = new Set<Subscriber>()\r\n private attempt: PopupAttempt | null = null\r\n private listening = false\r\n\r\n constructor(config: PofsisAuthClientConfig) {\r\n this.config = resolveConfig(config)\r\n this.attach()\r\n }\r\n\r\n private attach() {\r\n if (this.listening) return\r\n window.addEventListener('message', this.onPopupMessage)\r\n this.listening = true\r\n }\r\n\r\n destroy() {\r\n window.removeEventListener('message', this.onPopupMessage)\r\n this.listening = false\r\n const attempt = this.finishAttempt()\r\n if (attempt) {\r\n attempt.popup.close()\r\n attempt.resolve({ status: 'cancelled' })\r\n }\r\n this.subscribers.clear()\r\n }\r\n\r\n getUser() {\r\n return this.session?.user ?? null\r\n }\r\n\r\n getSession() {\r\n return this.session\r\n }\r\n\r\n getAccessToken() {\r\n return this.token\r\n }\r\n\r\n subscribe(listener: Subscriber) {\r\n this.attach()\r\n this.subscribers.add(listener)\r\n listener(this.session)\r\n return () => {\r\n this.subscribers.delete(listener)\r\n }\r\n }\r\n\r\n private emit() {\r\n for (const listener of this.subscribers) listener(this.session)\r\n }\r\n\r\n private accept(result: Awaited<ReturnType<typeof exchangeCode>>) {\r\n this.token = result.access_token\r\n this.session = toSession(result)\r\n this.emit()\r\n }\r\n\r\n private loadClient() {\r\n if (!this.clientPromise) {\r\n this.clientPromise = fetchOAuthClient(this.config)\r\n .then((client) => (this.client = client))\r\n .catch((error) => {\r\n this.clientPromise = null\r\n throw error\r\n })\r\n }\r\n return this.clientPromise\r\n }\r\n\r\n getOAuthClient() {\r\n return this.loadClient()\r\n }\r\n\r\n async refreshSession() {\r\n const client = await this.loadClient()\r\n if (!this.refreshPromise) {\r\n this.refreshPromise = refresh(this.config, client.client_id)\r\n .then((result) => {\r\n if (result) this.accept(result)\r\n else this.clearSession()\r\n })\r\n .finally(() => (this.refreshPromise = null))\r\n }\r\n return this.refreshPromise\r\n }\r\n\r\n async isRemoteSessionActive() {\r\n return checkSession(this.config)\r\n }\r\n\r\n clearSession() {\r\n this.token = null\r\n this.session = null\r\n this.emit()\r\n }\r\n\r\n replaceUser(user: PofsisUser) {\r\n if (!this.session) return\r\n this.session = { ...this.session, user }\r\n this.emit()\r\n }\r\n\r\n async logout() {\r\n try {\r\n await signOut(this.config)\r\n } finally {\r\n this.clearSession()\r\n }\r\n }\r\n\r\n signup(options: Omit<AuthLaunchOptions, 'screen'> = {}) {\r\n return this.login({ ...options, screen: 'signup' })\r\n }\r\n\r\n resetPassword(options: Omit<AuthLaunchOptions, 'screen'> = {}) {\r\n return this.login({ ...options, screen: 'reset' })\r\n }\r\n\r\n async login(options: AuthLaunchOptions = {}): Promise<AuthResult> {\r\n const launch = normalizeAuthLaunchOptions(options)\r\n const presentation = options.presentation ?? 'popup'\r\n if (presentation === 'popup') return this.openPopup({ ...options, ...launch })\r\n return this.startRedirect({ ...options, ...launch })\r\n }\r\n\r\n private async authorizationUrl(options: AuthLaunchOptions, state: string, verifier: string) {\r\n const client = await this.loadClient()\r\n const query = new URLSearchParams({\r\n client_id: client.client_id,\r\n redirect_uri: client.redirect_uri,\r\n response_type: 'code',\r\n scope: this.config.scope,\r\n state,\r\n code_challenge: await pkceChallenge(verifier),\r\n code_challenge_method: 'S256',\r\n })\r\n return buildAuthDestination({\r\n authUrl: this.config.authUrl,\r\n query,\r\n options,\r\n })\r\n }\r\n\r\n private storageKey(suffix: string) {\r\n return `${this.config.applicationId}.auth.${suffix}`\r\n }\r\n\r\n private async startRedirect(options: AuthLaunchOptions): Promise<AuthResult> {\r\n const state = randomValue()\r\n const verifier = randomValue()\r\n sessionStorage.setItem(this.storageKey('state'), state)\r\n sessionStorage.setItem(this.storageKey('verifier'), verifier)\r\n const returnUrl = safeLocalPath(options.returnUrl)\r\n if (returnUrl) sessionStorage.setItem(this.storageKey('return-path'), returnUrl)\r\n else sessionStorage.removeItem(this.storageKey('return-path'))\r\n window.location.assign(await this.authorizationUrl(options, state, verifier))\r\n return { status: 'redirecting' }\r\n }\r\n\r\n private async openPopup(options: AuthLaunchOptions): Promise<AuthResult> {\r\n if (this.attempt && !this.attempt.popup.closed) {\r\n this.attempt.popup.focus()\r\n return new Promise((resolve, reject) => {\r\n const current = this.attempt!\r\n const originalResolve = current.resolve\r\n const originalReject = current.reject\r\n current.resolve = (value) => {\r\n originalResolve(value)\r\n resolve(value)\r\n }\r\n current.reject = (error) => {\r\n originalReject(error)\r\n reject(error)\r\n }\r\n })\r\n }\r\n const { width, height, name, timeoutMs } = this.config.popup\r\n const left = Math.max(0, window.screenX + (window.outerWidth - width) / 2)\r\n const top = Math.max(0, window.screenY + (window.outerHeight - height) / 2)\r\n const popup = window.open(\r\n 'about:blank',\r\n name,\r\n `popup=yes,width=${width},height=${height},left=${Math.round(left)},top=${Math.round(top)}`,\r\n )\r\n if (!popup) return this.startRedirect({ ...options, presentation: 'redirect' })\r\n\r\n const correlationId = randomValue()\r\n const state = `${correlationId}.${randomValue()}`\r\n const verifier = randomValue()\r\n const returnUrl = safeLocalPath(options.returnUrl)\r\n return new Promise<AuthResult>((resolve, reject) => {\r\n const timer = setInterval(() => {\r\n if (!popup.closed) return\r\n const attempt = this.finishAttempt()\r\n attempt?.resolve({ status: 'cancelled' })\r\n }, 250)\r\n const timeout = setTimeout(() => {\r\n const attempt = this.finishAttempt()\r\n popup.close()\r\n attempt?.reject(new Error('POFSIS Auth popup timed out.'))\r\n }, timeoutMs)\r\n this.attempt = {\r\n popup,\r\n state,\r\n verifier,\r\n correlationId,\r\n returnUrl,\r\n resolve,\r\n reject,\r\n timer,\r\n timeout,\r\n }\r\n void this.authorizationUrl(options, state, verifier)\r\n .then((url) => popup.location.replace(url))\r\n .catch((error) => {\r\n const attempt = this.finishAttempt()\r\n popup.close()\r\n attempt?.reject(error instanceof Error ? error : new Error(String(error)))\r\n })\r\n })\r\n }\r\n\r\n private finishAttempt() {\r\n const attempt = this.attempt\r\n if (!attempt) return null\r\n clearInterval(attempt.timer)\r\n clearTimeout(attempt.timeout)\r\n this.attempt = null\r\n return attempt\r\n }\r\n\r\n private onPopupMessage = (event: MessageEvent<PopupCallbackMessage>) => {\r\n const attempt = this.attempt\r\n const message = event.data\r\n if (\r\n !attempt ||\r\n event.origin !== window.location.origin ||\r\n event.source !== attempt.popup ||\r\n message?.type !== POPUP_MESSAGE_TYPE ||\r\n message.correlationId !== attempt.correlationId ||\r\n correlationFromState(message.state || null) !== attempt.correlationId ||\r\n message.state !== attempt.state\r\n )\r\n return\r\n\r\n const completed = this.finishAttempt()\r\n if (!completed) return\r\n if (message.error || !message.code) {\r\n completed.popup.close()\r\n completed.reject(new Error(message.error || 'POFSIS Auth callback was incomplete.'))\r\n return\r\n }\r\n void this.completeCode(message.code, message.state, completed.verifier)\r\n .then(() => {\r\n completed.popup.close()\r\n if (completed.returnUrl) window.history.replaceState(null, '', completed.returnUrl)\r\n completed.resolve({ status: 'authenticated', user: this.getUser()! })\r\n })\r\n .catch((error) => {\r\n completed.popup.close()\r\n completed.reject(error instanceof Error ? error : new Error(String(error)))\r\n })\r\n }\r\n\r\n private async completeCode(code: string, state: string, verifier: string) {\r\n if (!state || !verifier) throw new Error('Authentication state could not be verified.')\r\n const client = await this.loadClient()\r\n this.accept(await exchangeCode(this.config, code, verifier, client))\r\n }\r\n\r\n async completeRedirectCallback(code: string, state: string) {\r\n const expected = sessionStorage.getItem(this.storageKey('state'))\r\n const verifier = sessionStorage.getItem(this.storageKey('verifier'))\r\n sessionStorage.removeItem(this.storageKey('state'))\r\n sessionStorage.removeItem(this.storageKey('verifier'))\r\n if (!expected || !verifier || state !== expected) {\r\n throw new Error('Authentication state could not be verified.')\r\n }\r\n await this.completeCode(code, state, verifier)\r\n }\r\n}\r\n\r\nexport function createPofsisAuth(config: PofsisAuthClientConfig) {\r\n return new PofsisAuthClient(config)\r\n}\r\n","import { createPofsisAuth, type PofsisAuthClient } from '../core'\r\nimport type { AuthLaunchOptions } from '../types'\r\n\r\nconst observed = [\r\n 'application-id',\r\n 'api-base-url',\r\n 'auth-url',\r\n 'scope',\r\n 'return-url',\r\n 'screen',\r\n 'method',\r\n 'login-hint',\r\n]\r\n\r\nexport class PofsisSignInElement extends HTMLElement {\r\n static get observedAttributes() {\r\n return observed\r\n }\r\n private client: PofsisAuthClient | null = null\r\n private button: HTMLButtonElement | null = null\r\n\r\n connectedCallback() {\r\n this.render()\r\n }\r\n disconnectedCallback() {\r\n this.client?.destroy()\r\n }\r\n attributeChangedCallback() {\r\n if (this.isConnected) this.render()\r\n }\r\n\r\n private required(name: string) {\r\n const value = this.getAttribute(name)?.trim()\r\n if (!value) throw new Error(`<pofsis-sign-in> requires ${name}`)\r\n return value\r\n }\r\n\r\n private render() {\r\n this.client?.destroy()\r\n this.client = createPofsisAuth({\r\n applicationId: this.required('application-id'),\r\n apiBaseUrl: this.required('api-base-url'),\r\n authUrl: this.required('auth-url'),\r\n scope: this.getAttribute('scope') || undefined,\r\n })\r\n const label = this.textContent?.trim() || 'Sign in'\r\n this.replaceChildren()\r\n this.button = document.createElement('button')\r\n this.button.type = 'button'\r\n this.button.part.add('button')\r\n this.button.textContent = label\r\n this.button.addEventListener('click', () => void this.launch())\r\n this.append(this.button)\r\n }\r\n\r\n private async launch() {\r\n if (!this.client || !this.button) return\r\n this.button.disabled = true\r\n const options: AuthLaunchOptions = {\r\n presentation: 'popup',\r\n returnUrl: this.getAttribute('return-url') || undefined,\r\n screen: (this.getAttribute('screen') || 'login') as AuthLaunchOptions['screen'],\r\n method: (this.getAttribute('method') || undefined) as AuthLaunchOptions['method'],\r\n loginHint: this.getAttribute('login-hint') || undefined,\r\n }\r\n try {\r\n const result = await this.client.login(options)\r\n this.dispatchEvent(\r\n new CustomEvent(`pofsis-auth-${result.status}`, {\r\n bubbles: true,\r\n composed: true,\r\n detail: result,\r\n }),\r\n )\r\n } catch (error) {\r\n this.dispatchEvent(\r\n new CustomEvent('pofsis-auth-error', {\r\n bubbles: true,\r\n composed: true,\r\n detail: { error },\r\n }),\r\n )\r\n } finally {\r\n this.button.disabled = false\r\n }\r\n }\r\n}\r\n\r\nif (!customElements.get('pofsis-sign-in')) {\r\n customElements.define('pofsis-sign-in', PofsisSignInElement)\r\n}\r\n"],"mappings":"iGAEA,eAAe,EAAa,EAAgC,CACxD,GAAI,EAAS,SAAW,IAAK,OAAO,KACpC,IAAM,EAAO,MAAM,EAAS,KAAK,EAEjC,OADK,EACE,KAAK,MAAM,CAAI,EADJ,IAEtB,CAEA,eAAe,EACX,EACA,EACA,EACoC,CACpC,IAAM,EAAW,MAAM,MAAM,GAAG,EAAO,aAAa,IAAQ,CACxD,YAAa,UACb,GAAG,EACH,QAAS,CACL,OAAQ,mBACR,GAAI,GAAM,MAAQ,EAAE,EAAK,gBAAgB,UACnC,CAAE,eAAgB,kBAAmB,EACrC,CAAC,EACP,GAAG,GAAM,OACb,CACJ,CAAC,EACD,GAAI,CAAC,EAAS,GAAI,CACd,IAAM,EA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C7C,KAAK,OAAO,KAAO,SACnB,KAAK,OAAO,KAAK,IAAI,QAAQ,EAC7B,KAAK,OAAO,YAAc,EAC1B,KAAK,OAAO,iBAAiB,YAAe,KAAK,KAAK,OAAO,CAAC,EAC9D,KAAK,OAAO,KAAK,MAAM,CAC3B,CAEA,MAAc,QAAS,CACnB,GAAI,CAAC,KAAK,QAAU,CAAC,KAAK,OAAQ,OAClC,KAAK,OAAO,SAAW,GACvB,IAAM,EAA6B,CAC/B,aAAc,QACd,UAAW,KAAK,aAAa,YAAY,GAAK,IAAA,GAC9C,OAAS,KAAK,aAAa,QAAQ,GAAK,QACxC,OAAS,KAAK,aAAa,QAAQ,GAAK,IAAA,GACxC,UAAW,KAAK,aAAa,YAAY,GAAK,IAAA,EAClD,EACA,GAAI,CACA,IAAM,EAAS,MAAM,KAAK,OAAO,MAAM,CAAO,EAC9C,KAAK,cACD,IAAI,YAAY,eAAe,EAAO,SAAU,CAC5C,QAAS,GACT,SAAU,GACV,OAAQ,CACZ,CAAC,CACL,CACJ,OAAS,EAAO,CACZ,KAAK,cACD,IAAI,YAAY,oBAAqB,CACjC,QAAS,GACT,SAAU,GACV,OAAQ,CAAE,OAAM,CACpB,CAAC,CACL,CACJ,QAAU,CACN,KAAK,OAAO,SAAW,EAC3B,CACJ,CACJ,SAEK,eAAe,IAAI,gBAAgB,GACpC,eAAe,OAAO,iBAAkB,CAAmB"}
|
|
1
|
+
{"version":3,"file":"pofsis-auth-elements.js","names":[],"sources":["../src/auth/api.ts","../src/auth/authLaunch.ts","../src/auth/config.ts","../src/auth/pkce.ts","../src/core/popupProtocol.ts","../src/core/PofsisAuthClient.ts","../src/elements/index.ts"],"sourcesContent":["import type { AccountProfile, OAuthClientConfig, PofsisAuthConfig, TokenResponse } from '../types'\r\n\r\nasync function parseJson<T>(response: Response): Promise<T> {\r\n if (response.status === 204) return null as T\r\n const text = await response.text()\r\n if (!text) return null as T\r\n return JSON.parse(text) as T\r\n}\r\n\r\nasync function request<T>(\r\n config: PofsisAuthConfig,\r\n path: string,\r\n init?: RequestInit,\r\n): Promise<{ status: number; data: T }> {\r\n const response = await fetch(`${config.apiBaseUrl}${path}`, {\r\n credentials: 'include',\r\n ...init,\r\n headers: {\r\n Accept: 'application/json',\r\n ...(init?.body && !(init.body instanceof FormData)\r\n ? { 'Content-Type': 'application/json' }\r\n : {}),\r\n ...init?.headers,\r\n },\r\n })\r\n if (!response.ok) {\r\n const error = new Error(`Auth API ${path} failed (${response.status})`)\r\n ;(error as Error & { status?: number }).status = response.status\r\n throw error\r\n }\r\n return { status: response.status, data: await parseJson<T>(response) }\r\n}\r\n\r\nexport async function fetchOAuthClient(config: PofsisAuthConfig) {\r\n const applicationId = encodeURIComponent(config.applicationId)\r\n const origin = encodeURIComponent(window.location.origin)\r\n const { data } = await request<OAuthClientConfig>(\r\n config,\r\n `/oauth/applications/${applicationId}/client?origin=${origin}`,\r\n )\r\n return data\r\n}\r\n\r\nexport async function exchangeCode(\r\n config: PofsisAuthConfig,\r\n code: string,\r\n verifier: string,\r\n client: Pick<OAuthClientConfig, 'client_id' | 'redirect_uri'>,\r\n) {\r\n const { data } = await request<TokenResponse>(config, '/oauth/token', {\r\n method: 'POST',\r\n body: JSON.stringify({\r\n grant_type: 'authorization_code',\r\n client_id: client.client_id,\r\n redirect_uri: client.redirect_uri,\r\n code,\r\n code_verifier: verifier,\r\n }),\r\n })\r\n return data\r\n}\r\n\r\nexport async function refresh(config: PofsisAuthConfig, clientId: string) {\r\n const { data } = await request<TokenResponse | null>(config, '/oauth/token', {\r\n method: 'POST',\r\n body: JSON.stringify({\r\n grant_type: 'refresh_token',\r\n client_id: clientId,\r\n }),\r\n })\r\n return data || null\r\n}\r\n\r\nexport async function checkSession(config: PofsisAuthConfig) {\r\n try {\r\n await request(config, '/auth/session')\r\n return true\r\n } catch {\r\n return false\r\n }\r\n}\r\n\r\nexport async function signOut(config: PofsisAuthConfig) {\r\n await request(config, '/auth/logout', { method: 'POST' })\r\n}\r\n\r\nexport async function getAccountProfile(config: PofsisAuthConfig, accessToken: string) {\r\n const { data } = await request<AccountProfile>(config, '/auth/profile/me', {\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n })\r\n return data\r\n}\r\n\r\nexport async function updateAccountProfile(\r\n config: PofsisAuthConfig,\r\n accessToken: string,\r\n profile: { firstName?: string | null; lastName?: string | null },\r\n) {\r\n const { data } = await request<AccountProfile>(config, '/auth/profile/me', {\r\n method: 'PATCH',\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n body: JSON.stringify(profile),\r\n })\r\n return data\r\n}\r\n\r\nexport async function uploadAccountProfileImage(\r\n config: PofsisAuthConfig,\r\n accessToken: string,\r\n kind: 'profile' | 'cover',\r\n file: File,\r\n) {\r\n const body = new FormData()\r\n body.append('file', file)\r\n const { data } = await request<AccountProfile>(config, `/auth/profile/me/images/${kind}`, {\r\n method: 'POST',\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n body,\r\n })\r\n return data\r\n}\r\n\r\nexport async function deleteAccountProfileImage(\r\n config: PofsisAuthConfig,\r\n accessToken: string,\r\n kind: 'profile' | 'cover',\r\n) {\r\n const { data } = await request<AccountProfile>(config, `/auth/profile/me/images/${kind}`, {\r\n method: 'DELETE',\r\n headers: { Authorization: `Bearer ${accessToken}` },\r\n })\r\n return data\r\n}\r\n","import type { AuthLaunchOptions, AuthMethod, AuthScreen } from '../types'\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\nconst PHILIPPINE_MOBILE = /^(?:\\+63|63|0)?9\\d{9}$/\nconst METHODS = new Set<AuthMethod>(['password', 'passkey', 'otp'])\nconst SCREENS = new Set<AuthScreen>(['login', 'signup', 'reset'])\nconst MAX_HINT_LENGTH = 320\n\nfunction normalizeHint(value: unknown, emailOnly = false): string | undefined {\n const candidate = typeof value === 'string' ? value.trim() : ''\n if (!candidate || candidate.length > MAX_HINT_LENGTH) return undefined\n if (EMAIL.test(candidate)) return candidate.toLowerCase()\n const compact = candidate.replace(/[\\s()-]/g, '')\n if (emailOnly || !PHILIPPINE_MOBILE.test(compact)) return undefined\n return `+63${compact.replace(/^(?:\\+63|63|0)/, '')}`\n}\n\nexport function normalizeAuthLaunchOptions(\n value?: AuthLaunchOptions | string | null,\n defaultScreen: AuthScreen = 'login',\n) {\n const options = typeof value === 'string' ? { returnUrl: value } : value || {}\n const requestedScreen = options.screen === 'register' ? 'signup' : options.screen\n const screen = SCREENS.has(requestedScreen as AuthScreen)\n ? (requestedScreen as AuthScreen)\n : defaultScreen\n const requestedMethod = METHODS.has(options.method as AuthMethod)\n ? (options.method as AuthMethod)\n : undefined\n const method =\n screen === 'login' ||\n (screen === 'signup' && (requestedMethod === 'password' || requestedMethod === 'otp'))\n ? requestedMethod\n : undefined\n return {\n returnUrl: options.returnUrl,\n screen,\n loginHint: normalizeHint(options.loginHint),\n method,\n }\n}\n\nexport function authLaunchOptionsFromSearch(search: string) {\n const params = new URLSearchParams(search)\n const canonicalHint = params.get('login_hint')\n const loginHint =\n canonicalHint !== null\n ? normalizeHint(canonicalHint)\n : normalizeHint(params.get('email'), true)\n return normalizeAuthLaunchOptions({\n screen: (params.get('screen') || undefined) as AuthLaunchOptions['screen'],\n loginHint,\n method: (params.get('method') || undefined) as AuthLaunchOptions['method'],\n })\n}\n\nexport function buildAuthDestination({\n authUrl,\n query,\n options,\n}: {\n authUrl: string\n query: URLSearchParams\n options?: AuthLaunchOptions\n}) {\n const launch = normalizeAuthLaunchOptions(options)\n const authorizationUrl = new URL(authUrl)\n authorizationUrl.search = query.toString()\n if (options?.presentation === 'modal') {\n authorizationUrl.searchParams.set('presentation', 'modal')\n }\n if (launch.loginHint) authorizationUrl.searchParams.set('login_hint', launch.loginHint)\n if (launch.screen === 'login' && launch.method) {\n authorizationUrl.searchParams.set('method', launch.method)\n }\n if (launch.screen === 'login') return authorizationUrl.toString()\n\n const pathname = launch.screen === 'signup' ? '/signup' : '/forgot-password'\n const destination = new URL(pathname, authorizationUrl)\n const clientId = query.get('client_id')\n if (clientId) destination.searchParams.set('client_id', clientId)\n if (options?.presentation === 'modal') destination.searchParams.set('presentation', 'modal')\n destination.searchParams.set(\n 'return_to',\n `${authorizationUrl.pathname}${authorizationUrl.search}`,\n )\n if (launch.loginHint) destination.searchParams.set('login_hint', launch.loginHint)\n if (launch.screen === 'signup') {\n destination.searchParams.set('method', launch.method || 'password')\n }\n return destination.toString()\n}\n","import type { PofsisAuthClientConfig, ResolvedPofsisAuthConfig } from '../types'\n\nfunction stripTrailingSlash(value: string) {\n return value.replace(/\\/$/, '')\n}\n\nexport type ConfigOverrides = Partial<PofsisAuthClientConfig>\n\n/**\n * Validate and normalize explicitly supplied runtime configuration.\n */\nexport function resolveConfig(overrides: ConfigOverrides = {}): ResolvedPofsisAuthConfig {\n const applicationId = overrides.applicationId?.trim()\n const apiBaseUrl = overrides.apiBaseUrl?.trim()\n const authUrl = overrides.authUrl?.trim()\n const scope = overrides.scope?.trim() || 'openid profile email'\n const callbackPath = overrides.callbackPath?.trim() || '/auth/callback'\n const popup = {\n width: overrides.popup?.width ?? 480,\n height: overrides.popup?.height ?? 720,\n name: overrides.popup?.name?.trim() || 'pofsis-auth',\n timeoutMs: overrides.popup?.timeoutMs ?? 300_000,\n }\n const modal = {\n width: overrides.modal?.width ?? 480,\n height: overrides.modal?.height ?? 720,\n timeoutMs: overrides.modal?.timeoutMs ?? 300_000,\n readyTimeoutMs: overrides.modal?.readyTimeoutMs ?? 15_000,\n }\n\n const missing: string[] = []\n if (!applicationId) missing.push('applicationId')\n if (!apiBaseUrl) missing.push('apiBaseUrl')\n if (!authUrl) missing.push('authUrl')\n if (missing.length) {\n throw new Error(`@pofsis-nbt/pofsis-auth missing config: ${missing.join(', ')}`)\n }\n if (!applicationId || !apiBaseUrl || !authUrl) {\n throw new Error('@pofsis-nbt/pofsis-auth missing config')\n }\n if (\n !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(\n applicationId,\n )\n ) {\n throw new Error('@pofsis-nbt/pofsis-auth applicationId must be a UUID')\n }\n if (!callbackPath.startsWith('/') || callbackPath.startsWith('//')) {\n throw new Error('@pofsis-nbt/pofsis-auth callbackPath must be application-relative')\n }\n if (popup.width <= 0 || popup.height <= 0 || popup.timeoutMs <= 0) {\n throw new Error('@pofsis-nbt/pofsis-auth popup dimensions and timeout must be positive')\n }\n if (\n modal.width <= 0 ||\n modal.height <= 0 ||\n modal.timeoutMs <= 0 ||\n modal.readyTimeoutMs <= 0\n ) {\n throw new Error('@pofsis-nbt/pofsis-auth modal dimensions and timeouts must be positive')\n }\n\n return {\n applicationId: applicationId.toLowerCase(),\n apiBaseUrl: stripTrailingSlash(apiBaseUrl),\n authUrl: stripTrailingSlash(authUrl),\n scope,\n callbackPath,\n popup,\n modal,\n }\n}\n","const encode = (bytes: Uint8Array) =>\r\n btoa(String.fromCharCode(...bytes))\r\n .replace(/\\+/g, '-')\r\n .replace(/\\//g, '_')\r\n .replace(/=+$/, '')\r\n\r\nexport const randomValue = () => encode(crypto.getRandomValues(new Uint8Array(32)))\r\n\r\nexport async function pkceChallenge(verifier: string) {\r\n return encode(\r\n new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier))),\r\n )\r\n}\r\n","export const POPUP_MESSAGE_TYPE = 'pofsis-auth:callback'\nexport const MODAL_INIT_MESSAGE_TYPE = 'pofsis-auth:frame-init'\nexport const MODAL_READY_MESSAGE_TYPE = 'pofsis-auth:frame-ready'\n\nexport type PopupCallbackMessage = {\n type: typeof POPUP_MESSAGE_TYPE\n code?: string\n state?: string\n error?: string\n correlationId?: string\n}\n\nexport type ModalProtocolMessage = {\n type: typeof MODAL_INIT_MESSAGE_TYPE | typeof MODAL_READY_MESSAGE_TYPE\n state: string\n correlationId: string\n applicationId: string\n}\n\nexport function correlationFromState(state: string | null) {\n if (!state) return undefined\n const separator = state.indexOf('.')\n return separator > 0 ? state.slice(0, separator) : undefined\n}\n\nexport function relayAuthCallback(targetOrigin = window.location.origin) {\n const params = new URLSearchParams(window.location.search)\n const state = params.get('state') || undefined\n const correlationId = correlationFromState(state || null)\n if (!correlationId) return false\n const opener = window.opener && !window.opener.closed ? window.opener : null\n const parent = window.parent !== window ? window.parent : null\n const recipient = opener || parent\n if (!recipient) return false\n const message: PopupCallbackMessage = {\n type: POPUP_MESSAGE_TYPE,\n code: params.get('code') || undefined,\n state,\n error: params.get('error') || undefined,\n correlationId,\n }\n recipient.postMessage(message, targetOrigin)\n if (opener) window.close()\n return true\n}\n\n/** @deprecated Use relayAuthCallback for both popup and modal callbacks. */\nexport const relayPopupCallback = relayAuthCallback\n","import { checkSession, exchangeCode, fetchOAuthClient, refresh, signOut } from '../auth/api'\nimport { buildAuthDestination, normalizeAuthLaunchOptions } from '../auth/authLaunch'\nimport { resolveConfig } from '../auth/config'\nimport { pkceChallenge, randomValue } from '../auth/pkce'\nimport type {\n AuthLaunchOptions,\n AuthResult,\n OAuthClientConfig,\n PofsisAuthClientConfig,\n ResolvedPofsisAuthConfig,\n PofsisUser,\n SessionPayload,\n} from '../types'\nimport {\n correlationFromState,\n MODAL_INIT_MESSAGE_TYPE,\n MODAL_READY_MESSAGE_TYPE,\n POPUP_MESSAGE_TYPE,\n type ModalProtocolMessage,\n type PopupCallbackMessage,\n} from './popupProtocol'\n\ntype Subscriber = (session: SessionPayload | null) => void\ntype AuthAttempt = {\n presentation: 'popup' | 'modal'\n source: Window\n state: string\n verifier: string\n correlationId: string\n returnUrl?: string\n resolve: (result: AuthResult) => void\n reject: (error: Error) => void\n timer?: ReturnType<typeof setInterval>\n timeout: ReturnType<typeof setTimeout>\n readyTimeout?: ReturnType<typeof setTimeout>\n ready?: boolean\n authOrigin?: string\n focus: () => void\n cleanup: () => void\n}\n\nconst safeLocalPath = (value?: string) =>\n value?.startsWith('/') && !value.startsWith('//') ? value : undefined\n\nconst toSession = (result: { token_type: string; expires_in: number; user: PofsisUser }) => ({\n token_type: result.token_type,\n expires_in: result.expires_in,\n user: result.user,\n})\n\nexport class PofsisAuthClient {\n readonly config: ResolvedPofsisAuthConfig\n private token: string | null = null\n private session: SessionPayload | null = null\n private client: OAuthClientConfig | null = null\n private clientPromise: Promise<OAuthClientConfig> | null = null\n private refreshPromise: Promise<void> | null = null\n private subscribers = new Set<Subscriber>()\n private attempt: AuthAttempt | null = null\n private listening = false\n\n constructor(config: PofsisAuthClientConfig) {\n this.config = resolveConfig(config)\n this.attach()\n }\n\n private attach() {\n if (this.listening) return\n window.addEventListener('message', this.onPopupMessage)\n this.listening = true\n }\n\n destroy() {\n window.removeEventListener('message', this.onPopupMessage)\n this.listening = false\n const attempt = this.finishAttempt()\n if (attempt) {\n attempt.resolve({ status: 'cancelled' })\n }\n this.subscribers.clear()\n }\n\n getUser() {\n return this.session?.user ?? null\n }\n\n getSession() {\n return this.session\n }\n\n getAccessToken() {\n return this.token\n }\n\n subscribe(listener: Subscriber) {\n this.attach()\n this.subscribers.add(listener)\n listener(this.session)\n return () => {\n this.subscribers.delete(listener)\n }\n }\n\n private emit() {\n for (const listener of this.subscribers) listener(this.session)\n }\n\n private accept(result: Awaited<ReturnType<typeof exchangeCode>>) {\n this.token = result.access_token\n this.session = toSession(result)\n this.emit()\n }\n\n private loadClient() {\n if (!this.clientPromise) {\n this.clientPromise = fetchOAuthClient(this.config)\n .then((client) => (this.client = client))\n .catch((error) => {\n this.clientPromise = null\n throw error\n })\n }\n return this.clientPromise\n }\n\n getOAuthClient() {\n return this.loadClient()\n }\n\n async refreshSession() {\n const client = await this.loadClient()\n if (!this.refreshPromise) {\n this.refreshPromise = refresh(this.config, client.client_id)\n .then((result) => {\n if (result) this.accept(result)\n else this.clearSession()\n })\n .finally(() => (this.refreshPromise = null))\n }\n return this.refreshPromise\n }\n\n async isRemoteSessionActive() {\n return checkSession(this.config)\n }\n\n clearSession() {\n this.token = null\n this.session = null\n this.emit()\n }\n\n replaceUser(user: PofsisUser) {\n if (!this.session) return\n this.session = { ...this.session, user }\n this.emit()\n }\n\n async logout() {\n try {\n await signOut(this.config)\n } finally {\n this.clearSession()\n }\n }\n\n signup(options: Omit<AuthLaunchOptions, 'screen'> = {}) {\n return this.login({ ...options, screen: 'signup' })\n }\n\n resetPassword(options: Omit<AuthLaunchOptions, 'screen'> = {}) {\n return this.login({ ...options, screen: 'reset' })\n }\n\n async login(options: AuthLaunchOptions = {}): Promise<AuthResult> {\n const launch = normalizeAuthLaunchOptions(options)\n const presentation = options.presentation ?? 'popup'\n if (presentation === 'popup') return this.openPopup({ ...options, ...launch })\n if (presentation === 'modal') return this.openModal({ ...options, ...launch })\n return this.startRedirect({ ...options, ...launch })\n }\n\n private async authorizationUrl(options: AuthLaunchOptions, state: string, verifier: string) {\n const client = await this.loadClient()\n const query = new URLSearchParams({\n client_id: client.client_id,\n redirect_uri: client.redirect_uri,\n response_type: 'code',\n scope: this.config.scope,\n state,\n code_challenge: await pkceChallenge(verifier),\n code_challenge_method: 'S256',\n })\n return buildAuthDestination({\n authUrl: this.config.authUrl,\n query,\n options,\n })\n }\n\n private storageKey(suffix: string) {\n return `${this.config.applicationId}.auth.${suffix}`\n }\n\n private async startRedirect(options: AuthLaunchOptions): Promise<AuthResult> {\n const state = randomValue()\n const verifier = randomValue()\n sessionStorage.setItem(this.storageKey('state'), state)\n sessionStorage.setItem(this.storageKey('verifier'), verifier)\n const returnUrl = safeLocalPath(options.returnUrl)\n if (returnUrl) sessionStorage.setItem(this.storageKey('return-path'), returnUrl)\n else sessionStorage.removeItem(this.storageKey('return-path'))\n window.location.assign(await this.authorizationUrl(options, state, verifier))\n return { status: 'redirecting' }\n }\n\n private async openPopup(options: AuthLaunchOptions): Promise<AuthResult> {\n if (this.attempt) return this.joinAttempt(this.attempt)\n const { width, height, name, timeoutMs } = this.config.popup\n const left = Math.max(0, window.screenX + (window.outerWidth - width) / 2)\n const top = Math.max(0, window.screenY + (window.outerHeight - height) / 2)\n const popup = window.open(\n 'about:blank',\n name,\n `popup=yes,width=${width},height=${height},left=${Math.round(left)},top=${Math.round(top)}`,\n )\n if (!popup) return this.startRedirect({ ...options, presentation: 'redirect' })\n\n const correlationId = randomValue()\n const state = `${correlationId}.${randomValue()}`\n const verifier = randomValue()\n const returnUrl = safeLocalPath(options.returnUrl)\n return new Promise<AuthResult>((resolve, reject) => {\n const timer = setInterval(() => {\n if (!popup.closed) return\n const attempt = this.finishAttempt()\n attempt?.resolve({ status: 'cancelled' })\n }, 250)\n const timeout = setTimeout(() => {\n const attempt = this.finishAttempt()\n popup.close()\n attempt?.reject(new Error('POFSIS Auth popup timed out.'))\n }, timeoutMs)\n this.attempt = {\n presentation: 'popup',\n source: popup,\n state,\n verifier,\n correlationId,\n returnUrl,\n resolve,\n reject,\n timer,\n timeout,\n focus: () => popup.focus(),\n cleanup: () => popup.close(),\n }\n void this.authorizationUrl(options, state, verifier)\n .then((url) => popup.location.replace(url))\n .catch((error) => {\n const attempt = this.finishAttempt()\n popup.close()\n attempt?.reject(error instanceof Error ? error : new Error(String(error)))\n })\n })\n }\n\n private async openModal(options: AuthLaunchOptions): Promise<AuthResult> {\n if (this.attempt) return this.joinAttempt(this.attempt)\n\n const { width, height, timeoutMs, readyTimeoutMs } = this.config.modal\n const previousFocus =\n document.activeElement instanceof HTMLElement ? document.activeElement : null\n const dialog = document.createElement('dialog')\n const header = document.createElement('div')\n const title = document.createElement('span')\n const close = document.createElement('button')\n const iframe = document.createElement('iframe')\n\n dialog.setAttribute('aria-label', 'POFSIS authentication')\n dialog.dataset.pofsisAuthModal = ''\n Object.assign(dialog.style, {\n width: `min(${width}px, calc(100vw - 32px))`,\n height: `min(${height}px, calc(100dvh - 32px))`,\n maxWidth: 'none',\n maxHeight: 'none',\n padding: '0',\n border: '0',\n borderRadius: '12px',\n boxShadow: '0 24px 80px rgba(0, 0, 0, 0.28)',\n overflow: 'hidden',\n })\n Object.assign(header.style, {\n height: '48px',\n padding: '0 10px 0 16px',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n background: '#fff',\n borderBottom: '1px solid rgba(0, 0, 0, 0.10)',\n font: '500 14px/20px Inter, sans-serif',\n })\n title.textContent =\n options.screen === 'signup'\n ? 'Create account'\n : options.screen === 'reset'\n ? 'Reset password'\n : 'Sign in'\n close.type = 'button'\n close.setAttribute('aria-label', 'Close authentication')\n close.textContent = '\\u00d7'\n Object.assign(close.style, {\n width: '36px',\n height: '36px',\n padding: '0',\n border: '0',\n borderRadius: '8px',\n background: 'transparent',\n color: '#0a0a0a',\n cursor: 'pointer',\n font: '400 26px/36px sans-serif',\n })\n iframe.title = title.textContent\n iframe.setAttribute(\n 'sandbox',\n 'allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox',\n )\n iframe.setAttribute('allow', 'publickey-credentials-get *; publickey-credentials-create *')\n Object.assign(iframe.style, {\n display: 'block',\n width: '100%',\n height: 'calc(100% - 48px)',\n border: '0',\n background: '#fff',\n })\n header.append(title, close)\n dialog.append(header, iframe)\n document.body.append(dialog)\n\n const styleId = 'pofsis-auth-modal-style'\n if (!document.getElementById(styleId)) {\n const style = document.createElement('style')\n style.id = styleId\n style.textContent =\n '[data-pofsis-auth-modal]::backdrop{background:rgba(10,10,10,.56);backdrop-filter:blur(2px)}'\n document.head.append(style)\n }\n\n const correlationId = randomValue()\n const state = `${correlationId}.${randomValue()}`\n const verifier = randomValue()\n const returnUrl = safeLocalPath(options.returnUrl)\n\n return new Promise<AuthResult>((resolve, reject) => {\n let attempt: AuthAttempt\n const cancel = () => {\n if (this.attempt !== attempt) return\n this.finishAttempt()?.resolve({ status: 'cancelled' })\n }\n close.addEventListener('click', cancel)\n dialog.addEventListener('cancel', (event) => {\n event.preventDefault()\n cancel()\n })\n dialog.addEventListener('click', (event) => {\n if (event.target !== dialog) return\n const rect = dialog.getBoundingClientRect()\n if (\n event.clientX < rect.left ||\n event.clientX > rect.right ||\n event.clientY < rect.top ||\n event.clientY > rect.bottom\n )\n cancel()\n })\n\n const timeout = setTimeout(() => {\n const completed = this.finishAttempt()\n completed?.reject(new Error('POFSIS Auth modal timed out.'))\n }, timeoutMs)\n const source = iframe.contentWindow\n if (!source) {\n dialog.remove()\n clearTimeout(timeout)\n reject(new Error('POFSIS Auth modal could not be created.'))\n return\n }\n attempt = {\n presentation: 'modal',\n source,\n state,\n verifier,\n correlationId,\n returnUrl,\n resolve,\n reject,\n timeout,\n focus: () => close.focus(),\n cleanup: () => {\n dialog.remove()\n previousFocus?.focus()\n },\n }\n this.attempt = attempt\n dialog.showModal()\n close.focus()\n\n void this.authorizationUrl(options, state, verifier)\n .then((url) => {\n if (this.attempt !== attempt) return\n const authOrigin = new URL(url).origin\n attempt.authOrigin = authOrigin\n const initMessage: ModalProtocolMessage = {\n type: MODAL_INIT_MESSAGE_TYPE,\n state,\n correlationId,\n applicationId: this.config.applicationId,\n }\n const sendInit = () =>\n iframe.contentWindow?.postMessage(initMessage, authOrigin)\n iframe.addEventListener('load', sendInit)\n iframe.src = url\n sendInit()\n attempt.timer = setInterval(sendInit, 250)\n attempt.readyTimeout = setTimeout(() => {\n const completed = this.finishAttempt()\n completed?.reject(new Error('POFSIS Auth modal could not be embedded.'))\n }, readyTimeoutMs)\n })\n .catch((error) => {\n const completed = this.finishAttempt()\n completed?.reject(error instanceof Error ? error : new Error(String(error)))\n })\n })\n }\n\n private joinAttempt(attempt: AuthAttempt) {\n attempt.focus()\n return new Promise<AuthResult>((resolve, reject) => {\n const originalResolve = attempt.resolve\n const originalReject = attempt.reject\n attempt.resolve = (value) => {\n originalResolve(value)\n resolve(value)\n }\n attempt.reject = (error) => {\n originalReject(error)\n reject(error)\n }\n })\n }\n\n private finishAttempt() {\n const attempt = this.attempt\n if (!attempt) return null\n if (attempt.timer) clearInterval(attempt.timer)\n clearTimeout(attempt.timeout)\n if (attempt.readyTimeout) clearTimeout(attempt.readyTimeout)\n this.attempt = null\n attempt.cleanup()\n return attempt\n }\n\n private onPopupMessage = (event: MessageEvent<PopupCallbackMessage | ModalProtocolMessage>) => {\n const attempt = this.attempt\n const message = event.data\n if (\n attempt?.presentation === 'modal' &&\n message?.type === MODAL_READY_MESSAGE_TYPE &&\n event.origin === attempt.authOrigin &&\n event.source === attempt.source &&\n message.applicationId === this.config.applicationId &&\n message.correlationId === attempt.correlationId &&\n message.state === attempt.state\n ) {\n attempt.ready = true\n if (attempt.timer) clearInterval(attempt.timer)\n if (attempt.readyTimeout) clearTimeout(attempt.readyTimeout)\n attempt.timer = undefined\n attempt.readyTimeout = undefined\n return\n }\n if (\n !attempt ||\n (attempt.presentation === 'modal' && !attempt.ready) ||\n event.origin !== window.location.origin ||\n event.source !== attempt.source ||\n message?.type !== POPUP_MESSAGE_TYPE ||\n message.correlationId !== attempt.correlationId ||\n correlationFromState(message.state || null) !== attempt.correlationId ||\n message.state !== attempt.state\n )\n return\n\n const completed = this.finishAttempt()\n if (!completed) return\n if (message.error || !message.code) {\n completed.reject(new Error(message.error || 'POFSIS Auth callback was incomplete.'))\n return\n }\n void this.completeCode(message.code, message.state, completed.verifier)\n .then(() => {\n if (completed.returnUrl) window.history.replaceState(null, '', completed.returnUrl)\n completed.resolve({ status: 'authenticated', user: this.getUser()! })\n })\n .catch((error) => {\n completed.reject(error instanceof Error ? error : new Error(String(error)))\n })\n }\n\n private async completeCode(code: string, state: string, verifier: string) {\n if (!state || !verifier) throw new Error('Authentication state could not be verified.')\n const client = await this.loadClient()\n this.accept(await exchangeCode(this.config, code, verifier, client))\n }\n\n async completeRedirectCallback(code: string, state: string) {\n const expected = sessionStorage.getItem(this.storageKey('state'))\n const verifier = sessionStorage.getItem(this.storageKey('verifier'))\n sessionStorage.removeItem(this.storageKey('state'))\n sessionStorage.removeItem(this.storageKey('verifier'))\n if (!expected || !verifier || state !== expected) {\n throw new Error('Authentication state could not be verified.')\n }\n await this.completeCode(code, state, verifier)\n }\n}\n\nexport function createPofsisAuth(config: PofsisAuthClientConfig) {\n return new PofsisAuthClient(config)\n}\n","import { createPofsisAuth, type PofsisAuthClient } from '../core'\nimport type { AuthLaunchOptions } from '../types'\n\nconst observed = [\n 'application-id',\n 'api-base-url',\n 'auth-url',\n 'scope',\n 'return-url',\n 'screen',\n 'method',\n 'login-hint',\n 'presentation',\n]\n\nexport class PofsisSignInElement extends HTMLElement {\n static get observedAttributes() {\n return observed\n }\n private client: PofsisAuthClient | null = null\n private button: HTMLButtonElement | null = null\n\n connectedCallback() {\n this.render()\n }\n disconnectedCallback() {\n this.client?.destroy()\n }\n attributeChangedCallback() {\n if (this.isConnected) this.render()\n }\n\n private required(name: string) {\n const value = this.getAttribute(name)?.trim()\n if (!value) throw new Error(`<pofsis-sign-in> requires ${name}`)\n return value\n }\n\n private render() {\n this.client?.destroy()\n this.client = createPofsisAuth({\n applicationId: this.required('application-id'),\n apiBaseUrl: this.required('api-base-url'),\n authUrl: this.required('auth-url'),\n scope: this.getAttribute('scope') || undefined,\n })\n const label = this.textContent?.trim() || 'Sign in'\n this.replaceChildren()\n this.button = document.createElement('button')\n this.button.type = 'button'\n this.button.part.add('button')\n this.button.textContent = label\n this.button.addEventListener('click', () => void this.launch())\n this.append(this.button)\n }\n\n private async launch() {\n if (!this.client || !this.button) return\n this.button.disabled = true\n const options: AuthLaunchOptions = {\n presentation: (['popup', 'modal', 'redirect'].includes(\n this.getAttribute('presentation') || '',\n )\n ? this.getAttribute('presentation')\n : 'popup') as AuthLaunchOptions['presentation'],\n returnUrl: this.getAttribute('return-url') || undefined,\n screen: (this.getAttribute('screen') || 'login') as AuthLaunchOptions['screen'],\n method: (this.getAttribute('method') || undefined) as AuthLaunchOptions['method'],\n loginHint: this.getAttribute('login-hint') || undefined,\n }\n try {\n const result = await this.client.login(options)\n this.dispatchEvent(\n new CustomEvent(`pofsis-auth-${result.status}`, {\n bubbles: true,\n composed: true,\n detail: result,\n }),\n )\n } catch (error) {\n this.dispatchEvent(\n new CustomEvent('pofsis-auth-error', {\n bubbles: true,\n composed: true,\n detail: { error },\n }),\n )\n } finally {\n this.button.disabled = false\n }\n }\n}\n\nif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Aa,YAAY,GAAK,IAAA,GAC9C,OAAS,KAAK,aAAa,QAAQ,GAAK,QACxC,OAAS,KAAK,aAAa,QAAQ,GAAK,IAAA,GACxC,UAAW,KAAK,aAAa,YAAY,GAAK,IAAA,EAClD,EACA,GAAI,CACA,IAAM,EAAS,MAAM,KAAK,OAAO,MAAM,CAAO,EAC9C,KAAK,cACD,IAAI,YAAY,eAAe,EAAO,SAAU,CAC5C,QAAS,GACT,SAAU,GACV,OAAQ,CACZ,CAAC,CACL,CACJ,OAAS,EAAO,CACZ,KAAK,cACD,IAAI,YAAY,oBAAqB,CACjC,QAAS,GACT,SAAU,GACV,OAAQ,CAAE,OAAM,CACpB,CAAC,CACL,CACJ,QAAU,CACN,KAAK,OAAO,SAAW,EAC3B,CACJ,CACJ,SAEK,eAAe,IAAI,gBAAgB,GACpC,eAAe,OAAO,iBAAkB,CAAmB"}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { attachAuthInterceptor } from '../attachAuthInterceptor';
|
|
|
3
3
|
export { AuthErrorScreen, AuthLoadingScreen, RequireAuth } from '../components';
|
|
4
4
|
export type { RequireAuthProps } from '../components';
|
|
5
5
|
export { useAuth } from '../context/useAuth';
|
|
6
|
-
export type { AccountProfile, AuthComponentOverrides, AuthContextValue, AuthErrorScreenProps, AuthLaunchOptions, AuthLoadingScreenProps, AuthMethod, AuthPopupOptions, AuthResult, AuthScreen, OAuthClientConfig, PofsisAuthConfig, PofsisAuthProps, PofsisUser, SessionPayload, TokenResponse, } from '../types';
|
|
6
|
+
export type { AccountProfile, AuthComponentOverrides, AuthContextValue, AuthErrorScreenProps, AuthLaunchOptions, AuthLoadingScreenProps, AuthMethod, AuthModalOptions, AuthPopupOptions, AuthResult, AuthScreen, OAuthClientConfig, PofsisAuthConfig, PofsisAuthProps, PofsisUser, SessionPayload, TokenResponse, } from '../types';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,YAAY,EACR,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,GAChB,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,YAAY,EACR,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,GAChB,MAAM,UAAU,CAAA"}
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./RequireAuth-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./RequireAuth-BkYhk-9p.cjs");exports.AuthErrorScreen=e.o,exports.AuthLoadingScreen=e.a,exports.PofsisAuth=e.i,exports.RequireAuth=e.t,exports.attachAuthInterceptor=e.r,exports.useAuth=e.n;
|
package/dist/react.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "./RequireAuth-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./RequireAuth-DroX56rd.js";
|
|
2
2
|
export { r as AuthErrorScreen, e as AuthLoadingScreen, t as PofsisAuth, a as RequireAuth, i as attachAuthInterceptor, n as useAuth };
|
package/dist/types.d.ts
CHANGED
|
@@ -40,10 +40,12 @@ export interface PofsisAuthConfig {
|
|
|
40
40
|
scope: string;
|
|
41
41
|
callbackPath?: string;
|
|
42
42
|
popup?: AuthPopupOptions;
|
|
43
|
+
modal?: AuthModalOptions;
|
|
43
44
|
}
|
|
44
45
|
export interface ResolvedPofsisAuthConfig extends PofsisAuthConfig {
|
|
45
46
|
callbackPath: string;
|
|
46
47
|
popup: Required<AuthPopupOptions>;
|
|
48
|
+
modal: Required<AuthModalOptions>;
|
|
47
49
|
}
|
|
48
50
|
export type AuthPopupOptions = {
|
|
49
51
|
width?: number;
|
|
@@ -51,6 +53,12 @@ export type AuthPopupOptions = {
|
|
|
51
53
|
name?: string;
|
|
52
54
|
timeoutMs?: number;
|
|
53
55
|
};
|
|
56
|
+
export type AuthModalOptions = {
|
|
57
|
+
width?: number;
|
|
58
|
+
height?: number;
|
|
59
|
+
timeoutMs?: number;
|
|
60
|
+
readyTimeoutMs?: number;
|
|
61
|
+
};
|
|
54
62
|
export type AuthLoadingScreenProps = {
|
|
55
63
|
callback?: boolean;
|
|
56
64
|
};
|
|
@@ -69,8 +77,8 @@ export type AuthLaunchOptions = {
|
|
|
69
77
|
screen?: AuthScreen | 'register';
|
|
70
78
|
loginHint?: string;
|
|
71
79
|
method?: AuthMethod;
|
|
72
|
-
/** Popup for explicit user actions; redirect for route guards and fallback. */
|
|
73
|
-
presentation?: 'popup' | 'redirect';
|
|
80
|
+
/** Popup or modal for explicit user actions; redirect for route guards and fallback. */
|
|
81
|
+
presentation?: 'popup' | 'modal' | 'redirect';
|
|
74
82
|
};
|
|
75
83
|
export type AuthResult = {
|
|
76
84
|
status: 'authenticated';
|
|
@@ -87,6 +95,7 @@ export type PofsisAuthClientConfig = {
|
|
|
87
95
|
scope?: string;
|
|
88
96
|
callbackPath?: string;
|
|
89
97
|
popup?: AuthPopupOptions;
|
|
98
|
+
modal?: AuthModalOptions;
|
|
90
99
|
};
|
|
91
100
|
export interface AuthContextValue {
|
|
92
101
|
user: PofsisUser | null;
|
|
@@ -122,6 +131,8 @@ export type PofsisAuthProps = {
|
|
|
122
131
|
callbackPath?: string;
|
|
123
132
|
/** Popup dimensions, name, and timeout. */
|
|
124
133
|
popup?: AuthPopupOptions;
|
|
134
|
+
/** Embedded modal dimensions and readiness/authentication timeouts. */
|
|
135
|
+
modal?: AuthModalOptions;
|
|
125
136
|
/** Where to send the user after a successful callback. Default `/`. */
|
|
126
137
|
postLoginPath?: string;
|
|
127
138
|
/** Override the package's default loading and error screens. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IA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