Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## Version 1.0.4 2026-03-05

**HOTFIX RELEASE — Critical: v3 Authentication Flow Broken**

### Bug Fixes (Critical)
- **`getInfo()` v3 mode called non-existent `/v3/info`**: CF API v3 has no `/v3/info` endpoint. Changed to root endpoint `/` which returns `{ links: { uaa, login, ... } }`. Response is normalized to include `authorization_endpoint` and `token_endpoint` at top level for backward compatibility with all existing consumer code.
- **`authorization_endpoint` was `undefined` in v3 mode**: The standard auth flow `info.authorization_endpoint → usersUAA.setEndPoint()` was completely broken for all v1.0.0+ users using default v3.

### New Features
- **`CloudController.getAuthorizationEndpoint()`**: Convenience method that returns UAA endpoint URL directly. Works with both v2 and v3, abstracts away response shape differences.

### TypeScript
- Added `getAuthorizationEndpoint(): Promise<string>` to `CloudController` type declarations

### Files Modified
- `lib/model/cloudcontroller/CloudController.js`
- `types/index.d.ts`
- `examples/cf-service-usage-example.js`

### Tests
- All **93 passing**, 0 failing

---

## Version 1.0.3 2026-03-05

**PATCH RELEASE — Code Quality Fixes & JSDoc Documentation**
Expand Down
21 changes: 21 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Migration Guide: cf-nodejs-client → cf-node-client v1.0.0

## Important: v1.0.4 Hotfix — Authentication Flow

If you upgraded to v1.0.0–v1.0.3 and hit the error:
```
Invalid endpoint URL: "undefined". Must be a valid http:// or https:// URL.
```

**Upgrade to v1.0.4** — this fixes `getInfo()` in v3 mode. The standard auth pattern now works correctly:

```javascript
// This works in v1.0.4+ (both v2 and v3):
const info = await cfController.getInfo();
usersUAA.setEndPoint(info.authorization_endpoint); // ✅ No longer undefined

// Or use the new convenience method (recommended):
const authEndpoint = await cfController.getAuthorizationEndpoint();
usersUAA.setEndPoint(authEndpoint);
```

---

## Overview

The cf-nodejs-client package has been renamed to `cf-node-client` and upgraded to version 1.0.0 with full Cloud Foundry API v3 support.
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,16 @@ npm install cf-node-client
```javascript
const { CloudController, UsersUAA, Apps } = require("cf-node-client");

const uaa = new UsersUAA("https://login.<your-cf-domain>");
// Step 1: Get UAA endpoint from Cloud Controller
const cc = new CloudController("https://api.<your-cf-domain>");
const authEndpoint = await cc.getAuthorizationEndpoint();

// Step 2: Authenticate
const uaa = new UsersUAA();
uaa.setEndPoint(authEndpoint);
const token = await uaa.login("user", "pass");

// Step 3: Use the token
const apps = new Apps("https://api.<your-cf-domain>");
apps.setToken(token);
const result = await apps.getApps();
Expand All @@ -128,7 +135,11 @@ import {
OAuthToken
} from "cf-node-client";

const uaa = new UsersUAA("https://login.<your-cf-domain>");
const cc = new CloudController("https://api.<your-cf-domain>");
const authEndpoint: string = await cc.getAuthorizationEndpoint();

const uaa = new UsersUAA();
uaa.setEndPoint(authEndpoint);
const token: OAuthToken = await uaa.login("user", "pass");

const apps = new Apps("https://api.<your-cf-domain>");
Expand Down
52 changes: 52 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
# cf-node-client v1.0.4 — Hotfix: v3 getInfo() Broken Authentication Flow

**Package**: cf-node-client v1.0.4
**Release Date**: March 5, 2026
**Status**: Production Ready
**Severity**: **Critical Hotfix**

## What's Fixed in v1.0.4

### Bug Fix — `getInfo()` Returns `undefined` for `authorization_endpoint` (v3 Mode)

**Impact**: All users on v1.0.0+ using default v3 mode. The standard authentication flow was completely broken:

```javascript
// This common pattern was broken in v3 mode:
const info = await cfController.getInfo();
usersUAA.setEndPoint(info.authorization_endpoint); // ❌ undefined → Error thrown
```

**Root Cause**: `CloudController.getInfo()` called `/v3/info` which does not exist in Cloud Foundry. CF v3 uses the root endpoint `/` which returns a different response shape:
- v2: `{ authorization_endpoint: "https://...", token_endpoint: "https://..." }`
- v3 root: `{ links: { uaa: { href: "https://..." }, login: { href: "https://..." } } }`

**Fix**: `getInfo()` in v3 mode now calls the correct root endpoint `/` and **normalizes** the response by adding `authorization_endpoint` and `token_endpoint` at the top level. All existing consumer code works without changes.

### New Convenience Method — `getAuthorizationEndpoint()`

A version-agnostic helper that extracts the UAA endpoint from CF info. Recommended for new code:

```javascript
// Old pattern (still works):
const info = await cfController.getInfo();
usersUAA.setEndPoint(info.authorization_endpoint);

// New pattern (cleaner):
const authEndpoint = await cfController.getAuthorizationEndpoint();
usersUAA.setEndPoint(authEndpoint);
```

### Files Modified

| File | Change |
|------|--------|
| `lib/model/cloudcontroller/CloudController.js` | Fixed `getInfo()` v3 endpoint + response normalization; added `getAuthorizationEndpoint()` |
| `types/index.d.ts` | Added `getAuthorizationEndpoint(): Promise<string>` type declaration |
| `examples/cf-service-usage-example.js` | Added `getAuthTokenV2()` example using new convenience method |

### Tests
- All **93 tests passing**, 0 failing

---

# cf-node-client v1.0.2 — Security: Zero Vulnerabilities

**Package**: cf-node-client v1.0.2
Expand Down
2 changes: 1 addition & 1 deletion doc/Apps.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Apps.html
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 14:08:18 GMT+0700 (Indochina Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 16:22:04 GMT+0700 (Indochina Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/AppsCopy.html
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Apps.html
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 14:08:18 GMT+0700 (Indochina Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 16:22:04 GMT+0700 (Indochina Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/AppsCore.html
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Apps.html
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 14:08:18 GMT+0700 (Indochina Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 16:22:04 GMT+0700 (Indochina Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/AppsDeployment.html
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Apps.html
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 14:08:18 GMT+0700 (Indochina Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 16:22:04 GMT+0700 (Indochina Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/BuildPacks.html
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Apps.html
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 14:08:18 GMT+0700 (Indochina Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 16:22:04 GMT+0700 (Indochina Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion doc/CfIgnoreHelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Apps.html
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 14:08:18 GMT+0700 (Indochina Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Thu Mar 05 2026 16:22:04 GMT+0700 (Indochina Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading