feat: add SMS Bower phone SMS provider
This commit is contained in:
@@ -1367,6 +1367,7 @@
|
||||
<option value="5sim">5sim</option>
|
||||
<option value="nexsms">NexSMS</option>
|
||||
<option value="madao">MaDao</option>
|
||||
<option value="sms-bower">SMS Bower</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="data-row" id="row-phone-sms-provider-order" style="display:none;">
|
||||
@@ -1377,6 +1378,7 @@
|
||||
<option value="5sim" selected>5sim</option>
|
||||
<option value="nexsms" selected>NexSMS</option>
|
||||
<option value="madao" selected>MaDao</option>
|
||||
<option value="sms-bower" selected>SMS Bower</option>
|
||||
</select>
|
||||
<div class="hero-sms-country-mainline">
|
||||
<div id="phone-sms-provider-order-menu-shell" class="hero-sms-country-menu">
|
||||
@@ -1534,6 +1536,16 @@
|
||||
<input type="text" id="input-nex-sms-service-code" class="data-input mono"
|
||||
placeholder="ot" />
|
||||
</div>
|
||||
<div class="data-row" id="row-sms-bower-api-key" style="display:none;">
|
||||
<span class="data-label">SMS Bower</span>
|
||||
<div class="input-with-icon">
|
||||
<input type="password" id="input-sms-bower-api-key" class="data-input data-input-with-icon mono"
|
||||
placeholder="只需填写 SMS Bower API Token" />
|
||||
<button id="btn-toggle-sms-bower-api-key" class="input-icon-btn" type="button"
|
||||
data-password-toggle="input-sms-bower-api-key" data-show-label="显示 SMS Bower Token"
|
||||
data-hide-label="隐藏 SMS Bower Token" aria-label="显示 SMS Bower Token" title="显示 SMS Bower Token"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="data-row" id="row-madao-base-url" style="display:none;">
|
||||
<span class="data-label">MaDao 地址</span>
|
||||
<input type="text" id="input-madao-base-url" class="data-input mono"
|
||||
@@ -1895,6 +1907,7 @@
|
||||
<script src="../phone-sms/providers/five-sim.js"></script>
|
||||
<script src="../phone-sms/providers/nexsms.js"></script>
|
||||
<script src="../phone-sms/providers/madao.js"></script>
|
||||
<script src="../phone-sms/providers/sms-bower.js"></script>
|
||||
<script src="../phone-sms/providers/registry.js"></script>
|
||||
<script src="../icloud-utils.js"></script>
|
||||
<script src="../mail-provider-utils.js"></script>
|
||||
|
||||
@@ -454,6 +454,7 @@ const rowNexSmsApiKey = document.getElementById('row-nex-sms-api-key');
|
||||
const rowNexSmsCountry = document.getElementById('row-nex-sms-country');
|
||||
const rowNexSmsCountryFallback = document.getElementById('row-nex-sms-country-fallback');
|
||||
const rowNexSmsServiceCode = document.getElementById('row-nex-sms-service-code');
|
||||
const rowSmsBowerApiKey = document.getElementById('row-sms-bower-api-key');
|
||||
const rowMaDaoBaseUrl = document.getElementById('row-madao-base-url');
|
||||
const rowMaDaoHttpSecret = document.getElementById('row-madao-http-secret');
|
||||
const rowMaDaoMode = document.getElementById('row-madao-mode');
|
||||
@@ -491,6 +492,8 @@ const inputFiveSimProduct = document.getElementById('input-five-sim-product');
|
||||
const inputNexSmsApiKey = document.getElementById('input-nex-sms-api-key');
|
||||
const btnToggleNexSmsApiKey = document.getElementById('btn-toggle-nex-sms-api-key');
|
||||
const inputNexSmsServiceCode = document.getElementById('input-nex-sms-service-code');
|
||||
const inputSmsBowerApiKey = document.getElementById('input-sms-bower-api-key');
|
||||
const btnToggleSmsBowerApiKey = document.getElementById('btn-toggle-sms-bower-api-key');
|
||||
const inputMaDaoBaseUrl = document.getElementById('input-madao-base-url');
|
||||
const inputMaDaoHttpSecret = document.getElementById('input-madao-http-secret');
|
||||
const btnToggleMaDaoHttpSecret = document.getElementById('btn-toggle-madao-http-secret');
|
||||
@@ -679,18 +682,22 @@ const PHONE_SMS_PROVIDER_FIVE_SIM = '5sim';
|
||||
const PHONE_SMS_PROVIDER_HERO_SMS = PHONE_SMS_PROVIDER_HERO;
|
||||
const PHONE_SMS_PROVIDER_NEXSMS = 'nexsms';
|
||||
const PHONE_SMS_PROVIDER_MADAO = 'madao';
|
||||
const PHONE_SMS_PROVIDER_SMS_BOWER = 'sms-bower';
|
||||
const DEFAULT_PHONE_SMS_PROVIDER = PHONE_SMS_PROVIDER_HERO;
|
||||
const DEFAULT_PHONE_SMS_PROVIDER_ORDER = Object.freeze([
|
||||
PHONE_SMS_PROVIDER_HERO,
|
||||
PHONE_SMS_PROVIDER_FIVE_SIM,
|
||||
PHONE_SMS_PROVIDER_NEXSMS,
|
||||
PHONE_SMS_PROVIDER_MADAO,
|
||||
PHONE_SMS_PROVIDER_SMS_BOWER,
|
||||
]);
|
||||
const DEFAULT_FIVE_SIM_COUNTRY_ORDER = Object.freeze(['thailand']);
|
||||
const DEFAULT_FIVE_SIM_OPERATOR = 'any';
|
||||
const DEFAULT_FIVE_SIM_PRODUCT = 'openai';
|
||||
const DEFAULT_NEX_SMS_COUNTRY_ORDER = Object.freeze([1]);
|
||||
const DEFAULT_NEX_SMS_SERVICE_CODE = 'ot';
|
||||
const DEFAULT_SMS_BOWER_COUNTRY_ORDER = Object.freeze([52]);
|
||||
const DEFAULT_SMS_BOWER_SERVICE_CODE = 'ot';
|
||||
const DEFAULT_MADAO_BASE_URL = 'http://127.0.0.1:7822';
|
||||
const MADAO_MODE_ROUTING_PLAN = 'routing_plan';
|
||||
const MADAO_MODE_DIRECT = 'direct';
|
||||
@@ -732,6 +739,11 @@ const PHONE_SMS_PROVIDER_UI_DESCRIPTORS = Object.freeze({
|
||||
'rowNexSmsServiceCode',
|
||||
]),
|
||||
}),
|
||||
[PHONE_SMS_PROVIDER_SMS_BOWER]: Object.freeze({
|
||||
rowKeys: Object.freeze([
|
||||
'rowSmsBowerApiKey',
|
||||
]),
|
||||
}),
|
||||
[PHONE_SMS_PROVIDER_MADAO]: Object.freeze({
|
||||
rowKeys: Object.freeze([
|
||||
'rowMaDaoBaseUrl',
|
||||
@@ -768,6 +780,7 @@ function getPhoneSmsProviderUiRowMap() {
|
||||
rowNexSmsCountry,
|
||||
rowNexSmsCountryFallback,
|
||||
rowNexSmsServiceCode,
|
||||
rowSmsBowerApiKey,
|
||||
rowMaDaoBaseUrl,
|
||||
rowMaDaoHttpSecret,
|
||||
rowMaDaoMode,
|
||||
@@ -4642,6 +4655,9 @@ function collectSettingsPayload() {
|
||||
const nexSmsApiKeyValue = typeof inputNexSmsApiKey !== 'undefined' && inputNexSmsApiKey
|
||||
? String(inputNexSmsApiKey.value || '')
|
||||
: String(latestState?.nexSmsApiKey || '');
|
||||
const smsBowerApiKeyValue = typeof inputSmsBowerApiKey !== 'undefined' && inputSmsBowerApiKey
|
||||
? String(inputSmsBowerApiKey.value || '')
|
||||
: String(latestState?.smsBowerApiKey || '');
|
||||
const maDaoBaseUrlValue = typeof inputMaDaoBaseUrl !== 'undefined' && inputMaDaoBaseUrl
|
||||
? normalizeMaDaoBaseUrlSafe(inputMaDaoBaseUrl.value || latestState?.madaoBaseUrl)
|
||||
: normalizeMaDaoBaseUrlSafe(latestState?.madaoBaseUrl);
|
||||
@@ -5287,6 +5303,7 @@ function collectSettingsPayload() {
|
||||
nexSmsApiKey: nexSmsApiKeyValue,
|
||||
nexSmsCountryOrder: nexSmsCountryOrderValue,
|
||||
nexSmsServiceCode: nexSmsServiceCodeValue,
|
||||
smsBowerApiKey: smsBowerApiKeyValue,
|
||||
madaoBaseUrl: maDaoBaseUrlValue,
|
||||
madaoHttpSecret: maDaoHttpSecretValue,
|
||||
madaoMode: maDaoModeValue,
|
||||
@@ -5426,6 +5443,9 @@ function normalizePhoneSmsProvider(value = '') {
|
||||
const maDaoProvider = typeof PHONE_SMS_PROVIDER_MADAO !== 'undefined'
|
||||
? PHONE_SMS_PROVIDER_MADAO
|
||||
: 'madao';
|
||||
const smsBowerProvider = typeof PHONE_SMS_PROVIDER_SMS_BOWER !== 'undefined'
|
||||
? PHONE_SMS_PROVIDER_SMS_BOWER
|
||||
: 'sms-bower';
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
if (normalized === PHONE_SMS_PROVIDER_FIVE_SIM) {
|
||||
return PHONE_SMS_PROVIDER_FIVE_SIM;
|
||||
@@ -5436,6 +5456,9 @@ function normalizePhoneSmsProvider(value = '') {
|
||||
if (normalized === maDaoProvider) {
|
||||
return maDaoProvider;
|
||||
}
|
||||
if (normalized === smsBowerProvider) {
|
||||
return smsBowerProvider;
|
||||
}
|
||||
return PHONE_SMS_PROVIDER_HERO_SMS;
|
||||
}
|
||||
function setPhoneSmsProviderSelectValue(provider) {
|
||||
@@ -5475,6 +5498,9 @@ function getPhoneSmsProviderLabel(provider = getSelectedPhoneSmsProvider()) {
|
||||
if (normalizedProvider === PHONE_SMS_PROVIDER_MADAO) {
|
||||
return 'MaDao';
|
||||
}
|
||||
if (normalizedProvider === PHONE_SMS_PROVIDER_SMS_BOWER) {
|
||||
return 'SMS Bower';
|
||||
}
|
||||
return 'HeroSMS';
|
||||
}
|
||||
|
||||
@@ -17772,6 +17798,9 @@ function applyPhoneSmsProviderFieldsToInputs(provider = getSelectedPhoneSmsProvi
|
||||
if (typeof inputNexSmsApiKey !== 'undefined' && inputNexSmsApiKey) {
|
||||
inputNexSmsApiKey.value = String(state?.nexSmsApiKey || '');
|
||||
}
|
||||
if (typeof inputSmsBowerApiKey !== 'undefined' && inputSmsBowerApiKey) {
|
||||
inputSmsBowerApiKey.value = String(state?.smsBowerApiKey || '');
|
||||
}
|
||||
if (typeof inputMaDaoBaseUrl !== 'undefined' && inputMaDaoBaseUrl) {
|
||||
inputMaDaoBaseUrl.value = normalizeMaDaoBaseUrlValue(state?.madaoBaseUrl);
|
||||
}
|
||||
@@ -19202,6 +19231,9 @@ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
if (message.payload.nexSmsApiKey !== undefined && inputNexSmsApiKey) {
|
||||
inputNexSmsApiKey.value = String(message.payload.nexSmsApiKey || '').trim();
|
||||
}
|
||||
if (message.payload.smsBowerApiKey !== undefined && inputSmsBowerApiKey) {
|
||||
inputSmsBowerApiKey.value = String(message.payload.smsBowerApiKey || '').trim();
|
||||
}
|
||||
if (message.payload.fiveSimCountryOrder !== undefined && typeof applyFiveSimCountrySelection === 'function') {
|
||||
applyFiveSimCountrySelection(
|
||||
Array.isArray(message.payload.fiveSimCountryOrder) ? message.payload.fiveSimCountryOrder : []
|
||||
|
||||
Reference in New Issue
Block a user