@meistrari/auth-core 1.18.0 → 1.19.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/README.md +19 -2
- package/dist/index.d.mts +18 -15
- package/dist/index.d.ts +18 -15
- package/dist/index.mjs +18 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @meistrari/auth-core
|
|
2
2
|
|
|
3
3
|
A TypeScript/JavaScript SDK for interacting with the Auth API service.
|
|
4
4
|
|
|
@@ -14,11 +14,18 @@ A TypeScript/JavaScript SDK for interacting with the Auth API service.
|
|
|
14
14
|
- Team management
|
|
15
15
|
- Member invitations
|
|
16
16
|
- **JWT Token Validation**
|
|
17
|
+
- **Application Authentication**
|
|
18
|
+
- OAuth PKCE application flows
|
|
19
|
+
- OAuth Device Authorization Grant endpoints
|
|
20
|
+
- Application token refresh, logout, and organization switching
|
|
21
|
+
- **API Keys**
|
|
22
|
+
- User-scoped API key CRUD
|
|
23
|
+
- Active-organization API key listing
|
|
17
24
|
|
|
18
25
|
## Installation
|
|
19
26
|
|
|
20
27
|
```bash
|
|
21
|
-
|
|
28
|
+
bun add @meistrari/auth-core
|
|
22
29
|
```
|
|
23
30
|
|
|
24
31
|
## Quick Start
|
|
@@ -38,6 +45,16 @@ await authClient.session.signInWithEmailAndPassword({
|
|
|
38
45
|
// List user's organizations
|
|
39
46
|
const organizations = await authClient.organization.listOrganizations()
|
|
40
47
|
console.log('Organizations:', organizations)
|
|
48
|
+
|
|
49
|
+
// Application auth helpers
|
|
50
|
+
const { code } = await authClient.application.startAuthorizationFlow(
|
|
51
|
+
'application-id',
|
|
52
|
+
'https://your-app.com/auth/callback',
|
|
53
|
+
'pkce-code-challenge',
|
|
54
|
+
'organization-id',
|
|
55
|
+
)
|
|
56
|
+
const tokens = await authClient.application.completeAuthorizationFlow(code, 'pkce-code-verifier')
|
|
57
|
+
console.log('Application user:', tokens.user.email)
|
|
41
58
|
```
|
|
42
59
|
|
|
43
60
|
## API Reference
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import * as better_auth_plugins from 'better-auth/plugins';
|
|
|
2
2
|
import * as better_auth from 'better-auth';
|
|
3
3
|
import { JWTPayload as JWTPayload$1 } from 'better-auth';
|
|
4
4
|
export { APIError } from 'better-auth';
|
|
5
|
-
import { z } from 'zod';
|
|
5
|
+
import z$1, { z } from 'zod';
|
|
6
6
|
import * as better_auth_client from 'better-auth/client';
|
|
7
7
|
import { BetterFetchOption } from 'better-auth/client';
|
|
8
8
|
import * as jose from 'jose';
|
|
@@ -261,21 +261,24 @@ declare const JWTPayload: z.ZodObject<{
|
|
|
261
261
|
}, z.core.$strip>;
|
|
262
262
|
type JWTPayload = JWTPayload$1 & z.infer<typeof JWTPayload>;
|
|
263
263
|
|
|
264
|
+
declare const ApiKeyMetadata: z$1.ZodObject<{
|
|
265
|
+
user: z$1.ZodObject<{
|
|
266
|
+
id: z$1.ZodString;
|
|
267
|
+
email: z$1.ZodString;
|
|
268
|
+
}, z$1.core.$strip>;
|
|
269
|
+
workspace: z$1.ZodObject<{
|
|
270
|
+
id: z$1.ZodString;
|
|
271
|
+
title: z$1.ZodString;
|
|
272
|
+
}, z$1.core.$strip>;
|
|
273
|
+
application: z$1.ZodNullable<z$1.ZodOptional<z$1.ZodObject<{
|
|
274
|
+
id: z$1.ZodString;
|
|
275
|
+
name: z$1.ZodString;
|
|
276
|
+
}, z$1.core.$strip>>>;
|
|
277
|
+
}, z$1.core.$strip>;
|
|
264
278
|
/**
|
|
265
279
|
* Metadata attached to an API key, identifying the owning user and workspace.
|
|
266
280
|
*/
|
|
267
|
-
type ApiKeyMetadata =
|
|
268
|
-
/** The user who owns this API key. */
|
|
269
|
-
user: {
|
|
270
|
-
id: string;
|
|
271
|
-
email: string;
|
|
272
|
-
};
|
|
273
|
-
/** The workspace this API key belongs to. */
|
|
274
|
-
workspace: {
|
|
275
|
-
id: string;
|
|
276
|
-
title: string;
|
|
277
|
-
};
|
|
278
|
-
} & Record<string, unknown>;
|
|
281
|
+
type ApiKeyMetadata = z$1.infer<typeof ApiKeyMetadata> & Record<string, unknown>;
|
|
279
282
|
/**
|
|
280
283
|
* A full API key including the secret key value.
|
|
281
284
|
*
|
|
@@ -5653,5 +5656,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5653
5656
|
*/
|
|
5654
5657
|
declare function extractTokenPayload(token: string): JWTPayload;
|
|
5655
5658
|
|
|
5656
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5657
|
-
export type { APIClient, ApiKey,
|
|
5659
|
+
export { ApiKeyMetadata, ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5660
|
+
export type { APIClient, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationInvitationResponse, BaseOrganization, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateApplicationInvitationResponse, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, FullOrganization, Invitation, InviteUserToApplicationOptions, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as better_auth_plugins from 'better-auth/plugins';
|
|
|
2
2
|
import * as better_auth from 'better-auth';
|
|
3
3
|
import { JWTPayload as JWTPayload$1 } from 'better-auth';
|
|
4
4
|
export { APIError } from 'better-auth';
|
|
5
|
-
import { z } from 'zod';
|
|
5
|
+
import z$1, { z } from 'zod';
|
|
6
6
|
import * as better_auth_client from 'better-auth/client';
|
|
7
7
|
import { BetterFetchOption } from 'better-auth/client';
|
|
8
8
|
import * as jose from 'jose';
|
|
@@ -261,21 +261,24 @@ declare const JWTPayload: z.ZodObject<{
|
|
|
261
261
|
}, z.core.$strip>;
|
|
262
262
|
type JWTPayload = JWTPayload$1 & z.infer<typeof JWTPayload>;
|
|
263
263
|
|
|
264
|
+
declare const ApiKeyMetadata: z$1.ZodObject<{
|
|
265
|
+
user: z$1.ZodObject<{
|
|
266
|
+
id: z$1.ZodString;
|
|
267
|
+
email: z$1.ZodString;
|
|
268
|
+
}, z$1.core.$strip>;
|
|
269
|
+
workspace: z$1.ZodObject<{
|
|
270
|
+
id: z$1.ZodString;
|
|
271
|
+
title: z$1.ZodString;
|
|
272
|
+
}, z$1.core.$strip>;
|
|
273
|
+
application: z$1.ZodNullable<z$1.ZodOptional<z$1.ZodObject<{
|
|
274
|
+
id: z$1.ZodString;
|
|
275
|
+
name: z$1.ZodString;
|
|
276
|
+
}, z$1.core.$strip>>>;
|
|
277
|
+
}, z$1.core.$strip>;
|
|
264
278
|
/**
|
|
265
279
|
* Metadata attached to an API key, identifying the owning user and workspace.
|
|
266
280
|
*/
|
|
267
|
-
type ApiKeyMetadata =
|
|
268
|
-
/** The user who owns this API key. */
|
|
269
|
-
user: {
|
|
270
|
-
id: string;
|
|
271
|
-
email: string;
|
|
272
|
-
};
|
|
273
|
-
/** The workspace this API key belongs to. */
|
|
274
|
-
workspace: {
|
|
275
|
-
id: string;
|
|
276
|
-
title: string;
|
|
277
|
-
};
|
|
278
|
-
} & Record<string, unknown>;
|
|
281
|
+
type ApiKeyMetadata = z$1.infer<typeof ApiKeyMetadata> & Record<string, unknown>;
|
|
279
282
|
/**
|
|
280
283
|
* A full API key including the secret key value.
|
|
281
284
|
*
|
|
@@ -5653,5 +5656,5 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
|
|
|
5653
5656
|
*/
|
|
5654
5657
|
declare function extractTokenPayload(token: string): JWTPayload;
|
|
5655
5658
|
|
|
5656
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5657
|
-
export type { APIClient, ApiKey,
|
|
5659
|
+
export { ApiKeyMetadata, ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
5660
|
+
export type { APIClient, ApiKey, ApiKeyWithoutSecret, Application, ApplicationAuthContextResponse, ApplicationInvitationResponse, BaseOrganization, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateApplicationInvitationResponse, CreateTeamPayload, DeviceAuthorizationActionResponse, DeviceAuthorizationContextResponse, DeviceAuthorizationResponse, DeviceContextApplication, FullOrganization, Invitation, InviteUserToApplicationOptions, InviteUserToOrganizationOptions, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, OrganizationSettings, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Strict, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIInclude, WhoAmIOptions, WhoAmIOrganization, WhoAmIResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import { createAuthClient } from 'better-auth/client';
|
|
|
5
5
|
import { organizationClient, inferOrgAdditionalFields, twoFactorClient, jwtClient, adminClient, inferAdditionalFields } from 'better-auth/client/plugins';
|
|
6
6
|
import { createAccessControl } from 'better-auth/plugins/access';
|
|
7
7
|
import { defaultStatements } from 'better-auth/plugins/organization/access';
|
|
8
|
-
import { z } from 'zod';
|
|
8
|
+
import z$1, { z } from 'zod';
|
|
9
9
|
export { APIError } from 'better-auth';
|
|
10
10
|
|
|
11
|
-
const version = "1.
|
|
11
|
+
const version = "1.19.0";
|
|
12
12
|
|
|
13
13
|
const statements = {
|
|
14
14
|
...defaultStatements,
|
|
@@ -1113,6 +1113,21 @@ class ApiKeyService {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
1116
|
+
const ApiKeyMetadata = z$1.object({
|
|
1117
|
+
user: z$1.object({
|
|
1118
|
+
id: z$1.string(),
|
|
1119
|
+
email: z$1.string()
|
|
1120
|
+
}),
|
|
1121
|
+
workspace: z$1.object({
|
|
1122
|
+
id: z$1.string(),
|
|
1123
|
+
title: z$1.string()
|
|
1124
|
+
}),
|
|
1125
|
+
application: z$1.object({
|
|
1126
|
+
id: z$1.string(),
|
|
1127
|
+
name: z$1.string()
|
|
1128
|
+
}).optional().nullable()
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1116
1131
|
class AuthClient {
|
|
1117
1132
|
client;
|
|
1118
1133
|
/**
|
|
@@ -1179,4 +1194,4 @@ function extractTokenPayload(token) {
|
|
|
1179
1194
|
return payload;
|
|
1180
1195
|
}
|
|
1181
1196
|
|
|
1182
|
-
export { ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|
|
1197
|
+
export { ApiKeyMetadata, ApplicationError, AuthClient, AuthorizationFlowError, DeviceAccessDeniedError, DeviceAuthorizationPendingError, DeviceAuthorizationSlowDownError, DeviceCodeExpiredError, DeviceTransientServerError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, JWTPayload, JWTPayloadUser, JWTPayloadWorkspace, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, extractTokenPayload, invitationAdditionalFields, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
|