@ownid/azure-b2c
Version:
Server-side library for integrating OwnID passwordless authentication with Azure Active Directory B2C
86 lines (85 loc) • 2.3 kB
TypeScript
/**
* OwnID Azure B2C Integration Types
*/
export interface OwnIDB2CConfig {
/**
* Azure Tenant ID (Directory ID)
*/
azureTenantId: string;
/**
* Azure Client ID for the application registered for OwnID integration
*/
azureClientId: string;
/**
* Azure Client Secret for the application registered for OwnID integration
*/
azureClientSecret: string;
/**
* Azure B2C Extension App ID for custom attributes
*/
azureB2cExtensionAppId: string;
/**
* B2C Tenant Name (e.g., "yourtenant" from "yourtenant.onmicrosoft.com")
*/
b2cTenantName: string;
/**
* Base64-encoded shared secret from OwnID Console for signature verification
*/
ownIdSharedSecret?: string;
/**
* Whether to disable request signature verification
* @default false
*/
disableRequestVerification?: boolean;
/**
* Optional custom session token generator function
* Allows overriding the default Azure B2C token generation
*/
customSessionGenerator?: SessionGeneratorFunction;
}
export interface OwnIDRequestHeaders {
'ownid-signature'?: string | string[];
'ownid-timestamp'?: string | string[];
[key: string]: string | string[] | undefined;
}
export interface OwnIDSessionToken {
accessToken: string;
expiresOn: Date;
scopes: string[];
account: {
homeAccountId: string;
environment: string;
tenantId: string;
username: string;
};
}
export interface OwnIDDataRequest {
loginId: string;
ownIdData?: any;
}
export interface OwnIDDataResponse {
ownIdData: any | null;
errorCode?: number;
}
export interface OwnIDB2CUser {
id: string;
displayName?: string;
mail?: string;
ownIdData?: any;
}
/**
* Microsoft Graph extension object interface
*/
export interface GraphExtension {
id: string;
extensionName?: string;
[key: string]: any;
}
/**
* Function signature for custom session token generation
* @param userId - Azure B2C user ID
* @param email - User's email address
* @param user - Full user object (if available)
* @returns Any token or session object
*/
export type SessionGeneratorFunction = (userId: string, email: string, user?: OwnIDB2CUser) => Promise<any>;