@absolutejs/auth 0.27.0-beta.8 → 0.27.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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/client/react.ts"],
4
+ "sourcesContent": [
5
+ "// Thin React hooks over `createAuthClient`. Same `{ data, error }` shape; the hook adds\n// `isPending` state and a stable mutator. Bring your own form/UI — these are primitives, not\n// components. Composables (Vue/Solid/Svelte) will follow the same pattern over the same client.\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport type { AuthClient, AuthClientError } from './createAuthClient';\n\ntype Mutator<Args, Data> = (\n\targs: Args\n) => Promise<{ data: Data | null; error: AuthClientError | null }>;\n\ntype MutationState<Args, Data> = {\n\tdata: Data | null;\n\terror: AuthClientError | null;\n\tisPending: boolean;\n\tmutate: Mutator<Args, Data>;\n\treset: () => void;\n};\n\n// Generic mutation hook. The other hooks are 1–2 line specializations of this — kept private\n// here so consumers see the cohesive named API and don't depend on this shape.\nconst useMutation = <Args, Data>(\n\trun: Mutator<Args, Data>\n): MutationState<Args, Data> => {\n\tconst [data, setData] = useState<Data | null>(null);\n\tconst [error, setError] = useState<AuthClientError | null>(null);\n\tconst [isPending, setIsPending] = useState(false);\n\tconst mountedRef = useRef(true);\n\tuseEffect(\n\t\t() => () => {\n\t\t\tmountedRef.current = false;\n\t\t},\n\t\t[]\n\t);\n\n\tconst mutate: Mutator<Args, Data> = useCallback(\n\t\tasync (args) => {\n\t\t\tsetIsPending(true);\n\t\t\tsetError(null);\n\t\t\tconst result = await run(args);\n\t\t\tif (mountedRef.current) {\n\t\t\t\tsetData(result.data);\n\t\t\t\tsetError(result.error);\n\t\t\t\tsetIsPending(false);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t},\n\t\t[run]\n\t);\n\n\tconst reset = useCallback(() => {\n\t\tsetData(null);\n\t\tsetError(null);\n\t\tsetIsPending(false);\n\t}, []);\n\n\treturn { data, error, isPending, mutate, reset };\n};\n\nexport const useMagicLink = (client: AuthClient) =>\n\tuseMutation(client.passwordless.requestMagicLink);\n\nexport const useMfaChallenge = (client: AuthClient) =>\n\tuseMutation(client.mfa.challenge);\n\nexport const usePasswordReset = (client: AuthClient) =>\n\tuseMutation(client.passwordReset.request);\n\n// Query hook for the user's active sessions; refetch() reruns it. The shape matches the\n// mutation hooks closely (isPending/error/data) so the consumer can render one way.\nexport const useSessions = (client: AuthClient) => {\n\tconst [data, setData] = useState<unknown[] | null>(null);\n\tconst [error, setError] = useState<AuthClientError | null>(null);\n\tconst [isPending, setIsPending] = useState(true);\n\tconst mountedRef = useRef(true);\n\tuseEffect(\n\t\t() => () => {\n\t\t\tmountedRef.current = false;\n\t\t},\n\t\t[]\n\t);\n\n\tconst refetch = useCallback(async () => {\n\t\tsetIsPending(true);\n\t\tconst result = await client.sessions.list();\n\t\tif (mountedRef.current) {\n\t\t\tsetData(result.data);\n\t\t\tsetError(result.error);\n\t\t\tsetIsPending(false);\n\t\t}\n\t}, [client]);\n\n\tuseEffect(() => {\n\t\tvoid refetch();\n\t}, [refetch]);\n\n\tconst revoke = useCallback(\n\t\tasync (sessionId: string) => {\n\t\t\tconst result = await client.sessions.revoke(sessionId);\n\t\t\tif (result.error === null) await refetch();\n\n\t\t\treturn result;\n\t\t},\n\t\t[client, refetch]\n\t);\n\n\treturn { data, error, isPending, refetch, revoke };\n};\n\nexport const useSignIn = (client: AuthClient) =>\n\tuseMutation(client.signIn.email);\n\nexport const useSignOut = (client: AuthClient) => useMutation(client.signOut);\n\nexport const useSignUp = (client: AuthClient) =>\n\tuseMutation(client.signUp.email);\n"
6
+ ],
7
+ "mappings": ";;AAIA;AAiBA,IAAM,cAAc,CACnB,QAC+B;AAAA,EAC/B,OAAO,MAAM,WAAW,SAAsB,IAAI;AAAA,EAClD,OAAO,OAAO,YAAY,SAAiC,IAAI;AAAA,EAC/D,OAAO,WAAW,gBAAgB,SAAS,KAAK;AAAA,EA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AAAA,MACnB,SAAS,OAAO,KAAK;AAAA,MACrB,aAAa,KAAK;AAAA,IACnB;AAAA,KACE,CAAC,MAAM,CAAC;AAAA,EAEX,UAAU,MAAM;AAAA,IACV,QAAQ;AAAA,KACX,CAAC,OAAO,CAAC;AAAA,EAEZ,MAAM,SAAS,YACd,OAAO,cAAsB;AAAA,IAC5B,MAAM,SAAS,MAAM,OAAO,SAAS,OAAO,SAAS;AAAA,IACrD,IAAI,OAAO,UAAU;AAAA,MAAM,MAAM,QAAQ;AAAA,IAEzC,OAAO;AAAA,KAER,CAAC,QAAQ,OAAO,CACjB;AAAA,EAEA,OAAO,EAAE,MAAM,OAAO,WAAW,SAAS,OAAO;AAAA;AAG3C,IAAM,YAAY,CAAC,WACzB,YAAY,OAAO,OAAO,KAAK;AAEzB,IAAM,aAAa,CAAC,WAAuB,YAAY,OAAO,OAAO;AAErE,IAAM,YAAY,CAAC,WACzB,YAAY,OAAO,OAAO,KAAK;",
8
+ "debugId": "6E80ACAADF4D834764756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,5 +1,11 @@
1
1
  import type { FgaSchema, Warrant, WarrantStore } from './types';
2
+ export type FgaCache = {
3
+ clear: () => void;
4
+ get: (key: string) => boolean | undefined;
5
+ set: (key: string, value: boolean) => void;
6
+ };
2
7
  export type FgaConfig = {
8
+ cache?: FgaCache;
3
9
  maxDepth?: number;
4
10
  schema: FgaSchema;
5
11
  warrantStore: WarrantStore;
@@ -15,10 +21,21 @@ export type Subject = {
15
21
  subjectId: string;
16
22
  subjectType: string;
17
23
  };
24
+ export type ObjectQuery = {
25
+ relation: string;
26
+ resourceType: string;
27
+ subjectId: string;
28
+ subjectType: string;
29
+ };
18
30
  export declare const check: (config: FgaConfig, query: CheckQuery) => Promise<boolean>;
31
+ export declare const createInMemoryCheckCache: ({ maxEntries, ttlMs }?: {
32
+ maxEntries?: number;
33
+ ttlMs?: number;
34
+ }) => FgaCache;
19
35
  export declare const createFgaEngine: (config: FgaConfig) => {
20
36
  check: (query: CheckQuery) => Promise<boolean>;
21
37
  deleteWarrant: (warrant: Warrant) => Promise<void>;
38
+ listObjects: (query: ObjectQuery) => Promise<string[]>;
22
39
  listSubjects: (query: {
23
40
  relation: string;
24
41
  resourceId: string;
@@ -27,6 +44,7 @@ export declare const createFgaEngine: (config: FgaConfig) => {
27
44
  writeWarrant: (warrant: Warrant) => Promise<void>;
28
45
  };
29
46
  export declare const deleteWarrant: (config: FgaConfig, warrant: Warrant) => Promise<void>;
47
+ export declare const listObjects: (config: FgaConfig, query: ObjectQuery) => Promise<string[]>;
30
48
  export declare const listSubjects: (config: FgaConfig, query: {
31
49
  relation: string;
32
50
  resourceId: string;
@@ -0,0 +1,2 @@
1
+ import type { FgaSchema } from './types';
2
+ export declare const parseSchema: (dsl: string) => FgaSchema;
@@ -9,6 +9,7 @@ export type Warrant = {
9
9
  export type WarrantStore = {
10
10
  deleteWarrant: (warrant: Warrant) => Promise<void>;
11
11
  listForResource: (resourceType: string, resourceId: string, relation: string) => Promise<Warrant[]>;
12
+ listResourceIds: (resourceType: string) => Promise<string[]>;
12
13
  saveWarrant: (warrant: Warrant) => Promise<void>;
13
14
  };
14
15
  export type RelationRule = {
package/dist/index.d.ts CHANGED
@@ -13450,9 +13450,9 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
13450
13450
  body: unknown;
13451
13451
  params: {};
13452
13452
  query: {
13453
- nonce?: string | undefined;
13454
13453
  client_id?: string | undefined;
13455
13454
  scope?: string | undefined;
13455
+ nonce?: string | undefined;
13456
13456
  code_challenge?: string | undefined;
13457
13457
  code_challenge_method?: string | undefined;
13458
13458
  redirect_uri?: string | undefined;
@@ -13478,10 +13478,10 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
13478
13478
  [x: string]: {
13479
13479
  post: {
13480
13480
  body: {
13481
- audience?: string | undefined;
13482
- resource?: string | undefined;
13483
13481
  client_id?: string | undefined;
13484
13482
  scope?: string | undefined;
13483
+ audience?: string | undefined;
13484
+ resource?: string | undefined;
13485
13485
  refresh_token?: string | undefined;
13486
13486
  client_secret?: string | undefined;
13487
13487
  grant_type?: string | undefined;
@@ -14635,8 +14635,13 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
14635
14635
  standaloneSchema: {};
14636
14636
  response: {};
14637
14637
  }>>;
14638
+ export * from './actions';
14638
14639
  export * from './types';
14639
14640
  export * from './typebox';
14641
+ export * from './vault/config';
14642
+ export * from './vault/types';
14643
+ export { createInMemoryVaultStore } from './vault/inMemoryVaultStore';
14644
+ export { createNeonVaultStore, createPostgresVaultStore, vaultEntriesTable } from './vault/postgresVaultStore';
14640
14645
  export type { AuthSessionStore } from './session/types';
14641
14646
  export { isAuthIntent, isUserSessionId, isValidUser } from './typeGuards';
14642
14647
  export { AuthIdentityConflictError } from './errors';
@@ -14698,6 +14703,7 @@ export { createTamperEvidentSink, hashAuditEvent, verifyAuditChain } from './aud
14698
14703
  export type { AuditChainResult, AuditIntegrity } from './audit/integrity';
14699
14704
  export { createSiemLogStream } from './audit/siem';
14700
14705
  export type { SiemEndpoint, SiemFormat } from './audit/siem';
14706
+ export * from './abuse/captcha';
14701
14707
  export * from './abuse/config';
14702
14708
  export * from './authorization/config';
14703
14709
  export { protectPermissionPlugin } from './authorization/protectPermission';
@@ -14712,6 +14718,7 @@ export { createInMemoryLockoutStore } from './lockout/inMemoryLockoutStore';
14712
14718
  export { createNeonLockoutStore, createPostgresLockoutStore, lockoutsTable } from './lockout/postgresLockoutStore';
14713
14719
  export { createRedisLockoutStore } from './lockout/redisLockoutStore';
14714
14720
  export type { RedisLike } from './stores/redis';
14721
+ export { exportAuditCsv } from './audit/export';
14715
14722
  export { createInMemoryAuditSink } from './audit/inMemoryAuditStore';
14716
14723
  export { auditEventsTable, createNeonAuditSink, createPostgresAuditSink } from './audit/postgresAuditStore';
14717
14724
  export * from './sso/types';
@@ -14736,10 +14743,12 @@ export type { DpopResult } from './oidc/dpop';
14736
14743
  export { createInMemoryAuthorizationCodeStore, createInMemoryOAuthClientStore, createInMemoryOidcRefreshTokenStore } from './oidc/inMemoryStores';
14737
14744
  export { createNeonAuthorizationCodeStore, createNeonOAuthClientStore, createNeonOidcRefreshTokenStore, createPostgresAuthorizationCodeStore, createPostgresOAuthClientStore, createPostgresOidcRefreshTokenStore, oauthClientsTable, oauthCodesTable, oauthRefreshTokensTable } from './oidc/postgresStores';
14738
14745
  export * from './adaptive/config';
14746
+ export * from './adaptive/fingerprint';
14739
14747
  export * from './adaptive/types';
14740
14748
  export { createInMemoryKnownDeviceStore, createInMemoryLoginHistoryStore } from './adaptive/inMemoryStores';
14741
14749
  export { createNeonKnownDeviceStore, createNeonLoginHistoryStore, createPostgresKnownDeviceStore, createPostgresLoginHistoryStore, knownDevicesTable, loginHistoryTable } from './adaptive/postgresStores';
14742
14750
  export * from './fga/config';
14751
+ export * from './fga/schema';
14743
14752
  export * from './fga/types';
14744
14753
  export { createInMemoryWarrantStore, warrantKey } from './fga/inMemoryStores';
14745
14754
  export { createNeonWarrantStore, createPostgresWarrantStore, warrantsTable } from './fga/postgresStores';