@workos-inc/node 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/lib/{factory-BbGPjwhL.mjs → factory-D2Ig6M1S.mjs} +904 -407
- package/lib/factory-D2Ig6M1S.mjs.map +1 -0
- package/lib/{factory-DJd6WXWm.cjs → factory-J5qx-wp3.cjs} +908 -405
- package/lib/factory-J5qx-wp3.cjs.map +1 -0
- package/lib/{factory-C86kGSc7.d.cts → factory-r4pCiC4E.d.cts} +2815 -2293
- package/lib/{factory-G1JU2hJz.d.mts → factory-r4pCiC4E.d.mts} +2816 -2293
- package/lib/index.cjs +50 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +50 -2
- package/lib/index.mjs.map +1 -1
- package/lib/index.worker.cjs +2 -1
- package/lib/index.worker.d.cts +2 -2
- package/lib/index.worker.d.mts +2 -2
- package/lib/index.worker.mjs +2 -2
- package/lib/{webapi-C2FQ2NNL.mjs → webapi-CfgZkeeN.mjs} +13 -2
- package/lib/{webapi-C2FQ2NNL.mjs.map → webapi-CfgZkeeN.mjs.map} +1 -1
- package/lib/webapi-MD5xmNba.cjs.map +1 -1
- package/package.json +2 -2
- package/lib/factory-BbGPjwhL.mjs.map +0 -1
- package/lib/factory-DJd6WXWm.cjs.map +0 -1
- package/lib/rolldown-runtime-D7D4PA-g.mjs +0 -13
package/README.md
CHANGED
|
@@ -82,6 +82,25 @@ const workos = new WorkOS('sk_1234', {
|
|
|
82
82
|
`issuer` also accepts an array when tokens from more than one issuer should be
|
|
83
83
|
accepted. When `issuer` is not set, the `iss` claim is not validated.
|
|
84
84
|
|
|
85
|
+
### Verifying access tokens
|
|
86
|
+
|
|
87
|
+
To verify an access token your application received elsewhere, for example from
|
|
88
|
+
an `Authorization: Bearer` header, use `verifyAccessToken`. It checks the
|
|
89
|
+
signature against the WorkOS JWKS and the expiry, plus the issuer when one is
|
|
90
|
+
configured, and that the token is a user access token rather than one WorkOS
|
|
91
|
+
signed for another purpose, such as an agent or widget token. It returns the
|
|
92
|
+
token's claims, or `null` when the token is invalid:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const claims = await workos.userManagement.verifyAccessToken(accessToken);
|
|
96
|
+
|
|
97
|
+
if (!claims) {
|
|
98
|
+
throw new Error('Invalid access token');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log(claims.sub, claims.org_id, claims.permissions);
|
|
102
|
+
```
|
|
103
|
+
|
|
85
104
|
## Public Client Mode (Browser/Mobile/CLI)
|
|
86
105
|
|
|
87
106
|
For apps that can't securely store secrets, initialize with just a client ID:
|
|
@@ -136,6 +155,36 @@ const { accessToken } = await workos.userManagement.authenticateWithCode({
|
|
|
136
155
|
});
|
|
137
156
|
```
|
|
138
157
|
|
|
158
|
+
## Feature flag runtime
|
|
159
|
+
|
|
160
|
+
The runtime client polls the v2 flag payload and evaluates flags locally. When a
|
|
161
|
+
flag is off it serves `off_value`. Otherwise rules are evaluated in array order:
|
|
162
|
+
the first matching rule's `value` wins, and `default_value` applies when no rule
|
|
163
|
+
matches. A matching rule can serve `false`. Every condition in a rule must match;
|
|
164
|
+
`one_of` matches an exact ID for its target type. Unknown rule kinds and condition
|
|
165
|
+
operators never match.
|
|
166
|
+
|
|
167
|
+
`isEnabled(key, context, defaultValue)` returns `defaultValue` (`false` when
|
|
168
|
+
omitted) if the flag is missing or the served value is not a boolean.
|
|
169
|
+
`getAllFlags` uses `false` in that case.
|
|
170
|
+
|
|
171
|
+
`getFlag(key)` returns the flag's `FlagPollEntry`: `slug`, `enabled`,
|
|
172
|
+
`default_value`, `off_value` and `rules`. The `previous` and `current` values in
|
|
173
|
+
`change` events have the same shape. Reordering rules emits a `change` event;
|
|
174
|
+
reordering IDs within a condition does not.
|
|
175
|
+
|
|
176
|
+
To start from saved configuration, pass a `FlagPollResponse`
|
|
177
|
+
(`{ version: 2, flags: { [slug]: FlagPollEntry } }`) as `bootstrapFlags`.
|
|
178
|
+
Unrecognized bootstrap data, including a bare map of entries without the
|
|
179
|
+
envelope, is ignored with a warning to `logger` and readiness still resolves;
|
|
180
|
+
polling populates the cache afterward.
|
|
181
|
+
|
|
182
|
+
A failed poll, including one that returns a payload the SDK can't read, emits
|
|
183
|
+
`error`, keeps the last good snapshot, and retries with backoff. A 401 stops
|
|
184
|
+
polling and also emits `failed`. Attach an `error` listener or a `logger` to see
|
|
185
|
+
failures; with neither, the client warns once and keeps polling, and warns again
|
|
186
|
+
if a 401 stops it.
|
|
187
|
+
|
|
139
188
|
## SDK Versioning
|
|
140
189
|
|
|
141
190
|
For our SDKs WorkOS follows a Semantic Versioning ([SemVer](https://semver.org/)) process where all releases will have a version X.Y.Z (like 1.0.0) pattern wherein Z would be a bug fix (e.g., 1.0.1), Y would be a minor release (1.1.0) and X would be a major release (2.0.0). We permit any breaking changes to only be released in major versions and strongly recommend reading changelogs before making any major version upgrades.
|