@maka/maka-cli 5.1.51 → 5.1.52

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maka/maka-cli",
3
- "version": "5.1.51",
3
+ "version": "5.1.52",
4
4
  "type": "module",
5
5
  "summary": "A command line tool for scaffolding Meteor 2.x applications using either React.",
6
6
  "description": "A command line tool for scaffolding Meteor 2.x applications using React.",
@@ -51,6 +51,7 @@ export const loginWithAuth0Redirect = async () => {
51
51
 
52
52
  /**
53
53
  * Login with Auth0 using popup
54
+ * Returns both ID token and access token
54
55
  */
55
56
  export const loginWithAuth0Popup = async () => {
56
57
  const client = await getAuth0Client();
@@ -58,18 +59,24 @@ export const loginWithAuth0Popup = async () => {
58
59
  await client.loginWithPopup();
59
60
 
60
61
  // Get the ID token
61
- const token = await client.getIdTokenClaims();
62
-
63
- if (!token?.__raw) {
64
- throw new Error('Failed to get Auth0 token');
62
+ const idTokenClaims = await client.getIdTokenClaims();
63
+ if (!idTokenClaims?.__raw) {
64
+ throw new Error('Failed to get Auth0 ID token');
65
65
  }
66
66
 
67
- return token.__raw;
67
+ // Get the access token
68
+ const accessToken = await client.getTokenSilently();
69
+
70
+ return {
71
+ idToken: idTokenClaims.__raw,
72
+ accessToken: accessToken,
73
+ };
68
74
  };
69
75
 
70
76
  /**
71
77
  * Handle Auth0 redirect callback
72
78
  * Call this on your callback page
79
+ * Returns both ID token and access token
73
80
  */
74
81
  export const handleAuth0Callback = async () => {
75
82
  const client = await getAuth0Client();
@@ -78,13 +85,18 @@ export const handleAuth0Callback = async () => {
78
85
  await client.handleRedirectCallback();
79
86
 
80
87
  // Get the ID token
81
- const token = await client.getIdTokenClaims();
82
-
83
- if (!token?.__raw) {
84
- throw new Error('Failed to get Auth0 token after callback');
88
+ const idTokenClaims = await client.getIdTokenClaims();
89
+ if (!idTokenClaims?.__raw) {
90
+ throw new Error('Failed to get Auth0 ID token after callback');
85
91
  }
86
92
 
87
- return token.__raw;
93
+ // Get the access token
94
+ const accessToken = await client.getTokenSilently();
95
+
96
+ return {
97
+ idToken: idTokenClaims.__raw,
98
+ accessToken: accessToken,
99
+ };
88
100
  };
89
101
 
90
102
  /**
@@ -143,21 +155,24 @@ export const getAuth0IdToken = async () => {
143
155
  /**
144
156
  * Silently refresh the Auth0 token and update Meteor session
145
157
  * This is called automatically when the token is about to expire
158
+ * Returns both ID token and access token
146
159
  */
147
160
  export const refreshAuth0Token = async () => {
148
161
  const client = await getAuth0Client();
149
162
 
150
- // Get a fresh token silently (using refresh token)
151
- await client.getTokenSilently({
163
+ // Get a fresh access token silently (using refresh token)
164
+ const accessToken = await client.getTokenSilently({
152
165
  cacheMode: 'off', // Force refresh
153
166
  });
154
167
 
155
168
  // Get the new ID token
156
- const token = await client.getIdTokenClaims();
157
-
158
- if (!token?.__raw) {
159
- throw new Error('Failed to refresh Auth0 token');
169
+ const idTokenClaims = await client.getIdTokenClaims();
170
+ if (!idTokenClaims?.__raw) {
171
+ throw new Error('Failed to refresh Auth0 ID token');
160
172
  }
161
173
 
162
- return token.__raw;
174
+ return {
175
+ idToken: idTokenClaims.__raw,
176
+ accessToken: accessToken,
177
+ };
163
178
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maka/maka-cli",
3
- "version": "5.1.51",
3
+ "version": "5.1.52",
4
4
  "type": "module",
5
5
  "summary": "A command line tool for scaffolding Meteor 2.x applications using either React.",
6
6
  "description": "A command line tool for scaffolding Meteor 2.x applications using React.",