@kubun/credential 0.17.1 → 0.17.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.
- package/lib/api.js +5 -1
- package/lib/provider.js +6 -0
- package/lib/refreshing-credential-provider.js +2 -1
- package/lib/validate.js +6 -0
- package/package.json +4 -4
package/lib/api.js
CHANGED
|
@@ -171,7 +171,11 @@ export function createCredentialAPI(params) {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
assertValidCredentialShape(parsed);
|
|
174
|
-
const result = await store.bindAliasIfAbsent(
|
|
174
|
+
const result = await store.bindAliasIfAbsent({
|
|
175
|
+
namespace: providerName,
|
|
176
|
+
aliasKey: owner,
|
|
177
|
+
entryID
|
|
178
|
+
});
|
|
175
179
|
if (result === 'inserted') return;
|
|
176
180
|
if (result === 'entry-missing') {
|
|
177
181
|
throw new CredentialNotFound('Credential entry', entryID);
|
package/lib/provider.js
CHANGED
|
@@ -15,6 +15,9 @@ export function serializeCredential(credential) {
|
|
|
15
15
|
if (credential.metadata != null) {
|
|
16
16
|
serialized.metadata = credential.metadata;
|
|
17
17
|
}
|
|
18
|
+
if (credential.providerAccount != null) {
|
|
19
|
+
serialized.providerAccount = credential.providerAccount;
|
|
20
|
+
}
|
|
18
21
|
return JSON.stringify(serialized);
|
|
19
22
|
}
|
|
20
23
|
export function deserializeCredential(raw) {
|
|
@@ -36,6 +39,9 @@ export function deserializeCredential(raw) {
|
|
|
36
39
|
if (parsed.metadata != null) {
|
|
37
40
|
credential.metadata = parsed.metadata;
|
|
38
41
|
}
|
|
42
|
+
if (parsed.providerAccount != null) {
|
|
43
|
+
credential.providerAccount = parsed.providerAccount;
|
|
44
|
+
}
|
|
39
45
|
return credential;
|
|
40
46
|
}
|
|
41
47
|
export class DBCredentialProvider {
|
|
@@ -146,7 +146,8 @@ export class RefreshingCredentialProvider {
|
|
|
146
146
|
expiresAt: tokenData.expires_in != null ? new Date(Date.now() + tokenData.expires_in * 1000) : undefined,
|
|
147
147
|
scopes: tokenData.scope?.split(' ') ?? credential.scopes,
|
|
148
148
|
accountLabel: credential.accountLabel,
|
|
149
|
-
metadata: credential.metadata
|
|
149
|
+
metadata: credential.metadata,
|
|
150
|
+
providerAccount: credential.providerAccount
|
|
150
151
|
};
|
|
151
152
|
let write;
|
|
152
153
|
try {
|
package/lib/validate.js
CHANGED
|
@@ -27,4 +27,10 @@ export function assertValidCredentialShape(value) {
|
|
|
27
27
|
if (c.metadata != null && (typeof c.metadata !== 'object' || Array.isArray(c.metadata))) {
|
|
28
28
|
throw new CredentialInvalidEntry('metadata must be an object when present');
|
|
29
29
|
}
|
|
30
|
+
if (c.providerAccount != null) {
|
|
31
|
+
const pa = c.providerAccount;
|
|
32
|
+
if (typeof pa !== 'object' || Array.isArray(c.providerAccount) || typeof pa.iss !== 'string' || pa.iss.length === 0 || typeof pa.sub !== 'string' || pa.sub.length === 0) {
|
|
33
|
+
throw new CredentialInvalidEntry('providerAccount must have non-empty string iss and sub when present');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
30
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/credential",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@kokuin/jwe": "^0.1.0",
|
|
19
|
-
"@kokuin/oauth": "^0.1.
|
|
19
|
+
"@kokuin/oauth": "^0.1.1",
|
|
20
20
|
"@kokuin/token": "^0.5.0",
|
|
21
|
-
"@kubun/credential-types": "^0.17.
|
|
21
|
+
"@kubun/credential-types": "^0.17.2",
|
|
22
22
|
"@kubun/db": "^0.17.0",
|
|
23
23
|
"@kubun/hlc": "^0.17.0",
|
|
24
24
|
"@kubun/id": "^0.17.0",
|
|
25
25
|
"@kubun/logger": "^0.17.0",
|
|
26
|
-
"@kubun/store-credential": "^0.17.
|
|
26
|
+
"@kubun/store-credential": "^0.17.4",
|
|
27
27
|
"@noble/ciphers": "^2.4.0",
|
|
28
28
|
"@noble/hashes": "^2.4.0",
|
|
29
29
|
"@sozai/codec": "^0.4.0",
|