Skip to main content
@shared/core holds the small set of TypeScript types shared across every NEAR Auth SDK and provider. It defines the contract each provider implements, the shapes returned by login and signature flows, the NEP-413 message parameters and encoder, and a handful of network constants.
@shared/core is an internal package — it is bundled into the published SDKs and providers, not installed on its own. You don’t need it for a normal integration. It’s documented here because these types are the seam you build against when you write a custom provider, or when you want precise types over the values the SDKs hand back.

IFastAuthProvider

Every provider — JavascriptProvider, ReactNativeProvider, or one you write yourself — implements this interface. The browser SDK and React SDK accept any IFastAuthProvider, so conforming to it is all a custom provider needs to plug into the rest of the stack.
The ...args: any[] signatures are intentionally open so each provider can accept its own options (for example the JavaScript provider’s popup/redirect flags). Concrete providers narrow these in their own types — see the JavaScript provider reference for the real parameters.

Response types

The provider methods resolve to a few thin shapes. User is the primitive they all build on.

User

The deterministic identifier for an authenticated identity. The same login always resolves to the same userId, which is what lets NEAR Auth derive a stable NEAR key per user.

LoginResponse, RequestTransactionSignatureResponse, RequestDelegateActionSignatureResponse, RequestMessageSignatureResponse

Each of these is an alias of User — login and every signature-request flow resolve to the identity they acted on.

GetSignatureRequestResponse

Returned by getSignatureRequest(). Pairs the authenticated User with the SignatureRequest the provider prepared for the on-chain FastAuth.sign call.

SignatureRequest

The data the SDK feeds into the NEAR Auth contract’s sign method. Its fields map directly onto the contract’s sign(guard_id, verify_payload, sign_payload, algorithm) arguments.
string
The guard identifier — which JWT guard verifies this request on-chain (for the Auth0 flow, the Auth0 guard).
string
The payload to verify — typically the JWT issued by the identity provider, which the guard RS256-verifies before any signature is produced.
Uint8Array
The bytes to sign — the encoded transaction, delegate action, or NEP-413 message.
MPCContractAlgorithm
The signing algorithm the MPC network should use. Optional; defaults are resolved downstream.

NEP-413 message signing

Signing an off-chain NEP-413 message lets a user prove they control their account without broadcasting a transaction of their own. @shared/core provides the parameter type and the encoder that the JavaScript provider uses to build the payload to sign. @shared/core is internal, so import both from @fast-auth-near/javascript-provider or @fast-auth-near/browser-sdk, which re-export them.

SignMessageParams

string
The message the user is asked to sign.
string
The recipient the message is addressed to, e.g. "alice.near" or "myapp.com".
Uint8Array
A 32-byte nonce chosen by the app, used to prevent replays. Issue it from your backend and bind it to the user’s session. See Sign messages.
string
Optional callback URL from NEP-413. It is only signed data. NEAR Auth never calls it.

encodeSignMessage

Encodes a NEP-413 message into the exact Borsh bytes whose SHA-256 hash the user signs: borsh(u32 tag) || borsh({ message, nonce, recipient, callbackUrl }), where the tag is 2^31 + 413. The JavaScript provider calls it internally when you request a message signature, and your backend calls it to re-encode the message when it verifies the signature.
Throws NEP-413 nonce must be 32 bytes, got … if nonce isn’t exactly 32 bytes.

Constants & unions

MPCContractAlgorithm

The signing algorithms the MPC contract supports.
This is the on-chain / MPC-facing algorithm union. The SDK-facing signer key type in the browser SDK uses "secp256k1" | "ed25519" for public keys — they describe different layers, so don’t mix them up.

FastAuthNetwork

The two supported NEAR networks. Providers and SDKs take this to select endpoints and defaults.

FAST_AUTH_AUTH0_DEFAULTS

Per-network Auth0 defaults, keyed by FastAuthNetwork. Providers fall back to these when you don’t pass an explicit domain or signingAudience.
The shape of each entry is FastAuthAuth0NetworkDefaults:
These are the same values documented on the testnet and mainnet resource pages. Read them from FAST_AUTH_AUTH0_DEFAULTS instead of hard-coding strings so a network switch stays a one-line change.

Building a custom provider

Because the SDKs depend only on IFastAuthProvider, you can implement your own provider — wrapping a different identity source or auth flow — and pass it straight into FastAuthClient or FastAuthProvider.
Writing a custom provider for a different identity issuer touches on-chain territory — a matching guard has to verify your JWTs. That’s an advanced topic outside the Auth0 happy path; see Protocol → Advanced → Custom issuer and Custom issuer guard before you go down this road.

Next steps

SDK overview

How the SDKs, providers, and core types fit together.

JavaScript provider

The reference IFastAuthProvider implementation for web.

Browser SDK

FastAuthClient and FastAuthSigner, built on these types.

How it works

Where a SignatureRequest goes once it leaves the SDK.