createPortalToken
function createPortalToken( secret, customer, options?): Promise<string>;Defined in: src/portal.ts:108
Mint a portal token for customer, valid for expiresIn (default 1 hour).
Call this server-side, after your own authentication — anyone holding
the portal secret can mint tokens for any customer.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
secret |
TokenSecret |
customer |
string |
options? |
PortalTokenOptions |
Returns
Section titled “Returns”Promise<string>
Example
Section titled “Example”import { createPortalToken } from "@xtandard/entitlements";
// In the host app's session-guarded route:const token = await createPortalToken(process.env.PORTAL_SECRET!, session.orgId, { expiresIn: "1h",});// Hand `token` to the frontend for <CustomerPortal token={token} />.