@plainkey/vue 0.5.1 → 0.6.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 +14 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -104
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,40 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LoginBeginRequest, LoginCompleteResponse, RegistrationBeginRequest, RegistrationCompleteResponse, UserCredentialBeginRequest, UserCredentialCompleteResponse } from "@plainkey/types";
|
|
1
|
+
import { PlainKey } from "@plainkey/browser";
|
|
3
2
|
|
|
4
3
|
//#region src/usePlainkey/index.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
error: Ref<string | null, string | null>;
|
|
18
|
-
registerSuccess: Ref<boolean, boolean>;
|
|
19
|
-
registeredCredential: Ref<{
|
|
20
|
-
id: string;
|
|
21
|
-
webAuthnId: string;
|
|
22
|
-
} | null, {
|
|
23
|
-
id: string;
|
|
24
|
-
webAuthnId: string;
|
|
25
|
-
} | null>;
|
|
26
|
-
registeredResponse: Ref<RegistrationCompleteResponse | null, RegistrationCompleteResponse | null>;
|
|
27
|
-
addCredential: (addCredentialParams: AddCredentialParams) => Promise<UserCredentialCompleteResponse | ErrorResponse>;
|
|
28
|
-
isAddingCredential: Ref<boolean, boolean>;
|
|
29
|
-
addCredentialError: Ref<string | null, string | null>;
|
|
30
|
-
addCredentialSuccess: Ref<boolean, boolean>;
|
|
31
|
-
addedCredentialResponse: Ref<UserCredentialCompleteResponse | null, UserCredentialCompleteResponse | null>;
|
|
32
|
-
login: (loginParams: LoginParams) => Promise<LoginCompleteResponse>;
|
|
33
|
-
isLoggingIn: Ref<boolean, boolean>;
|
|
34
|
-
loginError: Ref<string | null, string | null>;
|
|
35
|
-
loginSuccess: Ref<boolean, boolean>;
|
|
36
|
-
loggedInResponse: Ref<LoginCompleteResponse | null, LoginCompleteResponse | null>;
|
|
37
|
-
};
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param projectId - Your PlainKey project ID. You can find it in the PlainKey admin dashboard.
|
|
8
|
+
* @param baseUrl - Set by default to https://api.plainkey.io/api. Change only for development purposes.
|
|
9
|
+
*
|
|
10
|
+
* Docs: https://plainkey.io/docs
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const { login, createUserWithPasskey, addPasskey } = usePlainKey("projectId")
|
|
14
|
+
*/
|
|
15
|
+
declare function usePlainKey(projectId: string, baseUrl?: string): PlainKey;
|
|
38
16
|
//#endregion
|
|
39
|
-
export {
|
|
17
|
+
export { usePlainKey };
|
|
40
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/usePlainkey/index.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/usePlainkey/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAYA;;;;;;;;iBAAgB,WAAA,uCAA+C"}
|
package/dist/index.js
CHANGED
|
@@ -1,109 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PlainKeyClient } from "@plainkey/browser";
|
|
1
|
+
import { PlainKey } from "@plainkey/browser";
|
|
3
2
|
|
|
4
3
|
//#region src/usePlainkey/index.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const isLoggingIn = ref(false);
|
|
18
|
-
const loginError = ref(null);
|
|
19
|
-
const loginSuccess = ref(false);
|
|
20
|
-
const loggedInResponse = ref(null);
|
|
21
|
-
async function register(registerParams) {
|
|
22
|
-
try {
|
|
23
|
-
isRegistering.value = true;
|
|
24
|
-
registerError.value = null;
|
|
25
|
-
registerSuccess.value = false;
|
|
26
|
-
registeredCredential.value = null;
|
|
27
|
-
const registrationResult = await plainKeyClient.Registration({ userName: registerParams?.userName });
|
|
28
|
-
registerSuccess.value = registrationResult.success;
|
|
29
|
-
registeredCredential.value = registrationResult.credential;
|
|
30
|
-
registeredResponse.value = registrationResult;
|
|
31
|
-
return registrationResult;
|
|
32
|
-
} catch (err) {
|
|
33
|
-
registerError.value = err instanceof Error ? err.message : "Registration failed";
|
|
34
|
-
return { error: registerError.value };
|
|
35
|
-
} finally {
|
|
36
|
-
isRegistering.value = false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The user must be logged in first. Pass in their user token and project ID in beginParams.
|
|
41
|
-
* However, do not store the token in local storage, database, etc. Always keep it in memory.
|
|
42
|
-
*/
|
|
43
|
-
async function addCredential(addCredentialParams) {
|
|
44
|
-
try {
|
|
45
|
-
isAddingCredential.value = true;
|
|
46
|
-
addCredentialError.value = null;
|
|
47
|
-
addCredentialSuccess.value = false;
|
|
48
|
-
addedCredentialResponse.value = null;
|
|
49
|
-
const credentialResult = await plainKeyClient.AddCredential({
|
|
50
|
-
userIdentifier: addCredentialParams.userIdentifier,
|
|
51
|
-
userToken: addCredentialParams.userToken
|
|
52
|
-
});
|
|
53
|
-
addCredentialSuccess.value = credentialResult.success;
|
|
54
|
-
addedCredentialResponse.value = credentialResult;
|
|
55
|
-
return credentialResult;
|
|
56
|
-
} catch (err) {
|
|
57
|
-
addCredentialError.value = err instanceof Error ? err.message : "Add credential failed";
|
|
58
|
-
return { error: addCredentialError.value };
|
|
59
|
-
} finally {
|
|
60
|
-
isAddingCredential.value = false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async function login(loginParams) {
|
|
64
|
-
try {
|
|
65
|
-
isLoggingIn.value = true;
|
|
66
|
-
loginError.value = null;
|
|
67
|
-
loginSuccess.value = false;
|
|
68
|
-
loggedInResponse.value = null;
|
|
69
|
-
const loginResult = await plainKeyClient.Login({ userIdentifier: loginParams.userIdentifier });
|
|
70
|
-
loginSuccess.value = loginResult.verified;
|
|
71
|
-
loggedInResponse.value = loginResult;
|
|
72
|
-
return loginResult;
|
|
73
|
-
} catch (err) {
|
|
74
|
-
loginError.value = err instanceof Error ? err.message : "Login failed";
|
|
75
|
-
return {
|
|
76
|
-
verified: false,
|
|
77
|
-
user: { id: "" },
|
|
78
|
-
token: {
|
|
79
|
-
token: "",
|
|
80
|
-
expiresInSeconds: 0,
|
|
81
|
-
tokenType: ""
|
|
82
|
-
},
|
|
83
|
-
session: void 0
|
|
84
|
-
};
|
|
85
|
-
} finally {
|
|
86
|
-
isLoggingIn.value = false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
register,
|
|
91
|
-
isRegistering,
|
|
92
|
-
error: registerError,
|
|
93
|
-
registerSuccess,
|
|
94
|
-
registeredCredential,
|
|
95
|
-
registeredResponse,
|
|
96
|
-
addCredential,
|
|
97
|
-
isAddingCredential,
|
|
98
|
-
addCredentialError,
|
|
99
|
-
addCredentialSuccess,
|
|
100
|
-
addedCredentialResponse,
|
|
101
|
-
login,
|
|
102
|
-
isLoggingIn,
|
|
103
|
-
loginError,
|
|
104
|
-
loginSuccess,
|
|
105
|
-
loggedInResponse
|
|
106
|
-
};
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param projectId - Your PlainKey project ID. You can find it in the PlainKey admin dashboard.
|
|
7
|
+
* @param baseUrl - Set by default to https://api.plainkey.io/api. Change only for development purposes.
|
|
8
|
+
*
|
|
9
|
+
* Docs: https://plainkey.io/docs
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const { login, createUserWithPasskey, addPasskey } = usePlainKey("projectId")
|
|
13
|
+
*/
|
|
14
|
+
function usePlainKey(projectId, baseUrl) {
|
|
15
|
+
return new PlainKey(projectId, baseUrl);
|
|
107
16
|
}
|
|
108
17
|
|
|
109
18
|
//#endregion
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/usePlainkey/index.ts"],"sourcesContent":["import { PlainKey } from \"@plainkey/browser\"\n\n/**\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/api. Change only for development purposes.\n *\n * Docs: https://plainkey.io/docs\n *\n * @example\n * const { login, createUserWithPasskey, addPasskey } = usePlainKey(\"projectId\")\n */\nexport function usePlainKey(projectId: string, baseUrl?: string) {\n return new PlainKey(projectId, baseUrl)\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,YAAY,WAAmB,SAAkB;AAC/D,QAAO,IAAI,SAAS,WAAW,QAAQ"}
|