Skip to content

Commit c311f82

Browse files
authored
Merge pull request #1342 from cipherstash/docs/unwrap-oidc-federation-result
docs(stack): unwrap the OidcFederationStrategy Result in the README example
2 parents 8d48bbc + 4b14ee6 commit c311f82

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@cipherstash/stack": patch
3+
---
4+
5+
Fix the README's OIDC federation example, which passed the `Result` from `OidcFederationStrategy.create()` straight to `config.authStrategy` and failed in `Encryption()` with `opts.strategy.getToken is missing`.
6+
It now unwraps the `Result` and passes `strategy.data`, and so does the `LockContext` JSDoc example.

‎README.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,14 @@ const client = await Encryption({ schemas: [users] });
121121
// strategy serves every user. (On this native entry the client calls getJwt
122122
// from a background task, so a request read from AsyncLocalStorage is not
123123
// visible there yet — pass it in, or build the client per request; see
124-
// cipherstash/stack#1065.)
124+
// cipherstash/stack#1065.) create() returns a Result: unwrap it and pass the
125+
// strategy itself, not the Result envelope.
126+
const strategy = OidcFederationStrategy.create(workspaceCrn, () => getUserJwt(req));
127+
if (strategy.failure) throw new Error(strategy.failure.error.message);
128+
125129
const client = await Encryption({
126130
schemas: [users],
127-
config: { authStrategy: OidcFederationStrategy.create(workspaceCrn, () => getUserJwt(req)) },
131+
config: { authStrategy: strategy.data },
128132
});
129133
```
130134

‎languages/typescript/packages/stack/README.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,14 @@ const client = await Encryption({ schemas: [users] });
121121
// strategy serves every user. (On this native entry the client calls getJwt
122122
// from a background task, so a request read from AsyncLocalStorage is not
123123
// visible there yet — pass it in, or build the client per request; see
124-
// cipherstash/stack#1065.)
124+
// cipherstash/stack#1065.) create() returns a Result: unwrap it and pass the
125+
// strategy itself, not the Result envelope.
126+
const strategy = OidcFederationStrategy.create(workspaceCrn, () => getUserJwt(req));
127+
if (strategy.failure) throw new Error(strategy.failure.error.message);
128+
125129
const client = await Encryption({
126130
schemas: [users],
127-
config: { authStrategy: OidcFederationStrategy.create(workspaceCrn, () => getUserJwt(req)) },
131+
config: { authStrategy: strategy.data },
128132
});
129133
```
130134

‎languages/typescript/packages/stack/src/identity/index.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,14 @@ export function resolveLockContext(input: LockContextInput): Context {
186186
* import { OidcFederationStrategy } from "@cipherstash/auth"
187187
*
188188
* // Authenticate the client as the end user (replaces the old identify() flow).
189+
* // `create()` returns a `Result` — unwrap it before passing the strategy.
190+
* const strategy = OidcFederationStrategy.create(workspaceCrn, () => getJwt())
191+
* if (strategy.failure) throw new Error(strategy.failure.error.message)
192+
*
189193
* const client = await Encryption({
190194
* schemas,
191195
* config: {
192-
* authStrategy: OidcFederationStrategy.create(workspaceCrn, () => getJwt()),
196+
* authStrategy: strategy.data,
193197
* },
194198
* })
195199
*

0 commit comments

Comments
 (0)