@stackwright-pro/auth 0.2.0-alpha.1 → 0.2.0-alpha.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/dist/index.d.mts +52 -366
- package/dist/index.d.ts +52 -366
- package/dist/index.js +30 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,86 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export { authConfigSchema, authSessionSchema, authUserSchema, componentAuthSchema, oidcConfigSchema, pkiConfigSchema, rbacConfigSchema } from '@stackwright-pro/types';
|
|
2
2
|
import { X509Certificate } from '@peculiar/x509';
|
|
3
3
|
import * as crypto3 from 'crypto';
|
|
4
4
|
import * as jose3 from 'jose';
|
|
5
5
|
import { createContext, useContext, useMemo } from 'react';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
|
-
// src/schemas/
|
|
9
|
-
var pkiConfigSchema = z.object({
|
|
10
|
-
type: z.literal("pki"),
|
|
11
|
-
profile: z.enum(["dod_cac", "piv", "custom"]),
|
|
12
|
-
source: z.enum(["gateway_headers", "direct_tls"]),
|
|
13
|
-
headerPrefix: z.string().optional().default("x-client-cert-"),
|
|
14
|
-
verifiedHeader: z.string().optional().default("x-client-cert-verified"),
|
|
15
|
-
requiredValue: z.string().optional().default("SUCCESS"),
|
|
16
|
-
caChain: z.string().optional(),
|
|
17
|
-
requiredOU: z.array(z.string()).optional(),
|
|
18
|
-
allowedIssuers: z.array(z.string()).optional(),
|
|
19
|
-
headerSigning: z.object({
|
|
20
|
-
secret: z.string().min(32, "Header signing secret must be at least 32 characters"),
|
|
21
|
-
signatureHeader: z.string().optional(),
|
|
22
|
-
timestampHeader: z.string().optional(),
|
|
23
|
-
maxAge: z.number().min(5).max(300).optional(),
|
|
24
|
-
headerPrefix: z.string().optional()
|
|
25
|
-
}).optional().describe("HMAC signing config for verifying gateway-provided cert headers")
|
|
26
|
-
});
|
|
27
|
-
var oidcConfigSchema = z.object({
|
|
28
|
-
type: z.literal("oidc"),
|
|
29
|
-
provider: z.enum(["cognito", "azure_ad", "authentik", "keycloak", "okta", "auth0", "custom"]),
|
|
30
|
-
discoveryUrl: z.string().url(),
|
|
31
|
-
clientId: z.string(),
|
|
32
|
-
clientSecret: z.string(),
|
|
33
|
-
redirectUri: z.string().optional(),
|
|
34
|
-
claimsMapping: z.object({
|
|
35
|
-
user_id: z.string().optional(),
|
|
36
|
-
email: z.string().optional(),
|
|
37
|
-
name: z.string().optional(),
|
|
38
|
-
roles: z.string().optional()
|
|
39
|
-
}).optional(),
|
|
40
|
-
quirks: z.object({
|
|
41
|
-
skipIssuerCheck: z.boolean().optional(),
|
|
42
|
-
useRefreshTokenRotation: z.boolean().optional()
|
|
43
|
-
}).optional(),
|
|
44
|
-
requireState: z.boolean().optional().describe(
|
|
45
|
-
"When true (default), authenticate() throws if expectedState is missing from context."
|
|
46
|
-
)
|
|
47
|
-
});
|
|
48
|
-
var authConfigSchema = z.discriminatedUnion("type", [pkiConfigSchema, oidcConfigSchema]);
|
|
49
|
-
var componentAuthSchema = z.object({
|
|
50
|
-
required_roles: z.array(z.string()).optional(),
|
|
51
|
-
required_permissions: z.array(z.string()).optional(),
|
|
52
|
-
fallback: z.enum(["hide", "placeholder", "message"]).optional().default("hide"),
|
|
53
|
-
fallback_message: z.string().optional()
|
|
54
|
-
}).optional();
|
|
55
|
-
var rbacConfigSchema = z.object({
|
|
56
|
-
roles: z.array(
|
|
57
|
-
z.object({
|
|
58
|
-
name: z.string(),
|
|
59
|
-
permissions: z.array(z.string()).optional()
|
|
60
|
-
})
|
|
61
|
-
),
|
|
62
|
-
protected_routes: z.array(
|
|
63
|
-
z.object({
|
|
64
|
-
path: z.string(),
|
|
65
|
-
roles: z.array(z.string())
|
|
66
|
-
})
|
|
67
|
-
).optional(),
|
|
68
|
-
public_routes: z.array(z.string()).optional()
|
|
69
|
-
});
|
|
70
|
-
var authUserSchema = z.object({
|
|
71
|
-
id: z.string(),
|
|
72
|
-
email: z.string().email().optional(),
|
|
73
|
-
name: z.string().optional(),
|
|
74
|
-
roles: z.array(z.string()),
|
|
75
|
-
permissions: z.array(z.string()).optional(),
|
|
76
|
-
metadata: z.record(z.string(), z.any()).optional()
|
|
77
|
-
});
|
|
78
|
-
var authSessionSchema = z.object({
|
|
79
|
-
user: authUserSchema,
|
|
80
|
-
expiresAt: z.number(),
|
|
81
|
-
issuedAt: z.number(),
|
|
82
|
-
refreshToken: z.string().optional()
|
|
83
|
-
});
|
|
8
|
+
// src/schemas/index.ts
|
|
84
9
|
function parseCertificate(pemOrDer) {
|
|
85
10
|
const cert = new X509Certificate(pemOrDer);
|
|
86
11
|
const subjectAttrs = cert.subject.split(",").map((s) => s.trim());
|
|
@@ -1615,6 +1540,6 @@ function hasAuthConfig(item) {
|
|
|
1615
1540
|
return "auth" in item;
|
|
1616
1541
|
}
|
|
1617
1542
|
|
|
1618
|
-
export { AuditEventType, AuthContext, AuthProvider, CompositeAuditLogger, ConsoleAuditLogger, DOD_CAC_PROFILE, InMemoryRevocationStore, KeycloakAdapter, NoopAuditLogger, OIDCProvider, PKIProvider, RBACEngine, SessionManager,
|
|
1543
|
+
export { AuditEventType, AuthContext, AuthProvider, CompositeAuditLogger, ConsoleAuditLogger, DOD_CAC_PROFILE, InMemoryRevocationStore, KeycloakAdapter, NoopAuditLogger, OIDCProvider, PKIProvider, RBACEngine, SessionManager, buildAuthorizationUrl, clearCookie, createAuditEvent, createDoDCACConfig, createDoDCACDevConfig, decryptToken, deriveEncryptionKey, discoverOIDC, encryptToken, exchangeCodeForTokens, extractEDIPI, generateCodeChallenge, generateCodeVerifier, generateJti, generateNonce, generateState, getAuthDecorator, hasAuthConfig, maybeWrapWithAuth, parseCertFromHeaders, parseCertificate, parseCookies, refreshAccessToken, registerAuthDecorator, serializeCookie, signCertHeaders, useAuth, useRequireAuth, validateDoDCAC, validateIdToken, verifyCertHeaders, verifyState, withAuth, withAuthFallback };
|
|
1619
1544
|
//# sourceMappingURL=index.mjs.map
|
|
1620
1545
|
//# sourceMappingURL=index.mjs.map
|