Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#368 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
typescript

Direzione di ricerca

Inizia individuando AsgardeoAuthClient nel package @asgardeo/javascript e esaminando le implementazioni dell’SDK specifiche per il browser a cui fa riferimento l’issue. Conferma il design necessario per la costruzione protetta, il recupero delle istanze tramite ID e la pulizia del ciclo di vita; il lavoro è completato quando getInstance, destroyInstance, destroyAllInstances e hasInstance supportano client isolati e uno stato dei test pulito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
TypeScript
Stelle
18
Fork
67
Merge medio
3h 40m
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di asgardeo/javascript

Tutte le issue di asgardeo/javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.