Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates for beta branch #1572

Merged
merged 25 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d4f0791
Migrate other Stripe infrastructure to TS
anniel-stripe Sep 23, 2022
3776e5b
Merge branch 'master' into anniel-migrate-remaining-infrastructure
anniel-stripe Sep 26, 2022
133d4a2
Reviewer comments
anniel-stripe Sep 26, 2022
818bfc2
Update TypeScript
anniel-stripe Sep 26, 2022
e3a86ff
Reviewer comments
anniel-stripe Sep 27, 2022
651024f
Remove 'use strict' from migrated files
anniel-stripe Sep 27, 2022
bd50246
Turn on alwaysStrict in tsconfig
anniel-stripe Sep 27, 2022
98a9b5c
Update src/net/NodeHttpClient.ts
anniel-stripe Sep 27, 2022
cc86ba5
Update src/crypto/SubtleCryptoProvider.ts
anniel-stripe Sep 27, 2022
9ce094a
Update src/crypto/SubtleCryptoProvider.ts
anniel-stripe Sep 27, 2022
a2526b2
Remove hasOwn alias, undo suggested commits
anniel-stripe Sep 27, 2022
2704e87
Update src/net/FetchHttpClient.ts
anniel-stripe Sep 27, 2022
06a6d4e
Add more types to HTTP clients
kamil-stripe Sep 28, 2022
5aae73c
Merge pull request #1563 from stripe/anniel-migrate-remaining-infrast…
anniel-stripe Sep 28, 2022
db94c29
API Updates (#1564)
yejia-stripe Sep 29, 2022
d00097b
Bump version to 10.12.0
yejia-stripe Sep 29, 2022
7e89403
Fix release tag calculation (#1567)
pakrym-stripe Sep 29, 2022
234923e
Upgrade dev dependencies (#1568)
kamil-stripe Oct 3, 2022
30b4679
Update node-fetch to 2.6.7 (#1570)
kamil-stripe Oct 4, 2022
e628ac6
API Updates (#1571)
kamil-stripe Oct 6, 2022
deb7bb5
Bump version to 10.13.0
kamil-stripe Oct 6, 2022
7616949
Set version to 10.13.0 to simplify merge
kamil-stripe Oct 6, 2022
d1630ec
Include latest changes from the master branch
kamil-stripe Oct 6, 2022
5ce9c4b
Reset version to 10.12.0-beta.1
kamil-stripe Oct 6, 2022
973f9a3
Codegen for openapi v201
kamil-stripe Oct 6, 2022
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
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ module.exports = {
extends: ['plugin:prettier/recommended'],
overrides: [
{
files: ["**/*.ts"],
parser: "@typescript-eslint/parser",
files: ['**/*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
npm config set //registry.npmjs.org/:_authToken $NPM_AUTH_TOKEN
# print the NPM user name for validation
npm whoami
VERSION=$(npm -s run env echo '$npm_package_version')
VERSION=$(node -p "require('./package.json').version" )
# Only publish stable versions to the latest tag
if [[ "$VERSION" =~ ^[^-]+$ ]]; then
NPM_TAG="latest"
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 10.13.0 - 2022-10-06
* [#1571](https://github.com/stripe/stripe-node/pull/1571) API Updates
* Add support for new value `invalid_dob_age_under_18` on enums `Account.future_requirements.errors[].code`, `Account.requirements.errors[].code`, `Capability.future_requirements.errors[].code`, `Capability.requirements.errors[].code`, `Person.future_requirements.errors[].code`, and `Person.requirements.errors[].code`
* Add support for new value `bank_of_china` on enums `Charge.payment_method_details.fpx.bank`, `PaymentIntentConfirmParams.payment_method_data.fpx.bank`, `PaymentIntentCreateParams.payment_method_data.fpx.bank`, `PaymentIntentUpdateParams.payment_method_data.fpx.bank`, `PaymentMethod.fpx.bank`, `PaymentMethodCreateParams.fpx.bank`, `SetupIntentConfirmParams.payment_method_data.fpx.bank`, `SetupIntentCreateParams.payment_method_data.fpx.bank`, and `SetupIntentUpdateParams.payment_method_data.fpx.bank`
* Add support for new values `America/Nuuk`, `Europe/Kyiv`, and `Pacific/Kanton` on enum `ReportingReportRunCreateParams.parameters.timezone`
* Add support for `klarna` on `SetupAttempt.payment_method_details`
* [#1570](https://github.com/stripe/stripe-node/pull/1570) Update node-fetch to 2.6.7
* [#1568](https://github.com/stripe/stripe-node/pull/1568) Upgrade dependencies
* [#1567](https://github.com/stripe/stripe-node/pull/1567) Fix release tag calculation

## 10.12.0 - 2022-09-29
* [#1564](https://github.com/stripe/stripe-node/pull/1564) API Updates
* Change type of `Charge.payment_method_details.card_present.incremental_authorization_supported` and `Charge.payment_method_details.card_present.overcapture_supported` from `boolean | null` to `boolean`
* Add support for `created` on `Checkout.Session`
* Add support for `setup_future_usage` on `PaymentIntent.payment_method_options.pix`, `PaymentIntentConfirmParams.payment_method_options.pix`, `PaymentIntentCreateParams.payment_method_options.pix`, and `PaymentIntentUpdateParams.payment_method_options.pix`
* Deprecate `CheckoutSessionCreateParams.subscription_data.items` (use the `line_items` param instead). This will be removed in the next major version.
* [#1563](https://github.com/stripe/stripe-node/pull/1563) Migrate other Stripe infrastructure to TS
* [#1562](https://github.com/stripe/stripe-node/pull/1562) Restore lib after generating
* [#1551](https://github.com/stripe/stripe-node/pull/1551) Re-introduce Typescript changes

## 10.12.0-beta.1 - 2022-09-26
* [#1561](https://github.com/stripe/stripe-node/pull/1561) API Updates for beta branch
* Updated stable APIs to the latest version
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v196
v201
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
env: {
node: true,
},
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
Expand Down
10 changes: 8 additions & 2 deletions lib/Webhooks.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/apiVersion.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/crypto/SubtleCryptoProvider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions lib/multipart.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/net/FetchHttpClient.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/net/NodeHttpClient.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions lib/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,30 @@
"main": "lib/stripe.js",
"types": "types/2022-08-01/index.d.ts",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.13.0",
"@typescript-eslint/parser": "^2.13.0",
"chai": "~4.2.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"chai": "^4.3.6",
"chai-as-promised": "~7.1.1",
"coveralls": "^3.1.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-chai-friendly": "^0.4.0",
"eslint-plugin-prettier": "^3.0.1",
"mocha": "^8.3.2",
"mocha-junit-reporter": "^1.23.1",
"nock": "^13.1.1",
"node-fetch": "^2.6.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-prettier": "^3.4.1",
"mocha": "^8.4.0",
"mocha-junit-reporter": "^2.1.0",
"nock": "^13.2.9",
"node-fetch": "^2.6.7",
"nyc": "^15.1.0",
"prettier": "^1.16.4",
"typescript": "^3.7.2"
"typescript": "^4.8.4"
},
"resolutions": {
"ansi-regex": "5.0.1",
"minimist": "1.2.6",
"nanoid": "3.2.0"
"nanoid": "^3.2.0"
},
"dependencies": {
"@types/node": ">=8.1.0",
"qs": "^6.10.3"
"qs": "^6.11.0"
},
"license": "MIT",
"scripts": {
Expand All @@ -68,5 +67,5 @@
"report": "nyc -r text -r lcov report",
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"prettier-format": "prettier --config .prettierrc 'lib/**/*.js' --write"
}
}
}
1 change: 1 addition & 0 deletions src/Error.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable camelcase */
type RawErrorType =
| 'card_error'
| 'invalid_request_error'
Expand Down
2 changes: 0 additions & 2 deletions src/ResourceNamespace.js → src/ResourceNamespace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

// ResourceNamespace allows you to create nested resources, i.e. `stripe.issuing.cards`.
// It also works recursively, so you could do i.e. `stripe.billing.invoicing.pay`.

Expand Down
16 changes: 10 additions & 6 deletions src/Webhooks.js → src/Webhooks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

const utils = require('./utils');
const {StripeError, StripeSignatureVerificationError} = require('./Error');
import utils = require('./utils');
import _Error = require('./Error');
const {StripeError, StripeSignatureVerificationError} = _Error;

const Webhook = {
DEFAULT_TOLERANCE: 300, // 5 minutes
signature: null,

constructEvent(payload, header, secret, tolerance, cryptoProvider) {
this.signature.verifyHeader(
Expand Down Expand Up @@ -169,6 +169,7 @@ function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) {
if (!details || details.timestamp === -1) {
throw new StripeSignatureVerificationError({
message: 'Unable to extract timestamp and signatures from header',
// @ts-expect-error Type '{ decodedHeader: any; decodedPayload: any; }' is not assignable to type 'string'.
detail: {
decodedHeader,
decodedPayload,
Expand All @@ -179,6 +180,7 @@ function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) {
if (!details.signatures.length) {
throw new StripeSignatureVerificationError({
message: 'No signatures found with expected scheme',
// @ts-expect-error Type '{ decodedHeader: any; decodedPayload: any; }' is not assignable to type 'string'.
detail: {
decodedHeader,
decodedPayload,
Expand Down Expand Up @@ -210,6 +212,7 @@ function validateComputedSignature(
'No signatures found matching the expected signature for payload.' +
' Are you passing the raw request body you received from Stripe?' +
' https://github.com/stripe/stripe-node#webhook-signing',
// @ts-expect-error Type '{ header: any; payload: any; }' is not assignable to type 'string'.
detail: {
header,
payload,
Expand All @@ -222,6 +225,7 @@ function validateComputedSignature(
if (tolerance > 0 && timestampAge > tolerance) {
throw new StripeSignatureVerificationError({
message: 'Timestamp outside the tolerance zone',
// @ts-expect-error Type '{ header: any; payload: any; }' is not assignable to type 'string'.
detail: {
header,
payload,
Expand All @@ -242,7 +246,7 @@ function parseHeader(header, scheme) {
const kv = item.split('=');

if (kv[0] === 't') {
accum.timestamp = kv[1];
accum.timestamp = parseInt(kv[1], 10);
}

if (kv[0] === scheme) {
Expand Down Expand Up @@ -274,4 +278,4 @@ function getNodeCryptoProvider() {

Webhook.signature = signature;

module.exports = Webhook;
export = Webhook;
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

/**
* Interface encapsulating the various crypto computations used by the library,
* allowing pluggable underlying crypto implementations.
Expand All @@ -13,7 +11,7 @@ class CryptoProvider {
* - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd'
* - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43
*/
computeHMACSignature(payload, secret) {
computeHMACSignature(payload: string, secret: string): string {
throw new Error('computeHMACSignature not implemented.');
}

Expand All @@ -28,9 +26,9 @@ class CryptoProvider {
* - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd'
* - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43
*/
computeHMACSignatureAsync(payload, secret) {
computeHMACSignatureAsync(payload: string, secret: string): Promise<string> {
throw new Error('computeHMACSignatureAsync not implemented.');
}
}

module.exports = CryptoProvider;
export = CryptoProvider;
Loading