@goodandready/dsh-subscriptions 0.5.2 → 0.5.3

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/lib/client.js CHANGED
@@ -32,7 +32,8 @@ window.__ModuleLoader__.load({
32
32
  '.dsub-mini{appearance:none;font:inherit;font-size:12px;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;padding:3px 8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);transition:all .15s}' +
33
33
  '.dsub-mini:hover{background:var(--dsw-alias-bg-layer-1);border-color:var(--dsw-alias-label-dimmed)}' +
34
34
  '.dsub-ok{font-size:12px;color:var(--dsw-alias-state-success-primary)}' +
35
- '.dsub-bad{font-size:12px;color:var(--dsw-alias-state-error-primary)}' +
35
+ '.dsub-bad{font-size:12px;color:var(--dsw-alias-state-error-primary);overflow-wrap:anywhere;word-break:break-word;max-width:100%}' +
36
+ '.dsub-hint{overflow-wrap:anywhere;word-break:break-word;max-width:100%}' +
36
37
  '.dsub-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:5px 12px;font-size:12.5px;font-weight:500;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);transition:all .15s}' +
37
38
  '.dsub-btn:hover{background:var(--dsw-alias-bg-layer-1);border-color:var(--dsw-alias-label-dimmed)}' +
38
39
  '.dsub-inp{height:30px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);border-radius:6px;padding:0 8px;font-size:12px;min-width:180px}' +
@@ -324,7 +325,24 @@ const cssId = 'dsh-subscriptions/settings.module.css'
324
325
  }
325
326
 
326
327
  // #51: live countdown to the quota window reset (account.quota.resetAt).
327
- function normalizePlanBadge(provider, plan) {
328
+ function cleanErrorMessage(raw) {
329
+ if (!raw) return ''
330
+ var text = typeof raw === 'string' ? raw : (raw.message || String(raw))
331
+ text = text.trim()
332
+ if (text.charAt(0) === '{' && text.charAt(text.length - 1) === '}') {
333
+ try {
334
+ var parsed = JSON.parse(text)
335
+ if (parsed.error && parsed.error.message) text = parsed.error.message
336
+ else if (parsed.message) text = parsed.message
337
+ else if (parsed.code) text = parsed.code
338
+ } catch (e) {}
339
+ }
340
+ var firstLine = text.split('\n')[0].trim()
341
+ if (firstLine.length > 160) return firstLine.slice(0, 157) + '...'
342
+ return firstLine
343
+ }
344
+
345
+ function normalizePlanBadge(provider, plan) {
328
346
  if (!plan && provider !== 'kimi' && provider !== 'glm') return null
329
347
  var p = String(plan || '').toLowerCase().replace(/[^a-z0-9]/g, '')
330
348
  var label = plan
@@ -623,7 +641,7 @@ const cssId = 'dsh-subscriptions/settings.module.css'
623
641
  })
624
642
  const data = await res.json().catch(() => ({}))
625
643
  setProxyRes((m) => Object.assign({}, m, { [key]: data }))
626
- } catch (e) { setErr(String(e.message || e)) }
644
+ } catch (e) { setErr(cleanErrorMessage(e.message || e)) }
627
645
  setChecking((c) => Object.assign({}, c, { ['proxy:' + key]: false }))
628
646
  }
629
647
 
@@ -643,7 +661,7 @@ const cssId = 'dsh-subscriptions/settings.module.css'
643
661
  if (data && data.quota) {
644
662
  setAccounts((prev) => prev.map((a) => a.provider===provider && a.index===index ? Object.assign({}, a, { quota: data.quota }) : a))
645
663
  }
646
- } catch (e) { setErr(String(e.message || e)) }
664
+ } catch (e) { setErr(cleanErrorMessage(e.message || e)) }
647
665
  setChecking((c) => Object.assign({}, c, { [key]: false }))
648
666
  }
649
667
 
@@ -767,21 +785,21 @@ const cssId = 'dsh-subscriptions/settings.module.css'
767
785
  normalizePlanBadge(row.slot.provider, account.plan || (account.quota && account.quota.plan)),
768
786
  React.createElement('button', {
769
787
  type: 'button', className: 'dsub-mini',
770
- onClick: () => connect(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
788
+ onClick: () => connect(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
771
789
  }, on ? t('reconnect') : t('connect')),
772
790
  (row.slot.provider === 'codex' ? React.createElement('button', {
773
791
  type: 'button', className: 'dsub-mini',
774
- onClick: () => deviceStartLogin(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
792
+ onClick: () => deviceStartLogin(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
775
793
  }, t('deviceLogin')) : null),
776
794
  React.createElement('button', {
777
795
  type: 'button', className: 'dsub-mini',
778
796
  disabled: !on,
779
- onClick: () => logout(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
797
+ onClick: () => logout(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
780
798
  }, t('disconnect')),
781
799
  React.createElement('button', {
782
800
  type: 'button', className: 'dsub-mini',
783
801
  disabled: checking[key],
784
- onClick: () => doCheck(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
802
+ onClick: () => doCheck(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
785
803
  }, checking[key] ? t('checking') : t('check')),
786
804
  React.createElement('button', {
787
805
  type: 'button', className: 'dsub-mini', title: t('removeSlot'),
@@ -789,7 +807,7 @@ const cssId = 'dsh-subscriptions/settings.module.css'
789
807
  const slot = row.slot
790
808
  Promise.resolve(on ? logout(slot.provider, slot.index) : null)
791
809
  .then(() => setSlots(slots.filter((_, k) => k !== row.i)))
792
- .catch((e) => setErr(String(e.message || e)))
810
+ .catch((e) => setErr(cleanErrorMessage(e.message || e)))
793
811
  },
794
812
  }, '\u00d7'),
795
813
  ),
@@ -804,7 +822,7 @@ const cssId = 'dsh-subscriptions/settings.module.css'
804
822
  }),
805
823
  React.createElement('button', {
806
824
  type: 'button', className: 'dsub-mini',
807
- onClick: () => complete(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
825
+ onClick: () => complete(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
808
826
  }, t('submitCode')),
809
827
  ),
810
828
  React.createElement('div', { className: 'dsub-row' },
@@ -816,12 +834,12 @@ const cssId = 'dsh-subscriptions/settings.module.css'
816
834
  }),
817
835
  React.createElement('button', {
818
836
  type: 'button', className: 'dsub-mini',
819
- onClick: () => importToken(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
837
+ onClick: () => importToken(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
820
838
  }, t('importToken')),
821
839
  React.createElement('button', {
822
840
  type: 'button', className: 'dsub-mini',
823
841
  title: t('importLocalCli'),
824
- onClick: () => importLocalCli(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
842
+ onClick: () => importLocalCli(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
825
843
  }, '📥 CLI'),
826
844
  ),
827
845
  React.createElement('div', { className: 'dsub-row' },
@@ -838,7 +856,7 @@ const cssId = 'dsh-subscriptions/settings.module.css'
838
856
  React.createElement('button', {
839
857
  type: 'button', className: 'dsub-mini',
840
858
  disabled: checking['proxy:' + key],
841
- onClick: () => doProxyCheck(row.slot.provider, row.slot.index).catch((e) => setErr(String(e.message || e))),
859
+ onClick: () => doProxyCheck(row.slot.provider, row.slot.index).catch((e) => setErr(cleanErrorMessage(e.message || e))),
842
860
  }, checking['proxy:' + key] ? '\u2026' : t('proxyCheck')),
843
861
  ),
844
862
  (function(){
@@ -984,7 +1002,7 @@ const cssId = 'dsh-subscriptions/settings.module.css'
984
1002
  React.createElement('div', { className: 'dsub-foot' },
985
1003
  React.createElement('button', {
986
1004
  type: 'button', className: 'dsub-save',
987
- onClick: () => save().catch((e) => setErr(String(e.message || e))),
1005
+ onClick: () => save().catch((e) => setErr(cleanErrorMessage(e.message || e))),
988
1006
  }, t('save')),
989
1007
  saved ? React.createElement('span', { className: 'dsub-ok' }, t('saved')) : null,
990
1008
  err ? React.createElement('span', { className: 'dsub-bad' }, err) : null,
package/lib/mask.js CHANGED
@@ -19,3 +19,22 @@ const EMAIL_RE = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g
19
19
  export function maskText(value) {
20
20
  return String(value || '').replace(EMAIL_RE, (m) => maskEmail(m))
21
21
  }
22
+
23
+ export function cleanErrorMessage(raw) {
24
+ if (!raw) return ''
25
+ let text = typeof raw === 'string' ? raw : (raw.message || String(raw))
26
+ text = text.trim()
27
+ if (text.startsWith('{') && text.endsWith('}')) {
28
+ try {
29
+ const parsed = JSON.parse(text)
30
+ if (parsed.error && parsed.error.message) text = parsed.error.message
31
+ else if (parsed.message) text = parsed.message
32
+ else if (parsed.code) text = parsed.code
33
+ } catch {}
34
+ }
35
+ const firstLine = text.split('\n')[0].trim()
36
+ if (firstLine.length > 160) {
37
+ return firstLine.slice(0, 157) + '...'
38
+ }
39
+ return firstLine
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-subscriptions",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Use ChatGPT Codex, Claude, Grok, and Antigravity subscriptions as DeepSeek Harness LLM providers via OAuth.",
5
5
  "license": "MIT",
6
6
  "type": "module",