@ropean/sso-client 0.0.2 → 0.0.4
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/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -3
- package/dist/config.js.map +1 -1
- package/dist/idp.d.ts +8 -1
- package/dist/idp.d.ts.map +1 -1
- package/dist/idp.js +10 -0
- package/dist/idp.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/jwks/verifier.d.ts +6 -2
- package/dist/jwks/verifier.d.ts.map +1 -1
- package/dist/jwks/verifier.js.map +1 -1
- package/dist/middleware/authenticate.d.ts +1 -0
- package/dist/middleware/authenticate.d.ts.map +1 -1
- package/dist/middleware/authenticate.js +8 -3
- package/dist/middleware/authenticate.js.map +1 -1
- package/dist/middleware/cookie.js.map +1 -1
- package/dist/routes/backchannel.js.map +1 -1
- package/dist/routes/callback.js.map +1 -1
- package/dist/routes/login.js.map +1 -1
- package/dist/routes/logout.js.map +1 -1
- package/dist/routes/me.js.map +1 -1
- package/dist/routes/refresh.js.map +1 -1
- package/dist/store/crypto.js.map +1 -1
- package/dist/store/interface.js.map +1 -1
- package/dist/store/kv.js.map +1 -1
- package/dist/store/memory.js.map +1 -1
- package/dist/store/sqlite.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -2
- package/src/config.ts +0 -93
- package/src/idp.ts +0 -83
- package/src/index.ts +0 -120
- package/src/jwks/verifier.ts +0 -69
- package/src/middleware/authenticate.ts +0 -197
- package/src/middleware/cookie.test.ts +0 -29
- package/src/middleware/cookie.ts +0 -87
- package/src/routes/backchannel.ts +0 -67
- package/src/routes/callback.ts +0 -99
- package/src/routes/login.ts +0 -72
- package/src/routes/logout.ts +0 -50
- package/src/routes/me.ts +0 -26
- package/src/routes/refresh.ts +0 -35
- package/src/store/crypto.test.ts +0 -23
- package/src/store/crypto.ts +0 -51
- package/src/store/interface.ts +0 -28
- package/src/store/kv.ts +0 -137
- package/src/store/memory.ts +0 -110
- package/src/store/sqlite.test.ts +0 -111
- package/src/store/sqlite.ts +0 -201
- package/src/types.ts +0 -80
- package/src/utils.ts +0 -30
package/src/types.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// Public types for @ropean/sso-client. Kept dependency-free so this file can be
|
|
2
|
-
// imported without pulling in hono/jose/sqlite.
|
|
3
|
-
|
|
4
|
-
export interface SsoConfig {
|
|
5
|
-
// IDP
|
|
6
|
-
issuer: string; // e.g. https://sso.ropean.org/oauth
|
|
7
|
-
clientId: string;
|
|
8
|
-
clientSecret: string;
|
|
9
|
-
redirectUri: string; // {clientUri}/auth/callback
|
|
10
|
-
scopes: string; // space-separated, default: "openid profile email offline_access"
|
|
11
|
-
audience?: string; // optional aud validation; defaults to clientId
|
|
12
|
-
|
|
13
|
-
// Logout
|
|
14
|
-
postLogoutRedirectUri?: string;
|
|
15
|
-
|
|
16
|
-
// Session / cookie
|
|
17
|
-
sessionSecret: string; // 32+ random bytes; used for HMAC + AES-256-GCM
|
|
18
|
-
cookieName: string; // default: "sso_sid"
|
|
19
|
-
cookieDomain?: string;
|
|
20
|
-
cookieSecure: boolean; // default: true (force HTTPS)
|
|
21
|
-
cookieSameSite: 'Lax' | 'Strict' | 'None';
|
|
22
|
-
cookieMaxAgeSec: number; // default: refresh-token lifetime (30 days)
|
|
23
|
-
|
|
24
|
-
// Storage
|
|
25
|
-
dbPath: string; // SQLite file path (default: "./sso.db")
|
|
26
|
-
|
|
27
|
-
// Behavior
|
|
28
|
-
refreshSkewMs: number; // renew when access_token < skew from exp (default 120_000)
|
|
29
|
-
isDebug: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface PkceRecord {
|
|
33
|
-
codeVerifier: string;
|
|
34
|
-
nonce: string;
|
|
35
|
-
returnTo: string;
|
|
36
|
-
expiresAt: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface SessionRecord {
|
|
40
|
-
sid: string;
|
|
41
|
-
sub: string;
|
|
42
|
-
accessToken: string;
|
|
43
|
-
refreshTokenEnc: Uint8Array; // AES-256-GCM ciphertext (with IV + tag prefix)
|
|
44
|
-
idToken: string | null;
|
|
45
|
-
accessExpiresAt: number; // ms epoch
|
|
46
|
-
refreshExpiresAt: number; // ms epoch
|
|
47
|
-
createdAt: number;
|
|
48
|
-
rotatedAt: number;
|
|
49
|
-
userAgent: string | null;
|
|
50
|
-
ip: string | null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface UserClaims {
|
|
54
|
-
sub: string;
|
|
55
|
-
iss?: string;
|
|
56
|
-
aud?: string | string[];
|
|
57
|
-
exp?: number;
|
|
58
|
-
iat?: number;
|
|
59
|
-
jti?: string;
|
|
60
|
-
client_id?: string;
|
|
61
|
-
scope?: string;
|
|
62
|
-
role?: string;
|
|
63
|
-
org_id?: string | null;
|
|
64
|
-
sid?: string;
|
|
65
|
-
// OIDC profile (when carried)
|
|
66
|
-
preferred_username?: string;
|
|
67
|
-
username?: string;
|
|
68
|
-
name?: string;
|
|
69
|
-
email?: string;
|
|
70
|
-
email_verified?: boolean;
|
|
71
|
-
picture?: string;
|
|
72
|
-
// Allow passthrough custom claims
|
|
73
|
-
[key: string]: unknown;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface AuthContext {
|
|
77
|
-
user: UserClaims;
|
|
78
|
-
source: 'cookie' | 'bearer';
|
|
79
|
-
session?: { sid: string; sub: string };
|
|
80
|
-
}
|
package/src/utils.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Cross-runtime base64url + random byte utilities (Web Crypto API only, no node:crypto)
|
|
2
|
-
|
|
3
|
-
export function bufToBase64url(buf: Uint8Array): string {
|
|
4
|
-
let binary = '';
|
|
5
|
-
for (let i = 0; i < buf.length; i++) binary += String.fromCharCode(buf[i] as number);
|
|
6
|
-
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function base64urlToBuf(str: string): Uint8Array {
|
|
10
|
-
const b64 = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
11
|
-
const pad = (4 - (b64.length % 4)) % 4;
|
|
12
|
-
const binary = atob(b64 + '='.repeat(pad));
|
|
13
|
-
return Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function bufToBase64(buf: Uint8Array): string {
|
|
17
|
-
let binary = '';
|
|
18
|
-
for (let i = 0; i < buf.length; i++) binary += String.fromCharCode(buf[i] as number);
|
|
19
|
-
return btoa(binary);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function base64ToBuf(str: string): Uint8Array {
|
|
23
|
-
const binary = atob(str);
|
|
24
|
-
return Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function randomHex(byteLen: number): string {
|
|
28
|
-
const bytes = crypto.getRandomValues(new Uint8Array(byteLen));
|
|
29
|
-
return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
30
|
-
}
|