@auth-link/web 1.1.0 → 2.0.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 +7 -0
- package/README.md +33 -21
- package/dist/index.js +6 -32
- package/dist/index.js.map +2 -2
- package/dist/react.js +6 -38
- package/dist/react.js.map +2 -2
- package/dist/styles.css +5 -49
- package/dist/types/modal.d.ts +1 -3
- package/dist/types/passcode.d.ts +1 -2
- package/dist/types/react.d.ts +1 -1
- package/dist/types/types.d.ts +0 -3
- package/dist/types/view.d.ts +1 -4
- package/dist/types/vue.d.ts +1 -1
- package/dist/vue.js +7 -37
- package/dist/vue.js.map +2 -2
- package/docs/README.en.md +12 -8
- package/docs/README.ja.md +12 -8
- package/docs/README.zh-CN.md +12 -8
- package/examples/react-client.tsx +1 -1
- package/examples/vue-client.vue +1 -1
- package/package.json +2 -2
package/docs/README.en.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
# AuthLink Web
|
|
1
|
+
# AuthLink Web 2.0
|
|
2
2
|
|
|
3
3
|
[English](README.en.md) · [简体中文](README.zh-CN.md) · [日本語](README.ja.md)
|
|
4
4
|
|
|
5
|
+
## Upgrading from 1.x
|
|
6
|
+
|
|
7
|
+
All dialogs now use the minimal layout. Remove the variant option/prop, modal.setVariant() calls and DialogVariant type imports. Language switching and verification callbacks are unchanged.
|
|
8
|
+
|
|
5
9
|
## Direct rotating-code verification
|
|
6
10
|
|
|
7
11
|
The app directly displays a six-digit rotating code. No per-action approval, authorization requestId, businessId or polling is required. First-time enrollment still scans a QR and verifies the phone; entering its current code on the website completes binding.
|
|
@@ -9,7 +13,7 @@ The app directly displays a six-digit rotating code. No per-action approval, aut
|
|
|
9
13
|
The CMS backend must reserve one immutable pending action per session before opening the prompt. Another tab cannot replace it. Obtain the user from the server session and check CSRF and business permissions. Verify the passcode on the server and atomically commit verificationId with the saved operation before returning success. onVerified only updates the UI.
|
|
10
14
|
|
|
11
15
|
```sh
|
|
12
|
-
npm install @auth-link/web@^
|
|
16
|
+
npm install @auth-link/web@^2.0.0
|
|
13
17
|
```
|
|
14
18
|
|
|
15
19
|
```ts
|
|
@@ -17,31 +21,31 @@ import { openPasscode, createPasscodeClient } from '@auth-link/web';
|
|
|
17
21
|
import '@auth-link/web/styles.css';
|
|
18
22
|
const client = createPasscodeClient({ baseUrl: '/api', csrfToken: () => csrfToken });
|
|
19
23
|
const modal = openPasscode({
|
|
20
|
-
client, expiresAt: pending.expiresAt, locale: 'zh-CN',
|
|
24
|
+
client, expiresAt: pending.expiresAt, locale: 'zh-CN',
|
|
21
25
|
// First-time enrollment only:
|
|
22
26
|
// bindingQr: pending.bindingQr, authLinkOrigin: 'https://api.getauthlink.com',
|
|
23
27
|
onVerified: result => updateUI(result.verificationId),
|
|
24
28
|
});
|
|
25
|
-
// modal.setLocale('en'); modal.
|
|
29
|
+
// modal.setLocale('en'); modal.destroy();
|
|
26
30
|
```
|
|
27
31
|
|
|
28
32
|
The default client posts only {passcode} to POST /api/auth with current CMS credentials and CSRF. To submit a form at the same time, supply your own client.verify callback and send {form,passcode} to your CMS. The CMS checks the form against its saved snapshot; never send tenant keys or passcode seeds to the browser.
|
|
29
33
|
|
|
30
34
|
## Options and callbacks
|
|
31
35
|
|
|
32
|
-
Required: client.verify(passcode, signal) and expiresAt (the pending CMS action deadline). Optional: locale,
|
|
36
|
+
Required: client.verify(passcode, signal) and expiresAt (the pending CMS action deadline). Optional: locale, bindingQr and authLinkOrigin for first enrollment only, onVerified, onError, onClose, onExpired. Success contains status, verificationId, authenticationPolicy and expiresAt; it has no requestId or businessId.
|
|
33
37
|
|
|
34
38
|
Cookie authentication requires CSRF. Bearer authentication uses accessToken with credentials=omit. For a cross-origin CMS explicitly set allowedBackendOrigins. Bare HTTPS origins are required outside loopback development.
|
|
35
39
|
|
|
36
40
|
## React and Vue
|
|
37
41
|
|
|
38
|
-
The React component takes the same options. Vue emits verified, error, close and expired. Keep client references stable. Thirteen languages remain supported; Simplified Chinese is the default.
|
|
42
|
+
The React component takes the same options. Vue emits verified, error, close and expired. Keep client references stable. Thirteen languages remain supported; Simplified Chinese is the default. All dialogs use one responsive minimal layout.
|
|
39
43
|
|
|
40
44
|
```tsx
|
|
41
45
|
import { AuthLinkPasscode } from '@auth-link/web/react';
|
|
42
46
|
// Keep client stable (for example with useMemo).
|
|
43
47
|
<AuthLinkPasscode client={client} expiresAt={pending.expiresAt}
|
|
44
|
-
locale="zh-CN"
|
|
48
|
+
locale="zh-CN" onVerified={updateUI} />
|
|
45
49
|
```
|
|
46
50
|
```vue
|
|
47
51
|
<script setup>
|
|
@@ -49,7 +53,7 @@ import { AuthLinkPasscode } from '@auth-link/web/vue';
|
|
|
49
53
|
</script>
|
|
50
54
|
<template>
|
|
51
55
|
<AuthLinkPasscode :client="client" :expires-at="pending.expiresAt"
|
|
52
|
-
locale="zh-CN"
|
|
56
|
+
locale="zh-CN" @verified="updateUI" />
|
|
53
57
|
</template>
|
|
54
58
|
```
|
|
55
59
|
|
package/docs/README.ja.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
# AuthLink Web
|
|
1
|
+
# AuthLink Web 2.0
|
|
2
2
|
|
|
3
3
|
[English](README.en.md) · [简体中文](README.zh-CN.md) · [日本語](README.ja.md)
|
|
4
4
|
|
|
5
|
+
## 1.x からの更新
|
|
6
|
+
|
|
7
|
+
すべてのダイアログはシンプルレイアウトに統一されました。variant オプション・プロパティ、modal.setVariant() の呼び出し、DialogVariant 型のインポートを削除してください。言語切り替えと認証コールバックは変更ありません。
|
|
8
|
+
|
|
5
9
|
## 認証コードを直接検証
|
|
6
10
|
|
|
7
11
|
アプリに6桁の認証コードを直接表示します。通常の検証では、毎回の承認、認証用requestId、businessId、ポーリングは不要です。初回はQRで端末を確認し、サイトで現在のコードを検証して連携を完了します。
|
|
@@ -9,7 +13,7 @@
|
|
|
9
13
|
画面を開く前にCMSサーバーでセッションの唯一の保留中操作を原子的に確保します。別タブから上書きさせません。ユーザーはサーバーのセッションから取得し、CSRF、業務権限、元のフォームを確認します。コードを検証し、verificationIdと元の操作を原子的に確定してから成功を返します。onVerifiedは表示更新専用です。
|
|
10
14
|
|
|
11
15
|
```sh
|
|
12
|
-
npm install @auth-link/web@^
|
|
16
|
+
npm install @auth-link/web@^2.0.0
|
|
13
17
|
```
|
|
14
18
|
|
|
15
19
|
```ts
|
|
@@ -17,31 +21,31 @@ import { openPasscode, createPasscodeClient } from '@auth-link/web';
|
|
|
17
21
|
import '@auth-link/web/styles.css';
|
|
18
22
|
const client = createPasscodeClient({ baseUrl: '/api', csrfToken: () => csrfToken });
|
|
19
23
|
const modal = openPasscode({
|
|
20
|
-
client, expiresAt: pending.expiresAt, locale: 'zh-CN',
|
|
24
|
+
client, expiresAt: pending.expiresAt, locale: 'zh-CN',
|
|
21
25
|
// First-time enrollment only:
|
|
22
26
|
// bindingQr: pending.bindingQr, authLinkOrigin: 'https://api.getauthlink.com',
|
|
23
27
|
onVerified: result => updateUI(result.verificationId),
|
|
24
28
|
});
|
|
25
|
-
// modal.setLocale('en'); modal.
|
|
29
|
+
// modal.setLocale('en'); modal.destroy();
|
|
26
30
|
```
|
|
27
31
|
|
|
28
32
|
標準クライアントは現在の認証情報とCSRFを付け、CMSのPOST /api/authへ{passcode}を送信します。フォームも送る場合はclient.verifyで{form,passcode}をCMSへ送信し、サーバーで保存済み内容と照合します。テナントキーやコード生成用秘密はブラウザーへ渡しません。
|
|
29
33
|
|
|
30
34
|
## オプションとコールバック
|
|
31
35
|
|
|
32
|
-
必須はclient.verify(passcode, signal)とexpiresAt(CMS操作の期限)です。任意でlocale
|
|
36
|
+
必須はclient.verify(passcode, signal)とexpiresAt(CMS操作の期限)です。任意でlocale、初回用bindingQrとauthLinkOrigin、onVerified、onError、onClose、onExpiredを指定します。成功結果はstatus、verificationId、authenticationPolicy、expiresAtを含み、requestIdやbusinessIdは含みません。
|
|
33
37
|
|
|
34
38
|
Cookie認証ではCSRFが必須です。Bearer認証はaccessTokenとcredentials=omitを使います。別オリジンのCMSはallowedBackendOriginsを明示し、ループバック開発以外ではHTTPSを使います。
|
|
35
39
|
|
|
36
40
|
## ReactとVue
|
|
37
41
|
|
|
38
|
-
Reactは同じオプションを使い、Vueはverified、error、close、expiredイベントを発行します。clientの参照を安定させてください。13
|
|
42
|
+
Reactは同じオプションを使い、Vueはverified、error、close、expiredイベントを発行します。clientの参照を安定させてください。13言語に対応し、既定は簡体字中国語です。すべてのダイアログはレスポンシブなシンプルレイアウトを使用します。
|
|
39
43
|
|
|
40
44
|
```tsx
|
|
41
45
|
import { AuthLinkPasscode } from '@auth-link/web/react';
|
|
42
46
|
// Keep client stable (for example with useMemo).
|
|
43
47
|
<AuthLinkPasscode client={client} expiresAt={pending.expiresAt}
|
|
44
|
-
locale="zh-CN"
|
|
48
|
+
locale="zh-CN" onVerified={updateUI} />
|
|
45
49
|
```
|
|
46
50
|
```vue
|
|
47
51
|
<script setup>
|
|
@@ -49,7 +53,7 @@ import { AuthLinkPasscode } from '@auth-link/web/vue';
|
|
|
49
53
|
</script>
|
|
50
54
|
<template>
|
|
51
55
|
<AuthLinkPasscode :client="client" :expires-at="pending.expiresAt"
|
|
52
|
-
locale="zh-CN"
|
|
56
|
+
locale="zh-CN" @verified="updateUI" />
|
|
53
57
|
</template>
|
|
54
58
|
```
|
|
55
59
|
|
package/docs/README.zh-CN.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
# AuthLink Web
|
|
1
|
+
# AuthLink Web 2.0
|
|
2
2
|
|
|
3
3
|
[English](README.en.md) · [简体中文](README.zh-CN.md) · [日本語](README.ja.md)
|
|
4
4
|
|
|
5
|
+
## 从 1.x 升级
|
|
6
|
+
|
|
7
|
+
所有弹窗统一使用极简布局。请删除 variant 参数或组件属性、modal.setVariant() 调用和 DialogVariant 类型导入。语言切换与验证回调保持不变。
|
|
8
|
+
|
|
5
9
|
## 直接验证动态码
|
|
6
10
|
|
|
7
11
|
App 直接显示六位动态码。日常验证不需要逐次批准、授权 requestId、businessId 或轮询。首次绑定仍需扫码验证设备,在网站输入 App 当前动态码后才完成绑定。
|
|
@@ -9,7 +13,7 @@ App 直接显示六位动态码。日常验证不需要逐次批准、授权 req
|
|
|
9
13
|
打开弹窗前,CMS 后台必须为会话原子保留唯一且不可变的待办。其他标签页不能覆盖它。用户来自服务端会话,后台检查 CSRF、业务权限和原表单,验证动态码后将 verificationId 与原操作原子提交,再返回成功。onVerified 只更新界面。
|
|
10
14
|
|
|
11
15
|
```sh
|
|
12
|
-
npm install @auth-link/web@^
|
|
16
|
+
npm install @auth-link/web@^2.0.0
|
|
13
17
|
```
|
|
14
18
|
|
|
15
19
|
```ts
|
|
@@ -17,31 +21,31 @@ import { openPasscode, createPasscodeClient } from '@auth-link/web';
|
|
|
17
21
|
import '@auth-link/web/styles.css';
|
|
18
22
|
const client = createPasscodeClient({ baseUrl: '/api', csrfToken: () => csrfToken });
|
|
19
23
|
const modal = openPasscode({
|
|
20
|
-
client, expiresAt: pending.expiresAt, locale: 'zh-CN',
|
|
24
|
+
client, expiresAt: pending.expiresAt, locale: 'zh-CN',
|
|
21
25
|
// First-time enrollment only:
|
|
22
26
|
// bindingQr: pending.bindingQr, authLinkOrigin: 'https://api.getauthlink.com',
|
|
23
27
|
onVerified: result => updateUI(result.verificationId),
|
|
24
28
|
});
|
|
25
|
-
// modal.setLocale('en'); modal.
|
|
29
|
+
// modal.setLocale('en'); modal.destroy();
|
|
26
30
|
```
|
|
27
31
|
|
|
28
32
|
默认客户端向 CMS 的 POST /api/auth 提交 {passcode},携带当前会话与 CSRF。要随表单提交,可自行实现 client.verify,向 CMS 发送 {form,passcode};后台核对原保存快照。租户密钥与动态码密钥不能进入浏览器。
|
|
29
33
|
|
|
30
34
|
## 选项与回调
|
|
31
35
|
|
|
32
|
-
必填:client.verify(passcode, signal)、expiresAt(CMS 待办截止时间)。可选:locale
|
|
36
|
+
必填:client.verify(passcode, signal)、expiresAt(CMS 待办截止时间)。可选:locale、仅首次绑定使用的 bindingQr 与 authLinkOrigin、onVerified、onError、onClose、onExpired。成功结果含 status、verificationId、authenticationPolicy、expiresAt,不含 requestId 或 businessId。
|
|
33
37
|
|
|
34
38
|
Cookie 模式必须配置 CSRF。Bearer 模式配置 accessToken 且 credentials=omit。跨域 CMS 必须显式配置 allowedBackendOrigins;回环开发之外使用 HTTPS。
|
|
35
39
|
|
|
36
40
|
## React 与 Vue
|
|
37
41
|
|
|
38
|
-
React 组件使用相同选项,Vue 发出 verified、error、close、expired 事件。client 引用需保持稳定。支持 13
|
|
42
|
+
React 组件使用相同选项,Vue 发出 verified、error、close、expired 事件。client 引用需保持稳定。支持 13 种语言,默认简体中文;统一使用响应式极简布局。
|
|
39
43
|
|
|
40
44
|
```tsx
|
|
41
45
|
import { AuthLinkPasscode } from '@auth-link/web/react';
|
|
42
46
|
// Keep client stable (for example with useMemo).
|
|
43
47
|
<AuthLinkPasscode client={client} expiresAt={pending.expiresAt}
|
|
44
|
-
locale="zh-CN"
|
|
48
|
+
locale="zh-CN" onVerified={updateUI} />
|
|
45
49
|
```
|
|
46
50
|
```vue
|
|
47
51
|
<script setup>
|
|
@@ -49,7 +53,7 @@ import { AuthLinkPasscode } from '@auth-link/web/vue';
|
|
|
49
53
|
</script>
|
|
50
54
|
<template>
|
|
51
55
|
<AuthLinkPasscode :client="client" :expires-at="pending.expiresAt"
|
|
52
|
-
locale="zh-CN"
|
|
56
|
+
locale="zh-CN" @verified="updateUI" />
|
|
53
57
|
</template>
|
|
54
58
|
```
|
|
55
59
|
|
|
@@ -16,7 +16,7 @@ export function AuthLinkPanel({ client, pending, onVerified, onClose }: {
|
|
|
16
16
|
return <>
|
|
17
17
|
<AuthLinkPasscode client={client} expiresAt={pending.expiresAt}
|
|
18
18
|
bindingQr={pending.bindingQr} authLinkOrigin="https://api.getauthlink.com"
|
|
19
|
-
locale="en"
|
|
19
|
+
locale="en" onVerified={onVerified} onClose={onClose}
|
|
20
20
|
onExpired={() => setMessage('Expired; start a new action')}
|
|
21
21
|
onError={error => setMessage(error.message)} />
|
|
22
22
|
<p role="status">{message}</p>
|
package/examples/vue-client.vue
CHANGED
|
@@ -25,7 +25,7 @@ function showError(error: Error) { message.value = error.message; }
|
|
|
25
25
|
<template>
|
|
26
26
|
<AuthLinkPasscode :client="client" :expires-at="pending.expiresAt"
|
|
27
27
|
:binding-qr="pending.bindingQr" auth-link-origin="https://api.getauthlink.com"
|
|
28
|
-
locale="en"
|
|
28
|
+
locale="en" @verified="verified" @close="emit('close')"
|
|
29
29
|
@expired="message = 'Expired; start a new action'" @error="showError" />
|
|
30
30
|
<p role="status">{{ message }}</p>
|
|
31
31
|
</template>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth-link/web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "A responsive minimal AuthLink dialog for phone binding and TOTP verification. Framework-neutral API, React and Vue, 13 languages, Simplified Chinese by default.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"files": [
|