@kokuin/expo 0.1.0 → 0.1.1
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/lib/identity.js +14 -13
- package/package.json +4 -3
package/lib/identity.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { createTracer, KokuinAttributeKeys, KokuinSpanNames } from '@kokuin/otel';
|
|
1
2
|
import { createFullIdentity } from '@kokuin/token';
|
|
2
3
|
import { getLogger } from '@sozai/log';
|
|
3
|
-
import {
|
|
4
|
+
import { withSpan, withSyncSpan } from '@sozai/otel';
|
|
4
5
|
import { ExpoKeyStore } from './store.js';
|
|
5
6
|
const tracer = createTracer('keystore.expo');
|
|
6
7
|
const logger = getLogger([
|
|
@@ -8,23 +9,23 @@ const logger = getLogger([
|
|
|
8
9
|
'expo'
|
|
9
10
|
]);
|
|
10
11
|
export function provideFullIdentity(keyID) {
|
|
11
|
-
return withSyncSpan(tracer,
|
|
12
|
+
return withSyncSpan(tracer, KokuinSpanNames.KEYSTORE_GET_OR_CREATE, {
|
|
12
13
|
attributes: {
|
|
13
|
-
[
|
|
14
|
+
[KokuinAttributeKeys.KEYSTORE_STORE_TYPE]: 'expo'
|
|
14
15
|
}
|
|
15
16
|
}, (span)=>{
|
|
16
17
|
const entry = ExpoKeyStore.entry(keyID);
|
|
17
18
|
const existing = entry.get();
|
|
18
19
|
if (existing != null) {
|
|
19
20
|
const identity = createFullIdentity(existing);
|
|
20
|
-
span.setAttribute(
|
|
21
|
-
span.setAttribute(
|
|
21
|
+
span.setAttribute(KokuinAttributeKeys.AUTH_DID, identity.id);
|
|
22
|
+
span.setAttribute(KokuinAttributeKeys.KEYSTORE_KEY_CREATED, false);
|
|
22
23
|
return identity;
|
|
23
24
|
}
|
|
24
25
|
const key = entry.provide();
|
|
25
26
|
const identity = createFullIdentity(key);
|
|
26
|
-
span.setAttribute(
|
|
27
|
-
span.setAttribute(
|
|
27
|
+
span.setAttribute(KokuinAttributeKeys.AUTH_DID, identity.id);
|
|
28
|
+
span.setAttribute(KokuinAttributeKeys.KEYSTORE_KEY_CREATED, true);
|
|
28
29
|
logger.info('New identity generated: {did}', {
|
|
29
30
|
did: identity.id
|
|
30
31
|
});
|
|
@@ -32,23 +33,23 @@ export function provideFullIdentity(keyID) {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
export async function provideFullIdentityAsync(keyID) {
|
|
35
|
-
return withSpan(tracer,
|
|
36
|
+
return withSpan(tracer, KokuinSpanNames.KEYSTORE_GET_OR_CREATE, {
|
|
36
37
|
attributes: {
|
|
37
|
-
[
|
|
38
|
+
[KokuinAttributeKeys.KEYSTORE_STORE_TYPE]: 'expo'
|
|
38
39
|
}
|
|
39
40
|
}, async (span)=>{
|
|
40
41
|
const entry = ExpoKeyStore.entry(keyID);
|
|
41
42
|
const existing = await entry.getAsync();
|
|
42
43
|
if (existing != null) {
|
|
43
44
|
const identity = createFullIdentity(existing);
|
|
44
|
-
span.setAttribute(
|
|
45
|
-
span.setAttribute(
|
|
45
|
+
span.setAttribute(KokuinAttributeKeys.AUTH_DID, identity.id);
|
|
46
|
+
span.setAttribute(KokuinAttributeKeys.KEYSTORE_KEY_CREATED, false);
|
|
46
47
|
return identity;
|
|
47
48
|
}
|
|
48
49
|
const key = await entry.provideAsync();
|
|
49
50
|
const identity = createFullIdentity(key);
|
|
50
|
-
span.setAttribute(
|
|
51
|
-
span.setAttribute(
|
|
51
|
+
span.setAttribute(KokuinAttributeKeys.AUTH_DID, identity.id);
|
|
52
|
+
span.setAttribute(KokuinAttributeKeys.KEYSTORE_KEY_CREATED, true);
|
|
52
53
|
logger.info('New identity generated: {did}', {
|
|
53
54
|
did: identity.id
|
|
54
55
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kokuin/expo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Key store for React Native",
|
|
6
6
|
"keywords": [
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@sozai/codec": "^0.1.0",
|
|
30
30
|
"@sozai/log": "^0.1.0",
|
|
31
|
-
"@sozai/otel": "^0.
|
|
31
|
+
"@sozai/otel": "^0.2.0",
|
|
32
32
|
"expo-crypto": "^56.0.4",
|
|
33
33
|
"expo-secure-store": "^56.0.4",
|
|
34
|
-
"@kokuin/
|
|
34
|
+
"@kokuin/otel": "^0.1.0",
|
|
35
|
+
"@kokuin/token": "^0.1.1"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"build:clean": "del lib",
|