@plainkey/browser 0.17.0 → 0.19.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/dist/index.d.ts +63 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/readme.md +7 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthenticationResponseJSON, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON } from "@simplewebauthn/browser";
|
|
2
2
|
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type UserIdentifier = {
|
|
5
|
+
userId?: string;
|
|
6
|
+
userName?: string;
|
|
7
|
+
};
|
|
8
|
+
type AuthenticationToken = {
|
|
9
|
+
token: string;
|
|
10
|
+
expiresAt: number;
|
|
11
|
+
};
|
|
12
|
+
type CredentialBasicInfo = {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string | null;
|
|
15
|
+
authenticatorType: string | null;
|
|
16
|
+
userId: string;
|
|
17
|
+
};
|
|
18
|
+
interface AuthenticateResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
data?: {
|
|
21
|
+
authenticationToken: AuthenticationToken;
|
|
22
|
+
};
|
|
23
|
+
error?: {
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
interface CreateUserWithPasskeyResult {
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: {
|
|
30
|
+
userId: string;
|
|
31
|
+
credential: CredentialBasicInfo;
|
|
32
|
+
authenticationToken: AuthenticationToken;
|
|
33
|
+
};
|
|
34
|
+
error?: {
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
interface AddPasskeyResult {
|
|
39
|
+
success: boolean;
|
|
40
|
+
data?: {
|
|
41
|
+
credential: CredentialBasicInfo;
|
|
42
|
+
authenticationToken: AuthenticationToken;
|
|
43
|
+
};
|
|
44
|
+
error?: {
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
interface UpdatePasskeyLabelResult {
|
|
49
|
+
success: boolean;
|
|
50
|
+
error?: {
|
|
51
|
+
message: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
3
55
|
//#region src/plainKey.d.ts
|
|
4
|
-
|
|
5
56
|
/**
|
|
6
57
|
* PlainKey client for the browser. Used to register new users, add passkeys to existing users, and log users in.
|
|
7
58
|
*
|
|
@@ -16,7 +67,7 @@ declare class PlainKey {
|
|
|
16
67
|
constructor(projectId: string, baseUrl?: string);
|
|
17
68
|
/**
|
|
18
69
|
* Helper to parse response JSON.
|
|
19
|
-
* Throws error if status code is not 200 OK
|
|
70
|
+
* Throws error if status code is not 200 OK or if the response is not valid JSON.
|
|
20
71
|
*/
|
|
21
72
|
private parseResponse;
|
|
22
73
|
/**
|
|
@@ -29,17 +80,17 @@ declare class PlainKey {
|
|
|
29
80
|
/**
|
|
30
81
|
* Adds a passkey to an existing user. Will require user interaction to create a passkey.
|
|
31
82
|
*
|
|
32
|
-
* @param authenticationToken - The user authentication token,
|
|
83
|
+
* @param authenticationToken - The user authentication token, returned from .authenticate() or createUserWithPasskey().
|
|
33
84
|
* Do NOT store it in local storage, database, etc. Always keep it in memory.
|
|
34
|
-
* @param userName - A unique identifier for the user,
|
|
35
|
-
* If not provided, the user's stored userName will be used.
|
|
85
|
+
* @param userName - A unique identifier for the user. If not provided, the user's stored userName will be used.
|
|
36
86
|
*/
|
|
37
87
|
addPasskey(authenticationToken: string, userName?: string): Promise<AddPasskeyResult>;
|
|
38
88
|
/**
|
|
39
|
-
* Updates a passkey label.
|
|
40
|
-
*
|
|
89
|
+
* Updates a passkey label. Any passkey registered to the user can be updated.
|
|
90
|
+
*
|
|
91
|
+
* @param authenticationToken - The user authentication token, returned from .authenticate() or createUserWithPasskey().
|
|
41
92
|
* Do NOT store it in local storage, database, etc. Always keep it in memory.
|
|
42
|
-
* @param credentialId - The ID of the passkey
|
|
93
|
+
* @param credentialId - The ID of the passkey to update, returned from createUserWithPasskey() or addPasskey().
|
|
43
94
|
* @param label - The new label for the passkey.
|
|
44
95
|
*/
|
|
45
96
|
updatePasskeyLabel(authenticationToken: string, credentialId: string, label: string): Promise<UpdatePasskeyLabelResult>;
|
|
@@ -47,11 +98,11 @@ declare class PlainKey {
|
|
|
47
98
|
* Authenticates a user. Can be used for login, verification, 2FA, etc.
|
|
48
99
|
* Will require user interaction to authenticate.
|
|
49
100
|
*
|
|
50
|
-
* @param userIdentifier - Optional
|
|
51
|
-
*
|
|
101
|
+
* @param userIdentifier - Optional. Identify the user by their PlainKey user ID or userName.
|
|
102
|
+
* Not required for usernameless authentication.
|
|
52
103
|
*/
|
|
53
104
|
authenticate(userIdentifier?: UserIdentifier): Promise<AuthenticateResult>;
|
|
54
105
|
}
|
|
55
106
|
//#endregion
|
|
56
|
-
export { PlainKey };
|
|
107
|
+
export { AddPasskeyResult, AuthenticateResult, type AuthenticationResponseJSON, AuthenticationToken, CreateUserWithPasskeyResult, CredentialBasicInfo, PlainKey, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RegistrationResponseJSON, UpdatePasskeyLabelResult, UserIdentifier };
|
|
57
108
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/plainKey.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/plainKey.ts"],"sourcesContent":[],"mappings":";;;KAAY,cAAA;;;AAAZ,CAAA;AAKY,KAAA,mBAAA,GAAmB;EAKnB,KAAA,EAAA,MAAA;EAOK,SAAA,EAAA,MAAA;AAQjB,CAAA;AAUiB,KAzBL,mBAAA,GA4BI;EAMC,EAAA,EAAA,MAAA;;;;ACXjB,CAAA;AAiD0D,UDjEzC,kBAAA,CCiEyC;EAAR,OAAA,EAAA,OAAA;EAyD0B,IAAA,CAAA,EAAA;IAAR,mBAAA,EDvH3C,mBCuH2C;EA+DvD,CAAA;EAAR,KAAA,CAAA,EAAA;IAiCiC,OAAA,EAAA,MAAA;EAAyB,CAAA;;AAAD,UDlN7C,2BAAA,CCkN6C;;;;gBD9M9C;yBACS;;;;;;UAKR,gBAAA;;;gBAGD;yBACS;;;;;;UAKR,wBAAA;;;;;;;;;;AA5CjB;AAKA;AAKA;AAOA;AAQA;AAUA;AASiB,cCXJ,QAAA,CDWI;;;;ECXJ;;;;EA0GuD,QAAA,aAAA;EA+DvD;;;;;;4CAxHqC,QAAQ;;;;;;;;8DAyDU,QAAQ;;;;;;;;;wFA+DvE,QAAQ;;;;;;;;gCAiCyB,iBAAiB,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var PlainKey = class {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Helper to parse response JSON.
|
|
21
|
-
* Throws error if status code is not 200 OK
|
|
21
|
+
* Throws error if status code is not 200 OK or if the response is not valid JSON.
|
|
22
22
|
*/
|
|
23
23
|
async parseResponse(response) {
|
|
24
24
|
let bodyText;
|
|
@@ -48,36 +48,35 @@ var PlainKey = class {
|
|
|
48
48
|
*/
|
|
49
49
|
async createUserWithPasskey(userName) {
|
|
50
50
|
try {
|
|
51
|
-
const beginRequestBody = { userName };
|
|
52
51
|
const beginResponse = await fetch(`${this.baseUrl}/user/register/begin`, {
|
|
53
52
|
method: "POST",
|
|
54
53
|
headers: {
|
|
55
54
|
"Content-Type": "application/json",
|
|
56
55
|
"x-project-id": this.projectId
|
|
57
56
|
},
|
|
58
|
-
body: JSON.stringify(
|
|
57
|
+
body: JSON.stringify({ userName })
|
|
59
58
|
});
|
|
60
59
|
const { userId, options } = await this.parseResponse(beginResponse);
|
|
61
|
-
const
|
|
62
|
-
userId,
|
|
63
|
-
credential: await startRegistration({ optionsJSON: options })
|
|
64
|
-
};
|
|
60
|
+
const credential = await startRegistration({ optionsJSON: options });
|
|
65
61
|
const completeResponse = await fetch(`${this.baseUrl}/user/register/complete`, {
|
|
66
62
|
method: "POST",
|
|
67
63
|
headers: {
|
|
68
64
|
"Content-Type": "application/json",
|
|
69
65
|
"x-project-id": this.projectId
|
|
70
66
|
},
|
|
71
|
-
body: JSON.stringify(
|
|
67
|
+
body: JSON.stringify({
|
|
68
|
+
userId,
|
|
69
|
+
credential
|
|
70
|
+
})
|
|
72
71
|
});
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
72
|
+
const completeData = await this.parseResponse(completeResponse);
|
|
73
|
+
if (!completeData.success) throw new Error("Server could not complete registration");
|
|
75
74
|
return {
|
|
76
|
-
success:
|
|
75
|
+
success: true,
|
|
77
76
|
data: {
|
|
78
|
-
userId:
|
|
79
|
-
authenticationToken:
|
|
80
|
-
credential:
|
|
77
|
+
userId: completeData.userId,
|
|
78
|
+
authenticationToken: completeData.authenticationToken,
|
|
79
|
+
credential: completeData.credential
|
|
81
80
|
}
|
|
82
81
|
};
|
|
83
82
|
} catch (error) {
|
|
@@ -90,46 +89,44 @@ var PlainKey = class {
|
|
|
90
89
|
/**
|
|
91
90
|
* Adds a passkey to an existing user. Will require user interaction to create a passkey.
|
|
92
91
|
*
|
|
93
|
-
* @param authenticationToken - The user authentication token,
|
|
92
|
+
* @param authenticationToken - The user authentication token, returned from .authenticate() or createUserWithPasskey().
|
|
94
93
|
* Do NOT store it in local storage, database, etc. Always keep it in memory.
|
|
95
|
-
* @param userName - A unique identifier for the user,
|
|
96
|
-
* If not provided, the user's stored userName will be used.
|
|
94
|
+
* @param userName - A unique identifier for the user. If not provided, the user's stored userName will be used.
|
|
97
95
|
*/
|
|
98
96
|
async addPasskey(authenticationToken, userName) {
|
|
99
97
|
if (!authenticationToken) throw new Error("Authentication token is required");
|
|
100
98
|
try {
|
|
101
|
-
const beginParams = {
|
|
102
|
-
authenticationToken,
|
|
103
|
-
userName
|
|
104
|
-
};
|
|
105
99
|
const beginResponse = await fetch(`${this.baseUrl}/user/credential/begin`, {
|
|
106
100
|
method: "POST",
|
|
107
101
|
headers: {
|
|
108
102
|
"Content-Type": "application/json",
|
|
109
103
|
"x-project-id": this.projectId
|
|
110
104
|
},
|
|
111
|
-
body: JSON.stringify(
|
|
105
|
+
body: JSON.stringify({
|
|
106
|
+
authenticationToken,
|
|
107
|
+
userName
|
|
108
|
+
})
|
|
112
109
|
});
|
|
113
110
|
const { options } = await this.parseResponse(beginResponse);
|
|
114
|
-
const
|
|
115
|
-
authenticationToken,
|
|
116
|
-
credential: await startRegistration({ optionsJSON: options })
|
|
117
|
-
};
|
|
111
|
+
const credential = await startRegistration({ optionsJSON: options });
|
|
118
112
|
const completeResponse = await fetch(`${this.baseUrl}/user/credential/complete`, {
|
|
119
113
|
method: "POST",
|
|
120
114
|
headers: {
|
|
121
115
|
"Content-Type": "application/json",
|
|
122
116
|
"x-project-id": this.projectId
|
|
123
117
|
},
|
|
124
|
-
body: JSON.stringify(
|
|
118
|
+
body: JSON.stringify({
|
|
119
|
+
authenticationToken,
|
|
120
|
+
credential
|
|
121
|
+
})
|
|
125
122
|
});
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
123
|
+
const completeData = await this.parseResponse(completeResponse);
|
|
124
|
+
if (!completeData.success) throw new Error("Server could not complete passkey registration");
|
|
128
125
|
return {
|
|
129
|
-
success:
|
|
126
|
+
success: true,
|
|
130
127
|
data: {
|
|
131
|
-
authenticationToken:
|
|
132
|
-
credential:
|
|
128
|
+
authenticationToken: completeData.authenticationToken,
|
|
129
|
+
credential: completeData.credential
|
|
133
130
|
}
|
|
134
131
|
};
|
|
135
132
|
} catch (error) {
|
|
@@ -140,17 +137,18 @@ var PlainKey = class {
|
|
|
140
137
|
}
|
|
141
138
|
}
|
|
142
139
|
/**
|
|
143
|
-
* Updates a passkey label.
|
|
144
|
-
*
|
|
140
|
+
* Updates a passkey label. Any passkey registered to the user can be updated.
|
|
141
|
+
*
|
|
142
|
+
* @param authenticationToken - The user authentication token, returned from .authenticate() or createUserWithPasskey().
|
|
145
143
|
* Do NOT store it in local storage, database, etc. Always keep it in memory.
|
|
146
|
-
* @param credentialId - The ID of the passkey
|
|
144
|
+
* @param credentialId - The ID of the passkey to update, returned from createUserWithPasskey() or addPasskey().
|
|
147
145
|
* @param label - The new label for the passkey.
|
|
148
146
|
*/
|
|
149
147
|
async updatePasskeyLabel(authenticationToken, credentialId, label) {
|
|
150
148
|
if (!authenticationToken) throw new Error("Authentication token is required");
|
|
151
149
|
if (!credentialId) throw new Error("Credential ID is required");
|
|
152
150
|
try {
|
|
153
|
-
const
|
|
151
|
+
const body = {
|
|
154
152
|
authenticationToken,
|
|
155
153
|
label
|
|
156
154
|
};
|
|
@@ -160,7 +158,7 @@ var PlainKey = class {
|
|
|
160
158
|
"Content-Type": "application/json",
|
|
161
159
|
"x-project-id": this.projectId
|
|
162
160
|
},
|
|
163
|
-
body: JSON.stringify(
|
|
161
|
+
body: JSON.stringify(body)
|
|
164
162
|
})).ok) throw new Error("Failed to update passkey label");
|
|
165
163
|
return { success: true };
|
|
166
164
|
} catch (error) {
|
|
@@ -174,39 +172,37 @@ var PlainKey = class {
|
|
|
174
172
|
* Authenticates a user. Can be used for login, verification, 2FA, etc.
|
|
175
173
|
* Will require user interaction to authenticate.
|
|
176
174
|
*
|
|
177
|
-
* @param userIdentifier - Optional
|
|
178
|
-
*
|
|
175
|
+
* @param userIdentifier - Optional. Identify the user by their PlainKey user ID or userName.
|
|
176
|
+
* Not required for usernameless authentication.
|
|
179
177
|
*/
|
|
180
178
|
async authenticate(userIdentifier) {
|
|
181
179
|
try {
|
|
182
|
-
const beginParams = { userIdentifier };
|
|
183
180
|
const beginResponse = await fetch(`${this.baseUrl}/authenticate/begin`, {
|
|
184
181
|
method: "POST",
|
|
185
182
|
headers: {
|
|
186
183
|
"Content-Type": "application/json",
|
|
187
184
|
"x-project-id": this.projectId
|
|
188
185
|
},
|
|
189
|
-
body: JSON.stringify(
|
|
186
|
+
body: JSON.stringify({ userIdentifier })
|
|
190
187
|
});
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const authenticationResponse = await startAuthentication({ optionsJSON:
|
|
188
|
+
const beginData = await this.parseResponse(beginResponse);
|
|
189
|
+
if (!beginData.options) throw new Error("Server returned no options in authentication begin response");
|
|
190
|
+
const authenticationResponse = await startAuthentication({ optionsJSON: beginData.options });
|
|
194
191
|
if (!authenticationResponse) throw new Error("No authentication response from browser");
|
|
195
|
-
const
|
|
196
|
-
loginSessionId: beginResponseData.loginSession.id,
|
|
197
|
-
authenticationResponse
|
|
198
|
-
};
|
|
199
|
-
const authenticateCompleteResponse = await fetch(`${this.baseUrl}/authenticate/complete`, {
|
|
192
|
+
const completeResponse = await fetch(`${this.baseUrl}/authenticate/complete`, {
|
|
200
193
|
method: "POST",
|
|
201
194
|
headers: {
|
|
202
195
|
"Content-Type": "application/json",
|
|
203
196
|
"x-project-id": this.projectId
|
|
204
197
|
},
|
|
205
|
-
body: JSON.stringify(
|
|
198
|
+
body: JSON.stringify({
|
|
199
|
+
loginSessionId: beginData.loginSession.id,
|
|
200
|
+
authenticationResponse
|
|
201
|
+
})
|
|
206
202
|
});
|
|
207
203
|
return {
|
|
208
204
|
success: true,
|
|
209
|
-
data: { authenticationToken: (await this.parseResponse(
|
|
205
|
+
data: { authenticationToken: (await this.parseResponse(completeResponse)).authenticationToken }
|
|
210
206
|
};
|
|
211
207
|
} catch (error) {
|
|
212
208
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["bodyText: string","json: any","beginRequestBody: UserRegisterBeginRequest","completeRequestBody: UserRegisterCompleteRequest","completeResponseData: UserRegisterCompleteResponse","beginParams: UserCredentialBeginRequest","completeParams: UserCredentialCompleteRequest","completeResponseData: UserCredentialCompleteResponse","updateLabelParams: CredentialLabelUpdateRequest","beginParams: LoginBeginRequest","beginResponseData: AuthenticationBeginResponse","authenticationResponse: AuthenticationResponseJSON","completeParams: LoginCompleteRequest"],"sources":["../src/plainKey.ts"],"sourcesContent":["import { startAuthentication, startRegistration } from \"@simplewebauthn/browser\"\nimport { RegistrationResponseJSON, AuthenticationResponseJSON } from \"@simplewebauthn/browser\"\n\nimport type {\n UserCredentialBeginRequest,\n UserCredentialCompleteRequest,\n LoginBeginRequest,\n LoginCompleteRequest,\n UserIdentifier,\n CreateUserWithPasskeyResult,\n AddPasskeyResult,\n AuthenticateResult,\n UserRegisterBeginRequest,\n UserRegisterBeginResponse,\n UserRegisterCompleteRequest,\n UserRegisterCompleteResponse,\n AuthenticationCompleteResponse,\n AuthenticationBeginResponse,\n CredentialLabelUpdateRequest,\n UpdatePasskeyLabelResult\n} from \"@plainkey/types\"\n\nimport type { UserCredentialBeginResponse, UserCredentialCompleteResponse } from \"@plainkey/types\"\n\n/**\n * PlainKey client for the browser. Used to register new users, add passkeys to existing users, and log users in.\n *\n * Docs: https://plainkey.io/docs\n *\n * @param projectId - Your PlainKey project ID. You can find it in the PlainKey admin dashboard.\n * @param baseUrl - Set by default to https://api.plainkey.io/browser. Change only for development purposes.\n */\nexport class PlainKey {\n private readonly projectId: string\n private readonly baseUrl: string\n\n constructor(projectId: string, baseUrl: string = \"https://api.plainkey.io/browser\") {\n if (!projectId) throw new Error(\"Project ID is required\")\n if (!baseUrl) throw new Error(\"Base URL is required\")\n\n this.projectId = projectId\n this.baseUrl = baseUrl.replace(/\\/$/, \"\") // Remove trailing slash\n }\n\n /**\n * Helper to parse response JSON.\n * Throws error if status code is not 200 OK, if the response is not valid JSON.\n */\n private async parseResponse<T = any>(response: Response): Promise<T> {\n let bodyText: string\n\n // Read as text first to avoid JSON.parse errors on any HTML/plaintext error responses.\n try {\n bodyText = await response.text()\n } catch {\n throw new Error(\"Network error while reading server response\")\n }\n\n // Parse the response text as JSON.\n let json: any\n\n try {\n json = bodyText ? JSON.parse(bodyText) : {}\n } catch {\n if (!response.ok) throw new Error(\"Server returned an invalid JSON error response\")\n throw new Error(\"Invalid JSON received from server\")\n }\n\n if (!response.ok) {\n // Server should return { error: string }\n const message = json && typeof json.error === \"string\" ? json.error : \"Unknown server error\"\n throw new Error(message)\n }\n\n return json as T\n }\n\n /**\n * Registration of a new user with a passkey. Will require user interaction to create a passkey.\n *\n * @param userName - A unique identifier for the user, like an email address or username.\n * Can be empty for usernameless authentication.\n */\n async createUserWithPasskey(userName?: string): Promise<CreateUserWithPasskeyResult> {\n try {\n // Step 1: Get registration options from server\n const beginRequestBody: UserRegisterBeginRequest = { userName }\n const beginResponse = await fetch(`${this.baseUrl}/user/register/begin`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(beginRequestBody)\n })\n\n // Parse response JSON\n const { userId, options } = await this.parseResponse<UserRegisterBeginResponse>(beginResponse)\n\n // Step 2: Create credential using browser's WebAuthn API\n const credential: RegistrationResponseJSON = await startRegistration({\n optionsJSON: options\n })\n\n // Step 3: Send credential to server for verification\n const completeRequestBody: UserRegisterCompleteRequest = { userId, credential }\n const completeResponse = await fetch(`${this.baseUrl}/user/register/complete`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(completeRequestBody)\n })\n\n // Parse response JSON\n const completeResponseData: UserRegisterCompleteResponse =\n await this.parseResponse<UserRegisterCompleteResponse>(completeResponse)\n\n if (!completeResponseData.success) throw new Error(\"Server could not complete registration\")\n\n // Return success\n return {\n success: completeResponseData.success,\n data: {\n userId: completeResponseData.userId,\n authenticationToken: completeResponseData.authenticationToken,\n credential: completeResponseData.credential\n }\n }\n } catch (error) {\n // Return error\n return {\n success: false,\n error: {\n message: error instanceof Error ? error.message : \"Unknown error\"\n }\n }\n }\n }\n\n /**\n * Adds a passkey to an existing user. Will require user interaction to create a passkey.\n *\n * @param authenticationToken - The user authentication token, is returned from .authenticate() and createUserWithPasskey().\n * Do NOT store it in local storage, database, etc. Always keep it in memory.\n * @param userName - A unique identifier for the user, like an email address or username.\n * If not provided, the user's stored userName will be used.\n */\n async addPasskey(authenticationToken: string, userName?: string): Promise<AddPasskeyResult> {\n if (!authenticationToken) throw new Error(\"Authentication token is required\")\n\n try {\n // Step 1: Get credential registration options from server\n const beginParams: UserCredentialBeginRequest = { authenticationToken, userName }\n const beginResponse = await fetch(`${this.baseUrl}/user/credential/begin`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(beginParams)\n })\n\n // Parse response JSON\n const { options }: UserCredentialBeginResponse =\n await this.parseResponse<UserCredentialBeginResponse>(beginResponse)\n\n // Step 2: Create credential using browser's WebAuthn API\n const credential: RegistrationResponseJSON = await startRegistration({ optionsJSON: options })\n\n // Step 3: Send credential to server for verification\n const completeParams: UserCredentialCompleteRequest = { authenticationToken, credential }\n\n const completeResponse = await fetch(`${this.baseUrl}/user/credential/complete`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(completeParams)\n })\n\n // Parse response JSON\n const completeResponseData: UserCredentialCompleteResponse =\n await this.parseResponse<UserCredentialCompleteResponse>(completeResponse)\n\n if (!completeResponseData.success)\n throw new Error(\"Server could not complete passkey registration\")\n\n // Return success\n return {\n success: completeResponseData.success,\n data: {\n authenticationToken: completeResponseData.authenticationToken,\n credential: completeResponseData.credential\n }\n }\n } catch (error) {\n // Return error\n return {\n success: false,\n error: {\n message: error instanceof Error ? error.message : \"Unknown error\"\n }\n }\n }\n }\n\n /**\n * Updates a passkey label. Requires authentication shortly before this call. Any passkey registered to the user can be updated.\n * @param authenticationToken - The user authentication token, is returned from .authenticate() and createUserWithPasskey().\n * Do NOT store it in local storage, database, etc. Always keep it in memory.\n * @param credentialId - The ID of the passkey credential to update. Is returned from createUserWithPasskey() and addPasskey().\n * @param label - The new label for the passkey.\n */\n async updatePasskeyLabel(\n authenticationToken: string,\n credentialId: string,\n label: string\n ): Promise<UpdatePasskeyLabelResult> {\n if (!authenticationToken) throw new Error(\"Authentication token is required\")\n if (!credentialId) throw new Error(\"Credential ID is required\")\n // Empty label is allowed\n\n try {\n const updateLabelParams: CredentialLabelUpdateRequest = { authenticationToken, label }\n const updateLabelResponse = await fetch(`${this.baseUrl}/credential/${credentialId}/label`, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(updateLabelParams)\n })\n\n if (!updateLabelResponse.ok) throw new Error(\"Failed to update passkey label\")\n\n // Return success\n return { success: true }\n } catch (error) {\n // Return error\n return {\n success: false,\n error: { message: error instanceof Error ? error.message : \"Unknown error\" }\n }\n }\n }\n\n /**\n * Authenticates a user. Can be used for login, verification, 2FA, etc.\n * Will require user interaction to authenticate.\n *\n * @param userIdentifier - Optional object containing either the user's PlainKey User ID or their userName.\n * Does not have to be provided for usernameless authentication.\n */\n async authenticate(userIdentifier?: UserIdentifier): Promise<AuthenticateResult> {\n try {\n // Step 1: Get authentication options from server\n const beginParams: LoginBeginRequest = { userIdentifier }\n const beginResponse = await fetch(`${this.baseUrl}/authenticate/begin`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(beginParams)\n })\n\n // Parse response JSON\n const beginResponseData: AuthenticationBeginResponse =\n await this.parseResponse<AuthenticationBeginResponse>(beginResponse)\n\n if (!beginResponseData.options)\n throw new Error(\"Server returned no options in login begin response\")\n\n // Step 2: Pass options to the authenticator and wait for response\n const authenticationResponse: AuthenticationResponseJSON = await startAuthentication({\n optionsJSON: beginResponseData.options\n })\n\n if (!authenticationResponse) throw new Error(\"No authentication response from browser\")\n\n // Step 3: POST the response to the server\n // This uses the authentication session ID from the begin response - always in JS memory.\n // Do not store it in local storage, database, etc.\n const completeParams: LoginCompleteRequest = {\n loginSessionId: beginResponseData.loginSession.id,\n authenticationResponse\n }\n\n const authenticateCompleteResponse = await fetch(`${this.baseUrl}/authenticate/complete`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(completeParams)\n })\n\n const authCompleteResponseData: AuthenticationCompleteResponse =\n await this.parseResponse<AuthenticationCompleteResponse>(authenticateCompleteResponse)\n\n // Return success\n return {\n success: true,\n data: {\n authenticationToken: authCompleteResponseData.authenticationToken\n }\n }\n } catch (error) {\n // Return error\n return {\n success: false,\n error: {\n message: error instanceof Error ? error.message : \"Unknown error\"\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAgCA,IAAa,WAAb,MAAsB;CAIpB,YAAY,WAAmB,UAAkB,mCAAmC;AAClF,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,yBAAyB;AACzD,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,uBAAuB;AAErD,OAAK,YAAY;AACjB,OAAK,UAAU,QAAQ,QAAQ,OAAO,GAAG;;;;;;CAO3C,MAAc,cAAuB,UAAgC;EACnE,IAAIA;AAGJ,MAAI;AACF,cAAW,MAAM,SAAS,MAAM;UAC1B;AACN,SAAM,IAAI,MAAM,8CAA8C;;EAIhE,IAAIC;AAEJ,MAAI;AACF,UAAO,WAAW,KAAK,MAAM,SAAS,GAAG,EAAE;UACrC;AACN,OAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,iDAAiD;AACnF,SAAM,IAAI,MAAM,oCAAoC;;AAGtD,MAAI,CAAC,SAAS,IAAI;GAEhB,MAAM,UAAU,QAAQ,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ;AACtE,SAAM,IAAI,MAAM,QAAQ;;AAG1B,SAAO;;;;;;;;CAST,MAAM,sBAAsB,UAAyD;AACnF,MAAI;GAEF,MAAMC,mBAA6C,EAAE,UAAU;GAC/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gB;KAChB,gBAAgB,KAAK;KACtB;IACD,MAAM,KAAK,UAAU,YAAY;IAClC,CAAC;GAGF,MAAMC,oBACJ,MAAM,KAAK,cAA2C,cAAc;AAEtE,OAAI,CAAC,kBAAkB,QACrB,OAAM,IAAI,MAAM,qDAAqD;GAGvE,MAAMC,yBAAqD,MAAM,oBAAoB,EACnF,aAAa,kBAAkB,SAChC,CAAC;AAEF,OAAI,CAAC,uBAAwB,OAAM,IAAI,MAAM,0CAA0C;GAKvF,MAAMC,iBAAuC;IAC3C,gBAAgB,kBAAkB,aAAa;IAC/C;IACD;GAED,MAAM,+BAA+B,MAAM,MAAM,GAAG,KAAK,QAAQ,yBAAyB;IACxF,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,gBAAgB,KAAK;KACtB;IACD,MAAM,KAAK,UAAU,eAAe;IACrC,CAAC;AAMF,UAAO;IACL,SAAS;IACT,MAAM,EACJ,sBANF,MAAM,KAAK,cAA8C,6BAA6B,EAMtC,qBAC/C;IACF;WACM,OAAO;AAEd,UAAO;IACL,SAAS;IACT,OAAO,EACL,SAAS,iBAAiB,QAAQ,MAAM,UAAU,iBACnD;IACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["bodyText: string","json: any","body: UpdateCredentialLabelBody"],"sources":["../src/plainKey.ts"],"sourcesContent":["import {\n startAuthentication,\n startRegistration,\n type PublicKeyCredentialCreationOptionsJSON,\n type PublicKeyCredentialRequestOptionsJSON\n} from \"@simplewebauthn/browser\"\n\nimport type {\n AuthenticateResult,\n AddPasskeyResult,\n CreateUserWithPasskeyResult,\n UpdatePasskeyLabelResult,\n UserIdentifier\n} from \"./types\"\n\nimport type {\n BeginUserRegistration200,\n CompleteUserRegistration200,\n BeginCredentialRegistration200,\n CompleteCredentialRegistration200,\n BeginAuthentication200,\n CompleteAuthentication200,\n UpdateCredentialLabelBody\n} from \"./generated/api\"\n\n/**\n * PlainKey client for the browser. Used to register new users, add passkeys to existing users, and log users in.\n *\n * Docs: https://plainkey.io/docs\n *\n * @param projectId - Your PlainKey project ID. You can find it in the PlainKey admin dashboard.\n * @param baseUrl - Set by default to https://api.plainkey.io/browser. Change only for development purposes.\n */\nexport class PlainKey {\n private readonly projectId: string\n private readonly baseUrl: string\n\n constructor(projectId: string, baseUrl: string = \"https://api.plainkey.io/browser\") {\n if (!projectId) throw new Error(\"Project ID is required\")\n if (!baseUrl) throw new Error(\"Base URL is required\")\n\n this.projectId = projectId\n this.baseUrl = baseUrl.replace(/\\/$/, \"\") // Remove trailing slash\n }\n\n /**\n * Helper to parse response JSON.\n * Throws error if status code is not 200 OK or if the response is not valid JSON.\n */\n private async parseResponse<T = any>(response: Response): Promise<T> {\n let bodyText: string\n\n // Read as text first to avoid JSON.parse errors on any HTML/plaintext error responses.\n try {\n bodyText = await response.text()\n } catch {\n throw new Error(\"Network error while reading server response\")\n }\n\n let json: any\n\n try {\n json = bodyText ? JSON.parse(bodyText) : {}\n } catch {\n if (!response.ok) throw new Error(\"Server returned an invalid JSON error response\")\n throw new Error(\"Invalid JSON received from server\")\n }\n\n if (!response.ok) {\n const message = json && typeof json.error === \"string\" ? json.error : \"Unknown server error\"\n throw new Error(message)\n }\n\n return json as T\n }\n\n /**\n * Registration of a new user with a passkey. Will require user interaction to create a passkey.\n *\n * @param userName - A unique identifier for the user, like an email address or username.\n * Can be empty for usernameless authentication.\n */\n async createUserWithPasskey(userName?: string): Promise<CreateUserWithPasskeyResult> {\n try {\n // Step 1: Get registration options from server\n const beginResponse = await fetch(`${this.baseUrl}/user/register/begin`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify({ userName })\n })\n\n const { userId, options } =\n await this.parseResponse<BeginUserRegistration200>(beginResponse)\n\n // Step 2: Create credential using browser's WebAuthn API\n const credential = await startRegistration({\n optionsJSON: options as unknown as PublicKeyCredentialCreationOptionsJSON\n })\n\n // Step 3: Send credential to server for verification\n const completeResponse = await fetch(`${this.baseUrl}/user/register/complete`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify({ userId, credential })\n })\n\n const completeData = await this.parseResponse<CompleteUserRegistration200>(completeResponse)\n\n if (!completeData.success) throw new Error(\"Server could not complete registration\")\n\n return {\n success: true,\n data: {\n userId: completeData.userId,\n authenticationToken: completeData.authenticationToken,\n credential: completeData.credential\n }\n }\n } catch (error) {\n return {\n success: false,\n error: { message: error instanceof Error ? error.message : \"Unknown error\" }\n }\n }\n }\n\n /**\n * Adds a passkey to an existing user. Will require user interaction to create a passkey.\n *\n * @param authenticationToken - The user authentication token, returned from .authenticate() or createUserWithPasskey().\n * Do NOT store it in local storage, database, etc. Always keep it in memory.\n * @param userName - A unique identifier for the user. If not provided, the user's stored userName will be used.\n */\n async addPasskey(authenticationToken: string, userName?: string): Promise<AddPasskeyResult> {\n if (!authenticationToken) throw new Error(\"Authentication token is required\")\n\n try {\n // Step 1: Get credential registration options from server\n const beginResponse = await fetch(`${this.baseUrl}/user/credential/begin`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify({ authenticationToken, userName })\n })\n\n const { options } = await this.parseResponse<BeginCredentialRegistration200>(beginResponse)\n\n // Step 2: Create credential using browser's WebAuthn API\n const credential = await startRegistration({\n optionsJSON: options as unknown as PublicKeyCredentialCreationOptionsJSON\n })\n\n // Step 3: Send credential to server for verification\n const completeResponse = await fetch(`${this.baseUrl}/user/credential/complete`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify({ authenticationToken, credential })\n })\n\n const completeData =\n await this.parseResponse<CompleteCredentialRegistration200>(completeResponse)\n\n if (!completeData.success) throw new Error(\"Server could not complete passkey registration\")\n\n return {\n success: true,\n data: {\n authenticationToken: completeData.authenticationToken,\n credential: completeData.credential\n }\n }\n } catch (error) {\n return {\n success: false,\n error: { message: error instanceof Error ? error.message : \"Unknown error\" }\n }\n }\n }\n\n /**\n * Updates a passkey label. Any passkey registered to the user can be updated.\n *\n * @param authenticationToken - The user authentication token, returned from .authenticate() or createUserWithPasskey().\n * Do NOT store it in local storage, database, etc. Always keep it in memory.\n * @param credentialId - The ID of the passkey to update, returned from createUserWithPasskey() or addPasskey().\n * @param label - The new label for the passkey.\n */\n async updatePasskeyLabel(\n authenticationToken: string,\n credentialId: string,\n label: string\n ): Promise<UpdatePasskeyLabelResult> {\n if (!authenticationToken) throw new Error(\"Authentication token is required\")\n if (!credentialId) throw new Error(\"Credential ID is required\")\n\n try {\n const body: UpdateCredentialLabelBody = { authenticationToken, label }\n const response = await fetch(`${this.baseUrl}/credential/${credentialId}/label`, {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify(body)\n })\n\n if (!response.ok) throw new Error(\"Failed to update passkey label\")\n\n return { success: true }\n } catch (error) {\n return {\n success: false,\n error: { message: error instanceof Error ? error.message : \"Unknown error\" }\n }\n }\n }\n\n /**\n * Authenticates a user. Can be used for login, verification, 2FA, etc.\n * Will require user interaction to authenticate.\n *\n * @param userIdentifier - Optional. Identify the user by their PlainKey user ID or userName.\n * Not required for usernameless authentication.\n */\n async authenticate(userIdentifier?: UserIdentifier): Promise<AuthenticateResult> {\n try {\n // Step 1: Get authentication options from server\n const beginResponse = await fetch(`${this.baseUrl}/authenticate/begin`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify({ userIdentifier })\n })\n\n const beginData = await this.parseResponse<BeginAuthentication200>(beginResponse)\n\n if (!beginData.options) throw new Error(\"Server returned no options in authentication begin response\")\n\n // Step 2: Pass options to the authenticator and wait for response\n const authenticationResponse = await startAuthentication({\n optionsJSON: beginData.options as unknown as PublicKeyCredentialRequestOptionsJSON\n })\n\n if (!authenticationResponse) throw new Error(\"No authentication response from browser\")\n\n // Step 3: POST the response to the server\n const completeResponse = await fetch(`${this.baseUrl}/authenticate/complete`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-project-id\": this.projectId\n },\n body: JSON.stringify({\n loginSessionId: beginData.loginSession.id,\n authenticationResponse\n })\n })\n\n const completeData = await this.parseResponse<CompleteAuthentication200>(completeResponse)\n\n return {\n success: true,\n data: { authenticationToken: completeData.authenticationToken }\n }\n } catch (error) {\n return {\n success: false,\n error: { message: error instanceof Error ? error.message : \"Unknown error\" }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAiCA,IAAa,WAAb,MAAsB;CAIpB,YAAY,WAAmB,UAAkB,mCAAmC;AAClF,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,yBAAyB;AACzD,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,uBAAuB;AAErD,OAAK,YAAY;AACjB,OAAK,UAAU,QAAQ,QAAQ,OAAO,GAAG;;;;;;CAO3C,MAAc,cAAuB,UAAgC;EACnE,IAAIA;AAGJ,MAAI;AACF,cAAW,MAAM,SAAS,MAAM;UAC1B;AACN,SAAM,IAAI,MAAM,8CAA8C;;EAGhE,IAAIC;AAEJ,MAAI;AACF,UAAO,WAAW,KAAK,MAAM,SAAS,GAAG,EAAE;UACrC;AACN,OAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,iDAAiD;AACnF,SAAM,IAAI,MAAM,oCAAoC;;AAGtD,MAAI,CAAC,SAAS,IAAI;GAChB,MAAM,UAAU,QAAQ,OAAO,KAAK,UAAU,WAAW,KAAK,QAAQ;AACtE,SAAM,IAAI,MAAM,QAAQ;;AAG1B,SAAO;;;;;;;;CAST,MAAM,sBAAsB,UAAyD;AACnF,MAAI;GAEF,MAAM,gBAAgB,MAAM,MAAM,GAAG,KAAK,QAAQ,uBAAuB;IACvE,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,gBAAgB,KAAK;KACtB;IACD,MAAM,KAAK,UAAU,EAA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,CAAC,uBAAwB,OAAM,IAAI,MAAM,0CAA0C;GAGvF,MAAM,mBAAmB,MAAM,MAAM,GAAG,KAAK,QAAQ,yBAAyB;IAC5E,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,gBAAgB,KAAK;KACtB;IACD,MAAM,KAAK,UAAU;KACnB,gBAAgB,UAAU,aAAa;KACvC;KACD,CAAC;IACH,CAAC;AAIF,UAAO;IACL,SAAS;IACT,MAAM,EAAE,sBAJW,MAAM,KAAK,cAAyC,iBAAiB,EAI9C,qBAAqB;IAChE;WACM,OAAO;AACd,UAAO;IACL,SAAS;IACT,OAAO,EAAE,SAAS,iBAAiB,QAAQ,MAAM,UAAU,iBAAiB;IAC7E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plainkey/browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "PlainKey browser SDK for passkey registration, login and credential management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@plainkey/types": "0.17.0",
|
|
27
26
|
"@simplewebauthn/browser": "^13.2.0"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|