@poly-x/core 0.1.0-alpha.7 → 0.1.0-alpha.9
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.cjs +28 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.mts +24 -1
- package/dist/index.mjs +28 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -722,7 +722,13 @@ const ENDPOINTS = {
|
|
|
722
722
|
* `resetPassword` redeems that opaque token single-use and sets the new password.
|
|
723
723
|
*/
|
|
724
724
|
forgotPassword: "/v1/idp/forgot-password",
|
|
725
|
-
resetPassword: "/v1/idp/reset-password"
|
|
725
|
+
resetPassword: "/v1/idp/reset-password",
|
|
726
|
+
/**
|
|
727
|
+
* Public, pk_-scoped login-page branding (F037 / FR-BRND). GET with `client_id`
|
|
728
|
+
* (+ optional `organizationCode`) → the bounded `{ tokens }` set. Never 5xx's /
|
|
729
|
+
* never blocks login; the SDK falls back to its built-in defaults on any failure.
|
|
730
|
+
*/
|
|
731
|
+
branding: "/v1/idp/branding"
|
|
726
732
|
};
|
|
727
733
|
//#endregion
|
|
728
734
|
//#region src/auth/outcomes.ts
|
|
@@ -994,6 +1000,27 @@ var AuthClient = class {
|
|
|
994
1000
|
if (response.status !== 200) throw this.toError(response);
|
|
995
1001
|
return normalizeExchange(response.body, this.clock.now());
|
|
996
1002
|
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Fetch this app's login-page branding (public, pk_-scoped). NEVER throws and never
|
|
1005
|
+
* blocks the sign-in form: any non-200, malformed body, or network failure resolves
|
|
1006
|
+
* to an empty token set so the caller keeps its built-in defaults (FR-BRND-3).
|
|
1007
|
+
*/
|
|
1008
|
+
async fetchBranding(params = {}) {
|
|
1009
|
+
try {
|
|
1010
|
+
const url = new URL(this.config.baseUrl + ENDPOINTS.branding);
|
|
1011
|
+
url.searchParams.set("client_id", this.config.key.raw);
|
|
1012
|
+
if (params.organizationCode) url.searchParams.set("organizationCode", params.organizationCode);
|
|
1013
|
+
const response = await this.transport.request({
|
|
1014
|
+
method: "GET",
|
|
1015
|
+
url: url.toString()
|
|
1016
|
+
});
|
|
1017
|
+
if (response.status !== 200) return {};
|
|
1018
|
+
const tokens = response.body?.tokens;
|
|
1019
|
+
return tokens && typeof tokens === "object" ? tokens : {};
|
|
1020
|
+
} catch {
|
|
1021
|
+
return {};
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
997
1024
|
/** The `RefreshTokens` function the SessionEngine (F003) injects. */
|
|
998
1025
|
createRefresher() {
|
|
999
1026
|
return async (current) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -405,6 +405,12 @@ declare const ENDPOINTS: {
|
|
|
405
405
|
*/
|
|
406
406
|
readonly forgotPassword: "/v1/idp/forgot-password";
|
|
407
407
|
readonly resetPassword: "/v1/idp/reset-password";
|
|
408
|
+
/**
|
|
409
|
+
* Public, pk_-scoped login-page branding (F037 / FR-BRND). GET with `client_id`
|
|
410
|
+
* (+ optional `organizationCode`) → the bounded `{ tokens }` set. Never 5xx's /
|
|
411
|
+
* never blocks login; the SDK falls back to its built-in defaults on any failure.
|
|
412
|
+
*/
|
|
413
|
+
readonly branding: "/v1/idp/branding";
|
|
408
414
|
};
|
|
409
415
|
//#endregion
|
|
410
416
|
//#region src/auth/outcomes.d.ts
|
|
@@ -539,6 +545,17 @@ interface AuthorizeWithPasswordParams {
|
|
|
539
545
|
/** Set on the re-attempt after the user picks a workspace (select_tenant). */
|
|
540
546
|
tenantId?: string;
|
|
541
547
|
}
|
|
548
|
+
/** The bounded login-page branding token set (FR-BRND-1). Every field is optional. */
|
|
549
|
+
interface BrandingTokens {
|
|
550
|
+
displayName?: string;
|
|
551
|
+
logoUrl?: string;
|
|
552
|
+
primaryColor?: string;
|
|
553
|
+
backgroundColor?: string;
|
|
554
|
+
}
|
|
555
|
+
interface FetchBrandingParams {
|
|
556
|
+
/** Refine app-level branding with an org's when the org is already known. */
|
|
557
|
+
organizationCode?: string;
|
|
558
|
+
}
|
|
542
559
|
declare class AuthClient {
|
|
543
560
|
private readonly config;
|
|
544
561
|
private readonly transport;
|
|
@@ -590,6 +607,12 @@ declare class AuthClient {
|
|
|
590
607
|
newPassword: string;
|
|
591
608
|
}): Promise<PasswordResetOutcome>;
|
|
592
609
|
exchangeCode(params: ExchangeCodeParams): Promise<StoredSession>;
|
|
610
|
+
/**
|
|
611
|
+
* Fetch this app's login-page branding (public, pk_-scoped). NEVER throws and never
|
|
612
|
+
* blocks the sign-in form: any non-200, malformed body, or network failure resolves
|
|
613
|
+
* to an empty token set so the caller keeps its built-in defaults (FR-BRND-3).
|
|
614
|
+
*/
|
|
615
|
+
fetchBranding(params?: FetchBrandingParams): Promise<BrandingTokens>;
|
|
593
616
|
/** The `RefreshTokens` function the SessionEngine (F003) injects. */
|
|
594
617
|
createRefresher(): RefreshTokens;
|
|
595
618
|
logout(scope?: "device" | "everywhere"): Promise<void>;
|
|
@@ -607,4 +630,4 @@ declare class AuthClient {
|
|
|
607
630
|
declare const PACKAGE_NAME = "@poly-x/core";
|
|
608
631
|
declare const version = "0.0.0";
|
|
609
632
|
//#endregion
|
|
610
|
-
export { AuthClient, type AuthClientOptions, type AuthorizeOutcome, type AuthorizeWithPasswordParams, type BuildAuthorizeUrlParams, type Clock, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, ENDPOINTS, type ExchangeCodeParams, FetchTransport, type FieldError, ForbiddenError, type HttpMethod, INITIAL_STATE as INITIAL_SESSION_STATE, InMemoryLock, InMemoryPkceStore, InMemorySessionChannel, InMemorySessionStore, type KeyEnv, type KeyKind, type Lock, type MockRoute, MockTransport, PACKAGE_NAME, type ParsedKey, type PasswordAuthOutcome, type PasswordResetOutcome, type PkceEntry, type PkcePair, type PkceStore, type PlatformResponseLike, PolyXConfigError, PolyXError, type PolyXErrorOptions, RateLimitedError, type RefreshTokens, type ResolveConfigInput, type ResolvedConfig, type RetryPolicy, type RuntimeContext, type Session, type SessionChannel, type SessionChannelEvent, type SessionClaims, SessionEngine, type SessionEngineOptions, type SessionEvent, SessionExpiredError, SessionRevokedError, type SessionState, type SessionStore, type SetPasswordParams, type SignedOutReason, type StoredSession, SystemClock, type TenantOption, type TimerHandle, type TokenSet, type Transport, type TransportRequest, type TransportResponse, UnauthenticatedError, UpstreamError, ValidationError, computeChallenge, createSessionEngine, decodeJwtExp, generatePkce, isTransientStatus, mapPlatformError, normalizeExchange, normalizeRefresh, parseAuthorizeOutcome, parsePasswordOutcome, parsePolyXKey, parseResetOutcome, randomState, redactSensitive, reduce as reduceSessionState, resolveConfig, version };
|
|
633
|
+
export { AuthClient, type AuthClientOptions, type AuthorizeOutcome, type AuthorizeWithPasswordParams, type BrandingTokens, type BuildAuthorizeUrlParams, type Clock, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, ENDPOINTS, type ExchangeCodeParams, type FetchBrandingParams, FetchTransport, type FieldError, ForbiddenError, type HttpMethod, INITIAL_STATE as INITIAL_SESSION_STATE, InMemoryLock, InMemoryPkceStore, InMemorySessionChannel, InMemorySessionStore, type KeyEnv, type KeyKind, type Lock, type MockRoute, MockTransport, PACKAGE_NAME, type ParsedKey, type PasswordAuthOutcome, type PasswordResetOutcome, type PkceEntry, type PkcePair, type PkceStore, type PlatformResponseLike, PolyXConfigError, PolyXError, type PolyXErrorOptions, RateLimitedError, type RefreshTokens, type ResolveConfigInput, type ResolvedConfig, type RetryPolicy, type RuntimeContext, type Session, type SessionChannel, type SessionChannelEvent, type SessionClaims, SessionEngine, type SessionEngineOptions, type SessionEvent, SessionExpiredError, SessionRevokedError, type SessionState, type SessionStore, type SetPasswordParams, type SignedOutReason, type StoredSession, SystemClock, type TenantOption, type TimerHandle, type TokenSet, type Transport, type TransportRequest, type TransportResponse, UnauthenticatedError, UpstreamError, ValidationError, computeChallenge, createSessionEngine, decodeJwtExp, generatePkce, isTransientStatus, mapPlatformError, normalizeExchange, normalizeRefresh, parseAuthorizeOutcome, parsePasswordOutcome, parsePolyXKey, parseResetOutcome, randomState, redactSensitive, reduce as reduceSessionState, resolveConfig, version };
|
package/dist/index.d.mts
CHANGED
|
@@ -405,6 +405,12 @@ declare const ENDPOINTS: {
|
|
|
405
405
|
*/
|
|
406
406
|
readonly forgotPassword: "/v1/idp/forgot-password";
|
|
407
407
|
readonly resetPassword: "/v1/idp/reset-password";
|
|
408
|
+
/**
|
|
409
|
+
* Public, pk_-scoped login-page branding (F037 / FR-BRND). GET with `client_id`
|
|
410
|
+
* (+ optional `organizationCode`) → the bounded `{ tokens }` set. Never 5xx's /
|
|
411
|
+
* never blocks login; the SDK falls back to its built-in defaults on any failure.
|
|
412
|
+
*/
|
|
413
|
+
readonly branding: "/v1/idp/branding";
|
|
408
414
|
};
|
|
409
415
|
//#endregion
|
|
410
416
|
//#region src/auth/outcomes.d.ts
|
|
@@ -539,6 +545,17 @@ interface AuthorizeWithPasswordParams {
|
|
|
539
545
|
/** Set on the re-attempt after the user picks a workspace (select_tenant). */
|
|
540
546
|
tenantId?: string;
|
|
541
547
|
}
|
|
548
|
+
/** The bounded login-page branding token set (FR-BRND-1). Every field is optional. */
|
|
549
|
+
interface BrandingTokens {
|
|
550
|
+
displayName?: string;
|
|
551
|
+
logoUrl?: string;
|
|
552
|
+
primaryColor?: string;
|
|
553
|
+
backgroundColor?: string;
|
|
554
|
+
}
|
|
555
|
+
interface FetchBrandingParams {
|
|
556
|
+
/** Refine app-level branding with an org's when the org is already known. */
|
|
557
|
+
organizationCode?: string;
|
|
558
|
+
}
|
|
542
559
|
declare class AuthClient {
|
|
543
560
|
private readonly config;
|
|
544
561
|
private readonly transport;
|
|
@@ -590,6 +607,12 @@ declare class AuthClient {
|
|
|
590
607
|
newPassword: string;
|
|
591
608
|
}): Promise<PasswordResetOutcome>;
|
|
592
609
|
exchangeCode(params: ExchangeCodeParams): Promise<StoredSession>;
|
|
610
|
+
/**
|
|
611
|
+
* Fetch this app's login-page branding (public, pk_-scoped). NEVER throws and never
|
|
612
|
+
* blocks the sign-in form: any non-200, malformed body, or network failure resolves
|
|
613
|
+
* to an empty token set so the caller keeps its built-in defaults (FR-BRND-3).
|
|
614
|
+
*/
|
|
615
|
+
fetchBranding(params?: FetchBrandingParams): Promise<BrandingTokens>;
|
|
593
616
|
/** The `RefreshTokens` function the SessionEngine (F003) injects. */
|
|
594
617
|
createRefresher(): RefreshTokens;
|
|
595
618
|
logout(scope?: "device" | "everywhere"): Promise<void>;
|
|
@@ -607,4 +630,4 @@ declare class AuthClient {
|
|
|
607
630
|
declare const PACKAGE_NAME = "@poly-x/core";
|
|
608
631
|
declare const version = "0.0.0";
|
|
609
632
|
//#endregion
|
|
610
|
-
export { AuthClient, type AuthClientOptions, type AuthorizeOutcome, type AuthorizeWithPasswordParams, type BuildAuthorizeUrlParams, type Clock, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, ENDPOINTS, type ExchangeCodeParams, FetchTransport, type FieldError, ForbiddenError, type HttpMethod, INITIAL_STATE as INITIAL_SESSION_STATE, InMemoryLock, InMemoryPkceStore, InMemorySessionChannel, InMemorySessionStore, type KeyEnv, type KeyKind, type Lock, type MockRoute, MockTransport, PACKAGE_NAME, type ParsedKey, type PasswordAuthOutcome, type PasswordResetOutcome, type PkceEntry, type PkcePair, type PkceStore, type PlatformResponseLike, PolyXConfigError, PolyXError, type PolyXErrorOptions, RateLimitedError, type RefreshTokens, type ResolveConfigInput, type ResolvedConfig, type RetryPolicy, type RuntimeContext, type Session, type SessionChannel, type SessionChannelEvent, type SessionClaims, SessionEngine, type SessionEngineOptions, type SessionEvent, SessionExpiredError, SessionRevokedError, type SessionState, type SessionStore, type SetPasswordParams, type SignedOutReason, type StoredSession, SystemClock, type TenantOption, type TimerHandle, type TokenSet, type Transport, type TransportRequest, type TransportResponse, UnauthenticatedError, UpstreamError, ValidationError, computeChallenge, createSessionEngine, decodeJwtExp, generatePkce, isTransientStatus, mapPlatformError, normalizeExchange, normalizeRefresh, parseAuthorizeOutcome, parsePasswordOutcome, parsePolyXKey, parseResetOutcome, randomState, redactSensitive, reduce as reduceSessionState, resolveConfig, version };
|
|
633
|
+
export { AuthClient, type AuthClientOptions, type AuthorizeOutcome, type AuthorizeWithPasswordParams, type BrandingTokens, type BuildAuthorizeUrlParams, type Clock, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUT_MS, ENDPOINTS, type ExchangeCodeParams, type FetchBrandingParams, FetchTransport, type FieldError, ForbiddenError, type HttpMethod, INITIAL_STATE as INITIAL_SESSION_STATE, InMemoryLock, InMemoryPkceStore, InMemorySessionChannel, InMemorySessionStore, type KeyEnv, type KeyKind, type Lock, type MockRoute, MockTransport, PACKAGE_NAME, type ParsedKey, type PasswordAuthOutcome, type PasswordResetOutcome, type PkceEntry, type PkcePair, type PkceStore, type PlatformResponseLike, PolyXConfigError, PolyXError, type PolyXErrorOptions, RateLimitedError, type RefreshTokens, type ResolveConfigInput, type ResolvedConfig, type RetryPolicy, type RuntimeContext, type Session, type SessionChannel, type SessionChannelEvent, type SessionClaims, SessionEngine, type SessionEngineOptions, type SessionEvent, SessionExpiredError, SessionRevokedError, type SessionState, type SessionStore, type SetPasswordParams, type SignedOutReason, type StoredSession, SystemClock, type TenantOption, type TimerHandle, type TokenSet, type Transport, type TransportRequest, type TransportResponse, UnauthenticatedError, UpstreamError, ValidationError, computeChallenge, createSessionEngine, decodeJwtExp, generatePkce, isTransientStatus, mapPlatformError, normalizeExchange, normalizeRefresh, parseAuthorizeOutcome, parsePasswordOutcome, parsePolyXKey, parseResetOutcome, randomState, redactSensitive, reduce as reduceSessionState, resolveConfig, version };
|
package/dist/index.mjs
CHANGED
|
@@ -721,7 +721,13 @@ const ENDPOINTS = {
|
|
|
721
721
|
* `resetPassword` redeems that opaque token single-use and sets the new password.
|
|
722
722
|
*/
|
|
723
723
|
forgotPassword: "/v1/idp/forgot-password",
|
|
724
|
-
resetPassword: "/v1/idp/reset-password"
|
|
724
|
+
resetPassword: "/v1/idp/reset-password",
|
|
725
|
+
/**
|
|
726
|
+
* Public, pk_-scoped login-page branding (F037 / FR-BRND). GET with `client_id`
|
|
727
|
+
* (+ optional `organizationCode`) → the bounded `{ tokens }` set. Never 5xx's /
|
|
728
|
+
* never blocks login; the SDK falls back to its built-in defaults on any failure.
|
|
729
|
+
*/
|
|
730
|
+
branding: "/v1/idp/branding"
|
|
725
731
|
};
|
|
726
732
|
//#endregion
|
|
727
733
|
//#region src/auth/outcomes.ts
|
|
@@ -993,6 +999,27 @@ var AuthClient = class {
|
|
|
993
999
|
if (response.status !== 200) throw this.toError(response);
|
|
994
1000
|
return normalizeExchange(response.body, this.clock.now());
|
|
995
1001
|
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Fetch this app's login-page branding (public, pk_-scoped). NEVER throws and never
|
|
1004
|
+
* blocks the sign-in form: any non-200, malformed body, or network failure resolves
|
|
1005
|
+
* to an empty token set so the caller keeps its built-in defaults (FR-BRND-3).
|
|
1006
|
+
*/
|
|
1007
|
+
async fetchBranding(params = {}) {
|
|
1008
|
+
try {
|
|
1009
|
+
const url = new URL(this.config.baseUrl + ENDPOINTS.branding);
|
|
1010
|
+
url.searchParams.set("client_id", this.config.key.raw);
|
|
1011
|
+
if (params.organizationCode) url.searchParams.set("organizationCode", params.organizationCode);
|
|
1012
|
+
const response = await this.transport.request({
|
|
1013
|
+
method: "GET",
|
|
1014
|
+
url: url.toString()
|
|
1015
|
+
});
|
|
1016
|
+
if (response.status !== 200) return {};
|
|
1017
|
+
const tokens = response.body?.tokens;
|
|
1018
|
+
return tokens && typeof tokens === "object" ? tokens : {};
|
|
1019
|
+
} catch {
|
|
1020
|
+
return {};
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
996
1023
|
/** The `RefreshTokens` function the SessionEngine (F003) injects. */
|
|
997
1024
|
createRefresher() {
|
|
998
1025
|
return async (current) => {
|