@vizualkei/neuma-client-sdk 0.100.0 → 0.100.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/dist/NeumaClientHelper.d.ts +18 -18
- package/dist/NeumaClientHelper.js +35 -35
- package/dist/NeumaMobile.js +27 -27
- package/dist/NeumaMobileInterface.d.ts +8 -8
- package/package.json +1 -1
|
@@ -4,15 +4,15 @@ export type EnrollUserOptions = {
|
|
|
4
4
|
phoneNo?: string | null;
|
|
5
5
|
};
|
|
6
6
|
export type NeumaClientHelperConfig = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
neumaSessionUrl: string;
|
|
8
|
+
neumaResultUrl: string;
|
|
9
9
|
fetcher: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
10
10
|
biometricService?: string;
|
|
11
11
|
onQrCode?: NeumaMobileOptions['onQrCode'];
|
|
12
12
|
onAppLaunchFailed?: NeumaMobileOptions['onAppLaunchFailed'];
|
|
13
|
-
sdkOptions?: Omit<NeumaMobileOptions, '
|
|
13
|
+
sdkOptions?: Omit<NeumaMobileOptions, 'neumaSessionToken' | 'onQrCode' | 'onAppLaunchFailed'>;
|
|
14
14
|
resultPayloadBuilder?: (params: {
|
|
15
|
-
|
|
15
|
+
nrt: string;
|
|
16
16
|
enrollOptions?: EnrollUserOptions;
|
|
17
17
|
}) => Record<string, unknown>;
|
|
18
18
|
};
|
|
@@ -22,7 +22,7 @@ export type PendingOperationResult = {
|
|
|
22
22
|
operation: string;
|
|
23
23
|
callbackId: string;
|
|
24
24
|
payload: unknown;
|
|
25
|
-
|
|
25
|
+
nrt?: string;
|
|
26
26
|
claims?: Record<string, unknown>;
|
|
27
27
|
submitted: boolean;
|
|
28
28
|
};
|
|
@@ -30,7 +30,7 @@ export type PendingOperationErrorContext = {
|
|
|
30
30
|
operation: string;
|
|
31
31
|
callbackId: string;
|
|
32
32
|
payload?: unknown;
|
|
33
|
-
|
|
33
|
+
nrt?: string;
|
|
34
34
|
claims?: Record<string, unknown>;
|
|
35
35
|
};
|
|
36
36
|
export type HandlePendingOperationOptions = {
|
|
@@ -40,7 +40,7 @@ export type HandlePendingOperationOptions = {
|
|
|
40
40
|
*/
|
|
41
41
|
operation?: PendingOperationMatcher;
|
|
42
42
|
/**
|
|
43
|
-
* Submit the recovered
|
|
43
|
+
* Submit the recovered NRT to `neumaResultUrl` before calling
|
|
44
44
|
* `onSuccess`. Defaults to `true`, matching foreground helper methods.
|
|
45
45
|
* Set to `false` for direct business flows such as password updates.
|
|
46
46
|
*/
|
|
@@ -50,12 +50,12 @@ export type HandlePendingOperationOptions = {
|
|
|
50
50
|
*/
|
|
51
51
|
enrollOptions?: EnrollUserOptions;
|
|
52
52
|
/**
|
|
53
|
-
* Reject
|
|
53
|
+
* Reject NRTs whose decoded claim has `success: false`. Defaults to
|
|
54
54
|
* `true`, matching foreground SDK behavior.
|
|
55
55
|
*/
|
|
56
56
|
requireSuccess?: boolean;
|
|
57
57
|
/**
|
|
58
|
-
* Fallback error message when a failed
|
|
58
|
+
* Fallback error message when a failed NRT has no server-provided error.
|
|
59
59
|
*/
|
|
60
60
|
failureMessage?: string;
|
|
61
61
|
/**
|
|
@@ -66,12 +66,12 @@ export type HandlePendingOperationOptions = {
|
|
|
66
66
|
onStart?: (pending: PendingOperationInfo) => MaybePromise<void>;
|
|
67
67
|
/**
|
|
68
68
|
* Called after the SDK has recovered the payload and, when requested,
|
|
69
|
-
* submitted the
|
|
69
|
+
* submitted the NRT. Recovery state is cleared only after this callback
|
|
70
70
|
* resolves, so apps can durably persist or show their result UI here.
|
|
71
71
|
*/
|
|
72
72
|
onSuccess?: (result: PendingOperationResult) => MaybePromise<void>;
|
|
73
73
|
/**
|
|
74
|
-
* Called when recovery or
|
|
74
|
+
* Called when recovery or NRT validation fails. Recovery state is cleared
|
|
75
75
|
* after this callback resolves. If omitted, the error is rethrown and
|
|
76
76
|
* recovery state is left intact for a later retry.
|
|
77
77
|
*/
|
|
@@ -89,9 +89,9 @@ export declare class NeumaClientHelper {
|
|
|
89
89
|
restoreUser(): Promise<string>;
|
|
90
90
|
authenticateUser(): Promise<string>;
|
|
91
91
|
/**
|
|
92
|
-
* Authenticate and return a signed
|
|
92
|
+
* Authenticate and return a signed NRT without auto-submitting it to the
|
|
93
93
|
* biometric result endpoint. Use this for business routes that validate
|
|
94
|
-
* the
|
|
94
|
+
* the NRT themselves (e.g. ticket purchase, update-password).
|
|
95
95
|
*/
|
|
96
96
|
authenticateUserDirect(): Promise<string>;
|
|
97
97
|
unenrollUser(): Promise<string>;
|
|
@@ -119,20 +119,20 @@ export declare class NeumaClientHelper {
|
|
|
119
119
|
*
|
|
120
120
|
* This hides the storage/URL recovery details from webapps: it checks
|
|
121
121
|
* whether a matching operation is recoverable, resumes or retrieves the
|
|
122
|
-
* raw payload, decodes failed
|
|
123
|
-
* the
|
|
122
|
+
* raw payload, decodes failed NRTs into NeumaError, optionally submits
|
|
123
|
+
* the NRT to `neumaResultUrl`, and clears SDK recovery state only
|
|
124
124
|
* after the caller's success/error handler has completed.
|
|
125
125
|
*/
|
|
126
126
|
handlePendingOperation(options?: HandlePendingOperationOptions): Promise<PendingOperationResult | null>;
|
|
127
127
|
private createSdk;
|
|
128
128
|
private runSignedOperation;
|
|
129
129
|
private matchesPendingOperation;
|
|
130
|
-
private
|
|
130
|
+
private extractNrt;
|
|
131
131
|
private decodeJwtPayload;
|
|
132
132
|
private isFailedClaims;
|
|
133
133
|
private errorFromFailedClaims;
|
|
134
|
-
private
|
|
135
|
-
private
|
|
134
|
+
private requestNeumaSessionToken;
|
|
135
|
+
private submitNeumaResultToken;
|
|
136
136
|
private buildResultPayload;
|
|
137
137
|
private postJson;
|
|
138
138
|
/**
|
|
@@ -28,13 +28,13 @@ class NeumaClientHelper {
|
|
|
28
28
|
return this.runSignedOperation(client => client.authenticateUser());
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Authenticate and return a signed
|
|
31
|
+
* Authenticate and return a signed NRT without auto-submitting it to the
|
|
32
32
|
* biometric result endpoint. Use this for business routes that validate
|
|
33
|
-
* the
|
|
33
|
+
* the NRT themselves (e.g. ticket purchase, update-password).
|
|
34
34
|
*/
|
|
35
35
|
async authenticateUserDirect() {
|
|
36
|
-
const {
|
|
37
|
-
const client = this.createSdk(
|
|
36
|
+
const { nst } = await this.requestNeumaSessionToken();
|
|
37
|
+
const client = this.createSdk(nst);
|
|
38
38
|
return client.authenticateUser();
|
|
39
39
|
}
|
|
40
40
|
async unenrollUser() {
|
|
@@ -79,8 +79,8 @@ class NeumaClientHelper {
|
|
|
79
79
|
*
|
|
80
80
|
* This hides the storage/URL recovery details from webapps: it checks
|
|
81
81
|
* whether a matching operation is recoverable, resumes or retrieves the
|
|
82
|
-
* raw payload, decodes failed
|
|
83
|
-
* the
|
|
82
|
+
* raw payload, decodes failed NRTs into NeumaError, optionally submits
|
|
83
|
+
* the NRT to `neumaResultUrl`, and clears SDK recovery state only
|
|
84
84
|
* after the caller's success/error handler has completed.
|
|
85
85
|
*/
|
|
86
86
|
async handlePendingOperation(options = {}) {
|
|
@@ -99,21 +99,21 @@ class NeumaClientHelper {
|
|
|
99
99
|
this.clearPendingResult();
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
|
-
const
|
|
103
|
-
const claims =
|
|
104
|
-
context = { ...context, payload,
|
|
105
|
-
if (
|
|
102
|
+
const nrt = this.extractNrt(payload);
|
|
103
|
+
const claims = nrt ? this.decodeJwtPayload(nrt) : undefined;
|
|
104
|
+
context = { ...context, payload, nrt, claims };
|
|
105
|
+
if (nrt && options.requireSuccess !== false && claims && this.isFailedClaims(claims)) {
|
|
106
106
|
throw this.errorFromFailedClaims(claims, options.failureMessage);
|
|
107
107
|
}
|
|
108
|
-
const shouldSubmit = options.submitResult !== false && !!
|
|
109
|
-
if (shouldSubmit &&
|
|
110
|
-
await this.
|
|
108
|
+
const shouldSubmit = options.submitResult !== false && !!nrt;
|
|
109
|
+
if (shouldSubmit && nrt) {
|
|
110
|
+
await this.submitNeumaResultToken(nrt, options.enrollOptions);
|
|
111
111
|
}
|
|
112
112
|
const result = {
|
|
113
113
|
operation: pending.operation,
|
|
114
114
|
callbackId: pending.callbackId,
|
|
115
115
|
payload,
|
|
116
|
-
...(
|
|
116
|
+
...(nrt ? { nrt } : {}),
|
|
117
117
|
...(claims ? { claims } : {}),
|
|
118
118
|
submitted: shouldSubmit,
|
|
119
119
|
};
|
|
@@ -130,7 +130,7 @@ class NeumaClientHelper {
|
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
createSdk(
|
|
133
|
+
createSdk(neumaSessionToken) {
|
|
134
134
|
const client = NeumaMobile_1.NeumaMobileFactory.create();
|
|
135
135
|
const sdkOptions = this.config.sdkOptions;
|
|
136
136
|
const initOptions = {
|
|
@@ -141,22 +141,22 @@ class NeumaClientHelper {
|
|
|
141
141
|
...(this.config.onAppLaunchFailed
|
|
142
142
|
? { onAppLaunchFailed: this.config.onAppLaunchFailed }
|
|
143
143
|
: {}),
|
|
144
|
-
...(
|
|
144
|
+
...(neumaSessionToken ? { neumaSessionToken } : {}),
|
|
145
145
|
biometricService: this.biometricService,
|
|
146
146
|
};
|
|
147
147
|
client.initialize(initOptions);
|
|
148
148
|
return client;
|
|
149
149
|
}
|
|
150
150
|
async runSignedOperation(run, context) {
|
|
151
|
-
const {
|
|
152
|
-
const client = this.createSdk(
|
|
153
|
-
const
|
|
154
|
-
const claims = this.decodeJwtPayload(
|
|
151
|
+
const { nst } = await this.requestNeumaSessionToken();
|
|
152
|
+
const client = this.createSdk(nst);
|
|
153
|
+
const nrt = await run(client);
|
|
154
|
+
const claims = this.decodeJwtPayload(nrt);
|
|
155
155
|
if (claims && this.isFailedClaims(claims)) {
|
|
156
156
|
throw this.errorFromFailedClaims(claims);
|
|
157
157
|
}
|
|
158
|
-
await this.
|
|
159
|
-
return
|
|
158
|
+
await this.submitNeumaResultToken(nrt, context?.enrollOptions);
|
|
159
|
+
return nrt;
|
|
160
160
|
}
|
|
161
161
|
matchesPendingOperation(operation, matcher) {
|
|
162
162
|
if (!matcher)
|
|
@@ -169,11 +169,11 @@ class NeumaClientHelper {
|
|
|
169
169
|
return matcher(operation);
|
|
170
170
|
return false;
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
extractNrt(payload) {
|
|
173
173
|
if (!payload || typeof payload !== 'object')
|
|
174
174
|
return undefined;
|
|
175
|
-
const
|
|
176
|
-
return typeof
|
|
175
|
+
const nrt = payload.brt;
|
|
176
|
+
return typeof nrt === 'string' && nrt.length > 0 ? nrt : undefined;
|
|
177
177
|
}
|
|
178
178
|
decodeJwtPayload(token) {
|
|
179
179
|
try {
|
|
@@ -211,22 +211,22 @@ class NeumaClientHelper {
|
|
|
211
211
|
}
|
|
212
212
|
return new NeumaMobileInterface_1.NeumaError(error || fallbackMessage, 'AUTH_FAILED');
|
|
213
213
|
}
|
|
214
|
-
async
|
|
215
|
-
const response = await this.postJson(this.config.
|
|
216
|
-
if (!response?.
|
|
217
|
-
throw new Error('Missing
|
|
214
|
+
async requestNeumaSessionToken() {
|
|
215
|
+
const response = await this.postJson(this.config.neumaSessionUrl);
|
|
216
|
+
if (!response?.nst || typeof response.nst !== 'string') {
|
|
217
|
+
throw new Error('Missing nst in biometric session response');
|
|
218
218
|
}
|
|
219
219
|
return response;
|
|
220
220
|
}
|
|
221
|
-
async
|
|
222
|
-
const payload = this.buildResultPayload(
|
|
223
|
-
return this.postJsonWithRetry(this.config.
|
|
221
|
+
async submitNeumaResultToken(nrt, enrollOptions) {
|
|
222
|
+
const payload = this.buildResultPayload(nrt, enrollOptions);
|
|
223
|
+
return this.postJsonWithRetry(this.config.neumaResultUrl, payload);
|
|
224
224
|
}
|
|
225
|
-
buildResultPayload(
|
|
225
|
+
buildResultPayload(nrt, enrollOptions) {
|
|
226
226
|
if (this.config.resultPayloadBuilder) {
|
|
227
|
-
return this.config.resultPayloadBuilder({
|
|
227
|
+
return this.config.resultPayloadBuilder({ nrt, enrollOptions });
|
|
228
228
|
}
|
|
229
|
-
return {
|
|
229
|
+
return { nrt };
|
|
230
230
|
}
|
|
231
231
|
async postJson(url, body) {
|
|
232
232
|
if (!this.config.fetcher) {
|
package/dist/NeumaMobile.js
CHANGED
|
@@ -24,28 +24,28 @@ const OP_CODES = {
|
|
|
24
24
|
class NeumaMobile {
|
|
25
25
|
constructor() {
|
|
26
26
|
this.options = {
|
|
27
|
-
customSchemeBase: '
|
|
27
|
+
customSchemeBase: 'sophdplk://operation',
|
|
28
28
|
timeoutMs: 90000,
|
|
29
29
|
overlay: { appName: 'Neuma Mobile' },
|
|
30
30
|
apiServerPort: 443,
|
|
31
31
|
biometricService: DEFAULT_BIOMETRIC_SERVICE,
|
|
32
32
|
installUrlResolver: undefined,
|
|
33
33
|
qrAppLinkBase: undefined,
|
|
34
|
-
|
|
34
|
+
neumaSessionToken: undefined,
|
|
35
35
|
onQrCode: undefined,
|
|
36
36
|
onAppLaunchFailed: undefined,
|
|
37
37
|
};
|
|
38
38
|
this.versionInfo = this.parsePackageVersion(SDK_VERSION);
|
|
39
39
|
}
|
|
40
40
|
initialize(opts) {
|
|
41
|
-
const { overlay, timeoutMs, onQrCode, onAppLaunchFailed,
|
|
41
|
+
const { overlay, timeoutMs, onQrCode, onAppLaunchFailed, neumaSessionToken, biometricService, installUrlResolver, qrAppLinkBase, } = opts;
|
|
42
42
|
this.options = {
|
|
43
43
|
...this.options,
|
|
44
44
|
timeoutMs: timeoutMs ?? this.options.timeoutMs,
|
|
45
45
|
overlay: { ...this.options.overlay, ...(overlay || {}) },
|
|
46
46
|
onQrCode: onQrCode ?? this.options.onQrCode,
|
|
47
47
|
onAppLaunchFailed: onAppLaunchFailed ?? this.options.onAppLaunchFailed,
|
|
48
|
-
|
|
48
|
+
neumaSessionToken: neumaSessionToken ?? this.options.neumaSessionToken,
|
|
49
49
|
biometricService: (0, biometricService_1.normalizeBiometricService)(biometricService ?? this.options.biometricService),
|
|
50
50
|
installUrlResolver: installUrlResolver ?? this.options.installUrlResolver,
|
|
51
51
|
qrAppLinkBase: qrAppLinkBase ?? this.options.qrAppLinkBase,
|
|
@@ -54,7 +54,7 @@ class NeumaMobile {
|
|
|
54
54
|
timeoutMs: this.options.timeoutMs,
|
|
55
55
|
hasQrCallback: !!onQrCode,
|
|
56
56
|
hasAppLaunchFailedCallback: !!onAppLaunchFailed,
|
|
57
|
-
|
|
57
|
+
hasNeumaSessionToken: !!this.options.neumaSessionToken,
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
detectLaunchPlatform() {
|
|
@@ -580,7 +580,7 @@ class NeumaMobile {
|
|
|
580
580
|
return true;
|
|
581
581
|
return false;
|
|
582
582
|
}
|
|
583
|
-
|
|
583
|
+
extractNeumaResultToken(payload, operation, errorCode) {
|
|
584
584
|
if (this.isUserCancelledPayload(payload)) {
|
|
585
585
|
common_utils_1.logger.info('Operation cancelled by user', { operation });
|
|
586
586
|
throw new NeumaMobileInterface_1.NeumaError('Cancelled by user', 'USER_CANCELLED');
|
|
@@ -590,15 +590,15 @@ class NeumaMobile {
|
|
|
590
590
|
common_utils_1.logger.error('Operation failed', { operation, error: message });
|
|
591
591
|
throw new NeumaMobileInterface_1.NeumaError(message, errorCode);
|
|
592
592
|
}
|
|
593
|
-
const
|
|
594
|
-
if (typeof
|
|
593
|
+
const nrt = payload?.brt;
|
|
594
|
+
if (typeof nrt !== 'string' || nrt.length === 0) {
|
|
595
595
|
common_utils_1.logger.error('Biometric result token missing', {
|
|
596
596
|
operation,
|
|
597
597
|
payloadKeys: Object.keys(payload || {}),
|
|
598
598
|
});
|
|
599
599
|
throw new NeumaMobileInterface_1.NeumaError('Biometric result token missing', errorCode);
|
|
600
600
|
}
|
|
601
|
-
const claims = this.decodeJwtPayload(
|
|
601
|
+
const claims = this.decodeJwtPayload(nrt);
|
|
602
602
|
if (claims && claims.success === false) {
|
|
603
603
|
if (this.isUserCancelledPayload(claims)) {
|
|
604
604
|
common_utils_1.logger.info('Operation cancelled by user', { operation });
|
|
@@ -608,7 +608,7 @@ class NeumaMobile {
|
|
|
608
608
|
common_utils_1.logger.error('Operation failed', { operation, error: message });
|
|
609
609
|
throw new NeumaMobileInterface_1.NeumaError(message, errorCode);
|
|
610
610
|
}
|
|
611
|
-
return
|
|
611
|
+
return nrt;
|
|
612
612
|
}
|
|
613
613
|
decodeJwtPayload(token) {
|
|
614
614
|
try {
|
|
@@ -647,7 +647,7 @@ class NeumaMobile {
|
|
|
647
647
|
if (response.ok) {
|
|
648
648
|
const payload = await response.json();
|
|
649
649
|
if (payload && typeof payload.brt === 'string' && payload.brt.length > 0) {
|
|
650
|
-
common_utils_1.logger.info('Received
|
|
650
|
+
common_utils_1.logger.info('Received Neuma result token via long polling', {
|
|
651
651
|
callbackId,
|
|
652
652
|
payloadKeys: Object.keys(payload || {}),
|
|
653
653
|
});
|
|
@@ -753,7 +753,7 @@ class NeumaMobile {
|
|
|
753
753
|
common_utils_1.logger.info('Invoking mobile app via QR code', {
|
|
754
754
|
operation,
|
|
755
755
|
callbackId,
|
|
756
|
-
|
|
756
|
+
hasNeumaSessionToken: !!this.options.neumaSessionToken,
|
|
757
757
|
hasUser: !!user,
|
|
758
758
|
});
|
|
759
759
|
// Get short operation code
|
|
@@ -773,8 +773,8 @@ class NeumaMobile {
|
|
|
773
773
|
params.append('p', phone);
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
|
-
if (this.options.
|
|
777
|
-
params.append('bst', this.options.
|
|
776
|
+
if (this.options.neumaSessionToken) {
|
|
777
|
+
params.append('bst', this.options.neumaSessionToken);
|
|
778
778
|
}
|
|
779
779
|
// Use HTTPS App Link for QR codes - Android camera apps don't support custom schemes
|
|
780
780
|
const appLinkBase = this.resolveQrAppLinkBase();
|
|
@@ -848,7 +848,7 @@ class NeumaMobile {
|
|
|
848
848
|
operation,
|
|
849
849
|
callbackId,
|
|
850
850
|
isDesktop,
|
|
851
|
-
|
|
851
|
+
hasNeumaSessionToken: !!this.options.neumaSessionToken,
|
|
852
852
|
hasUser: !!user,
|
|
853
853
|
});
|
|
854
854
|
const isOfflineOperation = operation === 'retrieve-key' || operation === 'clear-user';
|
|
@@ -886,8 +886,8 @@ class NeumaMobile {
|
|
|
886
886
|
params.append('phone', phone);
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
|
-
if (this.options.
|
|
890
|
-
params.append('bst', this.options.
|
|
889
|
+
if (this.options.neumaSessionToken) {
|
|
890
|
+
params.append('bst', this.options.neumaSessionToken);
|
|
891
891
|
}
|
|
892
892
|
if (returnUrl) {
|
|
893
893
|
params.append('returnUrl', returnUrl);
|
|
@@ -997,8 +997,8 @@ class NeumaMobile {
|
|
|
997
997
|
async enrollUser(user) {
|
|
998
998
|
try {
|
|
999
999
|
const payload = await this.invokeMobileApp('enroll', user);
|
|
1000
|
-
const
|
|
1001
|
-
const decoded = this.decodeJwtPayload(
|
|
1000
|
+
const nrt = this.extractNeumaResultToken(payload, 'enroll', 'USER_EXISTS');
|
|
1001
|
+
const decoded = this.decodeJwtPayload(nrt);
|
|
1002
1002
|
if (decoded && decoded.userId && decoded.enrollmentId) {
|
|
1003
1003
|
const enrollment = {
|
|
1004
1004
|
userId: String(decoded.userId),
|
|
@@ -1013,7 +1013,7 @@ class NeumaMobile {
|
|
|
1013
1013
|
this.persistEnrollment(enrollment);
|
|
1014
1014
|
}
|
|
1015
1015
|
common_utils_1.logger.info('Enrollment successful', { userName: user.userName });
|
|
1016
|
-
return
|
|
1016
|
+
return nrt;
|
|
1017
1017
|
}
|
|
1018
1018
|
catch (error) {
|
|
1019
1019
|
if (error instanceof NeumaMobileInterface_1.NeumaError && error.code === 'USER_CANCELLED')
|
|
@@ -1029,8 +1029,8 @@ class NeumaMobile {
|
|
|
1029
1029
|
async restoreUser() {
|
|
1030
1030
|
try {
|
|
1031
1031
|
const payload = await this.invokeMobileApp('restore', undefined);
|
|
1032
|
-
const
|
|
1033
|
-
const decoded = this.decodeJwtPayload(
|
|
1032
|
+
const nrt = this.extractNeumaResultToken(payload, 'restore', 'AUTH_FAILED');
|
|
1033
|
+
const decoded = this.decodeJwtPayload(nrt);
|
|
1034
1034
|
if (decoded && decoded.userId && decoded.enrollmentId) {
|
|
1035
1035
|
const enrollment = {
|
|
1036
1036
|
userId: String(decoded.userId),
|
|
@@ -1045,7 +1045,7 @@ class NeumaMobile {
|
|
|
1045
1045
|
this.persistEnrollment(enrollment);
|
|
1046
1046
|
}
|
|
1047
1047
|
common_utils_1.logger.info('Restore successful');
|
|
1048
|
-
return
|
|
1048
|
+
return nrt;
|
|
1049
1049
|
}
|
|
1050
1050
|
catch (error) {
|
|
1051
1051
|
if (error instanceof NeumaMobileInterface_1.NeumaError && error.code === 'USER_CANCELLED')
|
|
@@ -1061,9 +1061,9 @@ class NeumaMobile {
|
|
|
1061
1061
|
async authenticateUser() {
|
|
1062
1062
|
try {
|
|
1063
1063
|
const payload = await this.invokeMobileApp('authenticate', undefined);
|
|
1064
|
-
const
|
|
1064
|
+
const nrt = this.extractNeumaResultToken(payload, 'authenticate', 'AUTH_FAILED');
|
|
1065
1065
|
common_utils_1.logger.info('Authentication successful');
|
|
1066
|
-
return
|
|
1066
|
+
return nrt;
|
|
1067
1067
|
}
|
|
1068
1068
|
catch (error) {
|
|
1069
1069
|
if (error instanceof NeumaMobileInterface_1.NeumaError && error.code === 'USER_CANCELLED')
|
|
@@ -1140,10 +1140,10 @@ class NeumaMobile {
|
|
|
1140
1140
|
async unenrollUser() {
|
|
1141
1141
|
try {
|
|
1142
1142
|
const payload = await this.invokeMobileApp('unenroll-user', undefined);
|
|
1143
|
-
const
|
|
1143
|
+
const nrt = this.extractNeumaResultToken(payload, 'unenroll-user', 'USER_NOT_FOUND');
|
|
1144
1144
|
this.persistEnrollment(null);
|
|
1145
1145
|
common_utils_1.logger.info('User unenrolled successfully');
|
|
1146
|
-
return
|
|
1146
|
+
return nrt;
|
|
1147
1147
|
}
|
|
1148
1148
|
catch (error) {
|
|
1149
1149
|
if (error instanceof NeumaMobileInterface_1.NeumaError && error.code === 'USER_CANCELLED')
|
|
@@ -79,8 +79,8 @@ export type NeumaMobileOptions = {
|
|
|
79
79
|
* `/neuma-wellness/f` or `https://apps.example.com/neuma-wellness/f`.
|
|
80
80
|
*/
|
|
81
81
|
qrAppLinkBase?: string;
|
|
82
|
-
/** Biometric session token (
|
|
83
|
-
|
|
82
|
+
/** Biometric session token (NST) from the server */
|
|
83
|
+
neumaSessionToken?: string;
|
|
84
84
|
/**
|
|
85
85
|
* Callback for displaying QR code in desktop browser flow.
|
|
86
86
|
* When running on desktop and this callback is provided, the SDK will:
|
|
@@ -137,17 +137,17 @@ export interface NeumaMobileInterface {
|
|
|
137
137
|
*/
|
|
138
138
|
getEnrolledUser(): Promise<EnrollmentResult | null>;
|
|
139
139
|
/**
|
|
140
|
-
* Launches the native enrollment flow and resolves with a
|
|
140
|
+
* Launches the native enrollment flow and resolves with a Neuma result token (NRT).
|
|
141
141
|
* Rejects with {@link NeumaError} when the operation fails or is cancelled.
|
|
142
142
|
*/
|
|
143
143
|
enrollUser(user: UserDescriptor): Promise<string>;
|
|
144
144
|
/**
|
|
145
|
-
* Restores an existing user to a new device and resolves with a
|
|
145
|
+
* Restores an existing user to a new device and resolves with a Neuma result token (NRT).
|
|
146
146
|
* Rejects with {@link NeumaError} when the operation fails or is cancelled.
|
|
147
147
|
*/
|
|
148
148
|
restoreUser(): Promise<string>;
|
|
149
149
|
/**
|
|
150
|
-
* Initiates biometric authentication and resolves with a
|
|
150
|
+
* Initiates biometric authentication and resolves with a Neuma result token (NRT),
|
|
151
151
|
* throwing {@link NeumaError} on failure.
|
|
152
152
|
*/
|
|
153
153
|
authenticateUser(): Promise<string>;
|
|
@@ -166,7 +166,7 @@ export interface NeumaMobileInterface {
|
|
|
166
166
|
parseRetrieveKeyResult(jsonString: string): KeyRetrievalResult;
|
|
167
167
|
/**
|
|
168
168
|
* Performs a full unenrollment (device plus server) and resolves with
|
|
169
|
-
* a
|
|
169
|
+
* a Neuma result token (NRT) if successful.
|
|
170
170
|
*/
|
|
171
171
|
unenrollUser(): Promise<string>;
|
|
172
172
|
/**
|
|
@@ -179,7 +179,7 @@ export interface NeumaMobileInterface {
|
|
|
179
179
|
* there is none.
|
|
180
180
|
*
|
|
181
181
|
* The SDK persists pending metadata in `sessionStorage` immediately
|
|
182
|
-
* before launching the `
|
|
182
|
+
* before launching the `sophdplk://` deep link. It also persists a
|
|
183
183
|
* short-lived completed-result cache before clearing pending metadata.
|
|
184
184
|
* Use this from a page-load `useEffect` to detect that the originating
|
|
185
185
|
* browser tab was re-mounted (iOS Safari often does not restore from
|
|
@@ -210,7 +210,7 @@ export interface NeumaMobileInterface {
|
|
|
210
210
|
*
|
|
211
211
|
* Throws on polling timeout or transport failure. Caller is expected to
|
|
212
212
|
* map the resulting payload into the appropriate page-level state in the
|
|
213
|
-
* same way the original operation method does (decode the
|
|
213
|
+
* same way the original operation method does (decode the NRT, surface
|
|
214
214
|
* the success popup, refresh session, etc.).
|
|
215
215
|
*/
|
|
216
216
|
resumePendingResult(): Promise<unknown | null>;
|
package/package.json
CHANGED