@things-factory/auth-ui 10.1.41 → 10.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/components/abstract-password-reset.d.ts +6 -0
- package/dist-client/components/abstract-password-reset.js +16 -1
- package/dist-client/components/abstract-password-reset.js.map +1 -1
- package/dist-client/components/accept-invitation.js +2 -2
- package/dist-client/components/accept-invitation.js.map +1 -1
- package/dist-client/entries/auth/verify.d.ts +25 -0
- package/dist-client/entries/auth/verify.js +81 -0
- package/dist-client/entries/auth/verify.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/{invitation-token.d.ts → link-token.d.ts} +5 -4
- package/dist-client/utils/{invitation-token.js → link-token.js} +6 -5
- package/dist-client/utils/link-token.js.map +1 -0
- package/dist-client/utils/{invitation-token.test.js → link-token.test.js} +17 -17
- package/dist-client/utils/link-token.test.js.map +1 -0
- package/package.json +5 -5
- package/translations/en.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
- package/dist-client/utils/invitation-token.js.map +0 -1
- package/dist-client/utils/invitation-token.test.js.map +0 -1
- /package/dist-client/utils/{invitation-token.test.d.ts → link-token.test.d.ts} +0 -0
|
@@ -14,6 +14,12 @@ export declare abstract class AbstractPasswordReset extends AbstractAuthPage {
|
|
|
14
14
|
private passwordPattern;
|
|
15
15
|
private passwordHelp;
|
|
16
16
|
abstract get submitButtonLabel(): string;
|
|
17
|
+
/**
|
|
18
|
+
* The mailed link is `…#<token>`: the browser does not send what follows `#`, so the token stays
|
|
19
|
+
* out of server and proxy logs. Taken out of the address bar here as well — `replaceState`, so
|
|
20
|
+
* going back does not put it on screen.
|
|
21
|
+
*/
|
|
22
|
+
connectedCallback(): void;
|
|
17
23
|
render(): import("lit-html").TemplateResult<1>;
|
|
18
24
|
updated(changed: any): void;
|
|
19
25
|
languageUpdated(): void;
|
|
@@ -12,6 +12,7 @@ import { i18next } from '@operato/i18n';
|
|
|
12
12
|
import { AUTH_STYLE_SIGN } from '../auth-style-sign.js';
|
|
13
13
|
import { generatePasswordPatternHelp, generatePasswordPatternRegExp } from '../utils/password-rule.js';
|
|
14
14
|
import { AbstractAuthPage } from './abstract-auth-page.js';
|
|
15
|
+
import { readLinkToken } from '../utils/link-token.js';
|
|
15
16
|
import { EntryControlSizeStyles } from '../entry-control-size-styles.js';
|
|
16
17
|
export class AbstractPasswordReset extends AbstractAuthPage {
|
|
17
18
|
constructor() {
|
|
@@ -45,6 +46,19 @@ export class AbstractPasswordReset extends AbstractAuthPage {
|
|
|
45
46
|
`,
|
|
46
47
|
AUTH_STYLE_SIGN
|
|
47
48
|
]; }
|
|
49
|
+
/**
|
|
50
|
+
* The mailed link is `…#<token>`: the browser does not send what follows `#`, so the token stays
|
|
51
|
+
* out of server and proxy logs. Taken out of the address bar here as well — `replaceState`, so
|
|
52
|
+
* going back does not put it on screen.
|
|
53
|
+
*/
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
super.connectedCallback();
|
|
56
|
+
const { token, clean } = readLinkToken(window.location.href);
|
|
57
|
+
this.token = token;
|
|
58
|
+
if (clean && clean !== window.location.href) {
|
|
59
|
+
window.history.replaceState(null, '', clean);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
48
62
|
render() {
|
|
49
63
|
var { icon, title, description } = this.applicationMeta;
|
|
50
64
|
const { disableUserFavoredLanguage, languages } = this.data || {};
|
|
@@ -126,7 +140,8 @@ export class AbstractPasswordReset extends AbstractAuthPage {
|
|
|
126
140
|
}
|
|
127
141
|
updated(changed) {
|
|
128
142
|
super.updated(changed);
|
|
129
|
-
|
|
143
|
+
/* A refused post renders the form again with the token it carried, in the page, not the address. */
|
|
144
|
+
if (changed.has('data') && this.data?.token) {
|
|
130
145
|
this.token = this.data.token;
|
|
131
146
|
}
|
|
132
147
|
if (changed.has('message')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-password-reset.js","sourceRoot":"","sources":["../../client/components/abstract-password-reset.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAChD,OAAO,8CAA8C,CAAA;AAErD,OAAO,0BAA0B,CAAA;AACjC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,iCAAiC,CAAA;AAExC,OAAO,oCAAoC,CAAA;AAE3C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAA;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAExE,MAAM,OAAgB,qBAAsB,SAAQ,gBAAgB;IAApE;;QAiCU,oBAAe,GAAW,EAAE,CAAA;QAC5B,iBAAY,GAAW,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"abstract-password-reset.js","sourceRoot":"","sources":["../../client/components/abstract-password-reset.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAChD,OAAO,8CAA8C,CAAA;AAErD,OAAO,0BAA0B,CAAA;AACjC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,iCAAiC,CAAA;AAExC,OAAO,oCAAoC,CAAA;AAE3C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAE,OAAO,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AAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;YAC5C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAA;QAC9B,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,YAAY,EAAE,CAAA;YACrB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,YAAY,CAAC;oBAChB,KAAK,EAAE,CAAC,CAAC;iBACV,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,eAAe;QACb,IAAI,CAAC,eAAe,GAAG,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAA;QACnF,IAAI,CAAC,YAAY,GAAG,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IACzE,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;IACtB,CAAC;;AArI2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAAU;AACT;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDAAe;AAEd;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8BAAe,WAAW;0DAAA","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/button/elevated-button.js'\nimport '@material/web/textfield/filled-text-field.js'\n\nimport '@operato/i18n/ox-i18n.js'\nimport '@operato/i18n/ox-i18n-selector.js'\nimport '@operato/layout/ox-snack-bar.js'\n\nimport '../components/profile-component.js'\n\nimport { css, html, nothing } from 'lit'\nimport { property, query } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { AUTH_STYLE_SIGN } from '../auth-style-sign.js'\nimport { generatePasswordPatternHelp, generatePasswordPatternRegExp } from '../utils/password-rule.js'\nimport { AbstractAuthPage } from './abstract-auth-page.js'\nimport { readLinkToken } from '../utils/link-token.js'\nimport { EntryControlSizeStyles } from '../entry-control-size-styles.js'\n\nexport abstract class AbstractPasswordReset extends AbstractAuthPage {\n static styles = [\n EntryControlSizeStyles,\n css`\n :host {\n position: relative;\n overflow: hidden;\n\n display: flex;\n flex-direction: row;\n\n width: 100vw;\n height: 100vh;\n height: 100dvh;\n }\n\n @media print {\n :host {\n width: 100%;\n height: 100%;\n min-height: 100vh;\n min-height: 100dvh;\n }\n }\n `,\n AUTH_STYLE_SIGN\n ]\n\n @property({ type: Object }) data: any\n @property({ type: String }) token?: string\n\n @query('#confirm-password') confirmPass!: HTMLElement\n\n private passwordPattern: string = ''\n private passwordHelp: string = ''\n\n abstract get submitButtonLabel(): string\n\n /**\n * The mailed link is `…#<token>`: the browser does not send what follows `#`, so the token stays\n * out of server and proxy logs. Taken out of the address bar here as well — `replaceState`, so\n * going back does not put it on screen.\n */\n connectedCallback() {\n super.connectedCallback()\n\n const { token, clean } = readLinkToken(window.location.href)\n\n this.token = token\n\n if (clean && clean !== window.location.href) {\n window.history.replaceState(null, '', clean)\n }\n }\n\n render() {\n var { icon, title, description } = this.applicationMeta\n const { disableUserFavoredLanguage, languages } = this.data || {}\n\n return html`\n <div class=\"wrap\">\n <div class=\"auth-brand\">\n <img src=${icon} />\n <strong class=\"name\">${title}</strong>\n <span class=\"welcome-msg\">${description}</span>\n </div>\n\n <div class=\"auth-form\">\n <h3><ox-i18n msgid=\"title.${this.title}\"></ox-i18n></h3>\n <form\n id=\"form\"\n action=\"${this.actionUrl}\"\n method=\"post\"\n @keypress=${e => {\n if (e.key == 'Enter') this._onSubmit(e)\n }}\n >\n <input name=\"token\" type=\"hidden\" .value=${this.token || ''} required />\n <div class=\"field\">\n <md-filled-text-field\n name=\"password\"\n type=\"password\"\n label=${String(i18next.t('label.password'))}\n pattern=${this.passwordPattern || ''}\n supporting-text=${this.passwordHelp}\n autocomplete=\"off\"\n @input=${e => {\n var val = e.target.value\n this.confirmPass.setAttribute('pattern', val.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '[$&]'))\n }}\n required\n ><md-icon slot=\"leading-icon\">password</md-icon></md-filled-text-field\n >\n </div>\n\n <div class=\"field\">\n <md-filled-text-field\n id=\"confirm-password\"\n name=\"confirm-password\"\n type=\"password\"\n label=${String(i18next.t('field.confirm password'))}\n autocomplete=\"off\"\n required\n ><md-icon slot=\"leading-icon\">password</md-icon></md-filled-text-field\n >\n </div>\n\n <md-elevated-button id=\"submit-button\" type=\"button\" @click=${e => this._onSubmit(e)}>\n <ox-i18n msgid=\"${this.submitButtonLabel}\"></ox-i18n>\n </md-elevated-button>\n\n ${!disableUserFavoredLanguage\n ? html` <div id=\"locale-area\">\n <label for=\"locale-selector\"><md-icon>language</md-icon></label>\n <ox-i18n-selector\n id=\"locale-selector\"\n value=${i18next.language || 'en-US'}\n .languages=${languages}\n @change=${e => {\n var locale = e.detail\n if (!locale) return\n\n i18next.changeLanguage(locale)\n }}\n ></ox-i18n-selector>\n </div>`\n : nothing}\n </form>\n </div>\n </div>\n\n <ox-snack-bar id=\"snackbar\" level=\"error\" .message=${this.message}></ox-snack-bar>\n `\n }\n\n updated(changed) {\n super.updated(changed)\n\n /* A refused post renders the form again with the token it carried, in the page, not the address. */\n if (changed.has('data') && this.data?.token) {\n this.token = this.data.token\n }\n\n if (changed.has('message')) {\n if (!this.message) {\n this.hideSnackbar()\n } else {\n this.showSnackbar({\n timer: -1\n })\n }\n }\n }\n\n languageUpdated() {\n this.passwordPattern = generatePasswordPatternRegExp(this.data.passwordRule).source\n this.passwordHelp = generatePasswordPatternHelp(this.data.passwordRule)\n }\n\n async submit() {\n this.formEl.submit()\n }\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import { i18next } from '@operato/i18n';
|
|
|
11
11
|
import { AUTH_STYLE_SIGN } from '../auth-style-sign.js';
|
|
12
12
|
import { EntryControlSizeStyles } from '../entry-control-size-styles.js';
|
|
13
13
|
import { AbstractAuthPage } from './abstract-auth-page.js';
|
|
14
|
-
import {
|
|
14
|
+
import { readLinkToken } from '../utils/link-token.js';
|
|
15
15
|
/**
|
|
16
16
|
* Accepting an invitation.
|
|
17
17
|
*
|
|
@@ -71,7 +71,7 @@ export class AcceptInvitation extends AbstractAuthPage {
|
|
|
71
71
|
}
|
|
72
72
|
connectedCallback() {
|
|
73
73
|
super.connectedCallback();
|
|
74
|
-
const { token, clean } =
|
|
74
|
+
const { token, clean } = readLinkToken(window.location.href);
|
|
75
75
|
this.token = token;
|
|
76
76
|
/*
|
|
77
77
|
* Taken out of the address bar and out of this history entry. `replaceState` rather than
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept-invitation.js","sourceRoot":"","sources":["../../client/components/accept-invitation.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAChD,OAAO,8CAA8C,CAAA;AAErD,OAAO,0BAA0B,CAAA;AACjC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAElE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;aAC7C,WAAM,GAAG;QACd,sBAAsB;QACtB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;KA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textfield/filled-text-field.js'\n\nimport '@operato/i18n/ox-i18n.js'\nimport '@operato/i18n/ox-i18n-selector.js'\nimport '@operato/layout/ox-snack-bar.js'\n\nimport { css, html, nothing } from 'lit'\nimport { property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { AUTH_STYLE_SIGN } from '../auth-style-sign.js'\nimport { EntryControlSizeStyles } from '../entry-control-size-styles.js'\nimport { AbstractAuthPage } from './abstract-auth-page.js'\nimport { readInvitationToken } from '../utils/invitation-token.js'\n\n/**\n * Accepting an invitation.\n *\n * ── Why the token is not in the address ─────────────────────────────────────\n * The link is `…/accept-invitation#<token>`, and a browser does not send what follows the `#`.\n * So the request that loads this page carries nothing, and the token stays out of server access\n * logs, proxy logs and `Referer`. This page reads it from the fragment and then clears it from\n * the address bar, so it does not sit in the browser's history either.\n *\n * The one place it can still travel is the mail being forwarded, and nothing about where the\n * token sits can prevent that. So the address it was sent to is asked for as well: holding the\n * link is not enough on its own.\n *\n * ── Why the password fields only appear after a try ─────────────────────────\n * Whether an address already has an account is not this page's to announce. It sends what it\n * has, and the server answers `invitation-needs-a-password` when it needs one — so the extra\n * fields appear for the person who is actually creating an account, and nobody learns anything\n * by loading the page.\n */\nexport class AcceptInvitation extends AbstractAuthPage {\n static styles = [\n EntryControlSizeStyles,\n css`\n :host {\n position: relative;\n overflow: hidden;\n\n display: flex;\n flex-direction: row;\n\n width: 100vw;\n height: 100vh;\n height: 100dvh;\n }\n\n .note {\n margin: 0 0 var(--spacing-medium) 0;\n font-size: 0.85rem;\n line-height: 1.5;\n color: var(--md-sys-color-on-surface-variant);\n }\n `,\n AUTH_STYLE_SIGN\n ]\n\n get pageName() {\n return 'accept invitation'\n }\n\n /*\n * ⚠ `/auth/…` — the server router carries that prefix. This read `/accept-invitation` until\n * 2026-09-24, which is no route; see the note beside `ACCEPT_INVITATION_PATH` in auth-base.\n */\n get actionUrl() {\n return '/auth/accept-invitation'\n }\n\n get title() {\n return 'accept invitation'\n }\n\n /** Read from the fragment on connect. Empty when the link was opened without one. */\n @property({ type: String }) token?: string\n\n /** The server asked for a password, so this person is creating an account. */\n @property({ type: Boolean }) needsPassword?: boolean\n\n /** Joined. The page stops being a form and says where to go. */\n @property({ type: Boolean }) joined?: boolean\n\n @property({ type: Boolean }) busy?: boolean\n\n connectedCallback() {\n super.connectedCallback()\n\n const { token, clean } = readInvitationToken(window.location.href)\n\n this.token = token\n\n /*\n * Taken out of the address bar and out of this history entry. `replaceState` rather than\n * `pushState`: going back should not put the token back on screen.\n */\n if (clean && clean !== window.location.href) {\n window.history.replaceState(null, '', clean)\n }\n }\n\n render() {\n const { icon, title, description } = this.applicationMeta\n const { disableUserFavoredLanguage, languages } = this.data || {}\n\n return html`\n <div class=\"wrap\">\n <div class=\"auth-brand\">\n <img src=${icon} />\n <strong class=\"name\">${title}</strong>\n <span class=\"welcome-msg\">${description}</span>\n </div>\n\n <div class=\"auth-form\">\n <h3><ox-i18n msgid=\"title.accept invitation\"></ox-i18n></h3>\n\n ${this.joined ? this.renderDone() : this.renderForm(disableUserFavoredLanguage, languages)}\n </div>\n </div>\n\n <ox-snack-bar id=\"snackbar\" level=\"error\" .message=${this.message}></ox-snack-bar>\n `\n }\n\n private renderDone() {\n return html`\n <p class=\"note\">${i18next.t('text.you have joined. sign in to continue')}</p>\n <md-elevated-button @click=${() => (window.location.href = '/auth/signin')}>\n <ox-i18n msgid=\"button.sign in\"></ox-i18n>\n </md-elevated-button>\n `\n }\n\n private renderForm(disableUserFavoredLanguage: boolean, languages: any) {\n return html`\n <form id=\"form\" @keypress=${(e: KeyboardEvent) => e.key === 'Enter' && this.accept()}>\n <p class=\"note\">${i18next.t('text.confirm the address this invitation was sent to')}</p>\n\n <div class=\"field\">\n <md-filled-text-field\n name=\"email\"\n type=\"email\"\n label=${String(i18next.t('field.email'))}\n autocomplete=\"email\"\n required\n ><md-icon slot=\"leading-icon\">mail</md-icon></md-filled-text-field\n >\n </div>\n\n ${this.token\n ? nothing\n : html`\n <div class=\"field\">\n <md-filled-text-field\n name=\"token\"\n label=${String(i18next.t('label.invitation code'))}\n supporting-text=${String(i18next.t('text.the code is printed in the invitation email'))}\n autocomplete=\"off\"\n required\n ><md-icon slot=\"leading-icon\">key</md-icon></md-filled-text-field\n >\n </div>\n `}\n ${this.needsPassword ? this.renderNewAccount() : nothing}\n\n <md-elevated-button id=\"submit-button\" type=\"button\" ?disabled=${this.busy} @click=${() => this.accept()}>\n <ox-i18n msgid=\"button.accept invitation\"></ox-i18n>\n </md-elevated-button>\n\n ${!disableUserFavoredLanguage\n ? html`<div id=\"locale-area\">\n <label for=\"locale-selector\"><md-icon>language</md-icon></label>\n <ox-i18n-selector\n id=\"locale-selector\"\n value=${i18next.language || 'en-US'}\n .languages=${languages}\n @change=${(e: CustomEvent) => e.detail && i18next.changeLanguage(e.detail as any)}\n ></ox-i18n-selector>\n </div>`\n : nothing}\n </form>\n `\n }\n\n private renderNewAccount() {\n return html`\n <p class=\"note\">${i18next.t('text.choose a password to finish joining')}</p>\n\n <div class=\"field\">\n <md-filled-text-field name=\"name\" label=${String(i18next.t('field.name'))} autocomplete=\"name\"\n ><md-icon slot=\"leading-icon\">person</md-icon></md-filled-text-field\n >\n </div>\n\n <div class=\"field\">\n <md-filled-text-field\n name=\"password\"\n type=\"password\"\n label=${String(i18next.t('label.password'))}\n autocomplete=\"new-password\"\n required\n ><md-icon slot=\"leading-icon\">password</md-icon></md-filled-text-field\n >\n </div>\n `\n }\n\n /*\n * ⚠ Not called `valueOf`. Overriding `Object.prototype.valueOf` with a different signature\n * makes the class type unassignable to `Object`, and every `@property` decorator on it then\n * fails to resolve — with an error that talks about decorators and never mentions the method.\n */\n private fieldValue(name: string): string {\n return (this.renderRoot.querySelector(`[name=\"${name}\"]`) as any)?.value?.trim() || ''\n }\n\n /*\n * The base class calls this to commit the page. It does not submit the form element: the\n * answer here is read rather than navigated to, because a refusal can mean \"now ask for a\n * password\" instead of \"stop\".\n */\n async submit() {\n await this.accept()\n }\n\n private async accept() {\n if (this.busy) {\n return\n }\n\n this.busy = true\n this.message = ''\n\n try {\n const response = await fetch(this.actionUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n token: this.token || this.fieldValue('token'),\n email: this.fieldValue('email'),\n name: this.fieldValue('name'),\n password: this.fieldValue('password')\n })\n })\n\n if (response.ok) {\n this.joined = true\n return\n }\n\n const refusal = await response.json().catch(() => ({}))\n\n /*\n * The one refusal that is not the end of the attempt — it means this person has no account\n * yet, which is exactly who this page is for.\n */\n if (refusal?.refusal?.code === 'invitation-needs-a-password' || refusal?.code === 'invitation-needs-a-password') {\n this.needsPassword = true\n this.message = String(i18next.t('text.choose a password to finish joining'))\n return\n }\n\n this.message = refusal?.message || String(i18next.t('text.this invitation cannot be used'))\n } catch (e) {\n this.message = String(i18next.t('text.this invitation cannot be used'))\n } finally {\n this.busy = false\n }\n }\n\n updated(changed: any) {\n super.updated(changed)\n\n if (changed.has('message')) {\n if (!this.message) {\n this.hideSnackbar()\n } else {\n this.showSnackbar({ timer: -1 })\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"accept-invitation.js","sourceRoot":"","sources":["../../client/components/accept-invitation.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,yCAAyC,CAAA;AAChD,OAAO,8CAA8C,CAAA;AAErD,OAAO,0BAA0B,CAAA;AACjC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,gBAA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EAAE,CAAC;;uDAAwB;AAGvB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;gDAAiB;AAEhB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;8CAAe","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@material/web/button/elevated-button.js'\nimport '@material/web/textfield/filled-text-field.js'\n\nimport '@operato/i18n/ox-i18n.js'\nimport '@operato/i18n/ox-i18n-selector.js'\nimport '@operato/layout/ox-snack-bar.js'\n\nimport { css, html, nothing } from 'lit'\nimport { property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { AUTH_STYLE_SIGN } from '../auth-style-sign.js'\nimport { EntryControlSizeStyles } from '../entry-control-size-styles.js'\nimport { AbstractAuthPage } from './abstract-auth-page.js'\nimport { readLinkToken } from '../utils/link-token.js'\n\n/**\n * Accepting an invitation.\n *\n * ── Why the token is not in the address ─────────────────────────────────────\n * The link is `…/accept-invitation#<token>`, and a browser does not send what follows the `#`.\n * So the request that loads this page carries nothing, and the token stays out of server access\n * logs, proxy logs and `Referer`. This page reads it from the fragment and then clears it from\n * the address bar, so it does not sit in the browser's history either.\n *\n * The one place it can still travel is the mail being forwarded, and nothing about where the\n * token sits can prevent that. So the address it was sent to is asked for as well: holding the\n * link is not enough on its own.\n *\n * ── Why the password fields only appear after a try ─────────────────────────\n * Whether an address already has an account is not this page's to announce. It sends what it\n * has, and the server answers `invitation-needs-a-password` when it needs one — so the extra\n * fields appear for the person who is actually creating an account, and nobody learns anything\n * by loading the page.\n */\nexport class AcceptInvitation extends AbstractAuthPage {\n static styles = [\n EntryControlSizeStyles,\n css`\n :host {\n position: relative;\n overflow: hidden;\n\n display: flex;\n flex-direction: row;\n\n width: 100vw;\n height: 100vh;\n height: 100dvh;\n }\n\n .note {\n margin: 0 0 var(--spacing-medium) 0;\n font-size: 0.85rem;\n line-height: 1.5;\n color: var(--md-sys-color-on-surface-variant);\n }\n `,\n AUTH_STYLE_SIGN\n ]\n\n get pageName() {\n return 'accept invitation'\n }\n\n /*\n * ⚠ `/auth/…` — the server router carries that prefix. This read `/accept-invitation` until\n * 2026-09-24, which is no route; see the note beside `ACCEPT_INVITATION_PATH` in auth-base.\n */\n get actionUrl() {\n return '/auth/accept-invitation'\n }\n\n get title() {\n return 'accept invitation'\n }\n\n /** Read from the fragment on connect. Empty when the link was opened without one. */\n @property({ type: String }) token?: string\n\n /** The server asked for a password, so this person is creating an account. */\n @property({ type: Boolean }) needsPassword?: boolean\n\n /** Joined. The page stops being a form and says where to go. */\n @property({ type: Boolean }) joined?: boolean\n\n @property({ type: Boolean }) busy?: boolean\n\n connectedCallback() {\n super.connectedCallback()\n\n const { token, clean } = readLinkToken(window.location.href)\n\n this.token = token\n\n /*\n * Taken out of the address bar and out of this history entry. `replaceState` rather than\n * `pushState`: going back should not put the token back on screen.\n */\n if (clean && clean !== window.location.href) {\n window.history.replaceState(null, '', clean)\n }\n }\n\n render() {\n const { icon, title, description } = this.applicationMeta\n const { disableUserFavoredLanguage, languages } = this.data || {}\n\n return html`\n <div class=\"wrap\">\n <div class=\"auth-brand\">\n <img src=${icon} />\n <strong class=\"name\">${title}</strong>\n <span class=\"welcome-msg\">${description}</span>\n </div>\n\n <div class=\"auth-form\">\n <h3><ox-i18n msgid=\"title.accept invitation\"></ox-i18n></h3>\n\n ${this.joined ? this.renderDone() : this.renderForm(disableUserFavoredLanguage, languages)}\n </div>\n </div>\n\n <ox-snack-bar id=\"snackbar\" level=\"error\" .message=${this.message}></ox-snack-bar>\n `\n }\n\n private renderDone() {\n return html`\n <p class=\"note\">${i18next.t('text.you have joined. sign in to continue')}</p>\n <md-elevated-button @click=${() => (window.location.href = '/auth/signin')}>\n <ox-i18n msgid=\"button.sign in\"></ox-i18n>\n </md-elevated-button>\n `\n }\n\n private renderForm(disableUserFavoredLanguage: boolean, languages: any) {\n return html`\n <form id=\"form\" @keypress=${(e: KeyboardEvent) => e.key === 'Enter' && this.accept()}>\n <p class=\"note\">${i18next.t('text.confirm the address this invitation was sent to')}</p>\n\n <div class=\"field\">\n <md-filled-text-field\n name=\"email\"\n type=\"email\"\n label=${String(i18next.t('field.email'))}\n autocomplete=\"email\"\n required\n ><md-icon slot=\"leading-icon\">mail</md-icon></md-filled-text-field\n >\n </div>\n\n ${this.token\n ? nothing\n : html`\n <div class=\"field\">\n <md-filled-text-field\n name=\"token\"\n label=${String(i18next.t('label.invitation code'))}\n supporting-text=${String(i18next.t('text.the code is printed in the invitation email'))}\n autocomplete=\"off\"\n required\n ><md-icon slot=\"leading-icon\">key</md-icon></md-filled-text-field\n >\n </div>\n `}\n ${this.needsPassword ? this.renderNewAccount() : nothing}\n\n <md-elevated-button id=\"submit-button\" type=\"button\" ?disabled=${this.busy} @click=${() => this.accept()}>\n <ox-i18n msgid=\"button.accept invitation\"></ox-i18n>\n </md-elevated-button>\n\n ${!disableUserFavoredLanguage\n ? html`<div id=\"locale-area\">\n <label for=\"locale-selector\"><md-icon>language</md-icon></label>\n <ox-i18n-selector\n id=\"locale-selector\"\n value=${i18next.language || 'en-US'}\n .languages=${languages}\n @change=${(e: CustomEvent) => e.detail && i18next.changeLanguage(e.detail as any)}\n ></ox-i18n-selector>\n </div>`\n : nothing}\n </form>\n `\n }\n\n private renderNewAccount() {\n return html`\n <p class=\"note\">${i18next.t('text.choose a password to finish joining')}</p>\n\n <div class=\"field\">\n <md-filled-text-field name=\"name\" label=${String(i18next.t('field.name'))} autocomplete=\"name\"\n ><md-icon slot=\"leading-icon\">person</md-icon></md-filled-text-field\n >\n </div>\n\n <div class=\"field\">\n <md-filled-text-field\n name=\"password\"\n type=\"password\"\n label=${String(i18next.t('label.password'))}\n autocomplete=\"new-password\"\n required\n ><md-icon slot=\"leading-icon\">password</md-icon></md-filled-text-field\n >\n </div>\n `\n }\n\n /*\n * ⚠ Not called `valueOf`. Overriding `Object.prototype.valueOf` with a different signature\n * makes the class type unassignable to `Object`, and every `@property` decorator on it then\n * fails to resolve — with an error that talks about decorators and never mentions the method.\n */\n private fieldValue(name: string): string {\n return (this.renderRoot.querySelector(`[name=\"${name}\"]`) as any)?.value?.trim() || ''\n }\n\n /*\n * The base class calls this to commit the page. It does not submit the form element: the\n * answer here is read rather than navigated to, because a refusal can mean \"now ask for a\n * password\" instead of \"stop\".\n */\n async submit() {\n await this.accept()\n }\n\n private async accept() {\n if (this.busy) {\n return\n }\n\n this.busy = true\n this.message = ''\n\n try {\n const response = await fetch(this.actionUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n token: this.token || this.fieldValue('token'),\n email: this.fieldValue('email'),\n name: this.fieldValue('name'),\n password: this.fieldValue('password')\n })\n })\n\n if (response.ok) {\n this.joined = true\n return\n }\n\n const refusal = await response.json().catch(() => ({}))\n\n /*\n * The one refusal that is not the end of the attempt — it means this person has no account\n * yet, which is exactly who this page is for.\n */\n if (refusal?.refusal?.code === 'invitation-needs-a-password' || refusal?.code === 'invitation-needs-a-password') {\n this.needsPassword = true\n this.message = String(i18next.t('text.choose a password to finish joining'))\n return\n }\n\n this.message = refusal?.message || String(i18next.t('text.this invitation cannot be used'))\n } catch (e) {\n this.message = String(i18next.t('text.this invitation cannot be used'))\n } finally {\n this.busy = false\n }\n }\n\n updated(changed: any) {\n super.updated(changed)\n\n if (changed.has('message')) {\n if (!this.message) {\n this.hideSnackbar()\n } else {\n this.showSnackbar({ timer: -1 })\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '@material/web/button/elevated-button.js';
|
|
2
|
+
import '@material/web/textfield/filled-text-field.js';
|
|
3
|
+
import '@operato/i18n/ox-i18n.js';
|
|
4
|
+
import '../../components/profile-component.js';
|
|
5
|
+
import { AbstractAuthPage } from '../../components/abstract-auth-page.js';
|
|
6
|
+
/**
|
|
7
|
+
* The page the sign-up confirmation mail links to — `/auth/verify#<token>`.
|
|
8
|
+
*
|
|
9
|
+
* Opening the link used to confirm the address (`GET /auth/verify/<token>`), so a mail scanner that
|
|
10
|
+
* fetched it confirmed it too, and the token sat in every access log it passed. Now the token rides
|
|
11
|
+
* after `#`, this page takes it out of the address bar, and the confirmation is the person's press
|
|
12
|
+
* of the button — a POST.
|
|
13
|
+
*
|
|
14
|
+
* A link whose fragment is missing or mangled shows a box for the code instead of a dead button.
|
|
15
|
+
*/
|
|
16
|
+
export declare class AuthVerify extends AbstractAuthPage {
|
|
17
|
+
token?: string;
|
|
18
|
+
get pageName(): string;
|
|
19
|
+
get actionUrl(): string;
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
firstUpdated(): void;
|
|
22
|
+
get formfields(): import("lit-html").TemplateResult<1>;
|
|
23
|
+
get links(): import("lit-html").TemplateResult<1>;
|
|
24
|
+
submit(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/button/elevated-button.js';
|
|
3
|
+
import '@material/web/textfield/filled-text-field.js';
|
|
4
|
+
import '@operato/i18n/ox-i18n.js';
|
|
5
|
+
import '../../components/profile-component.js';
|
|
6
|
+
import { html } from 'lit';
|
|
7
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
8
|
+
import { i18next } from '@operato/i18n';
|
|
9
|
+
import { AbstractAuthPage } from '../../components/abstract-auth-page.js';
|
|
10
|
+
import { readLinkToken } from '../../utils/link-token.js';
|
|
11
|
+
/**
|
|
12
|
+
* The page the sign-up confirmation mail links to — `/auth/verify#<token>`.
|
|
13
|
+
*
|
|
14
|
+
* Opening the link used to confirm the address (`GET /auth/verify/<token>`), so a mail scanner that
|
|
15
|
+
* fetched it confirmed it too, and the token sat in every access log it passed. Now the token rides
|
|
16
|
+
* after `#`, this page takes it out of the address bar, and the confirmation is the person's press
|
|
17
|
+
* of the button — a POST.
|
|
18
|
+
*
|
|
19
|
+
* A link whose fragment is missing or mangled shows a box for the code instead of a dead button.
|
|
20
|
+
*/
|
|
21
|
+
let AuthVerify = class AuthVerify extends AbstractAuthPage {
|
|
22
|
+
get pageName() {
|
|
23
|
+
return 'activate account';
|
|
24
|
+
}
|
|
25
|
+
get actionUrl() {
|
|
26
|
+
return '/auth/verify';
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback();
|
|
30
|
+
const { token, clean } = readLinkToken(window.location.href);
|
|
31
|
+
this.token = token;
|
|
32
|
+
/* `replaceState`, not `pushState`: going back should not put the token back on screen. */
|
|
33
|
+
if (clean && clean !== window.location.href) {
|
|
34
|
+
window.history.replaceState(null, '', clean);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
firstUpdated() {
|
|
38
|
+
/* The base focuses the first text field, and with a token in hand there is none. */
|
|
39
|
+
if (!this.token) {
|
|
40
|
+
super.firstUpdated();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
get formfields() {
|
|
44
|
+
return html `
|
|
45
|
+
${this.token
|
|
46
|
+
? html `<input name="token" type="hidden" .value=${this.token} />`
|
|
47
|
+
: html `
|
|
48
|
+
<div class="field">
|
|
49
|
+
<md-filled-text-field
|
|
50
|
+
name="token"
|
|
51
|
+
type="text"
|
|
52
|
+
label=${String(i18next.t('field.code'))}
|
|
53
|
+
autocomplete="off"
|
|
54
|
+
autocapitalize="off"
|
|
55
|
+
required
|
|
56
|
+
><md-icon slot="leading-icon">key</md-icon></md-filled-text-field
|
|
57
|
+
>
|
|
58
|
+
</div>
|
|
59
|
+
`}
|
|
60
|
+
|
|
61
|
+
<md-elevated-button class="ui" type="button" @click=${e => this._onSubmit(e)}>
|
|
62
|
+
<ox-i18n msgid="button.activate"></ox-i18n>
|
|
63
|
+
</md-elevated-button>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
get links() {
|
|
67
|
+
return html ``;
|
|
68
|
+
}
|
|
69
|
+
async submit() {
|
|
70
|
+
this.formEl.submit();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
__decorate([
|
|
74
|
+
property({ type: String }),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], AuthVerify.prototype, "token", void 0);
|
|
77
|
+
AuthVerify = __decorate([
|
|
78
|
+
customElement('auth-verify')
|
|
79
|
+
], AuthVerify);
|
|
80
|
+
export { AuthVerify };
|
|
81
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../client/entries/auth/verify.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,OAAO,8CAA8C,CAAA;AAErD,OAAO,0BAA0B,CAAA;AACjC,OAAO,uCAAuC,CAAA;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD;;;;;;;;;GASG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,gBAAgB;IAG9C,IAAI,QAAQ;QACV,OAAO,kBAAkB,CAAA;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAA;QAEzB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAE5D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAElB,0FAA0F;QAC1F,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC5C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;IAED,YAAY;QACV,oFAAoF;QACpF,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,CAAC,YAAY,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,KAAK;YACV,CAAC,CAAC,IAAI,CAAA,4CAA4C,IAAI,CAAC,KAAK,KAAK;YACjE,CAAC,CAAC,IAAI,CAAA;;;;;wBAKU,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;;;;;;;WAO5C;;4DAEiD,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;;;KAG7E,CAAA;IACH,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAA,EAAE,CAAA;IACf,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAA;IACtB,CAAC;CACF,CAAA;AA7D6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCAAe;AAD/B,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA8DtB","sourcesContent":["import '@material/web/button/elevated-button.js'\nimport '@material/web/textfield/filled-text-field.js'\n\nimport '@operato/i18n/ox-i18n.js'\nimport '../../components/profile-component.js'\n\nimport { html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { AbstractAuthPage } from '../../components/abstract-auth-page.js'\nimport { readLinkToken } from '../../utils/link-token.js'\n\n/**\n * The page the sign-up confirmation mail links to — `/auth/verify#<token>`.\n *\n * Opening the link used to confirm the address (`GET /auth/verify/<token>`), so a mail scanner that\n * fetched it confirmed it too, and the token sat in every access log it passed. Now the token rides\n * after `#`, this page takes it out of the address bar, and the confirmation is the person's press\n * of the button — a POST.\n *\n * A link whose fragment is missing or mangled shows a box for the code instead of a dead button.\n */\n@customElement('auth-verify')\nexport class AuthVerify extends AbstractAuthPage {\n @property({ type: String }) token?: string\n\n get pageName() {\n return 'activate account'\n }\n\n get actionUrl() {\n return '/auth/verify'\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n const { token, clean } = readLinkToken(window.location.href)\n\n this.token = token\n\n /* `replaceState`, not `pushState`: going back should not put the token back on screen. */\n if (clean && clean !== window.location.href) {\n window.history.replaceState(null, '', clean)\n }\n }\n\n firstUpdated() {\n /* The base focuses the first text field, and with a token in hand there is none. */\n if (!this.token) {\n super.firstUpdated()\n }\n }\n\n get formfields() {\n return html`\n ${this.token\n ? html`<input name=\"token\" type=\"hidden\" .value=${this.token} />`\n : html`\n <div class=\"field\">\n <md-filled-text-field\n name=\"token\"\n type=\"text\"\n label=${String(i18next.t('field.code'))}\n autocomplete=\"off\"\n autocapitalize=\"off\"\n required\n ><md-icon slot=\"leading-icon\">key</md-icon></md-filled-text-field\n >\n </div>\n `}\n\n <md-elevated-button class=\"ui\" type=\"button\" @click=${e => this._onSubmit(e)}>\n <ox-i18n msgid=\"button.activate\"></ox-i18n>\n </md-elevated-button>\n `\n }\n\n get links() {\n return html``\n }\n\n async submit() {\n this.formEl.submit()\n }\n}\n"]}
|