@astrada.co/card-enrollment-sdk
v1.1.0
Published
TypeScript types for the Astrada Card Enrollment SDK and Unified Enrollment SDK. Types only; the runtime loads from sdk.astrada.co via a <script> tag.
Readme
@astrada.co/card-enrollment-sdk
Official TypeScript types for the Astrada Card Enrollment SDK and Unified Enrollment SDK.
These SDKs load at runtime from a hosted <script> tag (they are not npm
runtime packages), so this package ships types only. Install it as a dev
dependency to get a typed window.CardEnrollmentSdk / window.UnifiedEnrollmentSdk
and typed config + callback payloads.
npm install --save-dev @astrada.co/card-enrollment-sdk
# or
yarn add --dev @astrada.co/card-enrollment-sdkCard Enrollment SDK (legacy)
import type {
CardEnrollmentSdkConfig,
EnrollmentSuccess,
OnErrorPayload,
} from '@astrada.co/card-enrollment-sdk';
// `window.CardEnrollmentSdk` is typed automatically once the package is imported.
const config: CardEnrollmentSdkConfig = {
companyName: 'Acme',
subaccountId: '…',
getAccessToken: () => fetchToken(),
onSuccess: (data: EnrollmentSuccess) => {
console.log(data.cardId, data.enrollmentGuidance.availableEnrollmentMethods);
},
onError: (data: OnErrorPayload) => {
console.log(data.type, data.verificationId);
},
};
window.CardEnrollmentSdk.openForm(config);Unified Enrollment SDK
import type {
UnifiedEnrollmentSdkConfig,
SdkEvent,
EnrollmentSuccess,
} from '@astrada.co/card-enrollment-sdk/unified';
const config: UnifiedEnrollmentSdkConfig = {
companyName: 'Acme',
subaccountId: '…',
getAccessToken: () => fetchToken(),
onEvent: (event: SdkEvent) => {
if (event.type === 'card-enrolled') console.log(event.cardId);
},
onSuccess: (data: EnrollmentSuccess) => {
console.log(Object.values(data.cards));
},
};
window.UnifiedEnrollmentSdk.open(config);The
./unifiedentry tracks a pre-GA SDK and its types may change ahead of a stable release; the top-level (Card Enrollment SDK) types are stable.
Versioning
These types are generated from the SDK source and checked against it in CI, so they match what the runtime delivers. See the SDK docs at https://docs.astrada.co for full integration guides.
