Skip to content

Commit

Permalink
made nut22 opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
Egge21M committed Feb 3, 2025
1 parent ffb2475 commit 9199f00
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/CashuMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,23 @@ import { MintInfo } from './model/MintInfo.js';
class CashuMint {
private ws?: WSConnection;
private _mintInfo?: MintInfo;
private _authProofGetter?: () => Promise<string>;
private _checkNut22 = false;
/**
* @param _mintUrl requires mint URL to create this object
* @param _customRequest if passed, use custom request implementation for network communication with the mint
*/
constructor(
private _mintUrl: string,
private _customRequest?: typeof request,
private _authProofGetter?: () => Promise<string>
authProofGetter?: () => Promise<string>
) {
this._mintUrl = sanitizeUrl(_mintUrl);
this._customRequest = _customRequest;
if (authProofGetter) {
this._checkNut22 = true;
this._authProofGetter = authProofGetter;
}
}

get mintUrl() {
Expand Down Expand Up @@ -536,6 +542,9 @@ class CashuMint {
}

async handleBlindAuth() {
if (!this._checkNut22) {
return;
}
const info = await this.getLazyMintInfo();
if (info.requiresBlindAuthToken('/v1/swap')) {
if (!this._authProofGetter) {
Expand Down

0 comments on commit 9199f00

Please sign in to comment.