@base44-preview/sdk 0.8.40-pr.240.6950df2 → 0.8.40-pr.240.92d2811

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.
@@ -12,40 +12,48 @@ export interface SsoAccessTokenResponse {
12
12
  * services.
13
13
  *
14
14
  * This module is only available to use with a client in service role authentication mode, which means it can only be used in backend environments.
15
- *
16
- * @example
17
- * ```typescript
18
- * // Access SSO module with service role
19
- * const response = await base44.asServiceRole.sso.getAccessToken('user_123');
20
- * console.log(response.data.access_token);
21
- * ```
22
15
  */
23
16
  export interface SsoModule {
24
17
  /**
25
- * Gets SSO access token for a specific user.
18
+ * Gets an SSO access token for the user who made the current request.
26
19
  *
27
- * Retrieves a Single Sign-On access token that can be used to authenticate
28
- * a user with external services or systems.
20
+ * Use this token to authenticate the user with external systems or services.
21
+ * This only works for that same user. Create the client with
22
+ * {@link createClientFromRequest} so it acts on behalf of the request's user,
23
+ * then pass that user's ID as `userid`. If `userid` is any other user, the
24
+ * call fails. An expired token is refreshed automatically when a refresh token
25
+ * is available.
29
26
  *
30
- * @param userid - The user ID to get the access token for.
27
+ * @param userid - The ID of the user who made the current request, such as the
28
+ * `id` returned by {@link AuthModule | base44.auth.me()}.
31
29
  * @returns Promise resolving to the SSO access token response.
32
30
  *
33
31
  * @example
34
32
  * ```typescript
35
- * // Get SSO access token for a user
36
- * const response = await base44.asServiceRole.sso.getAccessToken('user_123');
37
- * console.log(response.access_token);
33
+ * // Get the user's SSO access token to call an external system
34
+ * import { createClientFromRequest } from 'npm:@base44/sdk';
35
+ *
36
+ * Deno.serve(async (req) => {
37
+ * const base44 = createClientFromRequest(req);
38
+ * const user = await base44.auth.me();
39
+ * const { access_token } = await base44.asServiceRole.sso.getAccessToken(user.id);
40
+ *
41
+ * return Response.json({ access_token });
42
+ * });
38
43
  * ```
39
44
  */
40
45
  getAccessToken(userid: string): Promise<SsoAccessTokenResponse>;
41
46
  /**
42
- * Gets the stored SSO OIDC ID token for the current app user.
47
+ * Gets the stored SSO OIDC ID token for the user who made the current request.
43
48
  *
44
- * The service-role client must include an on-behalf-of token for the same
45
- * user specified by `userid`. This method returns the stored token as-is and
46
- * does not refresh it.
49
+ * This only works for that same user, not for arbitrary users. Create the
50
+ * client with {@link createClientFromRequest} so it acts on behalf of the
51
+ * request's user, then pass that user's ID as `userid`. If `userid` is any
52
+ * other user, the call fails. The stored token is returned as-is and is never
53
+ * refreshed, so the call fails if the token has already expired.
47
54
  *
48
- * @param userid - The current app user's ID.
55
+ * @param userid - The ID of the user who made the current request, such as the
56
+ * `id` returned by {@link AuthModule | base44.auth.me()}.
49
57
  * @returns Promise resolving to the raw ID-token string.
50
58
  *
51
59
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.40-pr.240.6950df2",
3
+ "version": "0.8.40-pr.240.92d2811",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",