Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Feature] Implement Multiton Pattern for Enhanced Instance Management in AsgardeoAuthClient

オープン
#368 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript

調査の方向性

まず、@asgardeo/javascript パッケージ内の AsgardeoAuthClient を探し、issue で参照されているブラウザー固有の SDK 実装を確認します。保護された構築、ID をキーとしたインスタンス取得、ライフサイクルのクリーンアップに必要な設計を確認します。完了の条件は、getInstance、destroyInstance、destroyAllInstances、hasInstance が分離されたクライアントとクリーンなテスト状態をサポートすることです。

索引モデルが issue の本文から書いたものです。

説明

Type/Improvement
Current Limitation

The AsgardeoAuthClient currently relies on a public constructor, allowing for the uncontrolled creation of multiple instances without a centralized management system. Unlike the browser-specific implementations in the SDK ecosystem, there is no static mechanism to track, retrieve, or properly dispose of active client instances.

This lack of lifecycle management creates several issues:

  • Inconsistency: It diverges from the architectural patterns used elsewhere in the SDK, leading to a fragmented developer experience.
  • Resource Management: There is no standard way to destroy an instance or clear its session data, which poses risks for memory leaks.
  • Multi-tenancy issues: Applications needing multiple isolated authentication contexts (e.g., distinct organization sessions) have no reliable way to manage and access specific instances by ID.
  • Testing challenges: Without a way to destroyAllInstances(), ensuring a clean state between unit tests is difficult.
Suggested Improvement

Refactor the AsgardeoAuthClient to implement the Multiton Pattern. This involves restricting direct instantiation and managing instances via a static internal map.

Specific changes recommended:

  • Protected Constructor: Change the constructor visibility to protected to prevent direct usage of new AsgardeoAuthClient().
  • Static Instance Map: Introduce a static Map<number, AsgardeoAuthClient> to store active instances.
  • Factory Method: Implement a static getInstance(id?: number) method that creates a new instance only if one does not exist for the given ID.
  • Lifecycle Methods: Add utility methods to support proper cleanup:
    • destroyInstance(id)
    • destroyAllInstances()
    • hasInstance(id)
Please select the package issue is related to

@asgardeo/javascript

Version

N/A

Reporter Checklist
  • I have searched the existing issues and this is not a duplicate.
  • I have provided all the necessary information.
  • I have verified the improvement is not available in the latest version of the package.
主要言語
TypeScript
スター
18
フォーク
67
平均マージ
3時間 40分
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

asgardeo/javascript のほかの issue

asgardeo/javascript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。