@glideidentity/glide-be-node-magical-auth 3.0.0 → 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.
- package/LICENSE +190 -23
- package/README.md +167 -1
- package/dist/index.cjs +716 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -7
- package/dist/index.d.ts +168 -7
- package/dist/index.js +708 -11
- package/dist/index.js.map +1 -1
- package/dist/{types-DgXuYYzq.d.cts → types-BPuPzIcL.d.cts} +456 -178
- package/dist/{types-DgXuYYzq.d.ts → types-BPuPzIcL.d.ts} +456 -178
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +4 -2
package/LICENSE
CHANGED
|
@@ -1,35 +1,202 @@
|
|
|
1
|
-
GLIDE IDENTITY — PRE-RELEASE SDK LICENSE
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
and/or testing of this pre-release version of Glide Identity, Inc.'s
|
|
9
|
-
services, only for your own internal use. Use in production environments
|
|
10
|
-
or any other use outside the scope expressly permitted herein is strictly
|
|
11
|
-
prohibited.
|
|
8
|
+
1. Definitions.
|
|
12
9
|
|
|
13
|
-
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
merchantability and fitness for a particular purpose. You expressly
|
|
18
|
-
acknowledge and agree that Glide Identity, Inc. does not represent or
|
|
19
|
-
warrant that any services and/or the operation of the SDK will be
|
|
20
|
-
uninterrupted or error-free.
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
23
|
|
|
24
|
-
You shall
|
|
25
|
-
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
32
40
|
|
|
33
|
-
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
34
48
|
|
|
35
|
-
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Glide Identity, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -113,6 +113,70 @@ const response = await client.prepare({
|
|
|
113
113
|
});
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
###### `PrepareOptions`
|
|
117
|
+
|
|
118
|
+
| Field | Type | Description |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| `parent_session_id` | `string` | Parent session for the desktop QR flow — set it on the companion/child prepare. |
|
|
121
|
+
| `theme` | `Theme` | UI theme forwarded verbatim to every touchpoint. `"dark"` / `"light"`, or any custom identifier (max 32 chars). |
|
|
122
|
+
| `link_type` | `LinkType` | Overrides link dispatch (`app_clip`, `app_link`, `headless`, `web_link`). Link strategy only. |
|
|
123
|
+
| `network_origin` | `NetworkOrigin` | The **server-observed** IP of the requesting device, stamped by your backend. Stamp it on both prepares to get `network_check` back. Never trust a client-supplied value. |
|
|
124
|
+
| `mobile_companion_passthrough` | `Record<string, unknown>` | Opaque JSON forwarded to the branded companion app. Object only, ≤16 KB. |
|
|
125
|
+
| `completion_redirect_url` | `string` | Where the browser lands once authentication completes. Selects one of your application's registered `completion_redirect_urls` (exact match per RFC 6749 §3.1.2). Stamp it server-side from your own deployment's origin — never from the request `Host` header or any client-controllable value. |
|
|
126
|
+
| `sim_swap_max_age_hours` | `number` | SIM swap query window in hours. See below. |
|
|
127
|
+
| `biometric` | `boolean` | Opt in to the TS43 biometric signal. See below. |
|
|
128
|
+
|
|
129
|
+
**`sim_swap_max_age_hours`** sets how far back a SIM/device swap check looks. Integer, **1–2400**; anything outside that range is refused with `400 VALIDATION_ERROR` before a session is created. When omitted, the server falls back to the carrier's configured `default_max_age_hours` and then to a **24 hour** default. The window that actually produced the answer comes back as `max_age_hours` on the swap payloads, so you can always tell which window you are reading.
|
|
130
|
+
|
|
131
|
+
**`biometric`** asks the device to run a biometric step during the TS43 credential ceremony and report the outcome as `biometric_verification`. It is sent as-is: `true` and explicit `false` both go on the wire; unset is omitted. On Desktop (QR), set on the parent prepare; the phone inherits it. Ignored on Link. Requesting it never makes biometric mandatory: a device that cannot perform it still authenticates.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const response = await client.prepare({
|
|
135
|
+
phone_number: '+14155551234',
|
|
136
|
+
nonce: 'unique-nonce',
|
|
137
|
+
use_case: 'VerifyPhoneNumber',
|
|
138
|
+
client_info: { user_agent: req.headers['user-agent'] },
|
|
139
|
+
options: {
|
|
140
|
+
sim_swap_max_age_hours: 72,
|
|
141
|
+
biometric: true,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
##### `prepareMultiple(request: PrepareMultipleRequest, options?: RequestOptions): Promise<PrepareMultipleResult[]>`
|
|
147
|
+
|
|
148
|
+
Prepares authentication for up to `PREPARE_MULTIPLE_MAX` (10) phone numbers in one call. Fans out one ordinary `prepare` per number — each gets its own nonce, session, and (for link strategy) `feCode`/`feHash`. Returns one result per input number, in input order.
|
|
149
|
+
|
|
150
|
+
Per-number failures are returned in the array, not thrown. The method throws only for caller-input errors (empty list, over cap, blank entry, or a shared prepare field that `prepare` would reject) and only before any HTTP request is issued.
|
|
151
|
+
|
|
152
|
+
`CARRIER_NOT_ELIGIBLE` and `CARRIER_TEMPORARILY_UNAVAILABLE` are both HTTP 422; only the code tells a durable refusal from a transient, retryable carrier outage — on each failed item, branch on its `error` (`instanceof CarrierNotEligibleError` or `item.error.code`), not on status, or a transiently breakered number gets hidden as permanently ineligible.
|
|
153
|
+
|
|
154
|
+
Strip `feCode` from each successful result before forwarding to a browser — it is the device-binding secret and must never reach client-side JavaScript.
|
|
155
|
+
|
|
156
|
+
Pass a short `session_timeout` (60–900 seconds, same as `prepare`) so unpicked sessions expire quickly.
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const results = await client.prepareMultiple({
|
|
160
|
+
use_case: 'VerifyPhoneNumber',
|
|
161
|
+
phone_numbers: ['+14155551234', '+14155559876'],
|
|
162
|
+
client_info: { user_agent: req.headers['user-agent'] },
|
|
163
|
+
session_timeout: 120,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const picker = results
|
|
167
|
+
.filter((r) => r.ok)
|
|
168
|
+
.map((r) => {
|
|
169
|
+
const { feCode, ...prepareForClient } = r.result;
|
|
170
|
+
return {
|
|
171
|
+
id: myPhoneIdFor(r.phone_number),
|
|
172
|
+
label: mask(r.phone_number),
|
|
173
|
+
prepare: prepareForClient,
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
TypeScript uses a discriminated union on `ok` (`{ ok: true; result } | { ok: false; error }`). Go and Java expose the same semantics via nullable fields and `OK()` / `isOk()`.
|
|
179
|
+
|
|
116
180
|
##### `verifyPhoneNumber(request: VerifyPhoneNumberRequest): Promise<VerifyPhoneNumberResponse>`
|
|
117
181
|
|
|
118
182
|
Verifies a phone number using digital credentials.
|
|
@@ -128,6 +192,35 @@ console.log(result.phone_number); // '+14155551234'
|
|
|
128
192
|
console.log(result.sim_swap?.risk_level); // 'RISK_LEVEL_LOW'
|
|
129
193
|
```
|
|
130
194
|
|
|
195
|
+
##### Verifying the signed verification record
|
|
196
|
+
|
|
197
|
+
The response also carries `verification_record`, a Glide-signed ES256 JWS of the verify result, and `verification_record_status` (`'signed'` or `'unavailable'`). Keep the record if you need proof of the result later, and check it with `verifyVerificationRecord(record, options?)`, passing the nonce you sent to prepare:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import { VerificationRecordError, VerificationRecordErrorCode } from '@glideidentity/glide-be-node-magical-auth';
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
const { claims, signOffResults } = await client.verifyVerificationRecord(result.verification_record, {
|
|
204
|
+
expectedNonce: prepareNonce,
|
|
205
|
+
});
|
|
206
|
+
console.log(claims.verified, claims.sub);
|
|
207
|
+
} catch (err) {
|
|
208
|
+
if (err instanceof VerificationRecordError && err.code === VerificationRecordErrorCode.RECORD_UNAVAILABLE) {
|
|
209
|
+
// no signed record for this result
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- An empty or missing record fails closed with `RECORD_UNAVAILABLE`, so the response field can be passed straight in.
|
|
215
|
+
- Records longer than 16 KiB are rejected as `MALFORMED` before decoding.
|
|
216
|
+
- The other codes (`VerificationRecordErrorCode`) are `MALFORMED`, `DISALLOWED_HEADER`, `UNKNOWN_KEY`, `BAD_SIGNATURE`, `WRONG_ISSUER`, `WRONG_AUDIENCE` (`aud` must equal the expected audience, default your client ID), `EXPIRED`, `NOT_YET_VALID`, `NONCE_MISMATCH`, `ORIGIN_MISMATCH`, `UNSUPPORTED_VERSION` and `REVOKED_KEY`. Every failure throws `VerificationRecordError` with `status` 0.
|
|
217
|
+
- Claims that break the v1 contract fail with `MALFORMED`: `ver` must be the string `"1.0"` (otherwise `UNSUPPORTED_VERSION`), `verified` a boolean, `jti`, `nonce` and `sub` (`tel:+E164`) non-empty strings, `nbf` equal to `iat`, `use_case` exactly `VerifyPhoneNumber`, `origin` (canonical device origin, `UNKNOWN` on Link) and `biometric_verification` strings, `exp` 1 to 60 s after `iat`, and `sign_offs` an array of entries with non-empty `role`, `signer` and `status` (`unavailable` with a `reason`, or `present` with `format` and `token`), exactly one of them a `carrier` entry signed `carrier:<id>`. Optional `strategy` (`TS_43`, `LINK`, `DESKTOP__TS_43`, `DESKTOP__LINK`, `DESKTOP`), `phone_number_details`, `carrier` (`{id, name, mvno}`), `sim_swap` and `device_swap` are accepted when present; a wrong JSON type, a `carrier` without a non-empty string `id`, or a `carrier.id` that does not match the carrier sign-off signer (`carrier:<id>`), is `MALFORMED`. Record `sim_swap` / `device_swap` carry `age_band` `{from, to}` in hours (`-1` unknown) and omit `checked_at` — `iat` is the authoritative check time.
|
|
218
|
+
- Keys come only from `<baseUrl>/.well-known/us/jwks.json` (it carries both regions' record keys), cached per `Cache-Control` (300 s default); nothing in the token picks a URL. Only Glide's record-signing kids are accepted. Glide keeps a retired record key published for at least 90 days (the default `maxAuditAgeSeconds`); a record whose key has since been unpublished fails `UNKNOWN_KEY`, even with `allowExpired`.
|
|
219
|
+
- Set `expectedAudience` to the record audience you configured in the developer portal (empty checks your client ID). To pin the device origin, set `expectedOrigin` (a list): the record's canonical `origin` must equal one entry exactly, else `ORIGIN_MISMATCH`; Link records carry `UNKNOWN`, so leave `UNKNOWN` out of the list to reject them.
|
|
220
|
+
- To audit a stored record after `exp`, set `allowExpired: true`; `iat` must still be within `maxAuditAgeSeconds` (90 days by default) and revoked kids (`revokedKids` plus the built-in list) are always rejected. `issuer` overrides the expected `iss` (default: the base URL).
|
|
221
|
+
- In v1 `claims.sign_offs` holds one `carrier` entry with status `unavailable`; `signOffResults` reports it as `unavailable`, and a present sign-off would be reported `unverified`, never trusted.
|
|
222
|
+
- Integer claims follow `JSON.parse`, so `1.0` is accepted where an integer is required (the Go and Java SDKs reject it); Glide never signs such values.
|
|
223
|
+
|
|
131
224
|
##### `getPhoneNumber(request: GetPhoneNumberRequest): Promise<GetPhoneNumberResponse>`
|
|
132
225
|
|
|
133
226
|
Retrieves the phone number associated with the device.
|
|
@@ -141,6 +234,58 @@ const result = await client.getPhoneNumber({
|
|
|
141
234
|
console.log(result.phone_number); // '+14157400083'
|
|
142
235
|
```
|
|
143
236
|
|
|
237
|
+
##### Risk signals on the success response
|
|
238
|
+
|
|
239
|
+
`VerifyPhoneNumberResponse` and `GetPhoneNumberResponse` carry the same signals: `biometric_verification`, plus the optional `sim_swap`, `device_swap` and `phone_number_details`. Each optional one is omitted when the carrier or the session did not produce it, so branch on presence rather than assuming a falsy value is meaningful.
|
|
240
|
+
|
|
241
|
+
###### `SimSwapInfo`
|
|
242
|
+
|
|
243
|
+
| Field | Type | Description |
|
|
244
|
+
|---|---|---|
|
|
245
|
+
| `checked` | `boolean` | Whether the check completed. When `false`, read `reason` and ignore the rest. |
|
|
246
|
+
| `risk_level` | `RiskLevel` | `RISK_LEVEL_HIGH` \| `RISK_LEVEL_MEDIUM` \| `RISK_LEVEL_LOW` \| `RISK_LEVEL_UNKNOWN`. |
|
|
247
|
+
| `age_band` | `string` | When the SIM last changed, e.g. `"0-4 hours"`, `"7-14 days"`, `"more than 3 years"`, `"older than query window"`, `"temporarily unavailable"`, `"not available"`. |
|
|
248
|
+
| `carrier_name` | `string` | The carrier that performed the check. |
|
|
249
|
+
| `checked_at` | `string` | When the check ran, RFC3339. Kept as a string — the SDK passes the wire value through without parsing. |
|
|
250
|
+
| `swapped` | `boolean` | Whether a swap fell inside `max_age_hours`. **Omitted when the carrier gave no determinable answer** (T-Mobile codes `999` / `NA`) — that is not the same as `false`. |
|
|
251
|
+
| `max_age_hours` | `number` | The window this answer actually describes. |
|
|
252
|
+
| `reason` | `SimSwapFailureReason` | Only when `checked` is `false`: `timeout`, `carrier_not_supported`, `disabled`, `error`. |
|
|
253
|
+
|
|
254
|
+
###### `DeviceSwapInfo`
|
|
255
|
+
|
|
256
|
+
Device (IMEI) change, reported only by carriers that support it — currently T-Mobile. It is a fully independent signal, not a variant of `SimSwapInfo`: identical fields **except that it has no `reason`**, because the server never populates one.
|
|
257
|
+
|
|
258
|
+
###### Reading the swap window
|
|
259
|
+
|
|
260
|
+
An absent `swapped` means the check was inconclusive — the carrier gave no determinable age. `RISK_LEVEL_UNKNOWN` is broader: it covers that inconclusive case **and** a CAMARA carrier successfully confirming no swap inside the window, which returns `swapped: false` and `age_band: "older than query window"` but still grades `RISK_LEVEL_UNKNOWN`, because the carrier never dated the last swap. That second case used to report `RISK_LEVEL_LOW`, so code reading `LOW` as "safe" now falls through to its default. Branch on `swapped` for "was there a swap in my window"; read `RISK_LEVEL_UNKNOWN` as "no risk grade available", not as a good or bad outcome.
|
|
261
|
+
|
|
262
|
+
A known `age_band` together with `swapped: false` is not a contradiction: it means the carrier dated the last swap and it fell outside the window. The flag is the band overlapped with the window, and a band straddling the boundary resolves to swapped rather than to an unknown — so with a 24-hour window a `"14-30 days"` band gives `swapped: false` alongside `RISK_LEVEL_MEDIUM`, because risk comes from the band's own recency, not from the window.
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
const s = result.sim_swap;
|
|
266
|
+
if (s?.checked) {
|
|
267
|
+
if (s.swapped === undefined) {
|
|
268
|
+
// carrier could not determine an age for this window
|
|
269
|
+
} else if (s.swapped) {
|
|
270
|
+
console.log(`SIM swapped within ${s.max_age_hours}h (${s.age_band})`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
###### `biometric_verification`
|
|
276
|
+
|
|
277
|
+
`biometric_verification` is on every success response, typed as `BiometricVerification`.
|
|
278
|
+
|
|
279
|
+
| Value | Meaning |
|
|
280
|
+
|---|---|
|
|
281
|
+
| `VERIFIED` | The device performed biometric verification. |
|
|
282
|
+
| `FAILED` | The device attempted it and reported a failure. |
|
|
283
|
+
| `NOT_ENROLLED` | No biometric is enrolled on the device. |
|
|
284
|
+
| `UNSUPPORTED` | Biometric was requested but no usable result came back. |
|
|
285
|
+
| `NOT_REQUESTED` | Nothing to report. |
|
|
286
|
+
|
|
287
|
+
On verify it equals the signed record's `biometric_verification` claim. Values outside this list are kept as sent, so treat anything unrecognised as "no useful signal". It is a signal, not an authentication result — the phone number is verified either way.
|
|
288
|
+
|
|
144
289
|
##### `reportInvocation(sessionId: string): Promise<ReportInvocationResponse>`
|
|
145
290
|
|
|
146
291
|
Reports when a user clicks the authenticate button (for analytics).
|
|
@@ -203,6 +348,8 @@ import {
|
|
|
203
348
|
UnauthorizedError,
|
|
204
349
|
SessionNotFoundError,
|
|
205
350
|
CarrierNotEligibleError,
|
|
351
|
+
CarrierRejectedError,
|
|
352
|
+
CarrierAppUnavailableError,
|
|
206
353
|
RateLimitError,
|
|
207
354
|
} from '@glideidentity/glide-be-node-magical-auth';
|
|
208
355
|
|
|
@@ -213,6 +360,12 @@ try {
|
|
|
213
360
|
console.log('Validation errors:', error.fieldErrors);
|
|
214
361
|
} else if (error instanceof CarrierNotEligibleError) {
|
|
215
362
|
console.log('Carrier not supported');
|
|
363
|
+
} else if (error instanceof CarrierRejectedError) {
|
|
364
|
+
// Carrier rejected a device-bound (link/desktop) auth
|
|
365
|
+
console.log('Carrier rejected:', error.details?.carrier_error, error.details?.stage);
|
|
366
|
+
} else if (error instanceof CarrierAppUnavailableError) {
|
|
367
|
+
// Desktop (QR): the scanning phone has no working carrier app; terminal, start a new QR
|
|
368
|
+
console.log('Carrier app unavailable; start a new QR flow');
|
|
216
369
|
} else if (error instanceof RateLimitError) {
|
|
217
370
|
console.log('Rate limited, retry after:', error.retryAfter);
|
|
218
371
|
} else if (error instanceof MagicalAuthError) {
|
|
@@ -222,6 +375,19 @@ try {
|
|
|
222
375
|
}
|
|
223
376
|
```
|
|
224
377
|
|
|
378
|
+
#### The typed error classes are not exhaustive
|
|
379
|
+
|
|
380
|
+
The classes above cover the codes worth branching on today; the API can return codes that have no
|
|
381
|
+
class. `specs/openapi.yaml` currently documents `TOKEN_ACQUISITION_FAILED`, `INVALID_PARAMETERS`,
|
|
382
|
+
`UNPROCESSABLE_ENTITY`, `UNEXPECTED_ERROR` and `COMPLETION_REDIRECT_URL_NOT_REGISTERED`, none of
|
|
383
|
+
which map to a typed class. They arrive as a base `MagicalAuthError` carrying the raw `code`, so
|
|
384
|
+
always keep the `instanceof MagicalAuthError` fallback last and read `error.code` from it rather
|
|
385
|
+
than assuming the specific classes are total.
|
|
386
|
+
|
|
387
|
+
The edge can also answer `401` and `429` with a `text/plain` body rather than the JSON error
|
|
388
|
+
envelope. The client only parses JSON, so those surface as `code: 'UNKNOWN_ERROR'` with the status
|
|
389
|
+
preserved — branch on `error.status` for those two rather than on `error.code`.
|
|
390
|
+
|
|
225
391
|
### Custom HTTP Client (BYOC)
|
|
226
392
|
|
|
227
393
|
```typescript
|
|
@@ -338,4 +504,4 @@ import type { PrepareRequest, PrepareResponse } from '@glideidentity/glide-be-no
|
|
|
338
504
|
|
|
339
505
|
## License
|
|
340
506
|
|
|
341
|
-
Distributed under the **
|
|
507
|
+
Distributed under the **Apache License 2.0** — see [LICENSE](./LICENSE).
|