@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.
- package/dist/modules/sso.types.d.ts +27 -19
- package/package.json +1 -1
|
@@ -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
|
|
18
|
+
* Gets an SSO access token for the user who made the current request.
|
|
26
19
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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
|
|
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
|
|
36
|
-
*
|
|
37
|
-
*
|
|
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
|
|
47
|
+
* Gets the stored SSO OIDC ID token for the user who made the current request.
|
|
43
48
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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
|
|
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
|