@ttoss/relay-amplify 0.6.12 → 0.6.13
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/esm/index.js +17 -12
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
4
|
+
value,
|
|
5
|
+
configurable: true
|
|
6
|
+
});
|
|
2
7
|
|
|
3
8
|
// src/index.ts
|
|
9
|
+
import { post } from "aws-amplify/api";
|
|
10
|
+
import { fetchAuthSession } from "aws-amplify/auth";
|
|
4
11
|
import { Environment, Network, RecordSource, Store } from "relay-runtime";
|
|
5
12
|
|
|
6
13
|
// src/encodeCredentials.ts
|
|
7
|
-
var encodeCredentials = credentials => {
|
|
14
|
+
var encodeCredentials = /* @__PURE__ */__name(credentials => {
|
|
8
15
|
return Buffer.from(JSON.stringify({
|
|
9
16
|
accessKeyId: credentials.accessKeyId,
|
|
10
17
|
secretAccessKey: credentials.secretAccessKey,
|
|
11
18
|
sessionToken: credentials.sessionToken
|
|
12
19
|
})).toString("base64");
|
|
13
|
-
};
|
|
14
|
-
var decodeCredentials = credentials => {
|
|
20
|
+
}, "encodeCredentials");
|
|
21
|
+
var decodeCredentials = /* @__PURE__ */__name(credentials => {
|
|
15
22
|
return JSON.parse(Buffer.from(credentials, "base64").toString("utf8"));
|
|
16
|
-
};
|
|
23
|
+
}, "decodeCredentials");
|
|
17
24
|
|
|
18
25
|
// src/index.ts
|
|
19
|
-
|
|
20
|
-
import { post } from "aws-amplify/api";
|
|
21
|
-
var fetchQuery = async (operation, variables) => {
|
|
26
|
+
var fetchQuery = /* @__PURE__ */__name(async (operation, variables) => {
|
|
22
27
|
let credentials;
|
|
23
28
|
try {
|
|
24
29
|
const authSession = await fetchAuthSession();
|
|
@@ -32,8 +37,8 @@ var fetchQuery = async (operation, variables) => {
|
|
|
32
37
|
authenticated: true
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
|
-
} catch (
|
|
36
|
-
console.error(
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(error?.message);
|
|
37
42
|
credentials = void 0;
|
|
38
43
|
}
|
|
39
44
|
try {
|
|
@@ -58,13 +63,13 @@ var fetchQuery = async (operation, variables) => {
|
|
|
58
63
|
}
|
|
59
64
|
throw error;
|
|
60
65
|
}
|
|
61
|
-
};
|
|
62
|
-
var createEnvironment = ({
|
|
66
|
+
}, "fetchQuery");
|
|
67
|
+
var createEnvironment = /* @__PURE__ */__name(({
|
|
63
68
|
storeOptions
|
|
64
69
|
}) => {
|
|
65
70
|
return new Environment({
|
|
66
71
|
network: Network.create(fetchQuery),
|
|
67
72
|
store: new Store(new RecordSource(), storeOptions)
|
|
68
73
|
});
|
|
69
|
-
};
|
|
74
|
+
}, "createEnvironment");
|
|
70
75
|
export { createEnvironment, decodeCredentials, encodeCredentials, fetchQuery };
|