authmi 1.0.0 → 1.1.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 +7 -7
- package/dist/chunk-EAK7C6YO.mjs +688 -0
- package/dist/client-DmZsG2xs.d.mts +406 -0
- package/dist/client-DmZsG2xs.d.ts +406 -0
- package/dist/index.d.mts +48 -23
- package/dist/index.d.ts +48 -23
- package/dist/index.js +581 -386
- package/dist/index.mjs +115 -3
- package/dist/next.d.mts +7 -37
- package/dist/next.d.ts +7 -37
- package/dist/next.js +476 -416
- package/dist/next.mjs +5 -24
- package/dist/react.d.mts +29 -30
- package/dist/react.d.ts +29 -30
- package/dist/react.js +549 -444
- package/dist/react.mjs +77 -52
- package/package.json +8 -6
- package/dist/chunk-UNKK6FP4.mjs +0 -609
- package/dist/client-D6JiIhlU.d.mts +0 -332
- package/dist/client-D6JiIhlU.d.ts +0 -332
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
interface AuthMiConfig {
|
|
2
|
+
/** Base URL of the AuthMi API — e.g. "https://api.authmi.dev" */
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
/** Service API Key for admin/M2M operations (k-xxx.ak-yyy) */
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
/** Service ID (svc-xxx) — required for token introspection */
|
|
7
|
+
serviceId?: string;
|
|
8
|
+
/** Client ID for Basic auth — alternative to apiKey for service-level auth */
|
|
9
|
+
clientId?: string;
|
|
10
|
+
/** Client Secret for Basic auth */
|
|
11
|
+
clientSecret?: string;
|
|
12
|
+
/** Default token expiration in hours (default: 24) */
|
|
13
|
+
defaultTokenExpiry?: number;
|
|
14
|
+
}
|
|
15
|
+
type ConfigProvider = AuthMiConfig | (() => AuthMiConfig);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Abstract token persistence layer.
|
|
19
|
+
*
|
|
20
|
+
* Implementations can be synchronous or async — the client awaits the result
|
|
21
|
+
* so both forms work transparently.
|
|
22
|
+
*/
|
|
23
|
+
interface TokenStorage {
|
|
24
|
+
getToken(): string | null | Promise<string | null>;
|
|
25
|
+
setToken(token: string): void | Promise<void>;
|
|
26
|
+
removeToken(): void | Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class IntrospectCache {
|
|
30
|
+
private store;
|
|
31
|
+
private defaultTtlMs;
|
|
32
|
+
constructor(ttlMs?: number);
|
|
33
|
+
/** Build a cache key from the token (simple hash) */
|
|
34
|
+
private key;
|
|
35
|
+
get(token: string): IntrospectResponse | undefined;
|
|
36
|
+
set(token: string, result: IntrospectResponse, ttlMs?: number): void;
|
|
37
|
+
invalidate(token: string): void;
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare class AuthMiError extends Error {
|
|
42
|
+
code: string;
|
|
43
|
+
statusCode?: number | undefined;
|
|
44
|
+
constructor(message: string, code: string, statusCode?: number | undefined);
|
|
45
|
+
}
|
|
46
|
+
declare class ScopeError extends AuthMiError {
|
|
47
|
+
requiredScopes: string[];
|
|
48
|
+
providedScopes: string[];
|
|
49
|
+
constructor(message: string, requiredScopes: string[], providedScopes: string[]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface ClientOptions {
|
|
53
|
+
storage?: TokenStorage;
|
|
54
|
+
cache?: IntrospectCache | false;
|
|
55
|
+
}
|
|
56
|
+
interface SignupCredentials {
|
|
57
|
+
email: string;
|
|
58
|
+
password: string;
|
|
59
|
+
name?: string;
|
|
60
|
+
client_id: string;
|
|
61
|
+
}
|
|
62
|
+
interface LoginCredentials {
|
|
63
|
+
email: string;
|
|
64
|
+
password: string;
|
|
65
|
+
expiresInHours?: number;
|
|
66
|
+
scopes?: string[];
|
|
67
|
+
}
|
|
68
|
+
interface AuthToken {
|
|
69
|
+
accessToken: string;
|
|
70
|
+
tokenType: "Bearer";
|
|
71
|
+
expiresIn: number;
|
|
72
|
+
expiresAt: string;
|
|
73
|
+
userId: string;
|
|
74
|
+
email: string;
|
|
75
|
+
emailVerified?: boolean;
|
|
76
|
+
scopes?: string[];
|
|
77
|
+
}
|
|
78
|
+
interface ForgotPasswordRequest {
|
|
79
|
+
email: string;
|
|
80
|
+
}
|
|
81
|
+
interface ResetPasswordRequest {
|
|
82
|
+
token: string;
|
|
83
|
+
newPassword: string;
|
|
84
|
+
}
|
|
85
|
+
interface VerifyEmailRequest {
|
|
86
|
+
token: string;
|
|
87
|
+
}
|
|
88
|
+
interface ResendVerificationRequest {
|
|
89
|
+
email: string;
|
|
90
|
+
}
|
|
91
|
+
type OAuthProvider = "google" | "github";
|
|
92
|
+
interface OAuthInitiateResponse {
|
|
93
|
+
url: string;
|
|
94
|
+
}
|
|
95
|
+
interface OAuthCallbackResult {
|
|
96
|
+
token: string;
|
|
97
|
+
userId: string;
|
|
98
|
+
email: string;
|
|
99
|
+
}
|
|
100
|
+
interface SamlInitiateRequest {
|
|
101
|
+
email: string;
|
|
102
|
+
redirectUri?: string;
|
|
103
|
+
}
|
|
104
|
+
interface SamlConnection {
|
|
105
|
+
id: string;
|
|
106
|
+
serviceId: string;
|
|
107
|
+
label: string;
|
|
108
|
+
idpEntityId: string;
|
|
109
|
+
idpSsoUrl: string;
|
|
110
|
+
createdAt: string;
|
|
111
|
+
}
|
|
112
|
+
interface CreateSamlConnectionRequest {
|
|
113
|
+
serviceId: string;
|
|
114
|
+
label: string;
|
|
115
|
+
idpEntityId: string;
|
|
116
|
+
idpSsoUrl: string;
|
|
117
|
+
idpCertificate: string;
|
|
118
|
+
attributeMapping?: string;
|
|
119
|
+
}
|
|
120
|
+
interface Setup2FAResult {
|
|
121
|
+
secret: string;
|
|
122
|
+
qr_uri: string;
|
|
123
|
+
}
|
|
124
|
+
interface Enable2FAResult {
|
|
125
|
+
backup_codes: string[];
|
|
126
|
+
}
|
|
127
|
+
interface Challenge2FARequest {
|
|
128
|
+
challenge_token: string;
|
|
129
|
+
code?: string;
|
|
130
|
+
backup_code?: string;
|
|
131
|
+
}
|
|
132
|
+
interface BackupCodesResult {
|
|
133
|
+
backup_codes: string[];
|
|
134
|
+
}
|
|
135
|
+
interface User {
|
|
136
|
+
userId: string;
|
|
137
|
+
email: string;
|
|
138
|
+
name?: string;
|
|
139
|
+
createdAt: string;
|
|
140
|
+
}
|
|
141
|
+
interface CreateUserRequest {
|
|
142
|
+
email: string;
|
|
143
|
+
password: string;
|
|
144
|
+
name?: string;
|
|
145
|
+
userId?: string;
|
|
146
|
+
scopes?: string[];
|
|
147
|
+
}
|
|
148
|
+
interface Role {
|
|
149
|
+
roleId: string;
|
|
150
|
+
name: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
createdAt: string;
|
|
153
|
+
}
|
|
154
|
+
interface CreateRoleRequest {
|
|
155
|
+
name: string;
|
|
156
|
+
description?: string;
|
|
157
|
+
permissions?: string[];
|
|
158
|
+
}
|
|
159
|
+
interface ApiKey {
|
|
160
|
+
keyId: string;
|
|
161
|
+
name: string;
|
|
162
|
+
scope: string;
|
|
163
|
+
scopes?: string[];
|
|
164
|
+
keyType: string;
|
|
165
|
+
tpsLimit: number;
|
|
166
|
+
revoked: boolean;
|
|
167
|
+
createdAt: string;
|
|
168
|
+
}
|
|
169
|
+
interface CreateApiKeyRequest {
|
|
170
|
+
name: string;
|
|
171
|
+
userId?: string;
|
|
172
|
+
scope?: string;
|
|
173
|
+
scopes?: string[];
|
|
174
|
+
keyType?: string;
|
|
175
|
+
tpsLimit?: number;
|
|
176
|
+
}
|
|
177
|
+
interface CreateApiKeyResponse {
|
|
178
|
+
keyId: string;
|
|
179
|
+
apiKey: string;
|
|
180
|
+
name: string;
|
|
181
|
+
scope: string;
|
|
182
|
+
scopes: string[];
|
|
183
|
+
}
|
|
184
|
+
interface Scope {
|
|
185
|
+
scopeId: string;
|
|
186
|
+
name: string;
|
|
187
|
+
key: string;
|
|
188
|
+
description?: string;
|
|
189
|
+
createdAt: string;
|
|
190
|
+
}
|
|
191
|
+
interface CreateScopeRequest {
|
|
192
|
+
name: string;
|
|
193
|
+
key: string;
|
|
194
|
+
description?: string;
|
|
195
|
+
}
|
|
196
|
+
interface IntrospectRequest {
|
|
197
|
+
serviceId: string;
|
|
198
|
+
token?: string;
|
|
199
|
+
apiKey?: string;
|
|
200
|
+
requiredScopes?: string[];
|
|
201
|
+
}
|
|
202
|
+
interface IntrospectResponse {
|
|
203
|
+
valid: boolean;
|
|
204
|
+
type?: "bearer" | "api_key";
|
|
205
|
+
userId?: string;
|
|
206
|
+
email?: string;
|
|
207
|
+
scopes?: string[];
|
|
208
|
+
keyId?: string;
|
|
209
|
+
error?: string;
|
|
210
|
+
required?: string[];
|
|
211
|
+
provided?: string[];
|
|
212
|
+
}
|
|
213
|
+
interface ValidationResult {
|
|
214
|
+
valid: boolean;
|
|
215
|
+
type?: "token" | "api_key";
|
|
216
|
+
serviceId?: string;
|
|
217
|
+
scope?: "admin" | "service" | "user";
|
|
218
|
+
scopes?: string[];
|
|
219
|
+
userId?: string;
|
|
220
|
+
email?: string;
|
|
221
|
+
keyId?: string;
|
|
222
|
+
error?: string;
|
|
223
|
+
}
|
|
224
|
+
interface Webhook {
|
|
225
|
+
webhookId: string;
|
|
226
|
+
url: string;
|
|
227
|
+
events: string[];
|
|
228
|
+
active: boolean;
|
|
229
|
+
createdAt: string;
|
|
230
|
+
}
|
|
231
|
+
interface RegisterWebhookRequest {
|
|
232
|
+
url: string;
|
|
233
|
+
events: string[];
|
|
234
|
+
secret?: string;
|
|
235
|
+
}
|
|
236
|
+
interface Plan {
|
|
237
|
+
planId: string;
|
|
238
|
+
name: string;
|
|
239
|
+
stripePriceId: string;
|
|
240
|
+
description: string;
|
|
241
|
+
monthlyPrice: number;
|
|
242
|
+
features: string[];
|
|
243
|
+
}
|
|
244
|
+
interface Subscription {
|
|
245
|
+
subscriptionId: string;
|
|
246
|
+
planId: string;
|
|
247
|
+
status: string;
|
|
248
|
+
currentPeriodEnd: string;
|
|
249
|
+
stripeSubscriptionId?: string;
|
|
250
|
+
}
|
|
251
|
+
interface CheckoutResponse {
|
|
252
|
+
url: string;
|
|
253
|
+
sessionId: string;
|
|
254
|
+
}
|
|
255
|
+
interface PortalResponse {
|
|
256
|
+
url: string;
|
|
257
|
+
}
|
|
258
|
+
interface ServiceDetail {
|
|
259
|
+
serviceId: string;
|
|
260
|
+
serviceName: string;
|
|
261
|
+
ownerEmail: string;
|
|
262
|
+
createdAt: string;
|
|
263
|
+
userCount: number;
|
|
264
|
+
apiKeyCount: number;
|
|
265
|
+
webhookCount: number;
|
|
266
|
+
twoFactorPolicy?: "disabled" | "optional" | "required";
|
|
267
|
+
allowSignup?: boolean;
|
|
268
|
+
}
|
|
269
|
+
interface UpdateServiceRequest {
|
|
270
|
+
serviceName?: string;
|
|
271
|
+
allowedCallbackUrls?: string[];
|
|
272
|
+
allowedLogoutUrls?: string[];
|
|
273
|
+
allowedOrigins?: string[];
|
|
274
|
+
twoFactorPolicy?: "disabled" | "optional" | "required";
|
|
275
|
+
allowSignup?: boolean;
|
|
276
|
+
}
|
|
277
|
+
interface AuditLog {
|
|
278
|
+
id: string;
|
|
279
|
+
action: string;
|
|
280
|
+
actorId: string;
|
|
281
|
+
actorEmail?: string;
|
|
282
|
+
resourceType: string;
|
|
283
|
+
resourceId: string;
|
|
284
|
+
metadata?: Record<string, unknown>;
|
|
285
|
+
createdAt: string;
|
|
286
|
+
}
|
|
287
|
+
interface AuditLogQuery {
|
|
288
|
+
limit?: number;
|
|
289
|
+
offset?: number;
|
|
290
|
+
actorId?: string;
|
|
291
|
+
action?: string;
|
|
292
|
+
resourceType?: string;
|
|
293
|
+
startDate?: string;
|
|
294
|
+
endDate?: string;
|
|
295
|
+
}
|
|
296
|
+
interface JwksResponse {
|
|
297
|
+
keys: JsonWebKey[];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
interface OnboardRequest {
|
|
301
|
+
serviceName: string;
|
|
302
|
+
ownerEmail: string;
|
|
303
|
+
}
|
|
304
|
+
interface OnboardResponse {
|
|
305
|
+
serviceId: string;
|
|
306
|
+
serviceName: string;
|
|
307
|
+
ownerEmail: string;
|
|
308
|
+
adminKeyId: string;
|
|
309
|
+
serviceAdminApiKey: string;
|
|
310
|
+
createdAt: string;
|
|
311
|
+
}
|
|
312
|
+
declare class AuthMiClient {
|
|
313
|
+
private configProvider;
|
|
314
|
+
private storage;
|
|
315
|
+
private cache;
|
|
316
|
+
constructor(config: ConfigProvider, options?: ClientOptions);
|
|
317
|
+
/** Resolve current config (supports lazy evaluation) */
|
|
318
|
+
private get config();
|
|
319
|
+
private request;
|
|
320
|
+
configure(config: Partial<AuthMiConfig>): void;
|
|
321
|
+
getConfig(): Omit<AuthMiConfig, "apiKey" | "clientSecret">;
|
|
322
|
+
getAccessToken(): Promise<string | null>;
|
|
323
|
+
setAccessToken(token: string): void;
|
|
324
|
+
clearAccessToken(): void;
|
|
325
|
+
isLoggedIn(): Promise<boolean>;
|
|
326
|
+
signup(credentials: SignupCredentials): Promise<AuthToken>;
|
|
327
|
+
login(credentials: LoginCredentials): Promise<AuthToken>;
|
|
328
|
+
logout(): Promise<void>;
|
|
329
|
+
refreshToken(): Promise<AuthToken>;
|
|
330
|
+
getMe(): Promise<User>;
|
|
331
|
+
forgotPassword(request: ForgotPasswordRequest): Promise<{
|
|
332
|
+
message: string;
|
|
333
|
+
}>;
|
|
334
|
+
resetPassword(request: ResetPasswordRequest): Promise<{
|
|
335
|
+
message: string;
|
|
336
|
+
}>;
|
|
337
|
+
verifyEmail(request: VerifyEmailRequest): Promise<{
|
|
338
|
+
message: string;
|
|
339
|
+
}>;
|
|
340
|
+
resendVerification(request: ResendVerificationRequest): Promise<{
|
|
341
|
+
message: string;
|
|
342
|
+
}>;
|
|
343
|
+
deactivateAccount(password: string): Promise<void>;
|
|
344
|
+
private mapAuthToken;
|
|
345
|
+
initiateOAuth(provider: OAuthProvider, redirectUri: string): Promise<string>;
|
|
346
|
+
handleOAuthCallback(url: string | URL): OAuthCallbackResult | null;
|
|
347
|
+
isOAuthCallback(url: string | URL): boolean;
|
|
348
|
+
initiateSaml(request: SamlInitiateRequest): Promise<{
|
|
349
|
+
url: string;
|
|
350
|
+
relayState?: string;
|
|
351
|
+
}>;
|
|
352
|
+
parseSamlMetadata(xml: string): Promise<{
|
|
353
|
+
idpEntityId: string;
|
|
354
|
+
idpSsoUrl: string;
|
|
355
|
+
idpCertificate: string;
|
|
356
|
+
}>;
|
|
357
|
+
listSamlConnections(): Promise<SamlConnection[]>;
|
|
358
|
+
createSamlConnection(request: CreateSamlConnectionRequest): Promise<SamlConnection>;
|
|
359
|
+
deleteSamlConnection(id: string): Promise<void>;
|
|
360
|
+
setup2fa(): Promise<Setup2FAResult>;
|
|
361
|
+
enable2fa(code: string): Promise<Enable2FAResult>;
|
|
362
|
+
disable2fa(password: string): Promise<void>;
|
|
363
|
+
regenerateBackupCodes(): Promise<BackupCodesResult>;
|
|
364
|
+
challenge2fa(request: Challenge2FARequest): Promise<AuthToken>;
|
|
365
|
+
createUser(request: CreateUserRequest): Promise<User>;
|
|
366
|
+
listUsers(): Promise<User[]>;
|
|
367
|
+
getUser(userId: string): Promise<User>;
|
|
368
|
+
deleteUser(userId: string): Promise<void>;
|
|
369
|
+
deleteUserById(userId: string): Promise<void>;
|
|
370
|
+
updatePassword(userId: string, oldPassword: string, newPassword: string): Promise<void>;
|
|
371
|
+
createRole(request: CreateRoleRequest): Promise<Role>;
|
|
372
|
+
listRoles(): Promise<Role[]>;
|
|
373
|
+
deleteRole(roleId: string): Promise<void>;
|
|
374
|
+
assignRole(userId: string, roleId: string): Promise<void>;
|
|
375
|
+
unassignRole(userId: string, roleId: string): Promise<void>;
|
|
376
|
+
getUserRoles(userId: string): Promise<Role[]>;
|
|
377
|
+
listApiKeys(): Promise<ApiKey[]>;
|
|
378
|
+
createApiKey(request: CreateApiKeyRequest): Promise<CreateApiKeyResponse>;
|
|
379
|
+
revokeApiKey(keyId: string): Promise<void>;
|
|
380
|
+
listScopes(): Promise<Scope[]>;
|
|
381
|
+
createScope(request: CreateScopeRequest): Promise<Scope>;
|
|
382
|
+
deleteScope(scopeId: string): Promise<void>;
|
|
383
|
+
introspect(request: IntrospectRequest): Promise<IntrospectResponse>;
|
|
384
|
+
validate(): Promise<ValidationResult>;
|
|
385
|
+
validateWithScopes(requiredScopes?: string[]): Promise<ValidationResult>;
|
|
386
|
+
requireScopes(...requiredScopes: string[]): Promise<ValidationResult>;
|
|
387
|
+
withScope<T>(scopes: string[], fn: () => Promise<T>): Promise<T>;
|
|
388
|
+
listWebhooks(): Promise<Webhook[]>;
|
|
389
|
+
registerWebhook(request: RegisterWebhookRequest): Promise<Webhook>;
|
|
390
|
+
deleteWebhook(webhookId: string): Promise<void>;
|
|
391
|
+
listPlans(): Promise<Plan[]>;
|
|
392
|
+
getSubscription(): Promise<Subscription>;
|
|
393
|
+
createCheckout(priceId: string): Promise<CheckoutResponse>;
|
|
394
|
+
createPortalSession(): Promise<PortalResponse>;
|
|
395
|
+
getAuditLogs(query?: AuditLogQuery): Promise<AuditLog[]>;
|
|
396
|
+
getService(serviceId: string): Promise<ServiceDetail>;
|
|
397
|
+
updateService(serviceId: string, data: UpdateServiceRequest): Promise<ServiceDetail>;
|
|
398
|
+
rotateClientSecret(serviceId: string): Promise<{
|
|
399
|
+
clientSecret: string;
|
|
400
|
+
}>;
|
|
401
|
+
getJwks(serviceId: string): Promise<JwksResponse>;
|
|
402
|
+
onboardService(request: OnboardRequest, masterAdminKey: string): Promise<OnboardResponse>;
|
|
403
|
+
deleteService(serviceId: string, masterAdminKey: string): Promise<void>;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export { type ApiKey as A, type BackupCodesResult as B, type Challenge2FARequest as C, type ServiceDetail as D, type Enable2FAResult as E, type ForgotPasswordRequest as F, type Setup2FAResult as G, type SignupCredentials as H, IntrospectCache as I, type JwksResponse as J, type Subscription as K, type LoginCredentials as L, type User as M, type VerifyEmailRequest as N, type OAuthCallbackResult as O, type Plan as P, type RegisterWebhookRequest as R, type SamlConnection as S, type TokenStorage as T, type UpdateServiceRequest as U, type ValidationResult as V, type Webhook as W, type AuditLog as a, type AuditLogQuery as b, AuthMiClient as c, type AuthMiConfig as d, AuthMiError as e, type AuthToken as f, type CheckoutResponse as g, type ClientOptions as h, type ConfigProvider as i, type CreateApiKeyRequest as j, type CreateApiKeyResponse as k, type CreateRoleRequest as l, type CreateSamlConnectionRequest as m, type CreateScopeRequest as n, type CreateUserRequest as o, type IntrospectRequest as p, type IntrospectResponse as q, type OAuthInitiateResponse as r, type OAuthProvider as s, type PortalResponse as t, type ResendVerificationRequest as u, type ResetPasswordRequest as v, type Role as w, type SamlInitiateRequest as x, type Scope as y, ScopeError as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,31 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import { T as TokenStorage } from './client-DmZsG2xs.mjs';
|
|
2
|
+
export { A as ApiKey, a as AuditLog, b as AuditLogQuery, c as AuthMiClient, d as AuthMiConfig, e as AuthMiError, f as AuthToken, B as BackupCodesResult, C as Challenge2FARequest, g as CheckoutResponse, h as ClientOptions, i as ConfigProvider, j as CreateApiKeyRequest, k as CreateApiKeyResponse, l as CreateRoleRequest, m as CreateSamlConnectionRequest, n as CreateScopeRequest, o as CreateUserRequest, E as Enable2FAResult, F as ForgotPasswordRequest, I as IntrospectCache, p as IntrospectRequest, q as IntrospectResponse, J as JwksResponse, L as LoginCredentials, O as OAuthCallbackResult, r as OAuthInitiateResponse, s as OAuthProvider, P as Plan, t as PortalResponse, R as RegisterWebhookRequest, u as ResendVerificationRequest, v as ResetPasswordRequest, w as Role, S as SamlConnection, x as SamlInitiateRequest, y as Scope, z as ScopeError, D as ServiceDetail, G as Setup2FAResult, H as SignupCredentials, K as Subscription, U as UpdateServiceRequest, M as User, V as ValidationResult, N as VerifyEmailRequest, W as Webhook } from './client-DmZsG2xs.mjs';
|
|
3
|
+
|
|
4
|
+
declare class LocalStorageTokenStorage implements TokenStorage {
|
|
5
|
+
private canAccess;
|
|
6
|
+
getToken(): string | null;
|
|
7
|
+
setToken(token: string): void;
|
|
8
|
+
removeToken(): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface CookieOptions {
|
|
12
|
+
/** Cookie name (default: "authmi_token") */
|
|
13
|
+
name?: string;
|
|
14
|
+
httpOnly?: boolean;
|
|
15
|
+
secure?: boolean;
|
|
16
|
+
sameSite?: "lax" | "strict" | "none";
|
|
17
|
+
domain?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
maxAge?: number;
|
|
20
|
+
}
|
|
21
|
+
declare class CookieTokenStorage implements TokenStorage {
|
|
22
|
+
private cookieStr;
|
|
23
|
+
private options;
|
|
24
|
+
/**
|
|
25
|
+
* @param cookieStr The raw `Cookie` header value (server-side) or `document.cookie` (browser).
|
|
26
|
+
* Pass an empty string in environments where cookies are managed via Set-Cookie.
|
|
27
|
+
*/
|
|
28
|
+
constructor(cookieStr?: string, options?: CookieOptions);
|
|
29
|
+
/** Update the raw cookie string (e.g. per-request in server middleware) */
|
|
30
|
+
setCookieString(cookieStr: string): void;
|
|
31
|
+
/** Escape special regex characters in a string */
|
|
32
|
+
private static escapeRegex;
|
|
33
|
+
getToken(): string | null;
|
|
34
|
+
private lastSetCookie;
|
|
35
|
+
setToken(token: string): void;
|
|
36
|
+
/** The last Set-Cookie header generated by setToken() or removeToken() */
|
|
37
|
+
getSetCookieHeader(): string | undefined;
|
|
38
|
+
removeToken(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare class MemoryTokenStorage implements TokenStorage {
|
|
42
|
+
private token;
|
|
43
|
+
getToken(): string | null;
|
|
44
|
+
setToken(token: string): void;
|
|
45
|
+
removeToken(): void;
|
|
46
|
+
}
|
|
2
47
|
|
|
3
48
|
/**
|
|
4
49
|
* Auth Mi Client
|
|
5
50
|
*
|
|
6
51
|
* Official client library for Auth Mi - Multi-tenant authentication-as-a-service
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { AuthMiClient } from "authmi";
|
|
11
|
-
*
|
|
12
|
-
* const client = new AuthMiClient({
|
|
13
|
-
* baseUrl: "https://authmi.dev",
|
|
14
|
-
* serviceId: "svc-xxx",
|
|
15
|
-
* apiKey: "ak-xxx",
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // Login
|
|
19
|
-
* const token = await client.login({
|
|
20
|
-
* email: "user@example.com",
|
|
21
|
-
* password: "password123",
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* // Validate token
|
|
25
|
-
* const isValid = await client.validate();
|
|
26
|
-
* ```
|
|
27
52
|
*/
|
|
28
53
|
|
|
29
|
-
declare const VERSION = "1.
|
|
54
|
+
declare const VERSION = "1.1.0";
|
|
30
55
|
|
|
31
|
-
export { VERSION };
|
|
56
|
+
export { type CookieOptions, CookieTokenStorage, LocalStorageTokenStorage, MemoryTokenStorage, TokenStorage, VERSION };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import { T as TokenStorage } from './client-DmZsG2xs.js';
|
|
2
|
+
export { A as ApiKey, a as AuditLog, b as AuditLogQuery, c as AuthMiClient, d as AuthMiConfig, e as AuthMiError, f as AuthToken, B as BackupCodesResult, C as Challenge2FARequest, g as CheckoutResponse, h as ClientOptions, i as ConfigProvider, j as CreateApiKeyRequest, k as CreateApiKeyResponse, l as CreateRoleRequest, m as CreateSamlConnectionRequest, n as CreateScopeRequest, o as CreateUserRequest, E as Enable2FAResult, F as ForgotPasswordRequest, I as IntrospectCache, p as IntrospectRequest, q as IntrospectResponse, J as JwksResponse, L as LoginCredentials, O as OAuthCallbackResult, r as OAuthInitiateResponse, s as OAuthProvider, P as Plan, t as PortalResponse, R as RegisterWebhookRequest, u as ResendVerificationRequest, v as ResetPasswordRequest, w as Role, S as SamlConnection, x as SamlInitiateRequest, y as Scope, z as ScopeError, D as ServiceDetail, G as Setup2FAResult, H as SignupCredentials, K as Subscription, U as UpdateServiceRequest, M as User, V as ValidationResult, N as VerifyEmailRequest, W as Webhook } from './client-DmZsG2xs.js';
|
|
3
|
+
|
|
4
|
+
declare class LocalStorageTokenStorage implements TokenStorage {
|
|
5
|
+
private canAccess;
|
|
6
|
+
getToken(): string | null;
|
|
7
|
+
setToken(token: string): void;
|
|
8
|
+
removeToken(): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface CookieOptions {
|
|
12
|
+
/** Cookie name (default: "authmi_token") */
|
|
13
|
+
name?: string;
|
|
14
|
+
httpOnly?: boolean;
|
|
15
|
+
secure?: boolean;
|
|
16
|
+
sameSite?: "lax" | "strict" | "none";
|
|
17
|
+
domain?: string;
|
|
18
|
+
path?: string;
|
|
19
|
+
maxAge?: number;
|
|
20
|
+
}
|
|
21
|
+
declare class CookieTokenStorage implements TokenStorage {
|
|
22
|
+
private cookieStr;
|
|
23
|
+
private options;
|
|
24
|
+
/**
|
|
25
|
+
* @param cookieStr The raw `Cookie` header value (server-side) or `document.cookie` (browser).
|
|
26
|
+
* Pass an empty string in environments where cookies are managed via Set-Cookie.
|
|
27
|
+
*/
|
|
28
|
+
constructor(cookieStr?: string, options?: CookieOptions);
|
|
29
|
+
/** Update the raw cookie string (e.g. per-request in server middleware) */
|
|
30
|
+
setCookieString(cookieStr: string): void;
|
|
31
|
+
/** Escape special regex characters in a string */
|
|
32
|
+
private static escapeRegex;
|
|
33
|
+
getToken(): string | null;
|
|
34
|
+
private lastSetCookie;
|
|
35
|
+
setToken(token: string): void;
|
|
36
|
+
/** The last Set-Cookie header generated by setToken() or removeToken() */
|
|
37
|
+
getSetCookieHeader(): string | undefined;
|
|
38
|
+
removeToken(): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare class MemoryTokenStorage implements TokenStorage {
|
|
42
|
+
private token;
|
|
43
|
+
getToken(): string | null;
|
|
44
|
+
setToken(token: string): void;
|
|
45
|
+
removeToken(): void;
|
|
46
|
+
}
|
|
2
47
|
|
|
3
48
|
/**
|
|
4
49
|
* Auth Mi Client
|
|
5
50
|
*
|
|
6
51
|
* Official client library for Auth Mi - Multi-tenant authentication-as-a-service
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { AuthMiClient } from "authmi";
|
|
11
|
-
*
|
|
12
|
-
* const client = new AuthMiClient({
|
|
13
|
-
* baseUrl: "https://authmi.dev",
|
|
14
|
-
* serviceId: "svc-xxx",
|
|
15
|
-
* apiKey: "ak-xxx",
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // Login
|
|
19
|
-
* const token = await client.login({
|
|
20
|
-
* email: "user@example.com",
|
|
21
|
-
* password: "password123",
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* // Validate token
|
|
25
|
-
* const isValid = await client.validate();
|
|
26
|
-
* ```
|
|
27
52
|
*/
|
|
28
53
|
|
|
29
|
-
declare const VERSION = "1.
|
|
54
|
+
declare const VERSION = "1.1.0";
|
|
30
55
|
|
|
31
|
-
export { VERSION };
|
|
56
|
+
export { type CookieOptions, CookieTokenStorage, LocalStorageTokenStorage, MemoryTokenStorage, TokenStorage, VERSION };
|