@layr-labs/ecloud-sdk 0.5.0-dev.3 → 1.0.0-dev.1
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/VERSION +2 -2
- package/dist/attest.cjs +31 -9
- package/dist/attest.cjs.map +1 -1
- package/dist/attest.d.cts +3 -2
- package/dist/attest.d.ts +3 -2
- package/dist/attest.js +31 -9
- package/dist/attest.js.map +1 -1
- package/dist/billing.cjs +46 -6
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +3 -1
- package/dist/billing.d.ts +3 -1
- package/dist/billing.js +46 -6
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +40 -6
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +4 -4
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +40 -6
- package/dist/browser.js.map +1 -1
- package/dist/{compute-Ckyn8ils.d.cts → compute-Bn6KcW3x.d.cts} +1 -1
- package/dist/{compute-Cnw6rwSB.d.ts → compute-Do2t0Fo8.d.ts} +1 -1
- package/dist/compute.cjs +8 -2
- package/dist/compute.cjs.map +1 -1
- package/dist/compute.d.cts +2 -2
- package/dist/compute.d.ts +2 -2
- package/dist/compute.js +8 -2
- package/dist/compute.js.map +1 -1
- package/dist/{helpers-DZL2bg9p.d.cts → helpers-BRamdfGn.d.ts} +5 -1
- package/dist/{helpers-Dj2ME5rp.d.ts → helpers-CfsfcGJO.d.cts} +5 -1
- package/dist/{index-U2vKBrry.d.cts → index-BbH7ZCIu.d.cts} +15 -1
- package/dist/{index-U2vKBrry.d.ts → index-BbH7ZCIu.d.ts} +15 -1
- package/dist/index.cjs +78 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +78 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as ComputeModule } from './compute-
|
|
2
|
-
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-
|
|
1
|
+
import { C as ComputeModule } from './compute-Bn6KcW3x.cjs';
|
|
2
|
+
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-Bn6KcW3x.cjs';
|
|
3
3
|
import { BillingModule } from './billing.cjs';
|
|
4
4
|
export { BillingModuleConfig, createBillingModule } from './billing.cjs';
|
|
5
5
|
import { WalletClient, PublicClient, Address, Hex } from 'viem';
|
|
6
6
|
export { AttestClient, AttestClientConfig, JwtProvider } from './attest.cjs';
|
|
7
|
-
import {
|
|
8
|
-
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as
|
|
9
|
-
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-
|
|
10
|
-
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams, an as DeployParams, E as EstimateBatchGasOptions, G as GeneratedKey, o as LoginRequest, p as LoginResult, q as LogsParams, a as SessionError, S as SessionInfo, b as SiweMessageParams, r as SiweMessageResult, ao as UpgradeParams, U as UserApiClient, t as addHexPrefix, ap as assertValidFilePath, u as assertValidImageReference, v as assertValidPrivateKey, w as checkERC7702Delegation, x as createSiweMessage, aq as createViemClients, y as estimateBatchGas, D as extractAppNameFromImage, F as generateNewPrivateKey, H as generateNonce, I as getAvailableEnvironments, K as getBillingEnvironmentConfig, M as getBuildType, N as getChainFromID, O as getComputeApiSession, P as getEnvironmentConfig, R as isEnvironmentAvailable, T as isMainnet, V as isSessionValid, W as isSiweMessageExpired, X as isSiweMessageNotYetValid, Y as isSubscriptionActive, $ as loginToComputeApi, a2 as logoutFromComputeApi, a3 as parseSiweMessage, a4 as sanitizeString, a5 as sanitizeURL, a6 as sanitizeXURL, a7 as stripHexPrefix, a8 as validateAppID, a9 as validateAppName, aa as validateCreateAppParams, ar as validateDeployParams, ab as validateDescription, as as validateFilePath, at as validateImagePath, ac as validateImageReference, ad as validateInstanceTypeSKU, ae as validateLogVisibility, af as validateLogsParams, ag as validatePrivateKeyFormat, au as validateResourceUsageMonitoring, ah as validateURL, av as validateUpgradeParams, ai as validateXURL } from './helpers-
|
|
7
|
+
import { V as PreparedDeploy, G as GasEstimate, E as EnvironmentConfig, H as Logger, q as DeployResult, Y as PreparedUpgrade, A as AppId } from './index-BbH7ZCIu.cjs';
|
|
8
|
+
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as CreditPurchaseResponse, n as DeployAppOpts, o as DeployOptions, p as DeployProgressCallback, r as DeployStep, s as DockerImageConfig, t as EstimateGasOptions, v as ExecuteDeployResult, x as ExecuteUpgradeResult, y as GasOpts, z as GetSubscriptionOptions, I as ImageDigestResult, L as LifecycleOpts, N as NoActiveSubscriptionResponse, P as ParsedEnvironment, J as PaymentIssueResponse, K as PaymentMethod, M as PaymentMethodsResponse, Q as PrepareDeployFromVerifiableBuildOpts, R as PrepareDeployOpts, T as PrepareUpgradeFromVerifiableBuildOpts, U as PrepareUpgradeOpts, X as PreparedDeployData, _ as PreparedUpgradeData, $ as ProductID, a0 as ProductSubscriptionResponse, a1 as Release, a3 as SequentialDeployResult, a4 as SubscribeResponse, a5 as SubscriptionLineItem, a6 as SubscriptionOpts, a7 as SubscriptionStatus, ab as UpgradeAppOpts, ac as calculateAppID, ae as estimateTransactionGas, aj as formatETH, al as getAllAppsByDeveloper, aC as getAppLatestReleaseBlockNumbers, am as getAppsByBillingAccount, ap as getBillingType, aD as getBlockTimestamps, as as logVisibility, at as noopLogger } from './index-BbH7ZCIu.cjs';
|
|
9
|
+
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-CfsfcGJO.cjs';
|
|
10
|
+
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams, an as DeployParams, E as EstimateBatchGasOptions, G as GeneratedKey, o as LoginRequest, p as LoginResult, q as LogsParams, a as SessionError, S as SessionInfo, b as SiweMessageParams, r as SiweMessageResult, ao as UpgradeParams, U as UserApiClient, t as addHexPrefix, ap as assertValidFilePath, u as assertValidImageReference, v as assertValidPrivateKey, w as checkERC7702Delegation, x as createSiweMessage, aq as createViemClients, y as estimateBatchGas, D as extractAppNameFromImage, F as generateNewPrivateKey, H as generateNonce, I as getAvailableEnvironments, K as getBillingEnvironmentConfig, M as getBuildType, N as getChainFromID, O as getComputeApiSession, P as getEnvironmentConfig, R as isEnvironmentAvailable, T as isMainnet, V as isSessionValid, W as isSiweMessageExpired, X as isSiweMessageNotYetValid, Y as isSubscriptionActive, $ as loginToComputeApi, a2 as logoutFromComputeApi, a3 as parseSiweMessage, a4 as sanitizeString, a5 as sanitizeURL, a6 as sanitizeXURL, a7 as stripHexPrefix, a8 as validateAppID, a9 as validateAppName, aa as validateCreateAppParams, ar as validateDeployParams, ab as validateDescription, as as validateFilePath, at as validateImagePath, ac as validateImageReference, ad as validateInstanceTypeSKU, ae as validateLogVisibility, af as validateLogsParams, ag as validatePrivateKeyFormat, au as validateResourceUsageMonitoring, ah as validateURL, av as validateUpgradeParams, ai as validateXURL } from './helpers-CfsfcGJO.cjs';
|
|
11
11
|
|
|
12
12
|
interface SubmitBuildRequest {
|
|
13
13
|
repoUrl: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { C as ComputeModule } from './compute-
|
|
2
|
-
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-
|
|
1
|
+
import { C as ComputeModule } from './compute-Do2t0Fo8.js';
|
|
2
|
+
export { a as ComputeModuleConfig, b as CreateAppOpts, L as LogsOptions, P as PRIMARY_LANGUAGES, S as SDKCreateAppOpts, c as createApp, d as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, g as encodeTerminateAppData, h as getAvailableTemplates, l as logs } from './compute-Do2t0Fo8.js';
|
|
3
3
|
import { BillingModule } from './billing.js';
|
|
4
4
|
export { BillingModuleConfig, createBillingModule } from './billing.js';
|
|
5
5
|
import { WalletClient, PublicClient, Address, Hex } from 'viem';
|
|
6
6
|
export { AttestClient, AttestClientConfig, JwtProvider } from './attest.js';
|
|
7
|
-
import {
|
|
8
|
-
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as
|
|
9
|
-
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-
|
|
10
|
-
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams, an as DeployParams, E as EstimateBatchGasOptions, G as GeneratedKey, o as LoginRequest, p as LoginResult, q as LogsParams, a as SessionError, S as SessionInfo, b as SiweMessageParams, r as SiweMessageResult, ao as UpgradeParams, U as UserApiClient, t as addHexPrefix, ap as assertValidFilePath, u as assertValidImageReference, v as assertValidPrivateKey, w as checkERC7702Delegation, x as createSiweMessage, aq as createViemClients, y as estimateBatchGas, D as extractAppNameFromImage, F as generateNewPrivateKey, H as generateNonce, I as getAvailableEnvironments, K as getBillingEnvironmentConfig, M as getBuildType, N as getChainFromID, O as getComputeApiSession, P as getEnvironmentConfig, R as isEnvironmentAvailable, T as isMainnet, V as isSessionValid, W as isSiweMessageExpired, X as isSiweMessageNotYetValid, Y as isSubscriptionActive, $ as loginToComputeApi, a2 as logoutFromComputeApi, a3 as parseSiweMessage, a4 as sanitizeString, a5 as sanitizeURL, a6 as sanitizeXURL, a7 as stripHexPrefix, a8 as validateAppID, a9 as validateAppName, aa as validateCreateAppParams, ar as validateDeployParams, ab as validateDescription, as as validateFilePath, at as validateImagePath, ac as validateImageReference, ad as validateInstanceTypeSKU, ae as validateLogVisibility, af as validateLogsParams, ag as validatePrivateKeyFormat, au as validateResourceUsageMonitoring, ah as validateURL, av as validateUpgradeParams, ai as validateXURL } from './helpers-
|
|
7
|
+
import { V as PreparedDeploy, G as GasEstimate, E as EnvironmentConfig, H as Logger, q as DeployResult, Y as PreparedUpgrade, A as AppId } from './index-BbH7ZCIu.js';
|
|
8
|
+
export { a as AlreadyActiveResponse, c as AppProfile, d as AppProfileResponse, e as AppRecord, f as BillingEnvironmentConfig, g as CancelResponse, h as CancelSuccessResponse, i as ChainID, j as CheckoutCreatedResponse, k as CreateSubscriptionOptions, l as CreateSubscriptionResponse, m as CreditPurchaseResponse, n as DeployAppOpts, o as DeployOptions, p as DeployProgressCallback, r as DeployStep, s as DockerImageConfig, t as EstimateGasOptions, v as ExecuteDeployResult, x as ExecuteUpgradeResult, y as GasOpts, z as GetSubscriptionOptions, I as ImageDigestResult, L as LifecycleOpts, N as NoActiveSubscriptionResponse, P as ParsedEnvironment, J as PaymentIssueResponse, K as PaymentMethod, M as PaymentMethodsResponse, Q as PrepareDeployFromVerifiableBuildOpts, R as PrepareDeployOpts, T as PrepareUpgradeFromVerifiableBuildOpts, U as PrepareUpgradeOpts, X as PreparedDeployData, _ as PreparedUpgradeData, $ as ProductID, a0 as ProductSubscriptionResponse, a1 as Release, a3 as SequentialDeployResult, a4 as SubscribeResponse, a5 as SubscriptionLineItem, a6 as SubscriptionOpts, a7 as SubscriptionStatus, ab as UpgradeAppOpts, ac as calculateAppID, ae as estimateTransactionGas, aj as formatETH, al as getAllAppsByDeveloper, aC as getAppLatestReleaseBlockNumbers, am as getAppsByBillingAccount, ap as getBillingType, aD as getBlockTimestamps, as as logVisibility, at as noopLogger } from './index-BbH7ZCIu.js';
|
|
9
|
+
import { L as LogVisibility, aj as ResourceUsageMonitoring } from './helpers-BRamdfGn.js';
|
|
10
|
+
export { A as AppInfo, d as AppMetrics, e as AppProfileInfo, ak as AppRelease, al as AppReleaseBuild, am as AppResponse, B as BillingApiClient, C as ComputeApiConfig, l as CreateAppParams, an as DeployParams, E as EstimateBatchGasOptions, G as GeneratedKey, o as LoginRequest, p as LoginResult, q as LogsParams, a as SessionError, S as SessionInfo, b as SiweMessageParams, r as SiweMessageResult, ao as UpgradeParams, U as UserApiClient, t as addHexPrefix, ap as assertValidFilePath, u as assertValidImageReference, v as assertValidPrivateKey, w as checkERC7702Delegation, x as createSiweMessage, aq as createViemClients, y as estimateBatchGas, D as extractAppNameFromImage, F as generateNewPrivateKey, H as generateNonce, I as getAvailableEnvironments, K as getBillingEnvironmentConfig, M as getBuildType, N as getChainFromID, O as getComputeApiSession, P as getEnvironmentConfig, R as isEnvironmentAvailable, T as isMainnet, V as isSessionValid, W as isSiweMessageExpired, X as isSiweMessageNotYetValid, Y as isSubscriptionActive, $ as loginToComputeApi, a2 as logoutFromComputeApi, a3 as parseSiweMessage, a4 as sanitizeString, a5 as sanitizeURL, a6 as sanitizeXURL, a7 as stripHexPrefix, a8 as validateAppID, a9 as validateAppName, aa as validateCreateAppParams, ar as validateDeployParams, ab as validateDescription, as as validateFilePath, at as validateImagePath, ac as validateImageReference, ad as validateInstanceTypeSKU, ae as validateLogVisibility, af as validateLogsParams, ag as validatePrivateKeyFormat, au as validateResourceUsageMonitoring, ah as validateURL, av as validateUpgradeParams, ai as validateXURL } from './helpers-BRamdfGn.js';
|
|
11
11
|
|
|
12
12
|
interface SubmitBuildRequest {
|
|
13
13
|
repoUrl: string;
|
package/dist/index.js
CHANGED
|
@@ -4837,7 +4837,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
|
4837
4837
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
4838
4838
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
4839
4839
|
function getDefaultClientId() {
|
|
4840
|
-
const version = true ? "0.
|
|
4840
|
+
const version = true ? "1.0.0-dev.1" : "0.0.0";
|
|
4841
4841
|
return `ecloud-sdk/v${version}`;
|
|
4842
4842
|
}
|
|
4843
4843
|
var UserApiClient = class {
|
|
@@ -5674,7 +5674,13 @@ function getEnvironmentConfig(environment, chainID) {
|
|
|
5674
5674
|
const resolvedChainID = chainID || (environment === "sepolia" || environment === "sepolia-dev" ? SEPOLIA_CHAIN_ID : MAINNET_CHAIN_ID);
|
|
5675
5675
|
return {
|
|
5676
5676
|
...env,
|
|
5677
|
-
chainID: BigInt(resolvedChainID)
|
|
5677
|
+
chainID: BigInt(resolvedChainID),
|
|
5678
|
+
...process.env.ECLOUD_USER_API_URL && {
|
|
5679
|
+
userApiServerURL: process.env.ECLOUD_USER_API_URL
|
|
5680
|
+
},
|
|
5681
|
+
...process.env.ECLOUD_RPC_URL && {
|
|
5682
|
+
defaultRPCURL: process.env.ECLOUD_RPC_URL
|
|
5683
|
+
}
|
|
5678
5684
|
};
|
|
5679
5685
|
}
|
|
5680
5686
|
function getBillingEnvironmentConfig(build) {
|
|
@@ -5682,7 +5688,12 @@ function getBillingEnvironmentConfig(build) {
|
|
|
5682
5688
|
if (!config) {
|
|
5683
5689
|
throw new Error(`Unknown billing environment: ${build}`);
|
|
5684
5690
|
}
|
|
5685
|
-
return
|
|
5691
|
+
return {
|
|
5692
|
+
...config,
|
|
5693
|
+
...process.env.ECLOUD_BILLING_API_URL && {
|
|
5694
|
+
billingApiServerURL: process.env.ECLOUD_BILLING_API_URL
|
|
5695
|
+
}
|
|
5696
|
+
};
|
|
5686
5697
|
}
|
|
5687
5698
|
function getBuildType() {
|
|
5688
5699
|
const buildTimeType = true ? "dev"?.toLowerCase() : void 0;
|
|
@@ -5987,6 +5998,20 @@ var BillingApiClient = class {
|
|
|
5987
5998
|
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
|
|
5988
5999
|
await this.makeAuthenticatedRequest(endpoint, "DELETE", productId);
|
|
5989
6000
|
}
|
|
6001
|
+
async getPaymentMethods() {
|
|
6002
|
+
const endpoint = `${this.config.billingApiServerURL}/v1/payment-methods`;
|
|
6003
|
+
const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
|
|
6004
|
+
return resp.json();
|
|
6005
|
+
}
|
|
6006
|
+
async purchaseCredits(amountCents, paymentMethodId) {
|
|
6007
|
+
const endpoint = `${this.config.billingApiServerURL}/v1/credits/purchase`;
|
|
6008
|
+
const body = { amountCents };
|
|
6009
|
+
if (paymentMethodId) {
|
|
6010
|
+
body.paymentMethodId = paymentMethodId;
|
|
6011
|
+
}
|
|
6012
|
+
const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", body);
|
|
6013
|
+
return resp.json();
|
|
6014
|
+
}
|
|
5990
6015
|
// ==========================================================================
|
|
5991
6016
|
// Internal Methods
|
|
5992
6017
|
// ==========================================================================
|
|
@@ -5996,10 +6021,19 @@ var BillingApiClient = class {
|
|
|
5996
6021
|
* Uses session auth if useSession is true, otherwise uses EIP-712 signature auth.
|
|
5997
6022
|
*/
|
|
5998
6023
|
async makeAuthenticatedRequest(url, method, productId, body) {
|
|
5999
|
-
if (this.
|
|
6000
|
-
|
|
6024
|
+
if (this.options.verbose) {
|
|
6025
|
+
console.debug(`[BillingAPI] ${method} ${url}`);
|
|
6026
|
+
}
|
|
6027
|
+
const resp = this.useSession ? await this.makeSessionAuthenticatedRequest(url, method, body) : await this.makeSignatureAuthenticatedRequest(url, method, productId, body);
|
|
6028
|
+
if (this.options.verbose) {
|
|
6029
|
+
const data = await resp.json();
|
|
6030
|
+
console.debug(`[BillingAPI] Response:`, JSON.stringify(data, null, 2));
|
|
6031
|
+
return {
|
|
6032
|
+
json: async () => data,
|
|
6033
|
+
text: async () => JSON.stringify(data)
|
|
6034
|
+
};
|
|
6001
6035
|
}
|
|
6002
|
-
return
|
|
6036
|
+
return resp;
|
|
6003
6037
|
}
|
|
6004
6038
|
/**
|
|
6005
6039
|
* Make a request using session-based authentication (cookies)
|
|
@@ -8188,7 +8222,7 @@ function createBillingModule(config) {
|
|
|
8188
8222
|
const address = walletClient.account.address;
|
|
8189
8223
|
const logger = getLogger(verbose);
|
|
8190
8224
|
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
8191
|
-
const billingApi = new BillingApiClient(billingEnvConfig, walletClient);
|
|
8225
|
+
const billingApi = new BillingApiClient(billingEnvConfig, walletClient, { verbose });
|
|
8192
8226
|
const environmentConfig = getEnvironmentConfig(environment);
|
|
8193
8227
|
const usdcCreditsAddress = environmentConfig.usdcCreditsAddress;
|
|
8194
8228
|
if (!usdcCreditsAddress) {
|
|
@@ -8352,6 +8386,12 @@ function createBillingModule(config) {
|
|
|
8352
8386
|
};
|
|
8353
8387
|
}
|
|
8354
8388
|
);
|
|
8389
|
+
},
|
|
8390
|
+
async getPaymentMethods() {
|
|
8391
|
+
return billingApi.getPaymentMethods();
|
|
8392
|
+
},
|
|
8393
|
+
async purchaseCredits(amountCents, paymentMethodId) {
|
|
8394
|
+
return billingApi.purchaseCredits(amountCents, paymentMethodId);
|
|
8355
8395
|
}
|
|
8356
8396
|
};
|
|
8357
8397
|
return module;
|
|
@@ -9169,7 +9209,10 @@ var AttestClient = class {
|
|
|
9169
9209
|
constructor(config) {
|
|
9170
9210
|
this.config = config;
|
|
9171
9211
|
}
|
|
9172
|
-
async attest() {
|
|
9212
|
+
async attest(extraData) {
|
|
9213
|
+
if (extraData && extraData.length > 1048576) {
|
|
9214
|
+
throw new Error(`extraData exceeds 1MB limit (${extraData.length} bytes)`);
|
|
9215
|
+
}
|
|
9173
9216
|
const { publicKey, privateKey } = generateKeyPairSync("rsa", {
|
|
9174
9217
|
modulusLength: 4096,
|
|
9175
9218
|
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
@@ -9177,8 +9220,8 @@ var AttestClient = class {
|
|
|
9177
9220
|
});
|
|
9178
9221
|
const challengeHash = createHash("sha256").update(CHALLENGE_PREFIX).update(NULL_BYTE).update(publicKey).digest();
|
|
9179
9222
|
const socketPath = this.config.socketPath ?? DEFAULT_SOCKET_PATH;
|
|
9180
|
-
const attestationBytes = await this.getAttestation(socketPath, challengeHash);
|
|
9181
|
-
const attestResponse = await this.postAttest(attestationBytes, publicKey);
|
|
9223
|
+
const attestationBytes = await this.getAttestation(socketPath, challengeHash, extraData);
|
|
9224
|
+
const attestResponse = await this.postAttest(attestationBytes, publicKey, extraData);
|
|
9182
9225
|
this.verifySignature(JSON.stringify(attestResponse.data), attestResponse.signature);
|
|
9183
9226
|
const rsaPrivateKey = await crypto.subtle.importKey(
|
|
9184
9227
|
"pkcs8",
|
|
@@ -9210,9 +9253,13 @@ var AttestClient = class {
|
|
|
9210
9253
|
throw new Error("KMS response signature verification failed");
|
|
9211
9254
|
}
|
|
9212
9255
|
}
|
|
9213
|
-
getAttestation(socketPath, challenge) {
|
|
9256
|
+
getAttestation(socketPath, challenge, extraData) {
|
|
9214
9257
|
return new Promise((resolve2, reject) => {
|
|
9215
|
-
const
|
|
9258
|
+
const requestBody = { challenge: challenge.toString("base64") };
|
|
9259
|
+
if (extraData && extraData.length > 0) {
|
|
9260
|
+
requestBody.extra_data = extraData.toString("base64");
|
|
9261
|
+
}
|
|
9262
|
+
const body = JSON.stringify(requestBody);
|
|
9216
9263
|
const req = http2.request(
|
|
9217
9264
|
{
|
|
9218
9265
|
socketPath,
|
|
@@ -9240,14 +9287,18 @@ var AttestClient = class {
|
|
|
9240
9287
|
req.end();
|
|
9241
9288
|
});
|
|
9242
9289
|
}
|
|
9243
|
-
async postAttest(attestationBytes, rsaPublicKey) {
|
|
9290
|
+
async postAttest(attestationBytes, rsaPublicKey, extraData) {
|
|
9244
9291
|
const url = `${this.config.kmsServerURL}/auth/attest`;
|
|
9245
|
-
const
|
|
9292
|
+
const requestBody = {
|
|
9246
9293
|
version: 3,
|
|
9247
9294
|
attestation: attestationBytes.toString("base64"),
|
|
9248
9295
|
rsaKey: rsaPublicKey,
|
|
9249
9296
|
audience: this.config.audience
|
|
9250
|
-
}
|
|
9297
|
+
};
|
|
9298
|
+
if (extraData && extraData.length > 0) {
|
|
9299
|
+
requestBody.extra_data = extraData.toString("base64");
|
|
9300
|
+
}
|
|
9301
|
+
const body = JSON.stringify(requestBody);
|
|
9251
9302
|
const response = await fetch(url, {
|
|
9252
9303
|
method: "POST",
|
|
9253
9304
|
headers: { "Content-Type": "application/json" },
|
|
@@ -9269,10 +9320,21 @@ function pemToBuffer(pem) {
|
|
|
9269
9320
|
// src/client/modules/attest/jwt-provider.ts
|
|
9270
9321
|
var JwtProvider = class {
|
|
9271
9322
|
constructor(attestClient, bufferSeconds = 30) {
|
|
9323
|
+
this.pendingExtraData = /* @__PURE__ */ new Map();
|
|
9272
9324
|
this.attestClient = attestClient;
|
|
9273
9325
|
this.bufferSeconds = bufferSeconds;
|
|
9274
9326
|
}
|
|
9275
|
-
async getToken() {
|
|
9327
|
+
async getToken(extraData) {
|
|
9328
|
+
if (extraData && extraData.length > 0) {
|
|
9329
|
+
const key = extraData.toString("hex");
|
|
9330
|
+
const existing = this.pendingExtraData.get(key);
|
|
9331
|
+
if (existing) return existing;
|
|
9332
|
+
const promise = this.attestClient.attest(extraData).finally(() => {
|
|
9333
|
+
this.pendingExtraData.delete(key);
|
|
9334
|
+
});
|
|
9335
|
+
this.pendingExtraData.set(key, promise);
|
|
9336
|
+
return promise;
|
|
9337
|
+
}
|
|
9276
9338
|
if (this.cachedToken && !this.isExpiringSoon()) {
|
|
9277
9339
|
return this.cachedToken;
|
|
9278
9340
|
}
|