@mintbase-js/auth
This package abstracts login, auth and signing functionality away from
@mintbase-js/sdk
core.As more complex use cases grow with more complex credential verification (ZK), message signing and whatever the future of web3 may hold, having standalone methods and documentation around these features is prudent.
This module can be used as a framework agnostic wrapper using framework specific integrations:
Check back soon for documentation on wallet selector wrapper methods and example usage with other frameworks in the near future.
The primary method used for loading a NEAR account into your Node programs is via the
connect
methodconnect(
accountId: string,
keyStore: Keystore,
network: NearNetwork = 'testnet'
): Promise<Account>
This method uses
near-api-js
to load account accountId
with credentials in the provided keystore.To use the near account signing method with the SDK contract api, you will need to implement a form of key management. You will want to read up on using
KeyStore
in the NEAR DocumentationExample usage:
loadAccount.ts
1
import { connect } from '@mintbase-js/auth';
2
import { KeyPair, InMemoryKeyStore, KeyStore } from '@mintbase-js/sdk';
3
4
const loadAuthenticatedNearAccountInNodeJS = async (accountId: string) => {
5
// NOTE: You will have to implement the method that securely fetches your private key.
6
// See above note
7
const privateKey: string = await <your-super-secure-key-method>();
8
const keyStore: KeyStore = new InMemoryKeyStore();
9
10
keyStore.setKey(
11
NEAR_NETWORK,
12
account,
13
KeyPair.fromString(privateKey),
14
);
15
16
return await connect(accountId, keyStore);
17
}
Last modified 25d ago