@atpassport/client 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +14 -15
  2. package/README_ja.md +14 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @atpassport/client
2
2
 
3
- [AtPassport](https://atpassport.net) is an authentication provider tailored for the atproto ecosystem.
4
- Using this client library, you can easily integrate AtPassport "login" functionality into your applications (such as browser extensions or web apps) with an OAuth-like flow.
3
+ [@passport](https://atpassport.net) is an authentication provider tailored for the atproto ecosystem.
4
+ Using this client library, you can easily integrate a @passport-powered "handle input assist feature" into your applications (such as browser extensions or web apps) with an OAuth-like flow.
5
5
 
6
6
  *For the Japanese documentation, please see [README_ja.md](./README_ja.md).*
7
7
 
8
8
  ## Features
9
9
  - **Zero dependencies**
10
- - **OAuth-like secure authentication flow** (Built-in CSRF protection via `atpstate`)
10
+ - **OAuth-like secure integration flow** (Built-in CSRF protection via `atpstate`)
11
11
  - **Custom parameter passthrough** (Query parameters attached to the callback URL are automatically returned)
12
12
 
13
13
  ## Installation
@@ -25,40 +25,39 @@ import { AtPassport } from '@atpassport/client';
25
25
 
26
26
  // 1. Initialize the client
27
27
  const passport = new AtPassport({
28
- baseUrl: 'https://atpassport.net', // Optional (defaults to atpassport.net)
29
- callbackUrl: 'https://myapp.com/oauth/callback' // Required: the URL to redirect back to
28
+ callbackUrl: 'https://myapp.com/oauth/login' // Required: the URL to redirect back to
30
29
  });
31
30
 
32
- // 2. Generate the authentication URL and redirect
31
+ // 2. (Optional) Generate the authentication URL and redirect
33
32
  // You can pass custom parameters (e.g., redirect_uri to return to the original page)
34
33
  const { url, atpstate } = passport.generateAuthUrl({
35
34
  redirect_uri: '/dashboard'
36
35
  });
37
36
 
38
- // For security, save the generated atpstate to sessionStorage or cookies to prevent CSRF
37
+ // 3. (Optional) For security, save the generated atpstate to sessionStorage or cookies to prevent CSRF
39
38
  sessionStorage.setItem('atpstate', atpstate);
40
39
 
41
- // Redirect the user to the AtPassport authentication page
40
+ // 4. Redirect the user to the @passport handle selection screen
42
41
  window.location.assign(url);
43
42
  ```
44
43
 
45
44
  ```typescript
46
- // 3. Receive the parameters on your callback page (https://myapp.com/oauth/callback)
47
- // By passing the saved atpstate as the second argument, parseCallback will automatically
45
+ // Receive the parameters on your callback page (https://myapp.com/oauth/callback)
46
+ // (Optional) By passing the saved atpstate as the second argument, parseCallback will automatically
48
47
  // throw an Error if the states don't match (preventing CSRF attacks).
49
48
  const savedState = sessionStorage.getItem('atpstate');
50
49
  const result = passport.parseCallback(window.location.href, savedState);
51
50
 
52
51
  console.log('Login successful:', result);
53
52
  console.log('Authenticated User:', result.handle);
54
- console.log('Custom Parameters:', result.customParams.redirect_uri); // Outputs '/dashboard'
53
+ console.log('Custom Parameters:', result.customParams['redirect_uri']); // Outputs '/dashboard'
55
54
  ```
56
55
 
57
56
  ---
58
57
 
59
58
  ## Explained: Parameters and Placeholders
60
59
 
61
- When AtPassport redirects back to your `callbackUrl`, the following information will be attached as URL parameters.
60
+ When @passport redirects back to your `callbackUrl`, the following information will be attached as URL parameters.
62
61
 
63
62
  ### Basic Parameters (Automatically extracted by `parseCallback`)
64
63
  - **`handle`**: The authenticated user's Bluesky / atproto handle (e.g., `alice.bsky.social`).
@@ -67,9 +66,9 @@ When AtPassport redirects back to your `callbackUrl`, the following information
67
66
  - **`atpstate`**: The state string automatically generated for CSRF protection via `generateAuthUrl()`.
68
67
 
69
68
  ### The `{handle}` and `{did}` Placeholder Replacement Feature
70
- Depending on the specific API endpoint used for integration or the exact implementation of the integrating client, there is a feature where placing `{handle}` or `{did}` string placeholders inside the `callbackUrl` string will instruct AtPassport to **dynamically string-replace** them with the actual handle/DID upon completion.
69
+ Depending on the specific API endpoint used for integration or the exact implementation of the integrating client, there is a feature where placing `{handle}` or `{did}` string placeholders inside the `callbackUrl` string will instruct @passport to **dynamically string-replace** them with the actual handle/DID upon completion.
71
70
 
72
71
  **Example:**
73
- If the `callbackUrl` was `https://myapp.com/login?handle={handle}`, AtPassport would redirect back to `https://myapp.com/login?handle=alice.bsky.social`.
72
+ If the `callbackUrl` was `https://myapp.com/login?handle={handle}`, @passport would redirect back to `https://myapp.com/login?handle=alice.bsky.social`.
74
73
 
75
- *Note: With the standard flow using `@atpassport/client` (`generateAuthUrl` → `parseCallback`), AtPassport does not rely on string replacement. Instead, it securely appends parameters like `&handle=...` as standardized URL queries. This allows you to simply and securely receive all information using `parseCallback()` without manually formatting placeholders.*
74
+ *Note: With the standard flow using `@atpassport/client` (`generateAuthUrl` → `parseCallback`), @passport does not rely on string replacement. Instead, it securely appends parameters like `&handle=...` as standardized URL queries. This allows you to simply and securely receive all information using `parseCallback()` without manually formatting placeholders.*
package/README_ja.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @atpassport/client
2
2
 
3
- [AtPassport](https://atpassport.net) は、atproto エコシステム向けの認証プロバイダーです。
4
- このクライアントライブラリを使うことで、あなたのアプリケーション(ブラウザ拡張機能やWebアプリ)に、AtPassportを利用した「ログイン機能」を簡単に組み込むことができます。
3
+ [@passport](https://atpassport.net) は、atproto エコシステム向けの認証プロバイダーです。
4
+ このクライアントライブラリを使うことで、あなたのアプリケーション(ブラウザ拡張機能やWebアプリ)に、@passport を利用した「ハンドル入力のアシスト機能」を簡単に組み込むことができます。
5
5
 
6
6
  *For the English documentation, please see [README.md](./README.md).*
7
7
 
8
8
  ## 特徴
9
9
  - 依存関係ゼロ(Zero dependencies)
10
- - OAuthライクなセキュアな認証フロー(CSRF対策のための `atpstate` 対応)
10
+ - OAuthライクなセキュアな連携フロー(CSRF対策のための `atpstate` 対応)
11
11
  - 複数のカスタムパラメータの引き回し(コールバックに付与したパラメータが自動で返却されます)
12
12
 
13
13
  ## インストール
@@ -25,39 +25,38 @@ import { AtPassport } from '@atpassport/client';
25
25
 
26
26
  // 1. クライアントの初期化
27
27
  const passport = new AtPassport({
28
- baseUrl: 'https://atpassport.net', // 省略可能 (デフォルトは atpassport.net)
29
- callbackUrl: 'https://myapp.com/oauth/callback' // 必須: 認証後に戻ってくるURL
28
+ callbackUrl: 'https://myapp.com/oauth/login' // 必須: 認証後に戻ってくるURL
30
29
  });
31
30
 
32
- // 2. 認証URLの生成とリダイレクト
31
+ // 2. (任意)認証URLの生成とリダイレクト
33
32
  // カスタムパラメータ(例: ログイン後に元いたページに戻すための redirect_uri など)を指定できます
34
33
  const { url, atpstate } = passport.generateAuthUrl({
35
34
  redirect_uri: '/dashboard'
36
35
  });
37
36
 
38
- // セキュリティのため、発行された atpstate をセッションや sessionStorage 等に保存します
37
+ // 3.(任意)セキュリティのため、発行された atpstate をセッションや sessionStorage 等に保存します
39
38
  sessionStorage.setItem('atpstate', atpstate);
40
39
 
41
- // AtPassportの認証画面へリダイレクト
40
+ // 4. @passport のハンドル選択画面へリダイレクト
42
41
  window.location.assign(url);
43
42
  ```
44
43
 
45
44
  ```typescript
46
- // 3. コールバック先 (https://myapp.com/oauth/callback) でのパラメータ受け取り
47
- // 保存していた atpstate を第2引数に渡すことで、状態が不一致(CSRFの疑い)の場合はエラー(例外)が発生します
45
+ // コールバック先 (https://myapp.com/oauth/callback) でのパラメータ受け取り
46
+ // (任意)保存していた atpstate を第2引数に渡すことで、状態が不一致(CSRFの疑い)の場合はエラー(例外)が発生します
48
47
  const savedState = sessionStorage.getItem('atpstate');
49
48
  const result = passport.parseCallback(window.location.href, savedState);
50
49
 
51
50
  console.log('ログイン成功:', result);
52
51
  console.log('認証ユーザー:', result.handle);
53
- console.log('カスタムパラメータ:', result.customParams.redirect_uri); // '/dashboard' が取れる
52
+ console.log('カスタムパラメータ:', result.customParams['redirect_uri']); // '/dashboard' が取れる
54
53
  ```
55
54
 
56
55
  ---
57
56
 
58
57
  ## パラメータ・プレースホルダーの解説
59
58
 
60
- AtPassport からコールバック URL にリダイレクトされる際、以下の情報が URL パラメータとして付与されます。
59
+ @passport からコールバック URL にリダイレクトされる際、以下の情報が URL パラメータとして付与されます。
61
60
 
62
61
  ### 基本パラメータ(`parseCallback` で自動取得されるもの)
63
62
  - **`handle`**: 認証されたユーザーの Bluesky / atproto ハンドル名(例: `alice.bsky.social`)
@@ -66,9 +65,9 @@ AtPassport からコールバック URL にリダイレクトされる際、以
66
65
  - **`atpstate`**: `generateAuthUrl()` で自動生成された CSRF 防止用のステート文字列。リクエスト元の検証に用います。
67
66
 
68
67
  ### `{handle}` などのプレースホルダー置換機能
69
- 特定のエンドポイントを利用した連携や、組み込み先のクライアント実装次第では、`callbackUrl` 内に `{handle}` や `{did}` といった文字列(プレースホルダー)を含めておくことで、認証完了時に AtPassport 側でユーザーの実際のハンドルや DID に**動的に文字列置換**されてリダイレクトされる機能があります。
68
+ 特定のエンドポイントを利用した連携や、組み込み先のクライアント実装次第では、`callbackUrl` 内に `{handle}` や `{did}` といった文字列(プレースホルダー)を含めておくことで、認証完了時に @passport 側でユーザーの実際のハンドルや DID に**動的に文字列置換**されてリダイレクトされる機能があります。
70
69
 
71
70
  **例:**
72
- `callbackUrl` を `https://myapp.com/login?handle={handle}` にして AtPassport へ送ると、完了時に `https://myapp.com/login?handle=alice.bsky.social` として戻ってきます。
71
+ `callbackUrl` を `https://myapp.com/login?handle={handle}` にして @passport へ送ると、完了時に `https://myapp.com/login?handle=alice.bsky.social` として戻ってきます。
73
72
 
74
- ※ `@atpassport/client` を使った標準の `generateAuthUrl` → `parseCallback` フローでは、AtPassport はプレースホルダー置換ではなく、安全に `&handle=...` のように標準的なクエリパラメータとして追記する形を採っているため、意識せずに `parseCallback()` だけで全ての情報を簡単に安全に受け取ることができます。
73
+ ※ `@atpassport/client` を使った標準の `generateAuthUrl` → `parseCallback` フローでは、@passport はプレースホルダー置換ではなく、安全に `&handle=...` のように標準的なクエリパラメータとして追記する形を採っているため、意識せずに `parseCallback()` だけで全ての情報を簡単に安全に受け取ることができます。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atpassport/client",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [