@logto/next 3.4.0 → 3.5.0
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.
|
@@ -85,11 +85,33 @@ const getAccessToken = async (config, resource, organizationId) => {
|
|
|
85
85
|
const getOrganizationToken = async (config, organizationId) => {
|
|
86
86
|
return getAccessToken(config, undefined, organizationId);
|
|
87
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Get access token for the specified resource or organization,
|
|
90
|
+
* this function can be used in React Server Components (RSC)
|
|
91
|
+
* Note: You can't write to the cookie in a React Server Component, so if the access token is refreshed, it won't be persisted in the session.
|
|
92
|
+
* When using server actions or API routes, we highly recommand to use the getAccessToken method
|
|
93
|
+
*/
|
|
94
|
+
const getAccessTokenRSC = async (config, resource, organizationId) => {
|
|
95
|
+
const client$1 = new client.default(config);
|
|
96
|
+
const { nodeClient } = await client$1.createNodeClientFromHeaders(await cookie.getCookies(config));
|
|
97
|
+
return nodeClient.getAccessToken(resource, organizationId);
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Get organization token from session,
|
|
101
|
+
* this function can be used in React Server Components (RSC)
|
|
102
|
+
* Note: You can't write to the cookie in a React Server Component, so if the access token is refreshed, it won't be persisted in the session.
|
|
103
|
+
* When using server actions or API routes, we highly recommand to use the getOrganizationToken method
|
|
104
|
+
*/
|
|
105
|
+
const getOrganizationTokenRSC = async (config, organizationId) => {
|
|
106
|
+
return getAccessTokenRSC(config, undefined, organizationId);
|
|
107
|
+
};
|
|
88
108
|
|
|
89
109
|
exports.default = client.default;
|
|
90
110
|
exports.getAccessToken = getAccessToken;
|
|
111
|
+
exports.getAccessTokenRSC = getAccessTokenRSC;
|
|
91
112
|
exports.getLogtoContext = getLogtoContext;
|
|
92
113
|
exports.getOrganizationToken = getOrganizationToken;
|
|
114
|
+
exports.getOrganizationTokenRSC = getOrganizationTokenRSC;
|
|
93
115
|
exports.getOrganizationTokens = getOrganizationTokens;
|
|
94
116
|
exports.handleSignIn = handleSignIn;
|
|
95
117
|
exports.signIn = signIn;
|
|
@@ -15,13 +15,13 @@ export declare const signOut: (config: LogtoNextConfig, redirectUri?: string) =>
|
|
|
15
15
|
* Get Logto context from session, including auth status and claims
|
|
16
16
|
*/
|
|
17
17
|
export declare const getLogtoContext: (config: LogtoNextConfig, getContextParameters?: Omit<GetContextParameters, 'getAccessToken' | 'resource' | 'organizationId' | 'getOrganizationToken'> & {
|
|
18
|
-
/** @deprecated use
|
|
18
|
+
/** @deprecated use getAccessTokenRSC() */
|
|
19
19
|
getAccessToken?: GetContextParameters['getAccessToken'];
|
|
20
|
-
/** @deprecated use
|
|
20
|
+
/** @deprecated use getOrganizationTokenRSC() */
|
|
21
21
|
getOrganizationToken?: GetContextParameters['getOrganizationToken'];
|
|
22
|
-
/** @deprecated use
|
|
22
|
+
/** @deprecated use getAccessTokenRSC() */
|
|
23
23
|
resource?: GetContextParameters['resource'];
|
|
24
|
-
/** @deprecated use
|
|
24
|
+
/** @deprecated use getOrganizationTokenRSC() */
|
|
25
25
|
organizationId?: GetContextParameters['organizationId'];
|
|
26
26
|
}) => Promise<LogtoContext>;
|
|
27
27
|
/**
|
|
@@ -43,4 +43,18 @@ export declare const getAccessToken: (config: LogtoNextConfig, resource?: string
|
|
|
43
43
|
* this function can be used in server actions or API routes
|
|
44
44
|
*/
|
|
45
45
|
export declare const getOrganizationToken: (config: LogtoNextConfig, organizationId?: string) => Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Get access token for the specified resource or organization,
|
|
48
|
+
* this function can be used in React Server Components (RSC)
|
|
49
|
+
* Note: You can't write to the cookie in a React Server Component, so if the access token is refreshed, it won't be persisted in the session.
|
|
50
|
+
* When using server actions or API routes, we highly recommand to use the getAccessToken method
|
|
51
|
+
*/
|
|
52
|
+
export declare const getAccessTokenRSC: (config: LogtoNextConfig, resource?: string, organizationId?: string) => Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Get organization token from session,
|
|
55
|
+
* this function can be used in React Server Components (RSC)
|
|
56
|
+
* Note: You can't write to the cookie in a React Server Component, so if the access token is refreshed, it won't be persisted in the session.
|
|
57
|
+
* When using server actions or API routes, we highly recommand to use the getOrganizationToken method
|
|
58
|
+
*/
|
|
59
|
+
export declare const getOrganizationTokenRSC: (config: LogtoNextConfig, organizationId?: string) => Promise<string>;
|
|
46
60
|
export { default } from './client';
|
|
@@ -81,5 +81,25 @@ const getAccessToken = async (config, resource, organizationId) => {
|
|
|
81
81
|
const getOrganizationToken = async (config, organizationId) => {
|
|
82
82
|
return getAccessToken(config, undefined, organizationId);
|
|
83
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Get access token for the specified resource or organization,
|
|
86
|
+
* this function can be used in React Server Components (RSC)
|
|
87
|
+
* Note: You can't write to the cookie in a React Server Component, so if the access token is refreshed, it won't be persisted in the session.
|
|
88
|
+
* When using server actions or API routes, we highly recommand to use the getAccessToken method
|
|
89
|
+
*/
|
|
90
|
+
const getAccessTokenRSC = async (config, resource, organizationId) => {
|
|
91
|
+
const client = new LogtoClient(config);
|
|
92
|
+
const { nodeClient } = await client.createNodeClientFromHeaders(await getCookies(config));
|
|
93
|
+
return nodeClient.getAccessToken(resource, organizationId);
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Get organization token from session,
|
|
97
|
+
* this function can be used in React Server Components (RSC)
|
|
98
|
+
* Note: You can't write to the cookie in a React Server Component, so if the access token is refreshed, it won't be persisted in the session.
|
|
99
|
+
* When using server actions or API routes, we highly recommand to use the getOrganizationToken method
|
|
100
|
+
*/
|
|
101
|
+
const getOrganizationTokenRSC = async (config, organizationId) => {
|
|
102
|
+
return getAccessTokenRSC(config, undefined, organizationId);
|
|
103
|
+
};
|
|
84
104
|
|
|
85
|
-
export { LogtoClient as default, getAccessToken, getLogtoContext, getOrganizationToken, getOrganizationTokens, handleSignIn, signIn, signOut };
|
|
105
|
+
export { LogtoClient as default, getAccessToken, getAccessTokenRSC, getLogtoContext, getOrganizationToken, getOrganizationTokenRSC, getOrganizationTokens, handleSignIn, signIn, signOut };
|