Skip to content

Commit 64e9c33

Browse files
authored
Merge pull request #71 from brionmario/next
feat(react): introduce `SignUp` & B2B components
2 parents f69f941 + e1389a7 commit 64e9c33

File tree

302 files changed

+33279
-7675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+33279
-7675
lines changed

.changeset/real-dolls-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@asgardeo/react': minor
3+
---
4+
5+
Introduce `SignUp` & B2B components.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ Thumbs.db
4343

4444
# Environment files
4545
*.env
46-
.env*
46+
.env*
47+
.cursor/rules/nx-rules.mdc
48+
.github/instructions/nx.instructions.md

.vscode/settings.json

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
{
2-
"conventionalCommits.scopes": [
3-
"workspace",
4-
"core",
5-
"react",
6-
"auth-components",
7-
"sample-app",
8-
"docs"
9-
],
10-
"editor.codeActionsOnSave": {
11-
"source.fixAll.eslint": "explicit"
12-
},
13-
"css.validate": false,
14-
"less.validate": false,
15-
"scss.validate": false,
16-
"stylelint.validate": [
17-
"css",
18-
"scss"
19-
],
20-
"typescript.tsdk": "node_modules/typescript/lib",
21-
"editor.formatOnSave": true
2+
"conventionalCommits.scopes": ["workspace", "core", "react", "auth-components", "sample-app", "docs"],
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": "explicit"
5+
},
6+
"css.validate": false,
7+
"less.validate": false,
8+
"scss.validate": false,
9+
"stylelint.validate": ["css", "scss"],
10+
"typescript.tsdk": "node_modules/typescript/lib",
11+
"editor.formatOnSave": true,
12+
"nxConsole.generateAiAgentRules": true
2213
}

ERROR_CODES.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Error Code Convention
2+
3+
## Overview
4+
This document defines the error code convention used throughout the Asgardeo JavaScript SDK to ensure consistency and maintainability.
5+
6+
## Format
7+
Error codes follow this format:
8+
```
9+
[{packageName}-]{functionName}-{ErrorCategory}-{SequentialNumber}
10+
```
11+
12+
### Components
13+
14+
#### 1. Package Name (Optional)
15+
- Use when the function might exist in multiple packages or when disambiguation is needed
16+
- Use the package identifier (e.g., "javascript", "react", "node")
17+
- Examples: `javascript-`, `react-`, `node-`
18+
19+
#### 2. Function Name
20+
- Use the exact function name as defined in the code
21+
- Use camelCase format matching the function declaration
22+
- Examples: `getUserInfo`, `executeEmbeddedSignUpFlow`, `initializeEmbeddedSignInFlow`
23+
24+
#### 3. Error Category
25+
Categories represent the type of error:
26+
27+
- **ValidationError**: Input validation failures, missing required parameters, invalid parameter values
28+
- **ResponseError**: HTTP response errors, network failures, server errors
29+
- **ConfigurationError**: Configuration-related errors, missing configuration, invalid settings
30+
- **AuthenticationError**: Authentication-specific errors, token issues, credential problems
31+
- **AuthorizationError**: Authorization-specific errors, permission denied, access control
32+
- **NetworkError**: Network connectivity issues, timeout errors
33+
- **ParseError**: JSON parsing errors, response format issues
34+
35+
#### 4. Sequential Number
36+
- Three-digit zero-padded format: `001`, `002`, `003`, etc.
37+
- Start from `001` for each function
38+
- Increment sequentially within each function
39+
- Group by error category for readability
40+
41+
## Numbering Strategy
42+
43+
For each function, allocate number ranges by category:
44+
- **001-099**: ValidationError
45+
- **100-199**: ResponseError
46+
- **200-299**: ConfigurationError
47+
- **300-399**: AuthenticationError
48+
- **400-499**: AuthorizationError
49+
- **500-599**: NetworkError
50+
- **600-699**: ParseError
51+
52+
## Package Prefix Guidelines
53+
54+
Use the package prefix when:
55+
1. **Multi-package scenarios**: When the same function name exists across different packages
56+
2. **Public APIs**: For functions that are part of the public API and might be referenced externally
57+
3. **Complex projects**: In large codebases where disambiguation aids debugging and maintenance
58+
59+
Examples of when to use prefixes:
60+
- `javascript-executeEmbeddedSignUpFlow-ValidationError-001` (public API function)
61+
- `react-useAuth-ConfigurationError-201` (React-specific hook)
62+
- `node-createServer-NetworkError-501` (Node.js-specific function)
63+
64+
## Examples
65+
66+
### With Package Prefix (Recommended for Public APIs)
67+
```typescript
68+
// executeEmbeddedSignUpFlow Function (JavaScript package)
69+
'javascript-executeEmbeddedSignUpFlow-ValidationError-001' // Missing payload
70+
'javascript-executeEmbeddedSignUpFlow-ValidationError-002' // Invalid flowType
71+
'javascript-executeEmbeddedSignUpFlow-ResponseError-100' // HTTP error response
72+
```
73+
74+
### Without Package Prefix (Internal/Simple Functions)
75+
```typescript
76+
// getUserInfo Function (internal utility)
77+
'getUserInfo-ValidationError-001' // Invalid URL
78+
'getUserInfo-ValidationError-002' // Missing access token
79+
'getUserInfo-ResponseError-100' // HTTP error response
80+
'getUserInfo-ResponseError-101' // Invalid response format
81+
```
82+
83+
## Implementation Guidelines
84+
85+
1. **Consistency**: Always use the exact function name in error codes
86+
2. **Package Prefix**: Use package prefixes for public APIs and when disambiguation is needed
87+
3. **Documentation**: Document each error code with clear description
88+
4. **Categorization**: Choose the most appropriate category for each error
89+
5. **Numbering**: Use the range-based numbering system for better organization
90+
6. **Future-proofing**: Leave gaps in numbering for future error codes
91+
92+
## Current Implementation Status
93+
94+
### Updated Functions (Following New Convention)
95+
-`executeEmbeddedSignUpFlow` - Uses `javascript-` prefix with range-based numbering
96+
97+
### Functions Needing Updates
98+
-`getUserInfo` - Currently uses simple format, needs prefix evaluation
99+
-`initializeEmbeddedSignInFlow` - Currently uses simple format, needs prefix evaluation
100+
-`executeEmbeddedSignInFlow` - Currently uses simple format, needs prefix evaluation
101+
102+
## Migration Notes
103+
104+
When updating existing error codes:
105+
1. **Evaluate prefix necessity**: Determine if the function needs a package prefix
106+
2. **Update numbering**: Move to range-based numbering (ValidationError: 001-099, ResponseError: 100-199, etc.)
107+
3. **Update tests**: Ensure all tests use the new error codes
108+
4. **Update documentation**: Document the new error codes
109+
5. **Consider backward compatibility**: If codes are exposed in public APIs, plan migration strategy
110+
111+
## Example Migration
112+
113+
### Before (Old Convention)
114+
```typescript
115+
'getUserInfo-ValidationError-001'
116+
'getUserInfo-ResponseError-001'
117+
```
118+
119+
### After (New Convention)
120+
```typescript
121+
// Option 1: With prefix (for public API)
122+
'javascript-getUserInfo-ValidationError-001'
123+
'javascript-getUserInfo-ResponseError-100'
124+
125+
// Option 2: Without prefix (for internal use)
126+
'getUserInfo-ValidationError-001'
127+
'getUserInfo-ResponseError-100'
128+
```
129+
130+
## Current Error Code Registry
131+
132+
### executeEmbeddedSignUpFlow (Updated - New Convention)
133+
- `javascript-executeEmbeddedSignUpFlow-ValidationError-001` - Missing payload
134+
- `javascript-executeEmbeddedSignUpFlow-ValidationError-002` - Invalid flowType
135+
- `javascript-executeEmbeddedSignUpFlow-ResponseError-100` - HTTP error response
136+
137+
### getUserInfo (Legacy Format)
138+
- `getUserInfo-ValidationError-001` - Invalid endpoint URL
139+
- `getUserInfo-ResponseError-001` - Failed to fetch user info
140+
141+
### initializeEmbeddedSignInFlow (Legacy Format)
142+
- `initializeEmbeddedSignInFlow-ValidationError-002` - Missing authorization payload
143+
- `initializeEmbeddedSignInFlow-ResponseError-001` - Authorization request failed
144+
145+
### executeEmbeddedSignInFlow (Legacy Format)
146+
- `executeEmbeddedSignInFlow-ValidationError-002` - Missing required parameter
147+
- `initializeEmbeddedSignInFlow-ResponseError-001` - Response error (Note: incorrect function name reference)
148+
149+
## Recommended Actions
150+
151+
1. **Standardize numbering**: Update legacy functions to use range-based numbering
152+
2. **Fix inconsistencies**: Correct the error code in `executeEmbeddedSignInFlow` that references the wrong function
153+
3. **Add prefixes**: Evaluate which functions need package prefixes based on their public API status
154+
4. **Document usage**: Add inline documentation in each file listing the error codes used

packages/browser/src/__legacy__/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
IsomorphicCrypto,
2424
TokenExchangeRequestConfig,
2525
StorageManager,
26-
IdTokenPayload,
26+
IdToken,
2727
OIDCEndpoints,
2828
User,
2929
} from '@asgardeo/javascript';
@@ -737,7 +737,7 @@ export class AsgardeoSPAClient {
737737
*
738738
* @preserve
739739
*/
740-
public async getDecodedIdToken(): Promise<IdTokenPayload | undefined> {
740+
public async getDecodedIdToken(): Promise<IdToken | undefined> {
741741
await this._validateMethod();
742742

743743
return this._client?.getDecodedIdToken();

0 commit comments

Comments
 (0)