@authowl/core 0.14.0 → 0.15.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/chunk-4VJL4WGF.js +1 -0
- package/dist/chunk-RRP2XNYV.js +2 -0
- package/dist/{client-jpaYv3wu.d.ts → client--0Q9VjLt.d.cts} +10 -1
- package/dist/{client-DOOkDLWg.d.cts → client-DwK6spWA.d.ts} +10 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -2
- package/dist/native.cjs +2 -2
- package/dist/native.d.cts +4 -4
- package/dist/native.d.ts +4 -4
- package/dist/native.js +1 -1
- package/dist/organization-membership--eTrgk_L.d.cts +442 -0
- package/dist/organization-membership--eTrgk_L.d.ts +442 -0
- package/dist/server.cjs +2 -2
- package/dist/server.d.cts +2 -3
- package/dist/server.d.ts +2 -3
- package/dist/server.js +1 -1
- package/dist/session-handoff-VJI4IXLT.js +2 -0
- package/package.json +1 -1
- package/dist/chunk-KPXCQZUX.js +0 -2
- package/dist/chunk-MX7KKUAW.js +0 -1
- package/dist/organization-membership-B3m6PbmO.d.cts +0 -117
- package/dist/organization-membership-B3m6PbmO.d.ts +0 -117
- package/dist/session-handoff-6B5KZXQV.js +0 -2
- package/dist/transport-DcWDTRd4.d.cts +0 -15
- package/dist/transport-DcWDTRd4.d.ts +0 -15
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
type DecodedPublishableKey = {
|
|
2
|
-
prefix: 'pk_live' | 'pk_test';
|
|
3
|
-
env: 'live' | 'test';
|
|
4
|
-
projectId: string;
|
|
5
|
-
};
|
|
6
|
-
declare function decodePublishableKey(key: string): DecodedPublishableKey;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The exact session-cookie name the auth server sets for a given project.
|
|
10
|
-
*
|
|
11
|
-
* Single source of truth for the cookie name across the SDK. The server
|
|
12
|
-
* (the AuthOwl server project factory) configures
|
|
13
|
-
* `advanced.cookiePrefix = "p_" + <projectId without dashes>` and
|
|
14
|
-
* `useSecureCookies` in production; the auth engine then names the session
|
|
15
|
-
* cookie `${securePrefix}${cookiePrefix}.session_token`, where `securePrefix`
|
|
16
|
-
* is `__Secure-` for secure cookies and empty otherwise:
|
|
17
|
-
*
|
|
18
|
-
* dev (http): p_<idNoDashes>.session_token
|
|
19
|
-
* prod (https): __Secure-p_<idNoDashes>.session_token
|
|
20
|
-
*
|
|
21
|
-
* Verified 2026-07-06 against the auth engine's `getCookies()` with the server's
|
|
22
|
-
* real config (see CONTRACTS section 5 and `cookie.test.ts`). Note the engine
|
|
23
|
-
* joins the prefix and name with a dot (`.`), not an underscore, and uses the
|
|
24
|
-
* `__Secure-` (not `__Host-`) prefix - both are easy to get wrong by hand, and
|
|
25
|
-
* getting them wrong makes `auth()` forward a cookie the server never set. If an
|
|
26
|
-
* auth-engine upgrade changes cookie naming, re-verify and update this function,
|
|
27
|
-
* the `cookie.test.ts` fixtures, and CONTRACTS section 5 together.
|
|
28
|
-
*
|
|
29
|
-
* `secure` must reflect the SERVER's cookie mode: callers holding the auth API
|
|
30
|
-
* URL derive it from the protocol (`https:` => secure). Callers that cannot
|
|
31
|
-
* know it (the UX-only redirect middleware) should check both variants.
|
|
32
|
-
*/
|
|
33
|
-
declare function sessionCookieName(projectId: string, opts?: {
|
|
34
|
-
secure?: boolean;
|
|
35
|
-
}): string;
|
|
36
|
-
|
|
37
|
-
type AuthConfig = {
|
|
38
|
-
publishableKey: string;
|
|
39
|
-
apiUrl: string;
|
|
40
|
-
/** Optional fetch override (e.g. for testing). */
|
|
41
|
-
fetch?: typeof fetch;
|
|
42
|
-
};
|
|
43
|
-
type ResolvedAuthConfig = AuthConfig & {
|
|
44
|
-
decoded: DecodedPublishableKey;
|
|
45
|
-
/** Fully-resolved base URL pointing at the per-project auth endpoint. */
|
|
46
|
-
projectBaseURL: string;
|
|
47
|
-
};
|
|
48
|
-
declare function resolveConfig(input: AuthConfig): ResolvedAuthConfig;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Pure, dependency-free evaluators for an organization membership's advisory
|
|
52
|
-
* permission claim. Shared by the CLIENT `has()` (organization-client.ts, over
|
|
53
|
-
* the browser session) and the SERVER `has()` (server.ts, over a verified JWT),
|
|
54
|
-
* so the two paths can never disagree on what a membership grants.
|
|
55
|
-
*
|
|
56
|
-
* The membership carries the SAME `permissions` array AuthOwl emits into the
|
|
57
|
-
* session and the JWT claim (plan §4/§5): the relabelled `org:sys_*` system ids
|
|
58
|
-
* (plus their legacy bare forms during the dual-emit window) AND the operator's
|
|
59
|
-
* custom `org:<feature>:<action>` ids. Evaluation is a pure array/string check
|
|
60
|
-
* over that local claim - it NEVER calls a statement-only `/organization/has-
|
|
61
|
-
* permission` route, which only knows the 14 static statements and would wrongly
|
|
62
|
-
* report `false` for any custom permission.
|
|
63
|
-
*/
|
|
64
|
-
/** The active-membership shape carried on the session / decoded from a token. */
|
|
65
|
-
interface OrganizationMembership {
|
|
66
|
-
/** The member's canonical role key (built-in `owner`/`admin`/`member` or a project role). */
|
|
67
|
-
role: string;
|
|
68
|
-
/**
|
|
69
|
-
* The member's effective permission ids: `org:sys_*` system claims (with
|
|
70
|
-
* their legacy bare forms during dual-emit) plus custom `org:<feature>:<action>`
|
|
71
|
-
* ids. Advisory only - the real boundary is server-side over the verified token.
|
|
72
|
-
*/
|
|
73
|
-
permissions: string[];
|
|
74
|
-
/**
|
|
75
|
-
* Team ids the member holds inside the ACTIVE organization, as emitted by
|
|
76
|
-
* AuthOwl into both the session and the JWT claim. Teams are pure grouping:
|
|
77
|
-
* belonging to one grants nothing on its own, so this is for the application's
|
|
78
|
-
* own gating, never an authority check.
|
|
79
|
-
*
|
|
80
|
-
* Optional because a token minted before teams shipped carries no `teams` claim.
|
|
81
|
-
* `has({ teamId })` then returns false rather than guessing - it can only ever
|
|
82
|
-
* confirm a team the claim actually proves.
|
|
83
|
-
*/
|
|
84
|
-
teams?: string[];
|
|
85
|
-
}
|
|
86
|
-
/** Clerk-style `has()` query: match the role, the permission, the team, or a combination (AND). */
|
|
87
|
-
interface HasParams {
|
|
88
|
-
role?: string;
|
|
89
|
-
permission?: string;
|
|
90
|
-
/** Require membership of this team within the active organization. */
|
|
91
|
-
teamId?: string;
|
|
92
|
-
}
|
|
93
|
-
/** True when the membership's permission claim includes `permission`. Pure. */
|
|
94
|
-
declare function membershipHasPermission(membership: OrganizationMembership | null | undefined, permission: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* True when the membership's team claim includes `teamId`. Pure.
|
|
97
|
-
*
|
|
98
|
-
* False when the claim carries no `teams` at all, which is what a token minted
|
|
99
|
-
* before teams shipped looks like - an absent claim is never read as "any team".
|
|
100
|
-
*/
|
|
101
|
-
declare function membershipHasTeam(membership: OrganizationMembership | null | undefined, teamId: string): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Clerk-style `has()`: true when the membership satisfies EVERY provided
|
|
104
|
-
* criterion - the role matches AND the permission is included AND the team is
|
|
105
|
-
* held. Returns false when there is no membership, or when no criterion at all is
|
|
106
|
-
* given. Pure: no I/O, evaluated entirely against the local claim.
|
|
107
|
-
*/
|
|
108
|
-
declare function membershipHas(membership: OrganizationMembership | null | undefined, params: HasParams): boolean;
|
|
109
|
-
/** Bind the pure evaluators to one membership (drives the client / hook `has`). */
|
|
110
|
-
declare function createMembershipHas(membership: OrganizationMembership | null | undefined): {
|
|
111
|
-
has: (params: HasParams) => boolean;
|
|
112
|
-
hasPermission: (params: {
|
|
113
|
-
permission: string;
|
|
114
|
-
}) => boolean;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export { type AuthConfig as A, type DecodedPublishableKey as D, type HasParams as H, type OrganizationMembership as O, type ResolvedAuthConfig as R, membershipHasPermission as a, membershipHasTeam as b, createMembershipHas as c, decodePublishableKey as d, membershipHas as m, resolveConfig as r, sessionCookieName as s };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-T5SH3ZZP.js';var u="authowl_handoff_verifier",a="authowl_code",g=32,S=900,m=["email","providerId","domain","organizationSlug"];function f(n){let e="";for(let i of n)e+=String.fromCharCode(i);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function w(n){let e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n));return f(new Uint8Array(e))}function h(){return f(crypto.getRandomValues(new Uint8Array(g)))}function p(n,e){let i=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${u}=${n}; Path=/; Max-Age=${e}; SameSite=Lax${i}`;}function R(){for(let n of document.cookie.split(";")){let e=n.indexOf("=");if(!(e<0)&&n.slice(0,e).trim()===u)return n.slice(e+1).trim()||null}return null}function y(){p("",0);}function l(n){return new URL(n,window.location.href).toString()}async function b(n,e){let i=e.callbackURL?l(e.callbackURL):null;if(i&&new URL(i).origin!==window.location.origin)return null;let t=h(),o=new URL(`${n.projectBaseURL}/session/start`);if(o.searchParams.set("pk",n.publishableKey),o.searchParams.set("kind",e.kind),e.kind==="social")o.searchParams.set("provider",e.provider),e.scopes?.length&&o.searchParams.set("scopes",e.scopes.join(",")),e.loginHint&&o.searchParams.set("loginHint",e.loginHint),e.requestSignUp!==void 0&&o.searchParams.set("requestSignUp",e.requestSignUp?"1":"0");else for(let s of m){let r=e[s];r&&o.searchParams.set(s,r);}let d=`${window.location.origin}${window.location.pathname}${window.location.search}`;o.searchParams.set("cb",i??d);for(let[s,r]of [["err",e.errorCallbackURL],["new",e.newUserCallbackURL]])r&&o.searchParams.set(s,l(r));return o.searchParams.set("challenge",await w(t)),p(t,S),o.toString()}function U(){if(typeof window>"u")return null;let n=window.location.hash;if(!n.includes(a))return null;let e=new URLSearchParams(n.replace(/^#/,"")),i=e.get(a);if(!i)return null;e.delete(a);let t=e.toString();return window.history.replaceState(window.history.state,"",`${window.location.pathname}${window.location.search}${t?`#${t}`:""}`),i}async function k(n){if(!a$1())return false;let e=U();if(!e)return false;let i=R();if(y(),!i)return false;let{error:t}=await n.request("/session/exchange",{method:"POST",body:{code:e,verifier:i}});return t===null}
|
|
2
|
-
export{b as beginCrossSiteSignIn,w as challengeFor,k as completeCrossSiteSignIn,U as takeHandoffCode};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type TransportErrorKind = 'aborted' | 'timeout' | 'network' | 'response_too_large' | 'invalid_response';
|
|
2
|
-
/**
|
|
3
|
-
* Stable, secret-safe failure from the shared HTTP boundary.
|
|
4
|
-
*
|
|
5
|
-
* Deliberately does not retain the request URL, headers, body, or underlying
|
|
6
|
-
* error. Server clients may carry secret authorization headers and hostile
|
|
7
|
-
* fetch implementations may echo those values in their error messages.
|
|
8
|
-
*/
|
|
9
|
-
declare class TransportError extends Error {
|
|
10
|
-
readonly kind: TransportErrorKind;
|
|
11
|
-
readonly requestId?: string;
|
|
12
|
-
constructor(kind: TransportErrorKind, requestId?: string);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { TransportError as T, type TransportErrorKind as a };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type TransportErrorKind = 'aborted' | 'timeout' | 'network' | 'response_too_large' | 'invalid_response';
|
|
2
|
-
/**
|
|
3
|
-
* Stable, secret-safe failure from the shared HTTP boundary.
|
|
4
|
-
*
|
|
5
|
-
* Deliberately does not retain the request URL, headers, body, or underlying
|
|
6
|
-
* error. Server clients may carry secret authorization headers and hostile
|
|
7
|
-
* fetch implementations may echo those values in their error messages.
|
|
8
|
-
*/
|
|
9
|
-
declare class TransportError extends Error {
|
|
10
|
-
readonly kind: TransportErrorKind;
|
|
11
|
-
readonly requestId?: string;
|
|
12
|
-
constructor(kind: TransportErrorKind, requestId?: string);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { TransportError as T, type TransportErrorKind as a };
|