@plainkey/browser 0.16.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.
@@ -0,0 +1,57 @@
1
+ import { AddPasskeyResult, AuthenticateResult, CreateUserWithPasskeyResult, UpdatePasskeyLabelResult, UserIdentifier } from "@plainkey/types";
2
+
3
+ //#region src/plainKey.d.ts
4
+
5
+ /**
6
+ * PlainKey client for the browser. Used to register new users, add passkeys to existing users, and log users in.
7
+ *
8
+ * Docs: https://plainkey.io/docs
9
+ *
10
+ * @param projectId - Your PlainKey project ID. You can find it in the PlainKey admin dashboard.
11
+ * @param baseUrl - Set by default to https://api.plainkey.io/browser. Change only for development purposes.
12
+ */
13
+ declare class PlainKey {
14
+ private readonly projectId;
15
+ private readonly baseUrl;
16
+ constructor(projectId: string, baseUrl?: string);
17
+ /**
18
+ * Helper to parse response JSON.
19
+ * Throws error if status code is not 200 OK, if the response is not valid JSON.
20
+ */
21
+ private parseResponse;
22
+ /**
23
+ * Registration of a new user with a passkey. Will require user interaction to create a passkey.
24
+ *
25
+ * @param userName - A unique identifier for the user, like an email address or username.
26
+ * Can be empty for usernameless authentication.
27
+ */
28
+ createUserWithPasskey(userName?: string): Promise<CreateUserWithPasskeyResult>;
29
+ /**
30
+ * Adds a passkey to an existing user. Will require user interaction to create a passkey.
31
+ *
32
+ * @param authenticationToken - The user authentication token, is returned from .authenticate() and createUserWithPasskey().
33
+ * Do NOT store it in local storage, database, etc. Always keep it in memory.
34
+ * @param userName - A unique identifier for the user, like an email address or username.
35
+ * If not provided, the user's stored userName will be used.
36
+ */
37
+ addPasskey(authenticationToken: string, userName?: string): Promise<AddPasskeyResult>;
38
+ /**
39
+ * Updates a passkey label. Requires authentication shortly before this call. Any passkey registered to the user can be updated.
40
+ * @param authenticationToken - The user authentication token, is returned from .authenticate() and createUserWithPasskey().
41
+ * Do NOT store it in local storage, database, etc. Always keep it in memory.
42
+ * @param credentialId - The ID of the passkey credential to update. Is returned from createUserWithPasskey() and addPasskey().
43
+ * @param label - The new label for the passkey.
44
+ */
45
+ updatePasskeyLabel(authenticationToken: string, credentialId: string, label: string): Promise<UpdatePasskeyLabelResult>;
46
+ /**
47
+ * Authenticates a user. Can be used for login, verification, 2FA, etc.
48
+ * Will require user interaction to authenticate.
49
+ *
50
+ * @param userIdentifier - Optional object containing either the user's PlainKey User ID or their userName.
51
+ * Does not have to be provided for usernameless authentication.
52
+ */
53
+ authenticate(userIdentifier?: UserIdentifier): Promise<AuthenticateResult>;
54
+ }
55
+ //#endregion
56
+ export { PlainKey };
57
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/plainKey.ts"],"sourcesContent":[],"mappings":";;;;;;AAgCA;;;;;;AA4LK,cA5LQ,QAAA,CA4LR;EAoCiC,iBAAA,SAAA;EAAyB,iBAAA,OAAA;EAAR,WAAA,CAAA,SAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAA,MAAA;EAAO;;;;;;;;;;;4CA7KZ,QAAQ;;;;;;;;;8DAkEU,QAAQ;;;;;;;;wFAuEvE,QAAQ;;;;;;;;gCAoCyB,iBAAiB,QAAQ"}
package/dist/index.js ADDED
@@ -0,0 +1,222 @@
1
+ import { startAuthentication, startRegistration } from "@simplewebauthn/browser";
2
+
3
+ //#region src/plainKey.ts
4
+ /**
5
+ * PlainKey client for the browser. Used to register new users, add passkeys to existing users, and log users in.
6
+ *
7
+ * Docs: https://plainkey.io/docs
8
+ *
9
+ * @param projectId - Your PlainKey project ID. You can find it in the PlainKey admin dashboard.
10
+ * @param baseUrl - Set by default to https://api.plainkey.io/browser. Change only for development purposes.
11
+ */
12
+ var PlainKey = class {
13
+ constructor(projectId, baseUrl = "https://api.plainkey.io/browser") {
14
+ if (!projectId) throw new Error("Project ID is required");
15
+ if (!baseUrl) throw new Error("Base URL is required");
16
+ this.projectId = projectId;
17
+ this.baseUrl = baseUrl.replace(/\/$/, "");
18
+ }
19
+ /**
20
+ * Helper to parse response JSON.
21
+ * Throws error if status code is not 200 OK, if the response is not valid JSON.
22
+ */
23
+ async parseResponse(response) {
24
+ let bodyText;
25
+ try {
26
+ bodyText = await response.text();
27
+ } catch {
28
+ throw new Error("Network error while reading server response");
29
+ }
30
+ let json;
31
+ try {
32
+ json = bodyText ? JSON.parse(bodyText) : {};
33
+ } catch {
34
+ if (!response.ok) throw new Error("Server returned an invalid JSON error response");
35
+ throw new Error("Invalid JSON received from server");
36
+ }
37
+ if (!response.ok) {
38
+ const message = json && typeof json.error === "string" ? json.error : "Unknown server error";
39
+ throw new Error(message);
40
+ }
41
+ return json;
42
+ }
43
+ /**
44
+ * Registration of a new user with a passkey. Will require user interaction to create a passkey.
45
+ *
46
+ * @param userName - A unique identifier for the user, like an email address or username.
47
+ * Can be empty for usernameless authentication.
48
+ */
49
+ async createUserWithPasskey(userName) {
50
+ try {
51
+ const beginRequestBody = { userName };
52
+ const beginResponse = await fetch(`${this.baseUrl}/user/register/begin`, {
53
+ method: "POST",
54
+ headers: {
55
+ "Content-Type": "application/json",
56
+ "x-project-id": this.projectId
57
+ },
58
+ body: JSON.stringify(beginRequestBody)
59
+ });
60
+ const { userId, options } = await this.parseResponse(beginResponse);
61
+ const completeRequestBody = {
62
+ userId,
63
+ credential: await startRegistration({ optionsJSON: options })
64
+ };
65
+ const completeResponse = await fetch(`${this.baseUrl}/user/register/complete`, {
66
+ method: "POST",
67
+ headers: {
68
+ "Content-Type": "application/json",
69
+ "x-project-id": this.projectId
70
+ },
71
+ body: JSON.stringify(completeRequestBody)
72
+ });
73
+ const completeResponseData = await this.parseResponse(completeResponse);
74
+ if (!completeResponseData.success) throw new Error("Server could not complete registration");
75
+ return {
76
+ success: completeResponseData.success,
77
+ data: {
78
+ userId: completeResponseData.userId,
79
+ authenticationToken: completeResponseData.authenticationToken,
80
+ credentialId: completeResponseData.credentialId
81
+ }
82
+ };
83
+ } catch (error) {
84
+ return {
85
+ success: false,
86
+ error: { message: error instanceof Error ? error.message : "Unknown error" }
87
+ };
88
+ }
89
+ }
90
+ /**
91
+ * Adds a passkey to an existing user. Will require user interaction to create a passkey.
92
+ *
93
+ * @param authenticationToken - The user authentication token, is returned from .authenticate() and createUserWithPasskey().
94
+ * Do NOT store it in local storage, database, etc. Always keep it in memory.
95
+ * @param userName - A unique identifier for the user, like an email address or username.
96
+ * If not provided, the user's stored userName will be used.
97
+ */
98
+ async addPasskey(authenticationToken, userName) {
99
+ if (!authenticationToken) throw new Error("Authentication token is required");
100
+ try {
101
+ const beginParams = {
102
+ authenticationToken,
103
+ userName
104
+ };
105
+ const beginResponse = await fetch(`${this.baseUrl}/user/credential/begin`, {
106
+ method: "POST",
107
+ headers: {
108
+ "Content-Type": "application/json",
109
+ "x-project-id": this.projectId
110
+ },
111
+ body: JSON.stringify(beginParams)
112
+ });
113
+ const { options } = await this.parseResponse(beginResponse);
114
+ const completeParams = {
115
+ authenticationToken,
116
+ credential: await startRegistration({ optionsJSON: options })
117
+ };
118
+ const completeResponse = await fetch(`${this.baseUrl}/user/credential/complete`, {
119
+ method: "POST",
120
+ headers: {
121
+ "Content-Type": "application/json",
122
+ "x-project-id": this.projectId
123
+ },
124
+ body: JSON.stringify(completeParams)
125
+ });
126
+ const completeResponseData = await this.parseResponse(completeResponse);
127
+ if (!completeResponseData.success) throw new Error("Server could not complete passkey registration");
128
+ return {
129
+ success: completeResponseData.success,
130
+ data: {
131
+ authenticationToken: completeResponseData.authenticationToken,
132
+ credentialId: completeResponseData.credentialId
133
+ }
134
+ };
135
+ } catch (error) {
136
+ return {
137
+ success: false,
138
+ error: { message: error instanceof Error ? error.message : "Unknown error" }
139
+ };
140
+ }
141
+ }
142
+ /**
143
+ * Updates a passkey label. Requires authentication shortly before this call. Any passkey registered to the user can be updated.
144
+ * @param authenticationToken - The user authentication token, is returned from .authenticate() and createUserWithPasskey().
145
+ * Do NOT store it in local storage, database, etc. Always keep it in memory.
146
+ * @param credentialId - The ID of the passkey credential to update. Is returned from createUserWithPasskey() and addPasskey().
147
+ * @param label - The new label for the passkey.
148
+ */
149
+ async updatePasskeyLabel(authenticationToken, credentialId, label) {
150
+ if (!authenticationToken) throw new Error("Authentication token is required");
151
+ if (!credentialId) throw new Error("Credential ID is required");
152
+ try {
153
+ const updateLabelParams = {
154
+ authenticationToken,
155
+ label
156
+ };
157
+ if (!(await fetch(`${this.baseUrl}/credential/${credentialId}/label`, {
158
+ method: "PATCH",
159
+ headers: {
160
+ "Content-Type": "application/json",
161
+ "x-project-id": this.projectId
162
+ },
163
+ body: JSON.stringify(updateLabelParams)
164
+ })).ok) throw new Error("Failed to update passkey label");
165
+ return { success: true };
166
+ } catch (error) {
167
+ return {
168
+ success: false,
169
+ error: { message: error instanceof Error ? error.message : "Unknown error" }
170
+ };
171
+ }
172
+ }
173
+ /**
174
+ * Authenticates a user. Can be used for login, verification, 2FA, etc.
175
+ * Will require user interaction to authenticate.
176
+ *
177
+ * @param userIdentifier - Optional object containing either the user's PlainKey User ID or their userName.
178
+ * Does not have to be provided for usernameless authentication.
179
+ */
180
+ async authenticate(userIdentifier) {
181
+ try {
182
+ const beginParams = { userIdentifier };
183
+ const beginResponse = await fetch(`${this.baseUrl}/authenticate/begin`, {
184
+ method: "POST",
185
+ headers: {
186
+ "Content-Type": "application/json",
187
+ "x-project-id": this.projectId
188
+ },
189
+ body: JSON.stringify(beginParams)
190
+ });
191
+ const beginResponseData = await this.parseResponse(beginResponse);
192
+ if (!beginResponseData.options) throw new Error("Server returned no options in login begin response");
193
+ const authenticationResponse = await startAuthentication({ optionsJSON: beginResponseData.options });
194
+ if (!authenticationResponse) throw new Error("No authentication response from browser");
195
+ const completeParams = {
196
+ loginSessionId: beginResponseData.loginSession.id,
197
+ authenticationResponse
198
+ };
199
+ const authenticateCompleteResponse = await fetch(`${this.baseUrl}/authenticate/complete`, {
200
+ method: "POST",
201
+ headers: {
202
+ "Content-Type": "application/json",
203
+ "x-project-id": this.projectId
204
+ },
205
+ body: JSON.stringify(completeParams)
206
+ });
207
+ return {
208
+ success: true,
209
+ data: { authenticationToken: (await this.parseResponse(authenticateCompleteResponse)).authenticationToken }
210
+ };
211
+ } catch (error) {
212
+ return {
213
+ success: false,
214
+ error: { message: error instanceof Error ? error.message : "Unknown error" }
215
+ };
216
+ }
217
+ }
218
+ };
219
+
220
+ //#endregion
221
+ export { PlainKey };
222
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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 credentialId: completeResponseData.credentialId\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 credentialId: completeResponseData.credentialId\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,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
3
+ "version": "0.16.0",
4
+ "description": "PlainKey browser SDK for passkey registration, login and credential management",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": "./dist/index.js",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "scripts": {
18
+ "build": "tsdown --clean --config tsdown.config.ts",
19
+ "prepare": "npm run build",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "@plainkey/types": "0.16.0",
27
+ "@simplewebauthn/browser": "^13.2.0"
28
+ },
29
+ "devDependencies": {
30
+ "tsdown": "^0.15.5"
31
+ }
32
+ }