![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@financial-times/n-membership-sdk
Advanced tools
A software development kit that centralises membership api calls
A software development kit that centralises Membership API calls.
const { ProductionConfiguration, Session } = require("n-membership-sdk");
// Use ProductionConfiguration defaults and set a key
const config = new ProductionConfiguration({
sessionApiKey: "secret",
});
// Setup and use a service
const sessionSdk = new Session(config);
const sessionInfo = sessionSdk.fetchSessionInfo(sessionId);
The Configuration class provides environment information for services, a Configuration instance needs to be provided when instantiating a service class.
const config = new Configuration({
// Provide environment information
})
There are two helper classes extend Configuration
and come with pre-populated environment information TestConfiguration
and ProductionConfiguration
. Non application specific configuration is defaulted (i.e. hosts) leaving only keys to be provided by the developer.
const config = new ProductionConfiguration({
userApiKey: 'secret'
})
set
Set the config properties using either a property string or config objectget
Return the value of the property givenExposes all the error types the SDK could throw allowing the developer to test the error and handle things differently.
const { Errors } = require('@financial-times/n-membership-sdk');
try {
const gateway = await subscription.fetchGatewayName(type, country);
} catch (error) {
if (error instanceof Errors.NotFoundError) {
// Handle Gateway not being found
} else {
// Handle all other errors
}
}
BadRequestError - HTTP response code 400 received from API
UnauthorizedError - HTTP response code 401 received from API
ForbiddenError - HTTP response code 403 received from API
NotFoundError - HTTP response code 404 received from API
ServerError - HTTP response code in 500 range or unhandled 400 range received from API
InvalidResponseError - Response from the API was invalid
EmptyResultError - No result to return after processing
ValidationError - Incorrect parameter supplied
These are the Membership endpoints that are currently being used by the SDK.
HEAD https://api.ft.com/users?email=${email}
POST https://api.ft.com/users/profile
PUT https://api.ft.com/users/${user.id}/profile
POST https://api.ft.com/login
POST https://api.ft.com/users/${userId}/credentials/change-password
GET https://api.ft.com/subscriptions/${subscriptionId}
POST https://api.ft.com/subscriptions/actions/subscribe
GET https://api.ft.com/paymentpage2/config/${paymentType}/${appId}/${countryCode}
GET https://api.ft.com/payment-gateway/${paymentType}/${countryCode}
POST https://api.ft.com/paymentpage2/validation/signature
GET https://dd-mandate-svc-eu-test.memb.ft.com/mandate/${userId}
POST https://api.ft.com/authorize?client_id=${clientId}&response_type=token&scope=${scope}
GET https://api-t.ft.com/invoice/membership/invoices/v1?accountId=${accountId}
FAQs
A software development kit that centralises membership api calls
The npm package @financial-times/n-membership-sdk receives a total of 0 weekly downloads. As such, @financial-times/n-membership-sdk popularity was classified as not popular.
We found that @financial-times/n-membership-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.