@de./sdk 2.0.0 → 2.1.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.
Files changed (43) hide show
  1. package/dist/allend/Access.js +22 -5
  2. package/dist/allend/Access.js.map +1 -1
  3. package/dist/allend/LSP/agents.d.ts +14 -1
  4. package/dist/allend/LSP/agents.js +38 -0
  5. package/dist/allend/LSP/agents.js.map +1 -1
  6. package/dist/allend/MSI/Handles.d.ts +10 -2
  7. package/dist/allend/MSI/Handles.js +11 -3
  8. package/dist/allend/MSI/Handles.js.map +1 -1
  9. package/dist/allend/MSI/index.d.ts +10 -0
  10. package/dist/allend/MSI/index.js +19 -0
  11. package/dist/allend/MSI/index.js.map +1 -1
  12. package/dist/allend/MSI/native.js +69 -35
  13. package/dist/allend/MSI/native.js.map +1 -1
  14. package/dist/allend/MSI/origin.d.ts +15 -0
  15. package/dist/allend/MSI/origin.js +25 -0
  16. package/dist/allend/MSI/origin.js.map +1 -0
  17. package/dist/allend/OTPAuth/index.d.ts +12 -18
  18. package/dist/allend/OTPAuth/index.js +17 -7
  19. package/dist/allend/OTPAuth/index.js.map +1 -1
  20. package/dist/baseUrl.d.ts +3 -5
  21. package/dist/baseUrl.js +3 -5
  22. package/dist/baseUrl.js.map +1 -1
  23. package/dist/core.d.ts +1 -0
  24. package/dist/core.js +3 -1
  25. package/dist/core.js.map +1 -1
  26. package/dist/response.d.ts +9 -0
  27. package/dist/response.js +42 -0
  28. package/dist/response.js.map +1 -0
  29. package/dist/utils/index.d.ts +14 -0
  30. package/dist/utils/index.js +24 -4
  31. package/dist/utils/index.js.map +1 -1
  32. package/package.json +13 -7
  33. package/src/allend/Access.ts +23 -4
  34. package/src/allend/LSP/agents.ts +46 -1
  35. package/src/allend/MSI/Handles.ts +12 -4
  36. package/src/allend/MSI/index.ts +20 -0
  37. package/src/allend/MSI/native.tsx +73 -34
  38. package/src/allend/MSI/origin.ts +20 -0
  39. package/src/allend/OTPAuth/index.ts +33 -25
  40. package/src/baseUrl.ts +3 -5
  41. package/src/core.ts +1 -0
  42. package/src/response.ts +38 -0
  43. package/src/utils/index.ts +27 -8
@@ -1,13 +1,17 @@
1
+ import type { SigninBody, CreateAccountBody } from '@de./types';
1
2
  import type { AccessOptions, UserSession } from '../../types/access';
2
3
  import AccessManager from '../Access';
3
4
  import { type Res } from '../../utils';
4
- export type SigninBody = {
5
- phone: string;
6
- /** Device fingerprint — an object or its JSON string. */
7
- device: string | Record<string, any>;
8
- /** ISO 3166-1 alpha-2. */
9
- country?: string;
10
- };
5
+ /**
6
+ * Request bodies come from `@de./types`, which is what de.auth validates
7
+ * against — these were hand-declared here, and said `country?: string` where
8
+ * de.auth wants the Country OBJECT. Its schema is additionalProperties:false,
9
+ * so a caller trusting the SDK's type was answered `body/country must be
10
+ * object`. Nothing caught it because this client could not be constructed at
11
+ * all: AccessManager demanded a workspace context and a bearer token, which
12
+ * sign-in is what produces.
13
+ */
14
+ export type { SigninBody, CreateAccountBody, VerificationBody, Country } from '@de./types';
11
15
  export type SigninResult = {
12
16
  /** What the caller must do next — verification, or account creation first. */
13
17
  next: string;
@@ -19,16 +23,6 @@ export type SigninResult = {
19
23
  */
20
24
  testVCode?: number;
21
25
  };
22
- export type CreateAccountBody = {
23
- phone: string;
24
- agreeTerms: boolean | string;
25
- firstName?: string;
26
- lastName?: string;
27
- photo?: string;
28
- type?: string;
29
- country?: string;
30
- newsletters?: boolean | string;
31
- };
32
26
  export type VerifyResult = {
33
27
  ctoken?: string;
34
28
  deviceId?: string;
@@ -51,7 +45,7 @@ export default class OTPAuth extends AccessManager {
51
45
  resendSms(body: {
52
46
  phone: string;
53
47
  }): Promise<Res<void>>;
54
- /** GET, with the scope in the querystring — not a POST. */
48
+ /** A state change, so a POST — it was a GET, which is cacheable. */
55
49
  signout(querystring?: {
56
50
  allDevices?: boolean | string;
57
51
  }): Promise<Res<void>>;
@@ -7,29 +7,39 @@ const Access_1 = __importDefault(require("../Access"));
7
7
  const utils_1 = require("../../utils");
8
8
  class OTPAuth extends Access_1.default {
9
9
  constructor(access) {
10
- super(access, 'ASI');
10
+ /**
11
+ * de.auth admits an agent that does not start with `De.service` only if
12
+ * the request carries an Authorization header — and the whole point of
13
+ * this client is the flow that has no token yet. The SDK's default
14
+ * platform is `proxy`, so every sign-in through it was answered 412
15
+ * before reaching a handler.
16
+ *
17
+ * `service` is the platform this client is for; a caller that knows
18
+ * better can still say so.
19
+ */
20
+ super({ ...access, platform: access.platform || 'service' }, 'ASI');
11
21
  }
12
22
  // ── Sign-in ───────────────────────────────────────────────────────────────
13
23
  /** Step 1 — sends the code. */
14
24
  async signin(body) {
15
25
  if (!body.phone)
16
26
  throw new Error('<phone> argument required');
17
- return this.request({ url: '/signin', method: 'POST', body });
27
+ return this.request({ url: '/auth/otp/send', method: 'POST', body });
18
28
  }
19
29
  /** Step 2 — exchanges the code for a session. */
20
30
  async verify(body) {
21
- return this.request({ url: '/verification', method: 'POST', body });
31
+ return this.request({ url: '/auth/otp/verify', method: 'POST', body });
22
32
  }
23
33
  /** Step 1a — for a phone de.auth has never seen. */
24
34
  async setAccount(body) {
25
- return this.request({ url: '/set-account', method: 'POST', body });
35
+ return this.request({ url: '/auth/account/create', method: 'POST', body });
26
36
  }
27
37
  async resendSms(body) {
28
- return this.request({ url: '/resend/sms', method: 'POST', body });
38
+ return this.request({ url: '/auth/otp/resend', method: 'POST', body });
29
39
  }
30
- /** GET, with the scope in the querystring — not a POST. */
40
+ /** A state change, so a POST — it was a GET, which is cacheable. */
31
41
  async signout(querystring) {
32
- return this.request({ url: `/signout${(0, utils_1.qs)(querystring)}`, method: 'GET' });
42
+ return this.request({ url: `/auth/session/revoke${(0, utils_1.qs)(querystring)}`, method: 'POST' });
33
43
  }
34
44
  // ── The signed-in person ──────────────────────────────────────────────────
35
45
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/allend/OTPAuth/index.ts"],"names":[],"mappings":";;;;;AACA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AAE,IAAI,EAAE,CAAC,CAAA;IACzE,CAAC;CACD;AAlFD,0BAkFC"}
package/dist/baseUrl.d.ts CHANGED
@@ -38,11 +38,9 @@ export declare const API_SERVER_BASEURL: {
38
38
  * It is not reachable through the API host: de.arch serves no `/workspace`
39
39
  * routes, so a client pointed there gets 404 for the whole surface.
40
40
  *
41
- * The staging and production hosts follow the naming of the other services
42
- * (auth.dedot.io, iot.dedot.io). Confirm them against the deployment before
43
- * relying on them, and pass `baseUrl` to address a host that differs — which
44
- * is also what a self-hosted De. needs, and what a dev machine running
45
- * de.workspace on a port other than 22200 needs.
41
+ * Pass `baseUrl` to address a host that differs — what a self-hosted De.
42
+ * needs, and what a dev machine running de.workspace on a port other than
43
+ * 22200 needs.
46
44
  */
47
45
  export declare const WSP_SERVER_BASEURL: {
48
46
  dev: string;
package/dist/baseUrl.js CHANGED
@@ -43,11 +43,9 @@ exports.API_SERVER_BASEURL = {
43
43
  * It is not reachable through the API host: de.arch serves no `/workspace`
44
44
  * routes, so a client pointed there gets 404 for the whole surface.
45
45
  *
46
- * The staging and production hosts follow the naming of the other services
47
- * (auth.dedot.io, iot.dedot.io). Confirm them against the deployment before
48
- * relying on them, and pass `baseUrl` to address a host that differs — which
49
- * is also what a self-hosted De. needs, and what a dev machine running
50
- * de.workspace on a port other than 22200 needs.
46
+ * Pass `baseUrl` to address a host that differs — what a self-hosted De.
47
+ * needs, and what a dev machine running de.workspace on a port other than
48
+ * 22200 needs.
51
49
  */
52
50
  exports.WSP_SERVER_BASEURL = {
53
51
  dev: `http://localhost:${DEV_PORTS.WSP}`,
@@ -1 +1 @@
1
- {"version":3,"file":"baseUrl.js","sourceRoot":"","sources":["../src/baseUrl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAoEH,0BAOC;AAzED,MAAM,SAAS,GAAG;IACjB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,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;;GAOG;AACH,SAAgB,OAAO,CAAE,MAAkB,EAAE,MAAiB,KAAK,EAAE,WAAoB;IACxF,MAAM,GAAG,GAAG,QAAQ,CAAE,MAAM,CAAE,CAAE,GAAG,CAAE,CAAA;IAErC,6EAA6E;IAC7E,OAAO,GAAG,KAAK,KAAK,IAAI,WAAW;QAC/B,CAAC,CAAC,UAAU,WAAW,IAAI,SAAS,CAAE,MAAM,CAAE,EAAE;QAChD,CAAC,CAAC,GAAG,CAAA;AACV,CAAC"}
package/dist/core.d.ts CHANGED
@@ -20,6 +20,7 @@ export { default as Workflows } from './allend/Workflows';
20
20
  export type { WorkflowsConfig } from './allend/Workflows';
21
21
  export { default as Utils } from './utils';
22
22
  export { default as APIError } from './error';
23
+ export { statusOf } from './response';
23
24
  export { default as IoTClient } from './allend/IoTClient';
24
25
  export type { IoTClientOptions } from './allend/IoTClient';
25
26
  export { default as Customer } from './allend/Customer';
package/dist/core.js CHANGED
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  return (mod && mod.__esModule) ? mod : { "default": mod };
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.core = exports.DClient = exports.Utilities = exports.Queries = exports.Agent = exports.Customer = exports.IoTClient = exports.APIError = exports.Utils = exports.Workflows = exports.Realtime = exports.Workspace = exports.IoTBackendRecords = exports.IoTSP = exports.DEV = exports.CSP = exports.LSP = exports.Pipelines = exports.Tracking = exports.OTPAuth = exports.Auth = void 0;
23
+ exports.core = exports.DClient = exports.Utilities = exports.Queries = exports.Agent = exports.Customer = exports.IoTClient = exports.statusOf = exports.APIError = exports.Utils = exports.Workflows = exports.Realtime = exports.Workspace = exports.IoTBackendRecords = exports.IoTSP = exports.DEV = exports.CSP = exports.LSP = exports.Pipelines = exports.Tracking = exports.OTPAuth = exports.Auth = void 0;
24
24
  // ── Named exports (preferred — tree-shakeable) ────────────────────────────────
25
25
  // Server-side auth: connector credentials → access token
26
26
  var Auth_1 = require("./backend/Auth");
@@ -56,6 +56,8 @@ var utils_1 = require("./utils");
56
56
  Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return __importDefault(utils_1).default; } });
57
57
  var error_1 = require("./error");
58
58
  Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return __importDefault(error_1).default; } });
59
+ var response_1 = require("./response");
60
+ Object.defineProperty(exports, "statusOf", { enumerable: true, get: function () { return response_1.statusOf; } });
59
61
  // ── Client layer (allend) ─────────────────────────────────────────────────────
60
62
  // DClient ({ Client, Event }), the IoT socket client, and the customer/agent/
61
63
  // query surfaces.
package/dist/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,WAAW;AACX,EAAE;AACF,0BAA0B;AAC1B,EAAE;AACF,mEAAmE;AACnE,sEAAsE;AACtE,EAAE;AACF,gFAAgF;;;;;;AAEhF,iFAAiF;AAEjF,yDAAyD;AACzD,uCAAgD;AAAvC,6GAAA,OAAO,OAAQ;AAGxB,yCAAyC;AACzC,4CAAqD;AAA5C,mHAAA,OAAO,OAAW;AAE3B,0CAA0C;AAC1C,8CAAuD;AAA9C,qHAAA,OAAO,OAAY;AAG5B,gDAAyD;AAAhD,uHAAA,OAAO,OAAa;AAG7B,oCAA6C;AAApC,2GAAA,OAAO,OAAO;AAGvB,oCAA6C;AAApC,2GAAA,OAAO,OAAO;AAGvB,oCAA6C;AAApC,2GAAA,OAAO,OAAO;AAGvB,qEAAqE;AACrE,wCAA+E;AAAtE,+GAAA,OAAO,OAAS;AAAE,0GAAA,OAAO,OAAqB;AAGvD,gDAAyD;AAAhD,uHAAA,OAAO,OAAa;AAG7B,4CAA4C;AAC5C,8CAAuD;AAA9C,qHAAA,OAAO,OAA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ememberStatus: (body: unknown, status: number) => void;
3
+ /**
4
+ * The HTTP status the given envelope arrived with.
5
+ *
6
+ * `undefined` when the object did not come from this SDK's transport, or when
7
+ * the call threw instead of returning — `APIError` carries its own `status`.
8
+ */
9
+ export declare const statusOf: (envelope: unknown) => number | undefined;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.statusOf = exports.rememberStatus = void 0;
4
+ /**
5
+ * The HTTP status a returned envelope arrived with.
6
+ *
7
+ * Clients return De.'s `{ error, status, message, data }` envelope, which is
8
+ * what makes `status` — the precise refusal code — reachable. It carries no
9
+ * HTTP status, and for most callers that is right: the envelope says more than
10
+ * a number can.
11
+ *
12
+ * A proxy is the exception. It answers its own client with an HTTP status, and
13
+ * mapping every De. refusal onto a generic 400 loses the distinction between
14
+ * "no such order" and "you may not do that" for whoever is downstream.
15
+ *
16
+ * So the status is kept beside the response rather than inside it: the type
17
+ * stays exactly the envelope, and a caller that needs the number asks for it,
18
+ * keyed on the object it was given. Keying on identity rather than on a
19
+ * mutable field is what makes it safe under concurrency — two calls in flight
20
+ * cannot read each other's status.
21
+ *
22
+ * ```ts
23
+ * const answer = await lsp.orders.get( reference )
24
+ * if( answer.error ) throw new HTTPException( statusOf( answer ) ?? 400, ... )
25
+ * ```
26
+ */
27
+ const statuses = new WeakMap();
28
+ /** Record the status for a parsed response body. Called by the transport. */
29
+ const rememberStatus = (body, status) => {
30
+ if (body && typeof body === 'object')
31
+ statuses.set(body, status);
32
+ };
33
+ exports.rememberStatus = rememberStatus;
34
+ /**
35
+ * The HTTP status the given envelope arrived with.
36
+ *
37
+ * `undefined` when the object did not come from this SDK's transport, or when
38
+ * the call threw instead of returning — `APIError` carries its own `status`.
39
+ */
40
+ const statusOf = (envelope) => envelope && typeof envelope === 'object' ? statuses.get(envelope) : undefined;
41
+ exports.statusOf = statusOf;
42
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAkB,CAAA;AAE9C,6EAA6E;AACtE,MAAM,cAAc,GAAG,CAAE,IAAa,EAAE,MAAc,EAAS,EAAE;IACvE,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAG,QAAQ,CAAC,GAAG,CAAE,IAAc,EAAE,MAAM,CAAE,CAAA;AAC9E,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B;AAED;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CAAE,QAAiB,EAAuB,EAAE,CACnE,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAE,QAAkB,CAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAD7E,QAAA,QAAQ,YACqE"}
@@ -23,6 +23,20 @@ export type Res<T = any> = {
23
23
  * property fails that test outright.
24
24
  */
25
25
  export type Data<T> = 'data' extends keyof T ? T['data'] : undefined;
26
+ /**
27
+ * Serialize a querystring for a De. route.
28
+ *
29
+ * Array values are appended as repeated keys — `state=A&state=B` — which is
30
+ * what Fastify's query parser turns back into an array. `String( value )` on
31
+ * an array produces `A,B`, a single comma-joined string, and the route answers
32
+ * `querystring/state must be array`: the schema is right, the request never
33
+ * matched it. Every array parameter the SDK sent was malformed this way, the
34
+ * same shape of fault as the coordinates object that once serialized to
35
+ * `[object Object]`.
36
+ *
37
+ * @param params - Query parameters; null and undefined values are dropped
38
+ * @return - `?a=1&b=2`, or an empty string when there is nothing to send
39
+ */
26
40
  export declare const qs: (params?: Record<string, any>) => string;
27
41
  declare const _default: {
28
42
  Stream: typeof Stream;
@@ -5,13 +5,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.qs = void 0;
7
7
  const stream_1 = __importDefault(require("./stream"));
8
+ /**
9
+ * Serialize a querystring for a De. route.
10
+ *
11
+ * Array values are appended as repeated keys — `state=A&state=B` — which is
12
+ * what Fastify's query parser turns back into an array. `String( value )` on
13
+ * an array produces `A,B`, a single comma-joined string, and the route answers
14
+ * `querystring/state must be array`: the schema is right, the request never
15
+ * matched it. Every array parameter the SDK sent was malformed this way, the
16
+ * same shape of fault as the coordinates object that once serialized to
17
+ * `[object Object]`.
18
+ *
19
+ * @param params - Query parameters; null and undefined values are dropped
20
+ * @return - `?a=1&b=2`, or an empty string when there is nothing to send
21
+ */
8
22
  const qs = (params) => {
9
23
  if (!params)
10
24
  return '';
11
- const q = new URLSearchParams(Object.fromEntries(Object.entries(params)
12
- .filter(([, v]) => v != null)
13
- .map(([k, v]) => [k, String(v)]))).toString();
14
- return q ? `?${q}` : '';
25
+ const q = new URLSearchParams();
26
+ for (const [key, value] of Object.entries(params)) {
27
+ if (value === null || value === undefined)
28
+ continue;
29
+ Array.isArray(value)
30
+ ? value.forEach(each => each !== null && each !== undefined && q.append(key, String(each)))
31
+ : q.append(key, String(value));
32
+ }
33
+ const query = q.toString();
34
+ return query ? `?${query}` : '';
15
35
  };
16
36
  exports.qs = qs;
17
37
  exports.default = { Stream: stream_1.default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;AACA,sDAA6B;AAsBtB,MAAM,EAAE,GAAG,CAAE,MAA4B,EAAW,EAAE;IAC3D,IAAI,CAAC,MAAM;QAAG,OAAO,EAAE,CAAA;IACvB,MAAM,CAAC,GAAG,IAAI,eAAe,CAC3B,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAE,MAAM,CAAE;SACjB,MAAM,CAAE,CAAE,CAAC,EAAE,CAAC,CAAC,EAAG,EAAE,CAAC,CAAC,IAAI,IAAI,CAAE;SAChC,GAAG,CAAE,CAAE,CAAC,CAAC,EAAE,CAAC,CAAC,E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AED,kBAAe,EAAE,MAAM,EAAN,gBAAM,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@de./sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Complete SDK pack for MSI (Map Service Interface), IoTClient and DClient services — web, server and React Native",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -41,12 +41,12 @@
41
41
  "test:event": "npm run build:tsc && jest test/event.test.js"
42
42
  },
43
43
  "dependencies": {
44
- "@de./types": "^2.0.0",
44
+ "@de./types": "^2.1.0",
45
45
  "events": "^3.3.0",
46
- "iframe.io": "^1.1.0",
46
+ "iframe.io": "^1.3.0",
47
47
  "node-fetch": "2.6.1",
48
48
  "socket.io-client": "^4.6.1",
49
- "webview.io": "^1.1.0"
49
+ "webview.io": "^1.2.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "react": ">=16.8.0",
@@ -54,9 +54,15 @@
54
54
  "react-native-webview": ">=11.0.0"
55
55
  },
56
56
  "peerDependenciesMeta": {
57
- "react": { "optional": true },
58
- "react-native": { "optional": true },
59
- "react-native-webview": { "optional": true }
57
+ "react": {
58
+ "optional": true
59
+ },
60
+ "react-native": {
61
+ "optional": true
62
+ },
63
+ "react-native-webview": {
64
+ "optional": true
65
+ }
60
66
  },
61
67
  "devDependencies": {
62
68
  "@babel/core": "^7.26.0",
@@ -2,6 +2,7 @@ import type { AccessOptions, UserSession } from '../types/access'
2
2
  import type { HTTPRequestOptions } from '../types'
3
3
  import { baseURL } from '../baseUrl'
4
4
  import APIError from '../error'
5
+ import { rememberStatus } from '../response'
5
6
 
6
7
  /**
7
8
  * Which service the client addresses.
@@ -55,10 +56,26 @@ export default class AccessManager {
55
56
 
56
57
  constructor( options: AccessOptions, atype: AccessType ){
57
58
  if( !options ) throw new Error('Undefined Access Configuration')
58
- if( !options.context ) throw new Error('Undefined Context Reference. Check https://doc.dedot.io/sdk/auth')
59
- if( !options.accessToken ) throw new Error('Undefined Access Token. Check https://doc.dedot.io/sdk/auth')
60
-
61
- this.context = options.context
59
+
60
+ /**
61
+ * A workspace context and a bearer token identify a CALLER to de.arch, and
62
+ * every API client needs both. de.auth answers a different question — who
63
+ * the PERSON is — and the sign-in flow is what produces a session in the
64
+ * first place: at `POST /auth/otp/send` there is no workspace to name and
65
+ * no token to bear.
66
+ *
67
+ * Requiring them of every access type meant `OTPAuth` threw in its own
68
+ * constructor and could never be used for the one thing it exists to do.
69
+ * That is why de.simulation's bootstrap and Hot's `getUser` both talk to
70
+ * de.auth over raw fetch, and why nothing ever caught that this client
71
+ * addressed `/v1/auth/otp` — a route de.auth has never served.
72
+ */
73
+ if( atype !== 'ASI' ){
74
+ if( !options.context ) throw new Error('Undefined Context Reference. Check https://doc.dedot.io/sdk/auth')
75
+ if( !options.accessToken ) throw new Error('Undefined Access Token. Check https://doc.dedot.io/sdk/auth')
76
+ }
77
+
78
+ this.context = options.context || ''
62
79
  this.atype = atype
63
80
  this.version = options.version || 1
64
81
  this.platform = options.platform || 'proxy'
@@ -168,6 +185,8 @@ export default class AccessManager {
168
185
  * look like a workspace being told no, which is precisely the bug that
169
186
  * hid `/LSP/invitation/agent` behind a plausible-looking failure.
170
187
  */
188
+ rememberStatus( body, response.status )
189
+
171
190
  if( typeof body?.error !== 'boolean' )
172
191
  throw new APIError(
173
192
  body?.message || `${options.method} ${url} — ${response.status} ${response.statusText || 'not a De. response'}`,
@@ -5,7 +5,10 @@ import type {
5
5
  LSPAgentUpdateValidation,
6
6
  LSPAgentAssignVehicleValidation,
7
7
  LSPAgentUnassignVehicleValidation,
8
- LSPAgentRemoveValidation
8
+ LSPAgentRemoveValidation,
9
+ LSPAgentEnrolValidation,
10
+ LSPAgentEnrolmentRetrieveValidation,
11
+ LSPAgentEnrolmentUpdateValidation
9
12
  } from '@de./types/aux/agents'
10
13
  import type {
11
14
  LSPConsolidationScheduleValidation,
@@ -22,6 +25,48 @@ import { qs, type Http, type Res, type Data } from '../../utils'
22
25
  export default class LSPAgents {
23
26
  constructor( private http: Http ){}
24
27
 
28
+ // ── Self-enrolment ──────────────────────────────────────────────────────
29
+ //
30
+ // The invitation flow needs an operator to name each agent, which is right
31
+ // when a provider picks riders one at a time and wrong for a platform that
32
+ // already runs its own verification. Enrolment keeps what invitation was
33
+ // buying — the agent lands in this provider's context, and the provider
34
+ // agreed to take them — but takes the agreement from a standing policy
35
+ // instead of a per-person act.
36
+
37
+ /** The provider's standing enrolment policy. Operator-scoped. */
38
+ async enrolmentPolicy(): Promise<LSPAgentEnrolmentRetrieveValidation['response']> {
39
+ return await this.http.request<LSPAgentEnrolmentRetrieveValidation['response']>({
40
+ url: '/lsp/agents/enrolment',
41
+ method: 'GET'
42
+ })
43
+ }
44
+
45
+ /** Set it. Off unless `enabled` says otherwise. Operator-scoped. */
46
+ async setEnrolmentPolicy( body: LSPAgentEnrolmentUpdateValidation['body'] ): Promise<LSPAgentEnrolmentUpdateValidation['response']> {
47
+ return await this.http.request<LSPAgentEnrolmentUpdateValidation['response']>({
48
+ url: '/lsp/agents/enrolment',
49
+ method: 'PUT',
50
+ body
51
+ })
52
+ }
53
+
54
+ /**
55
+ * Join this provider as an agent.
56
+ *
57
+ * Authorized as the person joining — the uid on the token — so a platform
58
+ * enrols on someone's behalf by minting for them, exactly as it would to
59
+ * redeem an invitation. `status`, `grade` and the zone come from the
60
+ * provider's policy, not from the body.
61
+ */
62
+ async enrol( body: LSPAgentEnrolValidation['body'] ): Promise<LSPAgentEnrolValidation['response']> {
63
+ return await this.http.request<LSPAgentEnrolValidation['response']>({
64
+ url: '/lsp/agents/enrolment',
65
+ method: 'POST',
66
+ body
67
+ })
68
+ }
69
+
25
70
  async list( querystring?: LSPAgentListValidation['querystring'] ): Promise<LSPAgentListValidation['response']> {
26
71
  return await this.http.request<LSPAgentListValidation['response']>({
27
72
  url: `/lsp/agents${qs( querystring )}`,
@@ -46,13 +46,21 @@ export default class Handles extends EventEmitter {
46
46
  /**
47
47
  * Create new stream through which user's current location
48
48
  * details will be pushed to the API level.
49
- *
50
- * @param usertype - (Default: `client`) Type of user at the current location
49
+ *
50
+ * This took a `usertype` of `client | agent` and sent it as the payload of
51
+ * `pin:current:location`. The gateway's handler takes an acknowledgement in
52
+ * that position and its `geolocator.pin()` takes no arguments at all, so the
53
+ * value was bound to `callback`, failed the `typeof … == 'function'` test and
54
+ * was discarded — `myLocation('agent')` and `myLocation('client')` did the
55
+ * same thing. `Controls.pinCurrentLocation()` emits the same event correctly,
56
+ * with only the ack. Removed rather than kept as decoration; distinguishing
57
+ * the marker by user type is a gateway feature that does not exist yet.
58
+ *
51
59
  * @return - Readable stream
52
60
  */
53
- myLocation( usertype?: 'client' | 'agent' ){
61
+ myLocation(){
54
62
  if( !this.chn ) return
55
- this.chn?.emit('pin:current:location', usertype || 'client' )
63
+ this.chn?.emit('pin:current:location')
56
64
 
57
65
  const stream = new Stream()
58
66
 
@@ -217,6 +217,26 @@ export default class MSI extends EventEmitter {
217
217
  */
218
218
  isReady(){ return this.chn && this.isConnected }
219
219
 
220
+ /**
221
+ * Tear the gateway down.
222
+ *
223
+ * Every `load()` adds a `message` listener to the window and an iframe to
224
+ * the page, and neither went away: a single-page host that mounts a map on
225
+ * a route accumulated one of each per visit, all of them still parsing
226
+ * traffic from the gateway. The React Native entry already unwinds this on
227
+ * unmount; the web entry had no way to.
228
+ */
229
+ destroy(){
230
+ this.chn?.disconnect()
231
+ this.chn = undefined
232
+ this.isConnected = false
233
+
234
+ const container = document.getElementById( this.element )
235
+ if( container ) container.innerHTML = ''
236
+
237
+ this.removeAllListeners()
238
+ }
239
+
220
240
  /**
221
241
  * Extend the kit's functionalities
222
242
  *