stripe 20.4.0 → 20.4.1
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/CHANGELOG.md +4 -0
- package/VERSION +1 -1
- package/cjs/RequestSender.js +9 -1
- package/cjs/resources/V2/Core/Events.js +3 -0
- package/cjs/stripe.core.js +12 -2
- package/cjs/utils.js +31 -2
- package/esm/RequestSender.js +9 -1
- package/esm/resources/V2/Core/Events.js +3 -0
- package/esm/stripe.core.js +13 -3
- package/esm/utils.js +29 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## 20.4.1 - 2026-03-06
|
|
3
|
+
* [#2590](https://github.com/stripe/stripe-node/pull/2590) Add Stripe-Request-Trigger header
|
|
4
|
+
* [#2588](https://github.com/stripe/stripe-node/pull/2588) Add agent information to UserAgent
|
|
5
|
+
|
|
2
6
|
## 20.4.0 - 2026-02-25
|
|
3
7
|
This release changes the pinned API version to `2026-02-25.clover`.
|
|
4
8
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
20.4.
|
|
1
|
+
20.4.1
|
package/cjs/RequestSender.js
CHANGED
|
@@ -263,7 +263,15 @@ class RequestSender {
|
|
|
263
263
|
const appInfo = this._stripe._appInfo
|
|
264
264
|
? this._stripe.getAppInfoAsString()
|
|
265
265
|
: '';
|
|
266
|
-
|
|
266
|
+
const aiAgent = this._stripe.getConstant('AI_AGENT');
|
|
267
|
+
let uaString = `Stripe/${apiMode} NodeBindings/${packageVersion}`;
|
|
268
|
+
if (appInfo) {
|
|
269
|
+
uaString += ` ${appInfo}`;
|
|
270
|
+
}
|
|
271
|
+
if (aiAgent) {
|
|
272
|
+
uaString += ` AIAgent/${aiAgent}`;
|
|
273
|
+
}
|
|
274
|
+
return uaString;
|
|
267
275
|
}
|
|
268
276
|
_getTelemetryHeader() {
|
|
269
277
|
if (this._stripe.getTelemetryEnabled() &&
|
package/cjs/stripe.core.js
CHANGED
|
@@ -37,9 +37,13 @@ const ALLOWED_CONFIG_PROPERTIES = [
|
|
|
37
37
|
];
|
|
38
38
|
const defaultRequestSenderFactory = (stripe) => new RequestSender_js_1.RequestSender(stripe, StripeResource_js_1.StripeResource.MAX_BUFFERED_REQUEST_METRICS);
|
|
39
39
|
function createStripe(platformFunctions, requestSender = defaultRequestSenderFactory) {
|
|
40
|
-
Stripe.PACKAGE_VERSION = '20.4.
|
|
40
|
+
Stripe.PACKAGE_VERSION = '20.4.1';
|
|
41
41
|
Stripe.API_VERSION = apiVersion_js_1.ApiVersion;
|
|
42
|
-
|
|
42
|
+
const aiAgent = typeof process !== 'undefined' && process.env
|
|
43
|
+
? (0, utils_js_1.detectAIAgent)(process.env)
|
|
44
|
+
: '';
|
|
45
|
+
Stripe.AI_AGENT = aiAgent;
|
|
46
|
+
Stripe.USER_AGENT = Object.assign(Object.assign({ bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', publisher: 'stripe', uname: null, typescript: false }, (0, utils_js_1.determineProcessUserAgentProperties)()), (aiAgent ? { ai_agent: aiAgent } : {}));
|
|
43
47
|
Stripe.StripeResource = StripeResource_js_1.StripeResource;
|
|
44
48
|
Stripe.StripeContext = StripeContext_js_1.StripeContext;
|
|
45
49
|
Stripe.resources = resources;
|
|
@@ -368,6 +372,9 @@ function createStripe(platformFunctions, requestSender = defaultRequestSenderFac
|
|
|
368
372
|
eventNotification.fetchEvent = () => {
|
|
369
373
|
return this._requestSender._rawRequest('GET', `/v2/core/events/${eventNotification.id}`, undefined, {
|
|
370
374
|
stripeContext: eventNotification.context,
|
|
375
|
+
headers: {
|
|
376
|
+
'Stripe-Request-Trigger': `event=${eventNotification.id}`,
|
|
377
|
+
},
|
|
371
378
|
}, ['fetch_event']);
|
|
372
379
|
};
|
|
373
380
|
eventNotification.fetchRelatedObject = () => {
|
|
@@ -376,6 +383,9 @@ function createStripe(platformFunctions, requestSender = defaultRequestSenderFac
|
|
|
376
383
|
}
|
|
377
384
|
return this._requestSender._rawRequest('GET', eventNotification.related_object.url, undefined, {
|
|
378
385
|
stripeContext: eventNotification.context,
|
|
386
|
+
headers: {
|
|
387
|
+
'Stripe-Request-Trigger': `event=${eventNotification.id}`,
|
|
388
|
+
},
|
|
379
389
|
}, ['fetch_related_object']);
|
|
380
390
|
};
|
|
381
391
|
return eventNotification;
|
package/cjs/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseHeadersForFetch = exports.parseHttpHeaderAsNumber = exports.parseHttpHeaderAsString = exports.getAPIMode = exports.jsonStringifyRequestData = exports.concat = exports.createApiKeyAuthenticator = exports.determineProcessUserAgentProperties = exports.validateInteger = exports.flattenAndStringify = exports.isObject = exports.emitWarning = exports.pascalToCamelCase = exports.callbackifyPromiseWithTimeout = exports.normalizeHeader = exports.normalizeHeaders = exports.removeNullish = exports.protoExtend = exports.getOptionsFromArgs = exports.getDataFromArgs = exports.extractUrlParams = exports.makeURLInterpolator = exports.queryStringifyRequestData = exports.isOptionsHash = void 0;
|
|
3
|
+
exports.parseHeadersForFetch = exports.parseHttpHeaderAsNumber = exports.parseHttpHeaderAsString = exports.getAPIMode = exports.jsonStringifyRequestData = exports.concat = exports.createApiKeyAuthenticator = exports.detectAIAgent = exports.AI_AGENTS = exports.determineProcessUserAgentProperties = exports.validateInteger = exports.flattenAndStringify = exports.isObject = exports.emitWarning = exports.pascalToCamelCase = exports.callbackifyPromiseWithTimeout = exports.normalizeHeader = exports.normalizeHeaders = exports.removeNullish = exports.protoExtend = exports.getOptionsFromArgs = exports.getDataFromArgs = exports.extractUrlParams = exports.makeURLInterpolator = exports.queryStringifyRequestData = exports.isOptionsHash = void 0;
|
|
4
4
|
const OPTIONS_KEYS = [
|
|
5
5
|
'apiKey',
|
|
6
6
|
'idempotencyKey',
|
|
@@ -11,6 +11,7 @@ const OPTIONS_KEYS = [
|
|
|
11
11
|
'host',
|
|
12
12
|
'authenticator',
|
|
13
13
|
'stripeContext',
|
|
14
|
+
'headers',
|
|
14
15
|
'additionalHeaders',
|
|
15
16
|
'streaming',
|
|
16
17
|
];
|
|
@@ -216,8 +217,13 @@ function getOptionsFromArgs(args) {
|
|
|
216
217
|
}
|
|
217
218
|
opts.authenticator = params.authenticator;
|
|
218
219
|
}
|
|
220
|
+
// these are sent by us from _rawRequest, which is what powers all generated requests
|
|
221
|
+
if (params.headers) {
|
|
222
|
+
Object.assign(opts.headers, params.headers);
|
|
223
|
+
}
|
|
224
|
+
// these are sent from the user-facing RawRequest
|
|
219
225
|
if (params.additionalHeaders) {
|
|
220
|
-
opts.headers
|
|
226
|
+
Object.assign(opts.headers, params.additionalHeaders);
|
|
221
227
|
}
|
|
222
228
|
if (params.streaming) {
|
|
223
229
|
opts.streaming = true;
|
|
@@ -380,6 +386,29 @@ function determineProcessUserAgentProperties() {
|
|
|
380
386
|
};
|
|
381
387
|
}
|
|
382
388
|
exports.determineProcessUserAgentProperties = determineProcessUserAgentProperties;
|
|
389
|
+
exports.AI_AGENTS = [
|
|
390
|
+
// The beginning of the section generated from our OpenAPI spec
|
|
391
|
+
['ANTIGRAVITY_CLI_ALIAS', 'antigravity'],
|
|
392
|
+
['CLAUDECODE', 'claude_code'],
|
|
393
|
+
['CLINE_ACTIVE', 'cline'],
|
|
394
|
+
['CODEX_SANDBOX', 'codex_cli'],
|
|
395
|
+
['CODEX_THREAD_ID', 'codex_cli'],
|
|
396
|
+
['CODEX_SANDBOX_NETWORK_DISABLED', 'codex_cli'],
|
|
397
|
+
['CODEX_CI', 'codex_cli'],
|
|
398
|
+
['CURSOR_AGENT', 'cursor'],
|
|
399
|
+
['GEMINI_CLI', 'gemini_cli'],
|
|
400
|
+
['OPENCODE', 'open_code'],
|
|
401
|
+
// The end of the section generated from our OpenAPI spec
|
|
402
|
+
];
|
|
403
|
+
function detectAIAgent(env) {
|
|
404
|
+
for (const [envVar, agentName] of exports.AI_AGENTS) {
|
|
405
|
+
if (env[envVar]) {
|
|
406
|
+
return agentName;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return '';
|
|
410
|
+
}
|
|
411
|
+
exports.detectAIAgent = detectAIAgent;
|
|
383
412
|
function createApiKeyAuthenticator(apiKey) {
|
|
384
413
|
const authenticator = (request) => {
|
|
385
414
|
request.headers.Authorization = 'Bearer ' + apiKey;
|
package/esm/RequestSender.js
CHANGED
|
@@ -260,7 +260,15 @@ export class RequestSender {
|
|
|
260
260
|
const appInfo = this._stripe._appInfo
|
|
261
261
|
? this._stripe.getAppInfoAsString()
|
|
262
262
|
: '';
|
|
263
|
-
|
|
263
|
+
const aiAgent = this._stripe.getConstant('AI_AGENT');
|
|
264
|
+
let uaString = `Stripe/${apiMode} NodeBindings/${packageVersion}`;
|
|
265
|
+
if (appInfo) {
|
|
266
|
+
uaString += ` ${appInfo}`;
|
|
267
|
+
}
|
|
268
|
+
if (aiAgent) {
|
|
269
|
+
uaString += ` AIAgent/${aiAgent}`;
|
|
270
|
+
}
|
|
271
|
+
return uaString;
|
|
264
272
|
}
|
|
265
273
|
_getTelemetryHeader() {
|
|
266
274
|
if (this._stripe.getTelemetryEnabled() &&
|
package/esm/stripe.core.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ApiVersion } from './apiVersion.js';
|
|
|
7
7
|
import { CryptoProvider } from './crypto/CryptoProvider.js';
|
|
8
8
|
import { HttpClient, HttpClientResponse } from './net/HttpClient.js';
|
|
9
9
|
import * as resources from './resources.js';
|
|
10
|
-
import { createApiKeyAuthenticator, determineProcessUserAgentProperties, pascalToCamelCase, validateInteger, } from './utils.js';
|
|
10
|
+
import { createApiKeyAuthenticator, detectAIAgent, determineProcessUserAgentProperties, pascalToCamelCase, validateInteger, } from './utils.js';
|
|
11
11
|
const DEFAULT_HOST = 'api.stripe.com';
|
|
12
12
|
const DEFAULT_PORT = '443';
|
|
13
13
|
const DEFAULT_BASE_PATH = '/v1/';
|
|
@@ -34,9 +34,13 @@ const ALLOWED_CONFIG_PROPERTIES = [
|
|
|
34
34
|
];
|
|
35
35
|
const defaultRequestSenderFactory = (stripe) => new RequestSender(stripe, StripeResource.MAX_BUFFERED_REQUEST_METRICS);
|
|
36
36
|
export function createStripe(platformFunctions, requestSender = defaultRequestSenderFactory) {
|
|
37
|
-
Stripe.PACKAGE_VERSION = '20.4.
|
|
37
|
+
Stripe.PACKAGE_VERSION = '20.4.1';
|
|
38
38
|
Stripe.API_VERSION = ApiVersion;
|
|
39
|
-
|
|
39
|
+
const aiAgent = typeof process !== 'undefined' && process.env
|
|
40
|
+
? detectAIAgent(process.env)
|
|
41
|
+
: '';
|
|
42
|
+
Stripe.AI_AGENT = aiAgent;
|
|
43
|
+
Stripe.USER_AGENT = Object.assign(Object.assign({ bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', publisher: 'stripe', uname: null, typescript: false }, determineProcessUserAgentProperties()), (aiAgent ? { ai_agent: aiAgent } : {}));
|
|
40
44
|
Stripe.StripeResource = StripeResource;
|
|
41
45
|
Stripe.StripeContext = StripeContext;
|
|
42
46
|
Stripe.resources = resources;
|
|
@@ -365,6 +369,9 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
|
|
|
365
369
|
eventNotification.fetchEvent = () => {
|
|
366
370
|
return this._requestSender._rawRequest('GET', `/v2/core/events/${eventNotification.id}`, undefined, {
|
|
367
371
|
stripeContext: eventNotification.context,
|
|
372
|
+
headers: {
|
|
373
|
+
'Stripe-Request-Trigger': `event=${eventNotification.id}`,
|
|
374
|
+
},
|
|
368
375
|
}, ['fetch_event']);
|
|
369
376
|
};
|
|
370
377
|
eventNotification.fetchRelatedObject = () => {
|
|
@@ -373,6 +380,9 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
|
|
|
373
380
|
}
|
|
374
381
|
return this._requestSender._rawRequest('GET', eventNotification.related_object.url, undefined, {
|
|
375
382
|
stripeContext: eventNotification.context,
|
|
383
|
+
headers: {
|
|
384
|
+
'Stripe-Request-Trigger': `event=${eventNotification.id}`,
|
|
385
|
+
},
|
|
376
386
|
}, ['fetch_related_object']);
|
|
377
387
|
};
|
|
378
388
|
return eventNotification;
|
package/esm/utils.js
CHANGED
|
@@ -8,6 +8,7 @@ const OPTIONS_KEYS = [
|
|
|
8
8
|
'host',
|
|
9
9
|
'authenticator',
|
|
10
10
|
'stripeContext',
|
|
11
|
+
'headers',
|
|
11
12
|
'additionalHeaders',
|
|
12
13
|
'streaming',
|
|
13
14
|
];
|
|
@@ -209,8 +210,13 @@ export function getOptionsFromArgs(args) {
|
|
|
209
210
|
}
|
|
210
211
|
opts.authenticator = params.authenticator;
|
|
211
212
|
}
|
|
213
|
+
// these are sent by us from _rawRequest, which is what powers all generated requests
|
|
214
|
+
if (params.headers) {
|
|
215
|
+
Object.assign(opts.headers, params.headers);
|
|
216
|
+
}
|
|
217
|
+
// these are sent from the user-facing RawRequest
|
|
212
218
|
if (params.additionalHeaders) {
|
|
213
|
-
opts.headers
|
|
219
|
+
Object.assign(opts.headers, params.additionalHeaders);
|
|
214
220
|
}
|
|
215
221
|
if (params.streaming) {
|
|
216
222
|
opts.streaming = true;
|
|
@@ -361,6 +367,28 @@ export function determineProcessUserAgentProperties() {
|
|
|
361
367
|
platform: process.platform,
|
|
362
368
|
};
|
|
363
369
|
}
|
|
370
|
+
export const AI_AGENTS = [
|
|
371
|
+
// The beginning of the section generated from our OpenAPI spec
|
|
372
|
+
['ANTIGRAVITY_CLI_ALIAS', 'antigravity'],
|
|
373
|
+
['CLAUDECODE', 'claude_code'],
|
|
374
|
+
['CLINE_ACTIVE', 'cline'],
|
|
375
|
+
['CODEX_SANDBOX', 'codex_cli'],
|
|
376
|
+
['CODEX_THREAD_ID', 'codex_cli'],
|
|
377
|
+
['CODEX_SANDBOX_NETWORK_DISABLED', 'codex_cli'],
|
|
378
|
+
['CODEX_CI', 'codex_cli'],
|
|
379
|
+
['CURSOR_AGENT', 'cursor'],
|
|
380
|
+
['GEMINI_CLI', 'gemini_cli'],
|
|
381
|
+
['OPENCODE', 'open_code'],
|
|
382
|
+
// The end of the section generated from our OpenAPI spec
|
|
383
|
+
];
|
|
384
|
+
export function detectAIAgent(env) {
|
|
385
|
+
for (const [envVar, agentName] of AI_AGENTS) {
|
|
386
|
+
if (env[envVar]) {
|
|
387
|
+
return agentName;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return '';
|
|
391
|
+
}
|
|
364
392
|
export function createApiKeyAuthenticator(apiKey) {
|
|
365
393
|
const authenticator = (request) => {
|
|
366
394
|
request.headers.Authorization = 'Bearer ' + apiKey;
|