@vizualkei/neuma-client-sdk 0.125.0 → 0.150.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.
package/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  See [README.md](../../README.md) for the Neuma SDK API documentation.
4
4
 
5
+ For session verification, `verifyUser()` polls Neuma and submits the NRT plus
6
+ any delegated IVP to the partner. For a custom business endpoint supporting
7
+ either mode, use `verifyUserSubmission()` and `encodeSubmission()`. The binary
8
+ IVP travels in a separate multipart part. See [verifier choice and payloads](../../README.md#choosing-the-session-proof-verifier).
9
+
5
10
  ## iOS Universal Link handoff
6
11
 
7
12
  On iOS phone browsers the SDK hands off to the Neuma app using an HTTPS
@@ -1,3 +1,4 @@
1
+ import { type VerificationSubmission } from './Submission';
1
2
  import type { NeumaMobileOptions, KeyRetrievalResult, PendingOperationInfo, UserDescriptor } from './NeumaMobileInterface';
2
3
  export type EnrollUserOptions = {
3
4
  email?: string | null;
@@ -88,6 +89,7 @@ export declare class NeumaClient {
88
89
  enrollUser(user: UserDescriptor, enrollOptions?: EnrollUserOptions): Promise<string>;
89
90
  restoreEnrollment(): Promise<string>;
90
91
  verifyUser(postResult?: boolean): Promise<string>;
92
+ verifyUserSubmission(): Promise<VerificationSubmission>;
91
93
  /**
92
94
  * Verify the user and return a signed NRT without auto-submitting it to
93
95
  * the biometric result endpoint by calling `verifyUser(false)`.
@@ -151,6 +153,7 @@ export declare const neumaClient: {
151
153
  ensureInitialized(): void;
152
154
  enrollUser(user: UserDescriptor, enrollOptions?: EnrollUserOptions): Promise<string>;
153
155
  restoreEnrollment(): Promise<string>;
156
+ verifyUserSubmission(): Promise<VerificationSubmission>;
154
157
  verifyUser(postResult?: boolean): Promise<string>;
155
158
  unenrollUser(): Promise<string>;
156
159
  verifyUserForKey(): Promise<null>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.neumaClient = exports.NeumaClient = void 0;
4
+ const Submission_1 = require("./Submission");
4
5
  const NeumaMobile_1 = require("./NeumaMobile");
5
6
  const biometricService_1 = require("./biometricService");
6
7
  const NeumaMobileInterface_1 = require("./NeumaMobileInterface");
@@ -25,12 +26,16 @@ class NeumaClient {
25
26
  return this.runSignedOperation(client => client.restoreEnrollment());
26
27
  }
27
28
  async verifyUser(postResult = true) {
28
- if (!postResult) {
29
- const { nst } = await this.requestNeumaSessionToken();
30
- const client = this.createSdk(nst);
31
- return client.verifyUser();
32
- }
33
- return this.runSignedOperation(client => client.verifyUser());
29
+ const result = await this.verifyUserSubmission();
30
+ if (postResult)
31
+ await this.submitNeumaResultToken(result.nrt, undefined, result);
32
+ else if (result.ivp)
33
+ throw Error('Use verifyUserSubmission for a partner-verified session');
34
+ return result.nrt;
35
+ }
36
+ async verifyUserSubmission() {
37
+ const { nst } = await this.requestNeumaSessionToken();
38
+ return this.createSdk(nst).verifyUserSubmission();
34
39
  }
35
40
  /**
36
41
  * Verify the user and return a signed NRT without auto-submitting it to
@@ -103,12 +108,12 @@ class NeumaClient {
103
108
  const nrt = this.extractNrt(payload);
104
109
  const claims = nrt ? this.decodeJwtPayload(nrt) : undefined;
105
110
  context = { ...context, payload, nrt, claims };
106
- if (nrt && options.requireSuccess !== false && claims && this.isFailedClaims(claims)) {
111
+ if (nrt && options.requireSuccess !== false && claims && this.isFailedClaims(claims) && !(pending.operation === 'verify-user' && claims.purpose === 'svp-proof-relay' && payload?.ivp instanceof Blob)) {
107
112
  throw this.errorFromFailedClaims(claims, options.failureMessage);
108
113
  }
109
114
  const shouldSubmit = options.submitResult !== false && !!nrt;
110
115
  if (shouldSubmit && nrt) {
111
- await this.submitNeumaResultToken(nrt, options.enrollOptions);
116
+ await this.submitNeumaResultToken(nrt, options.enrollOptions, payload);
112
117
  }
113
118
  const result = {
114
119
  operation: pending.operation,
@@ -219,8 +224,10 @@ class NeumaClient {
219
224
  }
220
225
  return response;
221
226
  }
222
- async submitNeumaResultToken(nrt, enrollOptions) {
227
+ async submitNeumaResultToken(nrt, enrollOptions, evidence) {
223
228
  const payload = this.buildResultPayload(nrt, enrollOptions);
229
+ if (evidence?.ivp)
230
+ Object.assign(payload, { ivp: evidence.ivp, mdocCertificates: evidence.mdocCertificates });
224
231
  return this.postJsonWithRetry(this.config.neumaResultUrl, payload);
225
232
  }
226
233
  buildResultPayload(nrt, enrollOptions) {
@@ -266,10 +273,7 @@ class NeumaClient {
266
273
  try {
267
274
  response = await this.config.fetcher(url, {
268
275
  method: 'POST',
269
- headers: {
270
- 'Content-Type': 'application/json',
271
- },
272
- body: body ? JSON.stringify(body) : undefined,
276
+ ...(0, Submission_1.encodeSubmission)(body ?? {}),
273
277
  });
274
278
  }
275
279
  catch (err) {
@@ -313,6 +317,7 @@ exports.neumaClient = {
313
317
  restoreEnrollment() {
314
318
  return getClientInstance().restoreEnrollment();
315
319
  },
320
+ verifyUserSubmission() { return getClientInstance().verifyUserSubmission(); },
316
321
  verifyUser(postResult = true) {
317
322
  return getClientInstance().verifyUser(postResult);
318
323
  },
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.NeumaMobileFactory = void 0;
7
+ const Submission_1 = require("./Submission");
7
8
  const NeumaMobileInterface_1 = require("./NeumaMobileInterface");
8
9
  const common_utils_1 = require("@vizualkei/common-utils");
9
10
  const package_json_1 = __importDefault(require("../package.json"));
@@ -204,7 +205,7 @@ class NeumaMobile {
204
205
  const record = {
205
206
  callbackId,
206
207
  operation,
207
- payload,
208
+ payload: payload?.ivp ? { repollEvidence: true } : payload,
208
209
  ts: Date.now(),
209
210
  ...(consuming ? { consumingAt: Date.now() } : {}),
210
211
  };
@@ -433,7 +434,8 @@ class NeumaMobile {
433
434
  });
434
435
  this.markCompletedResultConsuming(completed);
435
436
  this.clearPendingOperation();
436
- return completed.payload;
437
+ return completed.payload?.repollEvidence
438
+ ? this.waitForResult(completed.callbackId, this.options.timeoutMs) : completed.payload;
437
439
  }
438
440
  const pending = this.getPendingOperation();
439
441
  if (!pending)
@@ -463,8 +465,8 @@ class NeumaMobile {
463
465
  this.clearReturnUrlMarkers();
464
466
  }
465
467
  generateRandomId() {
466
- return (Math.random().toString(36).substring(2, 15) +
467
- Math.random().toString(36).substring(2, 15));
468
+ const bytes = crypto.getRandomValues(new Uint8Array(24));
469
+ return Array.from(bytes, n => n.toString(16).padStart(2, '0')).join('');
468
470
  }
469
471
  /**
470
472
  * Returns true only when running in **iOS Safari** — not iOS Chrome
@@ -602,7 +604,7 @@ class NeumaMobile {
602
604
  throw new NeumaMobileInterface_1.NeumaError('Biometric result token missing', errorCode);
603
605
  }
604
606
  const claims = this.decodeJwtPayload(nrt);
605
- if (claims && claims.success === false) {
607
+ if (claims && claims.success === false && !(operation === 'verify-user' && claims.purpose === 'svp-proof-relay' && payload.ivp instanceof Blob)) {
606
608
  if (this.isUserCancelledPayload(claims)) {
607
609
  common_utils_1.logger.info('Operation cancelled by user', { operation });
608
610
  throw new NeumaMobileInterface_1.NeumaError('Cancelled by user', 'USER_CANCELLED');
@@ -648,7 +650,8 @@ class NeumaMobile {
648
650
  headers: { Accept: 'application/json' },
649
651
  });
650
652
  if (response.ok) {
651
- const payload = await response.json();
653
+ const payload = response.headers.get('content-type')?.startsWith('multipart/form-data')
654
+ ? await (0, Submission_1.readVerificationResponse)(response) : await response.json();
652
655
  if (payload && typeof payload.nrt === 'string' && payload.nrt.length > 0) {
653
656
  common_utils_1.logger.info('Received Neuma result token via long polling', {
654
657
  callbackId,
@@ -1079,11 +1082,16 @@ class NeumaMobile {
1079
1082
  }
1080
1083
  }
1081
1084
  async verifyUser() {
1085
+ const result = await this.verifyUserSubmission();
1086
+ if (result.ivp)
1087
+ throw new NeumaMobileInterface_1.NeumaError('Partner proof submission required', 'AUTH_FAILED');
1088
+ return result.nrt;
1089
+ }
1090
+ async verifyUserSubmission() {
1082
1091
  try {
1083
1092
  const payload = await this.invokeMobileApp('verify-user', undefined);
1084
1093
  const nrt = this.extractNeumaResultToken(payload, 'verify-user', 'AUTH_FAILED');
1085
- common_utils_1.logger.info('User verification successful');
1086
- return nrt;
1094
+ return payload.ivp ? { nrt, ivp: payload.ivp, mdocCertificates: payload.mdocCertificates } : { nrt };
1087
1095
  }
1088
1096
  catch (error) {
1089
1097
  if (error instanceof NeumaMobileInterface_1.NeumaError && error.code === 'USER_CANCELLED')
@@ -1,3 +1,4 @@
1
+ import type { VerificationSubmission } from './Submission';
1
2
  export interface UserDescriptor {
2
3
  readonly userName: string;
3
4
  readonly email?: string;
@@ -160,6 +161,7 @@ export interface NeumaMobileInterface {
160
161
  * throwing {@link NeumaError} on failure.
161
162
  */
162
163
  verifyUser(): Promise<string>;
164
+ verifyUserSubmission(): Promise<VerificationSubmission>;
163
165
  /**
164
166
  * Requests a biometric-bound cryptographic key from the native flow.
165
167
  * NOTE: Works in offline mode - returns null and requires manual paste from mobile app.
@@ -0,0 +1,7 @@
1
+ export type VerificationSubmission = {
2
+ nrt: string;
3
+ ivp?: Blob;
4
+ mdocCertificates?: string[];
5
+ };
6
+ export declare function encodeSubmission(data: Record<string, unknown>): Pick<RequestInit, 'body' | 'headers'>;
7
+ export declare function readVerificationResponse(response: Response): Promise<VerificationSubmission>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeSubmission = encodeSubmission;
4
+ exports.readVerificationResponse = readVerificationResponse;
5
+ // The browser forwards the original IVP bytes. Ordinary NRT submissions retain their JSON shape.
6
+ function encodeSubmission(data) {
7
+ const { ivp, ...metadata } = data;
8
+ if (ivp === undefined)
9
+ return { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(metadata) };
10
+ if (!(ivp instanceof Blob) || ivp.size === 0 || ivp.size > 24 * 1024 * 1024)
11
+ throw Error('Invalid proof attachment');
12
+ const form = new FormData();
13
+ form.append('metadata', JSON.stringify(metadata));
14
+ form.append('ivp', ivp, 'proof.ivp');
15
+ return { body: form };
16
+ }
17
+ async function readVerificationResponse(response) {
18
+ const form = await response.formData();
19
+ const meta = form.get('metadata'), ivp = form.get('ivp');
20
+ if (typeof meta !== 'string' ||
21
+ meta.length > 98304 ||
22
+ !(ivp instanceof Blob) ||
23
+ !ivp.size ||
24
+ ivp.size > 24 * 1024 * 1024)
25
+ throw Error('Invalid Neuma evidence');
26
+ const { nrt, mdocCertificates } = JSON.parse(meta);
27
+ if (typeof nrt !== 'string' ||
28
+ !nrt ||
29
+ nrt.length > 32768 ||
30
+ !Array.isArray(mdocCertificates) ||
31
+ mdocCertificates.length < 1 ||
32
+ mdocCertificates.length > 2 ||
33
+ mdocCertificates.some(c => typeof c !== 'string' || c.length > 21848))
34
+ throw Error('Invalid Neuma evidence metadata');
35
+ return { nrt, mdocCertificates, ivp };
36
+ }
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export type { NeumaMobileInterface, NeumaMobileOptions, UserDescriptor, Enrollme
4
4
  export { NeumaError } from './NeumaMobileInterface';
5
5
  export { NeumaClient, neumaClient, } from './NeumaClient';
6
6
  export type { NeumaClientConfig, EnrollUserOptions, HandlePendingOperationOptions, PendingOperationErrorContext, PendingOperationMatcher, PendingOperationResult, } from './NeumaClient';
7
- export { NEUMA_MOBILE_PLAY_STORE_URL, NEUMA_MOBILE_TESTFLIGHT_URL, getNeumaMobileInstallUrl, } from './installLinks';
7
+ export { NEUMA_MOBILE_APP_STORE_URL, NEUMA_MOBILE_PLAY_STORE_URL, NEUMA_MOBILE_TESTFLIGHT_URL, getNeumaMobileInstallUrl, } from './installLinks';
8
+ export { encodeSubmission, type VerificationSubmission } from './Submission';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNeumaMobileInstallUrl = exports.NEUMA_MOBILE_TESTFLIGHT_URL = exports.NEUMA_MOBILE_PLAY_STORE_URL = exports.neumaClient = exports.NeumaClient = exports.NeumaError = exports.NEUMA_CLIENT_SDK_VERSION = exports.NeumaMobileFactory = void 0;
3
+ exports.encodeSubmission = exports.getNeumaMobileInstallUrl = exports.NEUMA_MOBILE_TESTFLIGHT_URL = exports.NEUMA_MOBILE_PLAY_STORE_URL = exports.NEUMA_MOBILE_APP_STORE_URL = exports.neumaClient = exports.NeumaClient = exports.NeumaError = exports.NEUMA_CLIENT_SDK_VERSION = exports.NeumaMobileFactory = void 0;
4
4
  // Neuma Client SDK - Main exports
5
5
  var NeumaMobile_1 = require("./NeumaMobile");
6
6
  Object.defineProperty(exports, "NeumaMobileFactory", { enumerable: true, get: function () { return NeumaMobile_1.NeumaMobileFactory; } });
@@ -13,6 +13,9 @@ var NeumaClient_1 = require("./NeumaClient");
13
13
  Object.defineProperty(exports, "NeumaClient", { enumerable: true, get: function () { return NeumaClient_1.NeumaClient; } });
14
14
  Object.defineProperty(exports, "neumaClient", { enumerable: true, get: function () { return NeumaClient_1.neumaClient; } });
15
15
  var installLinks_1 = require("./installLinks");
16
+ Object.defineProperty(exports, "NEUMA_MOBILE_APP_STORE_URL", { enumerable: true, get: function () { return installLinks_1.NEUMA_MOBILE_APP_STORE_URL; } });
16
17
  Object.defineProperty(exports, "NEUMA_MOBILE_PLAY_STORE_URL", { enumerable: true, get: function () { return installLinks_1.NEUMA_MOBILE_PLAY_STORE_URL; } });
17
18
  Object.defineProperty(exports, "NEUMA_MOBILE_TESTFLIGHT_URL", { enumerable: true, get: function () { return installLinks_1.NEUMA_MOBILE_TESTFLIGHT_URL; } });
18
19
  Object.defineProperty(exports, "getNeumaMobileInstallUrl", { enumerable: true, get: function () { return installLinks_1.getNeumaMobileInstallUrl; } });
20
+ var Submission_1 = require("./Submission");
21
+ Object.defineProperty(exports, "encodeSubmission", { enumerable: true, get: function () { return Submission_1.encodeSubmission; } });
@@ -1,4 +1,6 @@
1
1
  import type { AppLaunchPlatform } from './NeumaMobileInterface';
2
2
  export declare const NEUMA_MOBILE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=io.vizualkei.neuma";
3
- export declare const NEUMA_MOBILE_TESTFLIGHT_URL = "https://testflight.apple.com/join/yAv6ZB2S";
3
+ export declare const NEUMA_MOBILE_APP_STORE_URL = "https://apps.apple.com/us/app/neuma-id/id6769588036";
4
+ /** @deprecated Use NEUMA_MOBILE_APP_STORE_URL. */
5
+ export declare const NEUMA_MOBILE_TESTFLIGHT_URL = "https://apps.apple.com/us/app/neuma-id/id6769588036";
4
6
  export declare const getNeumaMobileInstallUrl: (platform: AppLaunchPlatform) => string | undefined;
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNeumaMobileInstallUrl = exports.NEUMA_MOBILE_TESTFLIGHT_URL = exports.NEUMA_MOBILE_PLAY_STORE_URL = void 0;
3
+ exports.getNeumaMobileInstallUrl = exports.NEUMA_MOBILE_TESTFLIGHT_URL = exports.NEUMA_MOBILE_APP_STORE_URL = exports.NEUMA_MOBILE_PLAY_STORE_URL = void 0;
4
4
  exports.NEUMA_MOBILE_PLAY_STORE_URL = 'https://play.google.com/store/apps/details?id=io.vizualkei.neuma';
5
- exports.NEUMA_MOBILE_TESTFLIGHT_URL = 'https://testflight.apple.com/join/yAv6ZB2S';
5
+ exports.NEUMA_MOBILE_APP_STORE_URL = 'https://apps.apple.com/us/app/neuma-id/id6769588036';
6
+ /** @deprecated Use NEUMA_MOBILE_APP_STORE_URL. */
7
+ exports.NEUMA_MOBILE_TESTFLIGHT_URL = exports.NEUMA_MOBILE_APP_STORE_URL;
6
8
  const getNeumaMobileInstallUrl = (platform) => {
7
9
  if (platform === 'android') {
8
10
  return exports.NEUMA_MOBILE_PLAY_STORE_URL;
9
11
  }
10
12
  if (platform === 'ios') {
11
- return exports.NEUMA_MOBILE_TESTFLIGHT_URL;
13
+ return exports.NEUMA_MOBILE_APP_STORE_URL;
12
14
  }
13
15
  return undefined;
14
16
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const NEUMA_CLIENT_SDK_VERSION = "0.125.0";
1
+ export declare const NEUMA_CLIENT_SDK_VERSION = "0.150.0";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NEUMA_CLIENT_SDK_VERSION = void 0;
4
4
  // This file is generated by scripts/generate-package-version.mjs. Do not edit by hand.
5
- exports.NEUMA_CLIENT_SDK_VERSION = '0.125.0';
5
+ exports.NEUMA_CLIENT_SDK_VERSION = '0.150.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizualkei/neuma-client-sdk",
3
- "version": "0.125.0",
3
+ "version": "0.150.0",
4
4
  "description": "Neuma Web Client SDK - Biometric verification SDK for webapp integration",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",