Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.88 KB

File metadata and controls

29 lines (22 loc) · 1.88 KB

Wallet Instance

This flow which consists of a single step, is used to create a wallet instance. The wallet provider must implement its endpoints based on the OpenAPI specification provided in the wallet-instance.yaml file. A service that is responsible for ensuring the integrity of the device where the app is running is required and it's supposed to use Google Play Integrity API and Key Attestation on Android, DCAppAttestService on iOS. The suggested way to implement this service is to use io-react-native-integrity by providing an IntegrityContext object. An example is provided as follows:

// Get env
const { GOOGLE_CLOUD_PROJECT_NUMBER, WALLET_PROVIDER_BASE_URL } = env; // Let's assume env is an object containing the environment variables

const googleCloudProjectNumber = isAndroid
  ? GOOGLE_CLOUD_PROJECT_NUMBER
  : undefined;

await ensureIntegrityServiceIsReady(googleCloudProjectNumber); // Required by io-react-native-integrity to ensure the service is ready
const integrityKeyTag = await generateIntegrityHardwareKeyTag();
const integrityContext = getIntegrityContext(integrityKeyTag); // This function is supposed to return an object as required by IntegrityContext.

await WalletInstance.createWalletInstance({
  integrityContext,
  walletProviderBaseUrl: WALLET_PROVIDER_BASE_URL,
  appFetch,
});

return integrityKeyTag;

The returned integrityKeyTag is supposed to be stored and used to verify the integrity of the device in the future when using an IntegrityContext object. It must be regenerated if another wallet instance is created.