@turnkey/http 0.17.1 → 0.18.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/CHANGELOG.md +7 -0
- package/dist/__generated__/services/coordinator/public/v1/public_api.fetcher.d.ts +2593 -528
- package/dist/__generated__/services/coordinator/public/v1/public_api.fetcher.d.ts.map +1 -1
- package/dist/__generated__/services/coordinator/public/v1/public_api.fetcher.js +372 -1
- package/dist/__generated__/services/coordinator/public/v1/public_api.fetcher.js.map +1 -1
- package/dist/__generated__/services/coordinator/public/v1/public_api.swagger.json +331 -43
- package/dist/__generated__/services/coordinator/public/v1/public_api.types.d.ts +181 -10
- package/dist/__generated__/services/coordinator/public/v1/public_api.types.d.ts.map +1 -1
- package/dist/base.d.ts +10 -1
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +29 -2
- package/dist/base.js.map +1 -1
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -1
- package/dist/config.js.map +1 -1
- package/dist/encoding.d.ts +1 -0
- package/dist/encoding.d.ts.map +1 -1
- package/dist/encoding.js +6 -8
- package/dist/encoding.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/shared.d.ts +5 -0
- package/dist/shared.d.ts.map +1 -1
- package/dist/webauthn-json/api.d.ts +13 -0
- package/dist/webauthn-json/api.d.ts.map +1 -0
- package/dist/webauthn-json/api.js +33 -0
- package/dist/webauthn-json/api.js.map +1 -0
- package/dist/webauthn-json/base64url.d.ts +4 -0
- package/dist/webauthn-json/base64url.d.ts.map +1 -0
- package/dist/webauthn-json/base64url.js +37 -0
- package/dist/webauthn-json/base64url.js.map +1 -0
- package/dist/webauthn-json/convert.d.ts +8 -0
- package/dist/webauthn-json/convert.d.ts.map +1 -0
- package/dist/webauthn-json/convert.js +69 -0
- package/dist/webauthn-json/convert.js.map +1 -0
- package/dist/webauthn-json/index.d.ts +14 -0
- package/dist/webauthn-json/index.d.ts.map +1 -0
- package/dist/webauthn-json/index.js +19 -0
- package/dist/webauthn-json/index.js.map +1 -0
- package/dist/webauthn-json/json.d.ts +92 -0
- package/dist/webauthn-json/json.d.ts.map +1 -0
- package/dist/webauthn-json/json.js +3 -0
- package/dist/webauthn-json/json.js.map +1 -0
- package/dist/webauthn-json/schema-format.d.ts +13 -0
- package/dist/webauthn-json/schema-format.d.ts.map +1 -0
- package/dist/webauthn-json/schema-format.js +3 -0
- package/dist/webauthn-json/schema-format.js.map +1 -0
- package/dist/webauthn-json/schema.d.ts +9 -0
- package/dist/webauthn-json/schema.d.ts.map +1 -0
- package/dist/webauthn-json/schema.js +86 -0
- package/dist/webauthn-json/schema.js.map +1 -0
- package/dist/webauthn.d.ts +24 -0
- package/dist/webauthn.d.ts.map +1 -0
- package/dist/webauthn.js +82 -0
- package/dist/webauthn.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.publicKeyCredentialWithAssertion = exports.credentialRequestOptions = exports.publicKeyCredentialWithAttestation = exports.credentialCreationOptions = void 0;
|
|
4
|
+
const convert_1 = require("./convert");
|
|
5
|
+
// Shared by `create()` and `get()`.
|
|
6
|
+
const publicKeyCredentialDescriptorSchema = {
|
|
7
|
+
type: (0, convert_1.required)(convert_1.copyValue),
|
|
8
|
+
id: (0, convert_1.required)(convert_1.convertValue),
|
|
9
|
+
transports: (0, convert_1.optional)(convert_1.copyValue),
|
|
10
|
+
};
|
|
11
|
+
const simplifiedExtensionsSchema = {
|
|
12
|
+
appid: (0, convert_1.optional)(convert_1.copyValue),
|
|
13
|
+
appidExclude: (0, convert_1.optional)(convert_1.copyValue),
|
|
14
|
+
credProps: (0, convert_1.optional)(convert_1.copyValue),
|
|
15
|
+
};
|
|
16
|
+
const simplifiedClientExtensionResultsSchema = {
|
|
17
|
+
appid: (0, convert_1.optional)(convert_1.copyValue),
|
|
18
|
+
appidExclude: (0, convert_1.optional)(convert_1.copyValue),
|
|
19
|
+
credProps: (0, convert_1.optional)(convert_1.copyValue),
|
|
20
|
+
};
|
|
21
|
+
// `navigator.create()` request
|
|
22
|
+
exports.credentialCreationOptions = {
|
|
23
|
+
publicKey: (0, convert_1.required)({
|
|
24
|
+
rp: (0, convert_1.required)(convert_1.copyValue),
|
|
25
|
+
user: (0, convert_1.required)({
|
|
26
|
+
id: (0, convert_1.required)(convert_1.convertValue),
|
|
27
|
+
name: (0, convert_1.required)(convert_1.copyValue),
|
|
28
|
+
displayName: (0, convert_1.required)(convert_1.copyValue),
|
|
29
|
+
}),
|
|
30
|
+
challenge: (0, convert_1.required)(convert_1.convertValue),
|
|
31
|
+
pubKeyCredParams: (0, convert_1.required)(convert_1.copyValue),
|
|
32
|
+
timeout: (0, convert_1.optional)(convert_1.copyValue),
|
|
33
|
+
excludeCredentials: (0, convert_1.optional)([publicKeyCredentialDescriptorSchema]),
|
|
34
|
+
authenticatorSelection: (0, convert_1.optional)(convert_1.copyValue),
|
|
35
|
+
attestation: (0, convert_1.optional)(convert_1.copyValue),
|
|
36
|
+
extensions: (0, convert_1.optional)(simplifiedExtensionsSchema),
|
|
37
|
+
}),
|
|
38
|
+
signal: (0, convert_1.optional)(convert_1.copyValue),
|
|
39
|
+
};
|
|
40
|
+
// `navigator.create()` response
|
|
41
|
+
exports.publicKeyCredentialWithAttestation = {
|
|
42
|
+
type: (0, convert_1.required)(convert_1.copyValue),
|
|
43
|
+
id: (0, convert_1.required)(convert_1.copyValue),
|
|
44
|
+
rawId: (0, convert_1.required)(convert_1.convertValue),
|
|
45
|
+
authenticatorAttachment: (0, convert_1.optional)(convert_1.copyValue),
|
|
46
|
+
response: (0, convert_1.required)({
|
|
47
|
+
clientDataJSON: (0, convert_1.required)(convert_1.convertValue),
|
|
48
|
+
attestationObject: (0, convert_1.required)(convert_1.convertValue),
|
|
49
|
+
transports: (0, convert_1.derived)(convert_1.copyValue, (response) => response.getTransports?.() || []),
|
|
50
|
+
}),
|
|
51
|
+
clientExtensionResults: (0, convert_1.derived)(simplifiedClientExtensionResultsSchema, (pkc) => pkc.getClientExtensionResults()),
|
|
52
|
+
};
|
|
53
|
+
// `navigator.get()` request
|
|
54
|
+
exports.credentialRequestOptions = {
|
|
55
|
+
mediation: (0, convert_1.optional)(convert_1.copyValue),
|
|
56
|
+
publicKey: (0, convert_1.required)({
|
|
57
|
+
challenge: (0, convert_1.required)(convert_1.convertValue),
|
|
58
|
+
timeout: (0, convert_1.optional)(convert_1.copyValue),
|
|
59
|
+
rpId: (0, convert_1.optional)(convert_1.copyValue),
|
|
60
|
+
allowCredentials: (0, convert_1.optional)([publicKeyCredentialDescriptorSchema]),
|
|
61
|
+
userVerification: (0, convert_1.optional)(convert_1.copyValue),
|
|
62
|
+
extensions: (0, convert_1.optional)(simplifiedExtensionsSchema),
|
|
63
|
+
}),
|
|
64
|
+
signal: (0, convert_1.optional)(convert_1.copyValue),
|
|
65
|
+
};
|
|
66
|
+
// `navigator.get()` response
|
|
67
|
+
exports.publicKeyCredentialWithAssertion = {
|
|
68
|
+
type: (0, convert_1.required)(convert_1.copyValue),
|
|
69
|
+
id: (0, convert_1.required)(convert_1.copyValue),
|
|
70
|
+
rawId: (0, convert_1.required)(convert_1.convertValue),
|
|
71
|
+
authenticatorAttachment: (0, convert_1.optional)(convert_1.copyValue),
|
|
72
|
+
response: (0, convert_1.required)({
|
|
73
|
+
clientDataJSON: (0, convert_1.required)(convert_1.convertValue),
|
|
74
|
+
authenticatorData: (0, convert_1.required)(convert_1.convertValue),
|
|
75
|
+
signature: (0, convert_1.required)(convert_1.convertValue),
|
|
76
|
+
userHandle: (0, convert_1.required)(convert_1.convertValue),
|
|
77
|
+
}),
|
|
78
|
+
clientExtensionResults: (0, convert_1.derived)(simplifiedClientExtensionResultsSchema, (pkc) => pkc.getClientExtensionResults()),
|
|
79
|
+
};
|
|
80
|
+
exports.schema = {
|
|
81
|
+
credentialCreationOptions: exports.credentialCreationOptions,
|
|
82
|
+
publicKeyCredentialWithAttestation: exports.publicKeyCredentialWithAttestation,
|
|
83
|
+
credentialRequestOptions: exports.credentialRequestOptions,
|
|
84
|
+
publicKeyCredentialWithAssertion: exports.publicKeyCredentialWithAssertion,
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/webauthn-json/schema.ts"],"names":[],"mappings":";;;AACA,uCAMmB;AAEnB,oCAAoC;AAEpC,MAAM,mCAAmC,GAAW;IAClD,IAAI,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;IACpB,EAAE,EAAE,IAAA,kBAAQ,EAAC,sBAAO,CAAC;IACrB,UAAU,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,0BAA0B,GAAW;IACzC,KAAK,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;IACrB,YAAY,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;IAC5B,SAAS,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,sCAAsC,GAAG;IAC7C,KAAK,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;IACrB,YAAY,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;IAC5B,SAAS,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;CAC1B,CAAC;AAEF,+BAA+B;AAElB,QAAA,yBAAyB,GAAW;IAC/C,SAAS,EAAE,IAAA,kBAAQ,EAAC;QAClB,EAAE,EAAE,IAAA,kBAAQ,EAAC,mBAAI,CAAC;QAClB,IAAI,EAAE,IAAA,kBAAQ,EAAC;YACb,EAAE,EAAE,IAAA,kBAAQ,EAAC,sBAAO,CAAC;YACrB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,EAAzB,iCAAyB;IACzB,kCAAkC,EAAlC,0CAAkC;IAClC,wBAAwB,EAAxB,gCAAwB;IACxB,gCAAgC,EAAhC,wCAAgC;CACjC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { definitions } from "./__generated__/services/coordinator/public/v1/public_api.types";
|
|
2
|
+
type TAttestation = definitions["v1Attestation"];
|
|
3
|
+
type ExternalAuthenticatorTransports = AuthenticatorTransport | "hybrid";
|
|
4
|
+
type InternalAuthenticatorTransports = definitions["externaldatav1AuthenticatorTransport"];
|
|
5
|
+
export type TurnkeyPublicKeyCredentialRequestOptions = {
|
|
6
|
+
timeout?: number;
|
|
7
|
+
rpId?: string;
|
|
8
|
+
allowCredentials?: PublicKeyCredentialDescriptor[];
|
|
9
|
+
userVerification?: UserVerificationRequirement;
|
|
10
|
+
extensions?: AuthenticationExtensionsClientInputs;
|
|
11
|
+
};
|
|
12
|
+
export type TurnkeyCredentialRequestOptions = {
|
|
13
|
+
mediation?: CredentialMediationRequirement;
|
|
14
|
+
publicKey: TurnkeyPublicKeyCredentialRequestOptions;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
password?: boolean;
|
|
17
|
+
unmediated?: boolean;
|
|
18
|
+
};
|
|
19
|
+
type TurnkeyCredentialCreationOptions = CredentialCreationOptions;
|
|
20
|
+
export type { TurnkeyCredentialCreationOptions };
|
|
21
|
+
export declare function protocolTransportEnumToInternalEnum(protocolEnum: ExternalAuthenticatorTransports): InternalAuthenticatorTransports;
|
|
22
|
+
export declare function getWebAuthnAssertion(payload: string, options?: TurnkeyCredentialRequestOptions): Promise<string>;
|
|
23
|
+
export declare function getWebAuthnAttestation(options: TurnkeyCredentialCreationOptions): Promise<TAttestation>;
|
|
24
|
+
//# sourceMappingURL=webauthn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../src/webauthn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iEAAiE,CAAC;AAQnG,KAAK,YAAY,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;AAGjD,KAAK,+BAA+B,GAAG,sBAAsB,GAAG,QAAQ,CAAC;AACzE,KAAK,+BAA+B,GAClC,WAAW,CAAC,sCAAsC,CAAC,CAAC;AAMtD,MAAM,MAAM,wCAAwC,GAAG;IAErD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,6BAA6B,EAAE,CAAC;IACnD,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;IAC/C,UAAU,CAAC,EAAE,oCAAoC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,SAAS,CAAC,EAAE,8BAA8B,CAAC;IAC3C,SAAS,EAAE,wCAAwC,CAAC;IACpD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,gCAAgC,GAAG,yBAAyB,CAAC;AAElE,YAAY,EAAE,gCAAgC,EAAE,CAAC;AAoCjD,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,+BAA+B,GAC5C,+BAA+B,CAqBjC;AAeD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,+BAA+B,GACxC,OAAO,CAAC,MAAM,CAAC,CAajB;AAED,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,YAAY,CAAC,CAIvB"}
|
package/dist/webauthn.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWebAuthnAttestation = exports.getWebAuthnAssertion = exports.protocolTransportEnumToInternalEnum = void 0;
|
|
4
|
+
const webauthn_json_1 = require("./webauthn-json");
|
|
5
|
+
const defaultTimeout = 5 * 60 * 1000; // five minutes
|
|
6
|
+
const defaultUserVerification = "preferred";
|
|
7
|
+
const defaultSigningOptions = {
|
|
8
|
+
publicKey: {
|
|
9
|
+
timeout: defaultTimeout,
|
|
10
|
+
userVerification: defaultUserVerification,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
async function getCredentialRequestOptions(payload, tkSigningOptions = defaultSigningOptions) {
|
|
14
|
+
const challenge = await getChallengeFromPayload(payload);
|
|
15
|
+
const signingOptions = {
|
|
16
|
+
...tkSigningOptions,
|
|
17
|
+
publicKey: {
|
|
18
|
+
...defaultSigningOptions.publicKey,
|
|
19
|
+
...tkSigningOptions.publicKey,
|
|
20
|
+
challenge,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return signingOptions;
|
|
24
|
+
}
|
|
25
|
+
async function getChallengeFromPayload(payload) {
|
|
26
|
+
const messageBuffer = new TextEncoder().encode(payload);
|
|
27
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", messageBuffer);
|
|
28
|
+
const hexString = Buffer.from(hashBuffer).toString("hex");
|
|
29
|
+
const hexBuffer = Buffer.from(hexString, "utf8");
|
|
30
|
+
return new Uint8Array(hexBuffer);
|
|
31
|
+
}
|
|
32
|
+
/* Pulled from https://www.w3.org/TR/webauthn-2/#enum-transport */
|
|
33
|
+
function protocolTransportEnumToInternalEnum(protocolEnum) {
|
|
34
|
+
switch (protocolEnum) {
|
|
35
|
+
case "internal": {
|
|
36
|
+
return "AUTHENTICATOR_TRANSPORT_INTERNAL";
|
|
37
|
+
}
|
|
38
|
+
case "usb": {
|
|
39
|
+
return "AUTHENTICATOR_TRANSPORT_USB";
|
|
40
|
+
}
|
|
41
|
+
case "nfc": {
|
|
42
|
+
return "AUTHENTICATOR_TRANSPORT_NFC";
|
|
43
|
+
}
|
|
44
|
+
case "ble": {
|
|
45
|
+
return "AUTHENTICATOR_TRANSPORT_BLE";
|
|
46
|
+
}
|
|
47
|
+
case "hybrid": {
|
|
48
|
+
return "AUTHENTICATOR_TRANSPORT_HYBRID";
|
|
49
|
+
}
|
|
50
|
+
default: {
|
|
51
|
+
throw new Error("unsupported transport format");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.protocolTransportEnumToInternalEnum = protocolTransportEnumToInternalEnum;
|
|
56
|
+
function toInternalAttestation(attestation) {
|
|
57
|
+
return {
|
|
58
|
+
credentialId: attestation.rawId,
|
|
59
|
+
attestationObject: attestation.response.attestationObject,
|
|
60
|
+
clientDataJson: attestation.response.clientDataJSON,
|
|
61
|
+
transports: attestation.response.transports.map(protocolTransportEnumToInternalEnum),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function getWebAuthnAssertion(payload, options) {
|
|
65
|
+
const signingOptions = await getCredentialRequestOptions(payload, options);
|
|
66
|
+
const clientGetResult = await (0, webauthn_json_1.get)(signingOptions);
|
|
67
|
+
const assertion = clientGetResult.toJSON();
|
|
68
|
+
const stamp = {
|
|
69
|
+
authenticatorData: assertion.response.authenticatorData,
|
|
70
|
+
clientDataJson: assertion.response.clientDataJSON,
|
|
71
|
+
credentialId: assertion.id,
|
|
72
|
+
signature: assertion.response.signature,
|
|
73
|
+
};
|
|
74
|
+
return JSON.stringify(stamp);
|
|
75
|
+
}
|
|
76
|
+
exports.getWebAuthnAssertion = getWebAuthnAssertion;
|
|
77
|
+
async function getWebAuthnAttestation(options) {
|
|
78
|
+
const res = await (0, webauthn_json_1.create)(options);
|
|
79
|
+
return toInternalAttestation(res.toJSON());
|
|
80
|
+
}
|
|
81
|
+
exports.getWebAuthnAttestation = getWebAuthnAttestation;
|
|
82
|
+
//# sourceMappingURL=webauthn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.js","sourceRoot":"","sources":["../src/webauthn.ts"],"names":[],"mappings":";;;AAEA,mDAGyB;AAUzB,MA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