@getpara/web-sdk 1.8.0 → 2.0.0-alpha.3

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.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/web-sdk",
3
- "version": "1.8.0",
3
+ "version": "2.0.0-alpha.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,8 +8,8 @@
8
8
  "wasm_exec.js"
9
9
  ],
10
10
  "dependencies": {
11
- "@getpara/core-sdk": "1.8.0",
12
- "@getpara/user-management-client": "1.8.0",
11
+ "@getpara/core-sdk": "2.0.0-alpha.3",
12
+ "@getpara/user-management-client": "2.0.0-alpha.3",
13
13
  "@sentry/browser": "^9.1.0",
14
14
  "assert": "^2.1.0",
15
15
  "base64url": "3.0.1",
@@ -37,5 +37,5 @@
37
37
  "dist",
38
38
  "package.json"
39
39
  ],
40
- "gitHead": "ef96e79558695ccbe148d25a8e3611c4596d1954"
40
+ "gitHead": "77a1e04b06258842ca9c81e3db2a2b0092517659"
41
41
  }
@@ -1,36 +0,0 @@
1
- "use client";
2
- import "./chunk-M66XENHI.js";
3
- class LocalStorage {
4
- constructor() {
5
- this.get = (key) => {
6
- if (typeof window !== "undefined") {
7
- return localStorage.getItem(key) || null;
8
- }
9
- return null;
10
- };
11
- this.set = (key, value) => {
12
- if (typeof window !== "undefined") {
13
- localStorage.setItem(key, value);
14
- }
15
- };
16
- this.removeItem = (key) => {
17
- if (typeof window !== "undefined") {
18
- localStorage.removeItem(key);
19
- }
20
- };
21
- this.clear = (prefix) => {
22
- if (typeof window !== "undefined") {
23
- for (let i = 0; i < localStorage.length; i++) {
24
- const key = localStorage.key(i);
25
- if (key && key.startsWith(prefix)) {
26
- localStorage.removeItem(key);
27
- i--;
28
- }
29
- }
30
- }
31
- };
32
- }
33
- }
34
- export {
35
- LocalStorage
36
- };
package/dist/ParaWeb.js DELETED
@@ -1,22 +0,0 @@
1
- "use client";
2
- import "./chunk-M66XENHI.js";
3
- import * as Sentry from "@sentry/browser";
4
- import ParaCore, { Environment } from "@getpara/core-sdk";
5
- import { WebUtils } from "./WebUtils.js";
6
- class Para extends ParaCore {
7
- constructor(env, apiKey, opts) {
8
- super(env, apiKey, opts);
9
- if (env !== Environment.PROD && env !== Environment.DEV) {
10
- Sentry.init({
11
- environment: env.toLowerCase(),
12
- dsn: "https://38f27d4836da617ab9e95cf66b9611d9@o4504568036720640.ingest.us.sentry.io/4508850812944384"
13
- });
14
- }
15
- }
16
- getPlatformUtils() {
17
- return new WebUtils();
18
- }
19
- }
20
- export {
21
- Para
22
- };
@@ -1,36 +0,0 @@
1
- "use client";
2
- import "./chunk-M66XENHI.js";
3
- class SessionStorage {
4
- constructor() {
5
- this.get = (key) => {
6
- if (typeof window !== "undefined") {
7
- return sessionStorage.getItem(key) || null;
8
- }
9
- return null;
10
- };
11
- this.set = (key, value) => {
12
- if (typeof window !== "undefined") {
13
- sessionStorage.setItem(key, value);
14
- }
15
- };
16
- this.removeItem = (key) => {
17
- if (typeof window !== "undefined") {
18
- sessionStorage.removeItem(key);
19
- }
20
- };
21
- this.clear = (prefix) => {
22
- if (typeof window !== "undefined") {
23
- for (let i = 0; i < sessionStorage.length; i++) {
24
- const key = sessionStorage.key(i);
25
- if (key && key.startsWith(prefix)) {
26
- sessionStorage.removeItem(key);
27
- i--;
28
- }
29
- }
30
- }
31
- };
32
- }
33
- }
34
- export {
35
- SessionStorage
36
- };
package/dist/WebUtils.js DELETED
@@ -1,109 +0,0 @@
1
- "use client";
2
- import "./chunk-M66XENHI.js";
3
- import { PopupType } from "@getpara/core-sdk";
4
- import { LocalStorage } from "./LocalStorage.js";
5
- import { SessionStorage } from "./SessionStorage.js";
6
- import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen, refresh } from "./wallet/keygen.js";
7
- import { signMessage, sendTransaction, signTransaction, ed25519Sign } from "./wallet/signing.js";
8
- import { getPrivateKey } from "./wallet/privateKey.js";
9
- class WebUtils {
10
- constructor() {
11
- this.localStorage = new LocalStorage();
12
- this.sessionStorage = new SessionStorage();
13
- this.secureStorage = null;
14
- this.isSyncStorage = true;
15
- this.disableProviderModal = false;
16
- }
17
- getPrivateKey(ctx, userId, walletId, share, sessionCookie) {
18
- return getPrivateKey(ctx, userId, walletId, share, sessionCookie);
19
- }
20
- keygen(ctx, userId, type, secretKey, sessionCookie, emailProps = {}) {
21
- return keygen(ctx, userId, type, secretKey, true, sessionCookie, emailProps);
22
- }
23
- refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId) {
24
- return refresh(ctx, sessionCookie, userId, walletId, share, oldPartnerId, newPartnerId, keyShareProtocolId);
25
- }
26
- preKeygen(ctx, partnerId, pregenIdentifier, pregenIdentifierType, type, secretKey, sessionCookie) {
27
- return preKeygen(ctx, pregenIdentifier, pregenIdentifierType, type, secretKey, false, partnerId, sessionCookie);
28
- }
29
- signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc) {
30
- return signMessage(ctx, userId, walletId, share, message, sessionCookie, isDKLS, cosmosSignDoc);
31
- }
32
- signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
33
- return signTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS);
34
- }
35
- sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS) {
36
- return sendTransaction(ctx, userId, walletId, share, tx, chainId, sessionCookie, isDKLS);
37
- }
38
- signHash(_address, _hash) {
39
- throw new Error("not implemented");
40
- }
41
- ed25519Keygen(ctx, userId, sessionCookie, emailProps) {
42
- return ed25519Keygen(ctx, userId, sessionCookie, emailProps);
43
- }
44
- ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie) {
45
- return ed25519PreKeygen(ctx, pregenIdentifier, pregenIdentifierType, sessionCookie);
46
- }
47
- ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
48
- return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie);
49
- }
50
- openPopup(popupUrl, opts) {
51
- if (typeof window === "undefined") {
52
- return;
53
- }
54
- if (opts) {
55
- const { type } = opts;
56
- const popUpWidth = 550;
57
- let popUpHeight;
58
- switch (type) {
59
- case PopupType.LOGIN_PASSKEY: {
60
- popUpHeight = 798;
61
- break;
62
- }
63
- case PopupType.CREATE_PASSKEY: {
64
- popUpHeight = 464;
65
- break;
66
- }
67
- case PopupType.SIGN_MESSAGE_REVIEW: {
68
- popUpHeight = 585;
69
- break;
70
- }
71
- case PopupType.SIGN_TRANSACTION_REVIEW: {
72
- popUpHeight = 750;
73
- break;
74
- }
75
- case PopupType.OAUTH:
76
- default: {
77
- popUpHeight = 768;
78
- break;
79
- }
80
- }
81
- const dualScreenLeft = window.screenLeft !== void 0 ? window.screenLeft : window.screenX;
82
- const dualScreenTop = window.screenTop !== void 0 ? window.screenTop : window.screenY;
83
- const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
84
- const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
85
- const left = (width - popUpWidth) / 2 + dualScreenLeft;
86
- const top = (height - popUpHeight) / 2 + dualScreenTop;
87
- const windowFeatures = `toolbar=no, menubar=no, width=${popUpWidth},
88
- height=${popUpHeight}, top=${top}, left=${left}`;
89
- let popupWindow = window.open(popupUrl, type.toString(), windowFeatures);
90
- if (!popupWindow) {
91
- setTimeout(() => {
92
- popupWindow = window.open(popupUrl, "_blank");
93
- }, 0);
94
- }
95
- return popupWindow;
96
- } else {
97
- const popupWindow = window.open(popupUrl, "popup", "popup=true,width=400,height=500");
98
- if (!popupWindow) {
99
- setTimeout(() => {
100
- window.open(popupUrl, "_blank");
101
- }, 0);
102
- }
103
- return popupWindow;
104
- }
105
- }
106
- }
107
- export {
108
- WebUtils
109
- };
@@ -1,25 +0,0 @@
1
- "use client";
2
- var __async = (__this, __arguments, generator) => {
3
- return new Promise((resolve, reject) => {
4
- var fulfilled = (value) => {
5
- try {
6
- step(generator.next(value));
7
- } catch (e) {
8
- reject(e);
9
- }
10
- };
11
- var rejected = (value) => {
12
- try {
13
- step(generator.throw(value));
14
- } catch (e) {
15
- reject(e);
16
- }
17
- };
18
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
- step((generator = generator.apply(__this, __arguments)).next());
20
- });
21
- };
22
-
23
- export {
24
- __async
25
- };
@@ -1,162 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../chunk-M66XENHI.js";
5
- import base64url from "base64url";
6
- import * as cbor from "cbor-web";
7
- import forge from "node-forge";
8
- import { getPortalDomain } from "@getpara/core-sdk";
9
- const ES256_ALGORITHM = -7;
10
- const RS256_ALGORITHM = -257;
11
- function publicKeyCredentialToJSON(pubKeyCred) {
12
- if (pubKeyCred instanceof ArrayBuffer || ArrayBuffer.isView(pubKeyCred)) {
13
- return base64url.encode(pubKeyCred);
14
- } else if (pubKeyCred instanceof Array) {
15
- return pubKeyCred.map(publicKeyCredentialToJSON);
16
- } else if (pubKeyCred instanceof Object) {
17
- const obj = {};
18
- for (const key in pubKeyCred) {
19
- obj[key] = publicKeyCredentialToJSON(pubKeyCred[key]);
20
- }
21
- return obj;
22
- } else return pubKeyCred;
23
- }
24
- function parseMakeCredAuthData(buffer) {
25
- const rpIdHash = buffer.slice(0, 32);
26
- buffer = buffer.slice(32);
27
- const flagsBuf = buffer.slice(0, 1);
28
- buffer = buffer.slice(1);
29
- const flags = flagsBuf[0];
30
- const counterBuf = buffer.slice(0, 4);
31
- buffer = buffer.slice(4);
32
- const counter = counterBuf.readUInt32BE(0);
33
- const aaguid = buffer.slice(0, 16);
34
- buffer = buffer.slice(16);
35
- const credIDLenBuf = buffer.slice(0, 2);
36
- buffer = buffer.slice(2);
37
- const credIDLen = credIDLenBuf.readUInt16BE(0);
38
- const credID = buffer.slice(0, credIDLen);
39
- buffer = buffer.slice(credIDLen);
40
- const COSEPublicKey = buffer;
41
- return {
42
- rpIdHash,
43
- flagsBuf,
44
- flags,
45
- counter,
46
- counterBuf,
47
- aaguid,
48
- credID,
49
- COSEPublicKey
50
- };
51
- }
52
- function parseAttestationObject(attestationObject) {
53
- const attestationObjectBuffer = base64url.toBuffer(attestationObject);
54
- return cbor.decodeAllSync(attestationObjectBuffer)[0];
55
- }
56
- function COSEECDSAtoPKCS(COSEPublicKey) {
57
- const coseStruct = cbor.decodeAllSync(COSEPublicKey)[0];
58
- const tag = Buffer.from([4]);
59
- const x = coseStruct.get(-2);
60
- const y = coseStruct.get(-3);
61
- return Buffer.concat([tag, x, y]);
62
- }
63
- function COSERSAtoPKCS(COSEPublicKey) {
64
- const coseStruct = cbor.decodeAllSync(COSEPublicKey)[0];
65
- const n = coseStruct.get(-1);
66
- const e = coseStruct.get(-2);
67
- const nForge = forge.util.createBuffer(n.toString("binary"));
68
- const eForge = forge.util.createBuffer(e.toString("binary"));
69
- const publicKey = forge.pki.setRsaPublicKey(
70
- new forge.jsbn.BigInteger(nForge.toHex(), 16),
71
- new forge.jsbn.BigInteger(eForge.toHex(), 16)
72
- );
73
- return Buffer.from(forge.pki.publicKeyToPem(publicKey), "utf-8");
74
- }
75
- function parseCredentialCreationRes(creds, algorithm) {
76
- const parsedAttestation = parseAttestationObject(creds.response.attestationObject);
77
- const { COSEPublicKey, aaguid } = parseMakeCredAuthData(parsedAttestation.authData);
78
- if (algorithm === RS256_ALGORITHM) {
79
- return {
80
- cosePublicKey: base64url.encode(COSERSAtoPKCS(COSEPublicKey)),
81
- clientDataJSON: creds.response.clientDataJSON,
82
- aaguid: aaguid.toString("hex")
83
- };
84
- }
85
- return {
86
- cosePublicKey: base64url.encode(COSEECDSAtoPKCS(COSEPublicKey)),
87
- clientDataJSON: creds.response.clientDataJSON,
88
- aaguid: aaguid.toString("hex")
89
- };
90
- }
91
- function generateUserHandle() {
92
- const userHandle = new Uint8Array(32);
93
- window.crypto.getRandomValues(userHandle);
94
- return userHandle;
95
- }
96
- function createCredential(env, userId, identifier, isE2E) {
97
- return __async(this, null, function* () {
98
- if (typeof navigator === "undefined") {
99
- return;
100
- }
101
- const userHandle = generateUserHandle();
102
- const createCredentialDefaultArgs = {
103
- publicKey: {
104
- authenticatorSelection: {
105
- authenticatorAttachment: "platform",
106
- requireResidentKey: true,
107
- residentKey: "required",
108
- userVerification: "required"
109
- },
110
- rp: {
111
- id: getPortalDomain(env, isE2E),
112
- name: "Para"
113
- },
114
- user: {
115
- id: userHandle,
116
- name: identifier,
117
- displayName: identifier
118
- },
119
- pubKeyCredParams: [
120
- { type: "public-key", alg: ES256_ALGORITHM },
121
- // RS256_ALGORITHM should only be needed for windows hello
122
- { type: "public-key", alg: RS256_ALGORITHM }
123
- ],
124
- attestation: "direct",
125
- timeout: 6e4,
126
- // TODO: don't think we really get value from verifying this, but should revisit
127
- challenge: Buffer.from(userId, "utf-8")
128
- }
129
- };
130
- const credential = yield navigator.credentials.create(createCredentialDefaultArgs);
131
- const algorithm = credential.response.getPublicKeyAlgorithm ? credential.response.getPublicKeyAlgorithm() : ES256_ALGORITHM;
132
- const userHandleEncoded = base64url.encode(Buffer.from(userHandle));
133
- return {
134
- creds: publicKeyCredentialToJSON(credential),
135
- userHandle: userHandleEncoded,
136
- algorithm
137
- };
138
- });
139
- }
140
- function generateSignature(env, challenge, allowedPublicKeys, isE2E) {
141
- return __async(this, null, function* () {
142
- const getCredentialDefaultArgs = {
143
- publicKey: {
144
- timeout: 6e4,
145
- challenge: Buffer.from(challenge, "base64"),
146
- allowCredentials: allowedPublicKeys.map((key) => ({
147
- id: base64url.toBuffer(key),
148
- type: "public-key"
149
- })),
150
- userVerification: "required",
151
- rpId: getPortalDomain(env, isE2E)
152
- }
153
- };
154
- const assertation = yield navigator.credentials.get(getCredentialDefaultArgs);
155
- return publicKeyCredentialToJSON(assertation);
156
- });
157
- }
158
- export {
159
- createCredential,
160
- generateSignature,
161
- parseCredentialCreationRes
162
- };
package/dist/errors.js DELETED
@@ -1,12 +0,0 @@
1
- "use client";
2
- import "./chunk-M66XENHI.js";
3
- class TransactionReviewError extends Error {
4
- constructor(transactionReviewUrl) {
5
- super("transaction review error");
6
- this.name = "TransactionReviewError";
7
- this.transactionReviewUrl = transactionReviewUrl;
8
- }
9
- }
10
- export {
11
- TransactionReviewError
12
- };
package/dist/package.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "type": "module",
3
- "sideEffects": [
4
- "wasm_exec.js"
5
- ]
6
- }
@@ -1,10 +0,0 @@
1
- "use client";
2
- import "../chunk-M66XENHI.js";
3
- function getMailtoLink(email, recoveryShare) {
4
- const emailBody = `Hello,%0D%0DBelow is your Para Recovery Secret. Keep this safe!%0D%0D${recoveryShare}%0D%0DPlease get in touch via support@getpara.com if you have any questions`;
5
- const mailText = `mailto:${email}?subject=Para%20Recovery%20Secret&body=${emailBody}`;
6
- return mailText;
7
- }
8
- export {
9
- getMailtoLink
10
- };
@@ -1,37 +0,0 @@
1
- "use client";
2
- import "../chunk-M66XENHI.js";
3
- function hexStringToBase64(hexString) {
4
- if (hexString.substring(0, 2) === "0x") {
5
- hexString = hexString.substring(2);
6
- }
7
- return Buffer.from(hexString, "hex").toString("base64");
8
- }
9
- function hexToSignature(hexSig) {
10
- return {
11
- r: `0x${hexSig.slice(2, 66)}`,
12
- s: `0x${hexSig.slice(66, 130)}`,
13
- v: BigInt(hexSig.slice(130, 132))
14
- };
15
- }
16
- function hexToUint8Array(hex) {
17
- if (hex.startsWith("0x")) {
18
- hex = hex.slice(2);
19
- }
20
- return new Uint8Array(Buffer.from(hex, "hex"));
21
- }
22
- function hexToDecimal(hex) {
23
- if (hex.startsWith("0x")) {
24
- hex = hex.slice(2);
25
- }
26
- return `${parseInt(hex, 16)}`;
27
- }
28
- function decimalToHex(decimal) {
29
- return `0x${parseInt(decimal).toString(16)}`;
30
- }
31
- export {
32
- decimalToHex,
33
- hexStringToBase64,
34
- hexToDecimal,
35
- hexToSignature,
36
- hexToUint8Array
37
- };
@@ -1,47 +0,0 @@
1
- "use client";
2
- import "../chunk-M66XENHI.js";
3
- function isAndroid() {
4
- return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
5
- }
6
- function isSmallIOS() {
7
- return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent);
8
- }
9
- function isLargeIOS() {
10
- return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
11
- }
12
- function isTablet() {
13
- return typeof navigator !== "undefined" && /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
14
- navigator.userAgent
15
- );
16
- }
17
- function isIOS() {
18
- return isSmallIOS() || isLargeIOS();
19
- }
20
- function isMobile() {
21
- return isAndroid() || isIOS();
22
- }
23
- function isSafari() {
24
- return typeof navigator !== "undefined" && /AppleWebKit/i.test(navigator.userAgent) && !/CriOS/i.test(navigator.userAgent) && !/Chrome/i.test(navigator.userAgent);
25
- }
26
- function isIOSWebview() {
27
- const isStandalone = typeof navigator !== "undefined" && !navigator.standalone;
28
- return typeof navigator !== "undefined" && isIOS() && !isStandalone && !/safari/i.test(navigator.userAgent.toLowerCase());
29
- }
30
- function isMobileSafari() {
31
- return isMobile() && isSafari();
32
- }
33
- function isTelegram() {
34
- return typeof window !== "undefined" && (Boolean(window.TelegramWebviewProxy) || Boolean(window.Telegram) || Boolean(window.TelegramWebviewProxyProto));
35
- }
36
- export {
37
- isAndroid,
38
- isIOS,
39
- isIOSWebview,
40
- isLargeIOS,
41
- isMobile,
42
- isMobileSafari,
43
- isSafari,
44
- isSmallIOS,
45
- isTablet,
46
- isTelegram
47
- };
@@ -1,17 +0,0 @@
1
- "use client";
2
- import {
3
- __async
4
- } from "../chunk-M66XENHI.js";
5
- import { UAParser } from "ua-parser-js";
6
- const isPasskeySupported = (userAgent) => __async(void 0, null, function* () {
7
- var _a, _b, _c;
8
- const directPasskeyCheck = yield (_b = (_a = window == null ? void 0 : window.PublicKeyCredential) == null ? void 0 : _a.isUserVerifyingPlatformAuthenticatorAvailable) == null ? void 0 : _b.call(_a);
9
- if (directPasskeyCheck === true || directPasskeyCheck === false) {
10
- return directPasskeyCheck;
11
- }
12
- const osName = (_c = new UAParser(userAgent).getOS().name) == null ? void 0 : _c.toLowerCase();
13
- return !!osName && !["linux", "chrome os"].includes(osName);
14
- });
15
- export {
16
- isPasskeySupported
17
- };
@@ -1,11 +0,0 @@
1
- "use client";
2
- import "../chunk-M66XENHI.js";
3
- const truncateRegex = /^(0x[a-zA-Z0-9]{4})[a-zA-Z0-9]+([a-zA-Z0-9]{4})$/;
4
- const truncateEthAddress = (address) => {
5
- const match = address.match(truncateRegex);
6
- if (!match) return address;
7
- return `${match[1]}\u2026${match[2]}`;
8
- };
9
- export {
10
- truncateEthAddress
11
- };