@workos-inc/node 7.74.2 → 7.75.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/audit-logs/audit-logs.js +2 -2
- package/lib/common/crypto/crypto-provider.d.ts +6 -0
- package/lib/common/crypto/crypto-provider.spec.js +37 -0
- package/lib/common/crypto/node-crypto-provider.d.ts +1 -0
- package/lib/common/crypto/node-crypto-provider.js +3 -0
- package/lib/common/crypto/subtle-crypto-provider.d.ts +1 -0
- package/lib/common/crypto/subtle-crypto-provider.js +14 -0
- package/lib/user-management/interfaces/authentication-response.interface.d.ts +1 -1
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.AuditLogs = void 0;
|
|
13
|
-
const crypto_1 = require("crypto");
|
|
14
13
|
const serializers_1 = require("./serializers");
|
|
15
14
|
class AuditLogs {
|
|
16
15
|
constructor(workos) {
|
|
@@ -19,7 +18,8 @@ class AuditLogs {
|
|
|
19
18
|
createEvent(organization, event, options = {}) {
|
|
20
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
20
|
// Auto-generate idempotency key if not provided
|
|
22
|
-
const optionsWithIdempotency = Object.assign(Object.assign({}, options), { idempotencyKey: options.idempotencyKey ||
|
|
21
|
+
const optionsWithIdempotency = Object.assign(Object.assign({}, options), { idempotencyKey: options.idempotencyKey ||
|
|
22
|
+
`workos-node-${this.workos.getCryptoProvider().randomUUID()}` });
|
|
23
23
|
yield this.workos.post('/audit_logs/events', {
|
|
24
24
|
event: (0, serializers_1.serializeCreateAuditLogEventOptions)(event),
|
|
25
25
|
organization_id: organization,
|
|
@@ -62,4 +62,10 @@ export declare abstract class CryptoProvider {
|
|
|
62
62
|
* @returns A Uint8Array containing the random bytes
|
|
63
63
|
*/
|
|
64
64
|
abstract randomBytes(length: number): Uint8Array;
|
|
65
|
+
/**
|
|
66
|
+
* Generates a random UUID v4 string.
|
|
67
|
+
*
|
|
68
|
+
* @returns A UUID v4 string in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
|
|
69
|
+
*/
|
|
70
|
+
abstract randomUUID(): string;
|
|
65
71
|
}
|
|
@@ -54,4 +54,41 @@ describe('CryptoProvider', () => {
|
|
|
54
54
|
expect(nodeCryptoProvider.secureCompare(signature, 'foo')).toEqual(subtleCryptoProvider.secureCompare(signature, 'foo'));
|
|
55
55
|
}));
|
|
56
56
|
});
|
|
57
|
+
describe('when generating UUIDs', () => {
|
|
58
|
+
const UUID_V4_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
59
|
+
it('generates valid UUID v4 format for NodeCryptoProvider', () => {
|
|
60
|
+
const nodeCryptoProvider = new node_crypto_provider_1.NodeCryptoProvider();
|
|
61
|
+
const uuid = nodeCryptoProvider.randomUUID();
|
|
62
|
+
expect(uuid).toMatch(UUID_V4_REGEX);
|
|
63
|
+
});
|
|
64
|
+
it('generates valid UUID v4 format for SubtleCryptoProvider', () => {
|
|
65
|
+
const subtleCryptoProvider = new subtle_crypto_provider_1.SubtleCryptoProvider();
|
|
66
|
+
const uuid = subtleCryptoProvider.randomUUID();
|
|
67
|
+
expect(uuid).toMatch(UUID_V4_REGEX);
|
|
68
|
+
});
|
|
69
|
+
it('generates unique UUIDs', () => {
|
|
70
|
+
const nodeCryptoProvider = new node_crypto_provider_1.NodeCryptoProvider();
|
|
71
|
+
const subtleCryptoProvider = new subtle_crypto_provider_1.SubtleCryptoProvider();
|
|
72
|
+
const uuids = new Set([
|
|
73
|
+
nodeCryptoProvider.randomUUID(),
|
|
74
|
+
nodeCryptoProvider.randomUUID(),
|
|
75
|
+
subtleCryptoProvider.randomUUID(),
|
|
76
|
+
subtleCryptoProvider.randomUUID(),
|
|
77
|
+
]);
|
|
78
|
+
expect(uuids.size).toBe(4);
|
|
79
|
+
});
|
|
80
|
+
it('SubtleCryptoProvider falls back when crypto.randomUUID is unavailable', () => {
|
|
81
|
+
const originalRandomUUID = globalThis.crypto.randomUUID;
|
|
82
|
+
// @ts-ignore - intentionally removing for test
|
|
83
|
+
delete globalThis.crypto.randomUUID;
|
|
84
|
+
try {
|
|
85
|
+
const subtleCryptoProvider = new subtle_crypto_provider_1.SubtleCryptoProvider();
|
|
86
|
+
const uuid = subtleCryptoProvider.randomUUID();
|
|
87
|
+
expect(uuid).toMatch(UUID_V4_REGEX);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
globalThis.crypto.randomUUID = originalRandomUUID;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
57
94
|
});
|
|
@@ -16,4 +16,5 @@ export declare class NodeCryptoProvider extends CryptoProvider {
|
|
|
16
16
|
}>;
|
|
17
17
|
decrypt(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, tag: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
18
18
|
randomBytes(length: number): Uint8Array;
|
|
19
|
+
randomUUID(): string;
|
|
19
20
|
}
|
|
@@ -105,5 +105,8 @@ class NodeCryptoProvider extends crypto_provider_1.CryptoProvider {
|
|
|
105
105
|
randomBytes(length) {
|
|
106
106
|
return new Uint8Array(crypto.randomBytes(length));
|
|
107
107
|
}
|
|
108
|
+
randomUUID() {
|
|
109
|
+
return crypto.randomUUID();
|
|
110
|
+
}
|
|
108
111
|
}
|
|
109
112
|
exports.NodeCryptoProvider = NodeCryptoProvider;
|
|
@@ -19,4 +19,5 @@ export declare class SubtleCryptoProvider extends CryptoProvider {
|
|
|
19
19
|
}>;
|
|
20
20
|
decrypt(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, tag: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
|
|
21
21
|
randomBytes(length: number): Uint8Array;
|
|
22
|
+
randomUUID(): string;
|
|
22
23
|
}
|
|
@@ -113,6 +113,20 @@ class SubtleCryptoProvider extends crypto_provider_1.CryptoProvider {
|
|
|
113
113
|
crypto.getRandomValues(bytes);
|
|
114
114
|
return bytes;
|
|
115
115
|
}
|
|
116
|
+
randomUUID() {
|
|
117
|
+
if (typeof crypto !== 'undefined' &&
|
|
118
|
+
typeof crypto.randomUUID === 'function') {
|
|
119
|
+
return crypto.randomUUID();
|
|
120
|
+
}
|
|
121
|
+
// Fallback for environments without crypto.randomUUID
|
|
122
|
+
const bytes = this.randomBytes(16);
|
|
123
|
+
// tslint:disable-next-line:no-bitwise
|
|
124
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
|
|
125
|
+
// tslint:disable-next-line:no-bitwise
|
|
126
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80; // variant
|
|
127
|
+
const hex = Array.from(bytes, (b) => byteHexMapping[b]).join('');
|
|
128
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
129
|
+
}
|
|
116
130
|
}
|
|
117
131
|
exports.SubtleCryptoProvider = SubtleCryptoProvider;
|
|
118
132
|
// Cached mapping of byte to hex representation. We do this once to avoid re-
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Impersonator, ImpersonatorResponse } from './impersonator.interface';
|
|
2
2
|
import { OauthTokens, OauthTokensResponse } from './oauth-tokens.interface';
|
|
3
3
|
import { User, UserResponse } from './user.interface';
|
|
4
|
-
type AuthenticationMethod = 'SSO' | 'Password' | 'Passkey' | 'AppleOAuth' | 'GitHubOAuth' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'SalesforceOAuth' | 'MagicAuth' | 'Impersonation';
|
|
4
|
+
type AuthenticationMethod = 'SSO' | 'Password' | 'Passkey' | 'AppleOAuth' | 'BitbucketOAuth' | 'GitHubOAuth' | 'GitLabOAuth' | 'GoogleOAuth' | 'LinkedInOAuth' | 'MicrosoftOAuth' | 'SalesforceOAuth' | 'VercelOAuth' | 'MagicAuth' | 'CrossAppAuth' | 'Impersonation';
|
|
5
5
|
export interface AuthenticationResponse {
|
|
6
6
|
user: User;
|
|
7
7
|
organizationId?: string;
|
package/lib/workos.js
CHANGED
|
@@ -33,7 +33,7 @@ const actions_1 = require("./actions/actions");
|
|
|
33
33
|
const vault_1 = require("./vault/vault");
|
|
34
34
|
const conflict_exception_1 = require("./common/exceptions/conflict.exception");
|
|
35
35
|
const parse_error_1 = require("./common/exceptions/parse-error");
|
|
36
|
-
const VERSION = '7.
|
|
36
|
+
const VERSION = '7.75.1';
|
|
37
37
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
38
38
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
39
39
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
package/package.json
CHANGED