@meistrari/auth-core 4.1.0 → 4.2.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.
- package/dist/index.d.mts +26 -10
- package/dist/index.d.ts +26 -10
- package/dist/index.mjs +5 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -753,16 +753,26 @@ type ClientCredentialsGrant = {
|
|
|
753
753
|
clientId: string;
|
|
754
754
|
/** A valid secret issued for the application. */
|
|
755
755
|
clientSecret: string;
|
|
756
|
-
/**
|
|
757
|
-
|
|
756
|
+
/**
|
|
757
|
+
* The organization to scope the access token to. Omit it for a token that
|
|
758
|
+
* is not scoped to any organization, for endpoints that act on the
|
|
759
|
+
* application itself rather than on one organization.
|
|
760
|
+
*/
|
|
761
|
+
organizationId?: string;
|
|
758
762
|
};
|
|
759
763
|
/**
|
|
760
764
|
* Response returned after a successful client credentials exchange.
|
|
761
765
|
*
|
|
762
766
|
* Client credentials issue only a short-lived access token, so this response
|
|
763
|
-
* intentionally does not include a refresh token.
|
|
767
|
+
* intentionally does not include a refresh token. `organization` is `null`
|
|
768
|
+
* when the grant did not name an organization.
|
|
764
769
|
*/
|
|
765
|
-
type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'refreshToken'
|
|
770
|
+
type ClientCredentialsTokenResponse<TGrant extends ClientCredentialsGrant = ClientCredentialsGrant> = Omit<CompleteAuthorizationFlowResponse, 'refreshToken' | 'organization'> & {
|
|
771
|
+
/** The organization the token is scoped to, or `null` when none was requested. */
|
|
772
|
+
organization: TGrant extends {
|
|
773
|
+
organizationId: string;
|
|
774
|
+
} ? FullOrganization : FullOrganization | null;
|
|
775
|
+
};
|
|
766
776
|
/**
|
|
767
777
|
* Response returned by the "who am I" endpoint.
|
|
768
778
|
*
|
|
@@ -773,8 +783,11 @@ type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'r
|
|
|
773
783
|
type WhoAmIResponse = {
|
|
774
784
|
/** The authenticated user. */
|
|
775
785
|
user: User;
|
|
776
|
-
/**
|
|
777
|
-
|
|
786
|
+
/**
|
|
787
|
+
* The user's active organization, or `null` for a client-credentials token
|
|
788
|
+
* requested without an organization.
|
|
789
|
+
*/
|
|
790
|
+
organization: WhoAmIOrganization | null;
|
|
778
791
|
/** Assurance context embedded in the verified access token. */
|
|
779
792
|
assurance: JWTPayload['assurance'];
|
|
780
793
|
};
|
|
@@ -1100,11 +1113,14 @@ declare class ApplicationService {
|
|
|
1100
1113
|
*
|
|
1101
1114
|
* The returned token is scoped to the requested organization and cannot be
|
|
1102
1115
|
* refreshed. Exchange the credentials again when a new token is needed.
|
|
1116
|
+
* Omit `organizationId` for a token not scoped to any organization; it can
|
|
1117
|
+
* call endpoints that act on the application itself, and the response's
|
|
1118
|
+
* `organization` is `null`.
|
|
1103
1119
|
*
|
|
1104
|
-
* @param credentials - Application credentials and target organization
|
|
1120
|
+
* @param credentials - Application credentials and optional target organization
|
|
1105
1121
|
* @returns A short-lived access token with service-account and organization details
|
|
1106
1122
|
*/
|
|
1107
|
-
exchangeClientCredentialsForToken(credentials:
|
|
1123
|
+
exchangeClientCredentialsForToken<TGrant extends ClientCredentialsGrant>(credentials: TGrant): Promise<ClientCredentialsTokenResponse<TGrant>>;
|
|
1108
1124
|
/**
|
|
1109
1125
|
* Completes an authorization flow for a specific application.
|
|
1110
1126
|
*
|
|
@@ -2782,8 +2798,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2782
2798
|
data: CompleteAuthorizationFlowResponse;
|
|
2783
2799
|
error: null;
|
|
2784
2800
|
}>;
|
|
2785
|
-
exchangeClientCredentialsForToken: (credentials:
|
|
2786
|
-
data: ClientCredentialsTokenResponse
|
|
2801
|
+
exchangeClientCredentialsForToken: <TGrant extends ClientCredentialsGrant>(credentials: TGrant) => Promise<{
|
|
2802
|
+
data: ClientCredentialsTokenResponse<TGrant>;
|
|
2787
2803
|
error: null;
|
|
2788
2804
|
} | {
|
|
2789
2805
|
data: null;
|
package/dist/index.d.ts
CHANGED
|
@@ -753,16 +753,26 @@ type ClientCredentialsGrant = {
|
|
|
753
753
|
clientId: string;
|
|
754
754
|
/** A valid secret issued for the application. */
|
|
755
755
|
clientSecret: string;
|
|
756
|
-
/**
|
|
757
|
-
|
|
756
|
+
/**
|
|
757
|
+
* The organization to scope the access token to. Omit it for a token that
|
|
758
|
+
* is not scoped to any organization, for endpoints that act on the
|
|
759
|
+
* application itself rather than on one organization.
|
|
760
|
+
*/
|
|
761
|
+
organizationId?: string;
|
|
758
762
|
};
|
|
759
763
|
/**
|
|
760
764
|
* Response returned after a successful client credentials exchange.
|
|
761
765
|
*
|
|
762
766
|
* Client credentials issue only a short-lived access token, so this response
|
|
763
|
-
* intentionally does not include a refresh token.
|
|
767
|
+
* intentionally does not include a refresh token. `organization` is `null`
|
|
768
|
+
* when the grant did not name an organization.
|
|
764
769
|
*/
|
|
765
|
-
type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'refreshToken'
|
|
770
|
+
type ClientCredentialsTokenResponse<TGrant extends ClientCredentialsGrant = ClientCredentialsGrant> = Omit<CompleteAuthorizationFlowResponse, 'refreshToken' | 'organization'> & {
|
|
771
|
+
/** The organization the token is scoped to, or `null` when none was requested. */
|
|
772
|
+
organization: TGrant extends {
|
|
773
|
+
organizationId: string;
|
|
774
|
+
} ? FullOrganization : FullOrganization | null;
|
|
775
|
+
};
|
|
766
776
|
/**
|
|
767
777
|
* Response returned by the "who am I" endpoint.
|
|
768
778
|
*
|
|
@@ -773,8 +783,11 @@ type ClientCredentialsTokenResponse = Omit<CompleteAuthorizationFlowResponse, 'r
|
|
|
773
783
|
type WhoAmIResponse = {
|
|
774
784
|
/** The authenticated user. */
|
|
775
785
|
user: User;
|
|
776
|
-
/**
|
|
777
|
-
|
|
786
|
+
/**
|
|
787
|
+
* The user's active organization, or `null` for a client-credentials token
|
|
788
|
+
* requested without an organization.
|
|
789
|
+
*/
|
|
790
|
+
organization: WhoAmIOrganization | null;
|
|
778
791
|
/** Assurance context embedded in the verified access token. */
|
|
779
792
|
assurance: JWTPayload['assurance'];
|
|
780
793
|
};
|
|
@@ -1100,11 +1113,14 @@ declare class ApplicationService {
|
|
|
1100
1113
|
*
|
|
1101
1114
|
* The returned token is scoped to the requested organization and cannot be
|
|
1102
1115
|
* refreshed. Exchange the credentials again when a new token is needed.
|
|
1116
|
+
* Omit `organizationId` for a token not scoped to any organization; it can
|
|
1117
|
+
* call endpoints that act on the application itself, and the response's
|
|
1118
|
+
* `organization` is `null`.
|
|
1103
1119
|
*
|
|
1104
|
-
* @param credentials - Application credentials and target organization
|
|
1120
|
+
* @param credentials - Application credentials and optional target organization
|
|
1105
1121
|
* @returns A short-lived access token with service-account and organization details
|
|
1106
1122
|
*/
|
|
1107
|
-
exchangeClientCredentialsForToken(credentials:
|
|
1123
|
+
exchangeClientCredentialsForToken<TGrant extends ClientCredentialsGrant>(credentials: TGrant): Promise<ClientCredentialsTokenResponse<TGrant>>;
|
|
1108
1124
|
/**
|
|
1109
1125
|
* Completes an authorization flow for a specific application.
|
|
1110
1126
|
*
|
|
@@ -2782,8 +2798,8 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
|
|
|
2782
2798
|
data: CompleteAuthorizationFlowResponse;
|
|
2783
2799
|
error: null;
|
|
2784
2800
|
}>;
|
|
2785
|
-
exchangeClientCredentialsForToken: (credentials:
|
|
2786
|
-
data: ClientCredentialsTokenResponse
|
|
2801
|
+
exchangeClientCredentialsForToken: <TGrant extends ClientCredentialsGrant>(credentials: TGrant) => Promise<{
|
|
2802
|
+
data: ClientCredentialsTokenResponse<TGrant>;
|
|
2787
2803
|
error: null;
|
|
2788
2804
|
} | {
|
|
2789
2805
|
data: null;
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function isTokenExpired(token, expiresInMs) {
|
|
|
21
21
|
return nowInSeconds > expirationTime;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const version = "4.
|
|
24
|
+
const version = "4.2.0";
|
|
25
25
|
|
|
26
26
|
function parsedEnumValues(schema) {
|
|
27
27
|
return Object.fromEntries(
|
|
@@ -1788,8 +1788,11 @@ class ApplicationService {
|
|
|
1788
1788
|
*
|
|
1789
1789
|
* The returned token is scoped to the requested organization and cannot be
|
|
1790
1790
|
* refreshed. Exchange the credentials again when a new token is needed.
|
|
1791
|
+
* Omit `organizationId` for a token not scoped to any organization; it can
|
|
1792
|
+
* call endpoints that act on the application itself, and the response's
|
|
1793
|
+
* `organization` is `null`.
|
|
1791
1794
|
*
|
|
1792
|
-
* @param credentials - Application credentials and target organization
|
|
1795
|
+
* @param credentials - Application credentials and optional target organization
|
|
1793
1796
|
* @returns A short-lived access token with service-account and organization details
|
|
1794
1797
|
*/
|
|
1795
1798
|
async exchangeClientCredentialsForToken(credentials) {
|