@portal-hq/passkey-storage 4.2.13 → 4.3.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.
- package/lib/commonjs/index.js +11 -8
- package/lib/esm/index.js +11 -8
- package/package.json +6 -6
- package/src/index.ts +29 -26
- package/types.d.ts +5 -5
package/lib/commonjs/index.js
CHANGED
|
@@ -144,11 +144,12 @@ class PasskeyStorage {
|
|
|
144
144
|
},
|
|
145
145
|
});
|
|
146
146
|
// check if challenge exists
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
const challenge = beginResponse.options.publicKey.challenge;
|
|
148
|
+
if (typeof challenge !== 'string' || !challenge) {
|
|
149
|
+
throw new Error('Challenge is missing or invalid in passkey options. Please try again and check your web authn host url.');
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
-
const result = yield react_native_passkey_1.Passkey.
|
|
151
|
+
const createRequest = Object.assign(Object.assign({}, beginResponse.options.publicKey), { challenge: convertBase64UrlToBase64(challenge) });
|
|
152
|
+
const result = yield react_native_passkey_1.Passkey.create(createRequest);
|
|
152
153
|
const attestation = {
|
|
153
154
|
rawId: convertBase64ToBase64Url(result.rawId),
|
|
154
155
|
id: convertBase64ToBase64Url(result.id),
|
|
@@ -176,11 +177,13 @@ class PasskeyStorage {
|
|
|
176
177
|
},
|
|
177
178
|
});
|
|
178
179
|
// check if challenge exists
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
const challenge = beginResponse.options.publicKey.challenge;
|
|
181
|
+
if (typeof challenge !== 'string' || !challenge) {
|
|
182
|
+
throw new Error('Challenge is missing or invalid in passkey options. Please try again and check your web authn host url.');
|
|
181
183
|
}
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
+
// Create a properly typed request for Passkey.get()
|
|
185
|
+
const getRequest = Object.assign(Object.assign({}, beginResponse.options.publicKey), { challenge: convertBase64UrlToBase64(challenge) });
|
|
186
|
+
const result = yield react_native_passkey_1.Passkey.get(getRequest);
|
|
184
187
|
const assertion = {
|
|
185
188
|
rawId: convertBase64ToBase64Url(result.rawId),
|
|
186
189
|
id: convertBase64ToBase64Url(result.id),
|
package/lib/esm/index.js
CHANGED
|
@@ -141,11 +141,12 @@ export class PasskeyStorage {
|
|
|
141
141
|
},
|
|
142
142
|
});
|
|
143
143
|
// check if challenge exists
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
const challenge = beginResponse.options.publicKey.challenge;
|
|
145
|
+
if (typeof challenge !== 'string' || !challenge) {
|
|
146
|
+
throw new Error('Challenge is missing or invalid in passkey options. Please try again and check your web authn host url.');
|
|
146
147
|
}
|
|
147
|
-
|
|
148
|
-
const result = yield Passkey.
|
|
148
|
+
const createRequest = Object.assign(Object.assign({}, beginResponse.options.publicKey), { challenge: convertBase64UrlToBase64(challenge) });
|
|
149
|
+
const result = yield Passkey.create(createRequest);
|
|
149
150
|
const attestation = {
|
|
150
151
|
rawId: convertBase64ToBase64Url(result.rawId),
|
|
151
152
|
id: convertBase64ToBase64Url(result.id),
|
|
@@ -173,11 +174,13 @@ export class PasskeyStorage {
|
|
|
173
174
|
},
|
|
174
175
|
});
|
|
175
176
|
// check if challenge exists
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
const challenge = beginResponse.options.publicKey.challenge;
|
|
178
|
+
if (typeof challenge !== 'string' || !challenge) {
|
|
179
|
+
throw new Error('Challenge is missing or invalid in passkey options. Please try again and check your web authn host url.');
|
|
178
180
|
}
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
+
// Create a properly typed request for Passkey.get()
|
|
182
|
+
const getRequest = Object.assign(Object.assign({}, beginResponse.options.publicKey), { challenge: convertBase64UrlToBase64(challenge) });
|
|
183
|
+
const result = yield Passkey.get(getRequest);
|
|
181
184
|
const assertion = {
|
|
182
185
|
rawId: convertBase64ToBase64Url(result.rawId),
|
|
183
186
|
id: convertBase64ToBase64Url(result.id),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/passkey-storage",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "Portal's Passkey storage adapter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Portal Labs, Inc.",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"test": "jest --pass-with-no-tests"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@portal-hq/core": "^4.
|
|
26
|
-
"@portal-hq/utils": "^4.
|
|
27
|
-
"react-native-passkey": "^
|
|
25
|
+
"@portal-hq/core": "^4.3.1",
|
|
26
|
+
"@portal-hq/utils": "^4.3.1",
|
|
27
|
+
"react-native-passkey": "^3.3.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/preset-typescript": "^7.18.6",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"typescript": "^4.8.4"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"react-native-passkey": "^
|
|
38
|
+
"react-native-passkey": "^3.3.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "0cfb3fc21c050a54e73044a87b92ac22f9e2edb7"
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { HttpRequester, IPortalApi, type Storage } from '@portal-hq/utils'
|
|
2
|
-
import {
|
|
3
|
-
Passkey,
|
|
4
|
-
PasskeyAuthenticationResult,
|
|
5
|
-
PasskeyRegistrationResult,
|
|
6
|
-
} from 'react-native-passkey'
|
|
7
2
|
|
|
8
3
|
import type {
|
|
9
4
|
AuthenticationResponse,
|
|
@@ -12,6 +7,13 @@ import type {
|
|
|
12
7
|
PasskeyStatusResponse,
|
|
13
8
|
RegistrationResponse,
|
|
14
9
|
} from '../types'
|
|
10
|
+
import {
|
|
11
|
+
Passkey,
|
|
12
|
+
type PasskeyCreateRequest,
|
|
13
|
+
type PasskeyCreateResult,
|
|
14
|
+
type PasskeyGetRequest,
|
|
15
|
+
type PasskeyGetResult,
|
|
16
|
+
} from 'react-native-passkey'
|
|
15
17
|
|
|
16
18
|
export class PasskeyStorage implements Storage {
|
|
17
19
|
public api?: IPortalApi
|
|
@@ -151,7 +153,7 @@ export class PasskeyStorage implements Storage {
|
|
|
151
153
|
// Helper Methods
|
|
152
154
|
private async getAttestationAndSetSessionId(
|
|
153
155
|
headers: Record<string, any>,
|
|
154
|
-
): Promise<
|
|
156
|
+
): Promise<PasskeyCreateResult> {
|
|
155
157
|
const beginResponse = await this.passkeyApi.post<RegistrationResponse>(
|
|
156
158
|
'/passkeys/begin-registration',
|
|
157
159
|
{
|
|
@@ -164,18 +166,19 @@ export class PasskeyStorage implements Storage {
|
|
|
164
166
|
)
|
|
165
167
|
|
|
166
168
|
// check if challenge exists
|
|
167
|
-
|
|
169
|
+
const challenge = beginResponse.options.publicKey.challenge
|
|
170
|
+
if (typeof challenge !== 'string' || !challenge) {
|
|
168
171
|
throw new Error(
|
|
169
|
-
'Challenge is missing in passkey options. Please try again and check your web authn host url.',
|
|
172
|
+
'Challenge is missing or invalid in passkey options. Please try again and check your web authn host url.',
|
|
170
173
|
)
|
|
171
174
|
}
|
|
172
|
-
beginResponse.options.publicKey.challenge = convertBase64UrlToBase64(
|
|
173
|
-
beginResponse.options.publicKey.challenge,
|
|
174
|
-
)
|
|
175
175
|
|
|
176
|
-
const
|
|
177
|
-
beginResponse.options.publicKey,
|
|
178
|
-
|
|
176
|
+
const createRequest: PasskeyCreateRequest = {
|
|
177
|
+
...beginResponse.options.publicKey,
|
|
178
|
+
challenge: convertBase64UrlToBase64(challenge),
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const result: PasskeyCreateResult = await Passkey.create(createRequest)
|
|
179
182
|
const attestation = {
|
|
180
183
|
rawId: convertBase64ToBase64Url(result.rawId),
|
|
181
184
|
id: convertBase64ToBase64Url(result.id),
|
|
@@ -203,7 +206,7 @@ export class PasskeyStorage implements Storage {
|
|
|
203
206
|
|
|
204
207
|
private async getAssertionAndSetSessionId(
|
|
205
208
|
headers: Record<string, any>,
|
|
206
|
-
): Promise<
|
|
209
|
+
): Promise<PasskeyGetResult> {
|
|
207
210
|
const beginResponse = await this.passkeyApi.post<AuthenticationResponse>(
|
|
208
211
|
'/passkeys/begin-login',
|
|
209
212
|
{
|
|
@@ -216,18 +219,20 @@ export class PasskeyStorage implements Storage {
|
|
|
216
219
|
)
|
|
217
220
|
|
|
218
221
|
// check if challenge exists
|
|
219
|
-
|
|
222
|
+
const challenge = beginResponse.options.publicKey.challenge
|
|
223
|
+
if (typeof challenge !== 'string' || !challenge) {
|
|
220
224
|
throw new Error(
|
|
221
|
-
'Challenge is missing in passkey options. Please try again and check your web authn host url.',
|
|
225
|
+
'Challenge is missing or invalid in passkey options. Please try again and check your web authn host url.',
|
|
222
226
|
)
|
|
223
227
|
}
|
|
224
|
-
beginResponse.options.publicKey.challenge = convertBase64UrlToBase64(
|
|
225
|
-
beginResponse.options.publicKey.challenge,
|
|
226
|
-
)
|
|
227
228
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
// Create a properly typed request for Passkey.get()
|
|
230
|
+
const getRequest: PasskeyGetRequest = {
|
|
231
|
+
...beginResponse.options.publicKey,
|
|
232
|
+
challenge: convertBase64UrlToBase64(challenge),
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const result: PasskeyGetResult = await Passkey.get(getRequest)
|
|
231
236
|
|
|
232
237
|
const assertion = {
|
|
233
238
|
rawId: convertBase64ToBase64Url(result.rawId),
|
|
@@ -249,9 +254,7 @@ export class PasskeyStorage implements Storage {
|
|
|
249
254
|
return assertion
|
|
250
255
|
}
|
|
251
256
|
|
|
252
|
-
private async getEncryptionKey(
|
|
253
|
-
assertion: PasskeyAuthenticationResult,
|
|
254
|
-
): Promise<string> {
|
|
257
|
+
private async getEncryptionKey(assertion: PasskeyGetResult): Promise<string> {
|
|
255
258
|
if (this.api?.apiKey === undefined) {
|
|
256
259
|
throw new Error('API key is not set')
|
|
257
260
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from 'react-native-passkey/lib/typescript/
|
|
2
|
+
PasskeyCreateRequest,
|
|
3
|
+
PasskeyGetRequest,
|
|
4
|
+
} from 'react-native-passkey/lib/typescript/PasskeyTypes'
|
|
5
5
|
import { PasskeyStatus } from './src'
|
|
6
6
|
|
|
7
7
|
export declare class PasskeyStorage {
|
|
@@ -33,7 +33,7 @@ export interface RegistrationResponse {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export interface RegistrationOptions {
|
|
36
|
-
publicKey:
|
|
36
|
+
publicKey: PasskeyCreateRequest
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export interface AuthenticationResponse {
|
|
@@ -42,7 +42,7 @@ export interface AuthenticationResponse {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface AuthenticationOptions {
|
|
45
|
-
publicKey:
|
|
45
|
+
publicKey: PasskeyGetRequest
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export interface LoginReadResponse {
|