@qbraid-core/ibm-cloud
Version:
Client for interacting with IBM's Qiskit Runtime Service via the IBM Cloud API.
90 lines • 3.54 kB
JavaScript
;
// Copyright (c) 2025, qBraid Development Team
// All rights reserved.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.IBMConfigManager = exports.DEFAULT_IBM_CONFIG_PATH = void 0;
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const base_1 = require("@qbraid-core/base");
exports.DEFAULT_IBM_CONFIG_PATH = path.join(os.homedir(), '.qiskit', 'qiskit-ibm.json');
class IBMConfigManager extends base_1.ConfigManager {
// this field is not used in the config file, but is an option which can be used
// to authenticate with the IBM Quantum API. Needed if user provides it separately
bearerToken = '';
constructor(filePath) {
super(filePath ? filePath : exports.DEFAULT_IBM_CONFIG_PATH);
}
parseConfig(content) {
return JSON.parse(content);
}
stringifyConfig(config) {
return JSON.stringify(config);
}
getDefaultConfig() {
return {
'default-ibm-quantum-platform': {
// latest IBMQ channel, ibm_cloud will be deprecated soon
channel: 'ibm_quantum_platform',
// Loading account from environment variables
// Ref : https://github.com/Qiskit/qiskit-ibm-runtime/tree/main?tab=readme-ov-file#loading-account-from-environment-variables
instance: process.env.QISKIT_IBM_INSTANCE ?? '',
token: process.env.QISKIT_IBM_TOKEN ?? '',
private_endpoint: false,
url: 'https://cloud.ibm.com',
},
};
}
getApiKey() {
return this.config['default-ibm-quantum-platform'].token;
}
setApiKey(apiKey) {
this.config['default-ibm-quantum-platform'].token = apiKey;
}
getServiceCRN() {
return this.config['default-ibm-quantum-platform'].instance;
}
setServiceCRN(crn) {
this.config['default-ibm-quantum-platform'].instance = crn;
}
getBearerToken() {
return this.bearerToken;
}
setBearerToken(token) {
this.bearerToken = token;
}
}
exports.IBMConfigManager = IBMConfigManager;
//# sourceMappingURL=config.js.map