session->getAccessToken(); } /** * Returns the current OAuth session, including remembered nonces. */ public function getSession(): OAuthSession { return $this->session; } /** * Adds authentication proof to the request. */ public function sign(RequestInterface $request): RequestInterface { return $this->signWithDpopNonce($request, $this->session->resourceServerNonce); } /** * Signs a request with the supplied DPoP nonce. */ public function signWithDpopNonce(RequestInterface $request, ?string $nonce): RequestInterface { if ($this->signer !== NULL) { return $this->signer->signWithDpopNonce($request, $nonce); } if ($this->session->dpopPrivateJwk === NULL) { throw new \InvalidArgumentException('OAuth session is missing DPoP key material.'); } $dpopKey = DpopPrivateKey::fromJwk($this->session->dpopPrivateJwk, $this->session->dpopAlgorithm); return new DpopRequestSigner(new DpopProofFactory($dpopKey), $this->session, $nonce)->sign($request); } /** * Returns the subject DID. */ public function getSubjectDid(): string { return $this->session->did; } /** * Returns the PDS URL. */ public function getPdsUrl(): ?string { return $this->session->pdsUrl; } /** * Stores the latest DPoP nonce in the session. */ public function rememberDpopNonce(?string $nonce): void { $this->session = $this->session->withResourceServerNonce($nonce); } }