gdc-sdk-node-ts 2.3.14 → 2.3.15

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.
@@ -28,6 +28,14 @@ type RecoverOrganizationControllerWithIssueDeps = {
28
28
  } & Record<string, unknown>, pollOptions?: PollOptions) => Promise<SubmitAndPollResult>;
29
29
  };
30
30
  export declare function recoverOrganizationControllerWithIssueWithDeps(deps: RecoverOrganizationControllerWithIssueDeps): Promise<OrganizationControllerRecoveryResult>;
31
- /** Reads the opaque activation code from a successful Organization/_issue poll result. */
31
+ /**
32
+ * Reads the opaque activation code from a successful Organization/_issue poll result.
33
+ *
34
+ * Gateway deployments may retain one or more transport/job envelopes around
35
+ * the terminal batch response. Only a response entry carrying the canonical
36
+ * serial-number claim, or an explicitly typed `License:Issued` entry carrying
37
+ * its public `id`, is accepted. Unrelated identifiers are never interpreted as
38
+ * activation material.
39
+ */
32
40
  export declare function readOrganizationIssueActivationCode(result: SubmitAndPollResult): string;
33
41
  export {};
@@ -32,20 +32,30 @@ export async function recoverOrganizationControllerWithIssueWithDeps(deps) {
32
32
  activation,
33
33
  };
34
34
  }
35
- /** Reads the opaque activation code from a successful Organization/_issue poll result. */
35
+ /**
36
+ * Reads the opaque activation code from a successful Organization/_issue poll result.
37
+ *
38
+ * Gateway deployments may retain one or more transport/job envelopes around
39
+ * the terminal batch response. Only a response entry carrying the canonical
40
+ * serial-number claim, or an explicitly typed `License:Issued` entry carrying
41
+ * its public `id`, is accepted. Unrelated identifiers are never interpreted as
42
+ * activation material.
43
+ */
36
44
  export function readOrganizationIssueActivationCode(result) {
37
45
  const pollBody = (result?.poll?.body || {});
38
- const body = (pollBody.body || pollBody);
39
- const data = Array.isArray(body.data) ? body.data : Array.isArray(pollBody.data) ? pollBody.data : [];
40
- const firstEntry = data[0] || {};
41
- const claims = firstEntry.meta?.claims;
42
- const activationCode = String(claims?.['org.schema.IndividualProduct.serialNumber'] || '').trim();
43
- if (activationCode) {
44
- return activationCode;
46
+ for (const candidate of nestedObjects(pollBody)) {
47
+ const claims = candidate.meta?.claims;
48
+ const activationCode = String(claims?.['org.schema.IndividualProduct.serialNumber'] || '').trim();
49
+ if (activationCode)
50
+ return activationCode;
51
+ if (candidate.type === 'License:Issued') {
52
+ const issuedId = String(candidate.id || '').trim();
53
+ if (issuedId)
54
+ return issuedId;
55
+ }
45
56
  }
46
- const diagnostics = firstEntry.response?.outcome
47
- ?.issue
48
- ?.map((issue) => String(issue?.diagnostics || '').trim())
57
+ const diagnostics = nestedObjects(pollBody)
58
+ .map((candidate) => String(candidate.diagnostics || '').trim())
49
59
  .filter(Boolean)
50
60
  .join(' | ');
51
61
  if (diagnostics) {
@@ -53,3 +63,24 @@ export function readOrganizationIssueActivationCode(result) {
53
63
  }
54
64
  return '';
55
65
  }
66
+ function nestedObjects(root) {
67
+ const found = [];
68
+ const pending = [{ value: root, depth: 0 }];
69
+ const visited = new Set();
70
+ while (pending.length > 0) {
71
+ const current = pending.shift();
72
+ if (!current.value || typeof current.value !== 'object' || current.depth > 8)
73
+ continue;
74
+ if (visited.has(current.value))
75
+ continue;
76
+ visited.add(current.value);
77
+ if (Array.isArray(current.value)) {
78
+ current.value.forEach((value) => pending.push({ value, depth: current.depth + 1 }));
79
+ continue;
80
+ }
81
+ const record = current.value;
82
+ found.push(record);
83
+ Object.values(record).forEach((value) => pending.push({ value, depth: current.depth + 1 }));
84
+ }
85
+ return found;
86
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-node-ts",
3
- "version": "2.3.14",
3
+ "version": "2.3.15",
4
4
  "description": "Next-generation Node runtime package for the GDC SDK family",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",