@multiplatform.one/wallet 7.7.2
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/README.md +8 -0
- package/dist/cjs/SiweKeycloakProvider.cjs +273 -0
- package/dist/cjs/SiweKeycloakProvider.native.js +309 -0
- package/dist/cjs/SiweKeycloakProvider.native.js.map +1 -0
- package/dist/cjs/base64.cjs +51 -0
- package/dist/cjs/base64.native.js +55 -0
- package/dist/cjs/base64.native.js.map +1 -0
- package/dist/cjs/base64.spec.cjs +57 -0
- package/dist/cjs/base64.spec.native.js +79 -0
- package/dist/cjs/base64.spec.native.js.map +1 -0
- package/dist/cjs/context.cjs +29 -0
- package/dist/cjs/context.native.js +32 -0
- package/dist/cjs/context.native.js.map +1 -0
- package/dist/cjs/hooks/context.cjs +29 -0
- package/dist/cjs/hooks/context.native.js +32 -0
- package/dist/cjs/hooks/context.native.js.map +1 -0
- package/dist/cjs/hooks/index.cjs +20 -0
- package/dist/cjs/hooks/index.native.js +23 -0
- package/dist/cjs/hooks/index.native.js.map +1 -0
- package/dist/cjs/hooks/useSiweKeycloak.cjs +61 -0
- package/dist/cjs/hooks/useSiweKeycloak.native.js +64 -0
- package/dist/cjs/hooks/useSiweKeycloak.native.js.map +1 -0
- package/dist/cjs/index.cjs +133 -0
- package/dist/cjs/index.native.js +189 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/render.cjs +78 -0
- package/dist/cjs/render.native.js +82 -0
- package/dist/cjs/render.native.js.map +1 -0
- package/dist/cjs/siwe.cjs +76 -0
- package/dist/cjs/siwe.native.js +94 -0
- package/dist/cjs/siwe.native.js.map +1 -0
- package/dist/cjs/types.cjs +18 -0
- package/dist/cjs/types.native.js +21 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/util.cjs +53 -0
- package/dist/cjs/util.native.js +56 -0
- package/dist/cjs/util.native.js.map +1 -0
- package/dist/cjs/util.spec.cjs +53 -0
- package/dist/cjs/util.spec.native.js +62 -0
- package/dist/cjs/util.spec.native.js.map +1 -0
- package/dist/esm/SiweKeycloakProvider.mjs +237 -0
- package/dist/esm/SiweKeycloakProvider.mjs.map +1 -0
- package/dist/esm/SiweKeycloakProvider.native.js +270 -0
- package/dist/esm/SiweKeycloakProvider.native.js.map +1 -0
- package/dist/esm/base64.mjs +26 -0
- package/dist/esm/base64.mjs.map +1 -0
- package/dist/esm/base64.native.js +27 -0
- package/dist/esm/base64.native.js.map +1 -0
- package/dist/esm/base64.spec.mjs +58 -0
- package/dist/esm/base64.spec.mjs.map +1 -0
- package/dist/esm/base64.spec.native.js +77 -0
- package/dist/esm/base64.spec.native.js.map +1 -0
- package/dist/esm/context.mjs +4 -0
- package/dist/esm/context.mjs.map +1 -0
- package/dist/esm/context.native.js +4 -0
- package/dist/esm/context.native.js.map +1 -0
- package/dist/esm/hooks/context.mjs +4 -0
- package/dist/esm/hooks/context.mjs.map +1 -0
- package/dist/esm/hooks/context.native.js +4 -0
- package/dist/esm/hooks/context.native.js.map +1 -0
- package/dist/esm/hooks/index.mjs +2 -0
- package/dist/esm/hooks/index.mjs.map +1 -0
- package/dist/esm/hooks/index.native.js +2 -0
- package/dist/esm/hooks/index.native.js.map +1 -0
- package/dist/esm/hooks/useSiweKeycloak.mjs +36 -0
- package/dist/esm/hooks/useSiweKeycloak.mjs.map +1 -0
- package/dist/esm/hooks/useSiweKeycloak.native.js +36 -0
- package/dist/esm/hooks/useSiweKeycloak.native.js.map +1 -0
- package/dist/esm/index.mjs +107 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +160 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/render.mjs +42 -0
- package/dist/esm/render.mjs.map +1 -0
- package/dist/esm/render.native.js +43 -0
- package/dist/esm/render.native.js.map +1 -0
- package/dist/esm/siwe.mjs +51 -0
- package/dist/esm/siwe.mjs.map +1 -0
- package/dist/esm/siwe.native.js +66 -0
- package/dist/esm/siwe.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/util.mjs +27 -0
- package/dist/esm/util.mjs.map +1 -0
- package/dist/esm/util.native.js +27 -0
- package/dist/esm/util.native.js.map +1 -0
- package/dist/esm/util.spec.mjs +54 -0
- package/dist/esm/util.spec.mjs.map +1 -0
- package/dist/esm/util.spec.native.js +60 -0
- package/dist/esm/util.spec.native.js.map +1 -0
- package/package.json +81 -0
- package/src/SiweKeycloakProvider.tsx +297 -0
- package/src/base64.spec.ts +65 -0
- package/src/base64.ts +26 -0
- package/src/context.ts +10 -0
- package/src/hooks/context.ts +10 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useSiweKeycloak.ts +23 -0
- package/src/index.ts +127 -0
- package/src/main/java/com/bitspur/keycloak/siwe/Errors.java +21 -0
- package/src/main/java/com/bitspur/keycloak/siwe/LiteAuthenticationService.java +167 -0
- package/src/main/java/com/bitspur/keycloak/siwe/SiweCredentials.java +36 -0
- package/src/main/java/com/bitspur/keycloak/siwe/SiweSession.java +36 -0
- package/src/main/java/com/bitspur/keycloak/siwe/SiweUtil.java +599 -0
- package/src/main/java/com/bitspur/keycloak/siwe/Token.java +85 -0
- package/src/main/java/com/bitspur/keycloak/siwe/authenticators/browser/SiweBrowserAuthenticator.java +109 -0
- package/src/main/java/com/bitspur/keycloak/siwe/authenticators/browser/SiweBrowserAuthenticatorFactory.java +93 -0
- package/src/main/java/com/bitspur/keycloak/siwe/authenticators/directgrant/SiweDirectGrantAuthenticator.java +153 -0
- package/src/main/java/com/bitspur/keycloak/siwe/authenticators/directgrant/SiweDirectGrantAuthenticatorFactory.java +93 -0
- package/src/main/java/com/bitspur/keycloak/siwe/jpa/nonce/SiweNonce.java +95 -0
- package/src/main/java/com/bitspur/keycloak/siwe/jpa/nonce/SiweNonceJpaEntityProvider.java +82 -0
- package/src/main/java/com/bitspur/keycloak/siwe/jpa/nonce/SiweNonceJpaEntityProviderFactory.java +46 -0
- package/src/main/java/com/bitspur/keycloak/siwe/jpa/wallet/SiweWalletAddress.java +103 -0
- package/src/main/java/com/bitspur/keycloak/siwe/jpa/wallet/SiweWalletJpaEntityProvider.java +43 -0
- package/src/main/java/com/bitspur/keycloak/siwe/jpa/wallet/SiweWalletJpaEntityProviderFactory.java +46 -0
- package/src/main/java/com/bitspur/keycloak/siwe/protocol/SiweWalletProtocolMapper.java +85 -0
- package/src/main/java/com/bitspur/keycloak/siwe/resource/SiweResource.java +210 -0
- package/src/main/java/com/bitspur/keycloak/siwe/resource/SiweResourceProvider.java +34 -0
- package/src/main/java/com/bitspur/keycloak/siwe/resource/SiweResourceProviderFactory.java +46 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/SiuCredentials.java +52 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/SiuMessage.java +362 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/SiuParseException.java +23 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/SiuUtil.java +547 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/authenticators/browser/SiuBrowserAuthenticator.java +112 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/authenticators/browser/SiuBrowserAuthenticatorFactory.java +96 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/authenticators/directgrant/SiuDirectGrantAuthenticator.java +169 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/authenticators/directgrant/SiuDirectGrantAuthenticatorFactory.java +96 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/resource/SiuResource.java +244 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/resource/SiuResourceProvider.java +34 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siu/resource/SiuResourceProviderFactory.java +48 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/SiwsCredentials.java +52 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/SiwsMessage.java +362 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/SiwsParseException.java +23 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/SiwsUtil.java +564 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/authenticators/browser/SiwsBrowserAuthenticator.java +112 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/authenticators/browser/SiwsBrowserAuthenticatorFactory.java +96 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/authenticators/directgrant/SiwsDirectGrantAuthenticator.java +169 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/authenticators/directgrant/SiwsDirectGrantAuthenticatorFactory.java +96 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/resource/SiwsResource.java +244 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/resource/SiwsResourceProvider.java +34 -0
- package/src/main/java/com/bitspur/keycloak/siwe/siws/resource/SiwsResourceProviderFactory.java +48 -0
- package/src/main/resources/META-INF/keycloak-themes.json +8 -0
- package/src/main/resources/META-INF/services/org.keycloak.authentication.AuthenticatorFactory +6 -0
- package/src/main/resources/META-INF/services/org.keycloak.connections.jpa.entityprovider.JpaEntityProviderFactory +2 -0
- package/src/main/resources/META-INF/services/org.keycloak.protocol.ProtocolMapper +1 -0
- package/src/main/resources/META-INF/services/org.keycloak.services.resource.RealmResourceProviderFactory +3 -0
- package/src/main/resources/META-INF/siwe-nonce-changelog.xml +29 -0
- package/src/main/resources/META-INF/siwe-wallet-changelog.xml +46 -0
- package/src/render.tsx +47 -0
- package/src/siwe.tsx +57 -0
- package/src/types.ts +6 -0
- package/src/util.spec.ts +72 -0
- package/src/util.ts +28 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var base64_exports = {};
|
|
26
|
+
__export(base64_exports, {
|
|
27
|
+
encodeBase64: () => encodeBase64
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(base64_exports);
|
|
30
|
+
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
31
|
+
function encodeBytes(bytes) {
|
|
32
|
+
var output = "";
|
|
33
|
+
for (var i = 0; i < bytes.length; i += 3) {
|
|
34
|
+
var _bytes_i, _bytes_, _bytes_1;
|
|
35
|
+
var a = (_bytes_i = bytes[i]) !== null && _bytes_i !== void 0 ? _bytes_i : 0;
|
|
36
|
+
var b = (_bytes_ = bytes[i + 1]) !== null && _bytes_ !== void 0 ? _bytes_ : 0;
|
|
37
|
+
var c = (_bytes_1 = bytes[i + 2]) !== null && _bytes_1 !== void 0 ? _bytes_1 : 0;
|
|
38
|
+
var triple = a << 16 | b << 8 | c;
|
|
39
|
+
output += alphabet[triple >> 18 & 63];
|
|
40
|
+
output += alphabet[triple >> 12 & 63];
|
|
41
|
+
output += i + 1 < bytes.length ? alphabet[triple >> 6 & 63] : "=";
|
|
42
|
+
output += i + 2 < bytes.length ? alphabet[triple & 63] : "=";
|
|
43
|
+
}
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
function encodeBase64(input) {
|
|
47
|
+
if (typeof globalThis.btoa === "function") {
|
|
48
|
+
return globalThis.btoa(input);
|
|
49
|
+
}
|
|
50
|
+
if (typeof Buffer !== "undefined") {
|
|
51
|
+
return Buffer.from(input, "utf-8").toString("base64");
|
|
52
|
+
}
|
|
53
|
+
return encodeBytes(new TextEncoder().encode(input));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=base64.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","base64_exports","__export","encodeBase64","module","exports","alphabet","encodeBytes","bytes","output","i","length","_bytes_i","_bytes_","_bytes_1","a","b","c","triple","input","globalThis","btoa","Buffer","from","toString"],"sources":["../../src/base64.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,cAAA;AAAAC,QAAA,CAAAD,cAAA;EAAAE,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAM,CAAAC,OAAA,GAAWT,YAAA,CAAAK,cAAA;AAEjB,IAAAK,QAAS,qEAAuC;AAC9C,SAAIC,WAASA,CAAAC,KAAA;EACb,IAAAC,MAAS,GAAI;EACX,SAAMC,CAAA,GAAI,GAAAA,CAAA,GAAOF,KAAK,CAAAG,MAAA,EAAAD,CAAA;IACtB,IAAAE,QAAU,EAAAC,OAAW,EAAAC,QAAK;IAC1B,IAAAC,CAAA,GAAM,CAAAH,QAAU,GAAIJ,KAAC,CAAKE,CAAA,eAAAE,QAAA,cAAAA,QAAA;IAC1B,IAAAI,CAAA,GAAM,CAAAH,OAAU,GAAAL,KAAK,CAAOE,CAAA,IAAK,OAAK,QAAAG,OAAA,cAAAA,OAAA;IACtC,IAAAI,CAAA,IAAAH,QAAU,GAAUN,KAAA,CAAAE,CAAA,GAAU,QAAU,QAAAI,QAAA,cAAAA,QAAA;IACxC,IAAAI,MAAU,GAAAH,CAAA,MAAU,GAAAC,CAAA,KAAU,GAAAC,CAAA;IAC9BR,MAAA,IAAUH,QAAQ,CAAAY,MAAM,SAAS;IACjCT,MAAA,IAAUH,QAAQ,CAAAY,MAAM,SAAS;IACnCT,MAAA,IAAAC,CAAA,OAAAF,KAAA,CAAAG,MAAA,GAAAL,QAAA,CAAAY,MAAA;IACAT,MAAO,IAAAC,CAAA,OAAAF,KAAA,CAAAG,MAAA,GAAAL,QAAA,CAAAY,MAAA;EACT;EAEO,OAAST,MAAA;AACd;AACE,SAAAN,YAAOA,CAAWgB,KAAK;EACzB,WAAAC,UAAA,CAAAC,IAAA;IACA,OAAID,UAAO,CAAAC,IAAW,CAAAF,KAAA;EACpB;EACF,WAAAG,MAAA;IACA,OAAOA,MAAA,CAAAC,IAAY,CAAAJ,KAAI,SAAY,EAAEK,QAAO,SAAM;EACpD","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var import_vitest = require("vitest");
|
|
2
|
+
var import_base64 = require("./base64.cjs");
|
|
3
|
+
(0, import_vitest.describe)("encodeBase64", () => {
|
|
4
|
+
(0, import_vitest.afterEach)(() => {
|
|
5
|
+
import_vitest.vi.restoreAllMocks();
|
|
6
|
+
});
|
|
7
|
+
(0, import_vitest.it)("encodes an empty string", () => {
|
|
8
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("")).toBe("");
|
|
9
|
+
});
|
|
10
|
+
(0, import_vitest.it)("encodes a simple ASCII string", () => {
|
|
11
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("Hello")).toBe("SGVsbG8=");
|
|
12
|
+
});
|
|
13
|
+
(0, import_vitest.it)("encodes 'Hello, World!'", () => {
|
|
14
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("Hello, World!")).toBe("SGVsbG8sIFdvcmxkIQ==");
|
|
15
|
+
});
|
|
16
|
+
(0, import_vitest.it)("encodes a single character", () => {
|
|
17
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("A")).toBe("QQ==");
|
|
18
|
+
});
|
|
19
|
+
(0, import_vitest.it)("encodes two characters (padding = 1)", () => {
|
|
20
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("AB")).toBe("QUI=");
|
|
21
|
+
});
|
|
22
|
+
(0, import_vitest.it)("encodes three characters (no padding)", () => {
|
|
23
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("ABC")).toBe("QUJD");
|
|
24
|
+
});
|
|
25
|
+
(0, import_vitest.it)("encodes strings with special characters", () => {
|
|
26
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("foo:bar")).toBe("Zm9vOmJhcg==");
|
|
27
|
+
});
|
|
28
|
+
(0, import_vitest.it)("encodes strings with numbers", () => {
|
|
29
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("12345")).toBe("MTIzNDU=");
|
|
30
|
+
});
|
|
31
|
+
(0, import_vitest.it)("produces output matching btoa for ASCII input", () => {
|
|
32
|
+
const inputs = ["test", "a", "ab", "abc", "abcd", "Hello, World!", "base64 encoding test"];
|
|
33
|
+
for (const input of inputs) {
|
|
34
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)(input)).toBe(btoa(input));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
(0, import_vitest.it)("falls back to manual encoding when btoa is unavailable", () => {
|
|
38
|
+
const originalBtoa = globalThis.btoa;
|
|
39
|
+
import_vitest.vi.spyOn(globalThis, "btoa").mockImplementation(() => {
|
|
40
|
+
throw new Error("btoa not available");
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(globalThis, "btoa", {
|
|
43
|
+
value: void 0,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("Hello")).toBe("SGVsbG8=");
|
|
48
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("ABC")).toBe("QUJD");
|
|
49
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("")).toBe("");
|
|
50
|
+
} finally {
|
|
51
|
+
Object.defineProperty(globalThis, "btoa", {
|
|
52
|
+
value: originalBtoa,
|
|
53
|
+
configurable: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_base64 = require("./base64.native.js");
|
|
5
|
+
(0, import_vitest.describe)("encodeBase64", function () {
|
|
6
|
+
(0, import_vitest.afterEach)(function () {
|
|
7
|
+
import_vitest.vi.restoreAllMocks();
|
|
8
|
+
});
|
|
9
|
+
(0, import_vitest.it)("encodes an empty string", function () {
|
|
10
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("")).toBe("");
|
|
11
|
+
});
|
|
12
|
+
(0, import_vitest.it)("encodes a simple ASCII string", function () {
|
|
13
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("Hello")).toBe("SGVsbG8=");
|
|
14
|
+
});
|
|
15
|
+
(0, import_vitest.it)("encodes 'Hello, World!'", function () {
|
|
16
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("Hello, World!")).toBe("SGVsbG8sIFdvcmxkIQ==");
|
|
17
|
+
});
|
|
18
|
+
(0, import_vitest.it)("encodes a single character", function () {
|
|
19
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("A")).toBe("QQ==");
|
|
20
|
+
});
|
|
21
|
+
(0, import_vitest.it)("encodes two characters (padding = 1)", function () {
|
|
22
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("AB")).toBe("QUI=");
|
|
23
|
+
});
|
|
24
|
+
(0, import_vitest.it)("encodes three characters (no padding)", function () {
|
|
25
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("ABC")).toBe("QUJD");
|
|
26
|
+
});
|
|
27
|
+
(0, import_vitest.it)("encodes strings with special characters", function () {
|
|
28
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("foo:bar")).toBe("Zm9vOmJhcg==");
|
|
29
|
+
});
|
|
30
|
+
(0, import_vitest.it)("encodes strings with numbers", function () {
|
|
31
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("12345")).toBe("MTIzNDU=");
|
|
32
|
+
});
|
|
33
|
+
(0, import_vitest.it)("produces output matching btoa for ASCII input", function () {
|
|
34
|
+
var inputs = ["test", "a", "ab", "abc", "abcd", "Hello, World!", "base64 encoding test"];
|
|
35
|
+
var _iteratorNormalCompletion = true,
|
|
36
|
+
_didIteratorError = false,
|
|
37
|
+
_iteratorError = void 0;
|
|
38
|
+
try {
|
|
39
|
+
for (var _iterator = inputs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
40
|
+
var input = _step.value;
|
|
41
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)(input)).toBe(btoa(input));
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
_didIteratorError = true;
|
|
45
|
+
_iteratorError = err;
|
|
46
|
+
} finally {
|
|
47
|
+
try {
|
|
48
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
49
|
+
_iterator.return();
|
|
50
|
+
}
|
|
51
|
+
} finally {
|
|
52
|
+
if (_didIteratorError) {
|
|
53
|
+
throw _iteratorError;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
(0, import_vitest.it)("falls back to manual encoding when btoa is unavailable", function () {
|
|
59
|
+
var originalBtoa = globalThis.btoa;
|
|
60
|
+
import_vitest.vi.spyOn(globalThis, "btoa").mockImplementation(function () {
|
|
61
|
+
throw new Error("btoa not available");
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(globalThis, "btoa", {
|
|
64
|
+
value: void 0,
|
|
65
|
+
configurable: true
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("Hello")).toBe("SGVsbG8=");
|
|
69
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("ABC")).toBe("QUJD");
|
|
70
|
+
(0, import_vitest.expect)((0, import_base64.encodeBase64)("")).toBe("");
|
|
71
|
+
} finally {
|
|
72
|
+
Object.defineProperty(globalThis, "btoa", {
|
|
73
|
+
value: originalBtoa,
|
|
74
|
+
configurable: true
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=base64.spec.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["import_vitest","require","import_base64","describe","afterEach","vi","restoreAllMocks","it","expect","encodeBase64","toBe","inputs","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","input","value","btoa","err"],"sources":["../../src/base64.spec.ts"],"sourcesContent":[null],"mappings":"AAAA;;AACA,IAAAA,aAAA,GAA6BC,OAAA;AAAA,IAE7BC,aAAA,GAAAD,OAAA,CAAS;AACP,IAAAD,aAAA,CAAAG,QAAA,gBAAgB;EACd,IAAAH,aAAA,CAAAI,SAAG,cAAgB;IACpBJ,aAAA,CAAAK,EAAA,CAAAC,eAAA;EAED;EACE,IAAAN,aAAA,CAAAO,EAAA,2BAAO,cAAa;IACrB,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,OAAAC,IAAA;EAED;EACE,IAAAV,aAAA,CAAAO,EAAA,iCAAO,cAAa;IACrB,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,YAAAC,IAAA;EAED;EACE,IAAAV,aAAA,CAAAO,EAAA,2BAAO,cAAa;IACrB,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,oBAAAC,IAAA;EAED;EACE,IAAAV,aAAA,CAAAO,EAAA,8BAAO,cAAgB;IACxB,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,QAAAC,IAAA;EAED;EACE,IAAAV,aAAA,CAAAO,EAAA,wCAAoB,cAAY;IACjC,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,SAAAC,IAAA;EAED;EACE,IAAAV,aAAA,CAAAO,EAAA,yCAAoB,cAAa;IAClC,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,UAAAC,IAAA;EAED;EACE,IAAAV,aAAA,CAAAO,EAAA,2CAAoB,cAAY;IACjC,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,cAAAC,IAAA;EAED;EACE,IAAAV,aAAA,CAAAO,EAAA,gCAAO,cAAa;IACrB,IAAAP,aAAA,CAAAQ,MAAA,MAAAN,aAAA,CAAAO,YAAA,YAAAC,IAAA;EAED;EACE,IAAAV,aAAe,CAACO,EAAA,iDAAmD;IACnE,IAAAI,MAAA,GAAW,CACT,QACF,KACD,MAED,OACE,MAAM,EACN,eAAG,EACD,sBAAgB,CACjB;IAGD,IAAAC,yBAAsB,OAAY;MAAAC,iBAAiB,QAAW;MAAAC,cAAoB;IAElF,IAAI;MACF,SAAAC,SAAA,GAAAJ,MAAA,CAAAK,MAAO,CAAAC,QAAA,KAAAC,KAAA,IAAAN,yBAA4B,GAAU,CAAAM,KAAA,GAAAH,SAAA,CAAAI,IAAA,IAAAC,IAAA,GAAAR,yBAAA;QAC7C,IAAAS,KAAA,GAAAH,KAAA,CAAAI,KAAA;QACA,IAAAtB,aAAA,CAAAQ,MAAA,IAAO,EAAAN,aAAA,CAAAO,YAAa,EAAEY,KAAG,GAAKX,IAAE,CAAAa,IAAA,CAAAF,KAAA;MAClC;IACE,SAAOG,GAAA;MACTX,iBAAA;MACDC,cAAA,GAAAU,GAAA;IACF","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var context_exports = {};
|
|
24
|
+
__export(context_exports, {
|
|
25
|
+
SiweKeycloakContext: () => SiweKeycloakContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(context_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
const SiweKeycloakContext = (0, import_react.createContext)({});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var context_exports = {};
|
|
26
|
+
__export(context_exports, {
|
|
27
|
+
SiweKeycloakContext: () => SiweKeycloakContext
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(context_exports);
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var SiweKeycloakContext = (0, import_react.createContext)({});
|
|
32
|
+
//# sourceMappingURL=context.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","context_exports","__export","SiweKeycloakContext","module","exports","import_react","require","createContext"],"sources":["../../src/context.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC,QAAA,CAAAD,eAAA;EAAAE,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAA8B,CAAAK,eAAA;AAMvB,IAAAK,YAAM,GAAAC,OAAA,QAAsB;AAAA,IAChCJ,mBAAA,OAAAG,YAAA,CAAAE,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var context_exports = {};
|
|
24
|
+
__export(context_exports, {
|
|
25
|
+
SiweKeycloakContext: () => SiweKeycloakContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(context_exports);
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
const SiweKeycloakContext = (0, import_react.createContext)({});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var context_exports = {};
|
|
26
|
+
__export(context_exports, {
|
|
27
|
+
SiweKeycloakContext: () => SiweKeycloakContext
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(context_exports);
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var SiweKeycloakContext = (0, import_react.createContext)({});
|
|
32
|
+
//# sourceMappingURL=context.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","context_exports","__export","SiweKeycloakContext","module","exports","import_react","require","createContext"],"sources":["../../../src/hooks/context.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC,QAAA,CAAAD,eAAA;EAAAE,mBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAA8B,CAAAK,eAAA;AAMvB,IAAAK,YAAM,GAAAC,OAAA,QAAsB;AAAA,IAChCJ,mBAAA,OAAAG,YAAA,CAAAE,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
+
get: () => from[key],
|
|
9
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
}), mod);
|
|
18
|
+
var hooks_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
20
|
+
__reExport(hooks_exports, require("./useSiweKeycloak.cjs"), module.exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
+
value: true
|
|
19
|
+
}), mod);
|
|
20
|
+
var hooks_exports = {};
|
|
21
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
22
|
+
__reExport(hooks_exports, require("./useSiweKeycloak.native.js"), module.exports);
|
|
23
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","hooks_exports","module","exports"],"sources":["../../../src/hooks/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var useSiweKeycloak_exports = {};
|
|
24
|
+
__export(useSiweKeycloak_exports, {
|
|
25
|
+
useSiweKeycloak: () => useSiweKeycloak
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useSiweKeycloak_exports);
|
|
28
|
+
var import_connectkit = require("@multiplatform.one/web3/connectkit");
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_wagmi = require("wagmi");
|
|
31
|
+
var import_context = require("./context.cjs");
|
|
32
|
+
function useSiweKeycloak() {
|
|
33
|
+
const {
|
|
34
|
+
addresses
|
|
35
|
+
} = (0, import_wagmi.useAccount)();
|
|
36
|
+
const {
|
|
37
|
+
signOut
|
|
38
|
+
} = (0, import_connectkit.useSIWE)();
|
|
39
|
+
const {
|
|
40
|
+
openSIWE,
|
|
41
|
+
openSwitchNetworks,
|
|
42
|
+
openOnboarding,
|
|
43
|
+
openAbout,
|
|
44
|
+
openProfile
|
|
45
|
+
} = (0, import_connectkit.useModal)();
|
|
46
|
+
const {
|
|
47
|
+
keycloak
|
|
48
|
+
} = (0, import_react.useContext)(import_context.SiweKeycloakContext);
|
|
49
|
+
return {
|
|
50
|
+
signOut,
|
|
51
|
+
openSIWE,
|
|
52
|
+
openSwitchNetworks,
|
|
53
|
+
openOnboarding,
|
|
54
|
+
openAbout,
|
|
55
|
+
openProfile,
|
|
56
|
+
keycloak,
|
|
57
|
+
connect() {
|
|
58
|
+
if (!addresses?.length) openProfile();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var useSiweKeycloak_exports = {};
|
|
26
|
+
__export(useSiweKeycloak_exports, {
|
|
27
|
+
useSiweKeycloak: () => useSiweKeycloak
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(useSiweKeycloak_exports);
|
|
30
|
+
var import_connectkit = require("@multiplatform.one/web3/connectkit");
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_wagmi = require("wagmi");
|
|
33
|
+
var import_context = require("./context.native.js");
|
|
34
|
+
function useSiweKeycloak() {
|
|
35
|
+
var {
|
|
36
|
+
addresses
|
|
37
|
+
} = (0, import_wagmi.useAccount)();
|
|
38
|
+
var {
|
|
39
|
+
signOut
|
|
40
|
+
} = (0, import_connectkit.useSIWE)();
|
|
41
|
+
var {
|
|
42
|
+
openSIWE,
|
|
43
|
+
openSwitchNetworks,
|
|
44
|
+
openOnboarding,
|
|
45
|
+
openAbout,
|
|
46
|
+
openProfile
|
|
47
|
+
} = (0, import_connectkit.useModal)();
|
|
48
|
+
var {
|
|
49
|
+
keycloak
|
|
50
|
+
} = (0, import_react.useContext)(import_context.SiweKeycloakContext);
|
|
51
|
+
return {
|
|
52
|
+
signOut,
|
|
53
|
+
openSIWE,
|
|
54
|
+
openSwitchNetworks,
|
|
55
|
+
openOnboarding,
|
|
56
|
+
openAbout,
|
|
57
|
+
openProfile,
|
|
58
|
+
keycloak,
|
|
59
|
+
connect() {
|
|
60
|
+
if (!(addresses === null || addresses === void 0 ? void 0 : addresses.length)) openProfile();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=useSiweKeycloak.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useSiweKeycloak_exports","__export","useSiweKeycloak","module","exports","import_connectkit","require","import_react","import_wagmi","import_context","addresses","useAccount","signOut","useSIWE","openSIWE","openSwitchNetworks","openOnboarding","openAbout","openProfile","useModal","keycloak","useContext","SiweKeycloakContext","connect","length"],"sources":["../../../src/hooks/useSiweKeycloak.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,uBAAA;AAAAC,QAAA,CAAAD,uBAAA;EAAAE,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAkC,CAAAK,uBAAA;AAClC,IAAAK,iBAA2B,GAAAC,OAAA;AAC3B,IAAAC,YAAA,GAA2BD,OAAA;AAC3B,IAAAE,YAAA,GAAAF,OAAoC;AAE7B,IAAAG,cAAS,GAAAH,OAAkB;AAChC,SAAMJ,eAAYA,CAAA;EAClB;IAAMQ;EAAU,QAAIF,YAAA,CAAAG,UAAA;EACpB;IAAMC;EAAE,IAAU,IAAAP,iBAAoB,CAAAQ,OAAA;EACtC;IAAMC,QAAE;IAAAC,kBAAa;IAAAC,cAAW;IAAAC,SAAA;IAAAC;EAAA,QAAAb,iBAAmB,CAAAc,QAAA;EACnD;IAAAC;EAAO,QAAAb,YAAA,CAAAc,UAAA,EAAAZ,cAAA,CAAAa,mBAAA;EAAA,OACL;IACAV,OAAA;IACAE,QAAA;IACAC,kBAAA;IACAC,cAAA;IACAC,SAAA;IACAC,WAAA;IACAE,QAAA;IACEG,OAAKA,CAAA;MACP,MAAAb,SAAA,aAAAA,SAAA,uBAAAA,SAAA,CAAAc,MAAA,GAAAN,WAAA;IACF;EACF","ignoreList":[]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
22
|
+
value: true
|
|
23
|
+
}), mod);
|
|
24
|
+
var index_exports = {};
|
|
25
|
+
__export(index_exports, {
|
|
26
|
+
SiweKeycloak: () => SiweKeycloak
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
var import_render = require("./render.cjs");
|
|
30
|
+
var import_util = require("./util.cjs");
|
|
31
|
+
__reExport(index_exports, require("./SiweKeycloakProvider.cjs"), module.exports);
|
|
32
|
+
__reExport(index_exports, require("./hooks/index.cjs"), module.exports);
|
|
33
|
+
__reExport(index_exports, require("./types.cjs"), module.exports);
|
|
34
|
+
__reExport(index_exports, require("./util.cjs"), module.exports);
|
|
35
|
+
class SiweKeycloak {
|
|
36
|
+
_walletClientResolvers = [];
|
|
37
|
+
addresses = [];
|
|
38
|
+
client;
|
|
39
|
+
connect;
|
|
40
|
+
keycloakConfig;
|
|
41
|
+
openAbout;
|
|
42
|
+
openOnboarding;
|
|
43
|
+
openProfile;
|
|
44
|
+
openSIWE;
|
|
45
|
+
openSwitchNetworks;
|
|
46
|
+
signOut;
|
|
47
|
+
walletClient;
|
|
48
|
+
constructor(options) {
|
|
49
|
+
(0, import_render.render)({
|
|
50
|
+
...options,
|
|
51
|
+
onAddresses: addresses => {
|
|
52
|
+
this.addresses = addresses;
|
|
53
|
+
if (!addresses.length) this.walletClient = void 0;
|
|
54
|
+
options?.onAddresses?.(addresses);
|
|
55
|
+
},
|
|
56
|
+
onSetOpenAbout: openAbout => {
|
|
57
|
+
this.openAbout = openAbout;
|
|
58
|
+
},
|
|
59
|
+
onSetOpenOnboarding: openOnboarding => {
|
|
60
|
+
this.openOnboarding = openOnboarding;
|
|
61
|
+
},
|
|
62
|
+
onSetOpenProfile: openProfile => {
|
|
63
|
+
this.openProfile = this._asyncTrigger(openProfile);
|
|
64
|
+
},
|
|
65
|
+
onSetOpenSIWE: openSIWE => {
|
|
66
|
+
this.openSIWE = this._asyncTrigger(openSIWE);
|
|
67
|
+
},
|
|
68
|
+
onSetConnect: connect => {
|
|
69
|
+
this.connect = this._asyncTrigger(connect);
|
|
70
|
+
},
|
|
71
|
+
onSetOpenSwitchNetworks: openSwitchNetworks => {
|
|
72
|
+
this.openSwitchNetworks = openSwitchNetworks;
|
|
73
|
+
},
|
|
74
|
+
onSetSignOut: signOut => {
|
|
75
|
+
this.signOut = signOut;
|
|
76
|
+
},
|
|
77
|
+
onSetClient: client => {
|
|
78
|
+
this.client = client;
|
|
79
|
+
},
|
|
80
|
+
onSetWalletClient: walletClient => {
|
|
81
|
+
this.walletClient = walletClient;
|
|
82
|
+
if (walletClient) {
|
|
83
|
+
this._walletClientResolvers.forEach(resolve => resolve(null));
|
|
84
|
+
this._walletClientResolvers = [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
this.keycloakConfig = {
|
|
89
|
+
...options?.keycloak,
|
|
90
|
+
...(typeof options?.keycloak?.baseUrl !== "undefined" ? {
|
|
91
|
+
baseUrl: options?.keycloak?.baseUrl
|
|
92
|
+
} : {
|
|
93
|
+
baseUrl: "http://localhost:8080"
|
|
94
|
+
}),
|
|
95
|
+
...(typeof options?.keycloak?.clientId !== "undefined" ? {
|
|
96
|
+
clientId: options?.keycloak?.clientId
|
|
97
|
+
} : {
|
|
98
|
+
clientId: "app"
|
|
99
|
+
}),
|
|
100
|
+
...(typeof options?.keycloak?.realm !== "undefined" ? {
|
|
101
|
+
realm: options?.keycloak?.realm
|
|
102
|
+
} : {
|
|
103
|
+
realm: "main"
|
|
104
|
+
}),
|
|
105
|
+
...(typeof options?.keycloak?.scope !== "undefined" ? {
|
|
106
|
+
scope: options?.keycloak?.scope
|
|
107
|
+
} : {
|
|
108
|
+
scope: []
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
_asyncTrigger(trigger) {
|
|
113
|
+
return async (...args) => {
|
|
114
|
+
await new Promise((resolve, reject) => {
|
|
115
|
+
try {
|
|
116
|
+
this._walletClientResolvers.push(resolve);
|
|
117
|
+
trigger(...args);
|
|
118
|
+
if (this.walletClient) return resolve(null);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
reject(err);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async getNonce() {
|
|
126
|
+
return (0, import_util.getNonce)(`${this.keycloakConfig.baseUrl}/realms/${this.keycloakConfig.realm || "main"}/siwe`);
|
|
127
|
+
}
|
|
128
|
+
async createMessage(address) {
|
|
129
|
+
if (!this.client?.chain.id) return;
|
|
130
|
+
const nonce = await this.getNonce();
|
|
131
|
+
return (0, import_util.createMessage)(nonce, address, this.client.chain.id);
|
|
132
|
+
}
|
|
133
|
+
}
|