🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@vercel/oidc

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/oidc - npm Package Compare versions

Comparing version
3.4.0
to
3.4.1
+13
docs/functions/getContext.md
[**@vercel/oidc**](../README.md)
---
# Function: getContext()
> **getContext**(): `Context`
Defined in: [packages/oidc/src/get-context.ts:7](https://github.com/vercel/vercel/blob/main/packages/oidc/src/get-context.ts#L7)
## Returns
`Context`
[**@vercel/oidc**](../README.md)
---
# Function: getVercelOidcToken()
> **getVercelOidcToken**(`options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
Defined in: [packages/oidc/src/get-vercel-oidc-token.ts:64](https://github.com/vercel/vercel/blob/main/packages/oidc/src/get-vercel-oidc-token.ts#L64)
Gets the current OIDC token from the request context or the environment variable.
Do not cache this value, as it is subject to change in production!
This function is used to retrieve the OIDC token from the request context or the environment variable.
It checks for the `x-vercel-oidc-token` header in the request context and falls back to the `VERCEL_OIDC_TOKEN` environment variable if the header is not present.
Unlike the `getVercelOidcTokenSync` function, this function will refresh the token if it is expired in a development environment.
## Parameters
### options?
`GetVercelOidcTokenOptions`
Optional configuration for token retrieval.
## Returns
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
A promise that resolves to the OIDC token.
## Throws
If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set. If the token
is expired in a development environment, will also throw an error if the token cannot be refreshed: no CLI credentials are available, CLI credentials are expired, no project configuration is available
or the token refresh request fails.
## Examples
```js
// Using the OIDC token
getVercelOidcToken()
.then(token => {
console.log('OIDC Token:', token);
})
.catch(error => {
console.error('Error:', error.message);
});
```
```js
// Using the OIDC token with explicit team and project (supports IDs and slugs)
getVercelOidcToken({ team: 'my-team', project: 'my-project' })
.then(token => {
console.log('OIDC Token:', token);
})
.catch(error => {
console.error('Error:', error.message);
});
```
[**@vercel/oidc**](../README.md)
---
# Function: getVercelOidcTokenSync()
> **getVercelOidcTokenSync**(): `string`
Defined in: [packages/oidc/src/get-vercel-oidc-token.ts:124](https://github.com/vercel/vercel/blob/main/packages/oidc/src/get-vercel-oidc-token.ts#L124)
Gets the current OIDC token from the request context or the environment variable.
Do not cache this value, as it is subject to change in production!
This function is used to retrieve the OIDC token from the request context or the environment variable.
It checks for the `x-vercel-oidc-token` header in the request context and falls back to the `VERCEL_OIDC_TOKEN` environment variable if the header is not present.
This function will not refresh the token if it is expired. For refreshing the token, use the @{link getVercelOidcToken} function.
## Returns
`string`
The OIDC token.
## Throws
If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set.
## Example
```js
// Using the OIDC token
const token = getVercelOidcTokenSync();
console.log('OIDC Token:', token);
```
[**@vercel/oidc**](../README.md)
---
# Function: getVercelToken()
> **getVercelToken**(`options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
Defined in: [packages/oidc/src/token-util.ts:35](https://github.com/vercel/vercel/blob/main/packages/oidc/src/token-util.ts#L35)
## Parameters
### options?
`GetVercelTokenOptions`
## Returns
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
+6
-0
# @vercel/oidc
## 3.4.1
### Patch Changes
- ae20217: Upgrade to TypeScript 5.9
## 3.4.0

@@ -4,0 +10,0 @@

+58
-80

@@ -0,44 +1,32 @@

[**@vercel/oidc**](../README.md)
---
# Class: AccessTokenMissingError
Defined in: [packages/oidc/src/auth-errors.ts:5](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L5)
Error thrown when no authentication configuration is found.
This typically means the user needs to log in.
## Hierarchy
## Extends
- [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
- [`Error`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)
↳ **`AccessTokenMissingError`**
## Constructors
## Table of contents
### Constructor
### Constructors
> **new AccessTokenMissingError**(): `AccessTokenMissingError`
- [constructor](AccessTokenMissingError.md#constructor)
Defined in: [packages/oidc/src/auth-errors.ts:7](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L7)
### Properties
#### Returns
- [message](AccessTokenMissingError.md#message)
- [name](AccessTokenMissingError.md#name)
- [stack](AccessTokenMissingError.md#stack)
- [prepareStackTrace](AccessTokenMissingError.md#preparestacktrace)
- [stackTraceLimit](AccessTokenMissingError.md#stacktracelimit)
`AccessTokenMissingError`
### Methods
- [captureStackTrace](AccessTokenMissingError.md#capturestacktrace)
## Constructors
### constructor
• **new AccessTokenMissingError**()
#### Overrides
Error.constructor
`Error.constructor`
#### Defined in
[packages/oidc/src/auth-errors.ts:7](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L7)
## Properties

@@ -48,12 +36,10 @@

• **message**: `string`
> **message**: `string`
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077
#### Inherited from
Error.message
`Error.message`
#### Defined in
node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es5.d.ts:1054
---

@@ -63,60 +49,53 @@

• **name**: `string` = `'AccessTokenMissingError'`
> **name**: `string` = `'AccessTokenMissingError'`
Defined in: [packages/oidc/src/auth-errors.ts:6](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L6)
#### Overrides
Error.name
`Error.name`
#### Defined in
---
[packages/oidc/src/auth-errors.ts:6](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L6)
### stack?
---
> `optional` **stack?**: `string`
### stack
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078
• `Optional` **stack**: `string`
#### Inherited from
Error.stack
`Error.stack`
#### Defined in
node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es5.d.ts:1055
---
### prepareStackTrace
### prepareStackTrace?
▪ `Static` `Optional` **prepareStackTrace**: (`err`: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error), `stackTraces`: `CallSite`[]) => `any`
> `static` `optional` **prepareStackTrace?**: (`err`, `stackTraces`) => `any`
#### Type declaration
Defined in: node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:28
▸ (`err`, `stackTraces`): `any`
Optional override for formatting stack traces
**`See`**
#### Parameters
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
##### err
##### Parameters
[`Error`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)
| Name | Type |
| :------------ | :------------------------------------------------------------------------------------------------ |
| `err` | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
| `stackTraces` | `CallSite`[] |
##### stackTraces
##### Returns
`CallSite`[]
#### Returns
`any`
#### Inherited from
#### See
Error.prepareStackTrace
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
#### Defined in
#### Inherited from
node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:28
`Error.prepareStackTrace`

@@ -127,18 +106,18 @@ ---

▪ `Static` **stackTraceLimit**: `number`
> `static` **stackTraceLimit**: `number`
Defined in: node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:30
#### Inherited from
Error.stackTraceLimit
`Error.stackTraceLimit`
#### Defined in
## Methods
node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:30
### captureStackTrace()
## Methods
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
### captureStackTrace
Defined in: node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:21
▸ `Static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
Create .stack property on a target object

@@ -148,7 +127,10 @@

| Name | Type |
| :---------------- | :------------------------------------------------------------------------------------------------------ |
| `targetObject` | `object` |
| `constructorOpt?` | [`Function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) |
##### targetObject
`object`
##### constructorOpt?
[`Function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)
#### Returns

@@ -160,6 +142,2 @@

Error.captureStackTrace
#### Defined in
node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:21
`Error.captureStackTrace`

@@ -0,50 +1,38 @@

[**@vercel/oidc**](../README.md)
---
# Class: RefreshAccessTokenFailedError
Defined in: [packages/oidc/src/auth-errors.ts:18](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L18)
Error thrown when attempting to refresh the authentication token fails.
This includes cases where no refresh token is available.
## Hierarchy
## Extends
- [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)
- [`Error`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)
↳ **`RefreshAccessTokenFailedError`**
## Constructors
## Table of contents
### Constructor
### Constructors
> **new RefreshAccessTokenFailedError**(`cause?`): `RefreshAccessTokenFailedError`
- [constructor](RefreshAccessTokenFailedError.md#constructor)
Defined in: [packages/oidc/src/auth-errors.ts:20](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L20)
### Properties
#### Parameters
- [message](RefreshAccessTokenFailedError.md#message)
- [name](RefreshAccessTokenFailedError.md#name)
- [stack](RefreshAccessTokenFailedError.md#stack)
- [prepareStackTrace](RefreshAccessTokenFailedError.md#preparestacktrace)
- [stackTraceLimit](RefreshAccessTokenFailedError.md#stacktracelimit)
##### cause?
### Methods
`unknown`
- [captureStackTrace](RefreshAccessTokenFailedError.md#capturestacktrace)
#### Returns
## Constructors
`RefreshAccessTokenFailedError`
### constructor
• **new RefreshAccessTokenFailedError**(`cause?`)
#### Parameters
| Name | Type |
| :------- | :-------- |
| `cause?` | `unknown` |
#### Overrides
Error.constructor
`Error.constructor`
#### Defined in
[packages/oidc/src/auth-errors.ts:20](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L20)
## Properties

@@ -54,12 +42,10 @@

• **message**: `string`
> **message**: `string`
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077
#### Inherited from
Error.message
`Error.message`
#### Defined in
node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es5.d.ts:1054
---

@@ -69,60 +55,53 @@

• **name**: `string` = `'RefreshAccessTokenFailedError'`
> **name**: `string` = `'RefreshAccessTokenFailedError'`
Defined in: [packages/oidc/src/auth-errors.ts:19](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L19)
#### Overrides
Error.name
`Error.name`
#### Defined in
---
[packages/oidc/src/auth-errors.ts:19](https://github.com/vercel/vercel/blob/main/packages/oidc/src/auth-errors.ts#L19)
### stack?
---
> `optional` **stack?**: `string`
### stack
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078
• `Optional` **stack**: `string`
#### Inherited from
Error.stack
`Error.stack`
#### Defined in
node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es5.d.ts:1055
---
### prepareStackTrace
### prepareStackTrace?
▪ `Static` `Optional` **prepareStackTrace**: (`err`: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error), `stackTraces`: `CallSite`[]) => `any`
> `static` `optional` **prepareStackTrace?**: (`err`, `stackTraces`) => `any`
#### Type declaration
Defined in: node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:28
▸ (`err`, `stackTraces`): `any`
Optional override for formatting stack traces
**`See`**
#### Parameters
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
##### err
##### Parameters
[`Error`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)
| Name | Type |
| :------------ | :------------------------------------------------------------------------------------------------ |
| `err` | [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) |
| `stackTraces` | `CallSite`[] |
##### stackTraces
##### Returns
`CallSite`[]
#### Returns
`any`
#### Inherited from
#### See
Error.prepareStackTrace
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
#### Defined in
#### Inherited from
node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:28
`Error.prepareStackTrace`

@@ -133,18 +112,18 @@ ---

▪ `Static` **stackTraceLimit**: `number`
> `static` **stackTraceLimit**: `number`
Defined in: node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:30
#### Inherited from
Error.stackTraceLimit
`Error.stackTraceLimit`
#### Defined in
## Methods
node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:30
### captureStackTrace()
## Methods
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
### captureStackTrace
Defined in: node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:21
▸ `Static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
Create .stack property on a target object

@@ -154,7 +133,10 @@

| Name | Type |
| :---------------- | :------------------------------------------------------------------------------------------------------ |
| `targetObject` | `object` |
| `constructorOpt?` | [`Function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) |
##### targetObject
`object`
##### constructorOpt?
[`Function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)
#### Returns

@@ -166,6 +148,2 @@

Error.captureStackTrace
#### Defined in
node_modules/.pnpm/@types+node@20.11.0/node_modules/@types/node/globals.d.ts:21
`Error.captureStackTrace`

@@ -0,149 +1,17 @@

**@vercel/oidc**
---
# @vercel/oidc
## Table of contents
## Classes
### Classes
- [AccessTokenMissingError](classes/AccessTokenMissingError.md)
- [RefreshAccessTokenFailedError](classes/RefreshAccessTokenFailedError.md)
### Functions
- [getContext](README.md#getcontext)
- [getVercelOidcToken](README.md#getverceloidctoken)
- [getVercelOidcTokenSync](README.md#getverceloidctokensync)
- [getVercelToken](README.md#getverceltoken)
## Functions
### getContext
▸ **getContext**(): `Context`
#### Returns
`Context`
#### Defined in
[packages/oidc/src/get-context.ts:7](https://github.com/vercel/vercel/blob/main/packages/oidc/src/get-context.ts#L7)
---
### getVercelOidcToken
▸ **getVercelOidcToken**(`options?`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`\>
Gets the current OIDC token from the request context or the environment variable.
Do not cache this value, as it is subject to change in production!
This function is used to retrieve the OIDC token from the request context or the environment variable.
It checks for the `x-vercel-oidc-token` header in the request context and falls back to the `VERCEL_OIDC_TOKEN` environment variable if the header is not present.
Unlike the `getVercelOidcTokenSync` function, this function will refresh the token if it is expired in a development environment.
**`Throws`**
If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set. If the token
is expired in a development environment, will also throw an error if the token cannot be refreshed: no CLI credentials are available, CLI credentials are expired, no project configuration is available
or the token refresh request fails.
**`Example`**
```js
// Using the OIDC token
getVercelOidcToken()
.then(token => {
console.log('OIDC Token:', token);
})
.catch(error => {
console.error('Error:', error.message);
});
```
**`Example`**
```js
// Using the OIDC token with explicit team and project (supports IDs and slugs)
getVercelOidcToken({ team: 'my-team', project: 'my-project' })
.then(token => {
console.log('OIDC Token:', token);
})
.catch(error => {
console.error('Error:', error.message);
});
```
#### Parameters
| Name | Type | Description |
| :--------- | :-------------------------- | :------------------------------------------ |
| `options?` | `GetVercelOidcTokenOptions` | Optional configuration for token retrieval. |
#### Returns
[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`\>
A promise that resolves to the OIDC token.
#### Defined in
[packages/oidc/src/get-vercel-oidc-token.ts:64](https://github.com/vercel/vercel/blob/main/packages/oidc/src/get-vercel-oidc-token.ts#L64)
---
### getVercelOidcTokenSync
▸ **getVercelOidcTokenSync**(): `string`
Gets the current OIDC token from the request context or the environment variable.
Do not cache this value, as it is subject to change in production!
This function is used to retrieve the OIDC token from the request context or the environment variable.
It checks for the `x-vercel-oidc-token` header in the request context and falls back to the `VERCEL_OIDC_TOKEN` environment variable if the header is not present.
This function will not refresh the token if it is expired. For refreshing the token, use the @{link getVercelOidcToken} function.
**`Throws`**
If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set.
**`Example`**
```js
// Using the OIDC token
const token = getVercelOidcTokenSync();
console.log('OIDC Token:', token);
```
#### Returns
`string`
The OIDC token.
#### Defined in
[packages/oidc/src/get-vercel-oidc-token.ts:124](https://github.com/vercel/vercel/blob/main/packages/oidc/src/get-vercel-oidc-token.ts#L124)
---
### getVercelToken
▸ **getVercelToken**(`options?`): [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`\>
#### Parameters
| Name | Type |
| :--------- | :---------------------- |
| `options?` | `GetVercelTokenOptions` |
#### Returns
[`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<`string`\>
#### Defined in
[packages/oidc/src/token-util.ts:35](https://github.com/vercel/vercel/blob/main/packages/oidc/src/token-util.ts#L35)
- [getContext](functions/getContext.md)
- [getVercelOidcToken](functions/getVercelOidcToken.md)
- [getVercelOidcTokenSync](functions/getVercelOidcTokenSync.md)
- [getVercelToken](functions/getVercelToken.md)

@@ -20,3 +20,3 @@ {

},
"version": "3.4.0",
"version": "3.4.1",
"repository": {

@@ -33,5 +33,5 @@ "directory": "packages/oidc",

"tinyspawn": "1.3.1",
"typedoc": "0.24.6",
"typedoc-plugin-markdown": "3.15.2",
"typedoc-plugin-mdn-links": "3.0.3",
"typedoc": "0.28.19",
"typedoc-plugin-markdown": "4.11.0",
"typedoc-plugin-mdn-links": "5.1.1",
"vitest": "2.0.1"

@@ -38,0 +38,0 @@ },