@16x/webphone-sdk 3.1.10 → 3.2.0

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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 老平台坐席密码的解密:`seat/account/get` 返回的 `password`(或 `registerPassword`)
3
+ * 是 **AES-128-CBC / Pkcs7 的密文,Base64 编码**,需要解密才有明文 SIP 密码。
4
+ *
5
+ * key/iv 各 16 字节,老平台是固定值(旧版 `ccbar.js` 里同样是硬编码),可用 options 覆盖。
6
+ * 在浏览器与 Node 里都能用(走 WebCrypto,无需额外依赖;需要安全上下文或 Node 18+)。
7
+ *
8
+ * 这里是**唯一实现**:`/legacy` 子入口的 `decryptSipPassword` 与 core 会话入口的兜底
9
+ * `tryDecryptSipTicket` 共用它,平台 AES 细节不多写一份。
10
+ */
11
+ export interface DecryptSipPasswordOptions {
12
+ /** AES key(16 字节,UTF-8),默认用老平台内置值 */
13
+ key?: string;
14
+ /** AES iv(16 字节,UTF-8),默认用老平台内置值 */
15
+ iv?: string;
16
+ /** 解密实现所用的 WebCrypto(测试可注入),默认全局 crypto.subtle */
17
+ subtle?: SubtleCrypto;
18
+ }
19
+ /**
20
+ * 解出 SIP 密码明文。
21
+ *
22
+ * ```ts
23
+ * import { decryptSipPassword } from '@16x/webphone-sdk/legacy';
24
+ *
25
+ * const res = await fetch(`${host}/openapi/token/v1/seat/account/get`, { method: 'POST', headers: { Authorization: token }, body: '{}' });
26
+ * const { data } = await res.json();
27
+ * const password = await decryptSipPassword(data.password); // 明文 SIP 密码
28
+ * ```
29
+ *
30
+ * 失败时抛 `CCBarError`:可读原因在 `error.cause` 上(密文为空 / 不是合法 Base64 / 解密失败)。
31
+ */
32
+ export declare function decryptSipPassword(cipherText: string, options?: DecryptSipPasswordOptions): Promise<string>;
33
+ /**
34
+ * 会话入口的兜底:值看着就是老平台密文时解出明文,否则返回 `undefined`(调用方保持原值)。
35
+ *
36
+ * **永不抛错** —— 判错了一定要退回原值,不能把接入方本来正确的会话搞坏。
37
+ * 判定条件收得很紧,避免把明文密码误当密文(见 `looksLikeCipher`/`looksLikePlainText`):
38
+ * 合法 Base64、长度是 4 的倍数、解出来是 16 字节的整数倍、AES 解出的文本没有替换符与控制字符。
39
+ */
40
+ export declare function tryDecryptSipTicket(ticket: string, options?: DecryptSipPasswordOptions): Promise<string | undefined>;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Diagnostics-x4G0ho6W.cjs"),t=require("../redact-Bq26pObO.cjs");require("../createJsSipFactory-Dr8HbLl-.cjs"),exports.Diagnostics=e.t,exports.RingBuffer=e.n,exports.diagnosticsVersion=e.r,exports.redactText=t.t,exports.redactValue=t.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Diagnostics-DF_5kd8L.cjs"),t=require("../redact-Bq26pObO.cjs");require("../createJsSipFactory-B1ORbJiP.cjs"),exports.Diagnostics=e.t,exports.RingBuffer=e.n,exports.diagnosticsVersion=e.r,exports.redactText=t.t,exports.redactValue=t.n;
@@ -1,3 +1,3 @@
1
- import { n as e, r as t, t as n } from "../Diagnostics-WkQagE6_.js";
1
+ import { n as e, r as t, t as n } from "../Diagnostics-8hQAQglO.js";
2
2
  import { n as r, t as i } from "../redact-DB3CMbsK.js";
3
3
  export { n as Diagnostics, e as RingBuffer, t as diagnosticsVersion, i as redactText, r as redactValue };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./SharedWorkerProtocol-39dch6xL.cjs"),t=require("./CCBarClient-z-TFUjTB.cjs"),n=require("./Diagnostics-x4G0ho6W.cjs"),r=require("./redact-Bq26pObO.cjs");require("./diagnostics/index.cjs"),require("./createJsSipFactory-Dr8HbLl-.cjs");function i(e){if(e.code!==`OK`)throw TypeError(`Unexpected session response code: ${e.code}`);if(e.data===void 0||e.data===null)throw TypeError(`Unexpected session response: missing data`);return e.data}function a(e={}){return{version:`0.1.0`,options:e}}var o=`0.1.0`;exports.CCBarCall=t.o,exports.CCBarClient=t.t,exports.CCBarError=e.i,exports.CallManager=t.a,exports.CallStateError=t.s,exports.Diagnostics=n.t,exports.RingBuffer=n.n,exports.TypedEventBus=t.f,exports.assertCallTransition=t.c,exports.canTransition=t.l,exports.createSdk=a,exports.createSharedWorkerSelection=t.n,exports.diagnosticsVersion=n.r,exports.parseSessionResponse=i,exports.redactText=r.t,exports.redactValue=r.n,exports.resolveWorkerUrl=t.r,exports.transition=t.u,exports.transitions=t.d,exports.version=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./SharedWorkerProtocol-39dch6xL.cjs"),t=require("./legacySessionProvider-BPVOuiwr.cjs"),n=require("./Diagnostics-DF_5kd8L.cjs"),r=require("./redact-Bq26pObO.cjs");require("./diagnostics/index.cjs"),require("./createJsSipFactory-B1ORbJiP.cjs");function i(e){if(e.code!==`OK`)throw TypeError(`Unexpected session response code: ${e.code}`);if(e.data===void 0||e.data===null)throw TypeError(`Unexpected session response: missing data`);return e.data}function a(e={}){return{version:`0.1.0`,options:e}}var o=`0.1.0`;exports.CCBarCall=t.c,exports.CCBarClient=t.r,exports.CCBarError=e.i,exports.CallManager=t.s,exports.CallStateError=t.l,exports.Diagnostics=n.t,exports.RingBuffer=n.n,exports.TypedEventBus=t.m,exports.assertCallTransition=t.u,exports.canTransition=t.d,exports.createSdk=a,exports.createSharedWorkerSelection=t.i,exports.createTokenSessionProvider=t.n,exports.diagnosticsVersion=n.r,exports.parseSessionResponse=i,exports.redactText=r.t,exports.redactValue=r.n,exports.resolveWorkerUrl=t.a,exports.transition=t.f,exports.transitions=t.p,exports.version=o;
package/dist/index.d.ts CHANGED
@@ -17,3 +17,4 @@ export * from './core/CallManager.js';
17
17
  export * from './core/CCBarClient.js';
18
18
  export * from './diagnostics/index.js';
19
19
  export * from './shared/SharedWorkerFactory.js';
20
+ export { createTokenSessionProvider, type TokenSessionProvider, type TokenSessionProviderOptions, type TokenSessionSeatAccount, type TokenSessionTokenResult, } from './legacy/legacySessionProvider.js';
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { i as e } from "./SharedWorkerProtocol-DKVQ5-po.js";
2
- import { a as t, c as n, d as r, f as i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./CCBarClient-Sr_zlDBu.js";
3
- import { n as f, r as p, t as m } from "./Diagnostics-WkQagE6_.js";
4
- import { n as h, t as g } from "./redact-DB3CMbsK.js";
2
+ import { a as t, c as n, d as r, f as i, i as a, l as o, m as s, n as c, p as l, r as u, s as d, u as f } from "./legacySessionProvider-D9q2coUM.js";
3
+ import { n as p, r as m, t as h } from "./Diagnostics-8hQAQglO.js";
4
+ import { n as g, t as _ } from "./redact-DB3CMbsK.js";
5
5
  import "./diagnostics/index.js";
6
6
  //#region src/api/contracts.ts
7
- function _(e) {
7
+ function v(e) {
8
8
  if (e.code !== "OK") throw TypeError(`Unexpected session response code: ${e.code}`);
9
9
  if (e.data === void 0 || e.data === null) throw TypeError("Unexpected session response: missing data");
10
10
  return e.data;
11
11
  }
12
12
  //#endregion
13
13
  //#region src/index.ts
14
- function v(e = {}) {
14
+ function y(e = {}) {
15
15
  return {
16
16
  version: "0.1.0",
17
17
  options: e
18
18
  };
19
19
  }
20
- var y = "0.1.0";
20
+ var b = "0.1.0";
21
21
  //#endregion
22
- export { s as CCBarCall, u as CCBarClient, e as CCBarError, t as CallManager, l as CallStateError, m as Diagnostics, f as RingBuffer, i as TypedEventBus, n as assertCallTransition, a as canTransition, v as createSdk, o as createSharedWorkerSelection, p as diagnosticsVersion, _ as parseSessionResponse, g as redactText, h as redactValue, c as resolveWorkerUrl, d as transition, r as transitions, y as version };
22
+ export { n as CCBarCall, u as CCBarClient, e as CCBarError, d as CallManager, o as CallStateError, h as Diagnostics, p as RingBuffer, s as TypedEventBus, f as assertCallTransition, r as canTransition, y as createSdk, a as createSharedWorkerSelection, c as createTokenSessionProvider, m as diagnosticsVersion, v as parseSessionResponse, _ as redactText, g as redactValue, t as resolveWorkerUrl, i as transition, l as transitions, b as version };