@atlasauth/svelte 0.6.0 → 0.7.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/CHANGELOG.md +6 -0
- package/dist/components/UserProfile.svelte +60 -0
- package/dist/context.d.ts +13 -1
- package/dist/context.js +3 -1
- package/dist/i18n.js +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlasauth/svelte changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
- **Referral attribution.** The prebuilt forms send the referral the visitor arrived with on sign-in and sign-up (through `@atlasauth/js` 0.13.0) when the instance has referrals on, and show the captcha for a referred sign-up when the instance requires it. New init options: `referral?: false` and `referralConsent?`.
|
|
5
|
+
|
|
6
|
+
## 0.6.1
|
|
7
|
+
- **`<UserProfile>` can verify an address.** Each unverified email address now has a **Verify** button: it emails a code (`POST /v1/client/me/email_addresses/{id}/prepare_verification`) and shows a field to enter it (`attempt_verification`), then reloads the user. This includes the sign-up address on an app that does not require email verification, which now reads unverified until it is proven. New catalog keys: `userProfile.verify`, `userProfile.verifyConfirm`, `userProfile.verifyCodePlaceholder`, `userProfile.verifySendFailed`, `userProfile.verifyCodeRejected`.
|
|
8
|
+
|
|
3
9
|
## 0.6.0
|
|
4
10
|
- **New `initAtlas({ onSignOut })` and `client.onSignOut(listener)`**: `onSignOut({ reason, sessionId })` fired once each time a signed-in user becomes signed out, on every
|
|
5
11
|
path: `reason` is `user` (this tab), `other_tab`, `session_expired`, `revoked` (the session was ended elsewhere,
|
|
@@ -2,11 +2,50 @@
|
|
|
2
2
|
import { getUser } from "../accessors";
|
|
3
3
|
import { classFor } from "../appearance";
|
|
4
4
|
import { translate } from "../i18n";
|
|
5
|
+
import { FapiClient } from "../fapi";
|
|
6
|
+
import { ATLAS_SVELTE_SDK } from "../version";
|
|
5
7
|
const atlas = useAtlas();
|
|
6
8
|
const user = getUser();
|
|
7
9
|
const t = (key) => translate(atlas.catalog, key);
|
|
10
|
+
const client = new FapiClient({
|
|
11
|
+
publishableKey: atlas.publishableKey,
|
|
12
|
+
baseUrl: atlas.frontendApi,
|
|
13
|
+
locale: atlas.locale,
|
|
14
|
+
sdk: ATLAS_SVELTE_SDK
|
|
15
|
+
});
|
|
16
|
+
let verifying = null;
|
|
17
|
+
let code = "";
|
|
18
|
+
let busy = false;
|
|
19
|
+
let verifyError = null;
|
|
20
|
+
async function sendCode(id) {
|
|
21
|
+
verifyError = null;
|
|
22
|
+
busy = true;
|
|
23
|
+
const res = await client.post(`/v1/client/me/email_addresses/${id}/prepare_verification`);
|
|
24
|
+
busy = false;
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
verifyError = t("userProfile.verifySendFailed");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
code = "";
|
|
30
|
+
verifying = id;
|
|
31
|
+
}
|
|
32
|
+
async function confirmCode() {
|
|
33
|
+
if (!verifying) return;
|
|
34
|
+
verifyError = null;
|
|
35
|
+
busy = true;
|
|
36
|
+
const res = await client.post(`/v1/client/me/email_addresses/${verifying}/attempt_verification`, { code });
|
|
37
|
+
busy = false;
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
verifyError = t("userProfile.verifyCodeRejected");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
verifying = null;
|
|
43
|
+
await atlas.reload();
|
|
44
|
+
}
|
|
8
45
|
$: current = $user.user;
|
|
9
46
|
$: cardClass = classFor("card", atlas.appearance, "atlas-card");
|
|
47
|
+
$: inputClass = classFor("formFieldInput", atlas.appearance, "atlas-account-input");
|
|
48
|
+
$: buttonClass = classFor("formButtonSecondary", atlas.appearance, "atlas-button-secondary");
|
|
10
49
|
</script>
|
|
11
50
|
|
|
12
51
|
{#if current}
|
|
@@ -21,10 +60,31 @@ $: cardClass = classFor("card", atlas.appearance, "atlas-card");
|
|
|
21
60
|
{email.email_address}
|
|
22
61
|
{#if !email.verified}
|
|
23
62
|
<em> — {t('userProfile.unverified')}</em>
|
|
63
|
+
{#if verifying === email.id}
|
|
64
|
+
<span data-atlas="email-verify">
|
|
65
|
+
<input
|
|
66
|
+
class={inputClass}
|
|
67
|
+
inputmode="numeric"
|
|
68
|
+
autocomplete="one-time-code"
|
|
69
|
+
placeholder={t('userProfile.verifyCodePlaceholder')}
|
|
70
|
+
bind:value={code}
|
|
71
|
+
/>
|
|
72
|
+
<button class={buttonClass} type="button" disabled={busy} on:click={() => void confirmCode()}>
|
|
73
|
+
{t('userProfile.verifyConfirm')}
|
|
74
|
+
</button>
|
|
75
|
+
</span>
|
|
76
|
+
{:else}
|
|
77
|
+
<button class={buttonClass} type="button" disabled={busy} on:click={() => void sendCode(email.id)}>
|
|
78
|
+
{t('userProfile.verify')}
|
|
79
|
+
</button>
|
|
80
|
+
{/if}
|
|
24
81
|
{/if}
|
|
25
82
|
</li>
|
|
26
83
|
{/each}
|
|
27
84
|
</ul>
|
|
85
|
+
{#if verifyError}
|
|
86
|
+
<p role="alert">{verifyError}</p>
|
|
87
|
+
{/if}
|
|
28
88
|
</section>
|
|
29
89
|
|
|
30
90
|
<section>
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Readable } from 'svelte/store';
|
|
2
|
-
import { type ProviderToken, type SignOutOptions, type SignOutResult, type SignOutEvent, type SignOutListener } from '@atlasauth/js';
|
|
2
|
+
import { type ProviderToken, type SignOutOptions, type SignOutResult, type SignOutEvent, type SignOutListener, type ReferralConsent } from '@atlasauth/js';
|
|
3
3
|
import { type Catalog } from './i18n';
|
|
4
4
|
import { type Appearance, type InstanceDesign } from './appearance';
|
|
5
5
|
import type { AtlasOrganizationMembership, AtlasSession, AtlasUser, SessionClaims } from './types';
|
|
@@ -23,6 +23,18 @@ export type AuthStatus = 'loading' | 'signed_in' | 'signed_out';
|
|
|
23
23
|
export declare const ATLAS_KEY: unique symbol;
|
|
24
24
|
export interface AtlasInitOptions {
|
|
25
25
|
publishableKey: string;
|
|
26
|
+
/**
|
|
27
|
+
* Referral attribution: the prebuilt forms send the referral the visitor
|
|
28
|
+
* arrived with on sign-in / sign-up when the instance has referrals on.
|
|
29
|
+
* `false` turns that off.
|
|
30
|
+
*/
|
|
31
|
+
referral?: false;
|
|
32
|
+
/**
|
|
33
|
+
* The app's own consent decision for the referral tracking cookie, used only
|
|
34
|
+
* when Cookie Munch is not on the page: `'granted'` (or a function returning
|
|
35
|
+
* it) lets the forms read the cookie. Default: the cookie is not read.
|
|
36
|
+
*/
|
|
37
|
+
referralConsent?: ReferralConsent;
|
|
26
38
|
/**
|
|
27
39
|
* The instance's Frontend API: an absolute URL such as
|
|
28
40
|
* `"https://auth.example.com"`, or `"same-origin"` / a path such as `"/atlas"`
|
package/dist/context.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
2
|
import { derived, get, writable } from 'svelte/store';
|
|
3
|
-
import { FapiClient, SignOutGuard, TokenCache, closeOAuthPopupAfterSignIn, completeOAuthPopupLanding, getProviderToken as fetchProviderToken, mapOAuthPopupPayload, msUntilRefresh, readExpiry, readRedirectResult, resolveFrontendApi, stripRedirectParams, catalogLocale, SDK_HEADER, SignOutNotifier, getTemplateToken, reportSdkAdvisory, sdkHeaderValue, signOutReasonFromClient, } from '@atlasauth/js';
|
|
3
|
+
import { FapiClient, SignOutGuard, TokenCache, closeOAuthPopupAfterSignIn, completeOAuthPopupLanding, getProviderToken as fetchProviderToken, mapOAuthPopupPayload, msUntilRefresh, readExpiry, readRedirectResult, resolveFrontendApi, stripRedirectParams, catalogLocale, SDK_HEADER, SignOutNotifier, getTemplateToken, reportSdkAdvisory, sdkHeaderValue, signOutReasonFromClient, configureReferralCapture, } from '@atlasauth/js';
|
|
4
4
|
import { ATLAS_SVELTE_SDK } from './version';
|
|
5
5
|
import { EN_US, withFallback } from './i18n';
|
|
6
6
|
import { instanceDesignFrom } from './appearance';
|
|
@@ -191,6 +191,8 @@ export function createAtlasClient(options) {
|
|
|
191
191
|
await refresh();
|
|
192
192
|
return cache.get(5_000)?.jwt ?? null;
|
|
193
193
|
}
|
|
194
|
+
// Referral attribution: app-wide options every FAPI client on the page falls back to.
|
|
195
|
+
configureReferralCapture({ referral: options.referral, referralConsent: options.referralConsent });
|
|
194
196
|
const fapiClient = new FapiClient({ publishableKey, baseUrl, fetchImpl: doFetch, locale, sdk: ATLAS_SVELTE_SDK });
|
|
195
197
|
function getProviderToken(provider) {
|
|
196
198
|
return fetchProviderToken(fapiClient, provider);
|
package/dist/i18n.js
CHANGED
|
@@ -79,6 +79,11 @@ export const EN_US = {
|
|
|
79
79
|
'userProfile.addEmail': 'Add an email address',
|
|
80
80
|
'userProfile.makePrimary': 'Make primary',
|
|
81
81
|
'userProfile.unverified': 'Unverified',
|
|
82
|
+
'userProfile.verify': 'Verify',
|
|
83
|
+
'userProfile.verifyConfirm': 'Confirm',
|
|
84
|
+
'userProfile.verifyCodePlaceholder': 'Code from the email',
|
|
85
|
+
'userProfile.verifySendFailed': 'We could not send a code right now. Try again in a minute.',
|
|
86
|
+
'userProfile.verifyCodeRejected': 'That code was not accepted.',
|
|
82
87
|
'userProfile.revokeDevice': 'Sign out',
|
|
83
88
|
'userProfile.deleteAccount': 'Delete account',
|
|
84
89
|
'organization.switcher': 'Switch organization',
|
package/dist/version.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AtlasSdkInfo } from '@atlasauth/js';
|
|
2
2
|
/** This package's version, sent as `X-Atlas-SDK` (kept in step with package.json by a test). */
|
|
3
|
-
export declare const ATLAS_SVELTE_VERSION = "0.
|
|
3
|
+
export declare const ATLAS_SVELTE_VERSION = "0.7.0";
|
|
4
4
|
export declare const ATLAS_SVELTE_SDK: AtlasSdkInfo;
|
package/dist/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** This package's version, sent as `X-Atlas-SDK` (kept in step with package.json by a test). */
|
|
2
|
-
export const ATLAS_SVELTE_VERSION = '0.
|
|
2
|
+
export const ATLAS_SVELTE_VERSION = '0.7.0';
|
|
3
3
|
export const ATLAS_SVELTE_SDK = { name: '@atlasauth/svelte', version: ATLAS_SVELTE_VERSION };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"svelte": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@atlasauth/design": "0.2.0",
|
|
26
|
-
"@atlasauth/
|
|
26
|
+
"@atlasauth/backend": "0.10.0",
|
|
27
27
|
"@atlasauth/authz": "0.1.1",
|
|
28
|
-
"@atlasauth/
|
|
28
|
+
"@atlasauth/js": "0.13.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"svelte": ">=4",
|