@useauthio/react 0.2.0 → 0.2.2
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/CHANGELOG.md +32 -0
- package/dist/index.cjs +70 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +70 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/provider.tsx +78 -2
- package/src/sign-in.ts +14 -7
- package/src/types.ts +29 -0
- package/src/version.ts +1 -1
- package/vendor/authio-node/LICENSE +0 -21
- package/vendor/authio-node/README.md +0 -116
- package/vendor/authio-node/dist/index.cjs +0 -230
- package/vendor/authio-node/dist/index.d.cts +0 -150
- package/vendor/authio-node/dist/index.d.ts +0 -150
- package/vendor/authio-node/dist/index.js +0 -201
- package/vendor/authio-node/package.json +0 -31
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { JWTPayload } from 'jose';
|
|
2
|
-
|
|
3
|
-
interface AuthioClaims extends JWTPayload {
|
|
4
|
-
sub: string;
|
|
5
|
-
/** The active organization for this token. Empty string if the user has not yet selected an org. */
|
|
6
|
-
act_org?: string;
|
|
7
|
-
/** The active role within `act_org`. */
|
|
8
|
-
act_role?: string;
|
|
9
|
-
/** Session ID. */
|
|
10
|
-
sid?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Verifier wraps a remote JWKS fetcher with caching. Spawn one per
|
|
14
|
-
* `apiUrl` and reuse — fetching JWKS on every request is wasteful.
|
|
15
|
-
*/
|
|
16
|
-
declare class JwtVerifier {
|
|
17
|
-
private readonly apiUrl;
|
|
18
|
-
private readonly issuer;
|
|
19
|
-
private readonly audience;
|
|
20
|
-
private readonly jwks;
|
|
21
|
-
constructor(apiUrl: string, issuer: string, audience: string);
|
|
22
|
-
verify(token: string): Promise<AuthioClaims>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface User {
|
|
26
|
-
id: string;
|
|
27
|
-
projectId: string;
|
|
28
|
-
email: string;
|
|
29
|
-
emailVerified: boolean;
|
|
30
|
-
name?: string;
|
|
31
|
-
avatarUrl?: string;
|
|
32
|
-
defaultOrganizationId: string | null;
|
|
33
|
-
createdAt: string;
|
|
34
|
-
updatedAt: string;
|
|
35
|
-
}
|
|
36
|
-
interface Organization {
|
|
37
|
-
id: string;
|
|
38
|
-
projectId: string;
|
|
39
|
-
name: string;
|
|
40
|
-
slug: string;
|
|
41
|
-
createdAt: string;
|
|
42
|
-
}
|
|
43
|
-
type MembershipStatus = "invited" | "active" | "suspended" | "deactivated";
|
|
44
|
-
interface Membership {
|
|
45
|
-
id: string;
|
|
46
|
-
projectId: string;
|
|
47
|
-
userId: string;
|
|
48
|
-
organizationId: string;
|
|
49
|
-
role: string;
|
|
50
|
-
status: MembershipStatus;
|
|
51
|
-
joinedAt: string;
|
|
52
|
-
invitedBy: string | null;
|
|
53
|
-
lastActiveAt: string | null;
|
|
54
|
-
preferredLoginMethod: "passkey" | "magic_link" | "oauth" | "sso" | null;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A verified Authio session.
|
|
58
|
-
*
|
|
59
|
-
* The session always identifies the *user* (`userId`); the active
|
|
60
|
-
* organization (`orgId`) is only set after the user has selected one of
|
|
61
|
-
* their memberships. A user with multiple memberships may move between
|
|
62
|
-
* orgs in-session without re-authenticating.
|
|
63
|
-
*/
|
|
64
|
-
interface Session {
|
|
65
|
-
sessionId: string;
|
|
66
|
-
userId: string;
|
|
67
|
-
orgId: string | null;
|
|
68
|
-
role: string | null;
|
|
69
|
-
expiresAt: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface AuthioOptions {
|
|
73
|
-
apiKey: string;
|
|
74
|
-
apiUrl?: string;
|
|
75
|
-
/** JWT issuer to require. Defaults to the production issuer. */
|
|
76
|
-
jwtIssuer?: string;
|
|
77
|
-
/** JWT audience to require. */
|
|
78
|
-
jwtAudience?: string;
|
|
79
|
-
fetch?: typeof fetch;
|
|
80
|
-
}
|
|
81
|
-
declare class Authio {
|
|
82
|
-
readonly options: AuthioOptions;
|
|
83
|
-
readonly users: UsersAPI;
|
|
84
|
-
readonly organizations: OrganizationsAPI;
|
|
85
|
-
readonly memberships: MembershipsAPI;
|
|
86
|
-
readonly sessions: SessionsAPI;
|
|
87
|
-
private readonly verifier;
|
|
88
|
-
constructor(options: AuthioOptions);
|
|
89
|
-
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
90
|
-
}
|
|
91
|
-
declare class UsersAPI {
|
|
92
|
-
private readonly client;
|
|
93
|
-
constructor(client: Authio);
|
|
94
|
-
get(userId: string): Promise<User>;
|
|
95
|
-
listMemberships(userId: string): Promise<Membership[]>;
|
|
96
|
-
}
|
|
97
|
-
declare class OrganizationsAPI {
|
|
98
|
-
private readonly client;
|
|
99
|
-
constructor(client: Authio);
|
|
100
|
-
list(): Promise<Organization[]>;
|
|
101
|
-
create(input: {
|
|
102
|
-
name: string;
|
|
103
|
-
slug?: string;
|
|
104
|
-
domain?: string;
|
|
105
|
-
}): Promise<Organization>;
|
|
106
|
-
get(orgId: string): Promise<Organization>;
|
|
107
|
-
}
|
|
108
|
-
declare class MembershipsAPI {
|
|
109
|
-
private readonly client;
|
|
110
|
-
constructor(client: Authio);
|
|
111
|
-
listForOrganization(orgId: string): Promise<Membership[]>;
|
|
112
|
-
add(orgId: string, input: {
|
|
113
|
-
userId: string;
|
|
114
|
-
role: string;
|
|
115
|
-
}): Promise<Membership>;
|
|
116
|
-
remove(orgId: string, membershipId: string): Promise<void>;
|
|
117
|
-
}
|
|
118
|
-
declare class SessionsAPI {
|
|
119
|
-
private readonly client;
|
|
120
|
-
private readonly verifier;
|
|
121
|
-
constructor(client: Authio, verifier: JwtVerifier);
|
|
122
|
-
/**
|
|
123
|
-
* Verify an Authio access token (JWT). Returns the typed Session, or
|
|
124
|
-
* null when the token is invalid/expired.
|
|
125
|
-
*
|
|
126
|
-
* `session.userId` is always set; `session.orgId` may be null when the
|
|
127
|
-
* user has authenticated but not yet selected an organization (multi-org
|
|
128
|
-
* users coming straight out of /v1/auth/passkey/login/verify).
|
|
129
|
-
*/
|
|
130
|
-
verify(accessToken: string): Promise<Session | null>;
|
|
131
|
-
/** Pivot a session into a different organization without re-authentication. */
|
|
132
|
-
switchOrg(_sessionId: string, input: {
|
|
133
|
-
organizationId: string;
|
|
134
|
-
}): Promise<Session>;
|
|
135
|
-
revoke(sessionId: string): Promise<void>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
declare class AuthioError extends Error {
|
|
139
|
-
readonly code: string;
|
|
140
|
-
readonly status: number;
|
|
141
|
-
readonly requestId?: string;
|
|
142
|
-
constructor(opts: {
|
|
143
|
-
code: string;
|
|
144
|
-
message: string;
|
|
145
|
-
status: number;
|
|
146
|
-
requestId?: string;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export { Authio, type AuthioClaims, AuthioError, type AuthioOptions, JwtVerifier, type Membership, type Organization, type Session, type User };
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { JWTPayload } from 'jose';
|
|
2
|
-
|
|
3
|
-
interface AuthioClaims extends JWTPayload {
|
|
4
|
-
sub: string;
|
|
5
|
-
/** The active organization for this token. Empty string if the user has not yet selected an org. */
|
|
6
|
-
act_org?: string;
|
|
7
|
-
/** The active role within `act_org`. */
|
|
8
|
-
act_role?: string;
|
|
9
|
-
/** Session ID. */
|
|
10
|
-
sid?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Verifier wraps a remote JWKS fetcher with caching. Spawn one per
|
|
14
|
-
* `apiUrl` and reuse — fetching JWKS on every request is wasteful.
|
|
15
|
-
*/
|
|
16
|
-
declare class JwtVerifier {
|
|
17
|
-
private readonly apiUrl;
|
|
18
|
-
private readonly issuer;
|
|
19
|
-
private readonly audience;
|
|
20
|
-
private readonly jwks;
|
|
21
|
-
constructor(apiUrl: string, issuer: string, audience: string);
|
|
22
|
-
verify(token: string): Promise<AuthioClaims>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface User {
|
|
26
|
-
id: string;
|
|
27
|
-
projectId: string;
|
|
28
|
-
email: string;
|
|
29
|
-
emailVerified: boolean;
|
|
30
|
-
name?: string;
|
|
31
|
-
avatarUrl?: string;
|
|
32
|
-
defaultOrganizationId: string | null;
|
|
33
|
-
createdAt: string;
|
|
34
|
-
updatedAt: string;
|
|
35
|
-
}
|
|
36
|
-
interface Organization {
|
|
37
|
-
id: string;
|
|
38
|
-
projectId: string;
|
|
39
|
-
name: string;
|
|
40
|
-
slug: string;
|
|
41
|
-
createdAt: string;
|
|
42
|
-
}
|
|
43
|
-
type MembershipStatus = "invited" | "active" | "suspended" | "deactivated";
|
|
44
|
-
interface Membership {
|
|
45
|
-
id: string;
|
|
46
|
-
projectId: string;
|
|
47
|
-
userId: string;
|
|
48
|
-
organizationId: string;
|
|
49
|
-
role: string;
|
|
50
|
-
status: MembershipStatus;
|
|
51
|
-
joinedAt: string;
|
|
52
|
-
invitedBy: string | null;
|
|
53
|
-
lastActiveAt: string | null;
|
|
54
|
-
preferredLoginMethod: "passkey" | "magic_link" | "oauth" | "sso" | null;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A verified Authio session.
|
|
58
|
-
*
|
|
59
|
-
* The session always identifies the *user* (`userId`); the active
|
|
60
|
-
* organization (`orgId`) is only set after the user has selected one of
|
|
61
|
-
* their memberships. A user with multiple memberships may move between
|
|
62
|
-
* orgs in-session without re-authenticating.
|
|
63
|
-
*/
|
|
64
|
-
interface Session {
|
|
65
|
-
sessionId: string;
|
|
66
|
-
userId: string;
|
|
67
|
-
orgId: string | null;
|
|
68
|
-
role: string | null;
|
|
69
|
-
expiresAt: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface AuthioOptions {
|
|
73
|
-
apiKey: string;
|
|
74
|
-
apiUrl?: string;
|
|
75
|
-
/** JWT issuer to require. Defaults to the production issuer. */
|
|
76
|
-
jwtIssuer?: string;
|
|
77
|
-
/** JWT audience to require. */
|
|
78
|
-
jwtAudience?: string;
|
|
79
|
-
fetch?: typeof fetch;
|
|
80
|
-
}
|
|
81
|
-
declare class Authio {
|
|
82
|
-
readonly options: AuthioOptions;
|
|
83
|
-
readonly users: UsersAPI;
|
|
84
|
-
readonly organizations: OrganizationsAPI;
|
|
85
|
-
readonly memberships: MembershipsAPI;
|
|
86
|
-
readonly sessions: SessionsAPI;
|
|
87
|
-
private readonly verifier;
|
|
88
|
-
constructor(options: AuthioOptions);
|
|
89
|
-
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
90
|
-
}
|
|
91
|
-
declare class UsersAPI {
|
|
92
|
-
private readonly client;
|
|
93
|
-
constructor(client: Authio);
|
|
94
|
-
get(userId: string): Promise<User>;
|
|
95
|
-
listMemberships(userId: string): Promise<Membership[]>;
|
|
96
|
-
}
|
|
97
|
-
declare class OrganizationsAPI {
|
|
98
|
-
private readonly client;
|
|
99
|
-
constructor(client: Authio);
|
|
100
|
-
list(): Promise<Organization[]>;
|
|
101
|
-
create(input: {
|
|
102
|
-
name: string;
|
|
103
|
-
slug?: string;
|
|
104
|
-
domain?: string;
|
|
105
|
-
}): Promise<Organization>;
|
|
106
|
-
get(orgId: string): Promise<Organization>;
|
|
107
|
-
}
|
|
108
|
-
declare class MembershipsAPI {
|
|
109
|
-
private readonly client;
|
|
110
|
-
constructor(client: Authio);
|
|
111
|
-
listForOrganization(orgId: string): Promise<Membership[]>;
|
|
112
|
-
add(orgId: string, input: {
|
|
113
|
-
userId: string;
|
|
114
|
-
role: string;
|
|
115
|
-
}): Promise<Membership>;
|
|
116
|
-
remove(orgId: string, membershipId: string): Promise<void>;
|
|
117
|
-
}
|
|
118
|
-
declare class SessionsAPI {
|
|
119
|
-
private readonly client;
|
|
120
|
-
private readonly verifier;
|
|
121
|
-
constructor(client: Authio, verifier: JwtVerifier);
|
|
122
|
-
/**
|
|
123
|
-
* Verify an Authio access token (JWT). Returns the typed Session, or
|
|
124
|
-
* null when the token is invalid/expired.
|
|
125
|
-
*
|
|
126
|
-
* `session.userId` is always set; `session.orgId` may be null when the
|
|
127
|
-
* user has authenticated but not yet selected an organization (multi-org
|
|
128
|
-
* users coming straight out of /v1/auth/passkey/login/verify).
|
|
129
|
-
*/
|
|
130
|
-
verify(accessToken: string): Promise<Session | null>;
|
|
131
|
-
/** Pivot a session into a different organization without re-authentication. */
|
|
132
|
-
switchOrg(_sessionId: string, input: {
|
|
133
|
-
organizationId: string;
|
|
134
|
-
}): Promise<Session>;
|
|
135
|
-
revoke(sessionId: string): Promise<void>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
declare class AuthioError extends Error {
|
|
139
|
-
readonly code: string;
|
|
140
|
-
readonly status: number;
|
|
141
|
-
readonly requestId?: string;
|
|
142
|
-
constructor(opts: {
|
|
143
|
-
code: string;
|
|
144
|
-
message: string;
|
|
145
|
-
status: number;
|
|
146
|
-
requestId?: string;
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export { Authio, type AuthioClaims, AuthioError, type AuthioOptions, JwtVerifier, type Membership, type Organization, type Session, type User };
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
// src/errors.ts
|
|
2
|
-
var AuthioError = class extends Error {
|
|
3
|
-
code;
|
|
4
|
-
status;
|
|
5
|
-
requestId;
|
|
6
|
-
constructor(opts) {
|
|
7
|
-
super(opts.message);
|
|
8
|
-
this.name = "AuthioError";
|
|
9
|
-
this.code = opts.code;
|
|
10
|
-
this.status = opts.status;
|
|
11
|
-
this.requestId = opts.requestId;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/jwks.ts
|
|
16
|
-
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
17
|
-
var JwtVerifier = class {
|
|
18
|
-
constructor(apiUrl, issuer, audience) {
|
|
19
|
-
this.apiUrl = apiUrl;
|
|
20
|
-
this.issuer = issuer;
|
|
21
|
-
this.audience = audience;
|
|
22
|
-
this.jwks = createRemoteJWKSet(
|
|
23
|
-
new URL(this.apiUrl.replace(/\/$/, "") + "/v1/auth/.well-known/jwks.json"),
|
|
24
|
-
{
|
|
25
|
-
cooldownDuration: 3e4,
|
|
26
|
-
cacheMaxAge: 6e5
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
apiUrl;
|
|
31
|
-
issuer;
|
|
32
|
-
audience;
|
|
33
|
-
jwks;
|
|
34
|
-
async verify(token) {
|
|
35
|
-
const { payload } = await jwtVerify(token, this.jwks, {
|
|
36
|
-
issuer: this.issuer,
|
|
37
|
-
audience: this.audience,
|
|
38
|
-
algorithms: ["EdDSA"]
|
|
39
|
-
});
|
|
40
|
-
if (!payload.sub) {
|
|
41
|
-
throw new Error("authio: token missing sub claim");
|
|
42
|
-
}
|
|
43
|
-
return payload;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// src/client.ts
|
|
48
|
-
var DEFAULT_API_URL = "https://api.authio.com";
|
|
49
|
-
var DEFAULT_ISSUER = "https://api.authio.com";
|
|
50
|
-
var DEFAULT_AUDIENCE = "authio";
|
|
51
|
-
var Authio = class {
|
|
52
|
-
constructor(options) {
|
|
53
|
-
this.options = options;
|
|
54
|
-
if (!options.apiKey) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
"Authio: apiKey is required. Pass it directly or set AUTHIO_SECRET_KEY."
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
const apiUrl = options.apiUrl ?? DEFAULT_API_URL;
|
|
60
|
-
this.verifier = new JwtVerifier(
|
|
61
|
-
apiUrl,
|
|
62
|
-
options.jwtIssuer ?? DEFAULT_ISSUER,
|
|
63
|
-
options.jwtAudience ?? DEFAULT_AUDIENCE
|
|
64
|
-
);
|
|
65
|
-
this.sessions = new SessionsAPI(this, this.verifier);
|
|
66
|
-
}
|
|
67
|
-
options;
|
|
68
|
-
users = new UsersAPI(this);
|
|
69
|
-
organizations = new OrganizationsAPI(this);
|
|
70
|
-
memberships = new MembershipsAPI(this);
|
|
71
|
-
sessions;
|
|
72
|
-
verifier;
|
|
73
|
-
async request(method, path, body) {
|
|
74
|
-
const url = (this.options.apiUrl ?? DEFAULT_API_URL) + path;
|
|
75
|
-
const fetchFn = this.options.fetch ?? globalThis.fetch;
|
|
76
|
-
const res = await fetchFn(url, {
|
|
77
|
-
method,
|
|
78
|
-
headers: {
|
|
79
|
-
"content-type": "application/json",
|
|
80
|
-
"user-agent": "authio-node/0.1.0",
|
|
81
|
-
authorization: `Bearer ${this.options.apiKey}`
|
|
82
|
-
},
|
|
83
|
-
body: body ? JSON.stringify(body) : void 0
|
|
84
|
-
});
|
|
85
|
-
if (!res.ok) {
|
|
86
|
-
const data = await res.json().catch(() => ({}));
|
|
87
|
-
throw new AuthioError({
|
|
88
|
-
code: data.code ?? "request_failed",
|
|
89
|
-
message: data.message ?? `Request failed with status ${res.status}`,
|
|
90
|
-
status: res.status,
|
|
91
|
-
requestId: data.request_id
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
if (res.status === 204) return void 0;
|
|
95
|
-
return await res.json();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var UsersAPI = class {
|
|
99
|
-
constructor(client) {
|
|
100
|
-
this.client = client;
|
|
101
|
-
}
|
|
102
|
-
client;
|
|
103
|
-
get(userId) {
|
|
104
|
-
return this.client.request("GET", `/v1/users/${userId}`);
|
|
105
|
-
}
|
|
106
|
-
listMemberships(userId) {
|
|
107
|
-
return this.client.request(
|
|
108
|
-
"GET",
|
|
109
|
-
`/v1/users/${userId}/memberships`
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var OrganizationsAPI = class {
|
|
114
|
-
constructor(client) {
|
|
115
|
-
this.client = client;
|
|
116
|
-
}
|
|
117
|
-
client;
|
|
118
|
-
list() {
|
|
119
|
-
return this.client.request("GET", "/v1/organizations");
|
|
120
|
-
}
|
|
121
|
-
create(input) {
|
|
122
|
-
return this.client.request("POST", "/v1/organizations", input);
|
|
123
|
-
}
|
|
124
|
-
get(orgId) {
|
|
125
|
-
return this.client.request("GET", `/v1/organizations/${orgId}`);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
var MembershipsAPI = class {
|
|
129
|
-
constructor(client) {
|
|
130
|
-
this.client = client;
|
|
131
|
-
}
|
|
132
|
-
client;
|
|
133
|
-
listForOrganization(orgId) {
|
|
134
|
-
return this.client.request(
|
|
135
|
-
"GET",
|
|
136
|
-
`/v1/organizations/${orgId}/memberships`
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
add(orgId, input) {
|
|
140
|
-
return this.client.request(
|
|
141
|
-
"POST",
|
|
142
|
-
`/v1/organizations/${orgId}/memberships`,
|
|
143
|
-
{ user_id: input.userId, role: input.role }
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
remove(orgId, membershipId) {
|
|
147
|
-
return this.client.request(
|
|
148
|
-
"DELETE",
|
|
149
|
-
`/v1/organizations/${orgId}/memberships/${membershipId}`
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
var SessionsAPI = class {
|
|
154
|
-
constructor(client, verifier) {
|
|
155
|
-
this.client = client;
|
|
156
|
-
this.verifier = verifier;
|
|
157
|
-
}
|
|
158
|
-
client;
|
|
159
|
-
verifier;
|
|
160
|
-
/**
|
|
161
|
-
* Verify an Authio access token (JWT). Returns the typed Session, or
|
|
162
|
-
* null when the token is invalid/expired.
|
|
163
|
-
*
|
|
164
|
-
* `session.userId` is always set; `session.orgId` may be null when the
|
|
165
|
-
* user has authenticated but not yet selected an organization (multi-org
|
|
166
|
-
* users coming straight out of /v1/auth/passkey/login/verify).
|
|
167
|
-
*/
|
|
168
|
-
async verify(accessToken) {
|
|
169
|
-
if (!accessToken) return null;
|
|
170
|
-
try {
|
|
171
|
-
const claims = await this.verifier.verify(accessToken);
|
|
172
|
-
return {
|
|
173
|
-
sessionId: claims.sid ?? "",
|
|
174
|
-
userId: claims.sub,
|
|
175
|
-
orgId: claims.act_org ? claims.act_org : null,
|
|
176
|
-
role: claims.act_role ? claims.act_role : null,
|
|
177
|
-
expiresAt: claims.exp ? new Date(claims.exp * 1e3).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
178
|
-
};
|
|
179
|
-
} catch {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
/** Pivot a session into a different organization without re-authentication. */
|
|
184
|
-
switchOrg(_sessionId, input) {
|
|
185
|
-
return this.client.request(
|
|
186
|
-
"POST",
|
|
187
|
-
"/v1/sessions/switch-org",
|
|
188
|
-
{ organization_id: input.organizationId }
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
revoke(sessionId) {
|
|
192
|
-
return this.client.request("POST", "/v1/sessions/revoke", {
|
|
193
|
-
session_id: sessionId
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
export {
|
|
198
|
-
Authio,
|
|
199
|
-
AuthioError,
|
|
200
|
-
JwtVerifier
|
|
201
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@useauthio/node",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Authio server-side SDK for Node.js, Bun, Deno, and edge runtimes. Vendored from authio-com/authio_node so @useauthio/react can resolve it locally before the npm scope is claimed.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/authio-com/authio_node.git"
|
|
9
|
-
},
|
|
10
|
-
"type": "module",
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"types": "./dist/index.d.ts",
|
|
16
|
-
"import": "./dist/index.js",
|
|
17
|
-
"require": "./dist/index.cjs"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"README.md",
|
|
23
|
-
"LICENSE"
|
|
24
|
-
],
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"jose": "^5.9.0"
|
|
27
|
-
},
|
|
28
|
-
"engines": {
|
|
29
|
-
"node": ">=20"
|
|
30
|
-
}
|
|
31
|
-
}
|