Files
WRNexusJSDoc/app/pages/packages/identity.wrn
T

240 lines
12 KiB
Plaintext

page wrnexusidentity {
seo {
title = "@wrnexus/identity"
description = "Portable identity records, claims, and account linking."
}
view {
<div class="docs-shell">
<a href="#main" class="skip-link">Skip to content</a>
<header class="topbar">
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
<nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.8.7</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
</header>
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
<main class="portal-main docs-layout">
<article id="main" class="documentation prose standalone package-document"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/packages">Packages</a><span>/</span><span aria-current="page">@wrnexus/identity</span></nav><section class="doc-intro"><span class="eyebrow">Security · Package reference</span><h1>@wrnexus/identity</h1><p>Portable identity records, claims, and account linking.</p><div class="doc-meta"><span>v0.8.7</span><span>Private registry</span><span>Security</span></div><section id="access" class="access-callout"><h2>Install the package</h2><p>After WorkRoot approves private registry access, install the release-aligned package:</p><pre><code>bun add @wrnexus/identity@0.8.7</code><button type="button" class="copy-button" aria-label="Copy installation command">Copy</button></pre><p><a href="/access">Request preview access</a>. Never put registry tokens in source control.</p></section></section><section id="guide"><p>Enterprise identity and governance for WRNexusJS: OIDC discovery, signed SAML adapter flows, LDAP/Active Directory synchronization adapters, SCIM provisioning, scoped API keys, service accounts, approval workflows, consent history, retention, subject export/deletion and audit.</p>
<p>The package complements <code>@wrnexus/auth</code> (passkeys, MFA, devices, sessions, OAuth and audited impersonation) and <code>@wrnexus/authz</code> (RBAC, ABAC and policy decisions). Protocol-specific SAML and directory parsing is supplied through adapters so applications can select a maintained vendor SDK without weakening framework validation, replay protection or governance auditing.</p></section><section id="api" class="api"><h2>Complete TypeScript API</h2><p>Generated from the exact installed package declarations.</p><pre data-language="typescript"><code>interface OidcMetadata &#123;
issuer: string;
authorization_endpoint: string;
token_endpoint: string;
userinfo_endpoint?: string;
jwks_uri: string;
scopes_supported?: string[];
&#125;
declare function discoverOidc(issuer: string, options?: &#123;
fetch?: typeof fetch;
&#125;): Promise&lt;OidcMetadata&gt;;
declare function oidcAuthorizationUrl(metadata: OidcMetadata, input: &#123;
clientId: string;
redirectUri: string;
state: string;
nonce: string;
codeChallenge: string;
scopes?: string[];
&#125;): string;
interface EnterpriseIdentity &#123;
externalId: string;
username: string;
displayName?: string;
email?: string;
groups: string[];
active: boolean;
attributes?: Record&lt;string, unknown&gt;;
&#125;
interface SamlAssertion &#123;
id: string;
issuer: string;
audience: string;
recipient: string;
expiresAt: number;
identity: EnterpriseIdentity;
&#125;
interface SamlAdapter &#123;
createLoginRequest(input: &#123;
requestId: string;
callbackUrl: string;
relayState: string;
&#125;): Promise&lt;string&gt; | string;
verifySignedResponse(response: string): Promise&lt;SamlAssertion&gt;;
&#125;
interface ReplayStore &#123;
consume(id: string, expiresAt: number): Promise&lt;boolean&gt;;
&#125;
declare function memoryReplayStore(now?: () =&gt; number): ReplayStore;
declare function createSamlFederation(options: &#123;
adapter: SamlAdapter;
issuer: string;
audience: string;
recipient: string;
replayStore?: ReplayStore;
now?: () =&gt; number;
&#125;): &#123;
login: (input: &#123;
requestId: string;
callbackUrl: string;
relayState: string;
&#125;) =&gt; Promise&lt;string&gt; | string;
callback(encodedResponse: string): Promise&lt;EnterpriseIdentity&gt;;
&#125;;
interface DirectoryAdapter &#123;
kind: &quot;ldap&quot; | &quot;active-directory&quot;;
search(input: &#123;
baseDn: string;
filter: string;
attributes: string[];
signal?: AbortSignal;
&#125;): Promise&lt;EnterpriseIdentity[]&gt;;
authenticate?(username: string, password: string, signal?: AbortSignal): Promise&lt;EnterpriseIdentity | null&gt;;
&#125;
declare function syncDirectory(adapter: DirectoryAdapter, options: &#123;
baseDn: string;
filter?: string;
attributes?: string[];
signal?: AbortSignal;
upsert: (identity: EnterpriseIdentity) =&gt; void | Promise&lt;void&gt;;
disableMissing?: (externalIds: string[]) =&gt; void | Promise&lt;void&gt;;
&#125;): Promise&lt;&#123;
provider: &quot;ldap&quot; | &quot;active-directory&quot;;
synchronized: number;
&#125;&gt;;
interface ScimUser extends EnterpriseIdentity &#123;
id: string;
/** RFC 7643 field accepted at the HTTP boundary. */
userName?: string;
schemas?: string[];
&#125;
interface ScimStore &#123;
list(): Promise&lt;ScimUser[]&gt;;
get(id: string): Promise&lt;ScimUser | null&gt;;
create(user: Omit&lt;ScimUser, &quot;id&quot;&gt;): Promise&lt;ScimUser&gt;;
update(id: string, user: Partial&lt;ScimUser&gt;): Promise&lt;ScimUser | null&gt;;
delete(id: string): Promise&lt;boolean&gt;;
&#125;
declare function memoryScimStore(): ScimStore;
declare function createScimHandler(options: &#123;
store: ScimStore;
bearerToken: string;
basePath?: string;
maxBodyBytes?: number;
&#125;): (request: Request) =&gt; Promise&lt;Response&gt;;
interface MachineCredential &#123;
id: string;
ownerId: string;
kind: &quot;api-key&quot; | &quot;service-account&quot;;
name: string;
scopes: string[];
secretHash: string;
createdAt: number;
expiresAt?: number;
revokedAt?: number;
&#125;
declare function createMachineIdentityManager(now?: () =&gt; number): &#123;
issue(input: &#123;
ownerId: string;
name: string;
scopes: string[];
kind?: MachineCredential[&quot;kind&quot;];
expiresAt?: number;
&#125;): Promise&lt;&#123;
secret: string;
credential: &#123;
secretHash: string;
id: string;
ownerId: string;
kind: &quot;api-key&quot; | &quot;service-account&quot;;
name: string;
scopes: string[];
createdAt: number;
expiresAt?: number;
revokedAt?: number;
&#125;;
&#125;&gt;;
authenticate(secret: string, requiredScope?: string): Promise&lt;&#123;
secretHash: string;
id: string;
ownerId: string;
kind: &quot;api-key&quot; | &quot;service-account&quot;;
name: string;
scopes: string[];
createdAt: number;
expiresAt?: number;
revokedAt?: number;
&#125; | null&gt;;
revoke(id: string): boolean;
list(ownerId: string): &#123;
secretHash: string;
id: string;
ownerId: string;
kind: &quot;api-key&quot; | &quot;service-account&quot;;
name: string;
scopes: string[];
createdAt: number;
expiresAt?: number;
revokedAt?: number;
&#125;[];
&#125;;
interface GovernanceEvent &#123;
id: string;
type: string;
subjectId: string;
actorId?: string;
createdAt: number;
data?: Record&lt;string, unknown&gt;;
&#125;
declare function createGovernance(options?: &#123;
now?: () =&gt; number;
audit?: (event: GovernanceEvent) =&gt; void | Promise&lt;void&gt;;
exportSubject?: (subjectId: string) =&gt; unknown | Promise&lt;unknown&gt;;
deleteSubject?: (subjectId: string) =&gt; void | Promise&lt;void&gt;;
&#125;): &#123;
consent(subjectId: string, purpose: string, granted: boolean, version: string): Promise&lt;&#123;
granted: boolean;
version: string;
at: number;
&#125;&gt;;
consents(subjectId: string): &#123;
[k: string]: &#123;
granted: boolean;
version: string;
at: number;
&#125;;
&#125;;
request(subjectId: string, action: &quot;export&quot; | &quot;delete&quot;): Promise&lt;&#123;
id: `$&#123;string&#125;-$&#123;string&#125;-$&#123;string&#125;-$&#123;string&#125;-$&#123;string&#125;`;
subjectId: string;
action: &quot;export&quot; | &quot;delete&quot;;
status: &quot;pending&quot;;
requestedAt: number;
&#125;&gt;;
decide(id: string, actorId: string, approved: boolean): Promise&lt;&#123;
decision: &#123;
status: &quot;approved&quot; | &quot;rejected&quot;;
decidedAt: number;
decidedBy: string;
id: string;
subjectId: string;
action: &quot;export&quot; | &quot;delete&quot;;
requestedAt: number;
&#125;;
result: unknown;
&#125;&gt;;
enforceRetention(records: Array&lt;&#123;
subjectId: string;
createdAt: number;
&#125;&gt;, maxAgeMs: number, remove: (record: &#123;
subjectId: string;
createdAt: number;
&#125;) =&gt; void | Promise&lt;void&gt;): Promise&lt;number&gt;;
&#125;;
export &#123; type DirectoryAdapter, type EnterpriseIdentity, type GovernanceEvent, type MachineCredential, type OidcMetadata, type ReplayStore, type SamlAdapter, type SamlAssertion, type ScimStore, type ScimUser, createGovernance, createMachineIdentityManager, createSamlFederation, createScimHandler, discoverOidc, memoryReplayStore, memoryScimStore, oidcAuthorizationUrl, syncDirectory &#125;;
</code></pre></section><section id="examples" class="examples"><h2>Examples</h2><p>Copy-ready examples from the installed package documentation.</p><div class="example-grid"><article class="example-card"><h3>Install @wrnexus/identity</h3><pre data-language="sh"><code>bun add @wrnexus/identity</code></pre></article><article class="example-card"><h3>Import @wrnexus/identity</h3><pre data-language="ts"><code>import * as identity from &quot;@wrnexus/identity&quot;;</code></pre></article></div></section></article>
<aside class="on-this-page"><h2>On this page</h2><nav><a class="toc-level-2" href="#guide">Guide</a><a class="toc-level-2" href="#api">Complete API</a><a class="toc-level-2" href="#examples">Examples</a></nav></aside>
</main>
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.8.7</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
</div>
}
}