@provablehq/sdk 0.11.6 → 0.11.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mainnet/api-auth.d.cts +102 -0
- package/dist/mainnet/api-auth.d.ts +102 -0
- package/dist/mainnet/browser.cjs +273 -127
- package/dist/mainnet/browser.cjs.map +1 -1
- package/dist/mainnet/browser.d.cts +2 -1
- package/dist/mainnet/browser.d.ts +2 -1
- package/dist/mainnet/browser.js +271 -128
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/network-client.d.cts +10 -8
- package/dist/mainnet/network-client.d.ts +10 -8
- package/dist/mainnet/node.cjs +3 -0
- package/dist/mainnet/node.cjs.map +1 -1
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/program-manager.d.cts +2 -2
- package/dist/mainnet/program-manager.d.ts +2 -2
- package/dist/mainnet/record-scanner.d.cts +30 -19
- package/dist/mainnet/record-scanner.d.ts +30 -19
- package/dist/testnet/api-auth.d.cts +102 -0
- package/dist/testnet/api-auth.d.ts +102 -0
- package/dist/testnet/browser.cjs +273 -127
- package/dist/testnet/browser.cjs.map +1 -1
- package/dist/testnet/browser.d.cts +2 -1
- package/dist/testnet/browser.d.ts +2 -1
- package/dist/testnet/browser.js +271 -128
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/network-client.d.cts +10 -8
- package/dist/testnet/network-client.d.ts +10 -8
- package/dist/testnet/node.cjs +3 -0
- package/dist/testnet/node.cjs.map +1 -1
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/program-manager.d.cts +2 -2
- package/dist/testnet/program-manager.d.ts +2 -2
- package/dist/testnet/record-scanner.d.cts +30 -19
- package/dist/testnet/record-scanner.d.ts +30 -19
- package/package.json +2 -2
|
@@ -58,6 +58,7 @@ import { BaseFunctionKeyLocator, InvalidLocatorError, InvalidLocatorReason, KeyL
|
|
|
58
58
|
import { OfflineKeyProvider, OfflineSearchParams } from "./keys/provider/offline.js";
|
|
59
59
|
import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
|
|
60
60
|
import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./record-scanner.js";
|
|
61
|
+
import { ApiAuth, ApiAuthConfig, DEFAULT_API_KEY_HEADER, normalizeAuthConfig } from "./api-auth.js";
|
|
61
62
|
import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
|
|
62
63
|
import { generateHookData } from "./integrations/circle/hook-data.js";
|
|
63
64
|
declare function initializeWasm(): Promise<void>;
|
|
@@ -68,7 +69,7 @@ export type { LogLevel } from "./utils/logger.js";
|
|
|
68
69
|
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, DynamicRecord, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, QueryOption, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImportsBuilder, ProgramManager as ProgramManagerBase, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, stringToField, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, getMaxProgramImports, initThreadPool, getOrInitConsensusVersionTestHeights, setWasmLogLevel, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "./wasm.js";
|
|
69
70
|
export { initializeWasm };
|
|
70
71
|
export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
|
|
71
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
|
|
72
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, ApiAuth, ApiAuthConfig, DEFAULT_API_KEY_HEADER, normalizeAuthConfig, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
|
|
72
73
|
export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
|
|
73
74
|
export { encryptAuthorization, encryptProvingRequest, encryptSerializedProvingRequest, encryptViewKey, encryptRegistrationRequest, serializeProvingRequest, zeroizeBytes, } from "./security.js";
|
|
74
75
|
export { toField, toGroup, toViewKey, toSignature, toAddress, isViewKeyStrategy, isInputIdStrategy, isRecordViewKeyStrategy, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, } from "./external-signing.js";
|
|
@@ -58,6 +58,7 @@ import { BaseFunctionKeyLocator, InvalidLocatorError, InvalidLocatorReason, KeyL
|
|
|
58
58
|
import { OfflineKeyProvider, OfflineSearchParams } from "./keys/provider/offline.js";
|
|
59
59
|
import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
|
|
60
60
|
import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./record-scanner.js";
|
|
61
|
+
import { ApiAuth, ApiAuthConfig, DEFAULT_API_KEY_HEADER, normalizeAuthConfig } from "./api-auth.js";
|
|
61
62
|
import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
|
|
62
63
|
import { generateHookData } from "./integrations/circle/hook-data.js";
|
|
63
64
|
declare function initializeWasm(): Promise<void>;
|
|
@@ -68,7 +69,7 @@ export type { LogLevel } from "./utils/logger.js";
|
|
|
68
69
|
export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, DynamicRecord, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, QueryOption, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImportsBuilder, ProgramManager as ProgramManagerBase, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, stringToField, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, getMaxProgramImports, initThreadPool, getOrInitConsensusVersionTestHeights, setWasmLogLevel, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "./wasm.js";
|
|
69
70
|
export { initializeWasm };
|
|
70
71
|
export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
|
|
71
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
|
|
72
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, ApiAuth, ApiAuthConfig, DEFAULT_API_KEY_HEADER, normalizeAuthConfig, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
|
|
72
73
|
export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
|
|
73
74
|
export { encryptAuthorization, encryptProvingRequest, encryptSerializedProvingRequest, encryptViewKey, encryptRegistrationRequest, serializeProvingRequest, zeroizeBytes, } from "./security.js";
|
|
74
75
|
export { toField, toGroup, toViewKey, toSignature, toAddress, isViewKeyStrategy, isInputIdStrategy, isRecordViewKeyStrategy, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, } from "./external-signing.js";
|
package/dist/testnet/browser.js
CHANGED
|
@@ -1435,21 +1435,6 @@ async function retryWithBackoff(fn, { maxAttempts = 5, baseDelay = 100, jitter,
|
|
|
1435
1435
|
throw new Error("retryWithBackoff: unreachable");
|
|
1436
1436
|
}
|
|
1437
1437
|
|
|
1438
|
-
/** Type guard: value is a ProvingResponse. */
|
|
1439
|
-
function isProvingResponse(value) {
|
|
1440
|
-
return (typeof value === "object" &&
|
|
1441
|
-
value !== null &&
|
|
1442
|
-
"transaction" in value &&
|
|
1443
|
-
"broadcast_result" in value &&
|
|
1444
|
-
typeof value.broadcast_result === "object");
|
|
1445
|
-
}
|
|
1446
|
-
/** Type guard: value is a ProveApiErrorBody. */
|
|
1447
|
-
function isProveApiErrorBody(value) {
|
|
1448
|
-
return (typeof value === "object" &&
|
|
1449
|
-
value !== null &&
|
|
1450
|
-
"message" in value);
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
1438
|
const KEY_STORE = Metadata.baseUrl();
|
|
1454
1439
|
function convert(metadata) {
|
|
1455
1440
|
// This looks up the method name in VerifyingKey
|
|
@@ -1550,6 +1535,165 @@ const RECORD_DOMAIN = "RecordScannerV0";
|
|
|
1550
1535
|
const ZERO_ADDRESS = "aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc";
|
|
1551
1536
|
const FIVE_MINUTES = 5 * 60 * 1000; // 5 minutes in milliseconds
|
|
1552
1537
|
|
|
1538
|
+
/** Default header carrying a provisioned API key (e.g. edge.provable.com). */
|
|
1539
|
+
const DEFAULT_API_KEY_HEADER = "X-API-Key";
|
|
1540
|
+
/**
|
|
1541
|
+
* Normalize legacy auth options into an explicit {@link ApiAuthConfig}.
|
|
1542
|
+
*
|
|
1543
|
+
* Rules, preserving the pre-mode behavior of both clients:
|
|
1544
|
+
* - An explicit `auth` wins. Combining it with legacy fields throws — the caller's intent
|
|
1545
|
+
* is ambiguous and guessing hides misconfiguration.
|
|
1546
|
+
* - A string `apiKey` (with or without `consumerId`) or a bare `jwtData` selects `jwt` mode.
|
|
1547
|
+
* - An `{ header, value }` apiKey selects `api-key` mode with that header. Combining it with
|
|
1548
|
+
* a `consumerId` throws: keyed auth has no consumer and the pair would silently pick one.
|
|
1549
|
+
* - Nothing configured selects `none`.
|
|
1550
|
+
*/
|
|
1551
|
+
function normalizeAuthConfig(options) {
|
|
1552
|
+
if (options.auth) {
|
|
1553
|
+
if (options.apiKey !== undefined || options.consumerId !== undefined || options.jwtData !== undefined) {
|
|
1554
|
+
throw new Error("Pass either `auth` or the legacy apiKey/consumerId/jwtData options, not both");
|
|
1555
|
+
}
|
|
1556
|
+
validateKeyed(options.auth);
|
|
1557
|
+
return options.auth;
|
|
1558
|
+
}
|
|
1559
|
+
if (typeof options.apiKey === "object" && options.apiKey !== null) {
|
|
1560
|
+
if (options.consumerId !== undefined) {
|
|
1561
|
+
throw new Error("A custom-header apiKey cannot be combined with consumerId — keyed auth has no consumer. Use a string apiKey for JWT auth.");
|
|
1562
|
+
}
|
|
1563
|
+
const config = { mode: "api-key", value: options.apiKey.value, header: options.apiKey.header };
|
|
1564
|
+
validateKeyed(config);
|
|
1565
|
+
return config;
|
|
1566
|
+
}
|
|
1567
|
+
if (options.apiKey !== undefined || options.consumerId !== undefined || options.jwtData !== undefined) {
|
|
1568
|
+
return { mode: "jwt", apiKey: options.apiKey, consumerId: options.consumerId, jwtData: options.jwtData };
|
|
1569
|
+
}
|
|
1570
|
+
return { mode: "none" };
|
|
1571
|
+
}
|
|
1572
|
+
/**
|
|
1573
|
+
* Rejects api-key configurations that would emit an empty or nameless header.
|
|
1574
|
+
*
|
|
1575
|
+
* @param config Any auth configuration; only the api-key mode has anything to check.
|
|
1576
|
+
* @throws When the key value is empty, or a custom header name is given but empty.
|
|
1577
|
+
*/
|
|
1578
|
+
function validateKeyed(config) {
|
|
1579
|
+
if (config.mode !== "api-key")
|
|
1580
|
+
return;
|
|
1581
|
+
if (!config.value) {
|
|
1582
|
+
throw new Error("api-key auth mode requires a key value. Keys are provisioned, not registered — supply one.");
|
|
1583
|
+
}
|
|
1584
|
+
if (config.header !== undefined && !config.header) {
|
|
1585
|
+
throw new Error("api-key auth header must be a non-empty header name when given.");
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* ApiAuth resolves the auth headers each request must carry, owning the JWT mint/refresh
|
|
1590
|
+
* lifecycle in `jwt` mode. Share one instance across clients that use the same credentials so
|
|
1591
|
+
* only one minter exists and concurrent refreshes are deduplicated.
|
|
1592
|
+
*/
|
|
1593
|
+
class ApiAuth {
|
|
1594
|
+
config;
|
|
1595
|
+
baseUrl;
|
|
1596
|
+
transport;
|
|
1597
|
+
jwtData;
|
|
1598
|
+
inFlight;
|
|
1599
|
+
warned = false;
|
|
1600
|
+
mintHeaders;
|
|
1601
|
+
/**
|
|
1602
|
+
* @param {ApiAuthConfig} config The auth mode and its material.
|
|
1603
|
+
* @param {string} baseUrl API root origin; `/jwts/{consumerId}` lives here in `jwt` mode.
|
|
1604
|
+
* @param {TransportFunction} transport Transport used for the JWT mint request.
|
|
1605
|
+
* @param {Record<string, string>} [mintHeaders] Extra headers on the mint request (e.g. SDK telemetry).
|
|
1606
|
+
*/
|
|
1607
|
+
constructor(config, baseUrl, transport = defaultTransport, mintHeaders = {}) {
|
|
1608
|
+
this.config = config;
|
|
1609
|
+
this.baseUrl = baseUrl;
|
|
1610
|
+
this.transport = transport;
|
|
1611
|
+
this.mintHeaders = mintHeaders;
|
|
1612
|
+
if (config.mode === "jwt")
|
|
1613
|
+
this.jwtData = config.jwtData;
|
|
1614
|
+
}
|
|
1615
|
+
/** The mode this instance authenticates with. */
|
|
1616
|
+
get mode() {
|
|
1617
|
+
return this.config.mode;
|
|
1618
|
+
}
|
|
1619
|
+
/** Replace the stored JWT, e.g. one minted elsewhere. Only meaningful in `jwt` mode. */
|
|
1620
|
+
setJwtData(jwtData) {
|
|
1621
|
+
this.jwtData = jwtData;
|
|
1622
|
+
}
|
|
1623
|
+
/** The stored JWT, when one exists. */
|
|
1624
|
+
getJwtData() {
|
|
1625
|
+
return this.jwtData;
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* The auth headers a request must carry, refreshing the JWT first when it is stale and a
|
|
1629
|
+
* refresh is possible. Returns an empty object in `none` mode or when `jwt` mode lacks
|
|
1630
|
+
* both a usable token and the material to mint one.
|
|
1631
|
+
*/
|
|
1632
|
+
async headers() {
|
|
1633
|
+
if (this.config.mode === "none")
|
|
1634
|
+
return {};
|
|
1635
|
+
if (this.config.mode === "api-key") {
|
|
1636
|
+
return { [this.config.header ?? DEFAULT_API_KEY_HEADER]: this.config.value };
|
|
1637
|
+
}
|
|
1638
|
+
const stale = !this.jwtData || Date.now() >= this.jwtData.expiration - FIVE_MINUTES;
|
|
1639
|
+
if (stale) {
|
|
1640
|
+
const { apiKey, consumerId } = this.config;
|
|
1641
|
+
if (apiKey && consumerId) {
|
|
1642
|
+
this.inFlight ??= this.refreshJwt(apiKey, consumerId).finally(() => {
|
|
1643
|
+
this.inFlight = undefined;
|
|
1644
|
+
});
|
|
1645
|
+
this.jwtData = await this.inFlight;
|
|
1646
|
+
}
|
|
1647
|
+
else if (!this.jwtData && !this.warned) {
|
|
1648
|
+
this.warned = true;
|
|
1649
|
+
logger.warn("JWT or both apiKey and consumerId are required when using the Provable API");
|
|
1650
|
+
}
|
|
1651
|
+
// A stale JWT that cannot be refreshed is still sent: the server is the
|
|
1652
|
+
// authority on expiry and rejecting locally would break long-lived callers.
|
|
1653
|
+
}
|
|
1654
|
+
return this.jwtData?.jwt ? { Authorization: this.jwtData.jwt } : {};
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Refreshes the JWT by making a POST request to /jwts/{consumer_id}.
|
|
1658
|
+
*
|
|
1659
|
+
* @param {string} apiKey The API key to use for the refresh request.
|
|
1660
|
+
* @param {string} consumerId The consumer ID for the JWT endpoint.
|
|
1661
|
+
* @returns {Promise<JWTData>} The new JWT data.
|
|
1662
|
+
*/
|
|
1663
|
+
async refreshJwt(apiKey, consumerId) {
|
|
1664
|
+
const response = await post(`${this.baseUrl}/jwts/${consumerId}`, {
|
|
1665
|
+
headers: {
|
|
1666
|
+
...this.mintHeaders,
|
|
1667
|
+
"X-Provable-API-Key": apiKey,
|
|
1668
|
+
},
|
|
1669
|
+
}, this.transport);
|
|
1670
|
+
const authHeader = response.headers.get("authorization");
|
|
1671
|
+
if (!authHeader) {
|
|
1672
|
+
throw new Error("No authorization header in JWT refresh response");
|
|
1673
|
+
}
|
|
1674
|
+
const body = await response.json();
|
|
1675
|
+
return {
|
|
1676
|
+
jwt: authHeader,
|
|
1677
|
+
expiration: body.exp * 1000, // Convert to milliseconds
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
/** Type guard: value is a ProvingResponse. */
|
|
1683
|
+
function isProvingResponse(value) {
|
|
1684
|
+
return (typeof value === "object" &&
|
|
1685
|
+
value !== null &&
|
|
1686
|
+
"transaction" in value &&
|
|
1687
|
+
"broadcast_result" in value &&
|
|
1688
|
+
typeof value.broadcast_result === "object");
|
|
1689
|
+
}
|
|
1690
|
+
/** Type guard: value is a ProveApiErrorBody. */
|
|
1691
|
+
function isProveApiErrorBody(value) {
|
|
1692
|
+
return (typeof value === "object" &&
|
|
1693
|
+
value !== null &&
|
|
1694
|
+
"message" in value);
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1553
1697
|
const HEADERS = new Set([
|
|
1554
1698
|
"x-aleo-sdk-version",
|
|
1555
1699
|
"x-aleo-environment",
|
|
@@ -1580,9 +1724,13 @@ class AleoNetworkClient {
|
|
|
1580
1724
|
network;
|
|
1581
1725
|
transport;
|
|
1582
1726
|
hasCustomTransport;
|
|
1727
|
+
auth;
|
|
1583
1728
|
apiKey;
|
|
1584
1729
|
consumerId;
|
|
1585
1730
|
jwtData;
|
|
1731
|
+
// The consumer the cached jwtData was minted for, so the cache is never
|
|
1732
|
+
// reused for a different identity on a shared client.
|
|
1733
|
+
jwtConsumerId;
|
|
1586
1734
|
proverUri;
|
|
1587
1735
|
recordScannerUri;
|
|
1588
1736
|
constructor(host, options) {
|
|
@@ -1602,7 +1750,7 @@ class AleoNetworkClient {
|
|
|
1602
1750
|
else {
|
|
1603
1751
|
this.headers = {
|
|
1604
1752
|
// This is replaced by the actual version by a Rollup plugin
|
|
1605
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1753
|
+
"X-Aleo-SDK-Version": "0.11.8",
|
|
1606
1754
|
"X-Aleo-environment": environment(),
|
|
1607
1755
|
};
|
|
1608
1756
|
}
|
|
@@ -1614,11 +1762,17 @@ class AleoNetworkClient {
|
|
|
1614
1762
|
if (options.recordScannerUri) {
|
|
1615
1763
|
this.recordScannerUri = options.recordScannerUri + "/testnet";
|
|
1616
1764
|
}
|
|
1765
|
+
// If an explicit auth mode was specified, validate and set it, so a
|
|
1766
|
+
// bad key fails here rather than on the first proving request.
|
|
1767
|
+
if (options.auth) {
|
|
1768
|
+
normalizeAuthConfig({ auth: options.auth });
|
|
1769
|
+
this.auth = options.auth;
|
|
1770
|
+
}
|
|
1617
1771
|
}
|
|
1618
1772
|
else {
|
|
1619
1773
|
this.headers = {
|
|
1620
1774
|
// This is replaced by the actual version by a Rollup plugin
|
|
1621
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1775
|
+
"X-Aleo-SDK-Version": "0.11.8",
|
|
1622
1776
|
"X-Aleo-environment": environment(),
|
|
1623
1777
|
};
|
|
1624
1778
|
}
|
|
@@ -3052,33 +3206,6 @@ class AleoNetworkClient {
|
|
|
3052
3206
|
throw new Error(`Error posting solution: No response received: ${error.message}`);
|
|
3053
3207
|
}
|
|
3054
3208
|
}
|
|
3055
|
-
/**
|
|
3056
|
-
* Refreshes the JWT by making a POST request to /jwts/{consumer_id}
|
|
3057
|
-
*
|
|
3058
|
-
* @param {string} apiKey - The API key for authentication.
|
|
3059
|
-
* @param {string} consumerId - The consumer ID associated with the API key.
|
|
3060
|
-
* @returns {Promise<JwtData>} The JWT token and expiration time
|
|
3061
|
-
*/
|
|
3062
|
-
async refreshJwt(apiKey, consumerId) {
|
|
3063
|
-
if (!apiKey || !consumerId) {
|
|
3064
|
-
throw new Error('API key and consumer ID are required to refresh JWT');
|
|
3065
|
-
}
|
|
3066
|
-
const response = await post(`${this.baseUrl}/jwts/${consumerId}`, {
|
|
3067
|
-
headers: {
|
|
3068
|
-
...this.method("refreshJwt"),
|
|
3069
|
-
'X-Provable-API-Key': apiKey,
|
|
3070
|
-
}
|
|
3071
|
-
}, this.transport);
|
|
3072
|
-
const authHeader = response.headers.get('authorization');
|
|
3073
|
-
if (!authHeader) {
|
|
3074
|
-
throw new Error('No authorization header in JWT refresh response');
|
|
3075
|
-
}
|
|
3076
|
-
const body = await response.json();
|
|
3077
|
-
return {
|
|
3078
|
-
jwt: authHeader,
|
|
3079
|
-
expiration: body.exp * 1000 // Convert to milliseconds
|
|
3080
|
-
};
|
|
3081
|
-
}
|
|
3082
3209
|
/**
|
|
3083
3210
|
* Parses a /prove/authorization or /prove/request response. Returns a result object (never throws for 200/400/500/503).
|
|
3084
3211
|
*/
|
|
@@ -3141,31 +3268,40 @@ class AleoNetworkClient {
|
|
|
3141
3268
|
async submitProvingRequestSafe(options) {
|
|
3142
3269
|
// Attempt to get the Prover URI first from the options, then from any configured globally, or third try the main configured host.
|
|
3143
3270
|
const proverUri = (options.url ?? this.proverUri) ?? this.host;
|
|
3144
|
-
//
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
const
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3271
|
+
// Resolve the auth mode: per-request, then client-wide, then the legacy fields.
|
|
3272
|
+
// Mixing an explicit per-request auth with per-request legacy fields is
|
|
3273
|
+
// ambiguous, so it throws — matching normalizeAuthConfig and RecordScanner.
|
|
3274
|
+
if (options.auth && (options.apiKey !== undefined || options.consumerId !== undefined || options.jwtData !== undefined)) {
|
|
3275
|
+
throw new Error("Pass either `auth` or the legacy apiKey/consumerId/jwtData options, not both");
|
|
3276
|
+
}
|
|
3277
|
+
const config = options.auth ?? this.auth ?? normalizeAuthConfig({
|
|
3278
|
+
apiKey: options.apiKey ?? this.apiKey,
|
|
3279
|
+
consumerId: options.consumerId ?? this.consumerId,
|
|
3280
|
+
jwtData: options.jwtData ?? this.jwtData,
|
|
3281
|
+
});
|
|
3282
|
+
const auth = new ApiAuth(config, this.baseUrl, this.transport, this.method("refreshJwt"));
|
|
3283
|
+
// Seed the cached token so an explicit jwt config reuses it until the
|
|
3284
|
+
// refresh window instead of minting on every request — but only for the
|
|
3285
|
+
// consumer that minted it, so per-request credentials on a shared
|
|
3286
|
+
// client never ride another identity's token.
|
|
3287
|
+
if (config.mode === "jwt" && !config.jwtData && this.jwtData && config.consumerId === this.jwtConsumerId) {
|
|
3288
|
+
auth.setJwtData(this.jwtData);
|
|
3289
|
+
}
|
|
3290
|
+
// Resolves the auth headers, which refreshes the JWT when it is stale. Runs before
|
|
3291
|
+
// parsing the proving request so JWT refresh errors propagate as they always have.
|
|
3292
|
+
const authHeaders = await auth.headers();
|
|
3293
|
+
const jwtData = auth.getJwtData();
|
|
3294
|
+
if (config.mode === "jwt" && jwtData) {
|
|
3295
|
+
this.jwtData = jwtData;
|
|
3296
|
+
this.jwtConsumerId = config.consumerId;
|
|
3297
|
+
options.jwtData = jwtData;
|
|
3160
3298
|
}
|
|
3161
3299
|
// Create the necessary headers to hit the provable api.
|
|
3162
3300
|
const headers = {
|
|
3163
3301
|
...this.method("submitProvingRequest"),
|
|
3164
3302
|
"Content-Type": "application/json",
|
|
3303
|
+
...authHeaders,
|
|
3165
3304
|
};
|
|
3166
|
-
if (jwtData?.jwt) {
|
|
3167
|
-
headers["Authorization"] = jwtData.jwt;
|
|
3168
|
-
}
|
|
3169
3305
|
// Send the proving request encrypted (libsodium-compatible sealed box).
|
|
3170
3306
|
// Used by both `/prove/authorization` (Authorization variant) and
|
|
3171
3307
|
// `/prove/request` (Request variant). The legacy plaintext `/prove`
|
|
@@ -4718,9 +4854,10 @@ class RecordScanner {
|
|
|
4718
4854
|
cacheViewKeysOnRegister;
|
|
4719
4855
|
url;
|
|
4720
4856
|
baseUrl;
|
|
4721
|
-
|
|
4857
|
+
auth;
|
|
4858
|
+
explicitAuth;
|
|
4859
|
+
legacyApiKey;
|
|
4722
4860
|
consumerId;
|
|
4723
|
-
jwtData;
|
|
4724
4861
|
uuid;
|
|
4725
4862
|
viewKeys;
|
|
4726
4863
|
autoReRegister;
|
|
@@ -4757,23 +4894,71 @@ class RecordScanner {
|
|
|
4757
4894
|
// Add the view key to the scanner's view keys.
|
|
4758
4895
|
this.addViewKey(this.account.viewKey());
|
|
4759
4896
|
}
|
|
4760
|
-
// Configure authentication options.
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4897
|
+
// Configure authentication options. Validated up front so an explicit
|
|
4898
|
+
// auth combined with the legacy fields throws instead of the legacy key
|
|
4899
|
+
// leaking onto requests the explicit mode should own.
|
|
4900
|
+
normalizeAuthConfig(options);
|
|
4901
|
+
this.explicitAuth = options.auth;
|
|
4902
|
+
this.legacyApiKey = options.apiKey;
|
|
4765
4903
|
this.consumerId = options.consumerId;
|
|
4766
|
-
this.
|
|
4904
|
+
this.auth = this.buildAuth(options.jwtData);
|
|
4767
4905
|
this.autoReRegister = options.autoReRegister;
|
|
4768
4906
|
this.decryptEnabled = options.decryptEnabled;
|
|
4769
4907
|
}
|
|
4908
|
+
/**
|
|
4909
|
+
* Builds the ApiAuth for the current auth configuration. An explicit `auth` option wins;
|
|
4910
|
+
* the legacy apiKey/consumerId fields normalize onto a mode otherwise.
|
|
4911
|
+
*
|
|
4912
|
+
* @param {RecordScannerJWTData} [jwtData] JWT to carry into the rebuilt auth.
|
|
4913
|
+
* @returns {ApiAuth} The auth for the current configuration.
|
|
4914
|
+
*/
|
|
4915
|
+
buildAuth(jwtData) {
|
|
4916
|
+
const config = this.explicitAuth ?? normalizeAuthConfig({
|
|
4917
|
+
apiKey: this.legacyApiKey,
|
|
4918
|
+
consumerId: this.consumerId,
|
|
4919
|
+
jwtData,
|
|
4920
|
+
});
|
|
4921
|
+
const auth = new ApiAuth(config, this.baseUrl, this.transport);
|
|
4922
|
+
if (jwtData)
|
|
4923
|
+
auth.setJwtData(jwtData);
|
|
4924
|
+
return auth;
|
|
4925
|
+
}
|
|
4926
|
+
/**
|
|
4927
|
+
* Legacy raw-key header echoed on every request alongside the mode's own headers, matching
|
|
4928
|
+
* the pre-mode wire behavior when the legacy apiKey option is used.
|
|
4929
|
+
*
|
|
4930
|
+
* @returns {{ header: string, value: string } | undefined} The raw key header, when a legacy apiKey is set.
|
|
4931
|
+
*/
|
|
4932
|
+
rawKeyHeader() {
|
|
4933
|
+
if (this.legacyApiKey === undefined)
|
|
4934
|
+
return undefined;
|
|
4935
|
+
return typeof this.legacyApiKey === "string"
|
|
4936
|
+
? { header: "X-Provable-API-Key", value: this.legacyApiKey }
|
|
4937
|
+
: this.legacyApiKey;
|
|
4938
|
+
}
|
|
4770
4939
|
/**
|
|
4771
4940
|
* Set the API key to use for the record scanner.
|
|
4772
4941
|
*
|
|
4773
4942
|
* @param {string | { header: string, value: string }} apiKey The API key to use for the record scanner.
|
|
4774
4943
|
*/
|
|
4775
4944
|
setApiKey(apiKey) {
|
|
4776
|
-
this.
|
|
4945
|
+
if (this.explicitAuth) {
|
|
4946
|
+
throw new Error("This scanner uses an explicit auth mode — replace it with setAuth instead of the legacy setApiKey");
|
|
4947
|
+
}
|
|
4948
|
+
this.legacyApiKey = apiKey;
|
|
4949
|
+
this.auth = this.buildAuth(this.auth.getJwtData());
|
|
4950
|
+
}
|
|
4951
|
+
/**
|
|
4952
|
+
* Set the explicit auth mode, replacing any legacy apiKey/consumerId configuration.
|
|
4953
|
+
*
|
|
4954
|
+
* @param {ApiAuthConfig} auth The auth mode and its material.
|
|
4955
|
+
*/
|
|
4956
|
+
setAuth(auth) {
|
|
4957
|
+
normalizeAuthConfig({ auth });
|
|
4958
|
+
this.explicitAuth = auth;
|
|
4959
|
+
this.legacyApiKey = undefined;
|
|
4960
|
+
this.consumerId = undefined;
|
|
4961
|
+
this.auth = this.buildAuth();
|
|
4777
4962
|
}
|
|
4778
4963
|
/**
|
|
4779
4964
|
* Set the consumer ID used for JWT refresh when using authenticated record scanner (e.g. Provable API).
|
|
@@ -4781,7 +4966,11 @@ class RecordScanner {
|
|
|
4781
4966
|
* @param {string} consumerId The consumer ID to use for JWT refresh.
|
|
4782
4967
|
*/
|
|
4783
4968
|
setConsumerId(consumerId) {
|
|
4969
|
+
if (this.explicitAuth) {
|
|
4970
|
+
throw new Error("This scanner uses an explicit auth mode — replace it with setAuth instead of the legacy setConsumerId");
|
|
4971
|
+
}
|
|
4784
4972
|
this.consumerId = consumerId;
|
|
4973
|
+
this.auth = this.buildAuth(this.auth.getJwtData());
|
|
4785
4974
|
}
|
|
4786
4975
|
/**
|
|
4787
4976
|
* Set JWT data for authentication. Optional; when not set, JWT can be refreshed from apiKey + consumerId if provided.
|
|
@@ -4789,7 +4978,7 @@ class RecordScanner {
|
|
|
4789
4978
|
* @param {RecordScannerJWTData | undefined} jwtData The JWT data to use, or undefined to clear.
|
|
4790
4979
|
*/
|
|
4791
4980
|
setJwtData(jwtData) {
|
|
4792
|
-
this.jwtData
|
|
4981
|
+
this.auth.setJwtData(jwtData);
|
|
4793
4982
|
}
|
|
4794
4983
|
/**
|
|
4795
4984
|
* Set whether /owned should automatically re-register on 422 (when a view key for the UUID is in viewKeys or account) and retry once.
|
|
@@ -4862,54 +5051,6 @@ class RecordScanner {
|
|
|
4862
5051
|
this.removeViewKey(this.computeUUID(existingVk).toString());
|
|
4863
5052
|
}
|
|
4864
5053
|
}
|
|
4865
|
-
/**
|
|
4866
|
-
* Refreshes the JWT by making a POST request to /jwts/{consumer_id}. Used when authentication is required.
|
|
4867
|
-
*
|
|
4868
|
-
* @param {string} apiKey The API key to use for the refresh request.
|
|
4869
|
-
* @param {string} consumerId The consumer ID for the JWT endpoint.
|
|
4870
|
-
* @returns {Promise<RecordScannerJWTData>} The new JWT data.
|
|
4871
|
-
*/
|
|
4872
|
-
async refreshJwt(apiKey, consumerId) {
|
|
4873
|
-
const response = await post(`${this.baseUrl}/jwts/${consumerId}`, {
|
|
4874
|
-
headers: {
|
|
4875
|
-
"X-Provable-API-Key": apiKey,
|
|
4876
|
-
},
|
|
4877
|
-
}, this.transport);
|
|
4878
|
-
const authHeader = response.headers.get("authorization");
|
|
4879
|
-
if (!authHeader) {
|
|
4880
|
-
throw new Error("No authorization header in JWT refresh response");
|
|
4881
|
-
}
|
|
4882
|
-
const body = await response.json();
|
|
4883
|
-
return {
|
|
4884
|
-
jwt: authHeader,
|
|
4885
|
-
expiration: body.exp * 1000, // Convert to milliseconds
|
|
4886
|
-
};
|
|
4887
|
-
}
|
|
4888
|
-
/**
|
|
4889
|
-
* Returns auth headers (e.g. Authorization with JWT). Refreshes JWT if expired and apiKey + consumerId are set. Empty when auth is not configured.
|
|
4890
|
-
*
|
|
4891
|
-
* @returns {Promise<Record<string, string>>} Auth headers to add to requests, or empty object when not configured.
|
|
4892
|
-
*/
|
|
4893
|
-
async getAuthHeaders() {
|
|
4894
|
-
let jwtData = this.jwtData;
|
|
4895
|
-
// Consider JWT expired a few minutes early to avoid race at boundary.
|
|
4896
|
-
const isExpired = jwtData && Date.now() >= jwtData.expiration - FIVE_MINUTES;
|
|
4897
|
-
if (!jwtData || isExpired) {
|
|
4898
|
-
const apiKey = this.apiKey?.value;
|
|
4899
|
-
if (apiKey && this.consumerId) {
|
|
4900
|
-
jwtData = await this.refreshJwt(apiKey, this.consumerId);
|
|
4901
|
-
this.jwtData = jwtData;
|
|
4902
|
-
}
|
|
4903
|
-
else if (jwtData?.jwt) {
|
|
4904
|
-
// Use existing JWT even if expired when refresh is not possible.
|
|
4905
|
-
return { Authorization: jwtData.jwt };
|
|
4906
|
-
}
|
|
4907
|
-
else {
|
|
4908
|
-
return {};
|
|
4909
|
-
}
|
|
4910
|
-
}
|
|
4911
|
-
return jwtData?.jwt ? { Authorization: jwtData.jwt } : {};
|
|
4912
|
-
}
|
|
4913
5054
|
/**
|
|
4914
5055
|
* Set the UUID for the record scanner.
|
|
4915
5056
|
*
|
|
@@ -5414,13 +5555,15 @@ class RecordScanner {
|
|
|
5414
5555
|
*/
|
|
5415
5556
|
async request(req) {
|
|
5416
5557
|
try {
|
|
5417
|
-
// Attach
|
|
5418
|
-
const authHeaders = await this.
|
|
5558
|
+
// Attach the mode's auth headers before sending.
|
|
5559
|
+
const authHeaders = await this.auth.headers();
|
|
5419
5560
|
for (const [key, value] of Object.entries(authHeaders)) {
|
|
5420
5561
|
req.headers.set(key, value);
|
|
5421
5562
|
}
|
|
5422
|
-
|
|
5423
|
-
|
|
5563
|
+
// Legacy apiKey callers also got their raw key echoed on every request.
|
|
5564
|
+
const rawKey = this.rawKeyHeader();
|
|
5565
|
+
if (rawKey) {
|
|
5566
|
+
req.headers.set(rawKey.header, rawKey.value);
|
|
5424
5567
|
}
|
|
5425
5568
|
const body = req.body ? await req.text() : undefined;
|
|
5426
5569
|
const plainHeaders = {};
|
|
@@ -8700,7 +8843,7 @@ class ProgramManager {
|
|
|
8700
8843
|
* import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
8701
8844
|
*
|
|
8702
8845
|
* // Initialize the development consensus heights in order to work with devnode.
|
|
8703
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17");
|
|
8846
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18");
|
|
8704
8847
|
*
|
|
8705
8848
|
* // Create a new NetworkClient and RecordProvider.
|
|
8706
8849
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -8827,7 +8970,7 @@ class ProgramManager {
|
|
|
8827
8970
|
* import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
|
|
8828
8971
|
*
|
|
8829
8972
|
* // Initialize the development consensus heights in order to work with a local devnode.
|
|
8830
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17");
|
|
8973
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18");
|
|
8831
8974
|
*
|
|
8832
8975
|
* // Create a new NetworkClient, and RecordProvider
|
|
8833
8976
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -9373,5 +9516,5 @@ async function initializeWasm() {
|
|
|
9373
9516
|
logger.warn("initializeWasm is deprecated, you no longer need to use it");
|
|
9374
9517
|
}
|
|
9375
9518
|
|
|
9376
|
-
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PreparedProgram, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, cookieAffinityTransport, defaultTransport, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptSerializedProvingRequest, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, programChecksum, provingKeyLocator, serializeProvingRequest, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
|
|
9519
|
+
export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, ApiAuth, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DEFAULT_API_KEY_HEADER, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PreparedProgram, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, cookieAffinityTransport, defaultTransport, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptSerializedProvingRequest, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, normalizeAuthConfig, programChecksum, provingKeyLocator, serializeProvingRequest, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
|
|
9377
9520
|
//# sourceMappingURL=browser.js.map
|